:root {
  /* Design tokens - one system for every page; the brief's names are in
     brackets. Every colour carries a meaning: blue is primary/interactive,
     green healthy, amber warning, red critical, cyan informational, and
     everything structural is neutral slate. The "as text" shades are the
     ones that read on white (>= 4.5:1); the brighter brief colours are the
     FILL shades for dots, bars, chips and buttons. */
  --bg: #F4F7FB;            /* BACKGROUND - cool enough for white cards to stand out */
  --bg-2: #F4F7FB;
  --surface: #FFFFFF;       /* CARD */
  --card-hover: #F8FAFC;
  --border: #DCE3EC;        /* BORDER */
  --border-strong: #64748B; /* a form field's boundary */
  --text: #172033;          /* TEXT */
  --text-muted: #64748B;    /* MUTED */
  --text-faint: #94A3B8;    /* decoration only: separators, dividers */
  --accent: #2563EB;        /* PRIMARY */
  --accent-soft: #EFF6FF;
  --info-fill: #06B6D4;     /* INFO */
  --success: #15803D;       /* SUCCESS as text */
  --success-fill: #16A34A;  /* SUCCESS */
  --warn: #B45309;          /* WARNING as text */
  --warn-fill: #F59E0B;     /* WARNING */
  --danger: #B91C1C;        /* CRITICAL as text (the fill red is 3.9:1 on a soft red chip) */
  --danger-fill: #DC2626;   /* CRITICAL */
  --radius: 10px;
  --page-glow: rgba(37,99,235,.05);
  /* The selected sidebar item: soft blue wash, primary text, accent bar. */
  --nav-active-bg: #EFF6FF;
  --nav-active-text: #2563EB;

  --table-head-bg: #F4F7FB;
  --table-head-text: #475569;
  --row-hover: #F4F7FB;
  /* A second surface tone: search field, round buttons, admin panels, hover rows. */
  --surface-2: #F4F7FB;
  /* Text on a filled accent / status colour (buttons, active tabs, count bubbles). */
  --on-accent: #ffffff;
  --on-color: #ffffff;
  /* The white panel the Best Brains logo is drawn on: the same in every theme. */
  --logo-chip: #ffffff;
  /* Faint washes over warning / critical cards and chips. */
  --warn-wash: rgba(245,158,11,.09);
  --danger-wash: rgba(220,38,38,.06);
  --accent-glow: rgba(37,99,235,.12);
  --shadow-sm: 0 1px 2px rgba(23,32,51,.05);
  --shadow-md: 0 8px 24px rgba(23,32,51,.12);
  --shadow-drawer: 2px 0 16px rgba(0,0,0,.18);
  --overlay: rgba(23,32,51,.45);
  --scrim: rgba(23,32,51,.35);
  color-scheme: light;

  /* The sidebar: white, bordered, so it reads as a panel rather than blending into the page. */
  --topbar-bg: #FFFFFF;
  --topbar-border: #DCE3EC;
  --topbar-text: #172033;
  --topbar-muted: #64748B;
  --topbar-hover: #F4F7FB;
  --topbar-active-bg: #2563EB;
  --topbar-active-text: #ffffff;

  /* Icon badges and chips: a readable text shade on a soft background. */
  --ov-blue: #1d4ed8;   --ov-blue-soft: #dbeafe;
  --ov-purple: #7c3aed; --ov-purple-soft: #ede9fe;
  --ov-green: #15803d;  --ov-green-soft: #dcfce7;
  --ov-orange: #b45309; --ov-orange-soft: #fef3c7;
  --ov-red: #b91c1c;    --ov-red-soft: #fee2e2;
  --ov-cyan: #0e7490;   --ov-cyan-soft: #cffafe;

  /* Table header columns cycle through these so each column name is visually
     distinct at a glance - applied to every .table in the app, not per-tab. */
  --th-1: #0e7490;
  --th-2: #2563eb;
  --th-3: #7c3aed;
  --th-4: #15803d;
  --th-5: #b45309;
  --th-6: #be185d;
  --th-7: #4338ca;
  --th-8: #ea580c; /* client errors in request charts: an orange that is not the Timeouts amber */
}


/* The dark theme. Chosen from the account menu (data-theme="dark" on <html>),
   or by Windows when the choice is "Match Windows" (no data-theme set).
   The same tokens appear twice because CSS cannot share a block between a
   selector and a media query. */
:root[data-theme="dark"] {
  /* BestBrains NOC Dark: deep navy page, slate-navy cards, electric-blue
     primary, cyan secondary, green / amber / red status. Text in three
     tiers: --text #F8FAFC for values that matter, --text-muted #94A3B8 for
     supporting information, --text-faint #64748B for decoration only
     (separators, dividers) - it is 3.5:1 on a card, too faint to read. Fills use the
     brief's colours as given; text on blue fills is navy and red text is a
     shade lighter, because white-on-blue (3.7:1) and #EF4444 on a hovered
     row (4.1:1) fail the readable floor. */
  --bg: #0B1220;
  --bg-2: #0F172A;
  --surface: #111C2E;
  --card-hover: #17243A;
  --border: #263449;
  --border-strong: #5B6B85;
  --text: #F8FAFC;
  --text-muted: #94A3B8;
  --text-faint: #64748B;
  --accent: #3B82F6;
  --accent-soft: #162846;
  --success: #22C55E;
  --warn: #F59E0B;
  --danger: #F87171;
  --danger-fill: #EF4444;
  --success-fill: #22C55E;
  --warn-fill: #F59E0B;
  --info-fill: #06B6D4;

  --th-1: #06B6D4;
  --th-2: #60A5FA;
  --th-3: #C4B5FD;
  --th-4: #22C55E;
  --th-5: #F59E0B;
  --th-6: #F472B6;
  --th-7: #818CF8;
  --th-8: #FB923C;

  /* The sidebar (the --topbar-* family themes it) and the Users sub-tabs. */
  --topbar-bg: #0F172A;
  --topbar-border: #263449;
  --topbar-text: #F8FAFC;
  --topbar-muted: #94A3B8;
  --topbar-hover: #17243A;
  --topbar-active-bg: #3B82F6;
  --topbar-active-text: #0B1220;
  /* The selected nav item: a soft blue wash with a left accent bar and glow. */
  --nav-active-bg: #162846;
  --nav-active-text: #93C5FD;

  --ov-blue: #60A5FA;   --ov-blue-soft: #0F2A4A;
  --ov-purple: #C4B5FD; --ov-purple-soft: #3B2F63;
  --ov-green: #22C55E;  --ov-green-soft: #0F2D1F;
  --ov-orange: #F59E0B; --ov-orange-soft: #3A2A0F;
  --ov-red: #F87171;    --ov-red-soft: #3B1A1F;
  --ov-cyan: #06B6D4;   --ov-cyan-soft: #0C3A45;

  --table-head-bg: #0F172A;
  --table-head-text: #94A3B8;
  --row-hover: #17243A;
  --surface-2: #17243A;
  --on-accent: #0B1220;
  --on-color: #0B1220;
  --logo-chip: #ffffff;
  --warn-wash: rgba(245,158,11,.08);
  --danger-wash: rgba(239,68,68,.08);
  --accent-glow: rgba(59,130,246,.18);
  --page-glow: rgba(59,130,246,.08);
  --shadow-sm: none;
  --shadow-md: 0 8px 24px rgba(0,0,0,.45);
  --shadow-drawer: 2px 0 16px rgba(0,0,0,.5);
  --overlay: rgba(11,18,32,.72);
  --scrim: rgba(11,18,32,.6);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    /* BestBrains NOC Dark: deep navy page, slate-navy cards, electric-blue
       primary, cyan secondary, green / amber / red status. Text in three
       tiers: --text #F8FAFC for values that matter, --text-muted #94A3B8 for
       supporting information, --text-faint #64748B for decoration only
       (separators, dividers) - it is 3.5:1 on a card, too faint to read. Fills use the
       brief's colours as given; text on blue fills is navy and red text is a
       shade lighter, because white-on-blue (3.7:1) and #EF4444 on a hovered
       row (4.1:1) fail the readable floor. */
    --bg: #0B1220;
    --bg-2: #0F172A;
    --surface: #111C2E;
    --card-hover: #17243A;
    --border: #263449;
    --border-strong: #5B6B85;
    --text: #F8FAFC;
    --text-muted: #94A3B8;
    --text-faint: #64748B;
    --accent: #3B82F6;
    --accent-soft: #162846;
    --success: #22C55E;
    --warn: #F59E0B;
    --danger: #F87171;
    --danger-fill: #EF4444;
    --success-fill: #22C55E;
    --warn-fill: #F59E0B;
    --info-fill: #06B6D4;

    --th-1: #06B6D4;
    --th-2: #60A5FA;
    --th-3: #C4B5FD;
    --th-4: #22C55E;
    --th-5: #F59E0B;
    --th-6: #F472B6;
    --th-7: #818CF8;
    --th-8: #FB923C;

    /* The sidebar (the --topbar-* family themes it) and the Users sub-tabs. */
    --topbar-bg: #0F172A;
    --topbar-border: #263449;
    --topbar-text: #F8FAFC;
    --topbar-muted: #94A3B8;
    --topbar-hover: #17243A;
    --topbar-active-bg: #3B82F6;
    --topbar-active-text: #0B1220;
    /* The selected nav item: a soft blue wash with a left accent bar and glow. */
    --nav-active-bg: #162846;
    --nav-active-text: #93C5FD;

    --ov-blue: #60A5FA;   --ov-blue-soft: #0F2A4A;
    --ov-purple: #C4B5FD; --ov-purple-soft: #3B2F63;
    --ov-green: #22C55E;  --ov-green-soft: #0F2D1F;
    --ov-orange: #F59E0B; --ov-orange-soft: #3A2A0F;
    --ov-red: #F87171;    --ov-red-soft: #3B1A1F;
    --ov-cyan: #06B6D4;   --ov-cyan-soft: #0C3A45;

    --table-head-bg: #0F172A;
    --table-head-text: #94A3B8;
    --row-hover: #17243A;
    --surface-2: #17243A;
    --on-accent: #0B1220;
    --on-color: #0B1220;
    --logo-chip: #ffffff;
    --warn-wash: rgba(245,158,11,.08);
    --danger-wash: rgba(239,68,68,.08);
    --accent-glow: rgba(59,130,246,.18);
    --page-glow: rgba(59,130,246,.08);
    --shadow-sm: none;
    --shadow-md: 0 8px 24px rgba(0,0,0,.45);
    --shadow-drawer: 2px 0 16px rgba(0,0,0,.5);
    --overlay: rgba(11,18,32,.72);
    --scrim: rgba(11,18,32,.6);
    color-scheme: dark;
    }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  /* A faint blue glow at the top: depth without decoration. */
  background: radial-gradient(1100px 520px at 78% -12%, var(--page-glow), transparent 60%), linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
}

