/* ============================================================
   METRICIZE — command-center design system
   Dark default · light available · indigo accent
   Custom UI + a bridge that themes the retained Radzen / ApexCharts
   charts so they are visually indistinguishable from the rest of the app.
   ============================================================ */

:root {
  /* ---- accent (brand / UI chrome) : indigo ---- */
  --accent: #6366f1;
  --accent-bright: #8b8efb;
  --accent-dim: rgba(99, 102, 241, 0.16);
  --accent-line: rgba(99, 102, 241, 0.38);

  /* ---- health palette (semantic — stable across themes) ---- */
  --h-healthy: #2fcf6b;   /* Healthy  >= 90 */
  --h-good:    #38bdf8;   /* Good     80-89 */
  --h-degraded:#f5a524;   /* Degraded 50-79 */
  --h-critical:#fb3b5c;   /* Critical  < 50 */
  --h-inactive:#64748b;   /* no data / abandoned */

  --h-healthy-soft:  rgba(47, 207, 107, 0.14);
  --h-good-soft:     rgba(56, 189, 248, 0.14);
  --h-degraded-soft: rgba(245, 165, 36, 0.15);
  --h-critical-soft: rgba(251, 59, 92, 0.15);
  --h-inactive-soft: rgba(100, 116, 139, 0.16);

  /* ---- Microsoft Teams brand purple (used for the active-call chip) ---- */
  --teams:      #7b83eb;
  --teams-soft: rgba(123, 131, 235, 0.16);

  --radius-xs: 6px;
  --radius-sm: 9px;
  --radius:    13px;
  --radius-lg: 18px;

  --rail-w: 234px;
  --topbar-h: 54px;

  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-ui: "Hanken Grotesk", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --shadow-1: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-2: 0 6px 24px rgba(0,0,0,0.34);
  --shadow-pop: 0 18px 50px rgba(0,0,0,0.55);
}

/* ---------------- DARK (default) ---------------- */
:root, [data-theme="dark"] {
  --bg:        #0a0c12;
  --bg-grad:   radial-gradient(1200px 700px at 78% -8%, rgba(99,102,241,0.10), transparent 60%);
  --surface:   #11141d;
  --surface-2: #161a25;
  --surface-3: #1c2130;
  --surface-hi:#222838;
  --border:    rgba(255,255,255,0.07);
  --border-2:  rgba(255,255,255,0.12);
  --border-strong: rgba(255,255,255,0.18);

  --text:      #f2f5fa;
  --text-2:    #b8c1d2;
  --text-3:    #8a93a8;
  --text-mute: #5c6478;

  --rail-bg:   #0c0e16;
  --chip-bg:   rgba(255,255,255,0.05);
  --track:     rgba(255,255,255,0.08);
}

/* ---------------- LIGHT ---------------- */
[data-theme="light"] {
  --bg:        #eef0f5;
  --bg-grad:   radial-gradient(1100px 650px at 80% -10%, rgba(99,102,241,0.08), transparent 60%);
  --surface:   #ffffff;
  --surface-2: #f6f7fb;
  --surface-3: #eef0f6;
  --surface-hi:#e6e9f2;
  --border:    rgba(15,23,42,0.09);
  --border-2:  rgba(15,23,42,0.14);
  --border-strong: rgba(15,23,42,0.22);

  --text:      #11151f;
  --text-2:    #4a5365;
  --text-3:    #79839a;
  --text-mute: #9aa3b5;

  --rail-bg:   #0c0e16;          /* keep rail dark in light mode for that command feel */
  --chip-bg:   rgba(15,23,42,0.04);
  --track:     rgba(15,23,42,0.08);

  --shadow-1: 0 1px 2px rgba(15,23,42,0.06);
  --shadow-2: 0 6px 22px rgba(15,23,42,0.10);
  --shadow-pop: 0 20px 50px rgba(15,23,42,0.22);
}

/* ============================================================
   RADZEN / APEXCHARTS THEME BRIDGE
   Maps Radzen's design tokens onto the command-center palette so
   the retained charts (and any Radzen dialog chrome) inherit the
   exact same colors, type and surfaces as the custom UI.
   Loaded AFTER the Radzen base theme so these win the cascade.
   ============================================================ */
