/* ============================================================
   CareIT Business OS — Design System v2.0
   "Aurora 2.0" — premium, executive, AI-first.
   Custom-built. No frameworks. Light + dark, density-aware.

   Palette: sapphire accent, neutral-first chrome.
   The aurora gradient (teal→sapphire→violet) is RESERVED for
   AI-generated / AI-suggested surfaces. Never use it as decoration.
   ============================================================ */

/* ---------- 0. Typefaces (self-hosted, latin subset, variable) ---------- */
@font-face {
  font-family: "Schibsted Grotesk"; font-style: normal; font-weight: 400 900;
  font-display: swap; src: url("../fonts/schibsted-grotesk-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Instrument Sans"; font-style: normal; font-weight: 400 700;
  font-display: swap; src: url("../fonts/instrument-sans-latin.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono"; font-style: normal; font-weight: 400 700;
  font-display: swap; src: url("../fonts/jetbrains-mono-latin.woff2") format("woff2");
}

/* ---------- 1. Tokens ---------- */
:root {
  /* Brand — sapphire ramp (replaces indigo; token names preserved) */
  --brand-50:  #eef3fe;
  --brand-100: #e3eafd;
  --brand-200: #c4d3fb;
  --brand-300: #9ab4f7;
  --brand-400: #6b8ff1;
  --brand-500: #4270ec;
  --brand-600: #2e5be6;
  --brand-700: #1e40c0;
  --brand-800: #1a3599;
  --brand-900: #172c78;
  --accent:    #1fa294;
  --accent-strong: #16786e;

  /* AI signature — the ONLY gradient in the product */
  --aur-a: #2bc5b4; --aur-b: #5b7cfa; --aur-c: #9a6bff;
  --aurora: linear-gradient(90deg, var(--aur-a), var(--aur-b) 52%, var(--aur-c));
  --aurora-135: linear-gradient(135deg, var(--aur-a), var(--aur-b) 52%, var(--aur-c));

  /* Neutrals (light) — slight sapphire bias, chosen not inherited */
  --bg:        #f7f9fc;
  --bg-raise:  #ffffff;
  --bg-sunk:   #eef2f8;
  --bg-hover:  #f1f5fa;
  --bg-active: #e7ecf5;
  --border:    #dce3ee;
  --border-strong: #c3cddf;
  --text:      #0d1526;
  --text-2:    #3d4a63;
  --text-3:    #5f6d89;   /* WCAG AA: 4.9:1 on --bg (was #8a90a6 ≈ 2.8:1) */
  --text-inv:  #ffffff;

  /* Semantic */
  --ok:      #177a4b;  --ok-bg:      #ddf3e7;  --ok-border:      #a8dcc2;
  --warn:    #9a6a10;  --warn-bg:    #faeecf;  --warn-border:    #edd193;
  --danger:  #c23434;  --danger-bg:  #fbe3e3;  --danger-border:  #f3bcbc;
  --info:    #1a56c4;  --info-bg:    #e3ecfd;  --info-border:    #b9cef7;
  --ai:      #7a5af8;  --ai-bg:      #f0ecfe;  --ai-border:      #d6cbfd;

  /* Charts (categorical, max 6 + 2 reserve; derived from sapphire) */
  --ch-1: #2e5be6; --ch-2: #1fa294; --ch-3: #7a5af8; --ch-4: #64748b;
  --ch-5: #c08a2d; --ch-6: #c25573; --ch-7: #0f8ea8; --ch-8: #8a8f9c;

  /* Elevation — 3 real steps + overlay */
  --shadow-1: 0 1px 2px rgba(13,21,38,.06);
  --shadow-2: 0 4px 16px -4px rgba(13,21,38,.10), 0 1px 2px rgba(13,21,38,.05);
  --shadow-3: 0 16px 40px -12px rgba(13,21,38,.18), 0 2px 8px rgba(13,21,38,.06);
  --shadow-pop: 0 24px 56px -16px rgba(13,21,38,.24), 0 4px 12px rgba(13,21,38,.08);

  /* Shape + rhythm — tightened geometry: 6 controls / 10 panels / 14 overlays */
  --r-sm: 6px; --r-md: 10px; --r-lg: 12px; --r-xl: 14px; --r-full: 999px;
  --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;

  /* Type — display / body / data */
  --font-display: "Schibsted Grotesk", "Segoe UI", system-ui, sans-serif;
  --font: "Instrument Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, "SF Mono", monospace;
  --fs-xs: 11.5px; --fs-sm: 12.5px; --fs-base: 13.5px; --fs-md: 15px;
  --fs-lg: 17px; --fs-xl: 21px; --fs-2xl: 26px; --fs-3xl: 32px;

  --sidebar-w: 248px;
  --sidebar-w-rail: 68px;
  --topbar-h: 60px;

  /* Motion — every animation maps to a state change */
  --ease: cubic-bezier(.2,.8,.2,1);
  --ease-out: cubic-bezier(.2,.8,.3,1);
  --t-instant: 80ms;
  --t-quick: 140ms;
  --t-move: 220ms;
  --t-reveal: 400ms;
  --t-ambient: 1.4s;
  --dur: var(--t-quick);

  color-scheme: light;
}

[data-theme="dark"] {
  --brand-50:  #16203a;
  --brand-100: #1a2647;
  --brand-200: #24356b;
  --brand-300: #a3b8ff;
  --brand-400: #8fa9ff;
  --brand-500: #7d9bff;
  --brand-600: #7d9bff;
  --brand-700: #a3b8ff;
  --brand-800: #c2d0ff;
  --brand-900: #dfe6ff;
  --accent:    #2ec4b3;
  --accent-strong: #52d6c6;

  --bg:        #0b1017;
  --bg-raise:  #111825;
  --bg-sunk:   #0d131d;
  --bg-hover:  #182131;
  --bg-active: #1f2a3d;
  --border:    #243044;
  --border-strong: #35435c;
  --text:      #e6ecf7;
  --text-2:    #a9b6cd;
  --text-3:    #8996ae;   /* WCAG AA: 5.6:1 on --bg (was #667090 ≈ 3.2:1) */
  --text-inv:  #0b1017;

  --ok:      #4cc98a;  --ok-bg:      rgba(76,201,138,.13);  --ok-border:     rgba(76,201,138,.32);
  --warn:    #e0b153;  --warn-bg:    rgba(224,177,83,.13);  --warn-border:   rgba(224,177,83,.32);
  --danger:  #f07f7f;  --danger-bg:  rgba(240,127,127,.13); --danger-border: rgba(240,127,127,.32);
  --info:    #7ba8ff;  --info-bg:    rgba(123,168,255,.13); --info-border:   rgba(123,168,255,.32);
  --ai:      #a78bfa;  --ai-bg:      rgba(167,139,250,.14); --ai-border:     rgba(167,139,250,.34);

  --ch-1: #7d9bff; --ch-2: #2ec4b3; --ch-3: #a78bfa; --ch-4: #94a3b8;
  --ch-5: #e0b153; --ch-6: #e58aa4; --ch-7: #4bb8d4; --ch-8: #b0b7c4;

  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 4px 16px -4px rgba(0,0,0,.5), 0 1px 2px rgba(0,0,0,.4);
  --shadow-3: 0 16px 40px -12px rgba(0,0,0,.6), 0 2px 8px rgba(0,0,0,.45);
  --shadow-pop: 0 24px 56px -16px rgba(0,0,0,.68), 0 4px 12px rgba(0,0,0,.5);
  color-scheme: dark;
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: var(--fs-base);
  line-height: 1.55; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  font-feature-settings: "cv02","cv03","cv04","cv11","tnum" 0;
}
h1,h2,h3,h4 { margin: 0; font-family: var(--font-display); font-weight: 700; letter-spacing: -0.015em; line-height: 1.2; }
h1 { font-size: var(--fs-2xl); } h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); letter-spacing: -0.008em; } h4 { font-size: var(--fs-md); letter-spacing: -0.005em; }
p  { margin: 0 0 var(--sp-3); }
a  { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }
small { font-size: var(--fs-sm); color: var(--text-3); }
code, kbd { font-family: var(--mono); font-size: 0.88em; }
kbd {
  padding: 1.5px 6px; border-radius: 6px; border: 1px solid var(--border-strong);
  background: var(--bg-raise); box-shadow: 0 1px 0 var(--border-strong);
  color: var(--text-2); font-size: 11px;
}
::selection { background: var(--brand-200); color: var(--brand-900); }
:focus-visible { outline: 2px solid var(--brand-600); outline-offset: 2px; border-radius: 4px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.tx2 { color: var(--text-2); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }

/* ---------- 3. App shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; z-index: 40;
  background: var(--bg-raise); border-right: 1px solid var(--border);
  transition: width var(--dur) var(--ease);
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px;
}
.logo-mark {
  width: 32px; height: 32px; flex-shrink: 0; border-radius: 8px; display: grid; place-items: center;
  background: #2e5be6; color: #fff; font-family: var(--font-display);
  font-weight: 800; font-size: 14.5px; letter-spacing: -.03em;
  box-shadow: 0 2px 8px rgba(46,91,230,.30);
}
.logo-word { font-family: var(--font-display); font-weight: 700; font-size: 15.5px; letter-spacing: -.02em; white-space: nowrap; }
.logo-word span { color: var(--text-3); font-weight: 500; }

/* Workspace switcher — the tenant, not the vendor, heads the sidebar */
.workspace-switch {
  display: flex; align-items: center; gap: 10px; width: calc(100% - 20px); margin: 12px 10px 6px;
  padding: 7px 8px; border: 1px solid transparent; border-radius: var(--r-sm);
  background: none; cursor: pointer; text-align: left; font: inherit; color: var(--text);
  transition: background var(--t-quick), border-color var(--t-quick);
}
.workspace-switch:hover { background: var(--bg-hover); border-color: var(--border); }
.workspace-switch .ws-text { min-width: 0; flex: 1; display: grid; }
.workspace-switch .ws-name { font-family: var(--font-display); font-weight: 700; font-size: 14px; letter-spacing: -.01em; }
.workspace-switch .ws-sub { font-family: var(--mono); font-size: 10.5px; color: var(--text-3); }
.workspace-switch .ws-caret { color: var(--text-3); flex-shrink: 0; }

.side-nav { flex: 1; overflow-y: auto; padding: 4px 10px 14px; }
.nav-group { margin-bottom: 2px; }
.nav-group-label {
  display: flex; align-items: center; gap: 6px; width: 100%;
  padding: 12px 10px 5px; font-size: 10.5px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--text-3); white-space: nowrap;
  background: none; border: 0; cursor: pointer; font-family: var(--font); text-align: left;
}
.nav-group-label.plain { cursor: default; }
.nav-group-label:hover { color: var(--text-2); }
.nav-group-label .nav-caret { transition: transform var(--t-quick) var(--ease-out); flex-shrink: 0; }
.nav-group-label[aria-expanded="false"] .nav-caret { transform: rotate(-90deg); }
.nav-group-items { display: grid; }
.nav-group-label[aria-expanded="false"] + .nav-group-items { display: none; }

