/* =========================================================================
 * DataGrant -- design system + component styles
 * -------------------------------------------------------------------------
 * Palette: midnight navy background + royal-violet primary + amber warnings.
 * Distinct from DriftSense (teal) -- reads as "issued key / royal grant /
 * permission-to-access." Purple = authority, access, credentialing.
 * ========================================================================= */

:root {
  /* Backgrounds -- deep, cool, with subtle violet tint */
  --bg-0: #060411;
  --bg-1: #0f0a1f;
  --bg-2: #1a1330;
  --bg-3: #241a45;
  --bg-panel: linear-gradient(180deg, #1a1330 0%, #0f0a1f 100%);

  /* Borders */
  --border: #2b2145;
  --border-hi: #3a2d5c;
  --border-focus: #8b5cf6;

  /* Text */
  --text: #ede9fe;
  --text-dim: #a99ec9;
  --text-muted: #78698f;

  /* Accents -- royal violet family */
  --accent: #8b5cf6;              /* Violet -- primary, "grant" color */
  --accent-hi: #a78bfa;
  --accent-deep: #5b21b6;
  --accent-glow: rgba(139, 92, 246, 0.40);

  --accent-warn: #f59e0b;          /* Amber -- warning */
  --accent-warn-hi: #fbbf24;

  --accent-danger: #f43f5e;        /* Rose -- critical */
  --accent-danger-hi: #fb7185;

  --accent-ok: #34d399;            /* Emerald -- healthy */
  --accent-ok-hi: #6ee7b7;

  --accent-info: #c4b5fd;          /* Lavender -- info notices */

  /* Typography */
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Sizing */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --sidebar-w: 240px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg-0);
  background-image:
    radial-gradient(ellipse 1000px 600px at 15% 0%, rgba(139, 92, 246, 0.10), transparent 65%),
    radial-gradient(ellipse 900px 500px at 90% 100%, rgba(196, 181, 253, 0.08), transparent 65%);
  background-attachment: fixed;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* =========================================================================
 * APP SHELL -- sidebar + main
 * ========================================================================= */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}
@media (max-width: 780px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

/* Sidebar */
.sidebar {
  background: linear-gradient(180deg, #0a1220 0%, #050810 100%);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  position: sticky; top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 8px 20px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.sidebar-brand .logo {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  min-width: 38px;
  border-radius: 10px;
  background: #0a1220;
  border: 1px solid #fff;
  display: grid; place-items: center;
  color: #fff;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .02em;
  position: relative;
  box-shadow: 0 6px 20px rgba(15, 118, 110, 0.40);
  z-index: 1;
}
.sidebar-brand .logo::after {
  content: '';
  position: absolute; inset: -2px;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--accent-deep) 0%, var(--accent-hi) 100%);
  filter: blur(12px);
  opacity: 0.32;
  z-index: -1;
}
.sidebar-brand .name {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.sidebar-brand .name .accent { color: var(--accent-hi); }
.sidebar-brand .role {
  font-size: 10px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  margin-top: 2px;
}
.sidebar-section-label {
  font-size: 10.5px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  padding: 12px 20px 6px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 20px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13.5px;
  border-left: 2px solid transparent;
  transition: color .12s ease, background .12s ease, border-left-color .12s ease;
}
.sidebar-link svg { width: 15px; height: 15px; flex: 0 0 auto; opacity: 0.85; }
.sidebar-link:hover { color: var(--text); background: rgba(255,255,255,.02); }
.sidebar-link.active {
  color: var(--accent-hi);
  background: linear-gradient(90deg, rgba(139, 92, 246, .12), transparent 90%);
  border-left-color: var(--accent);
}
.sidebar-link.active svg { opacity: 1; }

/* Trend arrows on KPI tiles (Wave 5) */
.ds-trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
  vertical-align: 3px;
  margin-left: 8px;
}
.ds-trend.ds-trend-up {
  background: rgba(52, 211, 153, .14);
  color: #86efac;
  border: 1px solid rgba(52, 211, 153, .35);
}
.ds-trend.ds-trend-down {
  background: rgba(244, 63, 94, .14);
  color: #fda4af;
  border: 1px solid rgba(244, 63, 94, .35);
}
.ds-trend.ds-trend-flat {
  background: rgba(148, 163, 184, .14);
  color: var(--text-dim);
  border: 1px solid rgba(148, 163, 184, .30);
}
.ds-trend svg {
  width: 10px; height: 10px;
}

