/* Half-Life design system v2: shadcn/ui "zinc" look.
   Neutral black/white/grey everywhere; colour only carries status (stages, errors, success).
   Token NAMES are unchanged from v1 so board.css / workspace.css keep working; only values changed.
   Theme: <html data-theme="light|dark"> forces a theme; no attribute = follow prefers-color-scheme. */

/* ---------- tokens: light (default) ---------- */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --surface-3: #e4e4e7;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #09090b;
  --text-2: #52525b;
  --text-3: #a1a1aa;
  --accent: #18181b;
  --accent-hover: #27272a;
  --accent-soft: #f4f4f5;
  --accent-contrast: #fafafa;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --focus-ring: rgba(24, 24, 27, .25);
  --ring: #a1a1aa;
  --hover: #f4f4f5;
  --sidebar: #fafafa;
  --overlay: rgba(0, 0, 0, .4);

  --stage-notice: #3b82f6;
  --stage-assign: #6366f1;
  --stage-nudge: #d97706;
  --stage-escalate: #ea580c;
  --stage-page: #dc2626;
  --stage-breach: #991b1b;
  --stage-watch: #a1a1aa;

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .05);
  --shadow-2: 0 4px 12px rgba(0, 0, 0, .08);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 48px;

  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --sidebar-w: 240px;
  --content-max: 1200px;
  --ease: cubic-bezier(.32, .72, 0, 1);

  /* chevron for .select, swapped per theme */
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

/* ---------- tokens: dark (system preference, unless forced light) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #09090b;
    --surface: #09090b;
    --surface-2: #18181b;
    --surface-3: #27272a;
    --border: #27272a;
    --border-strong: #3f3f46;
    --text: #fafafa;
    --text-2: #a1a1aa;
    --text-3: #71717a;
    --accent: #fafafa;
    --accent-hover: #e4e4e7;
    --accent-soft: #27272a;
    --accent-contrast: #18181b;
    --ok: #22c55e;
    --warn: #f59e0b;
    --danger: #ef4444;
    --danger-soft: #2a1215;
    --focus-ring: rgba(212, 212, 216, .35);
    --ring: #71717a;
    --hover: #27272a;
    --sidebar: #09090b;
    --overlay: rgba(0, 0, 0, .6);
    --stage-notice: #60a5fa;
    --stage-assign: #818cf8;
    --stage-nudge: #fbbf24;
    --stage-escalate: #fb923c;
    --stage-page: #f87171;
    --stage-breach: #fca5a5;
    --stage-watch: #71717a;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 4px 12px rgba(0, 0, 0, .4);
    --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  }
}
/* ---------- tokens: dark (forced) ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #09090b;
  --surface: #09090b;
  --surface-2: #18181b;
  --surface-3: #27272a;
  --border: #27272a;
  --border-strong: #3f3f46;
  --text: #fafafa;
  --text-2: #a1a1aa;
  --text-3: #71717a;
  --accent: #fafafa;
  --accent-hover: #e4e4e7;
  --accent-soft: #27272a;
  --accent-contrast: #18181b;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --danger-soft: #2a1215;
  --focus-ring: rgba(212, 212, 216, .35);
  --ring: #71717a;
  --hover: #27272a;
  --sidebar: #09090b;
  --overlay: rgba(0, 0, 0, .6);
  --stage-notice: #60a5fa;
  --stage-assign: #818cf8;
  --stage-nudge: #fbbf24;
  --stage-escalate: #fb923c;
  --stage-page: #f87171;
  --stage-breach: #fca5a5;
  --stage-watch: #71717a;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 4px 12px rgba(0, 0, 0, .4);
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

/* ---------- theme-dependent brand logos: render both, one is hidden ---------- */
:root[data-theme="light"] .logo-dark,
:root[data-theme="dark"] .logo-light { display: none !important; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .logo-light { display: none !important; } }
@media not (prefers-color-scheme: dark) { :root:not([data-theme]) .logo-dark { display: none !important; } }

/* ---------- base ---------- */
[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.5 var(--font-sans);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.3; font-weight: 600; letter-spacing: -.01em; color: var(--text); }
h1 { font-size: 24px; }
h2 { font-size: 16px; }
h3 { font-size: 15px; }
h4 { font-size: 14px; }
p { margin: 0; }
a { color: var(--text); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
code, kbd, samp { font-family: var(--font-mono); font-size: .9em; }
img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: color-mix(in srgb, var(--text) 16%, transparent); }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: var(--radius-sm); }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: var(--space-3); top: -60px; z-index: 100;
  background: var(--surface); color: var(--text); padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-2); text-decoration: none;
}
.skip-link:focus { top: var(--space-3); }