:root, [data-theme="dark"], [data-theme="light"] {
  --rz-primary: var(--accent);
  --rz-primary-light: var(--accent-bright);
  --rz-primary-lighter: var(--accent-dim);
  --rz-secondary: var(--text-2);
  --rz-success: var(--h-healthy);
  --rz-success-light: var(--h-healthy-soft);
  --rz-success-lighter: var(--h-healthy-soft);
  --rz-info: var(--h-good);
  --rz-info-light: var(--h-good-soft);
  --rz-info-lighter: var(--h-good-soft);
  --rz-warning: var(--h-degraded);
  --rz-warning-light: var(--h-degraded-soft);
  --rz-warning-lighter: var(--h-degraded-soft);
  --rz-danger: var(--h-critical);
  --rz-danger-light: var(--h-critical-soft);
  --rz-danger-lighter: var(--h-critical-soft);

  --rz-text-color: var(--text);
  --rz-text-secondary-color: var(--text-2);
  --rz-text-tertiary-color: var(--text-3);
  --rz-text-disabled-color: var(--text-mute);
  --rz-text-title-color: var(--text);

  --rz-base: var(--surface);
  --rz-base-50:  var(--surface);
  --rz-base-100: var(--surface-2);
  --rz-base-200: var(--surface-3);
  --rz-base-300: var(--border-2);
  --rz-base-400: var(--text-3);
  --rz-base-background-color: var(--bg);

  --rz-body-background-color: var(--bg);
  --rz-card-background-color: var(--surface);
  --rz-panel-background-color: var(--surface);
  --rz-border-color: var(--border);
  --rz-border-radius: var(--radius-sm);

  --rz-link-color: var(--accent-bright);

  /* chart series palette */
  --rz-series-1: var(--accent);
  --rz-series-2: var(--h-good);
  --rz-series-3: var(--h-healthy);
  --rz-series-4: var(--h-degraded);
  --rz-series-5: var(--h-critical);
  --rz-series-6: #a855f7;
  --rz-series-7: #14b8a6;
  --rz-series-8: #ec4899;

  --rz-grid-cell-color: var(--text);
  --rz-grid-color: var(--surface);
  --rz-grid-stripe-background-color: var(--surface-2);
  --rz-grid-header-background-color: var(--surface);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body { background-image: var(--bg-grad); background-attachment: fixed; }

#app { height: 100%; display: block; }

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

h1,h2,h3,h4 { font-family: var(--font-display); font-weight: 600; margin: 0; letter-spacing: -0.01em; color: var(--text); }
button { font-family: inherit; cursor: pointer; }
a { color: var(--accent-bright); }
.mono { font-family: var(--font-mono); font-feature-settings: "tnum" 1; }

/* scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--border-strong); background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   APP SHELL
   ============================================================ */
.app { height: 100%; display: grid; grid-template-rows: var(--topbar-h) 1fr; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  height: var(--topbar-h);
  padding: 0 16px 0 0;
  background: color-mix(in srgb, var(--bg) 86%, #000 14%);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  position: relative; z-index: 40;
}

/* wordmark */
.brand { display: flex; align-items: center; gap: 10px; width: var(--rail-w); padding-left: 18px; flex: none; }
.brand-mark { width: 24px; height: 24px; position: relative; flex: none; }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 19px; letter-spacing: 0.5px; color: var(--text); }
.brand-name b { color: var(--accent-bright); font-weight: 600; }

.topbar-search {
  flex: 1; max-width: 460px;
  display: flex; align-items: center; gap: 10px;
  height: 36px; padding: 0 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-3);
  transition: border-color .15s, background .15s;
}
.topbar-search:hover { border-color: var(--border-2); }
.topbar-search .kbd { margin-left: auto; }
.kbd {
  font-family: var(--font-mono); font-size: 11px; color: var(--text-3);
  background: var(--chip-bg); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 6px; line-height: 1.5;
}

.topbar-spacer { flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.greeting { color: var(--text-2); font-size: 13px; margin-right: 4px; }
.greeting b { color: var(--text); font-weight: 600; }

.iconbtn {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-2);
  transition: all .15s;
}
.iconbtn:hover { color: var(--text); border-color: var(--border-2); background: var(--surface-3); }
.iconbtn svg { width: 17px; height: 17px; }