/* Site links in sidebar (Wave 5) */
.ds-site-link {
  font-size: 12.5px;
  padding: 6px 20px 6px 20px;
}
.ds-site-badge {
  display: inline-grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: 6px;
  background: linear-gradient(135deg, rgba(139, 92, 246, .18), rgba(6, 78, 74, .12));
  border: 1px solid rgba(139, 92, 246, .25);
  color: var(--accent-hi);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0;
  flex: 0 0 auto;
}
.ds-site-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-site-dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex: 0 0 auto;
  background: #334155;
}
.ds-site-dot.ds-dot-live  { background: #34d399; box-shadow: 0 0 6px rgba(52,211,153,.6); }
.ds-site-dot.ds-dot-warm  { background: #f59e0b; box-shadow: 0 0 6px rgba(245,158,11,.5); }
.ds-site-dot.ds-dot-hot   { background: #f43f5e; box-shadow: 0 0 8px rgba(244,63,94,.7); }
.ds-site-dot.ds-dot-quiet { background: #334155; }

/* Stable release links in sidebar (Wave 5) */
.ds-stable-link {
  font-size: 12.5px;
  padding: 6px 20px;
}
.ds-stable-tag {
  display: inline-grid;
  place-items: center;
  width: 20px; height: 20px;
  border-radius: 5px;
  background: linear-gradient(135deg, #34d399, #5b21b6);
  color: #052e2b;
  font-size: 10.5px;
  font-weight: 900;
  flex: 0 0 auto;
  box-shadow: 0 0 0 1px rgba(52,211,153,.35);
}
.ds-stable-link:hover .ds-stable-tag { box-shadow: 0 0 12px rgba(52,211,153,.7); }

/* Main content area */
.app-main { min-width: 0; }
.topbar {
  padding: 16px 32px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(10, 18, 32, 0.5);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: .3px; }
.topbar-spacer { flex: 1; }
.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px 5px 5px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 12.5px;
}
.topbar-user .initials {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: #030710;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
  font-family: var(--mono);
}

.app-content {
  padding: 32px 40px 96px;
  /* Fill the available width -- the sidebar already grabs a fixed column
   * via .app-shell grid, so the main area fills the rest naturally.
   * A hard max-width here was cutting off wide-screen tables. */
  max-width: none;
  width: 100%;
  min-width: 0;
}

/* =========================================================================
 * DASHBOARD FILE-CHANGES KPI -- 4 sub-count links (Modified/Added/Deleted/All)
 * inside the main tile. Shows even when 0 so the operator sees the shape.
 * ========================================================================= */
.kpi-file-tile { display: flex; flex-direction: column; }
.fc-subgrid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 8px 12px 14px;
  border-top: 1px solid var(--border);
  background: rgba(139, 92, 246, .03);
}
.fc-sub {
  display: flex; flex-direction: column; align-items: center;
  gap: 3px;
  padding: 9px 4px 8px;
  border-radius: 8px;
  color: var(--text-dim);
  text-decoration: none;
  transition: background .12s, color .12s, transform .12s;
  border: 1px solid transparent;
}
.fc-sub svg { width: 14px; height: 14px; opacity: .55; }
.fc-sub:hover { color: var(--text); background: rgba(139, 92, 246, .07); border-color: rgba(139, 92, 246, .20); transform: translateY(-1px); }
.fc-sub:hover svg { opacity: 1; }
.fc-sub-num { font-family: var(--mono); font-size: 20px; font-weight: 800; line-height: 1; letter-spacing: -.01em; color: var(--text); }
.fc-sub-lbl { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted); font-weight: 700; }
.fc-sub-modified:hover svg { color: var(--accent-warn-hi); }
.fc-sub-added:hover    svg { color: var(--accent-ok); }
.fc-sub-deleted:hover  svg { color: var(--accent-danger-hi); }
/* Amber variant for the schema tile so the hover tint reads as amber
 * territory instead of teal. */
.fc-subgrid-amber { background: rgba(245, 158, 11, .03); }
.fc-subgrid-amber .fc-sub:hover { background: rgba(245, 158, 11, .07); border-color: rgba(245, 158, 11, .25); }

/* Non-zero sub-KPI is HOT: number + icon light up in the semantic color so
 * a glance at the row tells you which lane has activity. Zero stays muted. */
.fc-sub-hot .fc-sub-num              { color: var(--accent-hi);        text-shadow: 0 0 12px rgba(139,92,246,.35); }
.fc-sub-hot.fc-sub-modified .fc-sub-num  { color: var(--accent-warn-hi);   text-shadow: 0 0 12px rgba(245,158,11,.40); }
.fc-sub-hot.fc-sub-modified svg          { color: var(--accent-warn-hi);   opacity: 1; }
.fc-sub-hot.fc-sub-added .fc-sub-num     { color: var(--accent-ok);        text-shadow: 0 0 12px rgba(52,211,153,.40); }
.fc-sub-hot.fc-sub-added svg             { color: var(--accent-ok);        opacity: 1; }
.fc-sub-hot.fc-sub-deleted .fc-sub-num   { color: var(--accent-danger-hi); text-shadow: 0 0 12px rgba(244,63,94,.40); }
.fc-sub-hot.fc-sub-deleted svg           { color: var(--accent-danger-hi); opacity: 1; }
.fc-sub-hot.fc-sub-all .fc-sub-num       { color: var(--accent-hi);        text-shadow: 0 0 12px rgba(139,92,246,.40); }
.fc-sub-hot.fc-sub-all svg               { color: var(--accent-hi);        opacity: 1; }
.fc-sub-hot .fc-sub-lbl                  { color: var(--text-dim); }

/* Dashboard-top range bar (wraps the shared RangePicker so it sits nicely
 * above the KPI grid). */
.dash-range-bar { margin: 0 0 14px; }
.dash-range-bar .range-bar { padding: 10px 14px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.dash-range-bar .rb-label { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--text-muted); font-weight: 700; margin-right: 4px; }

/* =========================================================================
 * STATUS FILTER TABS (.fc-tabs / .fc-tab) -- used on /file_changes.cgi and
 * /schema_changes.cgi. Sit inside a .module, above the .module-head.
 * Modified | Added | Deleted | All -- active tab underlined + colored.
 * ========================================================================= */
.fc-tabs {
  display: flex;
  gap: 2px;
  padding: 8px 12px 0;
  border-bottom: 1px solid var(--border);
  background: rgba(139, 92, 246, .02);
}
.fc-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px 11px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .12s, border-color .12s, background .12s;
  border-radius: 6px 6px 0 0;
}
.fc-tab:hover { color: var(--text); background: rgba(139, 92, 246, .06); }
.fc-tab-active { color: var(--accent-hi); border-bottom-color: var(--accent); background: rgba(139, 92, 246, .10); }
.fc-tab-active .fc-tab-badge { background: rgba(139, 92, 246, .20); color: var(--accent-hi); }
.fc-tab-badge {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.fc-tab svg { opacity: .7; flex: 0 0 auto; }
.fc-tab-active svg { opacity: 1; color: var(--accent-hi); }

/* =========================================================================
 * KPI ROW -- shared across portfolio_drift / orphan_blobs / watchlist /
 * file_bio / release_diff / restore_batch pages. Auto-fit responsive grid
 * so 3-4 tiles sit side-by-side on desktop, wrap gracefully at narrower
 * widths.
 * ========================================================================= */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.kpi-tile {
  padding: 16px 18px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 0;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.kpi-tile:hover { border-color: var(--border-hi); }
.kpi-tile .kpi-label {
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 6px;
}
.kpi-tile .kpi-value {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.05;
  letter-spacing: -.01em;
}
.kpi-tile .kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* =========================================================================
 * PAGE HEAD
 * ========================================================================= */
.page-head { margin-bottom: 32px; }
.page-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--accent-hi);
  font-weight: 700;
  padding: 5px 12px;
  background: rgba(139, 92, 246, .10);
  border: 1px solid rgba(139, 92, 246, .30);
  border-radius: var(--radius-pill);
  margin-bottom: 14px;
  text-decoration: none;
}
.page-eyebrow .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent-hi);
  box-shadow: 0 0 10px var(--accent-hi);
}
.page-title {
  margin: 0 0 8px;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff 0%, #cbd5e1 60%, var(--accent-hi) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.page-subtitle {
  color: var(--text-dim);
  font-size: 14.5px;
  max-width: 780px;
  margin: 0;
}

