/* ============================================================================
   Argus Unified SecOps — Design System
   Framework-free, strict-CSP-safe (no @import, no external fonts/URLs).
   Token reference: /assets/ui/DESIGN_SYSTEM.md
   ---------------------------------------------------------------------------
   Theming model:
     - LIGHT is the default token set on :root.
     - DARK is applied two ways: prefers-color-scheme:dark (system) AND an
       explicit [data-theme="dark"] on <html> (persisted user toggle).
     - [data-theme="light"] forces light even when the OS prefers dark.
   All colors below are chosen to meet WCAG AA (>=4.5:1 for body text,
   >=3:1 for large text / UI borders) against their intended surface.
   ========================================================================== */

/* ---- TOKENS: LIGHT (default) --------------------------------------------- */
:root {
  color-scheme: light;

  /* Spacing scale (4px base) */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;

  /* Radius */
  --r-sm: 8px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px; --r-pill: 999px;

  /* Type scale */
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --fs-xs: 11px; --fs-sm: 13px; --fs-md: 14px; --fs-lg: 16px;
  --fs-xl: 21px; --fs-2xl: 30px;
  --lh: 1.5; --fw-normal: 400; --fw-med: 600; --fw-bold: 700; --fw-black: 900;

  /* Elevation */
  --el-1: 0 1px 2px rgba(15, 30, 46, .06), 0 2px 8px rgba(15, 30, 46, .06);
  --el-2: 0 10px 30px rgba(15, 30, 46, .10);
  --el-3: 0 24px 60px rgba(15, 30, 46, .18);

  /* Motion */
  --dur: 140ms; --ease: cubic-bezier(.2, .6, .2, 1);

  /* Color — surfaces & text */
  --bg: #f4f7fb;
  --bg-grad: radial-gradient(circle at top right, #e6eef8 0, #f4f7fb 45%);
  --panel: #ffffff;
  --panel2: #eef3f8;
  --line: #d4dde7;
  --text: #0f1e2e;
  --muted: #4a5b6b;            /* 7.0:1 on --panel — AA/AAA */

  /* Color — accents (all AA on light surfaces & as fills with dark text) */
  --accent: #0d7d70;          /* teal 700 — 4.7:1 on white */
  --accent-ink: #063b35;
  --warn: #8a5a00;            /* amber ink — 4.9:1 on white */
  --danger: #b0212f;          /* red ink — 6.2:1 on white */
  --ok: #12704a;             /* green ink — 5.6:1 on white */

  /* Focus ring */
  --focus: #0d7d70;
  --focus-ring: 0 0 0 3px rgba(13, 125, 112, .40);

  /* Back-compat aliases used by pre-existing rules */
  --border: var(--line);
  --surface: var(--panel);
  --surface-2: var(--panel2);

  /* Component-scoped surfaces */
  --input-bg: #ffffff;
  --code-bg: #f0f4f9;
  --overlay: rgba(9, 19, 30, .45);

  font-family: var(--font);
}

/* ---- TOKENS: DARK -------------------------------------------------------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #081018;
  --bg-grad: radial-gradient(circle at top right, #132c3d 0, #081018 45%);
  --panel: #101b27;
  --panel2: #142231;
  --line: #233548;
  --text: #eaf2fa;
  --muted: #a8bccd;           /* raised from #8fa5b8 -> 5.9:1 on --panel (AA) */
  --accent: #67e8c7;          /* 8.9:1 on --panel */
  --accent-ink: #061017;
  --warn: #f6c75b;
  --danger: #ff9aa2;          /* raised for AA on dark panels */
  --ok: #75e19a;
  --focus: #67e8c7;
  --focus-ring: 0 0 0 3px rgba(103, 232, 199, .35);
  --input-bg: #09131e;
  --code-bg: #071019;
  --overlay: rgba(2, 7, 12, .62);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #081018;
    --bg-grad: radial-gradient(circle at top right, #132c3d 0, #081018 45%);
    --panel: #101b27;
    --panel2: #142231;
    --line: #233548;
    --text: #eaf2fa;
    --muted: #a8bccd;
    --accent: #67e8c7;
    --accent-ink: #061017;
    --warn: #f6c75b;
    --danger: #ff9aa2;
    --ok: #75e19a;
    --focus: #67e8c7;
    --focus-ring: 0 0 0 3px rgba(103, 232, 199, .35);
    --input-bg: #09131e;
    --code-bg: #071019;
    --overlay: rgba(2, 7, 12, .62);
  }
}

