/* ============================================================
   AICorros Product App — Design System (DARK)
   Palette: near-black #0f0f11 · soft blue accent #7fb0e8
   Desktop-first, data-dense, visually calm. Depth via borders
   and surface steps, not shadows.
   ============================================================ */

:root {
  color-scheme: dark;

  /* Brand — soft blue accent on dark; deep blue only for rare fills */
  --brand: #7fb0e8;
  --brand-strong: #a3c6f0;
  --brand-deep: #0d4a7a;
  --brand-tint: rgba(127, 176, 232, 0.14);
  --brand-tint-2: rgba(127, 176, 232, 0.22);

  --sage: #8b8b85;
  --sage-deep: #a8a8a4;
  --sage-tint: rgba(255, 255, 255, 0.06);

  /* Surfaces: page #0f0f11 · raised #17171a · higher/hover #1d1d21 · sunken #0b0b0d */
  --canvas: #0f0f11;
  --cream: #141417;
  --paper: #17171a;
  --line: rgba(255, 255, 255, 0.08);
  --line-soft: rgba(255, 255, 255, 0.06);
  --line-strong: rgba(255, 255, 255, 0.15);
  --surface-hi: #1d1d21;
  --sunken: #0b0b0d;

  /* Ink */
  --ink: #f4f4f2;
  --ink-soft: #c6c6c2;
  --muted: #a8a8a4;
  --faint: #858580;

  /* Status — colored text on translucent tints */
  --ok: #57b87b;      --ok-bg: rgba(87, 184, 123, 0.14);
  --warn: #d98e3f;    --warn-bg: rgba(217, 142, 63, 0.14);
  --bad: #e0655f;     --bad-bg: rgba(224, 101, 95, 0.14);
  --info: #7fb0e8;    --info-bg: rgba(127, 176, 232, 0.14);
  --rev: #a78bfa;     --rev-bg: rgba(167, 139, 250, 0.14);
  --neu: #a8a8a4;     --neu-bg: rgba(255, 255, 255, 0.08);

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: none;
  --shadow-pop: 0 12px 40px rgba(0, 0, 0, 0.5);

  --sans: "Avenir Next", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;

  /* Chart segments (wealth composition WE-01..WE-05) — dark-calibrated */
  --seg-1: #7fb0e8;
  --seg-2: #57b87b;
  --seg-3: #d98e3f;
  --seg-4: #a78bfa;
  --seg-5: #5f6c78;

  /* ---- Liquid-glass pass (Jul 2026) — ambient scene + glass tokens.
     Dark is the default theme; html[data-theme="light"] overrides at
     the bottom of this file. Glass backgrounds only apply inside the
     @supports (backdrop-filter) block — these tokens keep both themes
     in sync without per-theme selector overrides. ---- */
  --ambient:
    url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E"),
    radial-gradient(1200px 800px at 14% -12%, rgba(13, 74, 122, 0.35), transparent 62%),
    radial-gradient(1050px 720px at 88% 14%, rgba(217, 142, 63, 0.12), transparent 56%),
    radial-gradient(950px 700px at 55% 112%, rgba(87, 184, 123, 0.08), transparent 55%)
    #0b0b0d;
  --glass-side: rgba(20, 20, 23, 0.55);   /* sidebar */
  --glass-top: rgba(15, 15, 17, 0.5);     /* topbar */
  --glass-card: rgba(23, 23, 26, 0.5);    /* cards / kpis / rails / panels */
  --glass-pop: rgba(23, 23, 26, 0.72);    /* popovers / menus / cmdk / toasts / modals */
  --glass-raise: rgba(29, 29, 33, 0.85);  /* semi-opaque raised surface on glass (excerpts, sticky heads) */
  --glass-input: rgba(0, 0, 0, 0.35);     /* sunken glass inputs */
  --glass-hl: rgba(255, 255, 255, 0.06);  /* inner top hairline highlight */
  --thead: rgba(20, 20, 23, 0.88);        /* sticky table headers stay readable */
  --topbar-fallback: rgba(15, 15, 17, 0.88);
  --focus-ring: rgba(127, 176, 232, 0.25);
  --wash-1: rgba(255, 255, 255, 0.04);    /* row hover */
  --wash-2: rgba(255, 255, 255, 0.06);    /* nav / menu hover */
  --wash-3: rgba(255, 255, 255, 0.08);    /* icon-button hover */
  --track: rgba(255, 255, 255, 0.1);      /* meter + ring track */
  --scroll-thumb: rgba(255, 255, 255, 0.18);
  --scroll-thumb-hover: rgba(255, 255, 255, 0.3);
  --scrim: rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
img { display: block; max-width: 100%; }

h1, h2, h3, h4, p { margin: 0; }

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

/* ============================================================
   APP SHELL
   ============================================================ */

body:not(.login-body):not([data-auth-ready]) .app {
  visibility: hidden;
}

.app {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--cream);
  border-right: 1px solid var(--line);
  padding: 18px 14px 16px;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
}

.sidebar-brand img { width: 34px; height: auto; filter: brightness(0) invert(1); }

.sidebar-brand span {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink);
}

/* the wordmark's "AI" reads as a lowercase "l" next to "Corros" in this
   typeface at this weight ("AICorros" → "AlCorros") — color it apart so
   the AI in the name stays legible. */
.sidebar-brand span .ai { color: var(--brand); }

.nav-label {
  margin: 16px 8px 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sage);
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  margin: 1px 0;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-soft);
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover { background: var(--wash-2); color: var(--ink); }

.nav-item.active {
  background: var(--brand-tint);
  color: var(--brand);
  font-weight: 600;
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--brand);
}

.nav-item .ico { flex: 0 0 auto; opacity: 0.85; }

.nav-item .n-badge {
  margin-left: auto;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 99px;
  background: var(--brand-tint-2);
  color: var(--brand);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.env-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 4px 10px;
  padding: 7px 10px;
  border-radius: 9px;
  background: var(--sage-tint);
  border: 1px dashed var(--line-strong);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--sage-deep);
}

.env-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }

/* ---- Icons (inline SVG sizing) ---- */
.ico { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ico-lg { width: 20px; height: 20px; }

/* ---- Main column ---- */
.main { display: flex; flex-direction: column; min-width: 0; }

/* ---- Topbar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 58px;
  padding: 0 28px;
  background: var(--topbar-fallback);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.crumbs .sep { color: var(--faint); }
.crumbs .here { color: var(--ink); font-weight: 600; }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.icon-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  color: var(--ink-soft);
  transition: background 0.15s ease;
}
.icon-btn:hover { background: var(--wash-3); }

.icon-btn .bubble {
  position: absolute;
  top: 3px; right: 2px;
  min-width: 15px; height: 15px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--brand);
  color: #0f0f11;
  font-size: 9.5px;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 8px;
  padding: 5px 10px 5px 5px;
  border-radius: 99px;
  transition: background 0.15s ease;
}
.user-chip:hover { background: var(--wash-3); }

.avatar {
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--brand-tint-2);
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
}

.user-chip .u-name { font-size: 13px; font-weight: 600; line-height: 1.15; }
.user-chip .u-role { font-size: 11px; color: var(--muted); line-height: 1.15; }

/* ---- Content area ---- */
.content {
  flex: 1;
  padding: 26px 28px 48px;
}

.content-rail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 304px;
  gap: 22px;
  align-items: start;
}