/* shell body */
.shell { display: grid; grid-template-columns: var(--rail-w) 1fr; min-height: 0; }

/* ---------------- SIDEBAR ---------------- */
.rail {
  background: var(--rail-bg);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 12px 12px 12px;
  overflow-y: auto; min-height: 0;
}
.rail-section-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: #5a6377; padding: 0 10px; margin: 14px 0 7px;
}
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: 10px;
  color: #aeb6c8; background: transparent; border: 1px solid transparent;
  text-align: left; width: 100%; font-size: 13.5px; font-weight: 500;
  transition: all .14s; text-decoration: none;
}
.nav-item svg { width: 18px; height: 18px; flex: none; opacity: 0.9; }
.nav-item:hover { background: rgba(255,255,255,0.045); color: #e7eaf2; }
.nav-item.active { background: var(--accent-dim); color: #fff; border-color: var(--accent-line); }
.nav-item.active svg { color: var(--accent-bright); opacity: 1; }
.nav-count {
  margin-left: auto; font-family: var(--font-mono); font-size: 11px;
  color: #8b93a7; background: rgba(255,255,255,0.06); padding: 1px 7px; border-radius: 99px;
}
.nav-item.active .nav-count { color: #fff; background: rgba(255,255,255,0.14); }

/* fleet health panel */
.fleet {
  margin-top: 10px;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.015));
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 14px;
}
.fleet-top { display: flex; align-items: center; gap: 12px; margin-bottom: 13px; }
.fleet-score { font-family: var(--font-mono); font-size: 30px; font-weight: 700; line-height: 1; }
.fleet-meta { font-size: 11px; color: #828ba0; }
.fleet-meta b { display:block; font-family: var(--font-display); font-size: 12.5px; color: #c8cedb; font-weight: 600; letter-spacing: .02em; }

.fleet-bar { height: 8px; border-radius: 99px; overflow: hidden; display: flex; background: rgba(255,255,255,0.06); }
.fleet-bar span { display: block; height: 100%; }

.fleet-legend { display: flex; flex-direction: column; gap: 2px; margin-top: 11px; }
.fleet-leg {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 5px 7px; border-radius: 8px; background: transparent; border: 1px solid transparent;
  color: #aeb6c8; font-size: 12.5px; transition: all .13s;
}
.fleet-leg:hover { background: rgba(255,255,255,0.05); }
.fleet-leg.on { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.1); color: #fff; }
.fleet-leg .dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.fleet-leg .lbl { font-weight: 500; }
.fleet-leg .n { margin-left: auto; font-family: var(--font-mono); font-size: 12px; color: #cfd5e2; }

.rail-attn { display: flex; flex-direction: column; gap: 5px; }
.rail-attn-item {
  display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: 9px;
  background: transparent; border: 1px solid transparent; text-align: left; width: 100%; transition: background .13s;
}
.rail-attn-item:hover { background: rgba(255,255,255,0.05); }
.rail-attn-item .dot { width: 7px; height: 7px; border-radius: 99px; flex: none; }
.rail-attn-item .nm { font-size: 12.5px; color: #cfd5e2; min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-attn-item .sc { font-family: var(--font-mono); font-size: 12px; font-weight: 700; }

.rail-foot { margin-top: auto; padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.rail-user { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.06); }
.rail-user .nm { font-size: 12.5px; color: #e7eaf2; font-weight: 600; line-height: 1.2; }
.rail-user .rl { font-size: 11px; color: #828ba0; }

/* ---------------- CONTENT ---------------- */
.content { min-width: 0; overflow-y: auto; min-height: 0; }
.page { padding: 18px 22px 40px; max-width: 1640px; margin: 0 auto; }

/* page header bar (sticky on detail pages) */
.pagehead {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 22px; position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.pagehead h1 { font-size: 21px; }

/* ============================================================
   PRIMITIVES
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.card-pad { padding: 16px 18px; }

.section-title {
  font-family: var(--font-display); font-size: 13px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3);
  display: flex; align-items: center; gap: 9px; margin: 0 0 13px;
}
.section-title .ico { width: 15px; height: 15px; color: var(--text-3); }

/* field grid for detail pages */
.fields { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px 22px; }
.fields.cols-1 { grid-template-columns: 1fr; }
.fields.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.fields.cols-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.field-k { font-size: 10.5px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-3); margin-bottom: 3px; }
.field-v { font-size: 13.5px; color: var(--text); font-weight: 500; line-height: 1.35; word-break: break-word; }
.field-v.mono { font-size: 13px; }

/* badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 99px; line-height: 1.4; white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 99px; }
.badge.healthy  { color: var(--h-healthy);  background: var(--h-healthy-soft); }
.badge.good     { color: var(--h-good);     background: var(--h-good-soft); }
.badge.degraded { color: var(--h-degraded); background: var(--h-degraded-soft); }
.badge.critical { color: var(--h-critical); background: var(--h-critical-soft); }
.badge.inactive { color: var(--h-inactive); background: var(--h-inactive-soft); }
.badge.neutral  { color: var(--text-2); background: var(--chip-bg); }
.badge.online   { color: var(--h-healthy); background: var(--h-healthy-soft); }
.badge.offline  { color: var(--text-3); background: var(--chip-bg); }
.badge.info     { color: var(--h-good); background: var(--h-good-soft); }
.badge.warning  { color: var(--h-degraded); background: var(--h-degraded-soft); }
.badge.danger   { color: var(--h-critical); background: var(--h-critical-soft); }
.badge.success  { color: var(--h-healthy); background: var(--h-healthy-soft); }
.badge.teams    { color: var(--teams); background: var(--teams-soft); }

/* pill button */
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 99px; font-size: 12.5px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
  transition: all .14s;
}
.pill:hover { border-color: var(--border-2); color: var(--text); }
.pill.active { background: var(--accent-dim); border-color: var(--accent-line); color: var(--text); }
.pill svg { width: 14px; height: 14px; }

.btn-primary {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 15px; border-radius: 10px; font-weight: 600; font-size: 13px;
  background: var(--accent); border: 1px solid var(--accent); color: #fff;
  transition: all .14s;
}
.btn-primary:hover { background: var(--accent-bright); border-color: var(--accent-bright); }
.btn-primary:disabled { opacity: .5; cursor: default; }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 10px; font-weight: 600; font-size: 13px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); transition: all .14s;
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-2); background: var(--surface-3); }

.input {
  height: 38px; padding: 0 13px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  font-family: inherit; font-size: 13.5px; outline: none; transition: border-color .14s;
}
.input::placeholder { color: var(--text-3); }
.input:focus { border-color: var(--accent-line); }

/* search box (inline) */
.searchbox {
  display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 38px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
}
.searchbox input { background: none; border: none; outline: none; color: var(--text); font-family: inherit; font-size: 13.5px; width: 100%; }
.searchbox input::placeholder { color: var(--text-3); }

/* toggle switch */
.mz-toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.mz-toggle.disabled { opacity: 0.5; cursor: default; }
.mz-toggle input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.mz-switch { width: 36px; height: 20px; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--border-2); position: relative; transition: background .15s, border-color .15s; flex: none; }
.mz-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 99px; background: var(--text-3); transition: transform .18s cubic-bezier(.2,.7,.2,1), background .15s; }
.mz-toggle:hover .mz-switch { border-color: var(--border-strong); }
.mz-toggle input:checked + .mz-switch { background: var(--accent-dim); border-color: var(--accent-line); }
.mz-toggle input:checked + .mz-switch::after { transform: translateX(16px); background: var(--accent-bright); }
.mz-toggle input:focus-visible + .mz-switch { box-shadow: 0 0 0 3px var(--accent-dim); }
.mz-toggle-label { font-size: 13px; color: var(--text-2); }

/* health color helpers */
.hc-healthy  { --hc: var(--h-healthy); }
.hc-good     { --hc: var(--h-good); }
.hc-degraded { --hc: var(--h-degraded); }
.hc-critical { --hc: var(--h-critical); }
.hc-inactive { --hc: var(--h-inactive); }

/* progress / score bar */
.scorebar { height: 7px; border-radius: 99px; background: var(--track); overflow: hidden; }
.scorebar > span { display: block; height: 100%; border-radius: 99px; background: var(--hc, var(--accent)); transition: width .5s cubic-bezier(.2,.7,.2,1); }

/* subscore mini */
.subscore { display: flex; flex-direction: column; gap: 5px; }
.subscore .top { display: flex; align-items: baseline; justify-content: space-between; }
.subscore .k { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; color: var(--text-3); }
.subscore .v { font-family: var(--font-mono); font-size: 15px; font-weight: 700; color: var(--hc, var(--text)); }
.subscore .v.na { color: var(--text-mute); }

/* device chip */
.dev-chip {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  padding: 7px 10px; border-radius: 10px; width: 100%;
  background: var(--surface-2); border: 1px solid var(--border); text-align: left;
  transition: all .14s;
}
.dev-chip:hover { border-color: var(--accent-line); background: var(--surface-3); }
.dev-chip.inactive { border-style: dashed; opacity: 0.72; }
.dev-chip .ic { width: 15px; height: 15px; color: var(--text-3); flex: none; }
.dev-chip .nm { font-size: 12.5px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev-chip .md { font-size: 11px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev-chip .sc { margin-left: auto; font-family: var(--font-mono); font-weight: 700; font-size: 13px; color: var(--hc); flex: none; }

/* tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
  padding: 10px 14px; font-size: 13px; font-weight: 600; color: var(--text-3);
  background: transparent; border: none; border-bottom: 2px solid transparent;
  white-space: nowrap; transition: color .14s; margin-bottom: -1px; display: inline-flex; align-items: center; gap: 7px;
}
.tab:hover { color: var(--text-2); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* table */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-3); padding: 9px 12px; border-bottom: 1px solid var(--border); position: sticky; top: 0;
  background: var(--surface); white-space: nowrap;
}
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--text-2); }
.tbl th .sort-ind { margin-left: 5px; opacity: .8; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.tbl tr:hover td { background: var(--surface-2); }
.tbl .mono { font-size: 12.5px; }
.tbl td.num, .tbl th.num { text-align: right; }
.tbl .group-row td { background: var(--surface-2); font-weight: 700; color: var(--text-2); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.tbl .expand-btn { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); }
.tbl .expand-btn:hover { color: var(--text); border-color: var(--border-2); }
.tbl .detail-row td { background: var(--surface-2); padding: 14px 16px; }

/* pager */
.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; padding: 11px 4px 2px; color: var(--text-3); font-size: 12.5px; }
.pager button { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); }
.pager button:hover:not(:disabled) { color: var(--text); border-color: var(--border-2); }
.pager button:disabled { opacity: .35; cursor: default; }