/* Shell: a left navigation sidebar and a content column. The sidebar carries
   the brand and the section list; the slim top bar carries search on the left
   and the notifications + account controls on the right. */
.app { display: flex; align-items: stretch; min-height: 100vh; }

.sidebar {
  width: 214px;
  flex-shrink: 0;
  background: var(--topbar-bg);
  color: var(--topbar-text);
  border-right: 1px solid var(--topbar-border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 10px;
  z-index: 6;
  /* Re-scope the shared tokens the nav's child rules use, so the sidebar
     re-themes (text, muted text, hover tint) without touching those rules. */
  --text: var(--topbar-text);
  --text-muted: var(--topbar-muted);
  --accent-soft: var(--topbar-hover);
  --border: var(--topbar-border);
  --surface-2: var(--topbar-hover);
}
.sidebar .brand { padding: 2px 8px; }
.sidebar.collapsed { display: none; }

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

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar-spacer { flex: 1; }
/* "Monitoring Live" / "N Active Incidents": the same facts the Overview
   health pill and the bell badge show, in one glance from every tab. */
.topbar-status { display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; border: 1px solid transparent; border-radius: 999px; font: inherit; font-size: 12px; font-weight: 600; line-height: 1.2; color: var(--table-head-text); background: transparent; white-space: nowrap; cursor: pointer; }
.topbar-status:hover { background: var(--surface-2); }
.topbar-status .dot { background: var(--success-fill); box-shadow: 0 0 8px var(--success-fill); }
.topbar-status.warn { color: var(--warn); background: var(--warn-wash); }
.topbar-status.crit { color: var(--danger); background: var(--danger-wash); }
/* With incidents open the dot is a shape (✕ critical, ▲ warning), so the
   level reads without colour. */
.topbar-status.crit .dot, .topbar-status.warn .dot { background: none; box-shadow: none; width: auto; height: auto; border-radius: 0; font-size: 11px; line-height: 1; }
.topbar-status.warn .dot { color: var(--warn-fill); }
.topbar-status.crit .dot { color: var(--danger-fill); }
.topbar-status.offline { color: var(--table-head-text); background: var(--surface-2); }
.topbar-status.offline .dot { background: var(--text-muted); box-shadow: none; }
/* Phone width: the text gives way to the short form the script keeps in
   data-short (the count, "Lost", or nothing when all is quiet). */
@media (max-width: 600px) {
  /* The text stays in the accessibility tree (it is the live region and the
     button's name); only its box is hidden. */
  .topbar-status { padding: 5px 8px; position: relative; }
  .topbar-status span:last-child { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .topbar-status[data-short]:not([data-short=""])::after { content: attr(data-short); content: attr(data-short) / ""; }
}
/* Shown on all sizes now: on desktop it collapses/expands the rail, on mobile it
   opens/closes the drawer. */
.topbar .sidebar-toggle { display: flex; }

.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 18px; margin: 0; font-weight: 700; }
/* The Best Brains logo, above the product name. It is drawn on white, so it
   sits on a white panel - invisible on the light sidebar, a clean card on the
   dark one. The collapsed rail shows only the "b" mark. */
.sidebar .brand { flex-direction: column; align-items: flex-start; gap: 8px; }
.brand-logo {
  display: block; width: 150px; height: auto; box-sizing: content-box;
  background: var(--logo-chip); border: 1px solid var(--border); border-radius: 10px; padding: 6px 8px;
}
.brand-mark { display: none; width: 34px; height: 34px; border-radius: 9px; background: var(--logo-chip); border: 1px solid var(--border); }
.brand-row { display: flex; align-items: center; gap: 8px; }
/* "NETWORK MONITORING" as a small caption under the logo. */
.sidebar .brand-row h1 { font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--topbar-muted); white-space: nowrap; }
.sidebar.collapsed .brand-logo { display: none; }
.sidebar.collapsed .brand-mark { display: block; }
.sidebar.collapsed .brand { align-items: center; }
.brand-icon {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--ov-blue), var(--ov-purple));
  color: var(--on-color); display: flex; align-items: center; justify-content: center; font-size: 17px;
}

.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--danger-fill);
  display: inline-block;
}
.dot.connected { background: var(--success-fill); }
/* Unknown is not down: grey, never the default red. */
.dot.unknown { background: var(--text-muted); }

.tabs { display: flex; flex-direction: column; gap: 2px; flex-wrap: nowrap; }
.tab-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background .12s, color .12s, opacity .12s;
}
.tab-ico { width: 20px; text-align: center; flex-shrink: 0; font-size: 15px; }
.tab-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Collapsed rail: icons only. Toggled by the button in the top bar and
   remembered per browser. */
.sidebar.collapsed { width: 60px; padding: 14px 8px; }
.sidebar.collapsed .tab-label,
.sidebar.collapsed .brand h1 { display: none; }
.sidebar.collapsed .tab-btn { justify-content: center; padding: 9px 0; gap: 0; }
.sidebar.collapsed .brand { justify-content: center; }
.tab-btn:hover { background: var(--topbar-hover); color: var(--text); }
.tab-btn { position: relative; }
.tab-btn.active { background: var(--nav-active-bg); color: var(--nav-active-text); box-shadow: 0 0 14px var(--accent-glow); }
.tab-btn.active::before { content: ""; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px; border-radius: 2px; background: var(--accent); }
.tab-btn.active .tab-ico { filter: saturate(1.2); }
/* The nav buttons set display:flex, which would beat the hidden attribute the
   permission gating sets - without this, every role saw every tab. */
.tab-btn[hidden] { display: none; }
.tabs-sep { height: 1px; margin: 8px 10px; background: var(--topbar-border); }
.tab-btn.search-dim { opacity: .35; }
.tab-btn.search-match { background: var(--ov-blue-soft); color: var(--ov-blue); }

.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-search { position: relative; }
.topbar-search input {
  padding: 7px 12px 7px 30px; border: 1px solid var(--border); border-radius: 20px;
  background: var(--surface-2); color: var(--text); font-size: 13px; width: 220px; outline: none;
}
.topbar-search input:focus { border-color: var(--ov-blue); background: var(--surface); }
.topbar-search::before {
  content: "\1F50D"; position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  font-size: 12px; opacity: .6; pointer-events: none;
}
.icon-btn {
  position: relative; width: 36px; height: 36px; border-radius: 50%; border: none;
  background: var(--surface-2); color: var(--text); cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--border); }
.notif-badge { border: 2px solid var(--surface); }
.notif-badge {
  position: absolute; top: -2px; right: -2px; background: var(--danger-fill); color: var(--on-color);
  font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; padding: 0 3px;
  border: 2px solid var(--topbar-bg);
}
.avatar-menu { position: relative; }
.avatar-btn {
  display: flex; align-items: center; gap: 8px; border: none; background: transparent;
  color: var(--text); cursor: pointer; padding: 4px 6px; border-radius: 20px; font-size: 13px;
}
.avatar-btn:hover { background: var(--topbar-hover); }
.avatar-circle {
  width: 28px; height: 28px; border-radius: 50%; background: var(--ov-blue-soft); color: var(--ov-blue);
  display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0;
}
.avatar-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-md);
  padding: 8px; min-width: 160px; z-index: 20;
}
.avatar-dropdown .btn { width: 100%; }
.avatar-dropdown .btn + .btn { margin-top: 6px; }
.mfa-codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); font-family: ui-monospace, Consolas, monospace; font-size: 14px; margin-bottom: 10px; }
.mfa-pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.mfa-pill.on { background: var(--ov-green-soft); color: var(--ov-green); }
.mfa-pill.off { background: var(--ov-orange-soft); color: var(--ov-orange); }
.mfa-pill.none { background: var(--row-hover); color: var(--text-muted); }
.mfa-pill.bad { background: var(--ov-red-soft); color: var(--ov-red); }
.mfa-pill.info { background: var(--ov-blue-soft); color: var(--ov-blue); }