/* ---- Page head ---- */
.page-head {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 20px;
}

.page-head h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.page-head .page-sub { margin-top: 3px; font-size: 13.5px; color: var(--muted); }

.page-head .page-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-top: 7px; font-size: 12.5px; color: var(--muted);
}
.page-head .page-meta .dot-sep { color: var(--faint); }

.page-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

/* THE one white solid pill per page */
.btn-primary { background: #f4f4f2; color: #111111; }
.btn-primary:hover { background: #ffffff; color: #111111; }
.btn-primary:disabled { background: rgba(244, 244, 242, 0.35); color: rgba(17, 17, 17, 0.65); cursor: not-allowed; }

.btn-outline { border-color: var(--line-strong); background: transparent; color: var(--muted); }
.btn-outline:hover { background: var(--surface-hi); border-color: var(--line-strong); color: var(--ink); }

.btn-ghost { color: var(--muted); }
.btn-ghost:hover { background: var(--surface-hi); color: var(--ink); }

.btn-danger-soft { background: var(--bad-bg); color: var(--bad); border-color: rgba(224, 101, 95, 0.25); }
.btn-danger-soft:hover { background: rgba(224, 101, 95, 0.22); }

.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 999px; }

.text-link { color: var(--brand); font-size: 12.5px; font-weight: 600; }
.text-link:hover { text-decoration: underline; }

/* ============================================================
   KPI CARDS
   ============================================================ */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-card {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 16px 17px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.kpi-ico {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
}
.kpi-ico.blue  { background: var(--info-bg); color: var(--brand); }
.kpi-ico.amber { background: var(--warn-bg); color: var(--warn); }
.kpi-ico.green { background: var(--ok-bg); color: var(--ok); }
.kpi-ico.red   { background: var(--bad-bg); color: var(--bad); }
.kpi-ico.purple{ background: var(--rev-bg); color: var(--rev); }
.kpi-ico.sage  { background: var(--sage-tint); color: var(--sage-deep); }

.kpi-card .k-label { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.kpi-card .k-value { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); line-height: 1.2; }
.kpi-card .k-value.red { color: var(--bad); }
.kpi-card .k-sub { font-size: 11.5px; color: var(--faint); }

/* ============================================================
   CARDS / PANELS
   ============================================================ */

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-pad { padding: 18px 20px; }

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.card-head h2, .card-head h3 { font-size: 14.5px; font-weight: 600; }
.card-head .spacer { margin-left: auto; }

.section-gap { margin-bottom: 20px; }

/* ============================================================
   CHIPS & BADGES
   ============================================================ */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2.5px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.9; }
.chip.no-dot::before { display: none; }

.chip.blue   { background: var(--info-bg); color: var(--info); border-color: rgba(127, 176, 232, 0.25); }
.chip.green  { background: var(--ok-bg);   color: var(--ok);   border-color: rgba(87, 184, 123, 0.25); }
.chip.amber  { background: var(--warn-bg); color: var(--warn); border-color: rgba(217, 142, 63, 0.25); }
.chip.red    { background: var(--bad-bg);  color: var(--bad);  border-color: rgba(224, 101, 95, 0.25); }
.chip.purple { background: var(--rev-bg);  color: var(--rev);  border-color: rgba(167, 139, 250, 0.25); }
.chip.neutral{ background: var(--neu-bg);  color: var(--neu);  border-color: rgba(255, 255, 255, 0.15); }

.count-badge {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 700;
}
.count-badge.blue  { background: var(--info-bg); color: var(--info); }
.count-badge.amber { background: var(--warn-bg); color: var(--warn); }
.count-badge.green { background: var(--ok-bg); color: var(--ok); }
.count-badge.red   { background: var(--bad-bg); color: var(--bad); }

/* ============================================================
   FILTER BAR
   ============================================================ */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.search-input {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 1 260px;
  padding: 8px 12px;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
}
.search-input input { border: 0; outline: none; background: none; width: 100%; font-size: 13px; color: var(--ink); }
.search-input input::placeholder { color: var(--faint); }

.select {
  appearance: none;
  padding: 8px 30px 8px 12px;
  background: var(--sunken) url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23a8a8a4' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 11px center;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
}
.select:hover { border-color: var(--line-strong); }

/* ============================================================
   TABLES
   ============================================================ */

.tbl-wrap { overflow-x: auto; }

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.tbl th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 10px 12px;
  background: var(--cream);
  border-bottom: 1px solid var(--line);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  white-space: nowrap;
}

.tbl td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  color: var(--ink-soft);
}

.tbl.nowrap td { white-space: nowrap; }
.tbl td.wrap { white-space: normal; }

.tbl td.strong, .tbl .strong { color: var(--ink); font-weight: 600; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl td.danger { color: var(--bad); font-weight: 600; }

.tbl tbody tr { transition: background 0.12s ease; }
.tbl tbody tr:hover { background: var(--wash-1); }
.tbl tbody tr.selected { background: var(--brand-tint); }
.tbl tbody tr.row-click { cursor: pointer; }

/* Group header rows inside table */
.tbl-group td {
  padding: 9px 12px;
  background: var(--cream);
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
}
.tbl-group .g-inner { display: flex; align-items: center; gap: 9px; }
.tbl-group .g-bar { width: 3.5px; height: 16px; border-radius: 2px; }
.tbl-group .g-bar.blue { background: var(--brand); }
.tbl-group .g-bar.amber { background: var(--warn); }
.tbl-group .g-bar.green { background: var(--ok); }
.tbl-group .g-bar.red { background: var(--bad); }
.tbl-group .g-bar.purple { background: var(--rev); }
.tbl-group .g-link { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--brand); }

.row-dots {
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  border-radius: 8px;
  color: var(--muted);
}
.row-dots:hover { background: var(--wash-3); }

.tbl-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  font-size: 12.5px;
  color: var(--muted);
}

.pager { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.pager button {
  display: grid; place-items: center;
  min-width: 28px; height: 28px;
  padding: 0 6px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
}
.pager button:hover { background: var(--wash-3); }
.pager button.on { background: var(--brand); color: #0f0f11; }

input[type="checkbox"].cbx {
  width: 15px; height: 15px;
  accent-color: var(--brand);
  cursor: pointer;
}

/* ============================================================
   RIGHT RAIL
   ============================================================ */

.rail { display: flex; flex-direction: column; gap: 16px; }

.rail-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 17px;
}

.rail-card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 700;
  margin-bottom: 12px;
}
.rail-card h3 .spacer { margin-left: auto; }

.feed { display: flex; flex-direction: column; gap: 0; }

.feed-item {
  position: relative;
  display: flex;
  gap: 11px;
  padding: 9px 0;
}
.feed-item + .feed-item { border-top: 1px dashed var(--line-soft); }

.feed-ico {
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
}
.feed-ico.blue { background: var(--info-bg); color: var(--brand); }
.feed-ico.green { background: var(--ok-bg); color: var(--ok); }
.feed-ico.amber { background: var(--warn-bg); color: var(--warn); }
.feed-ico.purple { background: var(--rev-bg); color: var(--rev); }
.feed-ico.red { background: var(--bad-bg); color: var(--bad); }

.feed-item .f-title { font-size: 12.5px; font-weight: 600; color: var(--ink); line-height: 1.3; }
.feed-item .f-sub { font-size: 12px; color: var(--muted); }
.feed-item .f-time { font-size: 11px; color: var(--faint); margin-top: 2px; }