/* A row wraps the link so the pin control can live beside it (never inside <a>) */
.nav-row { position: relative; display: flex; align-items: center; }
.nav-row .nav-item { flex: 1; min-width: 0; }
.nav-pin {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; display: grid; place-items: center; padding: 0;
  border: 0; border-radius: 5px; background: var(--bg-raise); color: var(--text-3);
  cursor: pointer; opacity: 0; transition: opacity var(--t-quick), color var(--t-quick);
}
.nav-row:hover .nav-pin, .nav-pin:focus-visible { opacity: 1; }
.nav-pin:hover { color: var(--brand-600); background: var(--bg-active); }
.nav-pin.on { opacity: 1; color: var(--brand-600); }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 6.5px 10px; margin: 1px 0;
  border-radius: var(--r-sm); color: var(--text-2); font-weight: 500; font-size: var(--fs-base);
  white-space: nowrap; transition: background var(--t-quick), color var(--t-quick);
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.nav-item.active {
  background: var(--brand-50); color: var(--brand-700); font-weight: 600;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .8; }
.nav-item.active svg { opacity: 1; }
.nav-badge {
  margin-left: auto; font-size: 10.5px; font-weight: 700; padding: 1px 7px;
  border-radius: var(--r-full); background: var(--bg-active); color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.nav-badge.danger { background: var(--danger-bg); color: var(--danger); }
.nav-row:hover .nav-badge { opacity: 0; }   /* the pin takes this slot on hover */
.nav-item.active .nav-badge { background: var(--brand-100); color: var(--brand-700); }

.sidebar-foot { border-top: 1px solid var(--border); padding: 10px; }
.user-chip {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 6px 8px;
  border: 1px solid transparent; border-radius: var(--r-sm); background: none;
  cursor: pointer; font: inherit; color: var(--text); transition: background var(--t-quick);
}
.user-chip:hover { background: var(--bg-hover); border-color: var(--border); }

/* Collapsed rail — icons keep working, labels come back as tooltips */
.app.rail .sidebar { width: var(--sidebar-w-rail); }
.app.rail .ws-text, .app.rail .ws-caret,
.app.rail .nav-group-label, .app.rail .nav-item span, .app.rail .nav-badge,
.app.rail .nav-pin, .app.rail .user-chip > div:last-child { display: none; }
.app.rail .nav-item { justify-content: center; padding: 9px 0; }
.app.rail .workspace-switch, .app.rail .user-chip { justify-content: center; padding-left: 0; padding-right: 0; }
.app.rail .nav-group { margin-bottom: 8px; }
.app.rail .nav-group-label[aria-expanded="false"] + .nav-group-items { display: grid; }

/* Rail tooltips: the label has to exist somewhere for a 68px sidebar to be usable */
.app.rail .nav-row { position: relative; }
.app.rail .nav-row .nav-item::after {
  content: attr(data-label); position: absolute; left: calc(100% + 10px); top: 50%;
  transform: translateY(-50%) translateX(-4px); z-index: 90;
  background: var(--text); color: var(--bg-raise); font-size: var(--fs-sm); font-weight: 600;
  padding: 5px 9px; border-radius: 5px; white-space: nowrap; pointer-events: none;
  opacity: 0; box-shadow: var(--shadow-3); transition: opacity var(--t-quick) var(--ease-out), transform var(--t-quick) var(--ease-out);
}
.app.rail .nav-row .nav-item:hover::after,
.app.rail .nav-row .nav-item:focus-visible::after { opacity: 1; transform: translateY(-50%) translateX(0); }

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

.topbar {
  height: var(--topbar-h); position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px; padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}
.topbar .crumbs { display: flex; align-items: center; gap: 7px; font-size: var(--fs-base); color: var(--text-3); min-width: 0; }
.topbar .crumbs b { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .crumbs a { color: var(--text-2); text-decoration: none; }
.topbar .crumbs a:hover { color: var(--text); text-decoration: underline; }
.topbar .crumbs .crumb-domain { font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
@media (max-width: 720px) { .topbar .crumbs .crumb-domain, .topbar .crumbs a { display: none; } .topbar .crumbs svg { display: none; } }

/* Numeric notification count — a dot can't say "how many" */
.icon-btn .count-badge {
  position: absolute; top: 2px; right: 1px; min-width: 16px; height: 16px; padding: 0 4px;
  display: grid; place-items: center; border-radius: 99px;
  background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
  font-variant-numeric: tabular-nums; border: 2px solid var(--bg); box-sizing: content-box;
}
[data-theme="dark"] .icon-btn .count-badge { color: #2a0d0d; }
.topbar-spacer { flex: 1; }

.search-pill {
  display: flex; align-items: center; gap: 9px; height: 34px; padding: 0 12px;
  min-width: 220px; border-radius: var(--r-full); cursor: pointer;
  background: var(--bg-raise); border: 1px solid var(--border);
  color: var(--text-3); font-size: var(--fs-sm); transition: border-color var(--dur), box-shadow var(--dur);
}
.search-pill:hover { border-color: var(--border-strong); box-shadow: var(--shadow-1); }
.search-pill kbd { margin-left: auto; }

.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center; border-radius: var(--r-sm);
  border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer;
  position: relative; transition: background var(--dur);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .dot {
  position: absolute; top: 6px; right: 7px; width: 7px; height: 7px; border-radius: 99px;
  background: var(--danger); border: 2px solid var(--bg);
}

.avatar {
  width: 30px; height: 30px; border-radius: var(--r-full); display: grid; place-items: center;
  font-size: 11.5px; font-weight: 700; color: #fff; flex-shrink: 0;
  /* fixed values: white initials must stay legible in both themes */
  background: linear-gradient(135deg, #2e5be6, #7a5af8);
}
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }
.avatar.sm { width: 24px; height: 24px; font-size: 9.5px; }

.content { padding: 24px 26px 60px; max-width: 1560px; width: 100%; margin: 0 auto; }
.content.narrow { max-width: 980px; }

/* Page header */
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .titles { min-width: 0; }
.page-head .sub { color: var(--text-3); margin-top: 3px; font-size: var(--fs-base); }
.page-head .actions { margin-left: auto; display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }

/* ---------- 4. Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid transparent;
  font: 600 var(--fs-base)/1 var(--font); cursor: pointer; white-space: nowrap;
  transition: background var(--t-quick) var(--ease-out), box-shadow var(--t-quick), transform var(--t-instant);
  text-decoration: none !important; position: relative;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 15.5px; height: 15.5px; }
.btn-primary {
  background: var(--brand-600); color: var(--text-inv);
  box-shadow: var(--shadow-1);
}
.btn-primary:hover { background: var(--brand-700); }
.btn-secondary {
  background: var(--bg-raise); color: var(--text); border-color: var(--border-strong);
  box-shadow: var(--shadow-1);
}
.btn-secondary:hover { background: var(--bg-hover); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
[data-theme="dark"] .btn-danger { color: #2a0d0d; }
.btn-danger:hover { filter: brightness(.92); }
/* The only gradient control in the system — AI actions (see aurora rule) */
.btn-ai {
  color: #fff; border: none;
  background: linear-gradient(120deg, var(--aur-b), var(--aur-c));
  background-size: 160% 100%; box-shadow: 0 2px 10px rgba(122,90,248,.30);
  transition: background-position var(--t-reveal) var(--ease), box-shadow var(--t-quick);
}
.btn-ai:hover { background-position: 90% 0; box-shadow: 0 4px 16px rgba(122,90,248,.42); }
.btn-sm { height: 30px; padding: 0 10px; font-size: var(--fs-sm); border-radius: 5px; }
.btn-lg { height: 40px; padding: 0 18px; font-size: var(--fs-md); }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* Busy state — label stays (no layout shift), spinner replaces icon slot */
.btn.is-busy { pointer-events: none; opacity: .8; }
.btn.is-busy > svg, .btn.is-busy > .btn-ico { display: none; }
.btn.is-busy::before {
  content: ""; width: 14px; height: 14px; flex-shrink: 0; border-radius: 99px;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin var(--t-ambient) linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 5. Cards / panels ---------- */
.card {
  background: var(--bg-raise); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.card-pad { padding: 20px; }
.card-head {
  display: flex; align-items: center; gap: 10px; padding: 15px 20px;
  border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: var(--fs-md); font-weight: 650; }
.card-head .spacer { flex: 1; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--border); display:flex; align-items:center; gap:10px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.dashboard-primary { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.dashboard-triple { grid-template-columns: repeat(3, minmax(0,1fr)); }
.dashboard-double { grid-template-columns: repeat(2, minmax(0,1fr)); }
.span-2 { grid-column: span 2; }
@media (max-width: 1100px) { .grid-4, .grid-3, .dashboard-triple { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media (max-width: 720px)  { .grid-4, .grid-3, .grid-2, .dashboard-primary, .dashboard-triple, .dashboard-double { grid-template-columns: minmax(0,1fr); } .span-2 { grid-column: span 1; } }

/* Stat tile */
.stat { padding: 18px 20px; position: relative; overflow: hidden; }
.stat .label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-3); display:flex; align-items:center; gap:7px; }
.stat .value { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat .delta { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-sm); font-weight: 650; margin-top: 5px; }
.stat .delta.up { color: var(--ok); } .stat .delta.down { color: var(--danger); } .stat .delta.flat { color: var(--text-3); }
.stat .spark { position: absolute; right: 14px; bottom: 12px; opacity: .9; }

/* ---------- 6. Badges & status ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 21px; padding: 0 8px;
  border-radius: var(--r-full); font-size: 11px; font-weight: 650; letter-spacing: .01em;
  border: 1px solid var(--border); background: var(--bg-sunk); color: var(--text-2); white-space: nowrap;
}
.badge::before { content:""; width: 6px; height: 6px; border-radius: 99px; background: currentColor; opacity:.75; }
.badge.plain::before { display: none; }
.badge-ok     { background: var(--ok-bg);     border-color: var(--ok-border);     color: var(--ok); }
.badge-warn   { background: var(--warn-bg);   border-color: var(--warn-border);   color: var(--warn); }
.badge-danger { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.badge-info   { background: var(--info-bg);   border-color: var(--info-border);   color: var(--info); }
.badge-ai     { background: var(--ai-bg);     border-color: var(--ai-border);     color: var(--ai); }
.badge-brand  { background: var(--brand-50);  border-color: var(--brand-200);     color: var(--brand-700); }

/* ---------- 7. Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: inherit; }
table.dt { width: 100%; border-collapse: collapse; font-size: var(--fs-base); }
.dt thead th {
  text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-3); padding: 10px 16px; border-bottom: 1px solid var(--border);
  background: var(--bg-sunk); white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
.dt tbody td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.dt tbody tr { transition: background 100ms; }
.dt tbody tr:hover { background: var(--bg-hover); }
.dt tbody tr:last-child td { border-bottom: none; }
.dt .r { text-align: right; font-variant-numeric: tabular-nums; }
.dt a.rowlink { color: var(--text); font-weight: 600; }
.dt a.rowlink:hover { color: var(--brand-600); text-decoration: none; }
.cell-2l .l1 { font-weight: 600; } .cell-2l .l2 { font-size: var(--fs-sm); color: var(--text-3); }

/* Toolbar above tables */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.input, select.input, textarea.input {
  height: 36px; padding: 0 11px; border-radius: var(--r-sm); font: 500 var(--fs-base) var(--font);
  border: 1px solid var(--border-strong); background: var(--bg-raise); color: var(--text);
  transition: border-color var(--t-quick), box-shadow var(--t-quick); min-width: 0;
  box-shadow: inset 0 1px 2px rgba(13,21,38,.03);
}
textarea.input { height: auto; padding: 9px 11px; resize: vertical; line-height: 1.5; }
.input:focus { outline: none; border-color: var(--brand-600); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-600) 20%, transparent); }
.input::placeholder { color: var(--text-3); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 20%, transparent); }
.input-search { padding-left: 32px; background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%235f6d89' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.4-3.4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 10px center; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: var(--fs-sm); font-weight: 650; color: var(--text-2); }
.field .hint { font-size: var(--fs-xs); color: var(--text-3); }
.field .err { font-size: var(--fs-xs); color: var(--danger); font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 18px; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }

.check { display: flex; align-items: center; gap: 9px; font-size: var(--fs-base); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand-600); }

/* Toggle switch */
.switch { position: relative; width: 36px; height: 21px; flex-shrink: 0; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; position: absolute; z-index: 1; }
.switch .track { position: absolute; inset: 0; border-radius: 99px; background: var(--border-strong); transition: background var(--dur); }
.switch .track::after {
  content: ""; position: absolute; top: 2.5px; left: 2.5px; width: 16px; height: 16px;
  border-radius: 99px; background: #fff; box-shadow: var(--shadow-1); transition: transform var(--dur) var(--ease);
}
.switch input:checked + .track { background: var(--brand-600); }
.switch input:checked + .track::after { transform: translateX(15px); }

/* ---------- 8. Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tab {
  padding: 9px 14px; font-weight: 600; font-size: var(--fs-base); color: var(--text-3);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; cursor: pointer;
  background: none; border-top: none; border-left: none; border-right: none; font-family: var(--font);
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--brand-600); border-bottom-color: var(--brand-600); }

/* Segmented control */
.seg { display: inline-flex; background: var(--bg-sunk); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 2.5px; gap: 2px; }
.seg button, .seg a {
  height: 26px; padding: 0 11px; display: inline-flex; align-items: center; border-radius: 6.5px; border: none;
  font: 600 var(--fs-sm) var(--font); color: var(--text-3); cursor: pointer; background: transparent; text-decoration: none !important;
}
.seg .active { background: var(--bg-raise); color: var(--text); box-shadow: var(--shadow-1); }

/* ---------- 9. Dropdown / context menu ---------- */
.menu {
  position: absolute; min-width: 190px; padding: 5px; z-index: 80;
  background: var(--bg-raise); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  animation: pop-in 130ms var(--ease);
}
.menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 10px;
  border: none; background: none; border-radius: 7px; text-align: left; cursor: pointer;
  font: 500 var(--fs-base) var(--font); color: var(--text-2); text-decoration: none !important;
}
.menu-item:hover { background: var(--bg-hover); color: var(--text); }
.menu-item.danger { color: var(--danger); }
.menu-item svg { width: 15px; height: 15px; opacity: .8; }
.menu-sep { height: 1px; background: var(--border); margin: 5px 6px; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

/* ---------- 10. Modal & slide-over ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 90; background: rgba(10,12,20,.45);
  backdrop-filter: blur(3px); animation: fade-in 160ms ease;
  display: flex; align-items: flex-start; justify-content: center;
}
@keyframes fade-in { from { opacity: 0; } }
.modal {
  margin-top: 9vh; width: min(560px, calc(100vw - 32px)); max-height: 80vh; overflow: auto;
  background: var(--bg-raise); border: 1px solid var(--border); border-radius: var(--r-xl);
  box-shadow: var(--shadow-pop); animation: modal-in 200ms var(--ease);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.modal-head { display:flex; align-items:center; gap:10px; padding: 18px 22px 0; }
.modal-body { padding: 14px 22px 8px; }
.modal-foot { padding: 14px 22px 20px; display: flex; justify-content: flex-end; gap: 9px; }

.slideover {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 95; width: min(480px, 94vw);
  background: var(--bg-raise); border-left: 1px solid var(--border); box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column; animation: slide-in 240ms var(--ease);
}
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } }
.slideover-head { display:flex; align-items:center; gap:10px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.slideover-body { flex: 1; overflow-y: auto; padding: 20px; }
.slideover-foot { border-top: 1px solid var(--border); padding: 14px 20px; display:flex; gap:9px; justify-content:flex-end; }

/* ---------- 11. Command palette ---------- */
.cmdk { margin-top: 12vh; width: min(640px, calc(100vw - 32px)); }
.cmdk .modal-search {
  display: flex; align-items: center; gap: 11px; padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.cmdk .modal-search input {
  flex: 1; border: none; background: none; outline: none; font: 500 var(--fs-md) var(--font); color: var(--text);
}
.cmdk-list { max-height: 46vh; overflow-y: auto; padding: 7px; }
.cmdk-group { padding: 9px 11px 3px; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.cmdk-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: var(--r-sm); cursor: pointer;
  color: var(--text-2);
}
.cmdk-item .ico { width: 28px; height: 28px; border-radius: 7px; display:grid; place-items:center; background: var(--bg-sunk); flex-shrink: 0; }
.cmdk-item .ico svg { width: 15px; height: 15px; }
.cmdk-item b { color: var(--text); font-weight: 600; }
.cmdk-item small { margin-left: auto; }
.cmdk-item.sel { background: var(--brand-50); }
.cmdk-foot { display: flex; gap: 14px; padding: 9px 16px; border-top: 1px solid var(--border); font-size: var(--fs-xs); color: var(--text-3); }

/* ---------- 12. Toasts ---------- */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 120; display: flex; flex-direction: column; gap: 9px; }
.toast {
  display: flex; align-items: flex-start; gap: 10px; width: 340px; padding: 13px 15px;
  background: var(--bg-raise); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-3); animation: toast-in 240ms var(--ease);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }
.toast.leaving { opacity: 0; transform: translateX(16px); transition: all 220ms ease; }
.toast .t-title { font-weight: 650; font-size: var(--fs-base); }
.toast .t-msg { font-size: var(--fs-sm); color: var(--text-2); margin-top: 1px; }
.toast .t-ico { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }
.toast .t-ico.ok { color: var(--ok); }
.toast .t-ico.err, .toast .t-ico.danger, .toast .t-ico.error { color: var(--danger); }
.toast .t-ico.warn, .toast .t-ico.warning { color: var(--warn); }
.toast .t-ico.info { color: var(--info); } .toast .t-ico.ai { color: var(--ai); }
/* Severity is carried by a left edge too — never colour alone */
.toast.k-err, .toast.k-danger, .toast.k-error { border-left: 3px solid var(--danger); }
.toast.k-warn, .toast.k-warning { border-left: 3px solid var(--warn); }
.toast.k-ok { border-left: 3px solid var(--ok); }
.toast.k-info { border-left: 3px solid var(--info); }
.toast.k-ai { border-left: 3px solid var(--ai); }

/* ---------- 13. Kanban ---------- */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 14px; align-items: flex-start; }
.kb-col { width: 288px; flex-shrink: 0; background: var(--bg-sunk); border: 1px solid var(--border); border-radius: var(--r-lg); }
.kb-col-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; font-weight: 650; font-size: var(--fs-base); }
.kb-col-head .count { font-size: 11px; font-weight: 700; color: var(--text-3); background: var(--bg-active); border-radius: 99px; padding: 0 7px; }
.kb-cards { padding: 0 10px 10px; display: flex; flex-direction: column; gap: 8px; min-height: 30px; }
.kb-card {
  background: var(--bg-raise); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 12px 13px; box-shadow: var(--shadow-1); cursor: grab;
  transition: box-shadow var(--dur), transform var(--dur);
}
.kb-card:hover { box-shadow: var(--shadow-2); transform: translateY(-1px); }
.kb-card.dragging { opacity: .5; }
.kb-card .kb-title { font-weight: 600; font-size: var(--fs-base); line-height: 1.35; }
.kb-card .kb-meta { display: flex; align-items: center; gap: 8px; margin-top: 9px; }
.kb-col.drop-hint { outline: 2px dashed var(--brand-400); outline-offset: -2px; }

/* ---------- 14. Timeline / activity ---------- */
.tl { position: relative; padding-left: 24px; }
.tl::before { content: ""; position: absolute; left: 7px; top: 4px; bottom: 4px; width: 2px; background: var(--border); border-radius: 2px; }
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item:last-child { padding-bottom: 2px; }
.tl-dot {
  position: absolute; left: -24px; top: 3px; width: 16px; height: 16px; border-radius: 99px;
  background: var(--bg-raise); border: 2px solid var(--brand-500); z-index: 1;
}
.tl-dot.ok { border-color: var(--ok); } .tl-dot.warn { border-color: var(--warn); }
.tl-dot.danger { border-color: var(--danger); } .tl-dot.ai { border-color: var(--ai); }
.tl-item .tl-head { font-size: var(--fs-base); }
.tl-item .tl-head b { font-weight: 650; }
.tl-item .tl-time { font-size: var(--fs-xs); color: var(--text-3); margin-top: 1px; }

/* ---------- 15. AI surfaces ---------- */
.ai-panel {
  border: 1px solid var(--ai-border); border-radius: var(--r-lg); overflow: hidden;
  background:
    radial-gradient(600px 200px at 0% 0%, color-mix(in srgb, var(--ai) 7%, transparent), transparent 60%),
    var(--bg-raise);
}
.ai-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px;
  border-radius: var(--r-full); font-size: var(--fs-xs); font-weight: 700;
  color: var(--ai); background: var(--ai-bg); border: 1px solid var(--ai-border);
}
.ai-chip svg { width: 12px; height: 12px; }

