/* ==========================================================================
   Supervision — design system
   Dark "cockpit" theme by default, light theme via [data-theme="light"].
   ========================================================================== */

:root {
  --font-sans: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;

  --accent: #4f8cff;
  --accent-strong: #6ea4ff;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --teal: #2dd4bf;
  --success: #34d399;
  --warn: #f5b544;
  --danger: #f87171;

  --ok-bg: rgba(52, 211, 153, 0.12);
  --warn-bg: rgba(245, 181, 68, 0.13);
  --danger-bg: rgba(248, 113, 113, 0.12);
  --accent-bg: rgba(79, 140, 255, 0.13);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);

  --sidebar-w: 268px;
  --topbar-h: 74px;

  --transition: 160ms ease;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #080c12;
  --bg-elev: #0d131b;
  --surface: #111923;
  --surface-2: #16202b;
  --surface-3: #1c2835;
  --border: #22303f;
  --border-soft: #1a2532;
  --text: #e9eff7;
  --text-muted: #93a5b9;
  --text-dim: #6c8095;
  --input-bg: #0c131b;
  --hover: rgba(255, 255, 255, 0.04);
  --chart-grid: rgba(147, 165, 185, 0.14);
  --chart-axis: #93a5b9;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f6fa;
  --bg-elev: #eef2f8;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef3f9;
  --border: #dde5ef;
  --border-soft: #e8eef6;
  --text: #0f1b2a;
  --text-muted: #5d6f83;
  --text-dim: #7d8ea1;
  --input-bg: #ffffff;
  --hover: rgba(15, 27, 42, 0.035);
  --chart-grid: rgba(93, 111, 131, 0.16);
  --chart-axis: #5d6f83;
  --shadow-sm: 0 1px 2px rgba(16, 34, 56, 0.08);
  --shadow: 0 14px 34px rgba(16, 34, 56, 0.10);
}

/* ── Reset ─────────────────────────────────────────────────────────────── */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p, dl, dd, dt, ul, ol {
  margin: 0;
}

ul, ol {
  padding: 0;
  list-style: none;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-strong);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

[hidden] {
  display: none !important;
}

::selection {
  background: var(--accent-soft);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ── Layout ────────────────────────────────────────────────────────────── */

.app-body {
  min-height: 100vh;
  background:
    radial-gradient(1100px 600px at 8% -10%, rgba(79, 140, 255, 0.10), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(45, 212, 191, 0.06), transparent 55%),
    var(--bg);
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  height: 100vh;
  padding: 20px 16px 16px;
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  border-right: 1px solid var(--border-soft);
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 20px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--teal));
  box-shadow: 0 6px 18px rgba(79, 140, 255, 0.35);
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-name {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.brand-sub {
  font-size: 11.5px;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  flex: 1;
  padding-top: 4px;
}

.nav-section {
  padding: 16px 10px 6px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: 9px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}

.nav-link:hover {
  color: var(--text);
  background: var(--hover);
}

.nav-link.is-active {
  color: var(--text);
  background: var(--accent-soft);
}

.nav-link.is-active::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 50%;
  width: 3px;
  height: 20px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
  transform: translateY(-50%);
}

.nav-link.is-active .icon {
  color: var(--accent);
}

.icon {
  flex: 0 0 auto;
  display: inline-block;
  vertical-align: middle;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 11px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 50%;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  background: linear-gradient(135deg, #4f8cff, #7c5cff);
}

.avatar-sm {
  width: 32px;
  height: 32px;
  flex-basis: 32px;
  font-size: 11.5px;
}

.sidebar-user-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-mail {
  font-size: 11.5px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-overlay {
  display: none;
}

.main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: var(--topbar-h);
  padding: 14px 32px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--border-soft);
  backdrop-filter: blur(14px);
}

.topbar-title {
  flex: 1;
  min-width: 0;
}