/* reason / finding row */
.reason { display: flex; gap: 12px; padding: 11px 0; border-top: 1px solid var(--border); }
.reason:first-child { border-top: none; }
.reason .sev {
  font-size: 9.5px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 3px 7px; border-radius: 6px; height: fit-content; flex: none; min-width: 58px; text-align: center;
}
.sev-info { color: var(--h-good); background: var(--h-good-soft); }
.sev-warning { color: var(--h-degraded); background: var(--h-degraded-soft); }
.sev-critical { color: var(--h-critical); background: var(--h-critical-soft); }
.sev-good { color: var(--h-healthy); background: var(--h-healthy-soft); }
.reason .r-title { font-weight: 700; font-size: 13px; color: var(--text); }
.reason .r-desc { font-size: 12.5px; color: var(--text-2); margin-top: 2px; line-height: 1.45; }

/* stat tile */
.stat-tile { padding: 12px 14px; background: var(--surface-2); border-radius: 11px; border: 1px solid var(--border); }
.stat-tile .k { font-size: 10.5px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-3); }
.stat-tile .v { font-family: var(--font-mono); font-size: 19px; font-weight: 700; color: var(--text); margin-top: 3px; }
.stat-tile .sub { color: var(--text-3); font-size: 11px; margin-top: 2px; line-height: 1.3; }
.stat-tile .v { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Quick-stats tiles pack into a dense responsive grid instead of full-width stacked rows.
   Targets exactly the flex rows that directly contain stat tiles — no markup changes needed. */
.stat-grid,
.row.wrap:has(> .stat-tile) {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
  align-items: stretch;
  margin-left: 0;
  margin-right: 0;
}

/* Stat tiles that pair a status chip with a score bar: place the chip to the RIGHT
   of the value (not stacked above the bar). Targets exactly chip+bar tiles. */
.stat-tile:has(> .scorebar):has(> .sub .badge) {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 8px;
  row-gap: 4px;
}
.stat-tile:has(> .scorebar):has(> .sub .badge) > .k { grid-column: 1 / -1; }
.stat-tile:has(> .scorebar):has(> .sub .badge) > .v { grid-column: 1; margin-top: 0; }
.stat-tile:has(> .scorebar):has(> .sub .badge) > .sub { grid-column: 2; justify-self: end; }
.stat-tile:has(> .scorebar):has(> .sub .badge) > .scorebar { grid-column: 1 / -1; }

/* Compact inline date-range + search bar (MzDateRange). Custom class names avoid the
   Bootstrap .card/.row/.col/.btn collisions that stretched the fields and button. */
.mz-dr {
  display: inline-flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  align-self: flex-start;
  max-width: 100%;
  padding: 10px 12px;
  margin-bottom: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.mz-dr-ico { color: var(--text-3); margin-bottom: 9px; flex: none; }
.mz-dr-field { display: inline-flex; flex-direction: column; gap: 5px; flex: none; }
.mz-dr-lbl { font-size: 10.5px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-3); }
.mz-dr-input {
  height: 36px; width: 220px; max-width: 46vw; padding: 0 10px; border-radius: 9px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  font-family: var(--font-mono); font-size: 13px; outline: none; color-scheme: dark;
}
.mz-dr-input:focus { border-color: var(--accent-line); }
.mz-dr-input.invalid, .mz-dr-input.invalid:focus { border-color: var(--h-critical); }
[data-theme="light"] .mz-dr-input { color-scheme: light; }
.mz-dr-btn {
  height: 36px; padding: 0 16px; display: inline-flex; align-items: center; gap: 7px; flex: none;
  border-radius: 9px; background: var(--accent); border: 1px solid var(--accent); color: #fff;
  font-weight: 600; font-size: 13px; white-space: nowrap;
}
.mz-dr-btn:hover:not(:disabled) { background: var(--accent-bright); border-color: var(--accent-bright); }
.mz-dr-btn:disabled { opacity: 0.55; cursor: default; }
.mz-dr-spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff; animation: spin .8s linear infinite; }