.task-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 0;
  font-size: 13px;
  color: var(--ink-soft);
}
.task-row + .task-row { border-top: 1px dashed var(--line-soft); }
.task-row .count-badge { margin-left: auto; }

/* ============================================================
   FORMS
   ============================================================ */

.form-section { padding: 18px 20px; border-bottom: 1px solid var(--line-soft); }
.form-section:last-child { border-bottom: 0; }

.form-section > h3 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sage-deep);
  margin-bottom: 14px;
}

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .span-2 { grid-column: span 2; }

.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 5px;
}
.field label .req { color: var(--bad); }

.field .hint { margin-top: 4px; font-size: 11.5px; color: var(--faint); }
.field .error-text { display: none; margin-top: 4px; font-size: 11.5px; color: var(--bad); font-weight: 600; }
.field.invalid .error-text { display: block; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--bad); background: rgba(224, 101, 95, 0.08); }

.field input[type="text"], .field input[type="date"], .field input[type="number"],
.field input[type="email"], .field input[type="password"],
.field select, .field textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field select {
  appearance: none;
  background: var(--sunken) url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23a8a8a4' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
}

.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.field textarea { resize: vertical; min-height: 86px; }

.radio-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.radio-card {
  position: relative;
  display: flex;
  gap: 12px;
  padding: 13px 14px;
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.radio-card:hover { border-color: var(--line-strong); }
.radio-card.on { border-color: rgba(127, 176, 232, 0.5); background: var(--brand-tint); }
.radio-card .r-title { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.radio-card .r-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.radio-card input { position: absolute; opacity: 0; }

/* ============================================================
   TABS
   ============================================================ */

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  overflow-x: auto;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.tab:hover { color: var(--ink); }
.tab.on { color: var(--brand); border-bottom-color: var(--brand); }
.tab .count-badge { min-width: 20px; }

.seg {
  display: inline-flex;
  padding: 3px;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: 999px;
  gap: 2px;
}
.seg button {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}
.seg button.on { background: var(--surface-hi); color: var(--ink); }

/* ============================================================
   BANNERS
   ============================================================ */

.banner {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 18px;
}
.banner .ico { flex-shrink: 0; margin-top: 1px; }
.banner b { font-weight: 700; }

.banner.info { background: var(--info-bg); color: #c3daf4; border: 1px solid rgba(127, 176, 232, 0.25); }
.banner.warn { background: var(--warn-bg); color: #ecc394; border: 1px solid rgba(217, 142, 63, 0.25); }
.banner.danger { background: var(--bad-bg); color: #f0aca7; border: 1px solid rgba(224, 101, 95, 0.25); }
.banner.sage { background: var(--sage-tint); color: var(--sage-deep); border: 1px dashed var(--line-strong); }

/* ============================================================
   PROGRESS / METERS / RINGS
   ============================================================ */

.meter {
  height: 7px;
  border-radius: 99px;
  background: var(--track);
  overflow: hidden;
}
.meter > span { display: block; height: 100%; border-radius: 99px; background: var(--brand); }
.meter > span.green { background: var(--ok); }
.meter > span.amber { background: var(--warn); }
.meter > span.red { background: var(--bad); }

.ring {
  --p: 75;
  --ring-color: var(--brand);
  position: relative;
  width: 108px; height: 108px;
  border-radius: 50%;
  background: conic-gradient(var(--ring-color) calc(var(--p) * 1%), var(--track) 0);
  display: grid;
  place-items: center;
  margin: 0 auto;
}
.ring::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: var(--paper);
}
.ring .ring-val { position: relative; font-size: 22px; font-weight: 700; color: var(--ink); }
.ring .ring-val small { display: block; font-size: 10.5px; font-weight: 600; color: var(--muted); text-align: center; }

/* ============================================================
   STAT LISTS  (label:value rows)
   ============================================================ */

.kv { display: flex; flex-direction: column; gap: 0; }
.kv-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7.5px 0;
  font-size: 13px;
}
.kv-row + .kv-row { border-top: 1px dashed var(--line-soft); }
.kv-row .k { color: var(--muted); }
.kv-row .v { font-weight: 600; color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }

/* ============================================================
   UPLOAD ZONE
   ============================================================ */

.dropzone {
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 30px 20px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--sunken);
  text-align: center;
  color: var(--muted);
  transition: border-color 0.15s ease, background 0.15s ease;
  cursor: pointer;
}
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-tint); }
.dropzone .dz-title { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.dropzone .dz-sub { font-size: 12px; color: var(--muted); }
.dropzone .ico { width: 26px; height: 26px; color: var(--sage-deep); }

/* ============================================================
   TIMELINE
   ============================================================ */

.vtimeline { position: relative; padding-left: 22px; }
.vtimeline::before {
  content: "";
  position: absolute;
  left: 7px; top: 8px; bottom: 8px;
  width: 2px;
  background: var(--line);
}
.vt-item { position: relative; padding: 10px 0 14px; }
.vt-item::before {
  content: "";
  position: absolute;
  left: -21px; top: 15px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--paper);
  border: 3px solid var(--brand);
}
.vt-item.green::before { border-color: var(--ok); }
.vt-item.amber::before { border-color: var(--warn); }
.vt-item.red::before { border-color: var(--bad); }
.vt-item .vt-date { font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--sage-deep); }
.vt-item .vt-title { font-size: 13.5px; font-weight: 600; color: var(--ink); margin-top: 2px; }
.vt-item .vt-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ============================================================
   BAR / COMPOSITION CHARTS (CSS only)
   ============================================================ */

.bars { display: flex; align-items: flex-end; gap: 18px; height: 150px; padding: 4px 6px 0; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .bar > i {
  width: 100%;
  max-width: 52px;
  border-radius: 6px 6px 2px 2px;
  background: var(--brand);
  opacity: 0.9;
}
.bars .bar.amber > i { background: var(--warn); }
.bars .bar.green > i { background: var(--ok); }
.bars .bar.sage > i { background: var(--sage); }
.bars .bar .b-label { font-size: 10.5px; color: var(--muted); text-align: center; line-height: 1.25; }
.bars .bar .b-val { font-size: 11px; font-weight: 700; color: var(--ink); }

.stackbar { display: flex; height: 14px; border-radius: 99px; overflow: hidden; }
.stackbar > span { height: 100%; }

.legend { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 10px; font-size: 12px; color: var(--ink-soft); }
.legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; }

/* ============================================================
   WORKFLOW GATES
   ============================================================ */

.gates { display: flex; align-items: flex-start; gap: 0; }
.gate { flex: 1; position: relative; text-align: center; padding-top: 4px; }
.gate::before {
  content: "";
  position: absolute;
  top: 17px; left: -50%; right: 50%;
  height: 2.5px;
  background: var(--line);
}
.gate:first-child::before { display: none; }
.gate.done::before, .gate.on::before { background: var(--ok); }

