/* Biz Macros — The Queer Gym
   Aubergine rail, condensed athletic headings, quiet data surfaces. */

@font-face {
  font-family: "Big Shoulders Display";
  src: url("fonts/big-shoulders-display.woff") format("woff");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Sans";
  src: url("fonts/instrument-sans.woff") format("woff");
  font-weight: 400 700;
  font-stretch: 75% 100%;
  font-display: swap;
}

:root {
  --plane: #f4f3f7;
  --surface: #ffffff;
  --surface-2: #f9f8fb;
  --ink: #1d1826;
  --ink-2: #4e4859;
  --muted: #7d768a;
  --line: #e6e3ec;
  --line-strong: #d2cddb;
  --rail: #2b1a40;
  --rail-2: #36224f;
  --rail-ink: #f1ecf8;
  --rail-muted: #ad9fc4;
  --accent: #6a3de8;
  --accent-strong: #5527d6;
  --accent-wash: #f0eafd;
  --good: #0ca30c;
  --good-ink: #116611;
  --good-wash: #e8f5e6;
  --warning: #fab219;
  --warning-ink: #7a5200;
  --warning-wash: #fff3d6;
  --serious: #ec835a;
  --critical: #d03b3b;
  --critical-ink: #a32828;
  --critical-wash: #fbebeb;
  --neutral-wash: #efedf3;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --deemph: #c9c4d3;
  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 16px;
  --font-ui: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Big Shoulders Display", "Arial Narrow", "Instrument Sans", system-ui, sans-serif;
  --rail-w: 236px;
  --shadow-pop: 0 12px 32px rgba(29, 24, 38, .16), 0 2px 6px rgba(29, 24, 38, .08);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--plane);
}
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon { flex: none; vertical-align: -3px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.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; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---------- shell ---------- */
.shell {
  display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100vh;
  background: linear-gradient(90deg, var(--rail) var(--rail-w), transparent var(--rail-w));
}
.rail {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--rail); color: var(--rail-ink);
  display: flex; flex-direction: column; padding: 0 0 14px;
}
.brand { padding: 0 20px 14px; }
.brand-stripe { display: flex; height: 6px; margin: 0 -20px 18px; }
.brand-stripe i { flex: 1; }
.brand-stripe i:nth-child(1) { background: #e40303; }
.brand-stripe i:nth-child(2) { background: #ff8c00; }
.brand-stripe i:nth-child(3) { background: #ffed00; }
.brand-stripe i:nth-child(4) { background: #008026; }
.brand-stripe i:nth-child(5) { background: #004dff; }
.brand-stripe i:nth-child(6) { background: #750787; }
.wordmark {
  display: block; font-family: var(--font-display); font-weight: 800; font-size: 34px;
  line-height: .9; letter-spacing: .01em; color: #fff; text-decoration: none;
}
.wordmark:hover { text-decoration: none; }
.brand-sub { display: block; margin-top: 6px; font-size: 12.5px; color: var(--rail-muted); }
.rail-search { margin: 4px 14px 10px; position: relative; }
.rail-search input {
  width: 100%; height: 34px; border-radius: var(--radius-s); border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.07); color: #fff; padding: 0 10px 0 32px;
}
.rail-search input::placeholder { color: var(--rail-muted); }
.rail-search .icon { position: absolute; left: 10px; top: 9px; color: var(--rail-muted); }
.nav-group { padding: 8px 10px 4px; }
.nav-label { padding: 6px 10px 4px; font-size: 12px; color: var(--rail-muted); }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-s);
  color: var(--rail-ink); text-decoration: none; font-size: 14px;
}
.nav a .icon { color: var(--rail-muted); }
.nav a:hover { background: rgba(255,255,255,.06); }
.nav a[aria-current="page"] { background: var(--rail-2); box-shadow: inset 3px 0 0 #fff; }
.nav a[aria-current="page"] .icon { color: #fff; }
.nav .count { margin-left: auto; font-size: 12px; color: var(--rail-muted); font-variant-numeric: tabular-nums; }
.rail-foot { margin-top: auto; padding: 12px 20px 0; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.rail-foot .who { color: var(--rail-ink); font-weight: 600; }
.rail-foot form { display: inline; }
.rail-foot button { background: none; border: 0; padding: 0; color: var(--rail-muted); cursor: pointer; font-size: 13px; }
.rail-foot button:hover { color: #fff; }
.menu-toggle { display: none; }

.main { min-width: 0; padding: 26px 32px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-title {
  margin: 0; font-family: var(--font-display); font-weight: 800; font-size: 40px; line-height: .95;
  letter-spacing: .005em; color: var(--ink);
}
.page-sub { margin: 6px 0 0; color: var(--ink-2); max-width: 70ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.section-title { font-size: 16px; font-weight: 650; margin: 28px 0 10px; }
.section-title small { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 6px; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 13px;
  border-radius: var(--radius-s); border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink); font-weight: 550; font-size: 13.5px; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { border-color: #b9b2c6; text-decoration: none; background: var(--surface-2); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover { background: var(--neutral-wash); border-color: transparent; }
.btn--danger { color: var(--critical-ink); }
.btn--danger:hover { background: var(--critical-wash); border-color: #e9b9b9; }
.btn--sm { height: 28px; padding: 0 9px; font-size: 12.5px; }
.btn[disabled] { opacity: .55; cursor: default; }
.icon-btn {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: var(--radius-s);
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--neutral-wash); color: var(--ink); }

.input, .select, .textarea, .form-grid input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), .form-grid select, .form-grid textarea {
  height: 34px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-s);
  background: var(--surface); min-width: 0;
}
.textarea, .form-grid textarea { height: auto; padding: 8px 10px; min-height: 84px; resize: vertical; width: 100%; }
.input:focus, .select:focus, .textarea:focus, .form-grid input:not([type="checkbox"]):not([type="radio"]):focus, .form-grid select:focus, .form-grid textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(106, 61, 232, .18);
}
.select { padding-right: 28px; }
.input[type="file"] { padding: 4px 6px; height: 36px; color: var(--ink-2); }
.input[type="file"]::file-selector-button {
  height: 26px; margin-right: 10px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-s);
  background: var(--surface-2); color: var(--ink); font: inherit; font-size: 13px; cursor: pointer;
}
label { font-size: 13px; color: var(--ink-2); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 13px; color: var(--ink-2); font-weight: 550; }
.field .hint { font-size: 12.5px; color: var(--muted); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--ink); }
.check input, .form-grid input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
.form-grid { display: grid; gap: 14px; }
.form-grid fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 10px; }
.form-grid legend { font-weight: 650; font-size: 14px; margin-bottom: 6px; color: var(--ink); }
.form-grid label:not(.check) { display: flex; flex-direction: column; gap: 5px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }

/* ---------- filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filters .input { width: 240px; }
.filters .grow { flex: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); font-size: 13px; color: var(--ink-2); text-decoration: none;
}
.chip:hover { text-decoration: none; border-color: #b9b2c6; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- notices / toasts ---------- */
.notice { padding: 10px 14px; border-radius: var(--radius-s); background: var(--accent-wash); color: var(--ink); margin-bottom: 14px; border: 1px solid #ddd0fb; }
.notice--error { background: var(--critical-wash); border-color: #efc1c1; color: var(--critical-ink); }
.notice--success { background: var(--good-wash); border-color: #c2e3bd; color: var(--good-ink); }
.notice--warn { background: var(--warning-wash); border-color: #f1d79c; color: var(--warning-ink); }
.toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 90; display: grid; gap: 8px; }
.toast {
  background: var(--rail); color: #fff; padding: 9px 14px; border-radius: 999px; font-size: 13.5px;
  box-shadow: var(--shadow-pop); display: flex; gap: 12px; align-items: center;
}
.toast button { background: none; border: 0; color: #d6c8ff; font-weight: 600; cursor: pointer; padding: 0; }
.toast--error { background: var(--critical-ink); }

/* ---------- KPI band ---------- */
.band {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); margin-bottom: 14px;
}
.band > .kpi { padding: 14px 16px 13px; border-left: 1px solid var(--line); min-width: 0; }
.band > .kpi:first-child { border-left: 0; }
.kpi-label { font-size: 12.5px; color: var(--ink-2); display: flex; gap: 6px; align-items: center; }
.kpi-value { font-size: 24px; font-weight: 650; letter-spacing: -.01em; margin-top: 3px; line-height: 1.15; }
.kpi-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.band-title { grid-column: 1 / -1; padding: 10px 16px; border-bottom: 1px solid var(--line); font-weight: 650; font-size: 13.5px; display: flex; justify-content: space-between; gap: 10px; }
.band-title .muted { font-weight: 400; }
.goal { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 999px; margin-top: 4px; white-space: nowrap; }
.goal--good { background: var(--good-wash); color: var(--good-ink); }
.goal--bad { background: var(--critical-wash); color: var(--critical-ink); }

/* ---------- status pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12.5px; font-weight: 550; background: var(--neutral-wash); color: var(--ink-2); white-space: nowrap; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill--good { background: var(--good-wash); color: var(--good-ink); }
.pill--bad { background: var(--critical-wash); color: var(--critical-ink); }
.pill--warn { background: var(--warning-wash); color: var(--warning-ink); }
.pill--info { background: var(--accent-wash); color: var(--accent-strong); }
.pill--off { background: var(--neutral-wash); color: var(--muted); }

/* ---------- data table ---------- */
.table-wrap {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m);
  overflow: auto; max-height: calc(100vh - 150px); position: relative;
}
.datatable { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13.5px; }
.datatable th, .datatable td { padding: 0 10px; height: 38px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.datatable thead th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2); font-size: 12.5px; font-weight: 600; color: var(--ink-2);
  border-bottom: 1px solid var(--line-strong); height: 36px;
}
.datatable thead th a { color: inherit; display: inline-flex; gap: 4px; align-items: center; }
.datatable thead th a:hover { color: var(--ink); text-decoration: none; }
.datatable thead th.sorted { color: var(--ink); }
.datatable tbody tr:hover td { background: #fbfaff; }
.datatable tbody tr:last-child td { border-bottom: 0; }
.datatable td.num, .datatable th.num { text-align: right; font-variant-numeric: tabular-nums; }
.datatable td.cell { cursor: text; position: relative; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.datatable td.cell:hover { box-shadow: inset 0 0 0 1px var(--line-strong); }
.datatable td.cell.is-saving { color: var(--muted); }
.datatable td.cell.is-saved { animation: saved 1.2s ease-out; }
.datatable td.cell.is-error { box-shadow: inset 0 0 0 2px var(--critical); }
@keyframes saved { from { background: var(--good-wash); } to { background: transparent; } }
.datatable td.editing { padding: 0; box-shadow: inset 0 0 0 2px var(--accent); }
.datatable td.editing input, .datatable td.editing select, .datatable td.editing textarea {
  width: 100%; height: 37px; border: 0; padding: 0 9px; background: #fff; outline: none; min-width: 120px;
}
.datatable td.editing textarea { height: 90px; padding: 8px 9px; position: absolute; left: 0; top: 0; z-index: 5; box-shadow: var(--shadow-pop); min-width: 260px; }
.datatable td.bool { text-align: center; cursor: default; }
.datatable td.bool input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; vertical-align: middle; }
.datatable td.cell .empty { color: #c4bfcd; }
.datatable td.row-actions { width: 1%; padding: 0 6px; text-align: right; }
.datatable .row-end { position: sticky; right: 0; z-index: 1; background: var(--surface); }
.datatable thead th.row-end { z-index: 3; background: var(--surface-2); }
.datatable tbody tr:hover td.row-end { background: #fbfaff; }
.table-wrap.has-overflow .row-end { box-shadow: inset 1px 0 0 var(--line), -8px 0 10px -8px rgba(43, 26, 64, .18); }
.datatable tr .row-actions .icon-btn { opacity: .0; }
.datatable tr:hover .row-actions .icon-btn, .datatable tr:focus-within .row-actions .icon-btn { opacity: 1; }
.datatable .person { font-weight: 600; color: var(--ink); cursor: pointer; }
.datatable .person:hover { color: var(--accent-strong); }
.datatable tr.is-deleted td { color: var(--muted); text-decoration: line-through; }
.datatable td.id-cell { color: var(--muted); font-size: 12.5px; }
.table-foot { display: flex; justify-content: space-between; align-items: center; padding: 10px 2px; color: var(--muted); font-size: 13px; gap: 12px; flex-wrap: wrap; }
.empty-state { padding: 46px 20px; text-align: center; color: var(--ink-2); }
.empty-state strong { display: block; font-size: 16px; color: var(--ink); margin-bottom: 4px; }

/* simple tables (stats, runs, users) */
.simple { width: 100%; border-collapse: collapse; font-size: 13.5px; background: var(--surface); }
.simple th, .simple td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.simple th { font-size: 12.5px; font-weight: 600; color: var(--ink-2); background: var(--surface-2); }
.simple td.num, .simple th.num { text-align: right; font-variant-numeric: tabular-nums; }
.simple tr:last-child td { border-bottom: 0; }
.simple th { white-space: nowrap; }
.card:has(> table.simple) { overflow-x: auto; }
.card > .simple th:first-child, .card > .simple td:first-child { padding-left: 18px; }
.card > .simple th:last-child, .card > .simple td:last-child { padding-right: 18px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; }
.card-pad { padding: 16px 18px; }
.card + .card { margin-top: 14px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 14px 18px 0; }
.card-head h2, .card-head h3 { margin: 0; font-size: 15px; font-weight: 650; }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

/* ---------- layout helpers ---------- */
.cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.split { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, 1fr); gap: 16px; align-items: start; }
.stack > * + * { margin-top: 14px; }
.row-gap { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- charts ---------- */
.chart-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px 16px 12px; min-width: 0; }
.chart-card header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.chart-card h3 { margin: 0; font-size: 15px; font-weight: 650; }
.chart-card header p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .gridline { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--line-strong); stroke-width: 1; shape-rendering: crispEdges; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .end-label { fill: var(--ink-2); font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart .end-label .note { fill: var(--muted); font-weight: 400; }
.chart .goal-line { stroke: var(--ink-2); stroke-width: 1; opacity: .5; }
.chart .goal-label { pointer-events: none; fill: var(--ink-2); font-size: 11px; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.chart .crosshair { stroke: var(--ink-2); stroke-width: 1; stroke-opacity: .35; pointer-events: none; }
.chart .bar:hover, .chart .bar.is-hot { filter: brightness(1.1); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 0 0 8px; font-size: 12.5px; color: var(--ink-2); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.chart-legend i.rect { width: 10px; height: 10px; border-radius: 3px; }
.chart-tip {
  position: absolute; z-index: 20; pointer-events: none; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; box-shadow: var(--shadow-pop); padding: 8px 10px; font-size: 12.5px; min-width: 120px; white-space: nowrap;
}
.chart-tip .tip-title { color: var(--muted); margin-bottom: 4px; }
.chart-tip .tip-row { display: flex; align-items: center; gap: 8px; }
.chart-tip .tip-row b { font-variant-numeric: tabular-nums; font-weight: 650; color: var(--ink); }
.chart-tip .tip-row i { display: inline-block; width: 12px; height: 2px; border-radius: 1px; }
.chart-tip .tip-row span { color: var(--ink-2); }
.chart-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 6px; }
.chart-table th, .chart-table td { padding: 5px 8px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
.chart-table th:first-child, .chart-table td:first-child { text-align: left; }
.chart-empty { padding: 34px 10px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- KPI grid (sheet-style tabs) ---------- */
.grid-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0 0 10px; }
.kgrid-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: auto; max-height: 72vh; }
.kgrid { border-collapse: separate; border-spacing: 0; font-size: 13px; }
.kgrid th, .kgrid td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); height: 34px; padding: 0 9px; white-space: nowrap; }
.kgrid thead th { position: sticky; top: 0; z-index: 3; background: var(--surface-2); font-weight: 600; font-size: 12.5px; color: var(--ink-2); text-align: right; cursor: pointer; }
.kgrid thead th:first-child { left: 0; z-index: 4; text-align: left; cursor: default; }
.kgrid tbody th { position: sticky; left: 0; z-index: 2; background: var(--surface); text-align: left; font-weight: 550; min-width: 230px; max-width: 300px; overflow: hidden; text-overflow: ellipsis; }
.kgrid tbody th .rk { color: #b3adbd; font-weight: 400; font-size: 11px; margin-left: 6px; }
.kgrid tbody th .fx { color: var(--accent-strong); font-weight: 600; font-size: 11px; margin-left: 4px; }
.kgrid tbody th .rowchart { margin-right: 6px; accent-color: var(--accent); vertical-align: -2px; }
.kgrid tbody tr.section-start th, .kgrid tbody tr.section-start td { border-top: 2px solid var(--line-strong); }
.kgrid td { text-align: right; font-variant-numeric: tabular-nums; cursor: text; min-width: 84px; }
.kgrid td:hover { box-shadow: inset 0 0 0 1px var(--line-strong); }
.kgrid td.computed { color: var(--ink-2); font-style: italic; }
.kgrid td.text { text-align: left; white-space: normal; min-width: 160px; max-width: 360px; font-size: 12.5px; color: var(--ink-2); line-height: 1.35; padding: 6px 9px; }
.kgrid td.text .clip { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.kgrid td.editing { padding: 0; box-shadow: inset 0 0 0 2px var(--accent); }
.kgrid td.editing input, .kgrid td.editing textarea { width: 100%; min-width: 90px; height: 33px; border: 0; padding: 0 8px; text-align: right; outline: none; background: #fff; }
.kgrid td.editing textarea { text-align: left; height: 120px; position: absolute; z-index: 6; width: 340px; box-shadow: var(--shadow-pop); padding: 8px; }
.kgrid td.is-saved { animation: saved 1.2s ease-out; }
.kgrid .section-label { display: block; font-size: 11.5px; color: var(--muted); font-weight: 600; }

/* ---------- drawer & modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(29, 24, 38, .32); z-index: 50; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(500px, 100vw); background: var(--surface); z-index: 60;
  box-shadow: var(--shadow-pop); display: flex; flex-direction: column;
}
.drawer-head { padding: 18px 20px 14px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; }
.drawer-head h2 { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: 30px; line-height: 1; }
.drawer-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.drawer-body { overflow-y: auto; padding: 16px 20px 30px; flex: 1; }
.drawer-tabs { display: flex; gap: 4px; padding: 0 20px; border-bottom: 1px solid var(--line); }
.drawer-tabs button { background: none; border: 0; padding: 10px 8px; cursor: pointer; color: var(--ink-2); border-bottom: 2px solid transparent; font-weight: 550; }
.drawer-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.fieldlist { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 0; font-size: 13.5px; }
.fieldlist dt { color: var(--muted); padding: 8px 0; border-bottom: 1px solid var(--line); }
.fieldlist dd { margin: 0; padding: 4px 0; border-bottom: 1px solid var(--line); min-height: 36px; display: flex; align-items: center; }
.fieldlist dd .cell-edit { width: 100%; }
.fieldlist dd input, .fieldlist dd select, .fieldlist dd textarea { width: 100%; height: 30px; border: 1px solid transparent; border-radius: var(--radius-s); padding: 0 8px; background: transparent; }
.fieldlist dd textarea { height: 70px; padding: 6px 8px; }
.fieldlist dd input:hover, .fieldlist dd select:hover, .fieldlist dd textarea:hover { border-color: var(--line-strong); }
.fieldlist dd input:focus, .fieldlist dd select:focus, .fieldlist dd textarea:focus { border-color: var(--accent); outline: none; background: #fff; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: -2px; width: 1px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline .mark { position: absolute; left: 0; top: 2px; width: 13px; height: 13px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line-strong); }
.timeline .mark.auto { border-color: var(--accent); }
.timeline .mark.user { border-color: var(--ink-2); }
.timeline .who { font-weight: 600; }
.timeline .when { color: var(--muted); font-size: 12.5px; }
.change-list { margin: 6px 0 0; padding: 0; list-style: none; font-size: 13px; }
.change-list li { padding: 2px 0; }
.change-list .from { color: var(--muted); text-decoration: line-through; }
.change-list .to { color: var(--ink); font-weight: 550; }
.change-list .fname { color: var(--ink-2); }
.modal {
  position: fixed; z-index: 70; top: 7vh; left: 50%; transform: translateX(-50%); width: min(640px, calc(100vw - 32px));
  max-height: 86vh; overflow-y: auto; background: var(--surface); border-radius: var(--radius-l); box-shadow: var(--shadow-pop); padding: 22px 24px;
}
.modal h2 { margin: 0 0 4px; font-family: var(--font-display); font-weight: 800; font-size: 30px; line-height: 1; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ---------- dashboard scoreboard ---------- */
.scoreboard { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); margin-bottom: 14px; }
.dept { padding: 14px 16px 16px; border-left: 1px solid var(--line); min-width: 0; }
.dept:first-child { border-left: 0; }
.dept h3 { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: 22px; line-height: 1; letter-spacing: .01em; }
.dept .owner { font-size: 12.5px; color: var(--muted); margin: 3px 0 10px; }
.dept .metric { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 5px 0; border-top: 1px solid var(--line); }
.dept .metric span { color: var(--ink-2); font-size: 13px; }
.dept .metric b { font-size: 17px; font-weight: 650; }
.dept .metric .goal { margin: 0 0 0 6px; }
.hero-num { font-size: 52px; font-weight: 650; letter-spacing: -.02em; line-height: 1; }

/* ---------- automations ---------- */
.url-box { display: flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 0 4px 0 9px; height: 30px; max-width: 100%; }
.url-box code { font-family: inherit; font-size: 12.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.map-table { width: 100%; border-collapse: collapse; }
.map-table th { text-align: left; font-size: 12.5px; color: var(--ink-2); font-weight: 600; padding: 0 6px 6px 0; }
.map-table td { padding: 0 6px 8px 0; vertical-align: top; }
.map-table input, .map-table select { width: 100%; }
.json { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px 12px; white-space: pre-wrap; word-break: break-word; max-height: 420px; overflow: auto; margin: 0; }
.textarea.code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; min-height: 220px; }
.toggle { position: relative; display: inline-block; width: 34px; height: 20px; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle span { position: absolute; inset: 0; background: var(--line-strong); border-radius: 999px; cursor: pointer; transition: background .15s; }
.toggle span::before { content: ""; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .15s; }
.toggle input:checked + span { background: var(--accent); }
.toggle input:checked + span::before { transform: translateX(14px); }
.toggle input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.steps { margin: 0; padding-left: 20px; }
.steps li { margin: 0 0 6px; }

/* ---------- auth ---------- */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--rail); }
.auth-card { width: min(400px, 100%); background: var(--surface); border-radius: var(--radius-l); padding: 0 28px 26px; overflow: hidden; box-shadow: var(--shadow-pop); }
.auth-card--wide { width: min(620px, 100%); }
.auth-card .brand-stripe { margin: 0 -28px 22px; height: 8px; }
.auth-title { font-family: var(--font-display); font-weight: 800; font-size: 42px; line-height: .95; margin: 0 0 6px; }
.auth-card .form-grid { margin-top: 18px; }
.auth-card .btn--primary { width: 100%; justify-content: center; height: 40px; }
.req-list { list-style: none; padding: 0; margin: 14px 0; font-size: 13px; display: grid; gap: 4px; }
.req-list .ok { color: var(--good-ink); }
.req-list .bad { color: var(--critical-ink); }
.req-list .warn { color: var(--warning-ink); }
.req-list li { display: flex; gap: 6px; align-items: flex-start; }
.req-list li .icon { flex: none; margin-top: 2px; }

/* ---------- activity ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed-day { font-weight: 650; margin: 0; padding: 12px 14px 8px; font-size: 13.5px; color: var(--ink-2); background: var(--surface-2); border-bottom: 1px solid var(--line); }
.feed-names { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; }
.change-more { margin-top: 4px; font-size: 13px; }
.change-more > summary { cursor: pointer; color: var(--accent-strong); width: fit-content; }
.change-more > summary:hover { text-decoration: underline; }
.change-more > .change-list { margin-top: 2px; }
.feed-item { display: grid; grid-template-columns: 68px 26px minmax(0, 1fr) auto; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface); align-items: start; }
.feed-item:first-child { border-top-left-radius: var(--radius-m); border-top-right-radius: var(--radius-m); }
.feed-time { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; padding-top: 2px; }
.feed-icon { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--neutral-wash); color: var(--ink-2); }
.feed-icon.auto { background: var(--accent-wash); color: var(--accent-strong); }
.feed-text { min-width: 0; }
.feed-box { border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .scoreboard { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .scoreboard .dept:nth-child(4) { border-left: 0; }
  .scoreboard .dept:nth-child(n+4) { border-top: 1px solid var(--line); }
  .split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 700px) {
  .hide-sm { display: none !important; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); background: none; }
  .rail { position: fixed; z-index: 80; left: 0; width: 270px; transform: translateX(-100%); transition: transform .2s; }
  .rail.open { transform: none; box-shadow: var(--shadow-pop); }
  .menu-toggle { display: inline-grid; position: fixed; top: 10px; left: 10px; z-index: 81; background: var(--rail); color: #fff; width: 38px; height: 38px; border-radius: 10px; border: 0; place-items: center; }
  .main { padding: 60px 16px 48px; }
  .page-title { font-size: 34px; }
  .cols-2, .cols-3 { grid-template-columns: minmax(0, 1fr); }
  .scoreboard { grid-template-columns: minmax(0, 1fr); }
  .scoreboard .dept { border-left: 0; border-top: 1px solid var(--line); }
  .scoreboard .dept:first-child { border-top: 0; }
  .filters .input { width: 100%; }
  .band { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .band > .kpi { border-left: 0; border-top: 1px solid var(--line); }
  .band > .kpi:nth-child(-n+2) { border-top: 0; }
  .band > .kpi:nth-child(even) { border-left: 1px solid var(--line); }
  .band-title + .kpi, .band-title + .kpi + .kpi { border-top: 0; }
  .feed-item { grid-template-columns: 56px minmax(0, 1fr); }
  .feed-icon { display: none; }
  .fieldlist { grid-template-columns: 120px minmax(0, 1fr); }
}
@media print {
  .rail, .menu-toggle, .page-actions, .filters, .row-actions { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  .table-wrap, .kgrid-wrap { max-height: none; overflow: visible; border: 0; }
}