.topbar-title h1 {
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.topbar-title p {
  font-size: 12.5px;
  margin-top: 1px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-form {
  display: inline;
  margin: 0;
}

.content {
  width: 100%;
  max-width: 1520px;
  margin: 0 auto;
  padding: 28px 32px 56px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.muted {
  color: var(--text-muted);
}

/* ── Buttons / controls ───────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition);
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #3b6fe0);
  box-shadow: 0 6px 16px rgba(79, 140, 255, 0.28);
}

.btn-primary:hover {
  color: #fff;
  background: linear-gradient(135deg, var(--accent-strong), #4a7ff0);
}

.btn-ghost {
  color: var(--text-muted);
  background: transparent;
  border-color: var(--border);
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--hover);
}

.btn-danger {
  color: #fff;
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

.btn-danger:hover {
  color: #fff;
  background: #ef4444;
}

.btn-danger-ghost {
  color: var(--danger);
  background: transparent;
  border-color: color-mix(in srgb, var(--danger) 32%, transparent);
}

.btn-danger-ghost:hover {
  background: var(--danger-bg);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 7px;
}

.btn-block {
  width: 100%;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}

.icon-btn:hover {
  color: var(--text);
  background: var(--hover);
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: inherit;
  font-weight: 500;
  cursor: pointer;
}

.link-btn:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.lang-switch a {
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

.lang-switch a:hover {
  color: var(--text);
}

.lang-switch a.is-active {
  color: var(--text);
  background: var(--surface-3);
}

[data-theme="dark"] .theme-icon-moon,
[data-theme="light"] .theme-icon-sun {
  display: none;
}

.menu-btn {
  display: none;
}

/* ── Cards ────────────────────────────────────────────────────────────── */

.card {
  padding: 20px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.card-head h2 {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.card-head p {
  font-size: 12.5px;
  margin-top: 2px;
}

.card-lead {
  margin: -6px 0 16px;
  font-size: 13px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.kpi-card {
  position: relative;
  overflow: hidden;
}

.kpi-card::after {
  content: "";
  position: absolute;
  inset: auto -30% -70% auto;
  width: 170px;
  height: 170px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft), transparent 70%);
  pointer-events: none;
}

.kpi-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.kpi-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--accent);
  background: var(--accent-soft);
}

.kpi-label {
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 30px;
  font-weight: 650;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.kpi-value-sm {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.kpi-value.is-muted {
  color: var(--text-dim);
}

.kpi-hint {
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--text-dim);
}

.charts-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 16px;
}

.chart-card {
  min-width: 0;
}

.chart {
  width: 100%;
  height: 300px;
}

.chart-note {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-soft);
  font-size: 11.5px;
  color: var(--text-dim);
}

.lower-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 16px;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

/* ── Badges / pills ───────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.03em;
  line-height: 1.5;
  white-space: nowrap;
}

.badge-accent {
  color: var(--accent);
  background: var(--accent-bg);
}

.badge-ok {
  color: var(--success);
  background: var(--ok-bg);
}

.badge-warn {
  color: var(--warn);
  background: var(--warn-bg);
}

.badge-danger {
  color: var(--danger);
  background: var(--danger-bg);
}

.badge-muted {
  color: var(--text-muted);
  background: var(--surface-3);
}

.code-pill {
  display: inline-block;
  padding: 2px 7px;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
}

/* ── Forms ────────────────────────────────────────────────────────────── */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.field-hint {
  font-size: 11.5px;
  color: var(--text-dim);
}

.input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input::placeholder {
  color: var(--text-dim);
}

.input:hover {
  border-color: color-mix(in srgb, var(--border) 60%, var(--text-muted));
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.form-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: flex-start;
}

.form-grid .field {
  width: 100%;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  background: var(--surface-2);
  cursor: pointer;
}

.check-row input {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.check-label {
  display: block;
  font-size: 13px;
  font-weight: 550;
}

/* ── Tables ───────────────────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  margin: 0 -20px -20px;
  padding: 0 20px 20px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  text-align: left;
  color: var(--text-dim);
  white-space: nowrap;
}

.table td {
  padding: 12px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover td {
  background: var(--hover);
}

.table-compact td {
  padding: 9px 12px;
}

.th-actions,
.cell-actions {
  text-align: right;
  white-space: nowrap;
}

.cell-actions .btn {
  margin-left: 4px;
}

.cell-strong {
  font-weight: 600;
}

.is-dimmed {
  opacity: 0.55;
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-cell-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-cell-text .muted {
  font-size: 11.5px;
}

/* ── Lists / details ──────────────────────────────────────────────────── */

.detail-list {
  display: flex;
  flex-direction: column;
}

.detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
}

.detail-row:last-child {
  border-bottom: 0;
}

.detail-row dt {
  font-size: 12.5px;
  color: var(--text-muted);
}

.detail-row dd {
  font-size: 13px;
  font-weight: 500;
  text-align: right;
  word-break: break-word;
}

.activity-list {
  display: flex;
  flex-direction: column;
  margin: -4px 0 -8px;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft);
}

