/* ============================================================
   Creative Request Ops · styles
   Tokens first (light on :root, dark under both guards), then
   layout, components, views, motion.
   ============================================================ */

:root {
  color-scheme: light;
  /* ground & surfaces */
  --bg: #F3F5F9;
  --grid: rgba(31, 79, 209, 0.055);
  --surface: #FFFFFF;
  --surface-2: #EAEEF5;
  --surface-3: #DFE5EF;
  --border: #D9E0EA;
  --border-strong: #C4CDDB;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px -12px rgba(15, 23, 42, 0.18);
  --shadow-lg: 0 24px 60px -20px rgba(15, 23, 42, 0.35), 0 2px 6px rgba(15, 23, 42, 0.08);
  /* ink */
  --ink: #0F172A;
  --ink-2: #46546B;
  --ink-3: #6B7A90;
  --ink-4: #98A4B8;
  /* accent: blueprint cobalt */
  --accent: #1F4FD1;
  --accent-hover: #183FAF;
  --accent-ink: #FFFFFF;
  --accent-soft: #E6ECFC;
  --accent-soft-2: #CBD8FA;
  --ring: rgba(31, 79, 209, 0.35);
  /* status (reserved) */
  --good: #0B8A3F;
  --good-mark: #16A34A;
  --good-soft: #DDF5E6;
  --warn: #9A4E00;
  --warn-mark: #F59E0B;
  --warn-soft: #FEF1D6;
  --crit: #B42323;
  --crit-mark: #E5484D;
  --crit-soft: #FDE2E2;
  /* stage categorical (validated) */
  --st-start: #64748B;
  --st-content: #1baf7a;
  --st-creative: #4a3aa7;
  --st-review: #eb6834;
  --st-done: #0ca30c;
  /* chart chrome */
  --chart-grid: #E6EAF1;
  --chart-axis: #C9D1DD;
  --series-1: #1F4FD1;
  --series-2: #eb6834;
  --series-mute: #C4CDDB;
  /* type */
  --font-display: "Bricolage Grotesque", "Instrument Sans", system-ui, sans-serif;
  --font-body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  /* radii & spacing */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --nav-w: 252px;
  --nav-rail: 68px;
  --top-h: 60px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0B1120;
    --grid: rgba(123, 152, 255, 0.06);
    --surface: #121A2B;
    --surface-2: #1A2438;
    --surface-3: #232E45;
    --border: #253049;
    --border-strong: #34405C;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, 0.7), 0 2px 6px rgba(0, 0, 0, 0.4);
    --ink: #E6EBF5;
    --ink-2: #A7B3C9;
    --ink-3: #7B889E;
    --ink-4: #56627A;
    --accent: #7B98FF;
    --accent-hover: #93ABFF;
    --accent-ink: #0B1120;
    --accent-soft: #1B2749;
    --accent-soft-2: #26377A;
    --ring: rgba(123, 152, 255, 0.45);
    --good: #6EE7A0;
    --good-mark: #4ADE80;
    --good-soft: #10331F;
    --warn: #FCD34D;
    --warn-mark: #FBBF24;
    --warn-soft: #3A2A0B;
    --crit: #FCA5A5;
    --crit-mark: #F87171;
    --crit-soft: #3F1616;
    --st-start: #8B98AC;
    --st-content: #199e70;
    --st-creative: #9085e9;
    --st-review: #d95926;
    --st-done: #3DBE3D;
    --chart-grid: #1E2941;
    --chart-axis: #34405C;
    --series-1: #7B98FF;
    --series-2: #d95926;
    --series-mute: #34405C;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0B1120;
  --grid: rgba(123, 152, 255, 0.06);
  --surface: #121A2B;
  --surface-2: #1A2438;
  --surface-3: #232E45;
  --border: #253049;
  --border-strong: #34405C;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, 0.7), 0 2px 6px rgba(0, 0, 0, 0.4);
  --ink: #E6EBF5;
  --ink-2: #A7B3C9;
  --ink-3: #7B889E;
  --ink-4: #56627A;
  --accent: #7B98FF;
  --accent-hover: #93ABFF;
  --accent-ink: #0B1120;
  --accent-soft: #1B2749;
  --accent-soft-2: #26377A;
  --ring: rgba(123, 152, 255, 0.45);
  --good: #6EE7A0;
  --good-mark: #4ADE80;
  --good-soft: #10331F;
  --warn: #FCD34D;
  --warn-mark: #FBBF24;
  --warn-soft: #3A2A0B;
  --crit: #FCA5A5;
  --crit-mark: #F87171;
  --crit-soft: #3F1616;
  --st-start: #8B98AC;
  --st-content: #199e70;
  --st-creative: #9085e9;
  --st-review: #d95926;
  --st-done: #3DBE3D;
  --chart-grid: #1E2941;
  --chart-axis: #34405C;
  --series-1: #7B98FF;
  --series-2: #d95926;
  --series-mute: #34405C;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; }
h1 { font-size: 26px; line-height: 1.2; }
h2 { font-size: 18px; line-height: 1.3; }
h3 { font-size: 15px; line-height: 1.35; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
svg { display: block; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.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; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }
::selection { background: var(--accent-soft-2); }

.icon { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon.sm { width: 14px; height: 14px; }
.icon.lg { width: 22px; height: 22px; }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: var(--nav-w) 1fr; min-height: 100vh; }
.app.rail { grid-template-columns: var(--nav-rail) 1fr; }

.nav {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 14px 12px;
  gap: 4px;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: linear-gradient(135deg, var(--accent), #5B7CFF 70%, #8FB0FF);
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 6px 16px -6px var(--ring);
}
.brand-mark svg { width: 18px; height: 18px; stroke: #fff; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: -0.015em; line-height: 1.1; white-space: nowrap; }
.brand-sub { font-size: 11px; color: var(--ink-3); letter-spacing: 0.06em; text-transform: uppercase; margin-top: 3px; }
.nav-section { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-4); padding: 12px 10px 4px; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--r-md);
  color: var(--ink-2); background: transparent; border: 0; width: 100%; text-align: left;
  transition: background .18s var(--ease-out), color .18s var(--ease-out), transform .18s var(--ease-out);
  position: relative; min-height: 40px;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-item .badge { margin-left: auto; }
.nav-spacer { flex: 1; }
.nav-foot { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 6px; }
.rail .nav .brand-name, .rail .nav .brand-sub, .rail .nav-item span, .rail .nav-section { display: none; }
.rail .nav-item { justify-content: center; padding: 10px; }
.rail .nav-item .badge { position: absolute; top: 4px; right: 4px; margin: 0; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 15;
  height: var(--top-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .title { font-family: var(--font-display); font-weight: 600; font-size: 17px; margin-right: 6px; }
.search { position: relative; flex: 1; max-width: 420px; }
.search input { width: 100%; padding: 8px 12px 8px 36px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.topbar .grow { flex: 1; }
.content {
  padding: 24px; flex: 1;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px;
  background-position: -1px -1px;
}
.page { max-width: 1440px; margin: 0 auto; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .lede { color: var(--ink-3); margin-top: 4px; max-width: 60ch; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 14px; border-radius: var(--r-md); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--ink); font-weight: 500; line-height: 1.2;
  min-height: 40px; white-space: nowrap;
  transition: background .18s var(--ease-out), border-color .18s, transform .12s var(--ease-out), box-shadow .18s, color .18s;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-4); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 14px -8px var(--ring); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.good { background: var(--good-mark); border-color: var(--good-mark); color: #fff; }
.btn.good:hover { filter: brightness(1.05); }
.btn.danger { color: var(--crit); border-color: var(--crit-mark); background: transparent; }
.btn.danger:hover { background: var(--crit-soft); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.sm { padding: 6px 10px; min-height: 32px; font-size: 13px; border-radius: 8px; }
.btn.icon-only { padding: 8px; width: 40px; }
.btn.icon-only.sm { width: 32px; padding: 6px; }
.btn.block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--ink-3); }
.field .error { font-size: 12px; color: var(--crit); }
.input, select.input, textarea.input {
  width: 100%; padding: 9px 12px; border-radius: var(--r-md);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  min-height: 40px; transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.input::placeholder { color: var(--ink-4); }
.input[aria-invalid="true"] { border-color: var(--crit-mark); }
textarea.input { min-height: 96px; resize: vertical; line-height: 1.5; }
select.input { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.input.sm { min-height: 32px; padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.switch { position: relative; width: 40px; height: 22px; border-radius: 999px; background: var(--surface-3); border: 0; transition: background .2s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s var(--ease-out); }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; min-height: 32px; transition: background .18s, color .18s, box-shadow .18s; }
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(15,23,42,.12); }

/* chips & badges */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 18px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.outline { background: transparent; border: 1px solid var(--border-strong); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.crit { background: var(--crit-soft); color: var(--crit); }
.chip.stage { color: var(--stage, var(--ink-2)); background: color-mix(in srgb, var(--stage, var(--ink-2)) 14%, transparent); }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--accent); color: var(--accent-ink); font-family: var(--font-mono); }
.badge.crit { background: var(--crit-mark); color: #fff; }
.prio { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.prio i { width: 8px; height: 8px; border-radius: 2px; background: var(--ink-4); display: inline-block; transform: rotate(45deg); }
.prio.p-high i { background: var(--warn-mark); }
.prio.p-urgent i { background: var(--crit-mark); }
.prio.p-low i { background: var(--ink-4); opacity: .5; }

.avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; letter-spacing: .02em; color: #fff; background: var(--ink-3); flex: none; font-family: var(--font-mono); }
.avatar.sm { width: 22px; height: 22px; font-size: 9px; }
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }
.avatar.empty { background: transparent; border: 1.5px dashed var(--border-strong); color: var(--ink-4); }
.avatar.sample { background: var(--surface-3); color: var(--ink-2); border: 1px dashed var(--ink-4); }
.who { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.who .name { font-weight: 500; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* cards & panels */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 0; }
.panel-head h2 { font-size: 15px; }
.panel-head .sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.panel-body { padding: 16px 18px 18px; }
.grid { display: grid; gap: 16px; }
.grid.kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.charts { grid-template-columns: 1fr 1fr; }
.grid.charts > .span-2 { grid-column: span 2; }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.divider { height: 1px; background: var(--border); margin: 12px 0; }

/* KPI tile */
.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; min-height: 108px; position: relative; overflow: hidden; }
.kpi .k-label { font-size: 12.5px; color: var(--ink-3); font-weight: 600; letter-spacing: .01em; }
.kpi .k-value { font-size: 32px; font-weight: 600; line-height: 1.05; letter-spacing: -0.02em; font-family: var(--font-body); }
.kpi .k-foot { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; margin-top: auto; }
.kpi.attention .k-value { color: var(--crit); }
.kpi.attention::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--crit-mark); }
.kpi.mine .k-value { color: var(--accent); }
.kpi .spark { position: absolute; right: 14px; bottom: 12px; opacity: .9; }

/* SLA meter */
.meter { height: 6px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; position: relative; }
.meter > i { display: block; height: 100%; border-radius: 999px; background: var(--accent); width: 0; transition: width .6s var(--ease-out); }
.meter.warn { background: var(--warn-soft); } .meter.warn > i { background: var(--warn-mark); }
.meter.crit { background: var(--crit-soft); } .meter.crit > i { background: var(--crit-mark); }
.meter.none { background: var(--surface-2); }
.sla-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--ink-3); }
.sla-line .t { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--ink-2); }
.sla-line .crit { color: var(--crit); font-weight: 600; }
.sla-line .warn { color: var(--warn); font-weight: 600; }
.breach-flag { display: inline-flex; align-items: center; gap: 5px; color: var(--crit); font-size: 12px; font-weight: 700; }
.breach-flag .icon { width: 14px; height: 14px; }
.pulse { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

/* ---------- board ---------- */
.board-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.board-tools .spacer { flex: 1; }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(280px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: start; scroll-snap-type: x proximity; }
.col { background: color-mix(in srgb, var(--surface) 70%, var(--bg)); border: 1px solid var(--border); border-radius: var(--r-lg); min-height: 240px; display: flex; flex-direction: column; scroll-snap-align: start; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); position: sticky; top: 0; }
.col-head .swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--stage); }
.col-head h3 { font-size: 14px; font-family: var(--font-body); font-weight: 600; }
.col-head .count { margin-left: auto; font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); }
.col-head .sla { font-size: 11px; color: var(--ink-3); font-family: var(--font-mono); }
.col-body { padding: 10px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.col-empty { border: 1.5px dashed var(--border); border-radius: var(--r-md); padding: 22px 12px; text-align: center; color: var(--ink-4); font-size: 13px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 12px 12px 12px 14px; cursor: pointer; position: relative;
  box-shadow: 0 1px 2px rgba(15,23,42,.05);
  transition: transform .18s var(--ease-out), box-shadow .18s var(--ease-out), border-color .18s;
  display: flex; flex-direction: column; gap: 9px;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.card::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--stage, var(--border-strong)); }