/* ---- RESET / BASE -------------------------------------------------------- */
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg-grad);
  color: var(--text);
  min-height: 100vh;
  line-height: var(--lh);
}
h1, h2, h3, p { margin-top: 0; }
.hidden { display: none !important; }
a { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---- ACCESSIBILITY: skip link & focus ------------------------------------ */
.skip-link {
  position: fixed; left: var(--sp-3); top: -60px; z-index: 300;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: var(--sp-2) var(--sp-4); box-shadow: var(--el-2);
  transition: top var(--dur) var(--ease);
}
.skip-link:focus { top: var(--sp-3); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
/* Don't double up ring on custom-styled controls that set box-shadow */
button:focus-visible, a:focus-visible, .btn:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ---- LAYOUT SHELL -------------------------------------------------------- */
.shell { display: grid; grid-template-columns: 245px 1fr; min-height: 100vh; }
aside {
  background: color-mix(in srgb, var(--panel) 92%, var(--bg));
  border-right: 1px solid var(--line);
  padding: var(--sp-5) var(--sp-4);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: var(--sp-3); align-items: center; padding: 0 var(--sp-2) var(--sp-6); }
.brand div { display: flex; flex-direction: column; }
.brand small, .user small { color: var(--muted); }
.mark {
  height: 42px; width: 42px; border-radius: 13px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #5e9dff);
  color: #ffffff; font-weight: var(--fw-black); font-size: var(--fs-xl);
}
:root[data-theme="dark"] .mark,
:root:not([data-theme="light"]) .mark { color: #061017; }

nav { display: grid; gap: var(--sp-2); }
nav button {
  border: 0; background: transparent; color: var(--muted);
  padding: 11px var(--sp-3); border-radius: var(--r-md);
  text-align: left; cursor: pointer; font: inherit; font-size: var(--fs-md);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
nav button:hover { background: var(--panel2); color: var(--text); }
nav button.active, nav button[aria-current="page"] {
  background: var(--panel2); color: var(--text);
  box-shadow: inset 3px 0 0 var(--accent);
}

.user {
  margin-top: auto; border-top: 1px solid var(--line);
  padding: var(--sp-4) var(--sp-2) 0; display: flex; flex-direction: column; gap: var(--sp-1);
}
.user a { color: var(--accent); font-size: var(--fs-sm); margin-top: 5px; }
.user .logout { margin: 0; }
.user .logout button {
  background: none; border: 0; color: var(--accent); font: inherit; font-size: var(--fs-sm);
  margin-top: 5px; padding: 0; cursor: pointer; text-align: left;
}

main { padding: var(--sp-6) var(--sp-8) 60px; min-width: 0; }
header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-5); gap: var(--sp-4); }
header p { color: var(--muted); margin: var(--sp-1) 0 0; }
.header-actions { display: flex; gap: var(--sp-2); align-items: center; }

/* ---- BUTTONS ------------------------------------------------------------- */
.button, button { font: inherit; }
.button, #refresh, .action, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  background: color-mix(in srgb, var(--accent) 14%, var(--panel));
  color: var(--text);
  padding: 9px var(--sp-4); border-radius: var(--r-md);
  text-decoration: none; cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.button:hover, #refresh:hover, .action:hover, .btn:hover {
  background: color-mix(in srgb, var(--accent) 24%, var(--panel));
}
.button:active, .action:active, .btn:active { transform: translateY(1px); }

.btn--primary {
  background: var(--accent); border-color: var(--accent); color: #ffffff;
}
:root[data-theme="dark"] .btn--primary,
:root:not([data-theme="light"]) .btn--primary { color: #04140f; }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn--danger { background: transparent; border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); color: var(--danger); }

.btn[disabled], .button[disabled], .action[disabled], button[disabled] {
  opacity: .5; cursor: not-allowed; pointer-events: none;
}
.btn.is-loading, .action.is-loading, .button.is-loading {
  pointer-events: none; color: transparent !important; position: relative;
}
.btn.is-loading::after, .action.is-loading::after, .button.is-loading::after {
  content: ""; position: absolute; width: 15px; height: 15px;
  border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%;
  color: var(--text); animation: spin .7s linear infinite;
}

/* Icon-only theme toggle */
.icon-btn {
  width: 40px; height: 40px; padding: 0; display: inline-grid; place-items: center;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: var(--r-md); cursor: pointer; font-size: var(--fs-lg);
}
.icon-btn:hover { background: var(--panel2); }

/* ---- HEADER NOTIFICATION BELL -------------------------------------------- */
.notif-bell-wrap { position: relative; }
.notif-bell-count {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: var(--r-pill); background: var(--danger);
  color: #fff; font-size: var(--fs-xs); font-weight: var(--fw-med);
  display: inline-flex; align-items: center; justify-content: center; line-height: 1;
  box-shadow: 0 0 0 2px var(--bg);
}
.notif-bell-menu {
  position: absolute; right: 0; top: calc(100% + var(--sp-2)); z-index: 200;
  width: 340px; max-width: 88vw; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--el-2); overflow: hidden;
}
.nbm-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
  padding: var(--sp-3); border-bottom: 1px solid var(--line); font-weight: var(--fw-med);
}
.nbm-list { max-height: 360px; overflow-y: auto; }
.nbm-empty { padding: var(--sp-5) var(--sp-3); color: var(--muted); text-align: center; font-size: var(--fs-sm); }
.nbm-item {
  display: flex; gap: var(--sp-2); align-items: flex-start; width: 100%; text-align: left;
  background: none; border: 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 65%, transparent);
  padding: var(--sp-3); cursor: pointer; color: var(--text); font: inherit;
}
.nbm-item:hover { background: var(--panel2); }
.nbm-body { display: grid; gap: 2px; min-width: 0; }
.nbm-title { font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.nbm-meta { font-size: var(--fs-xs); color: var(--muted); }
.nbm-all {
  display: block; width: 100%; background: none; border: 0; border-top: 1px solid var(--line);
  padding: var(--sp-3); cursor: pointer; color: var(--accent); font: inherit; font-weight: var(--fw-med);
}
.nbm-all:hover { background: var(--panel2); }

/* ---- NOTIFICATION RULE FORM CONTROLS ------------------------------------- */
.nt-spacer { flex: 1; }
.nt-fieldset {
  border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-3);
  display: flex; flex-wrap: wrap; gap: var(--sp-4); margin: 0;
}
.nt-fieldset legend { padding: 0 var(--sp-2); color: var(--muted); font-size: var(--fs-sm); }
.nt-check { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); }
.nt-window { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }

/* ---- SPINNER ------------------------------------------------------------- */
.spinner {
  display: inline-block; width: 18px; height: 18px; vertical-align: -3px;
  border: 2px solid color-mix(in srgb, var(--muted) 50%, transparent);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading { padding: var(--sp-8); color: var(--muted); display: flex; align-items: center; gap: var(--sp-3); }

/* ---- CARDS / GRID -------------------------------------------------------- */
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-4); }
.card {
  background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 17px; box-shadow: var(--el-1);
}
:root[data-theme="dark"] .card,
:root:not([data-theme="light"]) .card {
  background: linear-gradient(180deg, rgba(20,34,49,.97), rgba(14,26,38,.97));
  box-shadow: 0 15px 40px rgba(0,0,0,.14);
}
.metric b { font-size: var(--fs-2xl); display: block; margin-top: var(--sp-2); }
.metric span, .muted { color: var(--muted); }
.panel { margin-top: var(--sp-4); }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--sp-3); gap: var(--sp-3); }

/* ---- HEALTH DOTS --------------------------------------------------------- */
.health { display: flex; gap: 9px; align-items: center; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); flex: none; }
.dot.ok { background: var(--ok); }

/* ---- TABLES -------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th {
  text-align: left; color: var(--muted); font-weight: var(--fw-med);
  border-bottom: 1px solid var(--line); padding: var(--sp-3) var(--sp-2);
}
td { padding: 11px var(--sp-2); border-bottom: 1px solid color-mix(in srgb, var(--line) 65%, transparent); vertical-align: top; }
tbody tr:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.table-scroll { overflow-x: auto; }

pre {
  white-space: pre-wrap; word-break: break-word;
  background: var(--code-bg); padding: var(--sp-3); border-radius: var(--r-md);
  border: 1px solid var(--line); max-height: 480px; overflow: auto; font-size: var(--fs-sm);
}

/* ---- BADGES (color + text, never color-only) ----------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px var(--sp-2); border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--muted) 20%, var(--panel));
  color: var(--text); font-size: var(--fs-xs); font-weight: var(--fw-med);
  border: 1px solid color-mix(in srgb, var(--muted) 30%, transparent);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.badge.high, .badge.critical { background: color-mix(in srgb, var(--danger) 18%, var(--panel)); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.badge.medium { background: color-mix(in srgb, var(--warn) 18%, var(--panel)); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.badge.active { background: color-mix(in srgb, var(--ok) 18%, var(--panel)); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.badge.suspended { background: color-mix(in srgb, var(--warn) 18%, var(--panel)); color: var(--warn); }
.badge.archived { background: color-mix(in srgb, var(--muted) 24%, var(--panel)); color: var(--muted); }

/* ---- FORMS / TOOLBAR ----------------------------------------------------- */
.form { display: grid; gap: var(--sp-3); max-width: 680px; }
.form input, .form textarea, .form select,
.toolbar input, .toolbar select, .filter-bar input, .filter-bar select {
  width: 100%; background: var(--input-bg); border: 1px solid var(--line);
  color: var(--text); border-radius: 9px; padding: var(--sp-3);
}
.form textarea { min-height: 100px; }
.toolbar { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-3); align-items: center; }
.toolbar input, .toolbar select { width: auto; padding: var(--sp-2); }