/* Floating assistant */
.ai-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 70; width: 52px; height: 52px;
  border-radius: var(--r-xl); border: none; cursor: pointer; display: grid; place-items: center; color: #fff;
  background: var(--aurora-135);
  box-shadow: 0 8px 28px rgba(91,124,250,.42); transition: transform var(--t-move) var(--ease), box-shadow var(--t-quick);
}
.ai-fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 12px 34px rgba(91,124,250,.52); }
.ai-fab svg { width: 24px; height: 24px; }

.ai-drawer {
  position: fixed; right: 22px; bottom: 86px; z-index: 96; width: min(400px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 130px)); display: flex; flex-direction: column;
  background: var(--bg-raise); border: 1px solid var(--border); border-radius: var(--r-xl);
  box-shadow: var(--shadow-pop); overflow: hidden; animation: modal-in 220ms var(--ease);
}
.ai-drawer-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px; color: #fff;
  background: linear-gradient(120deg, #1a8c80, #3d63e0 52%, #7a4fd6);
}
.ai-drawer-head .t { font-weight: 700; font-size: var(--fs-md); }
.ai-drawer-head .s { font-size: var(--fs-xs); opacity: .8; }
.ai-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.ai-msg { max-width: 88%; padding: 10px 13px; border-radius: 14px; font-size: var(--fs-base); line-height: 1.5; white-space: pre-wrap; }
.ai-msg.user { align-self: flex-end; background: var(--brand-600); color: var(--text-inv); border-bottom-right-radius: 5px; }
.ai-msg.bot { align-self: flex-start; background: var(--bg-sunk); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.ai-msg.bot table { border-collapse: collapse; margin: 6px 0; font-size: var(--fs-sm); }
.ai-msg.bot td, .ai-msg.bot th { border: 1px solid var(--border-strong); padding: 3px 8px; text-align: left; }
.ai-suggest { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 16px 10px; }
.ai-suggest button {
  border: 1px solid var(--ai-border); background: var(--ai-bg); color: var(--ai);
  font: 600 var(--fs-xs) var(--font); border-radius: 99px; padding: 5px 11px; cursor: pointer;
}
.ai-suggest button:hover { filter: brightness(.97); }
.ai-input { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border); }
.ai-input input { flex: 1; }
.ai-typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.ai-typing i { width: 6px; height: 6px; border-radius: 99px; background: var(--text-3); animation: blink 1.2s infinite; }
.ai-typing i:nth-child(2) { animation-delay: .18s; } .ai-typing i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%,70%,100% { opacity: .25; } 35% { opacity: 1; } }