.card.breached { border-color: color-mix(in srgb, var(--crit-mark) 55%, var(--border)); }
.card .c-top { display: flex; align-items: center; gap: 8px; }
.card .c-id { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-3); font-weight: 500; }
.card .c-title { font-weight: 600; font-size: 14px; line-height: 1.35; color: var(--ink); }
.card .c-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card .c-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card .round { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); border: 1px solid var(--border); border-radius: 6px; padding: 0 5px; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl th button { border: 0; background: none; padding: 0; font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit; display: inline-flex; align-items: center; gap: 4px; }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .15s; }
.tbl tbody tr.link { cursor: pointer; }
.tbl tbody tr.link:hover { background: var(--surface-2); }
.tbl .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tbl td.actions { text-align: right; white-space: nowrap; }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.list-item:last-child { border-bottom: 0; }
.list-item:hover .li-title { color: var(--accent); }
.li-main { flex: 1; min-width: 0; }
.li-title { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: color .15s; }
.li-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-side { text-align: right; font-size: 12px; color: var(--ink-3); flex: none; }
.empty { padding: 28px 16px; text-align: center; color: var(--ink-3); font-size: 13.5px; }
.empty .icon { margin: 0 auto 8px; width: 28px; height: 28px; color: var(--ink-4); }

/* activity */
.act { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.act:last-child { border-bottom: 0; }
.act .ico { width: 28px; height: 28px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; color: var(--ink-2); flex: none; }
.act .ico.good { background: var(--good-soft); color: var(--good); }
.act .ico.crit { background: var(--crit-soft); color: var(--crit); }
.act .ico.accent { background: var(--accent-soft); color: var(--accent); }
.act .txt { flex: 1; min-width: 0; }
.act .txt b { font-weight: 600; }
.act .when { color: var(--ink-3); font-size: 12px; white-space: nowrap; }

/* ---------- charts ---------- */
.chart { width: 100%; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font-body); font-size: 12px; fill: var(--ink-3); }
.chart .lbl { fill: var(--ink-2); font-weight: 500; }
.chart .val { fill: var(--ink); font-weight: 600; font-family: var(--font-mono); font-size: 11.5px; }
.chart .grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis { stroke: var(--chart-axis); stroke-width: 1; }
.chart .bar { transition: opacity .15s; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover + .bar, .chart .hit:focus + .bar { opacity: .8; }
.chart .hit:hover + .cols .bar, .chart .hit:focus + .cols .bar { opacity: .82; }
.chart-cols svg { max-height: 260px; }
.chart .target { stroke: var(--ink); stroke-width: 2; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { opacity: .1; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .crosshair { stroke: var(--ink-4); stroke-width: 1; opacity: 0; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin-top: 8px; }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .key i { width: 14px; height: 3px; border-radius: 2px; background: var(--c); display: inline-block; }
.legend .key i.rect { width: 10px; height: 10px; border-radius: 3px; }
.tip { position: fixed; z-index: 100; pointer-events: none; background: var(--ink); color: var(--bg); padding: 8px 10px; border-radius: 8px; font-size: 12px; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s; max-width: 260px; }
.tip.show { opacity: 1; transform: translateY(0); }
.tip .t-title { font-weight: 600; margin-bottom: 4px; opacity: .8; }
.tip .t-row { display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tip .t-row i { width: 10px; height: 3px; border-radius: 2px; background: var(--c); }
.tip .t-row b { font-weight: 600; }
.tip .t-row span { opacity: .8; }
.bullet-row { display: grid; grid-template-columns: 104px 1fr 112px; align-items: center; gap: 12px; padding: 7px 0; }
.bullet-row .b-label { font-size: 12.5px; line-height: 1.2; font-weight: 500; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.bullet-row .b-label i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }
.bullet-track { position: relative; height: 22px; background: var(--surface-2); border-radius: 4px; overflow: visible; }
.bullet-track .fill { position: absolute; left: 0; top: 4px; bottom: 4px; width: 0; background: var(--series-1); border-radius: 0 4px 4px 0; transition: width .7s var(--ease-out); }
.bullet-track .fill.over { background: var(--crit-mark); }
.bullet-track .tgt { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); transform: translateX(-1px); }
.bullet-track .tgt::after { content: ""; position: absolute; top: -4px; left: -3px; width: 8px; height: 4px; background: var(--ink); border-radius: 2px 2px 0 0; }
.bullet-row .b-val { font-family: var(--font-mono); font-size: 12px; color: var(--ink-2); text-align: right; font-variant-numeric: tabular-nums; }
.bullet-row .b-val b { color: var(--ink); }
.bullet-row .b-val.over b { color: var(--crit); }

/* ---------- drawer / modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(8, 12, 24, .45); z-index: 40; backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); background: var(--surface); z-index: 50; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; border-left: 1px solid var(--border); }
.drawer-head { padding: 18px 22px 14px; border-bottom: 1px solid var(--border); display: flex; gap: 12px; align-items: flex-start; }
.drawer-head .grow { flex: 1; min-width: 0; }
.drawer-head h2 { font-size: 19px; margin-top: 4px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 22px 40px; display: flex; flex-direction: column; gap: 20px; }
.drawer-body > * { flex-shrink: 0; }
.section-title { font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; margin-bottom: 8px; }
.brief { white-space: pre-wrap; font-size: 14px; line-height: 1.55; color: var(--ink-2); }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px 16px; }
.kv .k { font-size: 12px; color: var(--ink-3); }
.kv .v { font-size: 13.5px; font-weight: 500; }
.action-panel { background: var(--surface-2); border-radius: var(--r-lg); padding: 16px; display: flex; flex-direction: column; gap: 12px; border: 1px solid var(--border); }
.action-panel.review { background: color-mix(in srgb, var(--warn-soft) 55%, var(--surface)); }
.action-panel.done { background: var(--good-soft); }
.action-panel h3 { font-family: var(--font-body); font-size: 14px; }
.action-panel .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.deliverable { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--r-md); font-size: 13px; }
.deliverable a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deliverable .who-when { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; }
.thread { display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; gap: 10px; }
.msg .bubble { background: var(--surface-2); border-radius: 12px; padding: 9px 12px; font-size: 13.5px; flex: 1; min-width: 0; }
.msg .bubble .m-head { display: flex; gap: 8px; align-items: baseline; margin-bottom: 3px; }
.msg .bubble .m-head b { font-size: 13px; }
.msg .bubble .m-head span { font-size: 11.5px; color: var(--ink-3); }
.msg .bubble .m-text { white-space: pre-wrap; }
.msg.edit .bubble { background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn-mark) 40%, transparent); }
.msg.approval .bubble { background: var(--good-soft); }
.msg.system .bubble { background: transparent; border: 1px dashed var(--border); color: var(--ink-3); font-size: 12.5px; }

/* stepper */
.stepper { display: flex; align-items: stretch; gap: 0; overflow-x: auto; padding: 4px 0 6px; }
.step { flex: 1; min-width: 92px; position: relative; padding: 0 6px; text-align: center; }
.step .node { width: 26px; height: 26px; border-radius: 50%; margin: 0 auto 6px; display: grid; place-items: center; border: 2px solid var(--border-strong); background: var(--surface); color: var(--ink-3); font-size: 11px; font-weight: 700; font-family: var(--font-mono); position: relative; z-index: 1; }
.step::before { content: ""; position: absolute; top: 12px; left: -50%; right: 50%; height: 2px; background: var(--border); z-index: 0; }
.step:first-child::before { display: none; }
.step.done .node { background: var(--stage); border-color: var(--stage); color: #fff; }
.step.done::before { background: var(--stage); }
.step.current .node { border-color: var(--stage); color: var(--stage); box-shadow: 0 0 0 4px color-mix(in srgb, var(--stage) 22%, transparent); }
.step.current::before { background: var(--stage); }
.step .s-name { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.step .s-time { font-size: 11px; font-family: var(--font-mono); color: var(--ink-3); margin-top: 1px; }
.step .s-time.crit { color: var(--crit); font-weight: 600; }
.step.current .s-name { color: var(--ink); }

/* timeline */
.timeline { display: flex; flex-direction: column; }
.tl { display: grid; grid-template-columns: 18px 1fr; gap: 10px; padding: 8px 0; position: relative; }
.tl::before { content: ""; position: absolute; left: 8px; top: 24px; bottom: -8px; width: 2px; background: var(--border); }
.tl:last-child::before { display: none; }
.tl .dot { width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 2px solid var(--stage, var(--border-strong)); position: relative; z-index: 1; margin-top: 2px; }
.tl .dot.filled { background: var(--stage); }
.tl .t-main { font-size: 13px; }
.tl .t-main b { font-weight: 600; }
.tl .t-sub { font-size: 12px; color: var(--ink-3); font-family: var(--font-mono); margin-top: 2px; display: flex; gap: 10px; flex-wrap: wrap; }
.tl .t-sub .crit { color: var(--crit); font-weight: 600; }
.tl .t-sub .good { color: var(--good); font-weight: 600; }

.modal-wrap { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; overflow-y: auto; }
.modal { width: min(680px, 100%); background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); border: 1px solid var(--border); max-height: calc(100vh - 40px); display: flex; flex-direction: column; }
.modal-head { padding: 20px 24px 12px; display: flex; align-items: flex-start; gap: 12px; }
.modal-head h2 { font-size: 20px; }
.modal-head p { color: var(--ink-3); font-size: 13.5px; margin-top: 3px; }
.modal-body { padding: 8px 24px 20px; overflow-y: auto; }
.modal-foot { padding: 14px 24px 20px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--border); }
.modal.sm { width: min(460px, 100%); }

/* toast */
.toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 500; max-width: min(520px, calc(100vw - 32px)); }
.toast .icon { color: var(--good-mark); }
.toast.crit .icon { color: var(--crit-mark); }
.toast.info .icon { color: var(--accent); }

/* ---------- sign in ---------- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 32px 32px; }
.gate-card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); padding: 30px 30px 26px; display: flex; flex-direction: column; gap: 18px; }
.gate-card h1 { font-size: 24px; }
.gate-card .lede { color: var(--ink-3); font-size: 14px; }
.gate-foot { font-size: 12px; color: var(--ink-3); text-align: center; }
.mode-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); }
.mode-pill.live { background: var(--good-soft); color: var(--good); }
.mode-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- team / flow / settings ---------- */
.role-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c); }
.role-chip i { width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.role-picks { display: flex; gap: 8px; flex-wrap: wrap; }
.role-picks .check { border: 1px solid var(--border-strong); border-radius: 999px; padding: 5px 11px 5px 8px; font-size: 13px; }
.role-picks .check:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.flow-diagram { display: flex; align-items: stretch; gap: 0; overflow-x: auto; padding: 8px 0 4px; }
.flow-node { flex: 1; min-width: 150px; display: flex; flex-direction: column; gap: 4px; position: relative; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); margin-right: 26px; }
.flow-node:last-child { margin-right: 0; }
.flow-node::after { content: ""; position: absolute; right: -26px; top: 50%; width: 26px; height: 2px; background: var(--border-strong); }
.flow-node:last-child::after { display: none; }
.flow-node .fn-arrow { position: absolute; right: -14px; top: calc(50% - 5px); width: 0; height: 0; border-left: 6px solid var(--border-strong); border-top: 5px solid transparent; border-bottom: 5px solid transparent; }
.flow-node:last-child .fn-arrow { display: none; }
.flow-node .fn-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.flow-node .fn-name i { width: 10px; height: 10px; border-radius: 3px; background: var(--stage); }
.flow-node .fn-meta { font-size: 12px; color: var(--ink-3); }
.flow-node .fn-meta b { color: var(--ink-2); font-family: var(--font-mono); font-weight: 500; }
.flow-node .fn-loop { font-size: 11px; color: var(--warn); font-weight: 600; }
.stage-editor { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; padding: 12px 0; border-bottom: 1px solid var(--border); }
.stage-editor:last-of-type { border-bottom: 0; }
.se-idx { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); width: 20px; text-align: center; padding-bottom: 9px; }
.se-field { display: flex; flex-direction: column; gap: 4px; flex: 0 1 150px; min-width: 120px; }
.se-field > label { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.se-field.se-name { flex: 1 1 220px; }
.se-field.se-sla { flex: 0 0 84px; min-width: 84px; }
.se-field.se-check { flex: 0 0 auto; min-width: 0; padding-bottom: 6px; }
.se-ops { display: flex; gap: 4px; margin-left: auto; padding-bottom: 1px; }
.color-dot-input { width: 36px; height: 36px; padding: 2px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); cursor: pointer; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border-radius: 8px; padding: 4px 6px 4px 10px; font-size: 13px; }
.tag button { border: 0; background: transparent; padding: 2px; color: var(--ink-3); display: grid; place-items: center; border-radius: 4px; }
.tag button:hover { color: var(--crit); background: var(--crit-soft); }
.callout { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: 10px 14px; border-radius: 0 var(--r-md) var(--r-md) 0; font-size: 13px; color: var(--ink-2); }
.callout.warn { border-color: var(--warn-mark); background: var(--warn-soft); }
.callout b { color: var(--ink); }
.days { display: flex; gap: 4px; }
.days label { width: 36px; height: 32px; display: grid; place-items: center; border: 1px solid var(--border-strong); border-radius: 8px; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.days label:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.days input { position: absolute; opacity: 0; width: 0; height: 0; }

/* bottom nav (mobile) */
.bottom-nav { display: none; }

/* skeleton */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .grid.kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid.charts { grid-template-columns: 1fr 1fr; }
  .grid.charts > :last-child { grid-column: span 2; }
}
@media (max-width: 1023px) {
  .app, .app.rail { grid-template-columns: var(--nav-rail) 1fr; }
  .nav .brand-name, .nav .brand-sub, .nav .nav-item span, .nav .nav-section { display: none; }
  .nav .nav-item { justify-content: center; padding: 10px; }
  .nav-item .badge { position: absolute; top: 4px; right: 4px; margin: 0; }
}
@media (max-width: 767px) {
  .app, .app.rail { grid-template-columns: 1fr; }
  .nav { display: none; }
  .bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--border); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; }
  .bottom-nav .nav-item { flex-direction: column; gap: 3px; font-size: 10.5px; padding: 6px 4px; min-width: 56px; }
  .bottom-nav .nav-item.active::before { display: none; }
  .bottom-nav .nav-item .badge { position: absolute; top: 2px; right: 6px; margin: 0; }
  .bottom-nav .nav-item span { display: block; }
  .content { padding: 16px 14px 90px; }
  .topbar { padding: 0 14px; }
  .topbar .title { display: none; }
  .grid.kpis, .grid.two, .grid.three, .grid.charts { grid-template-columns: 1fr; }
  .grid.charts > :last-child, .grid.charts > .span-2 { grid-column: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .board { grid-auto-columns: minmax(84vw, 1fr); }
  .kv { grid-template-columns: 1fr; }
  .se-idx { display: none; }
  .se-field { flex: 1 1 45%; }
  .bullet-row { grid-template-columns: 80px 1fr 100px; }
  .drawer-head, .drawer-body { padding-left: 16px; padding-right: 16px; }
  .modal-head, .modal-body, .modal-foot { padding-left: 16px; padding-right: 16px; }
}

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

/* ---------- Clerk sign-in ---------- */
.gate-card.auth { width: min(520px, 100%); }
.clerk-mount { display: flex; justify-content: center; min-height: 120px; }
.clerk-mount .cl-rootBox { width: 100%; }
.clerk-mount .cl-cardBox { width: 100%; box-shadow: none; border: 1px solid var(--border); }
.nav-foot .clerk-user { display: flex; align-items: center; gap: 10px; padding: 8px 10px; min-height: 44px; }
.nav-foot .clerk-user .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; color: var(--ink-2); }
.rail .nav-foot .clerk-user .name, .rail .nav-foot .clerk-user .role { display: none; }
@media (max-width: 1023px) { .nav .clerk-user .name, .nav .clerk-user .role { display: none; } }
.setup-banner { background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid color-mix(in srgb, var(--warn-mark) 40%, transparent); padding: 8px 24px; font-size: 13px; display: flex; gap: 10px; align-items: center; }
.setup-banner b { color: var(--ink); }