/* ---------- Users tab ---------- */
.usr-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 14px; }
.usr-tab { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 13px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.usr-tab:hover { border-color: var(--accent); }
.usr-tab.active { background: var(--topbar-active-bg); border-color: var(--topbar-active-bg); color: var(--topbar-active-text); }
.usr-count { font-size: 11px; font-weight: 700; opacity: .85; }
.usr-count:empty { display: none; }
.usr-count-alert { background: var(--danger-fill); color: var(--on-color); border-radius: 999px; padding: 0 6px; opacity: 1; }
.usr-add { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.usr-add > label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-muted); }
.usr-pw-choice { display: flex; flex-direction: column; gap: 4px; font-size: 13px; min-width: 0; }
.usr-pw-choice label { display: flex; gap: 6px; align-items: center; }
.usr-pw-choice .usr-must { color: var(--text-muted); font-size: 12px; }
/* display:flex above beats the browser's own [hidden] rule; restore it */
.usr-pw-choice label[hidden], .usr-pw-choice input[hidden] { display: none; }
.usr-err { color: var(--danger); font-size: 13px; min-height: 0; margin-top: 6px; }
.usr-err.ok { color: var(--success); }
.usr-result { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); font-size: 13px; }
.usr-result code { font-size: 16px; letter-spacing: 1px; padding: 2px 8px; border: 1px dashed var(--border); border-radius: 6px; background: var(--surface); user-select: all; }
.usr-note { color: var(--text-muted); font-size: 12px; margin: 4px 0 10px; line-height: 1.45; }
.usr-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.usr-small { padding: 5px 12px; font-size: 12px; }
.usr-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.usr-filters .ast-in { min-width: 200px; flex: 1 1 200px; max-width: 320px; }
/* width:0 + min-width:100% - the wide log tables scroll inside their card
   instead of stretching the whole page (their intrinsic width no longer
   counts towards the layout's). */
.usr-table-wrap { overflow-x: auto; width: 0; min-width: 100%; }
.usr-table-wrap .table td { vertical-align: top; }
.usr-table-wrap .table td.usr-wrap { white-space: normal; min-width: 180px; max-width: 420px; word-break: break-word; }
.usr-muted { color: var(--text-muted); font-size: 12px; }
.usr-detail { color: var(--text-muted); font-size: 11px; font-family: ui-monospace, Consolas, monospace; word-break: break-word; }
.usr-flags { margin: 0; padding-left: 16px; font-size: 12px; }
.usr-actions { white-space: nowrap; display: flex; gap: 4px; flex-wrap: wrap; }
.usr-actions .btn { padding: 4px 10px; font-size: 12px; }
.usr-cell-sel { padding: 3px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); font-size: 12px; margin-top: 4px; display: block; }
.usr-sub-h { margin: 14px 0 4px; font-size: 13px; }
.usr-self-pw { display: flex; gap: 6px; flex-wrap: wrap; }
.usr-self-pw .ast-in { flex: 1 1 140px; min-width: 0; }
#tab-users .ast-card { cursor: default; }
#users-table tr.usr-disabled td { opacity: .7; }
#users-table tr.usr-disabled td:last-child { opacity: 1; }
#tab-users .ast-card.warn .ast-card-value { color: var(--warn); }
#tab-users .ast-card.bad .ast-card-value { color: var(--danger); }

/* ---------- Notifications dropdown ---------- */
.notif-menu { position: relative; }
.notif-panel {
  position: absolute; top: calc(100% + 8px); right: 0; width: 340px; max-width: 92vw;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-md); z-index: 30; overflow: hidden;
}
.notif-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 13px;
}
.notif-panel-all {
  border: none; background: transparent; color: var(--ov-blue); cursor: pointer;
  font-size: 12px; font-weight: 600; padding: 2px 4px;
}
.notif-panel-all:hover { text-decoration: underline; }
.notif-panel-body { max-height: 60vh; overflow-y: auto; }
.notif-item {
  display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left;
  padding: 10px 12px; border: none; border-bottom: 1px solid var(--border);
  background: transparent; color: var(--text); cursor: pointer; font: inherit;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface-2); }
.notif-item-dot { font-size: 10px; line-height: 1.7; flex-shrink: 0; }
.notif-item-main { flex: 1; min-width: 0; }
.notif-item-title { font-size: 13px; font-weight: 600; }
.notif-item-issue { font-size: 12px; color: var(--text-muted); overflow-wrap: anywhere; }
.notif-item-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.notif-empty { padding: 22px 14px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* ---------- Assets (inventory) tab ---------- */
.ast-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 10px; }
.ast-card {
  display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; color: var(--text); font: inherit;
}
.ast-card:hover { border-color: var(--accent); background: var(--card-hover); }
.ast-card.active { border-color: var(--ov-blue); box-shadow: 0 0 0 1px var(--ov-blue) inset; }
.ast-card .ast-card-ico { font-size: 18px; line-height: 1; }
.ast-card .ast-card-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.ast-card .ast-card-value { font-size: 24px; font-weight: 700; }
.ast-status-strip { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.ast-chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px;
  padding: 4px 12px; font-size: 12px; cursor: pointer; font: inherit;
}
.ast-chip.active { border-color: var(--ov-blue); color: var(--ov-blue); }
.ast-sel, .ast-in {
  padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text);
}
.ast-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.ast-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.ast-form .ast-in { width: 100%; box-sizing: border-box; }
.ast-form .ast-wide { grid-column: 1 / -1; }
.ast-fleet-link { font-size: 12px; color: var(--text-muted); }
.ast-fleet-link[hidden] { display: none; }
/* The label rule above sets display:flex, which would beat the [hidden]
   attribute; the per-category fields rely on hidden actually hiding. */
.ast-form label[hidden], .ast-form .ast-sec[hidden] { display: none; }
.ast-form .ast-sec {
  grid-column: 1 / -1; margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--border);
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted);
}
.ast-tpl { display: inline-flex; gap: 6px; align-items: center; }
.ast-tpl-csv { font-size: 12px; color: var(--text-muted); }
.ast-spec { color: var(--text-muted); font-size: 12px; }
/* Selection and delete */
.ast-bulk {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 4px 0 10px; padding: 8px 12px;
  border: 1px solid var(--danger-fill); border-radius: 6px; font-size: 13px;
}
.ast-bulk[hidden] { display: none; }
.btn.ast-danger-btn { background: var(--danger-fill); border-color: var(--danger-fill); color: var(--on-color); }
.ast-row-btns { display: flex; gap: 6px; justify-content: flex-end; }
.ast-row-btns .btn { padding: 3px 10px; font-size: 12px; }
.ast-row-btns .ast-del { color: var(--danger); }
.ast-check { width: 16px; height: 16px; cursor: pointer; }
/* Documents */
.ast-docs-count {
  display: inline-block; margin-left: 6px; padding: 0 6px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 11px; font-weight: 400; color: var(--text-muted); background: none; cursor: pointer;
}
.ast-docs-row td { background: var(--surface-2); }
.ast-doc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.ast-doc-list li { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ast-doc-list .ast-doc-meta { color: var(--text-muted); font-size: 12px; }
.ast-doc-list .ast-doc-remove { padding: 1px 8px; font-size: 12px; color: var(--danger); }
.ast-form .ast-docs { display: flex; flex-direction: column; gap: 8px; }
/* Pick-from-list fields and the multi-row processor / storage / GPU editors */
.ast-form .ast-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; min-width: 0; }
.ast-form .ast-field[hidden] { display: none; }
/* Direct children only: the controls inside a multi-row size themselves. */
.ast-form .ast-field > select.ast-in, .ast-form .ast-field > input.ast-in { width: 100%; box-sizing: border-box; }
.ast-multi { display: flex; flex-direction: column; gap: 6px; }
.ast-multi-row { display: flex; gap: 6px; align-items: center; min-width: 0; }
.ast-form .ast-multi-row .ast-qty { width: 64px; flex: none; }
.ast-multi-row .ast-times { color: var(--text-muted); flex: none; }
.ast-form .ast-multi-row select.ast-in { flex: 1 1 40%; min-width: 0; width: auto; }
.ast-form .ast-multi-row input[data-ast-mother] { flex: 1 1 40%; min-width: 0; width: auto; }
.ast-multi-row .ast-mremove { flex: none; padding: 2px 9px; color: var(--danger); }
.ast-form .ast-multi-add { align-self: flex-start; padding: 3px 10px; font-size: 12px; }
.ast-tag { font-family: ui-monospace, Consolas, monospace; font-weight: 600; }
@media (max-width: 640px) { .ast-form { grid-template-columns: 1fr; } }