/* ---------- 16. Charts (SVG helpers) ---------- */
.chart-svg { display: block; width: 100%; height: auto; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: var(--fs-sm); color: var(--text-2); }
.chart-legend .key { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .swatch { width: 10px; height: 10px; border-radius: 3px; }
.chart-tip {
  position: fixed; z-index: 130; pointer-events: none; padding: 7px 10px; border-radius: 8px;
  background: var(--text); color: var(--bg-raise); font-size: var(--fs-xs); font-weight: 600;
  box-shadow: var(--shadow-3); transform: translate(-50%, calc(-100% - 10px)); white-space: nowrap;
}
.bar-track { height: 7px; border-radius: 99px; background: var(--bg-active); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; background: var(--brand-500); }

/* Donut center label */
.donut-wrap { position: relative; display: grid; place-items: center; }
.donut-center { position: absolute; text-align: center; }
.donut-center .v { font-size: var(--fs-xl); font-weight: 700; }
.donut-center .l { font-size: var(--fs-xs); color: var(--text-3); }

/* ---------- 17. Misc components ---------- */
.empty {
  text-align: center; padding: 54px 24px; color: var(--text-3);
}
.empty .ico { width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 16px; display:grid; place-items:center; background: var(--bg-sunk); color: var(--text-3); }
.empty .ico svg { width: 24px; height: 24px; }
.empty h4 { color: var(--text); margin-bottom: 4px; }

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 9px 16px; font-size: var(--fs-base); }
.kv dt { color: var(--text-3); font-weight: 500; } .kv dd { margin: 0; font-weight: 550; }

.pagination { display: flex; align-items: center; gap: 6px; justify-content: flex-end; padding: 12px 16px; }
.pagination a, .pagination span.pg {
  min-width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0 8px; border-radius: 7px; font-weight: 600; font-size: var(--fs-sm); color: var(--text-2);
  text-decoration: none !important;
}
.pagination a:hover { background: var(--bg-hover); }
.pagination .current { background: var(--brand-600); color: var(--text-inv); }
.pagination .disabled { opacity: .4; }

.divider { height: 1px; background: var(--border); border: none; margin: 18px 0; }