/* ---------- helpers ---------- */
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.stack-sm { display: flex; flex-direction: column; gap: var(--space-2); }
.stack-lg { display: flex; flex-direction: column; gap: var(--space-5); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.cluster-lg { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4); }
.spacer { flex: 1 1 auto; }
.separator { height: 1px; background: var(--border); border: 0; margin: var(--space-4) 0; }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }
.text-danger { color: var(--danger); }
.icon { width: 16px; height: 16px; flex: none; }
.icon-sm { width: 14px; height: 14px; flex: none; }
.brand-logo { width: 16px; height: 16px; flex: none; object-fit: contain; }
.brand-logo-lg { width: 20px; height: 20px; flex: none; object-fit: contain; }
@keyframes hl-spin { to { transform: rotate(360deg); } }
.spin { animation: hl-spin .8s linear infinite; }

/* ---------- button (shadcn Button) ---------- */
.btn {
  --btn-h: 36px;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--btn-h); padding: 0 var(--space-4);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-1);
  font-size: 14px; font-weight: 500; line-height: 1; white-space: nowrap;
  text-decoration: none; cursor: pointer; user-select: none;
  transition: background-color .15s, border-color .15s, color .15s, opacity .15s, box-shadow .15s;
}
.btn:hover { background: var(--hover); color: var(--text); }
.btn:focus-visible { outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px var(--focus-ring); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn svg, .btn img { width: 16px; height: 16px; flex: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { background: var(--accent); color: var(--accent-contrast); opacity: .9; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text); }
.btn-ghost:hover { background: var(--hover); }
.btn-danger, .btn-danger.btn-solid, .btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover, .btn-danger-solid:hover { background: var(--danger); color: #fff; opacity: .9; }
.btn-danger:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 30%, transparent); }
.btn-sm { --btn-h: 32px; padding: 0 var(--space-3); font-size: 13px; gap: 6px; }
.btn-lg { --btn-h: 40px; padding: 0 var(--space-6); }
.btn-block { width: 100%; }
.btn-icon { width: var(--btn-h); padding: 0; }
.btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy > * { visibility: hidden; }
.btn.is-busy::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px;
  border-radius: 50%; border: 2px solid var(--text-3); border-right-color: transparent;
  animation: hl-spin .7s linear infinite;
}
.btn-primary.is-busy::after { border-color: var(--accent-contrast); border-right-color: transparent; }
.btn-danger.is-busy::after { border-color: #fff; border-right-color: transparent; }

/* ---------- form controls (shadcn Input / Select / Textarea) ---------- */
.input, .select, .textarea {
  display: block; width: 100%; min-width: 0;
  height: 36px; padding: 0 var(--space-3);
  background: transparent; color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-1);
  font-size: 14px; line-height: 1.4;
  transition: border-color .15s, box-shadow .15s;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .input, :root:not([data-theme="light"]) .select, :root:not([data-theme="light"]) .textarea {
    background-color: color-mix(in srgb, var(--surface-3) 30%, transparent);
  }
}
:root[data-theme="dark"] .input, :root[data-theme="dark"] .select, :root[data-theme="dark"] .textarea {
  background-color: color-mix(in srgb, var(--surface-3) 30%, transparent);
}
.textarea { height: auto; min-height: 80px; padding: var(--space-2) var(--space-3); resize: vertical; }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: var(--select-chevron) !important;
  background-repeat: no-repeat !important; background-position: right 10px center !important; background-size: 16px 16px !important;
}
.select option { background: var(--surface); color: var(--text); }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus,
.input:focus-visible, .select:focus-visible, .textarea:focus-visible {
  outline: none; border-color: var(--ring) !important; box-shadow: 0 0 0 3px var(--focus-ring);
  border-radius: var(--radius-sm);
}
.input:disabled, .select:disabled, .textarea:disabled { opacity: .5; cursor: not-allowed; }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger) !important; }
.input[aria-invalid="true"]:focus, .select[aria-invalid="true"]:focus, .textarea[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 20%, transparent);
}
.input.mono { font-size: 13px; }
.input-sm { height: 32px; font-size: 13px; }