/* =========================================================================
 * MODULES / CARDS
 * ========================================================================= */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.module {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.module:hover { border-color: var(--border-hi); }
.module-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(139, 92, 246, .03);
}
.module-head .left { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.module-icon {
  width: 26px; height: 26px;
  border-radius: 7px;
  display: grid; place-items: center;
  color: var(--accent-hi);
  background: rgba(139, 92, 246, .10);
  border: 1px solid rgba(139, 92, 246, .30);
}
.module-title { font-size: 13px; font-weight: 700; letter-spacing: .3px; }
.module-subtitle {
  font-size: 11.5px;
  font-weight: 400;
  color: #b8c5d6;
  margin-left: 8px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
  line-height: 1.35;
}
.module-body { padding: 16px; }
.module-body.tight { padding: 0; }

/* Module glow variants */
.module.glow-teal   { box-shadow: 0 0 0 1px rgba(139, 92, 246, .20), 0 0 26px rgba(139, 92, 246, .10); }
.module.glow-amber  { box-shadow: 0 0 0 1px rgba(245, 158, 11, .20), 0 0 26px rgba(245, 158, 11, .10); }
.module.glow-rose   { box-shadow: 0 0 0 1px rgba(244, 63, 94, .20),  0 0 26px rgba(244, 63, 94, .10); }
.module.glow-emerald{ box-shadow: 0 0 0 1px rgba(52, 211, 153, .20), 0 0 26px rgba(52, 211, 153, .10); }
.module.glow-sky    { box-shadow: 0 0 0 1px rgba(196, 181, 253, .20), 0 0 26px rgba(196, 181, 253, .10); }

/* =========================================================================
 * KPI TILES
 * ========================================================================= */
.kpi { padding: 20px 22px; }
.kpi .num {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.kpi .lbl {
  font-size: 11px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  margin-top: 6px;
}
.kpi .sub { font-size: 12px; color: var(--text-dim); margin-top: 10px; }
.kpi-teal   .num { color: var(--accent-hi); text-shadow: 0 0 24px rgba(139, 92, 246, .35); }
.kpi-amber  .num { color: var(--accent-warn-hi); text-shadow: 0 0 24px rgba(245, 158, 11, .30); }
.kpi-rose   .num { color: var(--accent-danger-hi); text-shadow: 0 0 24px rgba(244, 63, 94, .30); }
.kpi-emerald .num { color: var(--accent-ok-hi); text-shadow: 0 0 24px rgba(52, 211, 153, .30); }
.kpi-sky    .num { color: var(--accent-info); text-shadow: 0 0 24px rgba(196, 181, 253, .30); }

/* =========================================================================
 * PILLS + STATUS BADGES
 * ========================================================================= */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 10.5px;
  letter-spacing: .6px;
  text-transform: uppercase;
  font-weight: 700;
  border: 1px solid var(--border);
}
.pill-ok    { background: rgba(52, 211, 153, .10); color: #a7f3d0; border-color: rgba(52, 211, 153, .35); }
.pill-warn  { background: rgba(245, 158, 11, .10); color: var(--accent-warn-hi); border-color: rgba(245, 158, 11, .35); }
.pill-bad   { background: rgba(244, 63, 94, .10);  color: var(--accent-danger-hi); border-color: rgba(244, 63, 94, .35); }
.pill-info  { background: rgba(196, 181, 253, .10); color: var(--accent-info); border-color: rgba(196, 181, 253, .35); }
.pill-mute  { background: rgba(255,255,255,.03); color: var(--text-dim); }

/* =========================================================================
 * TABLES
 * ========================================================================= */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left;
  padding: 10px 14px;
  font-size: 10.5px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,.02);
}
.tbl td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,.03);
  vertical-align: middle;
}
.tbl tr:hover td { background: rgba(255,255,255,.02); }
.tbl .mono { font-family: var(--mono); font-size: 12.5px; }
.tbl .dim  { color: var(--text-dim); }