/* filter-bar component */
.filter-bar {
  display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center;
  padding: var(--sp-3); border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--panel2); margin-bottom: var(--sp-4);
}
.filter-bar input, .filter-bar select { width: auto; }
.filter-bar .filter-label { color: var(--muted); font-size: var(--fs-sm); }

/* ---- PAGINATION ---------------------------------------------------------- */
.pagination { display: flex; gap: var(--sp-2); align-items: center; justify-content: flex-end; margin-top: var(--sp-3); }
.pagination .page-info { color: var(--muted); font-size: var(--fs-sm); }

/* ---- TABS ---------------------------------------------------------------- */
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--line); margin-bottom: var(--sp-4); }
.tab {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  padding: var(--sp-3) var(--sp-4); font: inherit; font-size: var(--fs-md);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

/* ---- EMPTY STATE --------------------------------------------------------- */
.empty-state {
  text-align: center; color: var(--muted); padding: var(--sp-10) var(--sp-4);
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
}
.empty-state .es-icon { font-size: 34px; opacity: .55; }
.empty-state .es-title { color: var(--text); font-weight: var(--fw-med); }

/* ---- ERROR BOX (with request-id slot) ------------------------------------ */
.error-box {
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--line));
  background: color-mix(in srgb, var(--danger) 10%, var(--panel));
  color: var(--text); border-radius: var(--r-md); padding: var(--sp-4);
  display: flex; flex-direction: column; gap: var(--sp-2);
}
.error-box .eb-title { color: var(--danger); font-weight: var(--fw-med); }
.error-box .eb-id { color: var(--muted); font-size: var(--fs-xs); font-family: ui-monospace, monospace; }
.error { padding: var(--sp-6); color: var(--danger); }

/* ---- LOGIN --------------------------------------------------------------- */
.login { min-height: 100vh; display: grid; place-items: center; }
.login-card {
  width: min(420px, 90vw); text-align: center; background: var(--panel);
  padding: 44px; border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--el-2);
}
.login-card h1.danger { color: var(--danger); }
.danger { color: var(--danger); }
.logout-standalone { margin: var(--sp-4) 0 0; }
.logout-standalone .button { font: inherit; }
.notice {
  color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  border-radius: var(--r-md); padding: var(--sp-3); font-size: var(--fs-sm);
}
.warnbar { display: flex; gap: var(--sp-3); align-items: baseline; border-color: var(--warn); margin-bottom: var(--sp-4); }
.warnbar b { color: var(--warn); }
.warnbar span { color: var(--muted); font-size: var(--fs-sm); }