.field { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.field > label, .field .label { font-size: 14px; font-weight: 500; color: var(--text); line-height: 1.2; }
.field .optional { font-weight: 400; color: var(--text-2); }
.field .hint { font-size: 13px; color: var(--text-2); line-height: 1.4; }
.field .error, .field-error { font-size: 13px; color: var(--danger); line-height: 1.4; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-4); align-items: start; }
.check { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; font-size: 14px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }

/* ---------- card ---------- */
.card {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1); min-width: 0;
}
.card-header {
  display: flex; flex-direction: column; gap: 6px;
  padding: var(--space-6) var(--space-6) 0;
}
.card-header h2, .card-header h3, .card-title { font-size: 16px; font-weight: 600; line-height: 1.3; letter-spacing: -.01em; }
.card-header p, .card-header .muted, .card-description { font-size: 14px; color: var(--text-2); }
.card-body { padding: var(--space-6); }
.card-footer {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-4) var(--space-6); border-top: 1px solid var(--border);
}

/* ---------- badge / chip / stage pill ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: transparent; color: var(--text-2);
  font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap;
}
.badge svg, .badge img { width: 12px; height: 12px; flex: none; }
.badge-secondary { background: var(--surface-2); border-color: transparent; color: var(--text); }
.badge-solid { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.badge-ok, .badge-warn, .badge-danger { color: var(--text); }
.badge-ok::before, .badge-warn::before, .badge-danger::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; flex: none; margin-right: 2px;
}
.badge-ok::before { background: var(--ok); }
.badge-warn::before { background: var(--warn); }
.badge-danger::before { background: var(--danger); }
.badge-accent { background: var(--surface-2); border-color: transparent; color: var(--text); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 8px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text);
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
button.chip { cursor: pointer; height: 28px; padding: 0 10px; background: transparent; border-color: var(--border); color: var(--text-2); }
button.chip:hover { background: var(--hover); color: var(--text); }
.chip.is-active, .chip[aria-pressed="true"] { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.chip .dot, .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }

.stage-pill {
  --stage: var(--stage-watch);
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 8px; border-radius: var(--radius-sm);
  background: transparent; border: 1px solid var(--border); color: var(--text);
  font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap; text-transform: capitalize;
}
.stage-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--stage); flex: none; }
.stage-pill[data-stage="watch"], .stage-pill[data-stage=""] { color: var(--text-2); }
/* stage colour hook for dots, rails, borders: set data-stage and read var(--stage) */
[data-stage="notice"] { --stage: var(--stage-notice); }
[data-stage="assign"] { --stage: var(--stage-assign); }
[data-stage="nudge"] { --stage: var(--stage-nudge); }
[data-stage="escalate"] { --stage: var(--stage-escalate); }
[data-stage="page"] { --stage: var(--stage-page); }
[data-stage="breach"] { --stage: var(--stage-breach); }
[data-stage="watch"] { --stage: var(--stage-watch); }

/* ---------- key/value ---------- */
.kv { display: grid; grid-template-columns: minmax(104px, max-content) 1fr; gap: var(--space-2) var(--space-6); margin: 0; font-size: 14px; }
.kv dt, .kv > .k { color: var(--text-2); }
.kv dd, .kv > .v { margin: 0; min-width: 0; overflow-wrap: anywhere; color: var(--text); }

/* ---------- empty / loading / error ---------- */
.empty-state {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 6px; padding: var(--space-7);
  border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
  color: var(--text-2);
}
.empty-state > svg, .empty-state .empty-icon {
  box-sizing: border-box; width: 40px; height: 40px; padding: 10px; margin-bottom: var(--space-2);
  display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  color: var(--text); box-shadow: var(--shadow-1);
}
.empty-state .empty-icon svg { width: 20px; height: 20px; }
.empty-state h3, .empty-state .title { font-size: 14px; font-weight: 600; color: var(--text); }
.empty-state p, .empty-state .text { max-width: 44ch; font-size: 14px; color: var(--text-2); }
.empty-state .actions, .empty-state .cluster { margin-top: var(--space-3); justify-content: center; }
.empty-state.is-compact { padding: var(--space-6) var(--space-4); }