.activity-item:last-child {
  border-bottom: 0;
}

.activity-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.activity-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.activity-action {
  font-size: 12.5px;
  font-weight: 550;
}

.activity-meta {
  font-size: 11px;
  color: var(--text-dim);
}

.activity-time {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}

.quick-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.quick-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--transition), border-color var(--transition);
}

.quick-link:hover {
  color: var(--text);
  background: var(--hover);
  border-color: var(--border-soft);
}

.quick-link .icon:last-child {
  margin-left: auto;
  color: var(--text-dim);
}

.quick-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: 8px;
  color: var(--accent);
  background: var(--accent-soft);
}

.check-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.check-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.check-list li .icon {
  color: var(--success);
}

/* ── Empty / placeholder ──────────────────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  text-align: center;
}

.empty-state-sm {
  padding: 26px 20px;
}

.empty-state p {
  font-size: 13px;
  max-width: 420px;
}

.placeholder-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 32px;
  text-align: center;
}

.placeholder-icon {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  margin-bottom: 16px;
  border-radius: 18px;
  color: var(--accent);
  background: var(--accent-soft);
}

.placeholder-card h2 {
  margin-top: 12px;
  font-size: 19px;
  letter-spacing: -0.015em;
}

.placeholder-lead {
  max-width: 560px;
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 13.5px;
}

.placeholder-card .check-list {
  width: 100%;
  max-width: 460px;
  text-align: left;
}

/* ── Alerts / toasts ──────────────────────────────────────────────────── */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 12.5px;
}

.alert-error {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: color-mix(in srgb, var(--danger) 25%, transparent);
}

.alert-warn {
  color: var(--warn);
  background: var(--warn-bg);
  border-color: color-mix(in srgb, var(--warn) 25%, transparent);
}

.alert .icon {
  margin-top: 1px;
}

.toasts {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(380px, calc(100vw - 44px));
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: toast-in 180ms ease;
}

.toast-ok {
  border-color: color-mix(in srgb, var(--success) 32%, transparent);
}

.toast-error {
  border-color: color-mix(in srgb, var(--danger) 32%, transparent);
}

.toast .icon {
  color: var(--success);
}

.toast-error .icon {
  color: var(--danger);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Modals ───────────────────────────────────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 14, 0.66);
  backdrop-filter: blur(3px);
}

.modal-panel {
  position: relative;
  width: min(520px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: modal-in 160ms ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
}

.modal-head h2 {
  font-size: 15.5px;
  font-weight: 650;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
}

.modal-body .alert {
  margin-bottom: 2px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-soft);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.modal-identity {
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  font-size: 12.5px;
  color: var(--text-muted);
  word-break: break-all;
}

.copy-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.copy-row .input {
  font-family: var(--font-mono);
  font-size: 12px;
}

.code-input {
  background: var(--surface-2);
}

/* ── Code blocks / endpoints ──────────────────────────────────────────── */

.code-block {
  overflow-x: auto;
  margin: 10px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  background: var(--bg-elev);
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--text-muted);
}

.endpoint-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 20px;
}