.gate .g-dot {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  margin: 0 auto 7px;
  border-radius: 50%;
  background: var(--paper);
  border: 2.5px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.gate.done .g-dot { background: var(--ok); border-color: var(--ok); color: #0f0f11; }
.gate.on .g-dot { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 4px rgba(127, 176, 232, 0.18); }
.gate.blocked .g-dot { border-color: var(--bad); color: var(--bad); background: var(--bad-bg); }

.gate .g-name { font-size: 11.5px; font-weight: 600; color: var(--ink-soft); line-height: 1.25; }
.gate .g-state { font-size: 10.5px; color: var(--faint); }

/* ============================================================
   NARRATIVE EDITOR
   ============================================================ */

.doc-editor {
  padding: 26px 30px 34px;
  font-size: 14.5px;
  line-height: 1.75;
  color: var(--ink);
}

.doc-editor h2 { font-size: 17px; font-weight: 700; margin: 22px 0 8px; }
.doc-editor h2:first-child { margin-top: 0; }
.doc-editor p { margin: 0 0 12px; }

.doc-editor .sent { border-bottom: 2px solid transparent; border-radius: 2px; padding: 0 1px; cursor: pointer; transition: background 0.15s ease; }
.doc-editor .sent.s-ok { border-bottom-color: rgba(87, 184, 123, 0.55); }
.doc-editor .sent.s-ok:hover { background: var(--ok-bg); }
.doc-editor .sent.s-warn { border-bottom-color: rgba(217, 142, 63, 0.6); background: rgba(217, 142, 63, 0.1); }
.doc-editor .sent.s-warn:hover { background: var(--warn-bg); }
.doc-editor .sent.s-bad { border-bottom-color: rgba(224, 101, 95, 0.65); background: rgba(224, 101, 95, 0.1); }
.doc-editor .sent.s-bad:hover { background: var(--bad-bg); }

.src-badge {
  display: inline-grid;
  place-items: center;
  min-width: 17px; height: 17px;
  padding: 0 4px;
  margin: 0 2px;
  border-radius: 5px;
  background: var(--brand-tint-2);
  color: var(--brand);
  font-size: 10px;
  font-weight: 700;
  vertical-align: 2px;
  cursor: pointer;
}
.src-badge:hover { background: var(--brand); color: #0f0f11; }

/* Issue cards (unsupported claims etc.) */
.issue-card {
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-left: 3.5px solid var(--warn);
  border-radius: 10px;
  background: var(--surface-hi);
  margin-bottom: 10px;
}
.issue-card.red { border-left-color: var(--bad); }
.issue-card.green { border-left-color: var(--ok); }
.issue-card.purple { border-left-color: var(--rev); }
.issue-card .i-title { font-size: 12.5px; font-weight: 600; color: var(--ink); line-height: 1.35; }
.issue-card .i-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.issue-card .i-actions { display: flex; gap: 10px; margin-top: 7px; }

/* ============================================================
   MISC
   ============================================================ */

.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }

.divider { height: 1px; background: var(--line-soft); margin: 14px 0; }

.empty {
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}
.empty .e-title { font-weight: 600; color: var(--ink-soft); }

.toast {
  position: fixed;
  bottom: 26px; left: 50%;
  transform: translateX(-50%) translateY(16px);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--surface-hi);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 12px;
  box-shadow: var(--shadow-pop);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================
   LOGIN PAGE
   ============================================================ */

body.login-body {
  min-height: 100vh;
  background:
    radial-gradient(1100px 600px at 85% -10%, rgba(127, 176, 232, 0.07), transparent 60%),
    radial-gradient(900px 550px at -10% 110%, rgba(255, 255, 255, 0.04), transparent 55%),
    var(--canvas);
  display: grid;
  place-items: center;
  padding: 40px 20px;
}

.login-shell {
  width: min(1060px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow-pop);
}

.login-form-col { padding: 44px 48px 40px; }

.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 34px; }
.login-brand img { width: 40px; filter: brightness(0) invert(1); }
.login-brand span { font-size: 22px; font-weight: 700; color: var(--ink); }

.login-form-col h1 { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.login-form-col .login-sub { font-size: 13.5px; color: var(--muted); margin-bottom: 26px; }

.role-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 22px; }

.role-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 13px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}
.role-card:hover { border-color: var(--line-strong); }
.role-card[aria-disabled="true"] { cursor: default; }
.role-card[aria-disabled="true"]:not(.on):hover { border-color: var(--line); }
.role-card.on { border-color: rgba(127, 176, 232, 0.5); background: var(--brand-tint); }
.role-card input { accent-color: var(--brand); flex-shrink: 0; }
.role-card .r-ico {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--sage-tint);
  color: var(--sage-deep);
  flex-shrink: 0;
}
.role-card.on .r-ico { background: var(--brand-tint-2); color: var(--brand); }
.role-card .r-name { font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.2; }
.role-card .r-desc { font-size: 11px; color: var(--muted); line-height: 1.3; }

.login-side {
  position: relative;
  background:
    radial-gradient(700px 420px at 110% -20%, rgba(127, 176, 232, 0.16), transparent 55%),
    linear-gradient(160deg, #0a2c49 0%, var(--brand-deep) 62%, #11588f 100%);
  color: #f2f6fa;
  padding: 44px 40px;
  display: flex;
  flex-direction: column;
}

.login-side .side-mark { width: 190px; opacity: 0.16; position: absolute; right: -34px; bottom: -20px; }

.login-side h2 { font-size: 19px; font-weight: 700; line-height: 1.35; margin-bottom: 10px; }
.login-side > p { font-size: 13px; color: rgba(242, 246, 250, 0.78); line-height: 1.55; }

.status-card {
  margin-top: 22px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  backdrop-filter: blur(6px);
}
.status-card .s-row { display: flex; align-items: center; gap: 9px; padding: 6px 0; font-size: 12.5px; }
.status-card .s-row + .s-row { border-top: 1px dashed rgba(255, 255, 255, 0.14); }
.status-card .s-dot { width: 8px; height: 8px; border-radius: 50%; background: #7fd6a4; }
.status-card .s-dot.amber { background: #ecc46f; }
.status-card b { font-weight: 600; }
.status-card .s-note { margin-left: auto; font-size: 11px; color: rgba(242, 246, 250, 0.6); }

/* ============================================================
   RESPONSIVE (light — desktop-first product)
   ============================================================ */

@media (max-width: 1220px) {
  /* keep minmax(0,…) so nowrap tables scroll INSIDE the track instead of
     stretching the grid and forcing page-level horizontal scroll (PG-01) */
  .content-rail { grid-template-columns: minmax(0, 1fr); }
  .rail { flex-direction: row; flex-wrap: wrap; }
  .rail > * { flex: 1 1 300px; }
}

@media (max-width: 1024px) {
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app { grid-template-columns: 76px minmax(0, 1fr); }
  .sidebar { padding: 16px 10px; }
  .sidebar-brand span, .nav-item span.txt, .nav-label, .env-pill span.txt, .nav-item .n-badge { display: none; }
  .sidebar-brand { justify-content: center; padding-bottom: 10px; }
  .nav-item { justify-content: center; padding: 10px; }
  .env-pill { justify-content: center; }
  /* auto-collapsed rail: hide the case-switcher's full text, show initials (PG-05) */
  .sidebar .case-switch .cs-line,
  .sidebar .case-switch .cs-client { display: none; }
  .sidebar .case-switch { padding: 6px 0; text-align: center; }
  .sidebar .case-switch .cs-mini {
    display: flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; margin: 0 auto;
    border-radius: 8px; background: var(--brand-tint); color: var(--brand);
    font-size: 11px; font-weight: 700;
  }
}

@media (max-width: 860px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-side { display: none; }
  .form-grid, .radio-cards, .role-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .content { padding: 18px 16px 40px; }
  .topbar { padding: 0 16px; }
  .page-head { flex-wrap: wrap; }
  .page-actions { margin-left: 0; width: 100%; }
  .kpi-row { grid-template-columns: 1fr; }
  .gates { flex-wrap: wrap; gap: 12px; }
  .gate { flex: 1 1 30%; }
  .gate::before { display: none; }
}

/* ============================================================
   BREADCRUMB LINKS
   ============================================================ */

.crumbs a.crumb-link {
  color: var(--muted);
  border-radius: 4px;
  transition: color 0.15s ease;
}
.crumbs a.crumb-link:hover,
.crumbs a.crumb-link:focus-visible {
  color: var(--brand);
  text-decoration: underline;
}

/* ============================================================
   COMMAND PALETTE  (⌘K)
   ============================================================ */

.cmdk-scrim {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 20px 20px;
  background: var(--scrim);
  backdrop-filter: blur(2px);
}

.cmdk {
  width: 100%;
  max-width: 560px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}

.cmdk-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--muted);
}
.cmdk-input-row .ico { flex-shrink: 0; }
.cmdk-input-row input {
  flex: 1;
  border: 0;
  outline: none;
  background: none;
  font-size: 14.5px;
  color: var(--ink);
}
.cmdk-input-row input::placeholder { color: var(--faint); }

.cmdk-list {
  max-height: 340px;
  overflow-y: auto;
  padding: 6px;
}

.cmdk-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 9px;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
}
.cmdk-item .ck-text { min-width: 0; }
.cmdk-item .ck-title { font-weight: 600; color: var(--ink); }
.cmdk-item .ck-sub { font-size: 11.5px; color: var(--muted); }
.cmdk-item .ck-type { margin-left: auto; flex-shrink: 0; }
.cmdk-item.active { background: var(--brand-tint); }