.error-state {
  display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;
  padding: var(--space-3) var(--space-4); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border));
  font-size: 14px;
}
.error-state::before {
  content: ""; width: 16px; height: 16px; flex: none; background: var(--danger);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' x2='12' y1='8' y2='12'/%3E%3Cline x1='12' x2='12.01' y1='16' y2='16'/%3E%3C/svg%3E") center / 16px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' x2='12' y1='8' y2='12'/%3E%3Cline x1='12' x2='12.01' y1='16' y2='16'/%3E%3C/svg%3E") center / 16px no-repeat;
}
.error-state .btn { margin-left: auto; }

.skeleton {
  display: block; min-height: 12px; border-radius: var(--radius-sm);
  background: var(--surface-2); color: transparent !important;
  animation: hl-pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;
}
.skeleton * { visibility: hidden; }
.skeleton-line { height: 12px; margin: 6px 0; }
.skeleton-block { height: 64px; border-radius: var(--radius); }
@keyframes hl-pulse { 50% { opacity: .5; } }

.spinner {
  display: inline-block; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-right-color: transparent; border-top-color: var(--text-2);
  animation: hl-spin .7s linear infinite;
}

/* ---------- table (shadcn Table) ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; caption-side: bottom; }
.table th {
  height: 40px; padding: 0 var(--space-3); text-align: left; vertical-align: middle;
  font-weight: 500; font-size: 13px; color: var(--text-2); white-space: nowrap;
  border-bottom: 1px solid var(--border); background: transparent;
}
.table td { height: 48px; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color .12s; }
.table tbody tr:hover td { background: var(--hover); }
.table .num, .table .mono { font-family: var(--font-mono); font-size: 13px; font-variant-numeric: tabular-nums; }
.table td.actions, .table th.actions { text-align: right; white-space: nowrap; }

/* ---------- segmented (shadcn Tabs list) + inline tabs ---------- */
.segmented {
  display: inline-flex; align-items: center; padding: 3px; gap: 0;
  background: var(--surface-2); border-radius: var(--radius); border: 0; height: 36px;
}
.segmented > button, .segmented > a {
  height: 30px; padding: 0 var(--space-3); border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-2); font-size: 13px; font-weight: 500;
  cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none;
  transition: background-color .15s, color .15s, box-shadow .15s;
}
.segmented > button:hover, .segmented > a:hover { color: var(--text); }
.segmented > .is-active, .segmented > [aria-pressed="true"], .segmented > [aria-selected="true"] {
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-1);
}
:root[data-theme="dark"] .segmented > .is-active, :root[data-theme="dark"] .segmented > [aria-pressed="true"], :root[data-theme="dark"] .segmented > [aria-selected="true"] {
  background: var(--surface-3); border-color: var(--border-strong);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .segmented > .is-active, :root:not([data-theme="light"]) .segmented > [aria-pressed="true"], :root:not([data-theme="light"]) .segmented > [aria-selected="true"] {
    background: var(--surface-3); border-color: var(--border-strong);
  }
}
.segmented svg { width: 14px; height: 14px; }

.tabs-inline { display: flex; gap: var(--space-5); border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs-inline::-webkit-scrollbar { display: none; }
.tabs-inline > button, .tabs-inline > a {
  position: relative; padding: var(--space-2) 0 var(--space-3); border: 0; background: none;
  color: var(--text-2); font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.tabs-inline > button:hover, .tabs-inline > a:hover { color: var(--text); }
.tabs-inline > .is-active, .tabs-inline > [aria-selected="true"] { color: var(--text); }
.tabs-inline > .is-active::after, .tabs-inline > [aria-selected="true"]::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--text);
}

/* ---------- page header (shared by views) ---------- */
.page-head { display: flex; align-items: flex-end; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-7); }
.page-head h1 { font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.page-head p { color: var(--text-2); margin-top: 4px; max-width: 70ch; }
.page-head .actions { margin-left: auto; display: flex; gap: var(--space-2); flex-wrap: wrap; }
.section-title { font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.section-description { font-size: 14px; color: var(--text-2); margin-top: 4px; }

/* ---------- dropdown menu (shadcn DropdownMenu) ---------- */
.menu-anchor { position: relative; display: inline-flex; }
.menu {
  position: absolute; z-index: 70; min-width: 148px; padding: 4px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-2);
  animation: hl-menu-in .12s ease-out;
}
.menu.menu-up { bottom: calc(100% + 6px); right: 0; }
.menu.menu-down { top: calc(100% + 6px); right: 0; }
.menu-label { padding: 6px 8px; font-size: 12px; font-weight: 500; color: var(--text-2); }
.menu-item {
  display: flex; align-items: center; gap: var(--space-2); width: 100%;
  height: 32px; padding: 0 8px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text); font-size: 14px; text-align: left; cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--hover); outline: none; }