.endpoint {
  padding: 16px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.endpoint-head {
  display: flex;
  align-items: center;
  gap: 9px;
}

.endpoint-path {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.method {
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.method-get {
  color: var(--teal);
  background: rgba(45, 212, 191, 0.12);
}

.method-post {
  color: var(--accent);
  background: var(--accent-soft);
}

.endpoint p {
  margin-top: 8px;
  font-size: 12.5px;
}

/* ── Auth pages ───────────────────────────────────────────────────────── */

.auth-body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background:
    radial-gradient(800px 500px at 20% 0%, rgba(79, 140, 255, 0.12), transparent 60%),
    radial-gradient(700px 500px at 90% 100%, rgba(45, 212, 191, 0.08), transparent 55%),
    var(--bg);
}

.auth-controls {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 18px 22px;
}

.auth-wrap {
  display: grid;
  place-items: center;
  flex: 1;
  padding: 20px 20px 90px;
}

.auth-card {
  width: min(392px, 100%);
  padding: 32px 30px 28px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: var(--shadow);
}

.auth-card-wide {
  width: min(460px, 100%);
}

.auth-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin-bottom: 18px;
  border-radius: 13px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}

.auth-mark-warn {
  color: var(--warn);
  background: var(--warn-bg);
  border-color: color-mix(in srgb, var(--warn) 22%, transparent);
}

.auth-card h1 {
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.auth-lead {
  margin-top: 7px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 20px;
}

.auth-form .btn-block {
  margin-top: 4px;
}

.auth-form + .alert {
  margin-top: 16px;
}

.auth-card > .alert {
  margin-top: 16px;
}

.auth-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
  text-align: center;
  font-size: 12.5px;
}

/* ── Error pages ──────────────────────────────────────────────────────── */

.error-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 56px 32px;
  text-align: center;
}

.error-code {
  font-size: 64px;
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 1;
  color: var(--accent);
  opacity: 0.35;
}

.error-card h2 {
  margin-top: 12px;
  font-size: 20px;
}

.error-card p {
  margin-top: 6px;
  max-width: 420px;
  font-size: 13.5px;
}

.error-card .btn {
  margin-top: 20px;
}

/* ── Scrollbars ───────────────────────────────────────────────────────── */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

*::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

*::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 8px;
  background: var(--border);
  background-clip: content-box;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

/* ── Responsive ───────────────────────────────────────────────────────── */

@media (max-width: 1240px) {
  .charts-grid,
  .lower-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1080px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .two-col {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    transform: translateX(-102%);
    transition: transform 200ms ease;
    box-shadow: var(--shadow);
  }

  .sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(4, 8, 14, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
  }

  .sidebar-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .menu-btn {
    display: inline-grid;
  }

  .topbar {
    padding: 12px 20px;
  }

  .content {
    padding: 22px 20px 48px;
  }
}

@media (max-width: 720px) {
  .topbar-title p {
    display: none;
  }

  .topbar-title h1 {
    font-size: 17px;
  }

  .topbar-actions .lang-switch {
    display: none;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 16px;
  }

  .table-wrap {
    margin: 0 -16px -16px;
    padding: 0 16px 16px;
  }

  .btn-sm .icon + span {
    display: none;
  }

  .chart {
    height: 250px;
  }
}

/* ── Monitoring additions ─────────────────────────────────────────────── */

.kpi-value.is-danger {
  color: var(--danger);
}

.kpi-value.is-warn {
  color: var(--warn);
}

.chart-lg {
  height: 380px;
}

.room-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.room-grid-wide {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.room-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
}

.room-card:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  background: var(--surface-3);
  transform: translateY(-1px);
}

.room-card-head {
  display: flex;
  align-items: center;
  gap: 9px;
}

.room-card-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--accent);
  background: var(--accent-soft);
}

.room-card-name {
  font-weight: 650;
  font-size: 14px;
}

.room-card-meta {
  font-size: 11.5px;
  color: var(--text-dim);
}

.room-card-stats {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.room-card-stats strong {
  color: var(--text);
  font-size: 15px;
}

.room-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 2px;
}