/* ---------- Overview page redesign ---------- */
.ov-header { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.ov-header h2 { margin: 0 0 4px; font-size: 26px; }
.ov-header .sub { color: var(--text-muted); font-size: 14px; font-weight: 500; }
.ov-header-right { text-align: right; font-size: 13px; color: var(--text-muted); }
.ov-status-pill {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px;
  color: var(--ov-green); margin-top: 4px;
}
.ov-status-pill .dot { background: var(--success-fill); }
.ov-status-pill.warn { color: var(--ov-orange); }
.ov-status-pill.warn .dot { background: var(--warn-fill); }
.ov-status-pill.crit { color: var(--ov-red); }
.ov-status-pill.crit .dot { background: var(--danger-fill); }

.grid-ov-stats { grid-template-columns: repeat(8, 1fr); }
@media (max-width: 1300px) { .grid-ov-stats { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 700px) { .grid-ov-stats { grid-template-columns: repeat(2, 1fr); } }

.ov-stat-card {
  display: flex; flex-direction: column; gap: 10px; cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
}
.ov-stat-card:hover { border-color: var(--accent); background: var(--card-hover); box-shadow: none; }
.ov-stat-card-top { display: flex; align-items: flex-start; justify-content: space-between; }
.ov-icon-badge {
  width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center;
  justify-content: center; font-size: 17px; flex-shrink: 0;
}
.ov-icon-badge.blue { background: var(--ov-blue-soft); color: var(--ov-blue); }
.ov-icon-badge.purple { background: var(--ov-purple-soft); color: var(--ov-purple); }
.ov-icon-badge.green { background: var(--ov-green-soft); color: var(--ov-green); }
.ov-icon-badge.orange { background: var(--ov-orange-soft); color: var(--ov-orange); }
.ov-icon-badge.red { background: var(--ov-red-soft); color: var(--ov-red); }
.ov-icon-badge.cyan { background: var(--ov-cyan-soft); color: var(--ov-cyan); }
.ov-stat-chevron { color: var(--text-muted); font-size: 15px; }
.ov-stat-label { font-size: 12.5px; color: var(--text-muted); font-weight: 600; }
.ov-stat-value { font-size: 24px; font-weight: 700; line-height: 1.1; }
.ov-stat-foot { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; }
.ov-stat-foot.green { color: var(--ov-green); }
.ov-stat-foot.orange { color: var(--ov-orange); }
.ov-stat-foot.red { color: var(--ov-red); }
.ov-stat-foot.muted { color: var(--text-muted); }
/* The foot's marker is a shape (● ▲ ✕ ○), coloured with the fill tokens. */
.ov-stat-foot .ov-foot-mark { flex-shrink: 0; font-size: 10px; line-height: 1; }
.ov-stat-foot.green .ov-foot-mark { color: var(--success-fill); }
.ov-stat-foot.orange .ov-foot-mark { color: var(--warn-fill); }
.ov-stat-foot.red .ov-foot-mark { color: var(--danger-fill); }
.ov-stat-foot.muted .ov-foot-mark { color: var(--text-muted); }
.ov-stat-trend { font-size: 12px; font-weight: 600; margin-top: -4px; }
.ov-stat-trend.green { color: var(--ov-green); }
.ov-stat-trend.orange { color: var(--ov-orange); }
.ov-stat-trend.red { color: var(--ov-red); }
.ov-stat-trend.muted { color: var(--text-muted); }

.ov-gauge-wrap { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ov-gauge-wrap svg { flex-shrink: 0; } /* the ring keeps its size; "Attention Required" wraps below it if it must */
.ov-gauge-label { display: flex; flex-direction: column; }
.ov-gauge-score { font-size: 22px; font-weight: 700; }
.ov-gauge-status { font-size: 13px; font-weight: 700; }
.ov-gauge-status.green { color: var(--ov-green); }
.ov-gauge-status.orange { color: var(--ov-orange); }
.ov-gauge-status.red { color: var(--ov-red); }
.ov-gauge-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.ov-health-extra { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 8px; display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
.ov-health-extra-row { display: flex; justify-content: space-between; color: var(--text-muted); }
.ov-health-extra-row b { color: var(--text); }

.grid-ov-mid { grid-template-columns: 1.5fr 1fr 1fr; align-items: start; }
@media (max-width: 1100px) { .grid-ov-mid { grid-template-columns: 1fr; } }
.grid-ov-bottom { grid-template-columns: 1fr 1fr 1fr; align-items: start; }
@media (max-width: 1100px) { .grid-ov-bottom { grid-template-columns: 1fr; } }

.ov-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.ov-card-head h3 {
  margin: 0; font-size: 15px; text-transform: none; letter-spacing: normal; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.ov-card-head a, .ov-card-head .ov-view-all {
  font-size: 12.5px; color: var(--ov-blue); cursor: pointer; font-weight: 600; text-decoration: none;
  background: none; border: 0; padding: 0; font-family: inherit;
}
.ov-count-badge[hidden] { display: none; }
/* Data freshness: one badge everywhere. Shape + word + colour, never colour alone. */
.fresh-row { display: flex; justify-content: flex-end; margin: 0 0 10px; }
.fresh { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 4px 11px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: 12.5px; color: var(--text-muted); line-height: 1.35; }
.fresh b { color: var(--text); font-weight: 600; }
.fresh-mark { font-size: 11px; line-height: 1; }
.fresh-live .fresh-mark { color: var(--success-fill); }
.fresh-idle .fresh-mark { color: var(--text-muted); }
.fresh-delayed { background: var(--warn-wash); border-color: var(--warn-fill); --text-muted: var(--table-head-text); }
.fresh-delayed .fresh-mark, .fresh-delayed b { color: var(--warn); }
.fresh-offline { background: var(--danger-wash); border-color: var(--danger-fill); --text-muted: var(--table-head-text); }
.fresh-offline .fresh-mark, .fresh-offline b { color: var(--danger); }
.fresh-refresh { background: none; border: 0; padding: 0 0 0 4px; font: inherit; font-weight: 600; color: var(--accent); cursor: pointer; text-decoration: underline; }
.ov-header-right .fresh { margin-bottom: 6px; }
/* Monitoring Health: one slim row of the collectors behind every number. */
.ov-mhealth { margin-bottom: 16px; padding: 12px 16px; }
.ov-mhealth-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.ov-mhealth-head h3 { margin: 0; font-size: 15px; text-transform: none; letter-spacing: normal; color: var(--text); }
.ov-mhealth-sub { font-size: 12px; color: var(--text-muted); }
.ov-mhealth-sum { margin-left: auto; font-size: 12.5px; font-weight: 600; }
.ov-mhealth-sum.ok { color: var(--success); }
.ov-mhealth-sum.warn { color: var(--warn); }
.ov-mhealth-sum.crit { color: var(--danger); }
.ov-mhealth-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 6px 10px; }
.ov-mh-item { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: 12.5px; text-align: left; cursor: default; }
.ov-mh-item[data-tab] { cursor: pointer; }
.ov-mh-item[data-tab]:hover { border-color: var(--accent); background: var(--card-hover); }
.ov-mh-mark { width: 12px; text-align: center; flex-shrink: 0; }
.ov-mh-label { color: var(--text-muted); min-width: 0; }
.ov-mh-val { margin-left: auto; font-weight: 600; text-align: right; min-width: 0; }
.ov-mh-item.ok .ov-mh-mark { color: var(--success-fill); }
.ov-mh-item.warn { border-color: var(--warn-fill); background: var(--warn-wash); --text-muted: var(--table-head-text); }
.ov-mh-item.warn .ov-mh-mark, .ov-mh-item.warn .ov-mh-val { color: var(--warn); }
.ov-mh-item.crit { border-color: var(--danger-fill); background: var(--danger-wash); --text-muted: var(--table-head-text); }
.ov-mh-item.crit .ov-mh-mark, .ov-mh-item.crit .ov-mh-val { color: var(--danger); }
.ov-mh-item.idle .ov-mh-mark, .ov-mh-item.idle .ov-mh-val { color: var(--text-muted); font-weight: 500; }
/* Device identity: one block everywhere - the name, then IP · location · OS · status · last seen. */
.dev-id { display: inline-flex; flex-direction: column; gap: 1px; min-width: 0; vertical-align: top; }
.dev-id-name { font-weight: 600; color: var(--text); }
.dev-id-link { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--text); cursor: pointer; text-align: left; }
.dev-id-link:hover, .dev-id-link:focus-visible { color: var(--accent); text-decoration: underline; }
.dev-id-meta { display: flex; flex-wrap: wrap; align-items: baseline; font-size: 12px; font-weight: 400; color: var(--text-muted); }
.dev-id-meta > span + span::before { content: '\00B7'; content: '\00B7' / ''; margin: 0 5px; color: var(--text-faint); }
.dev-id-ip { font-variant-numeric: tabular-nums; }
.dev-id-status { font-weight: 600; }
.dev-id-status.live { color: var(--success); }
.dev-id-status.delayed { color: var(--warn); }
.dev-id-status.offline { color: var(--danger); }
.dev-id-status.idle { color: var(--text-muted); font-weight: 500; }
.dev-id.compact .dev-id-meta { font-size: 11.5px; }
.dev-id.inline { display: inline; }
.dev-id.inline .dev-id-name { white-space: nowrap; } /* the cell may wrap; a name never breaks mid-word */
.dev-id.inline .dev-id-ip { color: var(--text-muted); font-size: 12px; margin-left: 4px; }
.dev-id-ip[data-copy-ip] { cursor: pointer; color: var(--accent); }
/* The Devices tab panel header carries the block inside an uppercase h3:
   the block keeps its own case, weight and colour. */
.snmp-device-header { display: inline-flex; align-items: center; gap: 6px; }
.snmp-device-header .dev-id { text-transform: none; letter-spacing: normal; color: var(--text); }
/* Read by screen readers, not seen. Kept in the normal flow on purpose: an
   absolutely positioned one inside a wide table escapes the card's scroll
   area and makes the whole page scroll sideways. */
.sr-only { display: inline-block; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; vertical-align: top; }
.ov-card-head-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 6px 10px; }
.ov-card-head-actions .ov-view-all { white-space: nowrap; }
#ov-chart-traffic { cursor: pointer; }
[data-ov-jump]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.ov-count-badge { display: inline-block; min-width: 18px; padding: 1px 7px; border-radius: 999px; background: var(--danger-fill); color: var(--on-color); font-size: 11.5px; font-weight: 700; line-height: 16px; text-align: center; }
.ov-period-select {
  padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
  color: var(--text); font-size: 12px;
}

.severity-pill {
  display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .02em;
}
/* The small form, beside a dot or emoji in a dense row (bell panel, events). */
.severity-pill.sm { font-size: 10px; padding: 1px 6px; vertical-align: 1px; }
.severity-pill.critical { background: var(--ov-red-soft); color: var(--ov-red); }
.severity-pill.warning { background: var(--ov-orange-soft); color: var(--ov-orange); }
.severity-pill.info { background: var(--ov-blue-soft); color: var(--ov-blue); }

.ov-event-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.ov-event-row:last-child { border-bottom: none; }
.ov-event-row:hover, .ov-problem-row:hover { background: var(--accent-soft); }

/* An incident is a bordered block with a severity-coloured edge and wash:
   who (name, type - address - location), what (a usage bar when the reason
   is a percentage, text otherwise), since when, and the way in. */
.ov-incident-card {
  display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; margin-bottom: 10px;
  border: 1px solid var(--border); border-left-width: 3px; border-radius: 8px; background: var(--surface);
}
.ov-incident-card:last-child { margin-bottom: 0; }
.ov-incident-card.critical { border-left-color: var(--danger-fill); background: var(--danger-wash); }
.ov-incident-card.warning { border-left-color: var(--warn-fill); background: var(--warn-wash); }
/* Muted text on a severity wash needs the darker grey to stay readable
   (the identity line and Started / Duration live here). */
.ov-incident-card.critical, .ov-incident-card.warning, .event-card-critical, .event-card-warning { --text-muted: var(--table-head-text); }
.ov-incident-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.ov-incident-who { min-width: 0; }
.ov-incident-device { font-weight: 700; font-size: 14px; }
.ov-incident-ident { font-size: 12px; color: var(--text-muted); margin-top: 1px; word-break: break-all; }
.ov-incident-ident .ov-sep { color: var(--text-faint); margin: 0 2px; }
/* The identity meta line wraps between its parts, not inside a word. */
.ov-incident-ident .dev-id-meta { word-break: normal; overflow-wrap: anywhere; }
.notif-item-ident .dev-id-meta { font-size: 11.5px; margin-top: 1px; }
.overview-system-ident { margin: -4px 4px 12px; }
.network-identity { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.network-identity[hidden] { display: none; }
.network-identity-iface { font-size: 13px; font-weight: 600; color: var(--text); }
.ov-incident-metric { display: flex; justify-content: space-between; align-items: baseline; font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.ov-incident-metric b { color: var(--text); font-size: 13.5px; }
.ov-incident-bar { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.ov-incident-bar span { display: block; height: 100%; border-radius: 3px; background: var(--danger-fill); }
.ov-incident-card.warning .ov-incident-bar span { background: var(--warn-fill); }
.ov-incident-issue { font-size: 13px; color: var(--text-muted); }
.ov-incident-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 2px; flex-wrap: wrap; }
.ov-incident-meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 14px; flex-wrap: wrap; }
.ov-incident-meta b { color: var(--text); font-weight: 600; }
.ov-btn-sm {
  font-size: 11.5px; font-weight: 600; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap;
}
.ov-btn-sm:hover { border-color: var(--ov-blue); color: var(--ov-blue); }
.ov-btn-sm.primary { background: var(--ov-blue); border-color: var(--ov-blue); color: var(--on-color); }
.ov-btn-sm:disabled, .ov-btn-sm:disabled:hover { opacity: .55; cursor: default; border-color: var(--border); color: var(--text); }

/* Incidents from the hub's incident store: the card adds the state (shape +
   word + who), owner / assignee, the metric against its threshold and the
   guidance; one in maintenance is dimmed and listed after the active ones. */
.ov-incident-device.inc-open {
  background: none; border: 0; padding: 0; margin: 0; font: inherit; font-weight: 700; font-size: 14px;
  color: var(--text); cursor: pointer; text-align: left; overflow-wrap: anywhere;
}
.ov-incident-device.inc-open:hover { color: var(--ov-blue); text-decoration: underline; }
.inc-id { font-size: 11.5px; font-weight: 600; color: var(--text-muted); margin-right: 3px; font-variant-numeric: tabular-nums; }
.inc-status-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; font-size: 12px; color: var(--text-muted); }
.inc-status-line b { color: var(--text); font-weight: 600; }
.inc-state { font-weight: 700; color: var(--text); white-space: nowrap; }
.inc-state.new { color: var(--danger); }
.inc-state.acknowledged, .inc-state.investigating { color: var(--warn); }
.inc-state.resolved { color: var(--success); }
.inc-maint-tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px;
  border: 1px dashed var(--text-muted); background: var(--surface-2); color: var(--text);
  font-size: 11px; font-weight: 700; white-space: nowrap; vertical-align: 1px;
}
.inc-maint-tag.sm { font-size: 10px; padding: 0 6px; }
.inc-maint-label { font-size: 12px; color: var(--text-muted); overflow-wrap: anywhere; }
.ov-incident-card.inc-maint { opacity: .72; background: var(--surface); border-left-style: dashed; }
.ov-incident-card.inc-maint:hover, .ov-incident-card.inc-maint:focus-within { opacity: 1; }
.inc-maint-head { font-size: 12px; font-weight: 600; color: var(--text-muted); margin: 14px 0 8px; }
.inc-more { font-size: 12px; color: var(--text-muted); margin: 4px 0 8px; }
.inc-thr { font-size: 11.5px; }
.ov-incident-bar.inc-bar { position: relative; overflow: visible; }
.inc-bar-thr { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--text); opacity: .65; border-radius: 1px; }
.inc-guide { display: grid; gap: 2px; font-size: 12px; color: var(--text-muted); }
.inc-guide b { color: var(--text); font-weight: 600; }
.inc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.inc-result { font-size: 12.5px; color: var(--text-muted); }
.inc-result.err { color: var(--danger); }
.inc-result:empty { display: none; }