.menu-item svg { width: 16px; height: 16px; color: var(--text-2); flex: none; }
.menu-item .menu-check { margin-left: auto; visibility: hidden; color: var(--text); }
.menu-item[aria-checked="true"] .menu-check { visibility: visible; }
@keyframes hl-menu-in { from { opacity: 0; transform: scale(.97); } }

/* theme toggle icon: sun in light, moon in dark */
.theme-toggle .ico-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .ico-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .ico-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle .ico-sun { display: none; }
  :root:not([data-theme]) .theme-toggle .ico-moon { display: block; }
}

/* =====================================================================
   Boot splash
   ===================================================================== */
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 5; }
.boot .brand-mark { width: 28px; height: 28px; color: var(--text-3); animation: hl-pulse 1.6s ease-in-out infinite; }

/* =====================================================================
   Brand
   ===================================================================== */
.brand { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--text); text-decoration: none; font-weight: 600; font-size: 15px; letter-spacing: -.01em; }
.brand:hover { color: var(--text); }
.brand-mark { width: 20px; height: 20px; flex: none; color: var(--text); }
.brand-tile {
  width: 32px; height: 32px; flex: none; display: grid; place-items: center;
  border-radius: var(--radius); background: var(--accent); color: var(--accent-contrast);
}
.brand-tile .brand-mark { width: 18px; height: 18px; color: var(--accent-contrast); }

/* =====================================================================
   App shell (shadcn sidebar-07)
   ===================================================================== */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-2);
  background: var(--sidebar); border-right: 1px solid var(--border);
}
.sidebar-top { display: flex; align-items: center; gap: var(--space-1); }
.ws-switch {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2); border-radius: var(--radius); color: var(--text); text-decoration: none;
}
.ws-switch:hover { background: var(--hover); }
.ws-switch .ws-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.ws-switch .ws-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-switch .ws-sub { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-group { display: flex; flex-direction: column; gap: 2px; padding: var(--space-2) 0; }
.sidebar-label { height: 32px; display: flex; align-items: center; padding: 0 var(--space-2); font-size: 12px; font-weight: 500; color: var(--text-2); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: var(--space-2);
  height: 32px; padding: 0 var(--space-2); border-radius: var(--radius-sm);
  color: var(--text-2); text-decoration: none; font-weight: 500; font-size: 14px;
  transition: background-color .12s, color .12s;
}
.nav a svg { width: 16px; height: 16px; flex: none; }
.nav a:hover { background: var(--hover); color: var(--text); }
.nav a[aria-current="page"] { background: var(--hover); color: var(--text); }
.nav a:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--ring); }