.collector-list {
  display: flex;
  flex-direction: column;
}

.collector-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-soft);
}

.collector-item:last-child {
  border-bottom: 0;
}

.collector-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px var(--ok-bg);
}

.collector-dot.is-stale {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-bg);
}

.collector-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.collector-body .muted {
  font-size: 11.5px;
}

.activity-dot.is-danger {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-bg);
}

.unit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.unit-card {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: hidden;
}

.unit-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--border-soft);
}

.unit-card-title {
  font-weight: 650;
  font-size: 14px;
  color: var(--text);
}

.unit-card-title:hover {
  color: var(--accent);
}

.unit-card-head .muted {
  font-size: 11px;
  margin-top: 2px;
}

.unit-card-foot {
  padding: 8px 14px;
  border-top: 1px solid var(--border-soft);
  font-size: 12px;
}

.table-tight td {
  padding: 7px 12px;
  font-size: 12px;
}

.table-tight td .muted {
  font-size: 10.5px;
}

.cell-right {
  text-align: right;
  white-space: nowrap;
}

.range-switch {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.range-btn {
  padding: 4px 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.range-btn:hover {
  color: var(--text);
  background: var(--hover);
}

.range-btn.is-active {
  color: var(--text);
  background: var(--surface-3);
}

.inline-edit {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.input-sm {
  width: 160px;
  padding: 6px 9px;
  font-size: 12px;
}

.form-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.form-row .field {
  min-width: 120px;
  flex: 1;
}

.form-grid-inline {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
}

.form-grid-inline .field {
  width: auto;
  min-width: 150px;
  flex: 1;
}

.action-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hierarchy-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hierarchy-location {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
}

.hierarchy-location-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-soft);
}

.hierarchy-location-head .muted {
  flex: 1;
  font-size: 11.5px;
}

.hierarchy-rooms {
  display: flex;
  flex-direction: column;
}

.hierarchy-room {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border-soft);
}

.hierarchy-room:last-child {
  border-bottom: 0;
}

.hierarchy-room-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
}

.hierarchy-room-head .muted {
  font-size: 11.5px;
}

.hierarchy-room-units {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  flex: 1;
  font-size: 11.5px;
}

.table td form.form-row {
  min-width: 420px;
}

@media (max-width: 720px) {
  .chart-lg {
    height: 280px;
  }

  .room-grid,
  .room-grid-wide,
  .unit-grid {
    grid-template-columns: 1fr;
  }

  .hierarchy-room {
    align-items: flex-start;
    flex-direction: column;
  }

  .hierarchy-room-head {
    min-width: 0;
    width: 100%;
  }

  .form-row {
    flex-direction: column;
    align-items: stretch;
  }

  .inline-edit {
    display: flex;
    width: 100%;
  }

  .input-sm {
    width: 100%;
  }
}

.mt-12 { margin-top: 12px; }

.hierarchy-edit {
  flex: 1;
  min-width: 260px;
}

.hierarchy-edit .input-sm {
  width: 150px;
}

.hierarchy-room-head {
  flex-wrap: wrap;
}

/* Sparklines and chart series picker */
.chart-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.series-picker {
  margin-bottom: 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: hidden;
}

.series-picker > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  list-style: none;
}

.series-picker > summary::-webkit-details-marker {
  display: none;
}

.series-picker > summary:hover {
  color: var(--text);
  background: var(--hover);
}

.series-picker-body {
  padding: 0 12px 12px;
  border-top: 1px solid var(--border-soft);
}

.series-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 10px 0 8px;
}

.series-search {
  width: 220px;
  margin-right: auto;
}

.series-groups {
  max-height: 230px;
  overflow-y: auto;
  padding-right: 4px;
}

.series-group {
  padding: 5px 0;
  border-top: 1px solid var(--border-soft);
}

.series-group:first-child {
  border-top: 0;
}

.series-group-name {
  padding: 2px 4px 3px;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.series-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 5px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
}

.series-item:hover {
  color: var(--text);
  background: var(--hover);
}