/* The incident popup. */
.inc-modal-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: -4px 0 10px; }
.inc-modal-head .inc-open-device { margin-left: auto; padding: 4px 12px; font-size: 12px; }
.inc-modal-ident { margin-bottom: 8px; }
.inc-modal-title { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.inc-modal .inc-guide { margin: 8px 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.inc-modal-rows { margin-top: 6px; }
.inc-manage { display: grid; gap: 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.inc-manage[hidden] { display: none; }
.inc-assign-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.inc-assign-row label, .inc-note-row > label, .inc-owner-grid label, .inc-field-label {
  display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--text-muted);
}
.inc-note-row { display: grid; gap: 6px; }
.inc-note-row textarea, .inc-teams-text {
  width: 100%; box-sizing: border-box; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 13px; resize: vertical;
}
.inc-tl-head { margin: 16px 0 6px; font-size: 13px; }
.inc-timeline { list-style: none; margin: 0; padding: 0 0 0 2px; border-left: 2px solid var(--border); }
.inc-tl-item { position: relative; padding: 4px 0 8px 14px; font-size: 13px; }
.inc-tl-item::before { content: ''; position: absolute; left: -6px; top: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.inc-tl-by, .inc-tl-at { font-size: 12px; color: var(--text-muted); }
.inc-tl-note { margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }

/* Alerts tab: incident teams. Users tab: who may act on incidents. */
.inc-owner-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px 12px; margin: 6px 0 12px; }
.inc-access { display: inline-block; font-size: 12px; font-weight: 600; white-space: nowrap; }
.inc-access.yes { color: var(--success); }
.inc-access.no { color: var(--text-muted); }

/* Fleet machine page: maintenance mode. */
.fp-maint-status { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 13px; }
.fp-maint-label { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; overflow-wrap: anywhere; }
.fp-maint-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-top: 10px; }
.fp-maint-controls label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.fp-maint-reason { flex: 1 1 220px; min-width: 0; }
.fp-maint-reason input { width: 100%; box-sizing: border-box; }
.fp-maint-card #fp-maint-result { margin-top: 6px; }
@media (max-width: 600px) {
  .inc-modal-head .inc-open-device { margin-left: 0; }
  .inc-assign-row > label, .fp-maint-controls > label { flex: 1 1 100%; }
}

.ov-mini-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
.ov-mini-card { display: flex; align-items: center; gap: 10px; padding: 12px; }
.ov-mini-card-body { display: flex; flex-direction: column; }
.ov-mini-label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.ov-mini-value { font-size: 19px; font-weight: 700; }
.ov-mini-trend { font-size: 12px; font-weight: 600; }
.ov-mini-trend.green { color: var(--ov-green); }
.ov-mini-trend.orange { color: var(--ov-orange); }
.ov-mini-trend.red { color: var(--ov-red); }
.ov-mini-trend.muted { color: var(--text-muted); font-weight: 500; }

/* The Device column carries the identity block (name over IP · location · OS ·
   status · last seen), so it gets the most room; minmax(0, ...) lets it wrap
   instead of pushing the other columns out. State and Status are one word
   each and never shrink below it (min-content). */
.ov-problem-row .dev-id-name, .ov-problem-row .dev-id-ip { overflow-wrap: anywhere; }
.ov-problem-row { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(min-content, .7fr) minmax(0, .9fr) minmax(min-content, .9fr); gap: 8px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px; cursor: pointer; }
.ov-problem-row:last-child { border-bottom: none; }
.ov-problem-head { font-size: 11px; text-transform: uppercase; color: var(--text-muted); font-weight: 700; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.ov-health-score-badge { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; font-size: 13px; }
.ov-problem-issue { font-size: 12px; color: var(--text-muted); }

.ov-filter-select {
  padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
  color: var(--text); font-size: 12px;
}
.ov-card-filters { display: flex; gap: 8px; }

.ov-traffic-stats { display: flex; gap: 22px; margin-bottom: 10px; font-size: 12.5px; }
.ov-traffic-stats b { display: block; font-size: 15px; color: var(--text); }

main { max-width: 1440px; margin: 0 auto; padding: 20px 24px 60px; }

.tab-panel { display: none; flex-direction: column; gap: 16px; }
.tab-panel.active { display: flex; }

.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
/* "All Sections" tiles carry short phrases ("2 errors / 5000 requests"), not
   a single crisp number - the default 26px .stat-value reads oversized and
   wraps awkwardly for those, so scale it down specifically here. */
.grid-auto .stat-value { font-size: 19px; line-height: 1.3; }

@media (max-width: 900px) {
  .grid-4, .grid-5, .grid-6, .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  overflow-x: auto; /* wide tables/charts scroll within the card on narrow screens instead of blowing out the page */
}
.card h3 { margin: 0 0 12px; font-size: 14px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

.stat { display: flex; flex-direction: column; gap: 6px; justify-content: center; }
.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 26px; font-weight: 700; }
.stat-clickable { cursor: pointer; transition: box-shadow .15s, border-color .15s; }
.stat-clickable:hover { border-color: var(--accent); background: var(--card-hover); }
.stat-clickable.active { box-shadow: 0 0 0 2px var(--accent) inset; border-color: var(--accent); }
.btn-icon { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 13px; padding: 0 2px; }
.btn-icon:hover { color: var(--accent); }
.stat-value.danger { color: var(--danger); }
.stat-value.warn { color: var(--warn); }

.action-card { align-items: center; justify-content: center; }

.btn {
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  padding: 10px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.btn:hover { opacity: .9; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--accent-soft); color: var(--text); opacity: 1; }

.list { display: flex; flex-direction: column; gap: 10px; }
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.list-item:last-child { border-bottom: none; }

.bar-track { flex: 1; height: 6px; background: var(--accent-soft); border-radius: 4px; margin: 0 12px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); }

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

/* ---------- Reports tab ---------- */
.rpt-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-bottom: 16px; }
.rpt-grid .card { margin-bottom: 0; }
.rpt-desc { color: var(--text-muted); font-size: 13px; line-height: 1.5; margin: -4px 0 12px; }
.rpt-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.rpt-actions[hidden] { display: none; }
.rpt-field { display: flex; flex-direction: column; gap: 4px; max-width: 320px; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.rpt-field select, .rpt-field input, .rpt-field textarea, .rpt-schedule select, .rpt-sla-input {
  padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text);
  font: inherit; font-size: 13px; font-weight: 400;
}
.rpt-wide { max-width: 680px; margin-top: 4px; }
.rpt-wide textarea { width: 100%; box-sizing: border-box; resize: vertical; min-height: 44px; }
.rpt-hint { display: block; margin-top: 4px; font-size: 12px; color: var(--text-muted); }
.rpt-schedule { display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 10px 12px; margin-bottom: 14px; font-size: 13px; }
.rpt-check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.rpt-next { font-size: 12px; color: var(--text-muted); }
.rpt-formats { display: flex; align-items: center; gap: 16px; border: 0; padding: 0; margin: 12px 0 0; font-size: 13px; }
.rpt-formats legend { float: left; padding: 0; margin-right: 4px; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.rpt-formats label { display: flex; align-items: center; gap: 6px; }
.rpt-result { min-height: 1.2em; margin: 8px 0 0; font-size: 13px; color: var(--text-muted); }
.rpt-result.ok, .rpt-ok { color: var(--success); }
.rpt-result.err, .rpt-err { color: var(--danger); }
.rpt-readonly { margin: 8px 0 0; font-size: 12px; color: var(--text-muted); }
.rpt-warning { margin-bottom: 12px; padding: 8px 12px; border: 1px solid var(--warn-fill); border-radius: 8px; background: var(--warn-wash); color: var(--warn); font-size: 13px; }
.rpt-warning[hidden] { display: none; }
.rpt-table-wrap { overflow-x: auto; margin-top: 12px; contain: inline-size; }
.rpt-sla-input { width: 110px; }
.rpt-muted { color: var(--text-muted); }
@media (max-width: 640px) {
  .rpt-schedule { grid-template-columns: 1fr; }
  .rpt-schedule select { justify-self: start; }
}
/* One neutral colour for every column heading. Colour is reserved for values
   that carry state - a failed SMART check, a disk at 89%, an interface that's
   down. When the column names are coloured too, the eye can't separate
   decoration from meaning and a genuinely red value stops standing out. */
.table th { text-align: left; font-weight: 600; padding: 8px; border-bottom: 1px solid var(--border); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; background: var(--table-head-bg); color: var(--table-head-text); }
.table td { padding: 7px 8px; border-bottom: 1px solid var(--border); }
.table tbody tr:hover { background: var(--row-hover); }

.badge { padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge.success { background: var(--ov-green-soft); color: var(--success); }
.badge.error, .badge.client_error { background: var(--ov-red-soft); color: var(--danger); }
.badge.timeout { background: var(--ov-orange-soft); color: var(--warn); }

/* Event feed cards: a severity-tinted background (not just the border) so a
   critical run of events reads as visually "hot" at a glance while scanning
   the feed, not just via a thin colored line. */
.event-card { border-left-width: 4px; border-left-style: solid; }
.event-card-critical { border-left-color: var(--danger-fill); background: var(--danger-wash); }
.event-card-warning { border-left-color: var(--warn-fill); background: var(--warn-wash); }
.event-card-info { border-left-color: var(--text-muted); }

/* Section heading used to introduce a block of the Overview tab (e.g. "This
   System") - a size step above a card's own <h3> so it reads as the parent
   of the cards beneath it rather than another card title. */
.section-heading { display: flex; align-items: baseline; gap: 10px; margin: 22px 0 6px; }
.section-heading h2 { font-size: 20px; font-weight: 700; margin: 0; }
.section-heading .sub { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.section-heading:first-child { margin-top: 0; }

.error-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.error-item:last-child { border-bottom: none; }
.error-item .msg { font-weight: 600; }
.error-item .meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.error-item pre { background: var(--bg); padding: 8px; border-radius: 6px; font-size: 11px; overflow-x: auto; margin-top: 6px; }

pre { background: var(--bg); padding: 12px; border-radius: 8px; overflow-x: auto; font-size: 12px; border: 1px solid var(--border); }
code { font-family: "SF Mono", Consolas, monospace; }

.plain-list { font-size: 13px; line-height: 1.8; padding-left: 20px; }

.empty { color: var(--text-muted); font-size: 13px; padding: 20px 0; text-align: center; }

/* Always-visible "this is clickable" affordance - a colored left edge plus a
   small chevron, so a clickable stat tile is identifiable at a glance rather
   than only on hover. Used consistently on every clickable stat tile across
   every tab (Overview, Fleet, Uptime, Database, IPAM, API Requests, etc.). */
.tile-clickable {
  cursor: pointer;
  position: relative;
  border-left: 3px solid var(--accent);
  padding-left: 15px;
}
.tile-clickable::after {
  content: '\203A';
  position: absolute;
  top: 10px;
  right: 12px;
  color: var(--accent);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  opacity: .7;
}
.tile-clickable:hover {
  background: var(--accent-soft);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.tile-clickable:hover::after { opacity: 1; }

/* State borders. A card's left edge says what state the thing is in, using the
   same four colours everywhere: neutral, healthy, warning, critical. */
.state-card { border-left: 4px solid var(--border); }
.state-healthy { border-left-color: var(--success-fill); }
.state-warning { border-left-color: var(--warn-fill); }
.state-critical { border-left-color: var(--danger-fill); }
.state-info { border-left-color: var(--accent); }

/* Utilisation meter: the number says how much, the bar says how it feels. */
.meter { height: 6px; border-radius: 4px; background: var(--border); overflow: hidden; margin: 6px 0 4px; }
.meter > span { display: block; height: 100%; border-radius: 4px; background: var(--success-fill); transition: width .3s; }
.meter-warning > span { background: var(--warn-fill); }
.meter-critical > span { background: var(--danger-fill); }
.meter-inline { display: inline-block; width: 90px; vertical-align: middle; margin: 0 8px 0 0; }

.status-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 20px; }
.status-pill.healthy { background: var(--ov-green-soft); color: var(--ov-green); }
.status-pill.warning { background: var(--ov-orange-soft); color: var(--ov-orange); }
.status-pill.critical { background: var(--ov-red-soft); color: var(--ov-red); }
.status-pill.neutral  { background: var(--bg-2); color: var(--text-muted); }

/* Detail tables read better as plain sections than as another rounded card. */
.flat-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 18px; }
.kv-grid > div { min-width: 0; }
/* Aligned label/value pairs. The label column sizes to the longest label in
   the group, so values line up in a readable column instead of sitting flush
   against whatever text precedes them. */
.spec-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 2px 28px; }
.spec-row { display: grid; grid-template-columns: minmax(120px, 40%) 1fr; gap: 12px; padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 13px; align-items: baseline; }
.spec-row:last-child { border-bottom: none; }
.spec-row > span:first-child { color: var(--text-muted); }
.spec-row > span:last-child { color: var(--text); font-weight: 600; text-align: right; word-break: break-word; }

/* Collapsible sections. The heading carries a chevron and toggles everything
   below it; collapsing leaves only the headings, so a long machine page can be
   skimmed as a table of contents. */
.collapsible > h3:first-of-type { cursor: pointer; user-select: none; display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.collapsible > h3:first-of-type::before {
  content: '▾'; font-size: 11px; color: var(--text-muted); transition: transform .15s; display: inline-block;
}
.collapsible.collapsed > h3:first-of-type::before { transform: rotate(-90deg); }
.collapsible.collapsed > h3:first-of-type { margin-bottom: 0; }
.collapsible.collapsed > :not(h3:first-of-type) { display: none !important; }
.collapsible > h3:first-of-type:hover { color: var(--accent); }
.collapsible > h3:first-of-type .sec-hint { margin-left: auto; font-size: 11px; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--text-muted); }

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { cursor: pointer; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
  border-radius: 20px; padding: 3px 12px; font-size: 12px; font-weight: 600; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--on-color); }