.alert { display: flex; gap: 11px; padding: 13px 15px; border-radius: var(--r-md); border: 1px solid var(--border); font-size: var(--fs-base); align-items: flex-start; }
.alert svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }
.alert-ok { background: var(--ok-bg); border-color: var(--ok-border); }  .alert-ok svg { color: var(--ok); }
.alert-warn { background: var(--warn-bg); border-color: var(--warn-border); } .alert-warn svg { color: var(--warn); }
.alert-danger { background: var(--danger-bg); border-color: var(--danger-border); } .alert-danger svg { color: var(--danger); }
.alert-info { background: var(--info-bg); border-color: var(--info-border); } .alert-info svg { color: var(--info); }
.alert-ai { background: var(--ai-bg); border-color: var(--ai-border); } .alert-ai svg { color: var(--ai); }

/* Avatars stack */
.avstack { display: inline-flex; }
.avstack .avatar { border: 2px solid var(--bg-raise); margin-left: -8px; }
.avstack .avatar:first-child { margin-left: 0; }

/* Progress steps */
.steps { display: flex; gap: 0; }
.step { flex: 1; text-align: center; position: relative; padding-top: 26px; font-size: var(--fs-sm); color: var(--text-3); }
.step::before {
  content: ""; position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  width: 14px; height: 14px; border-radius: 99px; background: var(--bg-raise); border: 2px solid var(--border-strong); z-index: 1;
}
.step::after { content: ""; position: absolute; top: 14px; left: calc(-50% + 8px); right: calc(50% + 8px); height: 2px; background: var(--border); }
.step:first-child::after { display: none; }
.step.done { color: var(--text-2); } .step.done::before { background: var(--brand-600); border-color: var(--brand-600); }
.step.done::after { background: var(--brand-600); }
.step.now { color: var(--brand-600); font-weight: 650; } .step.now::before { border-color: var(--brand-600); }

/* Inline edit */
.inline-edit { border-bottom: 1px dashed transparent; cursor: text; border-radius: 3px; }
.inline-edit:hover { border-bottom-color: var(--border-strong); background: var(--bg-hover); }
.inline-edit:focus { outline: none; background: var(--bg-hover); border-bottom-color: var(--brand-500); }

/* Auth pages */
.auth-wrap {
  min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
@media (max-width: 900px) { .auth-wrap { grid-template-columns: 1fr; } .auth-hero { display: none; } }
/* Ink ground with a slow aurora field — the brand's one theatrical moment */
.auth-hero {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between;
  padding: 44px 48px; color: #fff;
  background:
    radial-gradient(760px 520px at 82% -8%, rgba(122,90,248,.34), transparent 62%),
    radial-gradient(680px 580px at -8% 108%, rgba(43,197,180,.26), transparent 58%),
    linear-gradient(165deg, #0b1017, #14213b 46%, #101a33);
}
/* Static field, not an animated one: a perpetual loop here would repaint
   forever for zero information. Ambient motion is reserved for loading. */
.auth-hero::after {
  content: ""; position: absolute; inset: -30% -10% auto -10%; height: 70%;
  background: radial-gradient(closest-side, rgba(91,124,250,.20), transparent);
  pointer-events: none;
}
.auth-hero > * { position: relative; z-index: 1; }
.auth-hero .quote { font-family: var(--font-display); font-size: var(--fs-2xl); font-weight: 700; line-height: 1.25; max-width: 480px; letter-spacing: -.02em; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--bg); }
.auth-card { width: min(400px, 100%); }

/* Calendar grid */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); border-left: 1px solid var(--border); border-top: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
.cal .cal-dow { background: var(--bg-sunk); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 8px 10px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.cal .cal-day { min-height: 104px; padding: 7px 9px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--bg-raise); font-size: var(--fs-sm); }
.cal .cal-day.dim { background: var(--bg-sunk); color: var(--text-3); }
.cal .cal-day .d { font-weight: 650; margin-bottom: 5px; }
.cal .cal-day.today .d { display: inline-grid; place-items: center; width: 22px; height: 22px; background: var(--brand-600); color: var(--text-inv); border-radius: 99px; }
.cal-ev { display: block; padding: 2px 7px; border-radius: 5px; margin-bottom: 3px; font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--brand-700); background: var(--brand-100); border-left: 3px solid var(--brand-500); text-decoration: none !important; }
.cal-ev.ev-teal { color: var(--accent-strong); background: rgba(20,184,166,.13); border-left-color: var(--accent); }
.cal-ev.ev-amber { color: var(--warn); background: var(--warn-bg); border-left-color: var(--warn); }
.cal-ev.ev-rose { color: var(--danger); background: var(--danger-bg); border-left-color: var(--danger); }

/* Workflow canvas */
.wf-canvas {
  position: relative; min-height: 520px; border-radius: var(--r-lg); overflow: hidden;
  background:
    radial-gradient(circle, var(--border-strong) 1px, transparent 1.5px);
  background-size: 22px 22px; background-color: var(--bg-sunk);
  border: 1px solid var(--border);
}
.wf-node {
  position: absolute; width: 230px; background: var(--bg-raise); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); box-shadow: var(--shadow-2); cursor: grab; user-select: none;
}
.wf-node.dragging { cursor: grabbing; box-shadow: var(--shadow-3); z-index: 5; }
.wf-node-head { display: flex; align-items: center; gap: 8px; padding: 9px 12px; font-weight: 650; font-size: var(--fs-sm); border-bottom: 1px solid var(--border); }
.wf-node-head .wf-ico { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; color: #fff; flex-shrink: 0; }
.wf-node-head .wf-ico svg { width: 12px; height: 12px; }
.wf-node-body { padding: 8px 12px; font-size: var(--fs-xs); color: var(--text-3); }
.wf-node.trigger .wf-ico { background: var(--brand-600); }
.wf-node.action  .wf-ico { background: var(--accent-strong); }
.wf-node.cond    .wf-ico { background: #d97706; }
.wf-node.notify  .wf-ico { background: #db2777; }
.wf-node.selected { border-color: var(--brand-500); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-500) 22%, transparent); }
.wf-edge { stroke: var(--border-strong); stroke-width: 2; fill: none; }
.wf-edge-arrow { fill: var(--border-strong); }

/* Skeletons — see §18 for the full loading system */
@keyframes shimmer { to { background-position: -200% 0; } }

/* Print — a board pack is printed for real, so it gets a real layout */
@media print {
  @page { margin: 14mm 12mm; }

  /* Chrome and anything interactive has no meaning on paper */
  .sidebar, .topbar, .ai-fab, .toolbar, .page-head .actions, .nav-scrim,
  .peek, .overlay, .menu, .toasts, .skip-link, .chart-tools, .stat-explain,
  .settings-nav, .views-btn, .kb-more, .wf-tools, .wf-minimap, .wf-hint,
  .no-print { display: none !important; }

  html, body { background: #fff; color: #000; }
  .content { padding: 0; max-width: none; }
  .app { display: block; }

  /* Flat, ink-cheap surfaces */
  .card, .position-strip, .brief, .ai-panel {
    box-shadow: none !important; border: 1px solid #ccc !important;
    background: #fff !important; break-inside: avoid;
  }
  .card-head { border-bottom: 1px solid #ccc; }

  /* Never split a figure or a row across a page break */
  .stat, .health-cell, .needs-item, .position-cell,
  [data-chart], .donut-wrap, table tr { break-inside: avoid; }
  h1, h2, h3, h4 { break-after: avoid; }

  /* Charts are vector: let them print at full fidelity, and keep table
     fallbacks visible so the numbers survive a black-and-white printer. */
  .chart-svg { max-width: 100% !important; }
  .chart-table { display: block !important; max-height: none !important; overflow: visible !important; }
  .chart-table[hidden] { display: block !important; }

  /* Tables print with visible rules and repeated headers on every page */
  table.dt { border-collapse: collapse; width: 100%; }
  table.dt thead { display: table-header-group; }
  table.dt th, table.dt td { border-bottom: 1px solid #ddd; padding: 6px 8px; }
  .table-wrap { overflow: visible !important; }

  /* Each major report block starts a fresh page in the pack */
  .page-break, #monthly-report { break-before: page; }
  #monthly-report:first-child { break-before: auto; }

  /* Links are useless on paper unless the address is written out */
  main a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 9pt; color: #555; word-break: break-all; }
  main a[href^="#"]::after, .badge a::after { content: ""; }
}

/* Responsive shell */
@media (max-width: 960px) {
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); transition: transform var(--dur) var(--ease); box-shadow: var(--shadow-pop); }
  .app.nav-open .sidebar { transform: none; }
  .app.rail .sidebar { width: var(--sidebar-w); }
  .app.rail .logo-word, .app.rail .nav-group-label, .app.rail .nav-item span, .app.rail .nav-badge { display: initial; }
  .app.rail .nav-item { justify-content: flex-start; padding: 6.5px 10px; }
  .search-pill { min-width: 0; }
  .search-pill .hint-txt { display: none; }
  .content { padding: 18px 14px 80px; }
}

/* ============================================================
   18. Aurora 2.0 — accessibility, states, and new primitives
   ============================================================ */

/* ---- Skip link (keyboard entry point) ---- */
.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 200;
  background: var(--bg-raise); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); padding: 9px 14px; font-weight: 650; font-size: var(--fs-base);
  box-shadow: var(--shadow-3); transition: top var(--t-quick) var(--ease-out);
}
.skip-link:focus { top: 8px; text-decoration: none; }