/* ---- MODAL (replaces native confirm/alert) ------------------------------- */
.modal-overlay {
  position: fixed; inset: 0; background: var(--overlay);
  display: grid; place-items: center; z-index: 250; padding: var(--sp-4);
  animation: fade var(--dur) var(--ease);
}
.modal {
  width: min(460px, 96vw); background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--el-3); padding: var(--sp-6);
  display: flex; flex-direction: column; gap: var(--sp-4);
}
.modal h2 { font-size: var(--fs-lg); margin: 0; }
.modal .modal-body { color: var(--muted); white-space: pre-wrap; word-break: break-word; }
.modal .modal-actions { display: flex; gap: var(--sp-2); justify-content: flex-end; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---- TOAST (aria-live region) -------------------------------------------- */
.toast-region {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: var(--sp-2);
  align-items: center; pointer-events: none;
}
.toast {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); padding: var(--sp-3) 18px; border-radius: var(--r-md);
  font-size: var(--fs-sm); box-shadow: var(--el-3); pointer-events: auto;
  animation: toastin var(--dur) var(--ease);
  border-left: 3px solid var(--accent);
}
.toast.toast--warn { border-left-color: var(--warn); }
.toast.toast--error { border-left-color: var(--danger); }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---- CHARTS (inline SVG, themed via tokens) ------------------------------ */
.chart { width: 100%; display: block; }
.chart .axis { stroke: var(--line); }
.chart .grid-line { stroke: color-mix(in srgb, var(--line) 60%, transparent); }
.chart .series-line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .series-area { fill: color-mix(in srgb, var(--accent) 16%, transparent); }
.chart .bar { fill: var(--accent); }
.chart .bar:hover { fill: color-mix(in srgb, var(--accent) 78%, var(--text)); }
.chart .label, .chart .tick { fill: var(--muted); font-size: var(--fs-xs); }
.sparkline { vertical-align: middle; }
.sparkline .spark-line { fill: none; stroke: var(--accent); stroke-width: 1.5; }

/* ---- MISC (carried from prior sheet) ------------------------------------- */
.package-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--sp-3); }
.package { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-4); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface-2); }
.package small { overflow-wrap: anywhere; }
.package .action { text-align: center; text-decoration: none; }
.rowactions { display: flex; gap: 6px; flex-wrap: wrap; }
.rowactions .action { padding: 5px var(--sp-3); font-size: var(--fs-xs); }
.note { border-top: 1px solid color-mix(in srgb, var(--line) 65%, transparent); padding: var(--sp-3) 0; }
.note p { margin: 6px 0 0; white-space: pre-wrap; word-break: break-word; }
.note b { font-size: var(--fs-sm); }
.timeline-row { display: flex; gap: var(--sp-3); align-items: baseline; border-top: 1px solid color-mix(in srgb, var(--line) 65%, transparent); padding: 9px 0; font-size: var(--fs-sm); }

/* ---- DRAWER / DETAIL SIDE-PANEL (additive; used by data pages) -----------
   Right-anchored panel for row/record detail. Reuses existing tokens and the
   `fade` keyframe. Purely additive — introduces no override of existing rules. */