.kv-label { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 600; }
.kv-value { font-size: 13px; color: var(--text); margin-top: 2px; word-break: break-word; }

/* Machine identity follows you down a long page - on a fleet of similar
   servers, scrolling past the header otherwise leaves no way to tell which
   machine you're reading. */
.sticky-summary {
  /* Sits directly beneath the navigation, never over it: the topbar is itself
     sticky at z-index 5, so this docks at the topbar's measured height (it
     wraps to two rows on narrow windows, so the offset can't be a constant)
     and stays behind it in the stacking order. */
  position: sticky; top: var(--topbar-h, 64px); z-index: 4;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 14px; margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  font-size: 13px;
}
.sticky-summary .name { font-weight: 700; font-size: 14px; }
/* Name over IP · location · OS · status · last seen, so the bar still says which machine this is. */
.sticky-summary .sticky-ident { display: inline-flex; flex-direction: column; min-width: 0; }
.sticky-summary .sticky-ident .dev-id-meta { font-size: 11.5px; }
.fleet-page-ident .dev-id-meta { font-size: 13px; margin-top: 4px; }
.fleet-modal-ident { margin: -8px 0 4px; }
.fleet-modal-ident .dev-id-meta { font-size: 13px; }
.sticky-summary .metric { color: var(--text-muted); }
.sticky-summary .metric b { color: var(--text); font-weight: 600; }
/* The health word beside the status emoji, so the level reads without colour. */
.sticky-summary .sticky-state { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; }