.cmdk-empty {
  padding: 26px 16px;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
}

.cmdk-foot {
  display: flex;
  gap: 16px;
  padding: 8px 14px;
  border-top: 1px solid var(--line-soft);
  background: var(--cream);
  font-size: 11px;
  color: var(--faint);
}
.cmdk-foot kbd {
  display: inline-grid;
  place-items: center;
  min-width: 17px;
  padding: 1px 4px;
  margin-right: 3px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--paper);
  font-family: var(--sans);
  font-size: 10px;
  color: var(--muted);
}

/* ============================================================
   TOPBAR POPOVERS  (notifications, profile menu)
   ============================================================ */

.pop {
  position: fixed;
  z-index: 95;
  min-width: 292px;
  max-width: 360px;
  padding: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-pop);
}

.pop-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 10px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 6px;
}
.pop-head .text-link { margin-left: auto; }

.notif-item {
  display: flex;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  transition: background 0.12s ease;
}
.notif-item:hover { background: var(--brand-tint); }
.notif-item.read { opacity: 0.6; }
.notif-item .n-body { min-width: 0; }
.notif-item .n-title { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink); line-height: 1.3; }
.notif-item .n-sub { display: block; font-size: 11.5px; color: var(--muted); line-height: 1.35; }
.notif-item .n-time { display: block; font-size: 10.5px; color: var(--faint); margin-top: 2px; }

.menu-id {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 4px;
}
.menu-id .m-name { font-size: 13px; font-weight: 700; color: var(--ink); }
.menu-id .m-role { font-size: 11.5px; color: var(--muted); }

.menu-sec {
  padding: 8px 10px 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--sage);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 13px;
  color: var(--ink-soft);
  text-align: left;
  transition: background 0.12s ease, color 0.12s ease;
}
.menu-item:hover { background: var(--wash-2); color: var(--ink); }
.menu-item .mi-check { margin-left: auto; color: var(--ok); font-weight: 700; }
.menu-item.danger { color: var(--bad); }
.menu-item.danger:hover { background: var(--bad-bg); color: var(--bad); }

.menu-div { height: 1px; background: var(--line-soft); margin: 6px 4px; }

/* ============================================================
   SETTINGS PAGE
   ============================================================ */

.key-row { display: flex; gap: 8px; align-items: stretch; }
.key-row input { flex: 1; }
.key-row .btn { flex-shrink: 0; }

.conn-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}
.conn-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex-shrink: 0; }
.conn-status.ok { color: var(--ok); }
.conn-status.ok::before { background: var(--ok); }
.conn-status.bad { color: var(--bad); }
.conn-status.bad::before { background: var(--bad); }
.conn-status.busy { color: var(--warn); }
.conn-status.busy::before { background: var(--warn); }

.gov-row {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 12px 0;
}
.gov-row + .gov-row { border-top: 1px dashed var(--line-soft); }
.gov-row .ico { flex-shrink: 0; margin-top: 1px; color: var(--sage-deep); }
.gov-row .g-title { font-size: 13px; font-weight: 600; color: var(--ink); }
.gov-row .g-note { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.45; }
.gov-row .g-side { margin-left: auto; flex-shrink: 0; }

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
}

/* ============================================================
   DISPLAY DENSITY — compact (~20% tighter)
   ============================================================ */

body[data-density="compact"] .content { padding: 20px 22px 38px; }
body[data-density="compact"] .card-pad { padding: 14px 16px; }
body[data-density="compact"] .card-head { padding: 11px 14px; }
body[data-density="compact"] .kpi-card { padding: 13px 14px; }
body[data-density="compact"] .rail-card { padding: 13px 14px; }
body[data-density="compact"] .form-section { padding: 14px 16px; }
body[data-density="compact"] .tbl th { padding: 8px 10px; }
body[data-density="compact"] .tbl td { padding: 8.5px 10px; }
body[data-density="compact"] .page-head { margin-bottom: 16px; }
body[data-density="compact"] .kpi-row { gap: 11px; margin-bottom: 14px; }
body[data-density="compact"] .section-gap { margin-bottom: 16px; }
body[data-density="compact"] .banner { padding: 10px 13px; margin-bottom: 14px; }

/* ============================================================
   DASHBOARD  (dashboard.html)
   Sparklines · focus strip · priority rows · briefing · strips
   ============================================================ */