.drawer-overlay {
  position: fixed; inset: 0; background: var(--overlay);
  display: flex; justify-content: flex-end; z-index: 240;
  animation: fade var(--dur) var(--ease);
}
.drawer {
  width: min(560px, 96vw); height: 100%; background: var(--panel);
  border-left: 1px solid var(--line); box-shadow: var(--el-3);
  display: flex; flex-direction: column; overflow: hidden;
  animation: drawerin var(--dur) var(--ease);
}
:root[data-theme="dark"] .drawer,
:root:not([data-theme="light"]) .drawer {
  background: linear-gradient(180deg, rgba(20,34,49,.99), rgba(14,26,38,.99));
}
@keyframes drawerin { from { transform: translateX(28px); opacity: .35; } to { transform: none; opacity: 1; } }
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-5); border-bottom: 1px solid var(--line);
}
.drawer-head h2 { font-size: var(--fs-lg); margin: 0; word-break: break-word; }
.drawer-head .drawer-sub { color: var(--muted); font-size: var(--fs-sm); margin-top: var(--sp-1); }
.drawer-close {
  border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  width: 32px; height: 32px; border-radius: var(--r-md); cursor: pointer; flex: none;
  font-size: var(--fs-lg); line-height: 1; display: grid; place-items: center;
}
.drawer-close:hover { background: var(--line); }
.drawer-body { padding: var(--sp-5); overflow: auto; flex: 1; }
.drawer-body h3 { font-size: var(--fs-md); margin: var(--sp-4) 0 var(--sp-2); }
.drawer-body h3:first-child { margin-top: 0; }
.drawer-actions {
  display: flex; gap: var(--sp-2); flex-wrap: wrap;
  padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--line);
}
/* Key/value definition list used inside drawers and detail panels. */
.kv { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: var(--sp-1) var(--sp-3); margin: 0; font-size: var(--fs-sm); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.kv dd pre { margin: var(--sp-1) 0 0; max-height: 260px; }
@media (max-width: 560px) { .kv { grid-template-columns: 1fr; } .kv dt { margin-top: var(--sp-2); } }

/* Progress meter (scan progress, coverage). Text label always accompanies it. */
.meter { height: 8px; border-radius: var(--r-pill); background: var(--panel2); overflow: hidden; border: 1px solid var(--line); min-width: 90px; }
.meter > span { display: block; height: 100%; background: var(--accent); }

/* ---- SCREEN-READER-ONLY TEXT --------------------------------------------
   Visually hidden, still announced. Used to give colour-coded UI (stepper,
   progress rows) an unambiguous textual state. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---- STEPPER (guided wizards) --------------------------------------------
   A numbered, horizontally scrolling progress rail. State is carried by text
   ("completed"/"current step") as well as colour. */
.stepper-wrap { margin-bottom: var(--sp-4); }
.stepper {
  display: flex; gap: var(--sp-2); list-style: none; margin: 0; padding: 0 0 var(--sp-2);
  overflow-x: auto; flex-wrap: wrap;
}
.step {
  display: flex; align-items: center; gap: var(--sp-2); flex: none;
  padding: var(--sp-2) var(--sp-3); border: 1px solid var(--line);
  border-radius: var(--r-pill); background: var(--panel); color: var(--muted);
  font-size: var(--fs-sm);
}
.step-num {
  width: 22px; height: 22px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: var(--panel2); color: var(--muted); font-size: var(--fs-xs); font-weight: var(--fw-med);
  border: 1px solid var(--line);
}
.step--current {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background: color-mix(in srgb, var(--accent) 12%, var(--panel));
  color: var(--text); font-weight: var(--fw-med);
}
.step--current .step-num { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.step--done { color: var(--text); }
.step--done .step-num { background: color-mix(in srgb, var(--ok) 20%, var(--panel)); color: var(--ok); }

/* Wizard shell: step body, hints, inline validation slot, footer navigation. */
.wz-body { display: grid; gap: var(--sp-4); }
.wz-head h2 { margin: 0 0 var(--sp-1); font-size: var(--fs-lg); }
.wz-head h2:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: var(--r-sm); }
.wz-fields { display: grid; gap: var(--sp-3); max-width: 720px; }
.wz-fields label { display: grid; gap: 4px; font-size: var(--fs-sm); }
.wz-fields label.wz-check { grid-template-columns: auto 1fr; align-items: start; gap: var(--sp-2); }
.wz-fields input[type="checkbox"] { width: auto; justify-self: start; margin-top: 3px; }
.wz-row {
  display: grid; gap: var(--sp-3); padding: var(--sp-3); border: 1px solid var(--line);
  border-radius: var(--r-md); background: var(--panel2);
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); align-items: end;
}
.wz-row .wz-row-actions { display: flex; gap: var(--sp-2); }
.wz-hint { color: var(--muted); font-size: var(--fs-sm); margin: 0; }
.wz-nav {
  display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center;
  border-top: 1px solid var(--line); padding-top: var(--sp-4);
}
.wz-nav .wz-spacer { flex: 1; }
.wz-warn {
  border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--line));
  background: color-mix(in srgb, var(--warn) 12%, var(--panel));
  color: var(--text); border-radius: var(--r-md); padding: var(--sp-3); font-size: var(--fs-sm);
}
.wz-warn ul { margin: var(--sp-2) 0 0; padding-left: var(--sp-5); }
.wz-progress { display: grid; gap: var(--sp-2); }
.wz-prow {
  display: flex; gap: var(--sp-3); align-items: center; padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel);
}
.wz-prow .wz-pname { flex: 1; word-break: break-all; }
.wz-prow .wz-pdetail { color: var(--muted); font-size: var(--fs-sm); }

/* ---- RESPONSIVE ---------------------------------------------------------- */
@media (max-width: 1000px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px) {
  .shell { display: block; }
  aside { position: relative; height: auto; }
  nav { grid-template-columns: repeat(3, 1fr); }
  main { padding: var(--sp-5) var(--sp-4); }
  .grid { grid-template-columns: 1fr; }
  .user { display: none; }
  table { display: block; overflow: auto; }
}
