:root {
  --oz-bg: #0f172a;
  --oz-surface: #111827;
  --oz-surface-2: #1f2937;
  --oz-surface-3: #0b1220;
  --oz-text: #e5e7eb;
  --oz-muted: #94a3b8;
  --oz-primary: #2563eb;
  --oz-success: #16a34a;
  --oz-danger: #dc2626;
  --oz-warning: #f59e0b;
  --oz-border: rgba(148, 163, 184, 0.18);
  --oz-shadow: 0 12px 32px rgba(2, 6, 23, 0.35);
}

body {
  background: linear-gradient(180deg, #0b1020 0%, #0f172a 100%);
  color: var(--oz-text);
  min-height: 100vh;
}

body.light-mode {
  --oz-bg: #f3f4f6;
  --oz-surface: #ffffff;
  --oz-surface-2: #f8fafc;
  --oz-surface-3: #eef2f7;
  --oz-text: #111827;
  --oz-muted: #64748b;
  --oz-border: rgba(15, 23, 42, 0.08);
  --oz-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
  background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
}

/* Розовая */
body.theme-rose {
  --oz-bg: #fff0f3;
  --oz-surface: #fff5f7;
  --oz-surface-2: #ffe4ea;
  --oz-surface-3: #ffd6df;
  --oz-text: #3d1a22;
  --oz-muted: #9e6472;
  --oz-border: rgba(180, 80, 100, 0.15);
  --oz-shadow: 0 10px 28px rgba(180, 80, 100, 0.08);
  background: linear-gradient(180deg, #fff0f3 0%, #ffe4ea 100%);
}

/* Мятная */
body.theme-mint {
  --oz-bg: #f0faf5;
  --oz-surface: #f5fdf8;
  --oz-surface-2: #e0f5ea;
  --oz-surface-3: #cceedd;
  --oz-text: #1a3d2b;
  --oz-muted: #4d8c6a;
  --oz-border: rgba(40, 140, 90, 0.15);
  --oz-shadow: 0 10px 28px rgba(40, 140, 90, 0.08);
  background: linear-gradient(180deg, #f0faf5 0%, #e0f5ea 100%);
}

/* Голубая */
body.theme-sky {
  --oz-bg: #f0f7ff;
  --oz-surface: #f5faff;
  --oz-surface-2: #e0efff;
  --oz-surface-3: #cce4ff;
  --oz-text: #1a2d3d;
  --oz-muted: #4d7a9e;
  --oz-border: rgba(40, 100, 160, 0.15);
  --oz-shadow: 0 10px 28px rgba(40, 100, 160, 0.08);
  background: linear-gradient(180deg, #f0f7ff 0%, #e0efff 100%);
}

/* Лавандовая */
body.theme-lavender {
  --oz-bg: #f5f0ff;
  --oz-surface: #faf5ff;
  --oz-surface-2: #ede0ff;
  --oz-surface-3: #e0ccff;
  --oz-text: #2d1a3d;
  --oz-muted: #7a4d9e;
  --oz-border: rgba(100, 40, 160, 0.15);
  --oz-shadow: 0 10px 28px rgba(100, 40, 160, 0.08);
  background: linear-gradient(180deg, #f5f0ff 0%, #ede0ff 100%);
}

/* Персиковая */
body.theme-peach {
  --oz-bg: #fff7f0;
  --oz-surface: #fffaf5;
  --oz-surface-2: #ffede0;
  --oz-surface-3: #ffe0cc;
  --oz-text: #3d2010;
  --oz-muted: #9e6440;
  --oz-border: rgba(180, 100, 40, 0.15);
  --oz-shadow: 0 10px 28px rgba(180, 100, 40, 0.08);
  background: linear-gradient(180deg, #fff7f0 0%, #ffede0 100%);
}

/* Тёмная розовая */
body.theme-dark-rose {
  --oz-bg: #1a0a0e;
  --oz-surface: #221014;
  --oz-surface-2: #2e151b;
  --oz-surface-3: #180810;
  --oz-text: #f5d0d8;
  --oz-muted: #b07080;
  --oz-border: rgba(200, 80, 110, 0.18);
  --oz-shadow: 0 12px 32px rgba(80, 10, 20, 0.4);
  background: linear-gradient(180deg, #180810 0%, #1a0a0e 100%);
}

/* Тёмная мятная */
body.theme-dark-mint {
  --oz-bg: #071410;
  --oz-surface: #0c1e18;
  --oz-surface-2: #122a20;
  --oz-surface-3: #051008;
  --oz-text: #c8f0e0;
  --oz-muted: #5a9e80;
  --oz-border: rgba(40, 160, 100, 0.18);
  --oz-shadow: 0 12px 32px rgba(5, 30, 18, 0.4);
  background: linear-gradient(180deg, #051008 0%, #071410 100%);
}

/* Тёмная голубая */
body.theme-dark-sky {
  --oz-bg: #070e1a;
  --oz-surface: #0c1525;
  --oz-surface-2: #121e30;
  --oz-surface-3: #050a14;
  --oz-text: #c8dff5;
  --oz-muted: #5a80a8;
  --oz-border: rgba(40, 100, 180, 0.18);
  --oz-shadow: 0 12px 32px rgba(5, 15, 40, 0.4);
  background: linear-gradient(180deg, #050a14 0%, #070e1a 100%);
}

/* Тёмная лавандовая */
body.theme-dark-lavender {
  --oz-bg: #0e0714;
  --oz-surface: #150c1e;
  --oz-surface-2: #1e1228;
  --oz-surface-3: #0a0510;
  --oz-text: #e0d0f5;
  --oz-muted: #8060a8;
  --oz-border: rgba(120, 60, 200, 0.18);
  --oz-shadow: 0 12px 32px rgba(20, 5, 40, 0.4);
  background: linear-gradient(180deg, #0a0510 0%, #0e0714 100%);
}

/* Тёмная персиковая */
body.theme-dark-peach {
  --oz-bg: #1a0e07;
  --oz-surface: #22140a;
  --oz-surface-2: #2e1c10;
  --oz-surface-3: #180a05;
  --oz-text: #f5dfc8;
  --oz-muted: #a07050;
  --oz-border: rgba(180, 100, 40, 0.18);
  --oz-shadow: 0 12px 32px rgba(50, 20, 5, 0.4);
  background: linear-gradient(180deg, #180a05 0%, #1a0e07 100%);
}

.app-shell {
  min-height: 100vh;
}

.statusbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--oz-border);
}

body.light-mode .statusbar,
body.theme-rose .statusbar,
body.theme-mint .statusbar,
body.theme-sky .statusbar,
body.theme-lavender .statusbar,
body.theme-peach .statusbar {
  background: rgba(255, 255, 255, 0.88);
}

body.theme-dark-rose .statusbar,
body.theme-dark-mint .statusbar,
body.theme-dark-sky .statusbar,
body.theme-dark-lavender .statusbar,
body.theme-dark-peach .statusbar {
  background: rgba(10, 5, 8, 0.88);
}

.brand-button {
  border: 1px solid var(--oz-border);
  background: var(--oz-surface);
  color: var(--oz-text);
  border-radius: 1rem;
  padding: 0.9rem 1rem;
  text-align: left;
  width: 100%;
  box-shadow: var(--oz-shadow);
}

.brand-button:hover {
  border-color: rgba(37, 99, 235, 0.45);
}

.brand-title {
  font-size: 1rem;
  font-weight: 700;
}

.brand-subtitle {
  font-size: 0.85rem;
  color: var(--oz-muted);
}

.control-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.surface-card,
.device-card,
.info-card,
.modal-content {
  background: var(--oz-surface);
  color: var(--oz-text);
  border: 1px solid var(--oz-border);
  box-shadow: var(--oz-shadow);
}

.modal-content {
  border-radius: 1rem;
}

.modal-header,
.modal-footer {
  border-color: var(--oz-border);
}

.section-title {
  font-size: 1.05rem;
  font-weight: 700;
}

.section-subtitle {
  color: var(--oz-muted);
  font-size: 0.9rem;
}

.summary-card {
  border-radius: 1rem;
  padding: 1rem;
}

.summary-value {
  font-size: 1.3rem;
  font-weight: 700;
}

.summary-label {
  color: var(--oz-muted);
  font-size: 0.86rem;
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1rem;
}

.device-card {
  border-radius: 1rem;
  padding: 1rem;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.device-card:hover {
  transform: translateY(-2px);
  border-color: rgba(37, 99, 235, 0.5);
}

.device-card.offline {
  opacity: 0.72;
  border-color: rgba(220, 38, 38, 0.35);
}

.device-card.unreachable {
  border-color: rgba(245, 158, 11, 0.45);
}

.device-card.loading {
  pointer-events: none;
  opacity: 0.7;
}

.device-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
}

.device-name {
  font-weight: 700;
  font-size: 1rem;
}

.device-ip {
  color: var(--oz-muted);
  font-size: 0.82rem;
  word-break: break-word;
}

.status-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.online {
  background: var(--oz-success);
}
.status-dot.offline {
  background: var(--oz-danger);
}
.status-dot.warning {
  background: var(--oz-warning);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.device-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.device-actions .btn {
  flex: 1 1 0;
}

.metric-item {
  background: var(--oz-surface-2);
  border: 1px solid var(--oz-border);
  border-radius: 0.8rem;
  padding: 0.75rem;
}

.metric-name {
  font-size: 0.75rem;
  color: var(--oz-muted);
  margin-bottom: 0.2rem;
}

.metric-value {
  font-weight: 600;
  font-size: 0.92rem;
  word-break: break-word;
}

.metric-value.text-danger-soft {
  color: #fca5a5;
}

.metric-value.text-warning-soft {
  color: #fcd34d;
}

.device-note {
  margin-top: 0.85rem;
  padding: 0.75rem 0.85rem;
  border-radius: 0.8rem;
  background: rgba(148, 163, 184, 0.07);
  border: 1px solid var(--oz-border);
  color: var(--oz-muted);
  font-size: 0.82rem;
}

.device-note.warning {
  border-color: rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.08);
  color: #fcd34d;
}

.device-note.danger {
  border-color: rgba(220, 38, 38, 0.3);
  background: rgba(220, 38, 38, 0.08);
  color: #fca5a5;
}

.list-panel {
  background: var(--oz-surface-2);
  border: 1px solid var(--oz-border);
  border-radius: 1rem;
  padding: 0.75rem;
  max-height: 65vh;
  overflow: auto;
}

.preset-device-group + .preset-device-group {
  margin-top: 1rem;
}

.preset-device-title {
  font-size: 0.92rem;
  color: var(--oz-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

.preset-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--oz-border);
  background: var(--oz-surface);
  color: var(--oz-text);
  border-radius: 0.8rem;
  padding: 0.65rem 0.8rem;
}

.preset-item.active,
.preset-item:hover {
  border-color: rgba(37, 99, 235, 0.5);
  background: rgba(37, 99, 235, 0.12);
}

.form-panel {
  background: var(--oz-surface-2);
  border: 1px solid var(--oz-border);
  border-radius: 1rem;
  padding: 1rem;
}

.form-label,
.form-check-label,
.form-text,
.small-muted {
  color: var(--oz-muted);
}

.form-control,
.form-select,
.form-control:focus,
.form-select:focus,
.form-control[readonly] {
  background: var(--oz-surface-3);
  color: var(--oz-text);
  border-color: var(--oz-border);
}

.form-control:disabled,
.form-select:disabled,
body.dark-mode .form-control:disabled,
body.dark-mode .form-select:disabled {
  background: #172033;
  color: #94a3b8;
  border-color: rgba(148, 163, 184, 0.16);
  opacity: 1;
  -webkit-text-fill-color: #94a3b8;
}

body.light-mode .form-control:disabled,
body.light-mode .form-select:disabled,
body.theme-rose .form-control:disabled,
body.theme-rose .form-select:disabled,
body.theme-mint .form-control:disabled,
body.theme-mint .form-select:disabled,
body.theme-sky .form-control:disabled,
body.theme-sky .form-select:disabled,
body.theme-lavender .form-control:disabled,
body.theme-lavender .form-select:disabled,
body.theme-peach .form-control:disabled,
body.theme-peach .form-select:disabled {
  background: #e5e7eb;
  color: #64748b;
  border-color: rgba(15, 23, 42, 0.1);
}

.form-control::placeholder {
  color: #7c8aa0;
}

.btn-outline-surface {
  border-color: var(--oz-border);
  color: var(--oz-text);
}

.btn-outline-surface:hover {
  background: var(--oz-surface-2);
  color: var(--oz-text);
}

.badge-soft {
  background: rgba(148, 163, 184, 0.15);
  color: var(--oz-text);
  border: 1px solid var(--oz-border);
}

.loading-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--oz-border);
  background: var(--oz-surface-2);
  color: var(--oz-text);
  font-size: 0.84rem;
}

.loading-spinner {
  width: 0.95rem;
  height: 0.95rem;
  border: 2px solid rgba(148, 163, 184, 0.25);
  border-top-color: var(--oz-primary);
  border-radius: 50%;
  animation: ozone-spin 0.75s linear infinite;
}

@keyframes ozone-spin {
  to {
    transform: rotate(360deg);
  }
}

body.busy [data-busy-action] {
  pointer-events: none;
  opacity: 0.6;
}

.toast-container {
  z-index: 1080;
}

.toast {
  background: var(--oz-surface) !important;
  color: var(--oz-text) !important;
  border: 1px solid var(--oz-border) !important;
  box-shadow: var(--oz-shadow);
}

.toast .toast-body {
  color: var(--oz-text) !important;
}

.btn-close {
  filter: invert(1);
}

body.light-mode .btn-close,
body.theme-rose .btn-close,
body.theme-mint .btn-close,
body.theme-sky .btn-close,
body.theme-lavender .btn-close,
body.theme-peach .btn-close {
  filter: none;
}

.metric-item-tx.tx-on {
  border-color: rgba(22, 163, 74, 0.35);
  background: rgba(22, 163, 74, 0.08);
}

.metric-item-tx.tx-off {
  border-color: rgba(220, 38, 38, 0.25);
  background: rgba(220, 38, 38, 0.06);
}

.kv-row-action {
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
}

.kv-row-action:hover {
  border-color: rgba(37, 99, 235, 0.5);
  background: rgba(37, 99, 235, 0.08);
}

.metric-item-action {
  cursor: pointer;
}

.metric-item-action:hover {
  border-color: rgba(37, 99, 235, 0.5);
  background: rgba(37, 99, 235, 0.08);
}

.toast .btn-close {
  filter: invert(1);
}

body.light-mode .toast .btn-close,
body.theme-rose .toast .btn-close,
body.theme-mint .toast .btn-close,
body.theme-sky .toast .btn-close,
body.theme-lavender .toast .btn-close,
body.theme-peach .toast .btn-close {
  filter: none;
}

.empty-state {
  border: 1px dashed var(--oz-border);
  border-radius: 1rem;
  padding: 2rem 1rem;
  color: var(--oz-muted);
  text-align: center;
  background: rgba(148, 163, 184, 0.04);
}

.kv-list {
  display: grid;
  gap: 0.75rem;
}

.kv-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 0.85rem;
  border: 1px solid var(--oz-border);
  background: var(--oz-surface-2);
}

.kv-key {
  color: var(--oz-muted);
  font-size: 0.85rem;
}

.kv-value {
  font-weight: 600;
  text-align: right;
  word-break: break-word;
}

.notification-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: var(--oz-surface-2);
  color: var(--oz-muted);
  border: 1px solid var(--oz-border);
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.1rem;
  text-align: center;
  pointer-events: none;
}

.notification-row {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.55rem 0.75rem;
  border-radius: 0.7rem;
  border: 1px solid var(--oz-border);
  background: var(--oz-surface-2);
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
}

.notification-row-success {
  border-left: 3px solid var(--oz-success);
}
.notification-row-danger {
  border-left: 3px solid var(--oz-danger);
}
.notification-row-warning {
  border-left: 3px solid var(--oz-warning);
}
.notification-row-info {
  border-left: 3px solid var(--oz-primary);
}

.notification-time {
  color: var(--oz-muted);
  font-size: 0.78rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.notification-msg {
  color: var(--oz-text);
  word-break: break-word;
}

@media (max-width: 991.98px) {
  .control-bar {
    justify-content: stretch;
  }

  .control-bar .btn {
    flex: 1 1 auto;
  }
}

@media (max-width: 767.98px) {
  .statusbar {
    position: sticky;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .device-grid {
    grid-template-columns: 1fr;
  }

  .modal-dialog.modal-fullscreen-sm-down .modal-content {
    border-radius: 0;
  }
}

/* Notification bell button */
.notification-bell-btn {
  padding: 0.45rem 0.65rem;
  line-height: 1;
}

/* Summary card — presets shortcut */
.summary-card-presets {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
  text-align: center;
}

.summary-card-presets:hover {
  border-color: rgba(37, 99, 235, 0.5);
  background: rgba(37, 99, 235, 0.08);
}

.summary-card-presets:focus {
  outline: 2px solid var(--oz-primary);
  outline-offset: 2px;
}

.summary-presets-icon {
  color: var(--oz-muted);
  margin-bottom: 0.15rem;
}

.summary-sep {
  color: var(--oz-muted);
  font-weight: 400;
  font-size: 1rem;
}

/* Footer */
.app-footer {
  border-top: 1px solid var(--oz-border);
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  padding: 0.75rem 0;
  text-align: center;
}

body.light-mode .app-footer,
body.theme-rose .app-footer,
body.theme-mint .app-footer,
body.theme-sky .app-footer,
body.theme-lavender .app-footer,
body.theme-peach .app-footer {
  background: rgba(255, 255, 255, 0.7);
}

body.theme-dark-rose .app-footer,
body.theme-dark-mint .app-footer,
body.theme-dark-sky .app-footer,
body.theme-dark-lavender .app-footer,
body.theme-dark-peach .app-footer {
  background: rgba(10, 5, 8, 0.7);
}