/* =========================================================================
 * CHIP RANGE PICKER (portfolio-canonical .tr-chip pattern)
 * ========================================================================= */
.tr-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  background: transparent;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all .15s ease;
  font-family: inherit;
}
.tr-chip:hover { color: var(--text); border-color: var(--accent); }
.tr-chip.is-active {
  background: var(--accent);
  color: #0a1220;
  border-color: var(--accent);
}
.range-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.range-bar .rb-label {
  font-size: 11px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
}
.range-bar input[type="text"],
.range-bar input[type="datetime-local"] {
  background: var(--bg-1);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 12.5px;
  font-family: inherit;
}
.range-bar input[type="text"]:focus,
.range-bar input[type="datetime-local"]:focus {
  outline: none;
  border-color: var(--accent);
}

/* =========================================================================
 * CHART TOOLTIP (activity timeline etc.)
 * ========================================================================= */
.chart-tooltip {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  background: var(--bg-3);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  min-width: 160px;
  transform: translate(-50%, calc(-100% - 10px));
  opacity: 0;
  transition: opacity .1s ease;
}
.chart-tooltip.on { opacity: 1; }
.chart-tooltip .ct-date {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.chart-tooltip .ct-row {
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.5;
}
.chart-tooltip .ct-swatch {
  width: 9px; height: 9px; border-radius: 2px; display: inline-block;
}
.chart-tooltip .ct-hint {
  margin-top: 4px;
  font-size: 10.5px;
  color: var(--text-muted);
  font-style: italic;
}

/* =========================================================================
 * BUTTONS
 * ========================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--accent);
  color: #030710;
  border: none;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform .1s ease, box-shadow .1s ease, background .12s ease;
}
.btn:hover { background: var(--accent-hi); box-shadow: 0 4px 14px var(--accent-glow); transform: translateY(-1px); }
.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-2); border-color: var(--accent); color: var(--accent-hi); }
.btn-danger { background: var(--accent-danger); }
.btn-danger:hover { background: var(--accent-danger-hi); box-shadow: 0 4px 14px rgba(244, 63, 94, .35); }

/* =========================================================================
 * FORMS
 * ========================================================================= */
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=datetime-local], textarea, select {
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color .12s ease;
  color-scheme: dark;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }

/* =========================================================================
 * MISC UTILITIES
 * ========================================================================= */
code {
  background: rgba(139, 92, 246, .10);
  color: var(--accent-hi);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.88em;
  border: 1px solid rgba(139, 92, 246, .20);
}
.mono { font-family: var(--mono); }
.dim  { color: var(--text-dim); }
.muted { color: var(--text-muted); }

/* Banner */
.banner {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin: 10px 0;
  border-left: 3px solid;
}
.banner-ok    { background: rgba(52, 211, 153, .08); border-left-color: var(--accent-ok);       color: #a7f3d0; }
.banner-warn  { background: rgba(245, 158, 11, .08); border-left-color: var(--accent-warn);     color: var(--accent-warn-hi); }
.banner-err   { background: rgba(244, 63, 94, .08);  border-left-color: var(--accent-danger);   color: var(--accent-danger-hi); }
.banner-info  { background: rgba(196, 181, 253, .08); border-left-color: var(--accent-info);     color: var(--accent-info); }

/* Scrollbar (webkit) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-0); }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 5px; border: 2px solid var(--bg-0); }
::-webkit-scrollbar-thumb:hover { background: var(--border-hi); }


/* =========================================================================
 * META-ADMIN UI PARITY — 2026-07-12
 * app-shell alias for .app, brand-text tokens, topbar-title/actions/iconbtn/
 * search/pill, profile dropdown, avatar, sidebar-link-logout.
 * Palette re-uses the existing DriftSense teal/rose/emerald tokens.
 * ========================================================================= */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

/* Sidebar brand extra text nodes (kept .name/.role as legacy) */
.sidebar-brand .brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.05; }
.sidebar-brand .brand-name { font-family: var(--sans); font-weight: 700; letter-spacing: -.02em; font-size: 17px; color: var(--text); line-height: 1.1; }
.sidebar-brand .brand-name .accent { color: var(--accent-hi); }
.sidebar-brand .brand-sub { font-family: var(--sans); font-weight: 600; font-size: 9.5px; letter-spacing: .18em; text-transform: uppercase; color: var(--text-muted); margin-top: 4px; }