.sidebar-bottom { margin-top: auto; display: flex; flex-direction: column; gap: var(--space-2); }
.sidebar-bottom .btn { background: var(--surface); }
.sidebar-bottom .btn:hover { background: var(--hover); }
.sweep-status { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 6px; padding: 0 var(--space-2); }
.sweep-status:empty { display: none; }
.sweep-status .pulse { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); animation: hl-pulse 1.4s ease-in-out infinite; flex: none; }
.account {
  display: flex; align-items: center; gap: var(--space-2); min-width: 0;
  border-top: 1px solid var(--border); margin: 0 calc(-1 * var(--space-2)) calc(-1 * var(--space-2));
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-3);
}
.avatar {
  width: 32px; height: 32px; border-radius: var(--radius); flex: none; display: grid; place-items: center;
  background: var(--surface-3); color: var(--text); font-size: 12px; font-weight: 600; text-transform: uppercase;
}
.account .who { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.3; }
.account .who b { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account .who span { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account .btn-icon { --btn-h: 28px; color: var(--text-2); }
.account .btn-icon:hover { color: var(--text); }

.topbar { display: none; }
.main { min-width: 0; background: var(--bg); }
.main-inner { max-width: var(--content-max); margin: 0 auto; padding: var(--space-7) var(--space-7) var(--space-8); }
.view { min-width: 0; }
.view:focus { outline: none; }

.nav-scrim { display: none; }

@media (max-width: 767px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .topbar {
    display: flex; align-items: center; gap: var(--space-2);
    position: sticky; top: 0; z-index: 30; height: 56px; padding: 0 var(--space-4) 0 var(--space-2);
    background: var(--bg); border-bottom: 1px solid var(--border);
  }
  .topbar-sep { width: 1px; height: 16px; background: var(--border); margin: 0 var(--space-1); flex: none; }
  .topbar .topbar-view { color: var(--text); font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .sidebar {
    position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; width: min(288px, 86vw); height: auto;
    transform: translateX(-100%); transition: transform .3s var(--ease), visibility .3s;
    box-shadow: var(--shadow-2); visibility: hidden; background: var(--sidebar);
  }
  .shell.nav-open .sidebar { transform: none; visibility: visible; }
  .shell.nav-open .nav-scrim { display: block; position: fixed; inset: 0; z-index: 40; background: var(--overlay); animation: hl-fade .2s ease; }
  .main-inner { padding: var(--space-5) var(--space-4) var(--space-8); }
}
@media (min-width: 768px) { .sidebar .nav-close { display: none; } }

/* =====================================================================
   Toasts (shadcn Sonner)
   ===================================================================== */
.toasts {
  position: fixed; z-index: 90; right: var(--space-6); bottom: var(--space-6);
  display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-2);
  pointer-events: none; width: 356px; max-width: calc(100vw - 2 * var(--space-4));
}
.toast {
  pointer-events: auto; position: relative; display: flex; align-items: center; gap: var(--space-2);
  width: 100%; padding: var(--space-4); padding-right: 40px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-2); font-size: 14px; line-height: 1.4;
  animation: hl-toast-in .3s var(--ease);
}
.toast .toast-icon { width: 16px; height: 16px; flex: none; align-self: flex-start; margin-top: 1px; }
.toast[data-kind="ok"] .toast-icon { color: var(--ok); }
.toast[data-kind="error"] .toast-icon { color: var(--danger); }
.toast .toast-msg { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 500; }
.toast .toast-x {
  position: absolute; top: 50%; right: 10px; transform: translateY(-50%);
  width: 24px; height: 24px; display: grid; place-items: center; padding: 0;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-2); cursor: pointer;
}
.toast .toast-x svg { width: 14px; height: 14px; }
.toast .toast-x:hover { background: var(--hover); color: var(--text); }
.toast.is-leaving { animation: hl-toast-out .2s ease-in forwards; }
@keyframes hl-toast-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes hl-toast-out { to { opacity: 0; transform: translateY(6px); } }
@media (max-width: 600px) {
  .toasts { left: var(--space-4); right: var(--space-4); bottom: var(--space-4); width: auto; align-items: stretch; max-width: none; }
}

/* =====================================================================
   Drawer (shadcn Sheet, right side)
   ===================================================================== */
.drawer-root { position: fixed; inset: 0; z-index: 60; }
.drawer-backdrop { position: absolute; inset: 0; background: var(--overlay); animation: hl-fade .25s ease; }
.drawer {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(480px, 100vw);
  display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-2);
  animation: hl-drawer-in .35s var(--ease);
}
.drawer:focus { outline: none; }
.drawer-close {
  position: absolute; top: var(--space-4); right: var(--space-4); z-index: 2;
  --btn-h: 28px; color: var(--text-2);
}
.drawer-close:hover { color: var(--text); }
.drawer-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: var(--space-6); }
/* optional helpers for drawer content */
.sheet-header { display: flex; flex-direction: column; gap: 6px; padding-right: 36px; margin-bottom: var(--space-6); }
.sheet-title { font-size: 18px; font-weight: 600; letter-spacing: -.01em; line-height: 1.3; }
.sheet-description { font-size: 14px; color: var(--text-2); }
.sheet-section { padding: var(--space-5) 0; border-top: 1px solid var(--border); }
.sheet-footer { display: flex; flex-wrap: wrap; gap: var(--space-2); padding-top: var(--space-5); border-top: 1px solid var(--border); }
.drawer-root.is-leaving .drawer { animation: hl-drawer-out .2s ease-in forwards; }
.drawer-root.is-leaving .drawer-backdrop { animation: hl-fade-out .2s ease-in forwards; }
@keyframes hl-drawer-in { from { transform: translateX(100%); } }
@keyframes hl-drawer-out { to { transform: translateX(100%); } }
@keyframes hl-fade { from { opacity: 0; } }
@keyframes hl-fade-out { to { opacity: 0; } }
@media (max-width: 600px) { .drawer-body { padding: var(--space-4); } }