/* ---- Dropdown menus: real menu semantics ---- */
.menu [role="menuitem"]:focus-visible,
.menu-item:focus-visible { outline: none; background: var(--bg-hover); color: var(--text); box-shadow: inset 0 0 0 2px var(--brand-600); }
.menu-item[aria-disabled="true"] { opacity: .45; pointer-events: none; }

/* ---- Mobile navigation scrim ---- */
.nav-scrim {
  position: fixed; inset: 0; z-index: 35; background: rgba(10,14,24,.42);
  backdrop-filter: blur(2px); animation: fade-in var(--t-move) ease; border: 0; padding: 0; cursor: pointer;
}
@media (min-width: 961px) { .nav-scrim { display: none; } }

/* ---- Skeleton loading system ---- */
.skel { border-radius: var(--r-sm); background: linear-gradient(90deg, var(--bg-sunk) 25%, var(--bg-active) 45%, var(--bg-sunk) 65%); background-size: 200% 100%; animation: shimmer var(--t-ambient) infinite; }
.skel-text { height: 11px; margin: 7px 0; }
.skel-text.w40 { width: 40%; } .skel-text.w60 { width: 60%; } .skel-text.w80 { width: 80%; }
.skel-title { height: 20px; width: 45%; margin-bottom: 12px; border-radius: 5px; }
.skel-value { height: 26px; width: 58%; margin: 8px 0 6px; border-radius: 5px; }
.skel-chart { height: 200px; width: 100%; border-radius: var(--r-md); }
.skel-avatar { width: 30px; height: 30px; border-radius: var(--r-full); flex-shrink: 0; }
.skel-row { height: 40px; width: 100%; margin-bottom: 6px; }
.skel-card { padding: 18px 20px; }
/* Region that is loading: dim + block input, announce via aria-busy in markup */
[data-loading="true"] { position: relative; }
[data-loading="true"] > *:not(.skel-overlay) { opacity: .35; pointer-events: none; transition: opacity var(--t-quick); }
.skel-overlay { position: absolute; inset: 0; display: grid; place-items: center; }

/* Charts are rendered client-side from data attributes — hold their shape
   until the script fills them, so nothing pops in against a blank panel. */
[data-chart]:empty { display: block; min-height: 220px; border-radius: var(--r-md);
  background: linear-gradient(90deg, var(--bg-sunk) 25%, var(--bg-active) 45%, var(--bg-sunk) 65%);
  background-size: 200% 100%; animation: shimmer var(--t-ambient) infinite; }
[data-spark]:empty { display: inline-block; width: 84px; height: 30px; border-radius: 5px;
  background: var(--bg-sunk); }

/* ---- Notification center ---- */
.notif-center { width: 344px; max-height: 460px; display: flex; flex-direction: column; }
.notif-head { display: flex; align-items: center; gap: 8px; padding: 9px 11px; border-bottom: 1px solid var(--border); }
.notif-head b { font-size: var(--fs-base); }
.notif-list { overflow-y: auto; padding: 4px; }
.notif-bucket {
  padding: 9px 9px 4px; font-family: var(--mono); font-size: 10px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-3);
}
.notif-item { align-items: flex-start; }
.notif-item .notif-dot {
  margin-top: 6px; width: 7px; height: 7px; border-radius: 99px; flex-shrink: 0;
  background: var(--border-strong);
}
.notif-item.unread .notif-dot { background: var(--brand-600); }
.notif-item.unread { background: var(--brand-50); }

/* ---- Live filtering: the region stays put and says it's working ---- */
.is-filtering { position: relative; }
.is-filtering::after {
  content: ""; position: absolute; inset: 0; background: var(--bg);
  opacity: .5; border-radius: var(--r-lg); pointer-events: none;
}
.filter-bar-busy { opacity: .6; transition: opacity var(--t-quick); }
.toolbar .filter-status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-sm); color: var(--text-3);
}

/* ============================================================
   19. Phase 3 — record peek, table controls, chart affordances
   ============================================================ */

/* ---- Peek panel: inspect a record without losing the list ---- */
.peek {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 85;
  width: min(560px, 94vw); display: flex; flex-direction: column;
  background: var(--bg-raise); border-left: 1px solid var(--border);
  box-shadow: var(--shadow-pop); animation: peek-in var(--t-move) var(--ease);
}
@keyframes peek-in { from { transform: translateX(28px); opacity: 0; } }
.peek-head {
  display: flex; align-items: center; gap: 8px; padding: 13px 14px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.peek-title {
  font-family: var(--font-display); font-weight: 700; font-size: var(--fs-md);
  letter-spacing: -.01em; min-width: 0; flex: 1;
}
.peek-pos { font-family: var(--mono); font-size: var(--fs-xs); color: var(--text-3); white-space: nowrap; }
.peek-body { flex: 1; overflow-y: auto; padding: 16px 18px 28px; }
.peek-body .page-head { display: none; }           /* the panel header already names the record */
.peek-body .grid-4, .peek-body .grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.peek-body .grid-2, .peek-body .dashboard-primary,
.peek-body .dashboard-double, .peek-body .dashboard-triple { grid-template-columns: minmax(0,1fr); }
.peek-body .card { box-shadow: none; }
/* The row being previewed keeps its place in the list */
.dt tbody tr.peeking { background: var(--brand-50); box-shadow: inset 3px 0 0 var(--brand-600); }
@media (max-width: 720px) { .peek { width: 100vw; } }

/* ---- Row density ---- */
[data-density="compact"] .dt tbody td { padding: 6px 16px; }
[data-density="compact"] .dt thead th { padding: 7px 16px; }
[data-density="compact"] .avatar { width: 24px; height: 24px; font-size: 9.5px; }

/* ---- Sortable column headers ---- */
.dt thead th.sortable { padding: 0; }
.dt thead th.sortable > a {
  display: flex; align-items: center; gap: 5px; width: 100%; padding: 10px 16px;
  color: inherit; font: inherit; text-decoration: none !important; white-space: nowrap;
}
.dt thead th.sortable > a:hover { color: var(--text); background: var(--bg-hover); }
.dt thead th.sortable .sort-ind { opacity: 0; transition: opacity var(--t-quick); flex-shrink: 0; }
.dt thead th.sortable > a:hover .sort-ind { opacity: .5; }
.dt thead th.sortable.on { color: var(--brand-600); }
.dt thead th.sortable.on .sort-ind { opacity: 1; }

/* ---- Saved views ---- */
.views-btn { display: inline-flex; align-items: center; gap: 6px; }
.view-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px;
  border-radius: var(--r-full); font-size: var(--fs-sm); font-weight: 600;
  background: var(--brand-50); color: var(--brand-700); border: 1px solid var(--brand-200);
}
.view-chip button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0; display: grid; place-items: center; opacity: .7; }
.view-chip button:hover { opacity: 1; }

/* ---- Charts: keyboard + touch affordances ---- */
.chart-svg .pt:focus-visible, .chart-svg .bar:focus-visible, .chart-svg .seg:focus-visible {
  outline: 2px solid var(--brand-600); outline-offset: 1px;
}
.chart-tools { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.chart-tools .btn { height: 26px; padding: 0 9px; font-size: var(--fs-xs); }
.chart-table { margin-top: 10px; max-height: 260px; overflow: auto; border: 1px solid var(--border); border-radius: var(--r-sm); }
.chart-table table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.chart-table th, .chart-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.chart-table th { background: var(--bg-sunk); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.chart-table td.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: var(--fs-xs); }

/* ============================================================
   20. Phase 4 — command center + AI fabric
   ============================================================ */

.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;
}

/* ---- Daily brief ---- */
.brief {
  background: var(--bg-raise); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1); overflow: hidden;
}
.brief-head { display: flex; align-items: center; gap: 10px; padding: 12px 18px 0; }
.brief-list { list-style: none; margin: 0; padding: 10px 18px 16px; display: grid; gap: 8px; }
.brief-list li { position: relative; padding-left: 18px; font-size: var(--fs-md); line-height: 1.55; }
.brief-list li::before {
  content: ""; position: absolute; left: 0; top: .55em; width: 8px; height: 8px;
  border-radius: 99px; background: var(--text-3);
}
.brief-list li.tone-ok::before { background: var(--ok); }
.brief-list li.tone-warn::before { background: var(--warn); }
.brief-list li.tone-danger::before { background: var(--danger); }
.brief-list a { color: var(--text); text-decoration: none; border-bottom: 1px solid var(--border-strong); }
.brief-list a:hover { color: var(--brand-600); border-bottom-color: var(--brand-600); text-decoration: none; }
.brief-divider { height: 1px; background: var(--border); margin: 4px 0 2px; }

/* ---- Explain-this-number ---- */
.stat { position: relative; }
.stat-explain {
  position: absolute; top: 10px; right: 10px;
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 8px; border-radius: var(--r-full);
  border: 1px solid var(--ai-border); background: var(--ai-bg); color: var(--ai);
  font: 600 var(--fs-xs) var(--font); cursor: pointer;
  opacity: 0; transition: opacity var(--t-quick);
}
.stat:hover .stat-explain, .stat-explain:focus-visible { opacity: 1; }
.stat-explain:hover { filter: brightness(.97); }