/* finding card (mobile / health) */
.finding { background: var(--surface-2); border-radius: 0 10px 10px 0; padding: 13px 15px; border-left: 3px solid var(--h-good); }
.finding.crit { border-left-color: var(--h-critical); }
.finding.warn { border-left-color: var(--h-degraded); }
.finding.info { border-left-color: var(--h-good); }
.finding.good { border-left-color: var(--h-healthy); }

/* avatar */
.av { display: grid; place-items: center; font-family: var(--font-display); font-weight: 600; color: #fff; flex: none; }

/* ---------------- command palette ---------------- */
.cmdk-overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(5,7,12,0.62);
  backdrop-filter: blur(3px); display: flex; justify-content: center; align-items: flex-start;
  padding-top: 11vh; animation: fade .12s ease;
}
.cmdk {
  width: min(640px, 92vw); background: var(--surface); border: 1px solid var(--border-2);
  border-radius: 16px; box-shadow: var(--shadow-pop); overflow: hidden;
  animation: pop .14s cubic-bezier(.2,.8,.2,1);
}
.cmdk-input { display: flex; align-items: center; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.cmdk-input input { flex: 1; background: none; border: none; outline: none; color: var(--text); font-family: inherit; font-size: 16px; }
.cmdk-input input::placeholder { color: var(--text-3); }
.cmdk-list { max-height: 52vh; overflow-y: auto; padding: 7px; }
.cmdk-group { font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); padding: 9px 12px 5px; }
.cmdk-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 9px; cursor: pointer; }
.cmdk-item.sel { background: var(--accent-dim); }
.cmdk-item .ic { width: 16px; height: 16px; color: var(--text-3); flex: none; }
.cmdk-item .nm { font-weight: 600; font-size: 13.5px; color: var(--text); }
.cmdk-item .sub { font-size: 12px; color: var(--text-3); }