.filter-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--accent-soft); border-radius: 8px; padding: 8px 12px;
  margin-bottom: 10px; font-size: 13px;
}
.filter-bar[hidden] { display: none; }

#api-requests-table tbody tr { cursor: pointer; }
#api-requests-table tbody tr:hover { background: var(--accent-soft); }

.clickable-row { cursor: pointer; }
.clickable-row:hover { background: var(--accent-soft); }

.modal-overlay {
  position: fixed; inset: 0; background: var(--overlay);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
/* Leaf detail popup opened from within other modals (e.g. a row in a
   per-source/per-host drill-down) - always paint on top regardless of DOM
   order, which otherwise depends on source order for equal z-index siblings. */
#request-modal, #db-session-detail-modal, #gpu-detail-modal, #iface-detail-modal, #process-detail-modal,
#flow-drill-modal { z-index: 60; }
.modal-overlay[hidden] { display: none; }
.modal-box {
  background: var(--surface); border-radius: var(--radius); padding: 20px 24px;
  max-width: 560px; width: 90%; max-height: 80vh; overflow-y: auto; position: relative;
}
.modal-box h3 { margin: 0 0 12px; }
.modal-close {
  position: absolute; top: 14px; right: 16px; background: none; border: none;
  font-size: 20px; line-height: 1; color: var(--text-muted); cursor: pointer;
}
.modal-close:hover { color: var(--text); }
.modal-row { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.modal-row:last-child { border-bottom: none; }
.modal-row .k { color: var(--text-muted); flex-shrink: 0; }
.modal-row .v { text-align: right; word-break: break-all; }
/* An identity block in a key/value row lines up with the other right-aligned values. */
.modal-row .v > .dev-id { align-items: flex-end; word-break: normal; overflow-wrap: anywhere; }
.modal-row .v > .dev-id .dev-id-meta { justify-content: flex-end; }

.modal-box-wide { max-width: 900px; }

.period-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; }
.period-btn {
  border: 1px solid var(--border); background: var(--bg); color: var(--text-muted);
  padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 600;
}
.period-btn:hover { background: var(--accent-soft); color: var(--text); }
.period-btn.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.custom-range-bar {
  display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 14px; font-size: 12px;
}
.custom-range-bar label { display: flex; flex-direction: column; gap: 4px; color: var(--text-muted); font-weight: 600; }
.custom-range-bar label[hidden] { display: none; }
.custom-range-bar input[type="datetime-local"] {
  border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; background: var(--surface); color: var(--text); font-size: 12px;
}
.custom-range-bar[hidden] { display: none; }

.data-note {
  background: var(--accent-soft); color: var(--text); border-radius: 8px;
  padding: 10px 14px; margin-bottom: 12px; font-size: 13px;
}
.data-note[hidden] { display: none; }

.process-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 18px; }
@media (max-width: 700px) { .process-cols { grid-template-columns: 1fr; } }
.process-cols h4 { margin: 0 0 8px; font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.process-row { display: flex; justify-content: space-between; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.process-row:last-child { border-bottom: none; }
.process-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.process-row .val { flex-shrink: 0; font-weight: 600; }

/* Health-based coloring: applied dynamically via JS based on thresholds */
.health-ok { color: var(--success) !important; }
.health-warn { color: var(--warn) !important; }
.health-danger { color: var(--danger) !important; }
/* ▲ / ✕ after a coloured percentage (healthMark), so the level reads
   without colour. Small, so table cells do not grow. */
.health-mark { font-size: .75em; font-weight: 700; white-space: nowrap; }

/* ---------- responsive: tablet ---------- */
@media (max-width: 900px) {
  main { padding: 16px 14px 50px; }
  .topbar { padding: 12px 14px; }
  .modal-box-wide { max-width: 100%; }
}

/* On narrow screens the sidebar becomes an off-canvas drawer, opened by the
   hamburger in the top bar. */
@media (max-width: 820px) {
  .sidebar {
    position: fixed; left: 0; top: 0; height: 100vh;
    transform: translateX(-100%); transition: transform .2s ease;
    z-index: 30; box-shadow: var(--shadow-drawer);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  /* "Hide the menu" is a desktop choice, remembered per browser: it must not
     leave the phone drawer empty. */
  .sidebar.collapsed { display: flex; width: 214px; padding: 14px 10px; }
  .sidebar.collapsed .tab-label, .sidebar.collapsed .brand h1 { display: revert; }
  .sidebar.collapsed .tab-btn { justify-content: flex-start; padding: 9px 14px; gap: 10px; }
  .sidebar.collapsed .brand { align-items: flex-start; }
  .sidebar.collapsed .brand-logo { display: block; }
  .sidebar.collapsed .brand-mark { display: none; }
  body.sidebar-open::after {
    content: ""; position: fixed; inset: 0; background: var(--scrim); z-index: 25;
  }
  .topbar .sidebar-toggle { display: flex; }
}

/* ---------- responsive: mobile ---------- */
@media (max-width: 600px) {
  .brand h1 { font-size: 16px; }
  main { padding: 12px 10px 40px; }
  .topbar { padding: 10px 12px; gap: 8px; }
  .topbar-search input { width: 140px; } /* room for the status chip, bell and account on a 375px phone */
  .avatar-btn #current-username { display: none; } /* the account icon stays; the name is in the menu's own rows */

  .grid-4, .grid-5, .grid-6, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .card { padding: 12px 14px; }
  .stat-value { font-size: 22px; }

  .modal-box { padding: 16px 14px; width: 94%; max-height: 88vh; }

  /* Inline min-width on form inputs (set for desktop layouts) forces
     horizontal overflow on a phone-width screen; let them fill their row
     instead once custom-range-bar/flex wrapping stacks each label. */
  .custom-range-bar { flex-direction: column; align-items: stretch; }
  .custom-range-bar label { width: 100%; }
  .custom-range-bar input, .custom-range-bar select {
    min-width: 0 !important; width: 100%;
  }

  .table { font-size: 12px; }
  .table th, .table td { padding: 6px; }
}

/* Autocomplete for the device lookup. A native <datalist> was already there but
   could only offer bare addresses, which is the least useful thing to search
   by - so this is a real suggestion list that can show a name, a detail line
   and where the match came from. */
.ac-wrap { position: relative; display: inline-block; }
.ac-list {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px);
  max-height: 320px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow-md);
}
.ac-item { padding: 7px 10px; cursor: pointer; border-bottom: 1px solid var(--border); }
.ac-item:last-child { border-bottom: none; }
/* Hover and keyboard selection share one style, so arrowing through the list
   looks the same as pointing at it. */
.ac-item:hover, .ac-item.ac-active { background: var(--row-hover); }
.ac-item .ac-primary { font-size: 13px; }
.ac-item .ac-secondary { font-size: 11px; color: var(--text-muted); }
.ac-empty { padding: 8px 10px; font-size: 13px; color: var(--text-muted); }

/* Maintenance forms. The rest of this dashboard styles inputs inline; these
   forms have enough fields that repeating the same eight declarations per
   input made the markup unreadable. */
.mt-in {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}
.mt-in:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
/* Required-field marker, so a form does not have to be submitted to find out
   what it needs. */
.mt-req { color: var(--danger); font-weight: 700; }

/* The working time zone, stamped under every date and time input. The banner
   at the top of the tab says it once, but someone typing "22:00" is looking
   at the field, not the banner. */
.mt-tzhint {
  display: block;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: .02em;
  color: var(--text-muted);
  margin-top: 2px;
}

/* A source that has stopped reporting: dimmed, so the row reads as history
   rather than as current traffic. */
.api-source-stale { opacity: .72; }

/* ---------- RAID + iDRAC (machine page) ---------- */
.raid-array { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; }
.raid-array-head { font-size: 13px; margin-bottom: 6px; line-height: 1.8; }
.idrac-fans { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; }
.idrac-fan { white-space: nowrap; }

/* ---------- Fleet report / Fleet -> Assets / employee import ---------- */
.fleet-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.frp-sub { color: var(--text-muted); font-size: 13px; margin: -4px 0 12px; line-height: 1.5; }
.frp-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.frp-box { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px 10px; margin: 0; min-width: 0; }
.frp-box legend { font-weight: 600; font-size: 13px; padding: 0 4px; }
.frp-opt { display: flex; gap: 6px; align-items: flex-start; font-size: 13px; margin: 4px 0; cursor: pointer; line-height: 1.4; }
.frp-opt input { margin-top: 2px; flex-shrink: 0; }
.frp-opt.disabled { color: var(--text-muted); cursor: not-allowed; }
.frp-list { max-height: 210px; overflow-y: auto; margin: 4px 0; }
.frp-list:empty { display: none; }
.frp-list .frp-opt { margin: 2px 0; }
.frp-inline { display: flex; gap: 6px; align-items: center; font-size: 13px; margin-top: 8px; flex-wrap: wrap; }
.frp-inline[hidden] { display: none; }
.frp-count { font-size: 12px; color: var(--text-muted); margin-top: 8px; }
.frp-links { font-size: 12px; margin: 2px 0 4px; }
.frp-msg { font-size: 13px; margin-top: 10px; min-height: 1em; }
.frp-msg.error { color: var(--danger); }
.frp-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.frp-tag { font-size: 11px; color: var(--text-muted); }
.fla-machines { max-height: 220px; border: 1px solid var(--border); border-radius: 8px; padding: 4px 10px; }
.fla-result { margin-top: 10px; font-size: 13px; }
.fla-result table, .emp-imp-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 8px; }
.fla-result th, .fla-result td, .emp-imp-table th, .emp-imp-table td { text-align: left; vertical-align: top; padding: 5px 6px; border-bottom: 1px solid var(--border); }
.fla-result th, .emp-imp-table th { color: var(--text-muted); font-weight: 600; }
.fla-change { white-space: normal; word-break: break-word; }
.fla-change s { color: var(--text-muted); }
.fla-warn { color: var(--warn); }
.fla-err { color: var(--danger); }
.emp-xfer { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.emp-xfer-k { font-size: 11px; color: var(--text-muted); margin-left: 6px; }
.emp-xfer-btn { padding: 3px 9px; font-size: 12px; }
.emp-imp-scroll { max-height: 360px; overflow: auto; }
/* The tile breakdown: three summary columns, then the request list. */
.abd-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.abd-box { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px 10px; min-width: 0; }
.abd-box h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.abd-row { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; font-size: 13px; border-bottom: 1px solid var(--border); }
.abd-row:last-child { border-bottom: none; }
.abd-row .abd-k { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.abd-row .abd-n { flex-shrink: 0; font-variant-numeric: tabular-nums; }
.abd-row.clickable-row { cursor: pointer; }
.abd-row.clickable-row:hover { background: var(--accent-soft); }
.abd-list { max-height: 320px; overflow: auto; }
.abd-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0 0 10px; }
@media (max-width: 820px) { .abd-grid { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  .frp-grid { grid-template-columns: 1fr; }
  .fleet-actions { margin-left: 0; }
  .fla-result, .emp-imp-scroll { overflow-x: auto; }
}

/* ---------- theme switch (account menu) ---------- */
.theme-row { display: flex; gap: 4px; padding: 4px 4px 8px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.theme-row .theme-opt {
  flex: 1; padding: 6px 4px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2);
  color: var(--text-muted); font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.theme-row .theme-opt:hover { color: var(--text); border-color: var(--accent); }
.theme-row .theme-opt.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.theme-row-label { font-size: 11px; color: var(--text-muted); padding: 2px 6px 4px; }
/* Smooth the switch; nothing else animates colour, so this stays cheap. */
body, .card, .sidebar, .topbar, .table th { transition: background-color .18s ease, color .18s ease, border-color .18s ease; }

/* Printing always uses the light palette on a plain page: a dark theme
   would otherwise print as pages of navy. */
@media print {
  /* The third selector covers "Match Windows" (no attribute) at the same
     specificity as the dark media block, so print wins there too. */
  :root, :root[data-theme="dark"], :root:not([data-theme="light"]) {
    --bg: #ffffff; --bg-2: #ffffff; --surface: #ffffff; --border: #cbd5e1; --text: #0f172a; --text-muted: #475569;
    --table-head-bg: #f1f5f9; --table-head-text: #334155; --row-hover: #ffffff; --surface-2: #f1f5f9; --card-hover: #ffffff; --page-glow: transparent;
    --topbar-bg: #ffffff; --topbar-text: #0f172a; --topbar-muted: #475569;
    --shadow-sm: none; --shadow-md: none; --overlay: transparent;
    /* The status and accent tokens too: dark is now the default, and a note
       box or a health colour left on its dark value is unreadable on paper. */
    --accent: #2563eb; --accent-soft: #eff6ff; --accent-glow: transparent; --border-strong: #64748b;
    --success: #15803d; --warn: #b45309; --danger: #b91c1c; --danger-fill: #DC2626; --success-fill: #16A34A; --warn-fill: #F59E0B; --info-fill: #06B6D4; --on-accent: #ffffff; --on-color: #ffffff;
    --warn-wash: rgba(217,119,6,.06); --danger-wash: rgba(220,38,38,.06);
    --ov-blue: #1d4ed8; --ov-blue-soft: #dbeafe; --ov-purple: #7c3aed; --ov-purple-soft: #ede9fe; --ov-green: #15803d; --ov-green-soft: #dcfce7;
    --ov-orange: #b45309; --ov-orange-soft: #fef3c7; --ov-red: #b91c1c; --ov-red-soft: #fee2e2; --ov-cyan: #0e7490; --ov-cyan-soft: #cffafe;
    --th-1: #0e7490; --th-2: #2563eb; --th-3: #7c3aed; --th-4: #15803d; --th-5: #b45309; --th-6: #be185d; --th-7: #4338ca; --th-8: #ea580c;
    color-scheme: light;
  }
  body { background: #ffffff; }
  .sidebar, .topbar, .modal-overlay { display: none !important; }
}

/* The NOC look: controls use the page font, and form fields have a boundary
   that reads against a dark card (the card border alone is too faint). */
button, input, select, textarea { font-family: inherit; }
/* Re-pointing the token on the controls themselves reaches every
   "border: 1px solid var(--border)" a field carries - class rules, the
   datetime pickers, the inline styles in index.html and the sign-in page. */
input, select, textarea { --border: var(--border-strong); }
.topbar-search input:focus, .ast-in:focus, .mt-in:focus { border-color: var(--accent); }