/* ---- Needs you ---- */
.needs-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--bg-raise); transition: border-color var(--t-quick);
}
.needs-item:hover { border-color: var(--border-strong); }
.needs-item .btn { margin-left: auto; flex-shrink: 0; }

/* ---- Business health ---- */
.health-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.health-cell {
  display: grid; gap: 3px; padding: 16px 18px; text-decoration: none !important;
  border-right: 1px solid var(--border); border-top: 1px solid var(--border);
  color: inherit; position: relative; transition: background var(--t-quick);
}
.health-cell:last-child { border-right: 0; }
.health-cell:hover { background: var(--bg-hover); }
.health-state {
  width: 100%; height: 3px; border-radius: 2px; margin-bottom: 7px; display: block;
}
.state-ok .health-state { background: var(--ok); }
.state-watch .health-state { background: var(--warn); }
.state-risk .health-state { background: var(--danger); }
.health-label { font-size: var(--fs-sm); color: var(--text-3); font-weight: 600; }
.health-value { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-lg); letter-spacing: -.01em; }
.state-risk .health-value { color: var(--danger); }
.health-note { font-size: var(--fs-xs); color: var(--text-3); line-height: 1.45; }

/* ---- AI drawer v2: citations, history, actions ---- */
.ai-sources {
  margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border-strong);
  display: grid; gap: 3px;
}
.ai-sources .src-head {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-3);
}
.ai-sources li { font-size: var(--fs-xs); color: var(--text-3); line-height: 1.45; }
.ai-sources ul { margin: 0; padding-left: 15px; }
/* Answer still arriving. The caret is the only signal that text is landing
   incrementally rather than having stalled mid-sentence. */
.ai-streaming > div::after {
  content: ""; display: inline-block; vertical-align: -1px;
  width: 2px; height: 1em; margin-left: 2px;
  background: var(--ai); animation: ai-caret 1.05s steps(2) infinite;
}
@keyframes ai-caret { 0%, 49% { opacity: 1 } 50%, 100% { opacity: 0 } }
@media (prefers-reduced-motion: reduce) {
  .ai-streaming > div::after { animation: none; opacity: .85; }
}

/* Provenance tag: marks an answer whose prose came from the language model
   rather than the analytics engine. Quiet by design — it is a disclosure, not
   a badge of honour. */
.ai-engine {
  margin-top: 7px; display: inline-flex; align-items: center; gap: 5px;
  font: 600 10px var(--font); letter-spacing: .01em;
  color: var(--ai); background: var(--ai-bg);
  border: 1px solid var(--ai-border); border-radius: var(--r-full);
  padding: 2px 9px;
}
.ai-engine::before {
  content: ""; width: 5px; height: 5px; border-radius: 99px;
  background: var(--ai); flex-shrink: 0;
}
.ai-msg-tools { display: flex; gap: 6px; margin-top: 7px; }
.ai-msg-tools button {
  border: 1px solid var(--border); background: var(--bg-raise); color: var(--text-3);
  border-radius: var(--r-full); font: 600 10.5px var(--font); padding: 2px 9px; cursor: pointer;
}
.ai-msg-tools button:hover { color: var(--text); border-color: var(--border-strong); }
.ai-drawer-head .ai-clear {
  border: 0; background: rgba(255,255,255,.16); color: #fff; border-radius: var(--r-full);
  font: 600 10.5px var(--font); padding: 3px 9px; cursor: pointer;
}
.ai-drawer-head .ai-clear:hover { background: rgba(255,255,255,.26); }

@media (max-width: 720px) {
  .brief-list li { font-size: var(--fs-base); }
  .health-cell { border-right: 0; }
}

/* ============================================================
   21. Phase 5 — deep modules
   ============================================================ */

/* ---- Workflow canvas v2: zoom, pan, minimap, keyboard ---- */
.wf-stage {
  position: relative; overflow: hidden; border-radius: var(--r-lg);
  border: 1px solid var(--border); background-color: var(--bg-sunk);
  background-image: radial-gradient(circle, var(--border-strong) 1px, transparent 1.5px);
  background-size: 22px 22px; touch-action: none;
}
.wf-stage .wf-canvas {
  position: absolute; top: 0; left: 0; transform-origin: 0 0;
  border: 0; border-radius: 0; background: none; min-height: 0;
}
.wf-node { touch-action: none; }
.wf-node:focus-visible {
  outline: none; border-color: var(--brand-600);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-600) 26%, transparent);
}
.wf-node.kb-active {
  border-color: var(--brand-600);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-600) 26%, transparent), var(--shadow-3);
}

.wf-tools {
  position: absolute; right: 12px; bottom: 12px; z-index: 4;
  display: flex; align-items: center; gap: 4px; padding: 4px;
  background: var(--bg-raise); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--shadow-2);
}
.wf-tools button {
  width: 28px; height: 28px; display: grid; place-items: center; padding: 0;
  border: 0; border-radius: var(--r-sm); background: none; color: var(--text-2); cursor: pointer;
}
.wf-tools button:hover { background: var(--bg-hover); color: var(--text); }
.wf-tools .wf-zoom-label {
  min-width: 44px; text-align: center; font-family: var(--mono);
  font-size: var(--fs-xs); color: var(--text-3); font-variant-numeric: tabular-nums;
}

.wf-minimap {
  position: absolute; left: 12px; bottom: 12px; z-index: 4;
  width: 160px; height: 104px; overflow: hidden;
  background: var(--bg-raise); border: 1px solid var(--border);
  border-radius: var(--r-sm); box-shadow: var(--shadow-2); cursor: pointer;
}
.wf-minimap i { position: absolute; background: var(--brand-500); border-radius: 2px; opacity: .55; }
.wf-minimap i.trigger { background: var(--brand-600); }
.wf-minimap i.action { background: var(--accent-strong); }
.wf-minimap i.cond { background: var(--warn); }
.wf-minimap i.notify { background: var(--ch-6); }
.wf-minimap .wf-viewbox {
  position: absolute; border: 1.5px solid var(--brand-600); border-radius: 2px;
  background: color-mix(in srgb, var(--brand-600) 10%, transparent); pointer-events: none;
}
.wf-hint {
  position: absolute; left: 12px; top: 12px; z-index: 4;
  font-size: var(--fs-xs); color: var(--text-3); background: var(--bg-raise);
  border: 1px solid var(--border); border-radius: var(--r-full); padding: 3px 10px;
}
@media (max-width: 720px) { .wf-minimap { display: none; } }

/* ---- Kanban v2: WIP limits, keyboard move, capped rendering ---- */
.kb-col-head .wip {
  font-family: var(--mono); font-size: 10px; color: var(--text-3);
  border: 1px solid var(--border); border-radius: var(--r-full); padding: 0 6px;
}
.kb-col.over-wip { outline: 2px solid var(--warn); outline-offset: -2px; }
.kb-col.over-wip .wip { color: var(--warn); border-color: var(--warn-border); background: var(--warn-bg); }
.kb-card:focus-visible {
  outline: none; border-color: var(--brand-600);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-600) 26%, transparent);
}
.kb-card.kb-picked {
  border-color: var(--brand-600); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-600) 26%, transparent), var(--shadow-2);
}
.kb-col.kb-target { outline: 2px dashed var(--brand-500); outline-offset: -2px; }
.kb-more {
  width: 100%; border: 1px dashed var(--border-strong); background: none; color: var(--text-2);
  border-radius: var(--r-sm); padding: 7px; font: 600 var(--fs-sm) var(--font); cursor: pointer;
}
.kb-more:hover { background: var(--bg-hover); color: var(--text); }
.kb-live {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0);
}

/* ---- Documents: real upload progress + scan status ---- */
.up-progress { display: grid; gap: 6px; margin-top: 10px; }
.up-progress .bar-track { height: 6px; }
.up-progress .up-meta { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--text-3); }
.scan-badge { display: inline-flex; align-items: center; gap: 5px; }

/* ---- Finance: answer-first position strip ---- */
.position-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0; border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--bg-raise); box-shadow: var(--shadow-1); overflow: hidden; margin-bottom: 16px;
}
.position-lead {
  grid-column: 1 / -1; padding: 16px 20px 14px; border-bottom: 1px solid var(--border);
  font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 700;
  letter-spacing: -.01em; line-height: 1.35;
}
.position-lead .qualifier { display: block; font: 400 var(--fs-sm)/1.5 var(--font); color: var(--text-3); margin-top: 5px; letter-spacing: 0; }
.position-cell { padding: 13px 20px; border-right: 1px solid var(--border); display: grid; gap: 2px; }
.position-cell:last-child { border-right: 0; }
.position-cell .k { font-size: var(--fs-xs); color: var(--text-3); font-weight: 600; }
.position-cell .v { font-family: var(--mono); font-size: var(--fs-md); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ============================================================
   22. Phase 6 — craft pass: motion, illustration, container queries
   ============================================================ */

/* ---- Motion choreography (§11) -------------------------------------------
   Every animation maps to a state change: open, move, confirm, load. Exits run
   at ~70% of entry duration so dismissing never feels slower than opening. */
.overlay { animation: fade-in var(--t-move) var(--ease-out); }
.modal { animation: surface-in var(--t-move) var(--ease-out); }
.slideover, .peek { animation: slide-in var(--t-move) var(--ease-out); }
.menu { animation: surface-in var(--t-quick) var(--ease-out); }
.toast { animation: toast-in var(--t-move) var(--ease-out); }

@keyframes surface-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes slide-in   { from { opacity: 0; transform: translateX(12px); } }
@keyframes toast-in   { from { opacity: 0; transform: translateY(8px); } }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity 154ms var(--ease), transform 154ms var(--ease); }