.series-item input {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
}

.series-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.series-item .muted {
  font-size: 10.5px;
}

.spark-cell {
  width: 78px;
  padding-left: 4px !important;
  padding-right: 4px !important;
}

.spark {
  display: block;
  width: 72px;
  height: 18px;
  color: var(--accent);
  opacity: 0.9;
}

.spark path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  vector-effect: non-scaling-stroke;
}

.spark-alarm {
  color: var(--warn);
}

.spark-error {
  color: var(--danger);
}

.unit-grid {
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
}

@media (max-width: 720px) {
  .chart-tools {
    width: 100%;
    justify-content: flex-start;
  }

  .series-search {
    width: 100%;
  }

  .series-groups {
    max-height: 190px;
  }

  .spark-cell {
    width: 60px;
  }

  .spark {
    width: 54px;
  }
}

.row-clickable {
  cursor: pointer;
}

.row-clickable:hover td {
  background: var(--hover);
}

.row-clickable.is-selected td {
  background: var(--accent-soft);
}

.row-hint {
  display: inline-block;
  margin-left: 4px;
  color: var(--text-dim);
  opacity: 0.35;
  vertical-align: middle;
}

.row-clickable:hover .row-hint {
  color: var(--accent);
  opacity: 1;
}

.modal-panel-wide {
  width: min(920px, 100%);
}

.chart-modal {
  height: 360px;
}

@media (max-width: 720px) {
  .chart-modal {
    height: 260px;
  }
}


.row-open {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 22px;
  margin-left: 4px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--text-dim);
  opacity: 0.55;
  cursor: pointer;
  vertical-align: middle;
}

.row-open:hover {
  color: var(--accent);
  border-color: var(--border);
  background: var(--surface-2);
  opacity: 1;
}

.row-clickable.is-selected .row-open {
  color: var(--accent);
  opacity: 1;
}


.sidebar-version {
  padding: 10px 8px 2px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  text-align: right;
}

/* Compact hierarchy */
.page-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.site-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.site-block {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: hidden;
}

.site-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface);
}

.site-identity h3 {
  font-size: 14.5px;
  font-weight: 650;
}

.site-identity p {
  margin-top: 2px;
  font-size: 11.5px;
}

.site-actions,
.site-room-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.site-rooms {
  display: flex;
  flex-direction: column;
  padding: 4px 15px 12px;
}

.site-room {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
}

.site-room:last-of-type {
  border-bottom: 0;
}

.site-room-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex-wrap: wrap;
}

.site-room-main .muted {
  font-size: 11.5px;
}

.site-room-senders {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.site-add-room {
  align-self: flex-start;
  margin-top: 6px;
}

.hierarchy-details > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.hierarchy-details > summary::-webkit-details-marker {
  display: none;
}

.hierarchy-details[open] > summary {
  margin-bottom: 12px;
}

.hierarchy-details .table-wrap {
  margin-bottom: -8px;
}

@media (max-width: 720px) {
  .page-actions {
    justify-content: stretch;
  }

  .page-actions .btn {
    flex: 1;
  }

  .site-head,
  .site-room {
    flex-direction: column;
    align-items: stretch;
  }

  .site-actions,
  .site-room-actions {
    justify-content: flex-end;
  }
}


.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Filter bars ───────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface-2);
}

.field-inline {
  flex-direction: column;
  min-width: 170px;
}

.field-inline .field-label {
  font-size: 11.5px;
}

.filter-count {
  margin-left: auto;
  font-size: 12px;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .field-inline {
    flex: 1 1 100%;
  }

  .filter-count {
    margin-left: 0;
    width: 100%;
  }
}

@media (max-width: 720px) {
  .th-actions,
  .cell-actions {
    white-space: normal;
  }

  .cell-actions .btn {
    margin: 0 4px 4px 0;
  }
}

.alert-muted {
  color: var(--text-muted);
  background: var(--surface-2);
  border-color: var(--border-soft);
}

.admin-ip-bans .alert {
  margin-bottom: 12px;
}