/* Sign-out link at the bottom of the sidebar */
.sidebar-link-logout { color: var(--text-muted); }
.sidebar-link-logout:hover { color: var(--accent-danger-hi); background: rgba(244,63,94,.06); }
.sidebar-link-logout svg { opacity: .8; }

/* Topbar polish + new elements */
.topbar-title { font-size: 15px; font-weight: 600; letter-spacing: .3px; color: var(--text); margin: 0; }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: 4px; }
.topbar-iconbtn {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: var(--radius-sm); color: var(--text-muted);
  background: transparent; border: 1px solid transparent; cursor: pointer;
  text-decoration: none;
  transition: color .15s, border-color .15s, box-shadow .15s;
}
.topbar-iconbtn:hover { color: var(--text); border-color: var(--accent); box-shadow: 0 0 8px var(--accent-glow); }
.topbar-iconbtn svg { width: 18px; height: 18px; }
.topbar-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-2); border: 1px solid var(--border);
  padding: 6px 12px; border-radius: var(--radius-sm);
  width: 260px; max-width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.topbar-search:focus-within { border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--accent-glow); }
.topbar-search input { flex: 1; background: transparent; border: 0; outline: none; color: var(--text); font-size: 13px; font-family: var(--mono); }
.topbar-search input::placeholder { color: var(--text-muted); }
.topbar-search svg { width: 14px; height: 14px; color: var(--text-dim); }

/* Avatar */
.avatar {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: #0a1220;
  border: 1px solid #fff;
  color: #fff;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  font-family: var(--sans);
  letter-spacing: .02em;
  flex: 0 0 auto;
  position: relative;
  box-shadow: 0 4px 14px rgba(15, 118, 110, 0.40);
  z-index: 1;
}
.avatar::after {
  content: '';
  position: absolute; inset: -2px;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--accent-deep) 0%, var(--accent-hi) 100%);
  filter: blur(10px);
  opacity: 0.32;
  z-index: -1;
}

/* Profile dropdown */
.profile-dropdown { position: relative; }
.profile-btn {
  display: flex; align-items: center; gap: 8px;
  background: transparent; border: 1px solid transparent;
  padding: 4px 10px 4px 4px; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.profile-btn:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.profile-dropdown-menu {
  display: none;
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 280px;
  background: linear-gradient(180deg, var(--bg-2) 0%, var(--bg-1) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 40px rgba(0,0,0,.6), 0 0 0 1px rgba(139,92,246,.15);
  padding: 6px;
  z-index: 100;
}
.profile-dropdown-menu.open { display: block; }
.profile-dropdown-menu::before {
  content: ''; position: absolute; top: -6px; right: 20px;
  width: 10px; height: 10px;
  background: var(--bg-2);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  transform: rotate(45deg);
}
.profile-dropdown-menu a {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 12.5px;
  border-radius: 6px;
  transition: color .1s, background .1s;
}
.profile-dropdown-menu a:hover { color: var(--text); background: rgba(139,92,246,.06); }
.profile-dropdown-menu a .dropdown-icon { color: var(--text-muted); display: inline-flex; }
.profile-dropdown-menu a:hover .dropdown-icon { color: var(--accent-hi); }
.profile-dropdown-section {
  padding: 10px 12px 4px;
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-muted); font-weight: 700;
}
.profile-dropdown-divider { height: 1px; background: var(--border); margin: 6px 4px; }

/* Sidebar-collapsed mode (desktop) */
html.sidebar-collapsed .app-shell { grid-template-columns: 64px 1fr; }
html.sidebar-collapsed .sidebar-brand .brand-text,
html.sidebar-collapsed .sidebar-link span,
html.sidebar-collapsed .sidebar-section-label,
html.sidebar-collapsed .ds-stable-tag { display: none; }
html.sidebar-collapsed .sidebar-link { justify-content: center; padding: 10px 0; }
html.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 8px 0 16px; }