/* Lists reveal in sequence — 20ms apart, capped at 8 so long tables never crawl */
.stagger > * { animation: surface-in var(--t-move) var(--ease-out) backwards; }
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 20ms; }
.stagger > *:nth-child(3) { animation-delay: 40ms; }
.stagger > *:nth-child(4) { animation-delay: 60ms; }
.stagger > *:nth-child(5) { animation-delay: 80ms; }
.stagger > *:nth-child(6) { animation-delay: 100ms; }
.stagger > *:nth-child(7) { animation-delay: 120ms; }
.stagger > *:nth-child(n+8) { animation-delay: 140ms; }

/* Charts fade in as they render. Deliberately NOT animating stroke-dasharray:
   a CSS dasharray would override the presentation attribute and flatten the
   dashed forecast series into a solid line. */
.chart-svg path[stroke] { animation: draw-in var(--t-reveal) var(--ease-out) backwards; }
@keyframes draw-in { from { opacity: 0; } }

/* Success lives where the click happened, not in a corner */
.btn.is-done { background: var(--ok); color: #fff; border-color: transparent; }
.btn.is-done::before {
  content: ""; width: 14px; height: 14px; flex-shrink: 0;
  background: currentColor;
  clip-path: polygon(14% 46%, 0 60%, 40% 100%, 100% 22%, 86% 8%, 40% 72%);
  animation: check-draw var(--t-reveal) var(--ease-out);
}
@keyframes check-draw { from { transform: scale(.4); opacity: 0; } }

/* Hover feedback is instant; movement is not */
.card, .needs-item, .health-cell { transition: box-shadow var(--t-quick) var(--ease), border-color var(--t-quick) var(--ease); }

/* ---- Illustrations ---- */
.illus { display: block; margin: 0 auto 14px; color: var(--text-3); }
.empty .illus { opacity: .95; }
.empty h4 { color: var(--text); margin-bottom: 4px; }
.empty p { max-width: 42ch; margin-left: auto; margin-right: auto; }

/* ---- Container queries: widgets adapt to their slot, not the viewport ----
   A KPI card in a narrow column should render compactly even on a wide screen,
   which viewport media queries can never express. */
.card, .stat, .position-strip, .brief { container-type: inline-size; }

@container (max-width: 260px) {
  .stat .value { font-size: var(--fs-xl); }
  .stat .spark { display: none; }
  .stat-explain { position: static; opacity: 1; margin-top: 8px; justify-self: start; }
}
@container (max-width: 200px) {
  .stat .delta { font-size: var(--fs-xs); }
  .stat { padding: 14px 15px; }
}

/* ---- Settings: two-pane with a persistent sub-navigation ---- */
.settings-shell {
  display: grid; grid-template-columns: 248px minmax(0, 1fr); gap: 24px; align-items: start;
}
.settings-nav { position: sticky; top: 16px; display: grid; gap: 2px; }
.settings-nav-label {
  padding: 14px 10px 5px; font-family: var(--mono); font-size: 10px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--text-3);
}
.settings-nav-label:first-child { padding-top: 0; }
.settings-nav-item {
  display: flex; align-items: flex-start; gap: 10px; padding: 9px 11px;
  border-radius: var(--r-sm); color: var(--text-2); text-decoration: none !important;
  border: 1px solid transparent; transition: background var(--t-quick), color var(--t-quick);
}
.settings-nav-item svg { margin-top: 1px; flex-shrink: 0; opacity: .8; }
.settings-nav-item:hover { background: var(--bg-hover); color: var(--text); }
.settings-nav-item.active { background: var(--brand-50); border-color: var(--brand-200); color: var(--brand-700); }
.settings-nav-item.active svg { opacity: 1; }
.settings-nav-item .sn-label { display: block; font-size: var(--fs-base); font-weight: 600; }
.settings-nav-item .sn-hint { display: block; font-size: var(--fs-xs); color: var(--text-3); line-height: 1.4; margin-top: 1px; }
.settings-nav-item.active .sn-hint { color: color-mix(in srgb, var(--brand-700) 65%, var(--text-3)); }
.settings-pane { min-width: 0; }
@media (max-width: 900px) {
  .settings-shell { grid-template-columns: 1fr; gap: 16px; }
  .settings-nav { position: static; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
  .settings-nav-label { grid-column: 1 / -1; }
  .settings-nav-item .sn-hint { display: none; }
}

/* ---- Permission matrix ---- */
.perm-matrix .perm-domain th {
  background: var(--bg-sunk); padding: 9px 16px; text-align: left;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-3); font-weight: 700; position: static;
}
.perm-matrix .perm-domain th { display: flex; align-items: center; gap: 10px; }
.perm-matrix .perm-domain .btn { margin-left: auto; }
.perm-matrix td.tc, .perm-matrix th.tc { text-align: center; }
.perm-matrix input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--brand-600); }
.perm-matrix tbody tr:not(.perm-domain):hover { background: var(--bg-hover); }

/* ---- Password field: reveal toggle + strength meter ---- */
.pw-wrap { position: relative; display: flex; }
.pw-wrap .input { flex: 1; padding-right: 40px; }
.pw-toggle {
  position: absolute; right: 3px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 30px; display: grid; place-items: center; border: 0; background: none;
  color: var(--text-3); cursor: pointer; border-radius: 5px;
}
.pw-toggle:hover { color: var(--text); background: var(--bg-hover); }
.pw-toggle svg { width: 16px; height: 16px; }
.pw-meter { display: flex; gap: 4px; margin-top: 7px; }
.pw-meter i { flex: 1; height: 4px; border-radius: 99px; background: var(--bg-active); transition: background var(--t-quick); }
.pw-meter.s1 i:nth-child(-n+1) { background: var(--danger); }
.pw-meter.s2 i:nth-child(-n+2) { background: var(--warn); }
.pw-meter.s3 i:nth-child(-n+3) { background: var(--info); }
.pw-meter.s4 i { background: var(--ok); }
.pw-note { font-size: var(--fs-xs); color: var(--text-3); margin-top: 5px; }
.caps-warn { display: none; align-items: center; gap: 6px; margin-top: 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--warn); }
.caps-warn.on { display: flex; }

/* ---- Segmented one-time-code input (MFA) ---- */
.otp { display: flex; gap: 8px; }
.otp input {
  width: 46px; height: 54px; text-align: center; font-family: var(--mono);
  font-size: 21px; font-weight: 600; color: var(--text); background: var(--bg-raise);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  transition: border-color var(--t-quick), box-shadow var(--t-quick);
}
.otp input:focus { outline: none; border-color: var(--brand-600); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-600) 20%, transparent); }
.otp input.filled { border-color: var(--brand-500); }
@media (max-width: 420px) { .otp { gap: 5px; } .otp input { width: 100%; height: 48px; font-size: 18px; } }

/* ---- MFA QR frame ---- */
.qr-frame {
  display: inline-grid; place-items: center; padding: 12px; background: #fff;
  border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-1);
}
.qr-frame svg { display: block; width: 168px; height: 168px; }
.setup-split { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 20px; align-items: start; }
@media (max-width: 560px) { .setup-split { grid-template-columns: 1fr; justify-items: center; text-align: center; } }

/* ---- Recovery codes ---- */
.codes { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; font-family: var(--mono); font-size: var(--fs-base); }
.codes span { padding: 8px 10px; background: var(--bg-sunk); border: 1px solid var(--border); border-radius: var(--r-sm); text-align: center; letter-spacing: .04em; }

/* ---- AI surfaces: the aurora signature ---- */
.aurora-edge { border-top: 3px solid transparent; border-image: var(--aurora) 1; }
.ai-chip.aurora { color: #fff; background: var(--aurora); border-color: transparent; }

/* ---- Motion: state changes only, and always defeatable ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
  .skel { animation: none; background: var(--bg-sunk); }
  .auth-hero::after { animation: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .topbar { backdrop-filter: none; background: var(--bg); }
  .overlay { backdrop-filter: none; }
}

/* Utility */
.flex { display: flex; } .aic { align-items: center; } .g2 { gap: 8px; } .g3 { gap: 12px; } .g4 { gap: 16px; }
.jcb { justify-content: space-between; }
.mt2 { margin-top: 8px; } .mt3 { margin-top: 12px; } .mt4 { margin-top: 16px; } .mt6 { margin-top: 24px; }
.mb2 { margin-bottom: 8px; } .mb3 { margin-bottom: 12px; } .mb4 { margin-bottom: 16px; }
.w100 { width: 100%; }
.fs-sm { font-size: var(--fs-sm); } .fs-xs { font-size: var(--fs-xs); }
.fw6 { font-weight: 600; } .fw7 { font-weight: 700; }
.tr { text-align: right; } .tc { text-align: center; }
.nowrap { white-space: nowrap; }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