/* =====================================================================
   Confirm dialog (shadcn AlertDialog)
   ===================================================================== */
.dialog {
  width: min(420px, calc(100vw - 32px)); max-width: none; padding: var(--space-6); border: 1px solid var(--border);
  border-radius: var(--radius-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow-2);
}
.dialog::backdrop { background: var(--overlay); }
.dialog[open] { animation: hl-dialog-in .18s ease-out; }
@keyframes hl-dialog-in { from { opacity: 0; transform: scale(.96); } }
.dialog-body { display: flex; flex-direction: column; gap: var(--space-2); }
.dialog-body h2 { font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.dialog-body p { color: var(--text-2); font-size: 14px; white-space: pre-line; overflow-wrap: anywhere; }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-6); flex-wrap: wrap; }
@media (max-width: 480px) {
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions .btn { width: 100%; }
}

/* =====================================================================
   Signed-out: auth screen (shadcn login-01)
   ===================================================================== */
.auth {
  position: relative; min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-6); padding: var(--space-8) var(--space-4); background: var(--bg);
}
.auth-top { position: absolute; top: var(--space-4); right: var(--space-4); }
.auth-brand { font-size: 15px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .card-header { padding-bottom: 0; }
.auth-card .card-header h1 { font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
.auth-card .card-body { display: flex; flex-direction: column; gap: var(--space-5); }
.auth-divider {
  position: relative; display: flex; align-items: center; gap: var(--space-3);
  color: var(--text-2); font-size: 13px;
}
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-form { display: flex; flex-direction: column; gap: var(--space-4); }
.auth-switch { text-align: center; font-size: 14px; color: var(--text-2); }
.link-btn {
  padding: 0; border: 0; background: none; cursor: pointer; font: inherit; font-weight: 500;
  color: var(--text); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--border-strong);
}
.link-btn:hover { text-decoration-color: currentColor; }
.auth-error {
  display: flex; gap: var(--space-2); align-items: flex-start; padding: var(--space-3);
  border-radius: var(--radius); background: var(--surface); color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border)); font-size: 14px;
}
.auth-error::before {
  content: ""; width: 16px; height: 16px; flex: none; margin-top: 1px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' x2='12' y1='8' y2='12'/%3E%3Cline x1='12' x2='12.01' y1='16' y2='16'/%3E%3C/svg%3E") center / 16px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' x2='12' y1='8' y2='12'/%3E%3Cline x1='12' x2='12.01' y1='16' y2='16'/%3E%3C/svg%3E") center / 16px no-repeat;
}
.auth-foot { max-width: 380px; text-align: center; font-size: 12px; color: var(--text-2); line-height: 1.5; text-wrap: balance; }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ---------- custom dropdowns (assets/select.js): shadcn Select / Combobox popover ---------- */
select.hls-native {
  position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important;
  overflow: hidden !important; clip: rect(0 0 0 0) !important; border: 0 !important; opacity: 0 !important; pointer-events: none !important;
}
.hls-trigger { display: flex; align-items: center; text-align: left; font: inherit; color: var(--text); width: 100%; }
.hls-trigger .hls-value { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hls-trigger .hls-value.is-placeholder { color: var(--text-3); }
.hls-trigger[aria-expanded="true"] { border-color: var(--ring) !important; box-shadow: 0 0 0 3px var(--focus-ring); }
.hls-pop {
  position: fixed; z-index: 1000; max-height: 288px; overflow-y: auto; padding: 4px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-2); font-size: 14px; animation: hls-in .12s ease-out;
}
.hls-pop[data-side="top"] { animation-name: hls-in-up; }
@keyframes hls-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
@keyframes hls-in-up { from { opacity: 0; transform: translateY(4px) scale(.98); } }
@media (prefers-reduced-motion: reduce) { .hls-pop { animation: none; } }
.hls-opt {
  display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 6px 8px; border-radius: var(--radius-sm);
  cursor: default; user-select: none;
}
.hls-opt.is-active { background: var(--hover); }
.hls-opt[aria-disabled="true"] { opacity: .5; }
.hls-opt-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hls-opt-label.mono { font-size: 13px; }
.hls-opt-hint { flex: none; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--text-2); }
.hls-check { width: 16px; height: 16px; flex: none; visibility: hidden; color: var(--text); }
.hls-opt.is-selected .hls-check { visibility: visible; }