/* ---------------- switcher popover ---------------- */
.switcher { position: relative; }
.switch-btn {
  display: flex; align-items: center; gap: 9px; padding: 7px 12px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-weight: 600; font-size: 13px;
  transition: all .14s;
}
.switch-btn:hover { border-color: var(--border-2); background: var(--surface-3); }
.switch-pop {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 60; width: 360px;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 14px;
  box-shadow: var(--shadow-pop); overflow: hidden; animation: pop .13s ease;
}
.switch-pop .sp-search { display: flex; align-items: center; gap: 9px; padding: 11px 13px; border-bottom: 1px solid var(--border); }
.switch-pop .sp-search input { flex: 1; background: none; border: none; outline: none; color: var(--text); font-family: inherit; font-size: 13.5px; }
.switch-pop .sp-list { max-height: 380px; overflow-y: auto; padding: 6px; }
.sp-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; cursor: pointer; }
.sp-row:hover { background: var(--surface-2); }
.sp-row.sel { background: var(--accent-dim); }
.sp-row .nm { font-weight: 600; font-size: 13px; color: var(--text); overflow:hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-row .sub { font-size: 11.5px; color: var(--text-3); }
.sp-row .sc { margin-left: auto; font-family: var(--font-mono); font-weight: 700; font-size: 13px; flex: none; }

/* stepper */
.stepper { display: flex; align-items: center; gap: 1px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.stepper button { width: 32px; height: 34px; display: grid; place-items: center; background: none; border: none; color: var(--text-2); }
.stepper button:hover { background: var(--surface-3); color: var(--text); }
.stepper button:disabled { opacity: 0.3; cursor: default; }
.stepper button svg { width: 16px; height: 16px; }

/* ---------------- chat drawer ---------------- */
.chat-overlay { position: fixed; inset: 0; z-index: 110; background: rgba(5,7,12,0.45); backdrop-filter: blur(2px); animation: fade .14s ease; }
.chat-drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: min(440px, 96vw); z-index: 111;
  background: var(--surface); border-left: 1px solid var(--border-2); box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column; animation: slidein .2s cubic-bezier(.2,.8,.2,1);
}
.chat-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.chat-head .t { font-family: var(--font-display); font-weight: 600; font-size: 15px; }
.chat-head .sub { font-size: 11.5px; color: var(--text-3); }
.chat-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.chat-group { display: flex; flex-direction: column; gap: 3px; max-width: 88%; }
.chat-group.user { align-self: flex-end; align-items: flex-end; }
.chat-group.assistant { align-self: flex-start; align-items: flex-start; }
.chat-msg { padding: 10px 13px; border-radius: 13px; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.chat-msg.user { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.assistant { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-bottom-left-radius: 4px; }
.chat-time { font-size: 10.5px; color: var(--text-3); padding: 0 3px; }
.chat-empty { margin: auto; text-align: center; color: var(--text-3); font-size: 13px; padding: 20px; }
.chat-foot { padding: 12px 14px; border-top: 1px solid var(--border); display: flex; gap: 9px; align-items: flex-end; }
.chat-foot textarea {
  flex: 1; resize: none; max-height: 120px; min-height: 40px; padding: 10px 12px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-family: inherit; font-size: 13.5px; outline: none;
}
.chat-foot textarea:focus { border-color: var(--accent-line); }
.chat-send { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--accent); border: none; color: #fff; }
.chat-send:disabled { opacity: .45; cursor: default; }
.typing { display: inline-flex; align-items: center; gap: 5px; white-space: normal; vertical-align: middle; }
.typing-dot { display: inline-block; width: 6px; height: 6px; border-radius: 99px; background: var(--text-3); animation: blink 1.2s infinite; }

/* ---------------- loading ---------------- */
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--border-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.tab-loading { display: grid; place-items: center; align-content: center; padding: 60px 0; gap: 14px; color: var(--text-3); }
.empty-state { display: grid; place-items: center; align-content: center; padding: 50px 20px; gap: 12px; color: var(--text-3); text-align: center; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes slidein { from { transform: translateX(100%); } to { transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 0%,100% { opacity: .25; } 50% { opacity: 1; } }

.rise { animation: rise .4s cubic-bezier(.2,.7,.2,1) both; }

/* utilities */
.row { display: flex; align-items: center; }
.gap6 { gap: 6px; } .gap8 { gap: 8px; } .gap10 { gap: 10px; } .gap12 { gap: 12px; } .gap16 { gap: 16px; }
.col { display: flex; flex-direction: column; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--text-3); }
.center { display: grid; place-items: center; }
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.grid-2-wide { display: grid; grid-template-columns: 1.5fr 1fr; gap: 14px; align-items: start; }
.linkbtn { background: none; border: none; color: var(--accent-bright); font-weight: 600; cursor: pointer; padding: 0; font-size: inherit; font-family: inherit; }

@media (max-width: 1100px) {
  .grid-2, .grid-2-wide { grid-template-columns: 1fr; }
}
/* ---------------- mobile nav (shown when the rail is hidden) ---------------- */
.mobile-nav { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail { display: none; }
  .mobile-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: color-mix(in srgb, var(--rail-bg) 92%, #000 8%);
    border-top: 1px solid var(--border);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    backdrop-filter: blur(8px);
  }
  .mnav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px 4px; border: none; background: transparent; color: #aeb6c8;
    font-size: 10.5px; font-weight: 600; border-radius: 9px; text-decoration: none;
  }
  .mnav-item svg { width: 18px; height: 18px; }
  .mnav-item.active { color: var(--accent-bright); background: var(--accent-dim); }
  .content { padding-bottom: 68px; }
  .pagehead { flex-wrap: wrap; gap: 10px; }
}

/* ============================================================
   RETAINED-RADZEN / APEXCHARTS COHESION OVERRIDES
   ============================================================ */
.rz-chart, .rz-dialog, .rz-datatable, .apexcharts-canvas, .rz-tooltip { font-family: var(--font-ui); }

/* charts: text + gridlines follow the palette */
.rz-chart text { fill: var(--text-3); }
.rz-chart .rz-tick text, .rz-chart .rz-axis-title { fill: var(--text-2); }
.rz-chart .rz-gridline, .rz-chart line.rz-grid-line { stroke: var(--border); }
.rz-chart-tooltip, .rz-tooltip-content {
  background: var(--surface) !important; color: var(--text) !important;
  border: 1px solid var(--border-2) !important; border-radius: 10px !important;
  box-shadow: var(--shadow-pop) !important; font-family: var(--font-ui) !important;
}

/* ApexCharts cohesion */
.apexcharts-tooltip {
  background: var(--surface) !important; color: var(--text) !important;
  border: 1px solid var(--border-2) !important; box-shadow: var(--shadow-pop) !important;
}
.apexcharts-tooltip-title { background: var(--surface-2) !important; border-bottom: 1px solid var(--border) !important; }
.apexcharts-xaxistooltip, .apexcharts-yaxistooltip { background: var(--surface) !important; color: var(--text) !important; border-color: var(--border-2) !important; }
.apexcharts-legend-text { color: var(--text-2) !important; }
.apexcharts-gridline { stroke: var(--border) !important; }
.apexcharts-text, .apexcharts-xaxis-label, .apexcharts-yaxis-label { fill: var(--text-3) !important; }

/* Radzen dialog chrome (busy + AI analysis modals) themed to the surface */
.rz-dialog { background: var(--surface) !important; color: var(--text) !important; border: 1px solid var(--border-2) !important; border-radius: 16px !important; box-shadow: var(--shadow-pop) !important; }
.rz-dialog-titlebar { background: transparent !important; border-bottom: 1px solid var(--border) !important; color: var(--text) !important; }
.rz-dialog-content { color: var(--text) !important; }

/* Radzen ProgressBarCircular accent (used inside retained components) */
.rz-progressbar-circular .rz-progressbar-circular-value { stroke: var(--accent) !important; }