/* Tiny corner sparklines on KPI cards */
.kpi-card.kpi-spark { position: relative; }
.kpi-card.kpi-spark .spark { position: absolute; top: 13px; right: 14px; }
.spark { width: 62px; height: 20px; overflow: visible; }
.spark polyline { fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* One-line "Focus" strip under the greeting */
.focus-strip {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 12px 16px;
  margin-bottom: 18px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 3.5px solid var(--brand);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 13px;
  color: var(--ink-soft);
}
.focus-strip .ico { flex-shrink: 0; margin-top: 1px; color: var(--brand); }
.focus-strip b { color: var(--ink); }

/* Priority / SLA rows with a severity accent bar */
.prio-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 16px 11px 22px;
}
.prio-row + .prio-row { border-top: 1px dashed var(--line-soft); }
.prio-row .sev-bar {
  position: absolute;
  left: 9px; top: 12px; bottom: 12px;
  width: 3px;
  border-radius: 2px;
  background: var(--info);
}
.prio-row .sev-bar.red { background: var(--bad); }
.prio-row .sev-bar.amber { background: var(--warn); }
.prio-row .sev-bar.blue { background: var(--info); }
.prio-row .p-body { flex: 1; min-width: 0; }
.prio-row .p-title { font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.35; }
.prio-row .p-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.prio-row .p-side { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.prio-row.done { opacity: 0.62; }
.prio-row.done .p-title { text-decoration: line-through; color: var(--muted); }

/* Inline spinner (briefing button busy state) */
.spinner {
  display: inline-block;
  width: 13px; height: 13px;
  border: 2px solid rgba(127, 176, 232, 0.25);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: aic-spin 0.7s linear infinite;
}
@keyframes aic-spin { to { transform: rotate(360deg); } }

/* AI briefing output */
.brief-out { margin-top: 9px; font-size: 13px; line-height: 1.6; color: var(--ink-soft); }

/* Toast with an Undo action (dashboard checklist) */
.toast.undo-toast { pointer-events: auto; }
.toast .toast-undo {
  margin-left: 4px;
  color: var(--brand);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* "Learn the workflow" strip */
.learn-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  padding: 14px 18px;
  background: var(--brand-tint);
  border: 1px solid rgba(127, 176, 232, 0.25);
  border-radius: var(--radius);
  font-size: 13px;
  color: #c3daf4;
}
.learn-strip .ico { flex-shrink: 0; color: var(--brand); }
.learn-strip .spacer { margin-left: auto; }

/* ============================================================
   GUIDE  (guide.html) — numbered steps, FAQ, kbd hints
   ============================================================ */

.guide-step { display: flex; gap: 12px; padding: 10px 0; }
.guide-step + .guide-step { border-top: 1px dashed var(--line-soft); }
.guide-step .gs-num {
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--brand-tint-2);
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}
.guide-step .gs-title { font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.35; }
.guide-step .gs-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; line-height: 1.5; }
.guide-step .gs-sub a { color: var(--brand); font-weight: 600; }
.guide-step .gs-sub a:hover { text-decoration: underline; }

/* FAQ accordion */
.faq details { border-bottom: 1px dashed var(--line-soft); }
.faq details:last-child { border-bottom: 0; }
.faq summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; margin-left: auto; color: var(--sage-deep); font-weight: 700; }
.faq details[open] summary::after { content: "\2013"; }
.faq .faq-a { padding: 0 0 11px; font-size: 12px; color: var(--muted); line-height: 1.55; }

/* Keyboard hint chips (shortcuts card) */
.kbd {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--cream);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
}

/* ============================================================
   NATURAL-UX PASS ADDITIONS (Jul 2026) — additive only.
   Generic helpers: ⋯ overflow menu (.menu-pop), one-line page
   hints (.page-hint), collapsed filter row (.filter-more) and
   card-consistent <details> folds (details.fold).
   ============================================================ */

/* ---- ⋯ overflow menu (Esc / outside-click closed via page script) ---- */
.menu-pop { position: relative; display: inline-flex; }

.menu-pop-btn {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.menu-pop-btn:hover,
.menu-pop.open .menu-pop-btn { border-color: var(--brand); color: var(--brand); }

.menu-pop-list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 70;
  min-width: 216px;
  padding: 6px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-pop);
  display: none;
}
.menu-pop.open .menu-pop-list { display: block; }

.menu-pop-list > button,
.menu-pop-list > a {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink-soft);
  text-align: left;
  transition: background 0.12s ease, color 0.12s ease;
}
.menu-pop-list > button:hover,
.menu-pop-list > a:hover { background: var(--wash-2); color: var(--ink); }

.menu-pop-label {
  padding: 7px 10px 3px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--sage);
}

.menu-pop-div { height: 1px; background: var(--line-soft); margin: 6px 4px; }

/* ---- one-line page hint (self-explaining tables/graphs) ---- */
.page-hint {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin: 10px 2px 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}
.page-hint::before {
  content: "ⓘ";
  flex-shrink: 0;
  font-size: 12px;
  color: var(--sage-deep);
  opacity: 0.8;
}

/* ---- collapsed filter row (hidden until "Filters" is toggled) ---- */
.filter-more { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; width: 100%; }
.filter-more[hidden] { display: none; }

/* ---- card-consistent <details> folds ---- */
details.fold > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--brand);
  cursor: pointer;
  list-style: none;
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before {
  content: "›";
  font-size: 15px;
  font-weight: 700;
  color: var(--sage-deep);
  transition: transform 0.15s ease;
}
details.fold[open] > summary::before { transform: rotate(90deg); }

/* ============================================================
   CASE CONTEXT PASS (Jul 2026) — additive only.
   Sidebar case switcher, case dropdown, lite-case context
   banner, client-profile lite blocks and real case notes.
   ============================================================ */

/* ---- sidebar case switcher (replaces the static CASE label) ---- */
.case-switch {
  display: block;
  width: 100%;
  margin: 14px 0 4px;
  padding: 5px 8px 6px;
  border-radius: 9px;
  text-align: left;
  transition: background 0.15s ease;
}
.case-switch:hover { background: var(--wash-2); }
.case-switch .cs-line { display: flex; align-items: center; gap: 5px; }
.case-switch .cs-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sage);
}
.case-switch .cs-chev {
  width: 11px; height: 11px;
  stroke: var(--sage-deep);
  flex-shrink: 0;
  transition: transform 0.15s ease;
}
.case-switch[aria-expanded="true"] .cs-chev { transform: rotate(180deg); }
.case-switch .cs-client {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--sage-deep);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- case dropdown (uses the fixed .pop base) ---- */
.case-pop { width: 316px; }
.case-pop-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 10px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 6px;
}
.case-pop-search .ico { flex-shrink: 0; color: var(--faint); }
.case-pop-search input { border: 0; outline: none; background: none; width: 100%; font-size: 13px; color: var(--ink); }
.case-pop-search input::placeholder { color: var(--faint); }

.case-pop-list { max-height: 46vh; overflow-y: auto; }

.case-opt {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 9px;
  text-align: left;
  transition: background 0.12s ease;
}
.case-opt:hover, .case-opt.hi { background: var(--brand-tint); }
.case-opt .co-main { flex: 1; min-width: 0; }
.case-opt .co-name { display: block; font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.3; }
.case-opt .co-sub { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; }
.case-opt .chip { flex-shrink: 0; font-size: 10px; padding: 1px 7px; }
.case-opt .co-check { flex-shrink: 0; color: var(--ok); font-weight: 700; }

.case-pop-empty { padding: 16px 10px; font-size: 12.5px; color: var(--muted); text-align: center; }
.case-pop-foot { border-top: 1px solid var(--line-soft); margin-top: 6px; padding: 9px 10px 4px; }

/* ---- slim lite-case context banner (injected on deep case pages) ---- */
.banner.slim { align-items: center; padding: 8px 14px; font-size: 12.5px; }
.banner.slim .ico { margin-top: 0; }
.case-context-banner .ccb-text { min-width: 0; }
.case-context-banner .ccb-actions {
  display: flex;
  gap: 14px;
  margin-left: auto;
  flex-shrink: 0;
  align-items: center;
}
.case-context-banner .text-link { white-space: nowrap; }

/* ---- client-profile lite blocks ---- */
.lite-empty { padding: 36px 24px; text-align: center; }
.lite-empty p {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  max-width: 460px;
  margin: 0 auto 10px;
}

.ws-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  font-size: 13px;
}
.ws-row + .ws-row { border-top: 1px dashed var(--line-soft); }
.ws-row .ws-label { flex: 1; min-width: 0; font-weight: 600; color: var(--ink); }
.ws-row .ws-amt { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink-soft); }
.ws-row .chip { flex-shrink: 0; }

.na-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 0;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.5;
}
.na-row + .na-row { border-top: 1px dashed var(--line-soft); }
.na-row .na-num {
  flex-shrink: 0;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--brand-tint-2);
  color: var(--brand);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  margin-top: 1px;
}

/* ---- case notes (client-profile rail) ---- */
.note-composer textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
  font-size: 12.5px;
  line-height: 1.5;
  resize: vertical;
}
.note-composer textarea:focus { outline: 2px solid var(--brand-tint-2); border-color: var(--brand); }
.note-actions { display: flex; gap: 8px; margin: 8px 0 10px; }

.note-item { padding: 10px 0; }
.note-item + .note-item { border-top: 1px dashed var(--line-soft); }
.note-item .note-text {
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.note-item .note-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--faint);
  margin-top: 4px;
}
.note-item .note-del {
  margin-left: auto;
  flex-shrink: 0;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.2;
  color: var(--faint);
  transition: background 0.12s ease, color 0.12s ease;
}
.note-item .note-del:hover { color: var(--bad); background: var(--bad-bg); }
.notes-empty { font-size: 12.5px; color: var(--muted); line-height: 1.55; }

/* ============================================================
   DARK THEME PASS (Jul 2026) — additive only.
   Subtle scrollbars for the near-black surfaces.
   ============================================================ */

* { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--scroll-thumb-hover); }

/* ============================================================
   LIQUID GLASS PASS (Jul 2026) — additive only.
   1) Fixed ambient backdrop behind everything (pure CSS).
   2) Translucent glass chrome + floating surfaces inside
      @supports (backdrop-filter) — solid token fallbacks stay
      above for browsers without it.
   3) .glass utility + .aic-ball / .aic-chat assistant widgets.
   ============================================================ */

/* ---- 1 · ambient backdrop ---- */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;             /* above the canvas background, below all content */
  pointer-events: none;
  background: var(--ambient);
}

/* ---- reusable glass utility (fallback: solid paper) ---- */
.glass {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* ---- 2 · glass surfaces (only when backdrop-filter exists) ---- */
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {

  /* chrome */
  .sidebar {
    background: var(--glass-side);
    -webkit-backdrop-filter: blur(24px) saturate(1.2);
    backdrop-filter: blur(24px) saturate(1.2);
  }
  .topbar {
    background: var(--glass-top);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
    backdrop-filter: blur(20px) saturate(1.2);
  }

  /* cards / panels — backdrop glows through */
  .card, .kpi-card, .rail-card, .focus-strip, .glass {
    background: var(--glass-card);
    border-color: var(--line);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
    backdrop-filter: blur(20px) saturate(1.2);
    box-shadow: inset 0 1px 0 var(--glass-hl);
  }

  /* login hero card */
  .login-shell {
    background: var(--glass-card);
    -webkit-backdrop-filter: blur(24px) saturate(1.2);
    backdrop-filter: blur(24px) saturate(1.2);
    box-shadow: var(--shadow-pop), inset 0 1px 0 var(--glass-hl);
  }

  /* floating surfaces — stronger glass */
  .pop, .cmdk, .menu-pop-list, .toast {
    background: var(--glass-pop);
    -webkit-backdrop-filter: blur(28px) saturate(1.2);
    backdrop-filter: blur(28px) saturate(1.2);
    box-shadow: var(--shadow-pop), inset 0 1px 0 var(--glass-hl);
  }

  /* scrims get a soft liquid blur */
  .cmdk-scrim { -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }

  /* tables stay readable: opaque-ish sticky header, translucent group rows.
     NOTE: no backdrop-filter on rows/cells — chrome & floating surfaces only. */
  .tbl th { background: var(--thead); }
  .tbl-group td { background: var(--wash-2); }
  .cmdk-foot { background: transparent; }
  .issue-card { background: var(--wash-2); }
  .ring::before { background: var(--glass-raise); }

  /* sunken glass inputs (no blur — cheap, and focus ring unchanged) */
  .search-input, .seg, .dropzone,
  .field input[type="text"], .field input[type="date"], .field input[type="number"],
  .field input[type="email"], .field input[type="password"], .field textarea,
  .aic-chat-input input, .aic-chat-input textarea {
    background: var(--glass-input);
  }
  .select, .field select { background-color: var(--glass-input); }
}

/* ============================================================
   AI ASSISTANT (Jul 2026) — floating orb + chat panel.
   DOM injected from app.js: .aic-ball, .aic-chat, .aic-chat-head,
   .aic-chat-msgs, .aic-chat-msg (.me/.ai), .aic-chat-input.
   Styled defensively — safe if the DOM is absent.
   ============================================================ */

.aic-ball {
  position: fixed;
  right: 26px;
  bottom: 26px;
  z-index: 97;
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background:
    radial-gradient(circle at 30% 26%,
      rgba(255, 255, 255, 0.98),
      rgba(226, 228, 232, 0.92) 38%,
      rgba(152, 155, 162, 0.9) 72%,
      rgba(104, 107, 115, 0.95) 100%);
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.45),
    inset 0 2px 6px rgba(255, 255, 255, 0.8),
    inset 0 -8px 14px rgba(0, 0, 0, 0.28);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.aic-ball:active { cursor: grabbing; }
.aic-ball:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }

/* subtle idle glow (opacity-only animation, cheap) */
.aic-ball::after {
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  box-shadow: 0 0 26px 7px rgba(255, 255, 255, 0.16);
  opacity: 0.3;
  pointer-events: none;
  animation: aic-ball-glow 3.8s ease-in-out infinite;
}
@keyframes aic-ball-glow {
  0%, 100% { opacity: 0.22; }
  50% { opacity: 0.75; }
}

.aic-chat {
  position: fixed;
  right: 26px;
  bottom: 96px;
  z-index: 96;
  width: min(360px, calc(100vw - 32px));
  height: min(480px, calc(100vh - 130px));
  display: flex;
  flex-direction: column;
  background: var(--paper);            /* fallback; glass below */
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}
.aic-chat[hidden] { display: none; }

.aic-chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  flex-shrink: 0;
}
.aic-chat-head .spacer { margin-left: auto; }

.aic-chat-msgs {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.aic-chat-msg {
  max-width: 84%;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.aic-chat-msg.ai {
  align-self: flex-start;
  background: var(--wash-2);
  border: 1px solid var(--line-soft);
  border-bottom-left-radius: 5px;
}
.aic-chat-msg.me {
  align-self: flex-end;
  background: var(--brand-tint-2);
  border: 1px solid var(--focus-ring);
  border-bottom-right-radius: 5px;
}

.aic-chat-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--line-soft);
  flex-shrink: 0;
}
.aic-chat-input input,
.aic-chat-input textarea {
  flex: 1;
  min-width: 0;
  padding: 8px 13px;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  color: var(--ink);
  outline: none;
  resize: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.aic-chat-input input::placeholder,
.aic-chat-input textarea::placeholder { color: var(--faint); }
.aic-chat-input input:focus,
.aic-chat-input textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .aic-chat {
    background: var(--glass-pop);
    -webkit-backdrop-filter: blur(28px) saturate(1.2);
    backdrop-filter: blur(28px) saturate(1.2);
    box-shadow: var(--shadow-pop), inset 0 1px 0 var(--glass-hl);
  }
  .aic-chat-input input,
  .aic-chat-input textarea { background: var(--glass-input); }
}

@media (prefers-reduced-motion: reduce) {
  .aic-ball::after { animation: none; opacity: 0.3; }
}

/* ============================================================
   LIGHT MODE — html[data-theme="light"] (Jul 2026).
   Cream liquid-glass counterpart of the dark default. app.js
   persists "aicorros-theme" and flips the attribute; no attribute
   means dark. Token overrides first, then the few rules whose
   dark values are hardcoded.
   ============================================================ */

html[data-theme="light"] {
  color-scheme: light;

  /* Brand — original deep blue on cream */
  --brand: #09568c;
  --brand-strong: #07456f;
  --brand-tint: rgba(9, 86, 140, 0.1);
  --brand-tint-2: rgba(9, 86, 140, 0.16);

  --sage: #6b675c;
  --sage-deep: #57534a;
  --sage-tint: rgba(28, 39, 51, 0.06);

  /* Surfaces — warm cream */
  --canvas: #f2efe6;
  --cream: #f7f4ea;
  --paper: #fffdf7;
  --line: rgba(15, 23, 32, 0.1);
  --line-soft: rgba(15, 23, 32, 0.07);
  --line-strong: rgba(15, 23, 32, 0.2);
  --surface-hi: #edeade;
  --sunken: #f0ede2;

  /* Ink */
  --ink: #1c2733;
  --ink-soft: #37424e;
  --muted: #5b6572;
  --faint: #616b79;

  /* Status — darkened for ≥4.5:1 on tinted chips */
  --ok: #1e6b3d;   --ok-bg: rgba(46, 125, 79, 0.13);
  --warn: #96590f; --warn-bg: rgba(176, 111, 36, 0.14);
  --bad: #b3362e;  --bad-bg: rgba(179, 54, 46, 0.12);
  --info: #09568c; --info-bg: rgba(9, 86, 140, 0.1);
  --rev: #6d4fa3;  --rev-bg: rgba(109, 79, 163, 0.12);
  --neu: #4c5560;  --neu-bg: rgba(15, 23, 32, 0.07);

  --shadow-pop: 0 12px 40px rgba(28, 39, 51, 0.18);

  /* Chart segments — light-calibrated */
  --seg-1: #09568c;
  --seg-2: #2e7d4f;
  --seg-3: #b06f24;
  --seg-4: #6d4fa3;
  --seg-5: #5b6572;

  /* Liquid glass — cream ambient + light glass */
  --ambient:
    url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E"),
    radial-gradient(1200px 800px at 14% -12%, rgba(9, 86, 140, 0.1), transparent 62%),
    radial-gradient(1050px 720px at 88% 14%, rgba(176, 111, 36, 0.1), transparent 56%),
    radial-gradient(950px 700px at 55% 112%, rgba(46, 125, 79, 0.08), transparent 55%)
    #f2efe6;
  --glass-side: rgba(255, 254, 249, 0.6);
  --glass-top: rgba(255, 254, 249, 0.55);
  --glass-card: rgba(255, 254, 249, 0.65);
  --glass-pop: rgba(255, 254, 249, 0.85);
  --glass-raise: rgba(255, 254, 249, 0.94);
  --glass-input: rgba(255, 255, 255, 0.6);
  --glass-hl: rgba(255, 255, 255, 0.7);
  --thead: rgba(247, 244, 234, 0.92);
  --topbar-fallback: rgba(250, 248, 240, 0.92);
  --focus-ring: rgba(9, 86, 140, 0.2);
  --wash-1: rgba(15, 23, 32, 0.04);
  --wash-2: rgba(15, 23, 32, 0.055);
  --wash-3: rgba(15, 23, 32, 0.07);
  --track: rgba(15, 23, 32, 0.12);
  --scroll-thumb: rgba(15, 23, 32, 0.25);
  --scroll-thumb-hover: rgba(15, 23, 32, 0.4);
  --scrim: rgba(28, 39, 51, 0.35);
}

/* logos un-invert (dark default inverts them to white) */
html[data-theme="light"] .sidebar-brand img,
html[data-theme="light"] .login-brand img { filter: none; }

/* THE one solid button per page becomes deep blue */
html[data-theme="light"] .btn-primary { background: #09568c; color: #ffffff; }
html[data-theme="light"] .btn-primary:hover { background: #0b62a0; color: #ffffff; }
html[data-theme="light"] .btn-primary:disabled {
  background: rgba(9, 86, 140, 0.4);
  color: rgba(255, 255, 255, 0.85);
}

/* text that sits on a solid brand fill flips to white */
html[data-theme="light"] .icon-btn .bubble { color: #ffffff; }
html[data-theme="light"] .pager button.on { color: #ffffff; }
html[data-theme="light"] .src-badge:hover { color: #ffffff; }
html[data-theme="light"] .gate.done .g-dot { color: #ffffff; }

/* banners — dark-mode pastels → readable deep tones */
html[data-theme="light"] .banner.info { color: #0a4a77; border-color: rgba(9, 86, 140, 0.25); }
html[data-theme="light"] .banner.warn { color: #7d4a0e; border-color: rgba(150, 89, 15, 0.3); }
html[data-theme="light"] .banner.danger { color: #922f28; border-color: rgba(179, 54, 46, 0.3); }
html[data-theme="light"] .learn-strip { color: #0a4a77; border-color: rgba(9, 86, 140, 0.25); }

/* chip hairlines re-tinted to the light status hues */
html[data-theme="light"] .chip.blue { border-color: rgba(9, 86, 140, 0.28); }
html[data-theme="light"] .chip.green { border-color: rgba(46, 125, 79, 0.32); }
html[data-theme="light"] .chip.amber { border-color: rgba(150, 89, 15, 0.32); }
html[data-theme="light"] .chip.red { border-color: rgba(179, 54, 46, 0.3); }
html[data-theme="light"] .chip.purple { border-color: rgba(109, 79, 163, 0.3); }
html[data-theme="light"] .chip.neutral { border-color: rgba(15, 23, 32, 0.16); }

/* narrative claim underlines/tints re-tinted */
html[data-theme="light"] .doc-editor .sent.s-ok { border-bottom-color: rgba(46, 125, 79, 0.55); }
html[data-theme="light"] .doc-editor .sent.s-warn { border-bottom-color: rgba(150, 89, 15, 0.55); background: rgba(176, 111, 36, 0.09); }
html[data-theme="light"] .doc-editor .sent.s-bad { border-bottom-color: rgba(179, 54, 46, 0.6); background: rgba(179, 54, 46, 0.07); }

/* selection accents */
html[data-theme="light"] .radio-card.on,
html[data-theme="light"] .role-card.on { border-color: rgba(9, 86, 140, 0.45); }
html[data-theme="light"] .gate.on .g-dot { box-shadow: 0 0 0 4px rgba(9, 86, 140, 0.14); }
html[data-theme="light"] .spinner { border-color: rgba(9, 86, 140, 0.2); border-top-color: var(--brand); }

/* assistant orb — softer shadow + darker rim on cream */
html[data-theme="light"] .aic-ball {
  border-color: rgba(15, 23, 32, 0.18);
  box-shadow:
    0 10px 24px rgba(28, 39, 51, 0.28),
    inset 0 2px 6px rgba(255, 255, 255, 0.9),
    inset 0 -8px 14px rgba(28, 39, 51, 0.18);
}
html[data-theme="light"] .aic-ball::after {
  box-shadow: 0 0 26px 7px rgba(9, 86, 140, 0.22);
}
