/* The Bucket CRM — design system (2026-10-22 rebuild).
   One file: tokens (dark + light), base, layout, components. Components are
   class-scoped; nothing styles bare elements except the reset below, so no
   rule written for one page can leak into another (the old UI's failure). */

/* ---------- tokens ---------- */
:root, [data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1016;
  --surface: #18202b;
  --surface-2: #1e2834;
  --surface-3: #273242;
  --surface-sunken: #111821;
  --border: #2e3b4d;
  --border-2: #44566e;
  --control-border: #5d6f87;
  --text: #e9eef5;
  --text-2: #b0bccb;
  --text-3: #8b99ab;
  --accent: #6aa5ff;
  --accent-strong: #2f6fed;
  --accent-text: #ffffff;
  --accent-soft: rgba(106, 165, 255, 0.15);
  --accent-line: rgba(106, 165, 255, 0.55);
  --success: #45c08a;
  --success-soft: rgba(69, 192, 138, 0.15);
  --warning: #e8ad45;
  --warning-soft: rgba(232, 173, 69, 0.16);
  --danger: #f07474;
  --danger-strong: #d64545;
  --danger-soft: rgba(240, 116, 116, 0.15);
  --info: #55bfdc;
  --info-soft: rgba(85, 191, 220, 0.15);
  --violet: #ae91f7;
  --violet-soft: rgba(174, 145, 247, 0.16);
  --neutral-soft: rgba(176, 188, 203, 0.13);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-2: 0 10px 30px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
  --overlay: rgba(4, 7, 11, 0.62);
  --row-hover: #1f2937;
  --row-selected: rgba(106, 165, 255, 0.12);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #e9edf2;
  --surface: #ffffff;
  --surface-2: #f4f6f9;
  --surface-3: #e8edf3;
  --surface-sunken: #f7f9fb;
  --border: #cfd7e1;
  --border-2: #b3bfcc;
  --control-border: #7e8b9d;
  --text: #16202b;
  --text-2: #475668;
  --text-3: #525f71;
  --accent: #1d56c4;
  --accent-strong: #2f6fed;
  --accent-text: #ffffff;
  --accent-soft: rgba(29, 86, 196, 0.1);
  --accent-line: rgba(47, 111, 237, 0.5);
  --success: #126a41;
  --success-soft: rgba(31, 138, 91, 0.1);
  --warning: #7f4c00;
  --warning-soft: rgba(214, 140, 20, 0.13);
  --danger: #a82828;
  --danger-strong: #c93838;
  --danger-soft: rgba(201, 56, 56, 0.09);
  --info: #126580;
  --info-soft: rgba(25, 121, 154, 0.1);
  --violet: #6140c4;
  --violet-soft: rgba(109, 75, 209, 0.1);
  --neutral-soft: rgba(71, 86, 104, 0.09);
  --shadow-1: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-2: 0 12px 32px rgba(16, 24, 40, 0.14), 0 2px 6px rgba(16, 24, 40, 0.08);
  --overlay: rgba(16, 24, 40, 0.4);
  --row-hover: #f4f7fb;
  --row-selected: rgba(47, 111, 237, 0.08);
}

:root {
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
  --control-h: 38px;
  --control-h-sm: 32px;
  --radius: 8px;
  --radius-lg: 12px;
  --sidebar-w: 236px;
  --sidebar-rail: 64px;
  --topbar-h: 58px;
  --gap: 16px;
}

/* ---------- reset + base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent-soft); }
.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; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.i { flex: none; }

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

/* ---------- app layout ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden;
}
.app.rail { grid-template-columns: var(--sidebar-rail) minmax(0, 1fr); }
.main-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.content { flex: 1; min-height: 0; overflow: auto; padding: 22px 28px 40px; }
.content.fill { display: flex; flex-direction: column; overflow: hidden; padding-bottom: 16px; }

/* ---------- sidebar ---------- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.sb-brand { height: var(--topbar-h); display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border); flex: none; }
.sb-mark {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, var(--accent) 0%, var(--violet) 100%);
  color: #fff; display: grid; place-items: center; font-weight: 750; font-size: 15px; letter-spacing: -0.02em;
}
.sb-name { font-weight: 650; font-size: 15px; letter-spacing: -0.01em; white-space: nowrap; }
.sb-name small { display: block; color: var(--text-3); font-weight: 500; font-size: 11.5px; letter-spacing: 0; }
.sb-nav { flex: 1; overflow-y: auto; padding: 10px 10px; display: flex; flex-direction: column; gap: 2px; }
.sb-section { color: var(--text-3); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; padding: 14px 10px 6px; white-space: nowrap; }
.sb-link {
  display: flex; align-items: center; gap: 11px; height: 38px; padding: 0 10px; border-radius: var(--radius);
  color: var(--text-2); font-weight: 520; white-space: nowrap; position: relative;
}
.sb-link:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.sb-link[aria-current="page"] { background: var(--accent-soft); color: var(--text); }
.sb-link[aria-current="page"]::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.sb-link[aria-current="page"] .i { color: var(--accent); }
.sb-count { margin-left: auto; min-width: 22px; height: 20px; padding: 0 7px; border-radius: 10px; background: var(--accent-strong); color: #fff; font-size: 11.5px; font-weight: 650; display: grid; place-items: center; }
.sb-count.warn { background: var(--warning); color: #1b1305; }
.sb-foot { border-top: 1px solid var(--border); padding: 10px; display: flex; flex-direction: column; gap: 2px; flex: none; }
.app.rail .sb-name, .app.rail .sb-label, .app.rail .sb-section, .app.rail .sb-count { display: none; }
.app.rail .sb-brand { justify-content: center; padding: 0; }
.app.rail .sb-link { justify-content: center; padding: 0; }
.app.rail .sb-link .sb-dot { position: absolute; top: 7px; right: 12px; width: 8px; height: 8px; border-radius: 4px; background: var(--accent-strong); display: block; }
.sb-dot { display: none; }

/* ---------- topbar ---------- */
.topbar {
  height: var(--topbar-h); flex: none; display: flex; align-items: center; gap: 12px; padding: 0 20px 0 14px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.tb-search { flex: 1; max-width: 560px; position: relative; }
.tb-search .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.tb-search input { padding-left: 38px; padding-right: 54px; background: var(--surface-2); }
.tb-search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.env-pill { height: 26px; padding: 0 10px; border-radius: 13px; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 650; background: var(--warning-soft); color: var(--warning); border: 1px solid color-mix(in srgb, var(--warning) 45%, transparent); }
kbd { font: 11px/1 var(--mono); padding: 3px 6px; border-radius: 5px; border: 1px solid var(--border-2); color: var(--text-3); background: var(--surface); }

/* ---------- buttons ---------- */
.btn {
  height: var(--control-h); padding: 0 14px; border-radius: var(--radius);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--control-border); background: var(--surface-2); color: var(--text);
  font-weight: 560; font-size: 13.5px; line-height: 1; white-space: nowrap; text-decoration: none; cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: translateY(0.5px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-text); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent-strong) 88%, #fff); }
.btn.danger { background: transparent; border-color: color-mix(in srgb, var(--danger) 55%, transparent); color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.danger.solid { background: var(--danger-strong); border-color: var(--danger-strong); color: #fff; }
.btn.success { background: var(--success); border-color: var(--success); color: #062015; }
[data-theme="light"] .btn.success { color: #ffffff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.sm { height: var(--control-h-sm); padding: 0 11px; font-size: 13px; }
.btn.icon { width: var(--control-h); padding: 0; flex-shrink: 0; }
.btn.icon.sm { width: var(--control-h-sm); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
/* A one-button POST form sits in a row like a plain button would. */
.inline-form { display: inline-flex; align-items: center; gap: 8px; margin: 0; }

/* ---------- form controls ---------- */
.input, .select, .textarea {
  width: 100%; height: var(--control-h); padding: 0 12px; border-radius: var(--radius);
  border: 1px solid var(--control-border); background: var(--surface-sunken); color: var(--text);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.textarea { height: auto; min-height: 88px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.textarea.one-line { min-height: 0; resize: none; }
.select { appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b99ab' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.input.sm, .select.sm { height: var(--control-h-sm); font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field + .field { margin-top: 14px; }
.field > label, .label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field > label.wrap { display: flex; flex-direction: column; gap: 6px; font: inherit; color: inherit; }
.field .hint { font-size: 12px; color: var(--text-3); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
/* Side-by-side fields share one top edge (the stacked-field spacing above must not apply across a row). */
.field-row > .field + .field { margin-top: 0; }
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; color: var(--text-2); }
input[type="checkbox"].cb {
  appearance: none; width: 18px; height: 18px; margin: 0; flex: none; cursor: pointer; border-radius: 5px;
  border: 1.5px solid var(--control-border); background: var(--surface-sunken); display: inline-grid; place-items: center;
  transition: background-color 0.1s, border-color 0.1s;
}
input[type="checkbox"].cb:hover { border-color: var(--accent); }
input[type="checkbox"].cb:checked, input[type="checkbox"].cb:indeterminate { background: var(--accent-strong); border-color: var(--accent-strong); }
input[type="checkbox"].cb:checked::after { content: ""; width: 9px; height: 5px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
input[type="checkbox"].cb:indeterminate::after { content: ""; width: 9px; height: 2px; background: #fff; border-radius: 1px; }

/* ---------- pills / badges / tags ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 11px;
  font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--neutral-soft); color: var(--text-2);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 3px; background: currentColor; flex: none; }
.pill.plain::before { display: none; }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill.success { background: var(--success-soft); color: var(--success); }
.pill.warning { background: var(--warning-soft); color: var(--warning); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.violet { background: var(--violet-soft); color: var(--violet); }
.tag { display: inline-block; line-height: 20px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; color: var(--text-2); background: var(--surface-3); border: 1px solid var(--border); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.biz-dot { width: 9px; height: 9px; border-radius: 3px; flex: none; display: inline-block; }
.biz { display: inline-flex; align-items: center; gap: 7px; min-width: 0; max-width: 100%; vertical-align: middle; }
.avatar {
  width: 30px; height: 30px; border-radius: 8px; flex: none; display: grid; place-items: center;
  font-weight: 700; font-size: 12.5px; color: #fff; letter-spacing: 0.01em;
}
.avatar.lg { width: 52px; height: 52px; border-radius: 12px; font-size: 19px; }
.avatar.round { border-radius: 50%; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 0; }
.card-head h2, .card-head h3 { font-size: 14.5px; font-weight: 650; letter-spacing: -0.005em; }
.card-head .count { color: var(--text-3); font-weight: 600; }
.card-head .actions { margin-left: auto; display: flex; gap: 6px; }
.card-body { padding: 14px 16px 16px; }
.card + .card { margin-top: 14px; }
/* Flex and grid containers space their cards with gap — no stacking margin. */
:is(.stat-row, .zone-left, .zone-right, .split, .board) > .card + .card { margin-top: 0; }

/* ---------- board (training stages) ---------- */
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; flex: 1; min-height: 0; }
.board-col { display: flex; flex-direction: column; min-height: 0; }
.board-col .hint { padding: 4px 16px 0; }
.board-list { padding: 12px; display: flex; flex-direction: column; gap: 10px; overflow: auto; }
.board-card { display: block; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); color: inherit; text-decoration: none; }
.board-card:hover { border-color: var(--border-2); background: var(--surface-3); text-decoration: none; }
.board-card .head { display: flex; align-items: center; gap: 8px; }
.board-card .head .faint { margin-left: auto; }
.board-card .desc { font-size: 13px; margin-top: 4px; }
.board-card .meta { font-size: 12px; margin-top: 6px; }
.stack > * + * { margin-top: 14px; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; flex: none; min-height: 40px; }
.page-head h1 { font-size: 22px; font-weight: 680; letter-spacing: -0.02em; display: flex; align-items: baseline; gap: 10px; }
.page-head .count { font-size: 14px; font-weight: 600; color: var(--text-3); }
.page-head .sub { color: var(--text-2); font-size: 13px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 13px; margin-bottom: 10px; }
.crumbs a { color: var(--text-2); }
.crumbs .crumb-back { display: inline-flex; align-items: center; gap: 2px; padding: 2px 8px 2px 4px; margin-right: 6px; border: 1px solid var(--border); border-radius: 999px; color: var(--text-2); font-weight: 560; }
.crumbs .crumb-back:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }

/* ---------- toolbar (filters + search + columns) ---------- */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; flex: none; min-height: var(--control-h); }
/* The search shrinks before the toolbar wraps (small basis, grows to 280). */
.toolbar .search { position: relative; flex: 1 1 180px; min-width: 160px; max-width: 280px; }
.toolbar .search .i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.toolbar .search .input { padding-left: 36px; }
.toolbar .filter { width: auto; min-width: 140px; max-width: 220px; }
/* 12.1: the Queue has four filters; a little narrower each, they stay on one row with the search and Columns at
   desktop width (with long business names "Columns" dropped to a row of its own whenever a filter was on). */
.toolbar[data-grid-toolbar="queue"] .filter { max-width: 196px; }
.toolbar .spacer { flex: 1; }
.toolbar .clear { font-size: 13px; color: var(--text-2); padding: 0 6px; }
.seg { display: inline-flex; border: 1px solid var(--control-border); border-radius: var(--radius); overflow: hidden; height: var(--control-h); background: var(--surface-2); }
.seg a, .seg button { display: inline-flex; align-items: center; gap: 7px; padding: 0 13px; color: var(--text-2); font-weight: 560; font-size: 13px; white-space: nowrap; border: 0; background: transparent; text-decoration: none; }
.seg a + a, .seg button + button { border-left: 1px solid var(--border); }
.seg a:hover, .seg button:hover { background: var(--surface-3); color: var(--text); }
.seg a[aria-current="true"], .seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--text); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { height: 32px; padding: 0 12px; border-radius: 16px; display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--control-border); background: var(--surface-2); color: var(--text-2); font-size: 13px; font-weight: 560; text-decoration: none; }
.chip:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.chip[aria-current="true"] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--text); }
.chip .n { color: var(--text-3); font-weight: 650; }

/* bulk bar replaces the toolbar while rows are selected */
.bulkbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; height: var(--control-h); padding: 0 6px 0 14px; border-radius: var(--radius); background: var(--accent-soft); border: 1px solid var(--accent-line); flex: none; }
.bulkbar .n { font-weight: 650; }
.bulkbar form { display: flex; gap: 8px; align-items: center; margin: 0; }

/* ---------- THE GRID ---------- */
.grid-wrap {
  flex: 1; min-height: 0; overflow: auto; position: relative;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-1);
}
.grid-wrap.inline { flex: none; max-height: 560px; }
/* Width is set inline to the sum of the columns (fixed layout holds only with a definite width); the filler column absorbs the rest. */
table.grid { border-collapse: separate; border-spacing: 0; table-layout: fixed; min-width: 100%; }
.grid th, .grid td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 0 12px; height: 46px; text-align: left; vertical-align: middle; }
.grid th:last-child, .grid td:last-child { border-right: 0; }
.grid td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid thead th {
  position: sticky; top: 0; z-index: 2; height: 44px; background: var(--surface-2);
  color: var(--text-2); font-size: 12.5px; font-weight: 650; letter-spacing: 0.01em; user-select: none;
  border-bottom: 1px solid var(--border-2);
}
.grid .th { display: flex; align-items: center; gap: 4px; height: 100%; min-width: 0; }
.grid .th-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: inherit; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; height: 100%; }
.grid a.th-label:hover { color: var(--text); text-decoration: none; }
.grid .sort-ind { color: var(--text-3); display: inline-flex; }
.grid th[aria-sort="ascending"] .sort-ind, .grid th[aria-sort="descending"] .sort-ind { color: var(--accent); }
.grid .th-menu { width: 26px; height: 26px; border-radius: 6px; border: 1px solid transparent; background: transparent; color: var(--text-3); display: grid; place-items: center; flex: none; padding: 0; }
.grid .th-menu:hover, .grid .th-menu[aria-expanded="true"] { background: var(--surface-3); border-color: var(--border); color: var(--text); }
.grid .col-resize { position: absolute; top: 0; right: -5px; width: 10px; height: 100%; cursor: col-resize; z-index: 3; touch-action: none; }
.grid .col-resize::after { content: ""; position: absolute; top: 10px; bottom: 10px; left: 4px; width: 2px; border-radius: 1px; background: transparent; transition: background-color 0.1s; }
.grid th:hover .col-resize::after { background: var(--border-2); }
.grid .col-resize:hover::after, .grid .col-resize.dragging::after { background: var(--accent); }
.grid th.sel, .grid td.sel { width: 48px; padding: 0; text-align: center; }
.grid th.sel .cb, .grid td.sel .cb { margin: 0 auto; }
.grid td.sel label { display: grid; place-items: center; width: 100%; height: 100%; cursor: pointer; }
.grid th.filler, .grid td.filler { border-right: 0; padding: 0; }
.grid tbody tr { transition: background-color 0.08s; }
.grid tbody tr:hover td { background: var(--row-hover); }
.grid tbody tr.selected td { background: var(--row-selected); }
.grid .cell-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.grid .cell-name a { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid .cell-name a:hover { color: var(--accent); }
.grid .cell-name .sub { color: var(--text-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid .cell-stack { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.grid .cell-stack > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid td.num, .grid th.num { text-align: right; }
.grid td.num .th, .grid th.num .th { justify-content: flex-end; }
.grid td .muted, .grid td .faint { font-size: 13px; }
.grid .editable { cursor: text; border-radius: 6px; padding: 3px 6px; margin: -3px -6px; }
.grid .editable:hover { background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--border-2); }
.grid td.editing { padding: 0 6px; overflow: visible; }
.grid td.editing .input, .grid td.editing .select { height: 34px; }
.grid tbody tr.blank:hover td { background: transparent; }

/* tickets: the pasted-screenshot preview in the dialog, and the filed shot */
.ticket-preview { display: block; max-width: 100%; max-height: 220px; margin-top: 10px; border-radius: 8px; border: 1px solid var(--border); }
.ticket-shot { display: block; max-width: 100%; border-radius: 8px; border: 1px solid var(--border); }
.row-actions { display: flex; gap: 6px; align-items: center; }
/* 12.1: what a Queue row needs, one chip each (UX-07); the line of waiting pieces or decisions (UX-03). */
.q-chips { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 4px; font-size: 12px; }
.q-chips .pill { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 11.1: a hand post's "Mark posted" under its row's words — the address box takes what the cell leaves. */
.q-inline { margin-top: 6px; max-width: 420px; }
.q-inline .input { flex: 1 1 auto; min-width: 0; height: 30px; font-size: 13px; }
.q-inline .btn { flex: none; }
/* 12.3: the reason chips — one tap sends a piece back with its reason; in a dialog, the same chips as a choice. */
.reason-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 14px; }
.reason-head { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.reason-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.btn.chip { border-radius: 999px; padding-left: 12px; padding-right: 12px; }
.chip-choice { display: inline-flex; cursor: pointer; }
.chip-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip-choice span { display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border-2); background: var(--surface); color: var(--text); font-size: 13px; font-weight: 550; }
.chip-choice input:checked + span { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.chip-choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
/* 12.4: the Review desk — the list of waiting pieces on the left, the piece in full on the right. */
.desk { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 16px; align-items: start; }
.desk-list { position: sticky; top: 0; max-height: calc(100vh - 170px); display: flex; flex-direction: column; }
.desk-items { overflow-y: auto; }
/* Wave 6, fix 2: more wait than a page shows — which of how many, and the way to the rest. */
.desk-pager { display: flex; align-items: center; gap: 4px; padding: 4px 8px 4px 14px; border-top: 1px solid var(--border); font-size: 12.5px; flex: none; }
.desk-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-top: 1px solid var(--border); color: var(--text); text-decoration: none; }
.desk-item:hover { background: var(--row-hover); text-decoration: none; }
.desk-item.on { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.desk-item .biz-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; }
.desk-item .title { display: block; font-weight: 600; font-size: 13.5px; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.desk-item .sub { display: block; font-size: 12.5px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.desk-pills { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; flex: none; }
.desk-head { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; }
.desk-title { font-size: 20px; line-height: 1.3; margin: 0 0 4px; }
.desk-step { font-size: 12.5px; white-space: nowrap; }
/* 12.6: an employee's scorecard — the headline rate, then a two-column table (since its version, before), per variation. */
.score-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.score-big { font-size: 34px; font-weight: 700; line-height: 1.1; letter-spacing: -0.01em; }
.score-was { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.score-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.score-table th, .score-table td { padding: 7px 8px; border-top: 1px solid var(--border); text-align: left; vertical-align: top; }
.score-table thead th { border-top: 0; color: var(--text-2); font-size: 12px; font-weight: 600; }
.score-table tbody th { font-weight: 500; color: var(--text-2); width: 38%; }
.score-table td.num { font-variant-numeric: tabular-nums; }
.score-vars { margin-top: 14px; }
@media (max-width: 700px) {
  .score-table tbody th { width: auto; }
  .score-was { align-items: flex-start; }
}
/* 11.8: For me today — the sections waiting (each line a link to its page), yesterday's numbers beside them. */
.digest { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); gap: 16px; align-items: start; }
.digest-line { color: inherit; text-decoration: none; }
.digest-line:hover { background: var(--surface-2); text-decoration: none; }
.digest-line .title { font-weight: 550; }
.digest-line .title, .digest-line .sub { display: block; }
.digest-notes p { margin: 0; }
.digest-notes p + p { margin-top: 6px; }
.digest-line > .i { color: var(--text-3); flex: none; }
.stat-row.digest-yesterday { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; }
.digest-yesterday .stat { padding: 10px 12px; box-shadow: none; }
.digest-yesterday .stat .v { font-size: 22px; }
@media (max-width: 900px) {
  .digest { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 700px) {
  .digest-line .title { white-space: normal; }
  .stat-row.digest-yesterday { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* 11.10: "This week" — the headline (person-minutes per published piece) first and marked, then four numbers; on a
   narrow screen the headline takes the whole row and the four sit two by two. */
.week-card { margin-bottom: 14px; flex: none; }
.stat-row.week-numbers { grid-template-columns: minmax(0, 1.35fr) repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0; }
.week-numbers .stat { padding: 10px 12px; box-shadow: none; }
.week-numbers .stat .v { font-size: 22px; }
.week-numbers .stat .v.warn { color: var(--warning); }
.week-numbers .stat.lead { border-color: var(--accent-line); background: var(--accent-soft); }
/* Wave 6, fix 6: since when openings are recorded, while that is inside the week. */
.week-numbers .week-note { display: block; margin-top: 2px; color: var(--warning); }
@media (max-width: 1100px) {
  .stat-row.week-numbers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .week-numbers .stat.lead { grid-column: 1 / -1; }
}
/* 12.5 (d, UX-22): a hire's line — what it makes, its minimum, who checks each piece; the choice gets room for its
   words; on a phone the three stack (they spilled past a 390 px screen). */
.list-row.hire-line { display: grid; grid-template-columns: minmax(220px, 1fr) auto minmax(240px, 340px); gap: 14px; align-items: center; }
.list-row.hire-line .select, .list-row.hire-line select { width: 100%; }
@media (max-width: 700px) {
  .list-row.hire-line { grid-template-columns: minmax(0, 1fr); gap: 8px; }
}
/* 12.5: the keys' reason hint, the key list, two pieces side by side, "Approve all like this". */
.desk-hint { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 400; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; max-width: min(720px, calc(100vw - 32px)); padding: 10px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border-2); box-shadow: var(--shadow-2); font-size: 13px; }
.desk-hint-key { white-space: nowrap; }
.desk-keys { grid-template-columns: max-content 1fr; }
.desk-compare { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.desk-compare > div { min-width: 0; padding: 12px; border: 1px solid var(--border); border-radius: 10px; }
.desk-compare .label { font-weight: 600; font-size: 12.5px; color: var(--text-2); margin-bottom: 8px; }
.desk-batch { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.desk-list-toggle { display: none; margin: 0 0 12px; }
@media (max-width: 960px) {
  .desk { grid-template-columns: minmax(0, 1fr); }
  .desk-list { position: static; max-height: 360px; order: 2; }
  .desk-reader { order: 1; }
}
/* 12.5 (UX-22): on a phone the piece comes first, the list behind a button, the main acts in a bar fixed to the bottom. */
@media (max-width: 700px) {
  .desk-list-toggle { display: inline-flex; }
  .desk-filters .filter { flex: 1 1 calc(50% - 4px); min-width: 0; max-width: none; }
  .desk .desk-list { display: none; }
  .desk.show-list .desk-list { display: flex; order: 0; max-height: 60vh; }
  .desk-compare { grid-template-columns: minmax(0, 1fr); }
  .desk-reader { padding-bottom: 64px; }
  .desk-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; margin: 0; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -6px 16px rgba(0, 0, 0, 0.18); }
  .desk-bar .btn { flex: 1 1 auto; justify-content: center; }
  .desk-hint { bottom: 76px; }
}
.stepper { display: inline-flex; gap: 6px; align-items: center; margin-right: 6px; }
.stepper .num { font-size: 12.5px; padding: 0 2px; white-space: nowrap; }

/* pagination: centered, grouped */
.pager { flex: none; display: flex; align-items: center; justify-content: center; gap: 10px; padding-top: 14px; }
.pager .pos { color: var(--text-2); font-size: 13px; min-width: 120px; text-align: center; }
.pager .per { display: inline-flex; align-items: center; gap: 8px; margin-left: 14px; color: var(--text-3); font-size: 13px; }
.pager .per .select { width: 84px; }

/* ---------- popover menus ---------- */
.menu[popover] {
  margin: 0; inset: auto; position: fixed; min-width: 210px; max-width: 320px; padding: 6px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-2); border-radius: 10px; box-shadow: var(--shadow-2);
}
.menu .mi {
  width: 100%; display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: 7px;
  border: 0; background: transparent; color: var(--text); font-size: 13.5px; text-align: left; text-decoration: none; white-space: nowrap;
}
.menu .mi .i { color: var(--text-3); }
.menu .mi:hover, .menu .mi:focus-visible { background: var(--surface-3); text-decoration: none; outline: none; }
.menu .mi[aria-current="true"] { color: var(--accent); }
.menu .mi[aria-current="true"] .i { color: var(--accent); }
.menu .mi.danger { color: var(--danger); }
.menu .mi.danger .i { color: var(--danger); }
.menu .sep { height: 1px; background: var(--border); margin: 6px 4px; }
.menu .mh { padding: 6px 10px 4px; font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); }
.menu form { margin: 0; }

/* ---------- dialogs ---------- */
dialog.dlg {
  padding: 0; border: 1px solid var(--border-2); border-radius: 14px; background: var(--surface); color: var(--text);
  width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); box-shadow: var(--shadow-2);
}
dialog.dlg.wide { width: min(760px, calc(100vw - 32px)); }
dialog.dlg::backdrop { background: var(--overlay); backdrop-filter: blur(2px); }
.dlg-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.dlg-head h2 { font-size: 16px; font-weight: 680; }
.dlg-head .btn { margin-left: auto; }
.dlg-body { padding: 18px; overflow: auto; max-height: calc(100dvh - 200px); }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 14px 14px; }
.col-list { display: flex; flex-direction: column; gap: 4px; }
.col-item { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.col-item .grip { color: var(--text-3); cursor: grab; display: grid; place-items: center; }
.col-item.dragging { opacity: 0.5; }
.col-item.drop-before { box-shadow: 0 -2px 0 0 var(--accent); }
.col-item .name { flex: 1; }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; min-width: 280px; max-width: 440px; padding: 12px 12px 12px 14px;
  background: var(--surface); border: 1px solid var(--border-2); border-left: 4px solid var(--success); border-radius: 10px; box-shadow: var(--shadow-2);
  animation: toast-in 0.18s ease-out;
}
.toast.error { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--accent); }
.toast .msg { flex: 1; line-height: 1.4; padding-top: 2px; }
.toast .x { width: 26px; height: 26px; border: 0; background: transparent; color: var(--text-3); border-radius: 6px; display: grid; place-items: center; }
.toast .x:hover { background: var(--surface-3); color: var(--text); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- banners (alerts inside a page) ---------- */
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border-2); background: var(--surface-2); }
.banner + .banner { margin-top: 10px; }
.banner .i { margin-top: 1px; }
.banner strong { display: block; margin-bottom: 2px; }
.banner.danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.banner.danger .i, .banner.danger strong { color: var(--danger); }
.banner.warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 45%, transparent); }
.banner.warning .i, .banner.warning strong { color: var(--warning); }
.banner.info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 40%, transparent); }
.banner.info .i, .banner.info strong { color: var(--info); }
.banner.success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 40%, transparent); }
.banner.success .i, .banner.success strong { color: var(--success); }
.banner .grow { flex: 1; min-width: 0; }

/* ---------- tooltip (hover/focus help, never prose on the surface) ---------- */
.help { display: inline-grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; border: 1px solid var(--border-2); color: var(--text-3); font-size: 11px; font-weight: 700; cursor: help; position: relative; vertical-align: middle; }
.help:hover, .help:focus-visible { color: var(--text); border-color: var(--text-3); }
.help .tipbox { display: none; position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); width: max-content; max-width: 280px; padding: 9px 11px; border-radius: 8px; background: var(--text); color: var(--bg); font-size: 12.5px; font-weight: 500; line-height: 1.45; z-index: 50; white-space: normal; text-align: left; box-shadow: var(--shadow-2); }
.help:hover .tipbox, .help:focus-visible .tipbox { display: block; }
/* Ticket #71: an info bubble on a stat feed — a real button; hover, tap or Enter opens it, Esc closes it. */
.info { display: inline-block; position: relative; vertical-align: middle; margin-left: 4px; }
.info-btn { position: relative; display: inline-grid; place-items: center; width: 17px; height: 17px; padding: 0; border-radius: 50%; border: 1px solid var(--border-2); background: transparent; color: var(--text-3); font: italic 700 11px/1 Georgia, serif; cursor: help; }
.info-btn::after { content: ""; position: absolute; inset: -14px; } /* a 44px tap target around the 17px mark */
.info-btn:hover, .info-btn:focus-visible, .info.open .info-btn { color: var(--text); border-color: var(--text-3); }
.info .tipbox { display: none; position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); width: max-content; max-width: 300px; padding: 9px 11px; border-radius: 8px; background: var(--text); color: var(--bg); font-size: 12.5px; font-weight: 500; font-style: normal; line-height: 1.45; z-index: 50; white-space: normal; text-align: left; box-shadow: var(--shadow-2); }
.info:hover .tipbox, .info.open .tipbox { display: block; }
@media (max-width: 700px) {
  /* A phone: the words sit at the foot of the screen, whole width, never off an edge. */
  .info .tipbox { position: fixed; left: 12px; right: 12px; bottom: 12px; top: auto; transform: none; width: auto; max-width: none; font-size: 14px; padding: 12px 14px; }
  .info:hover:not(.open) .tipbox { display: none; }
}

/* ---------- record page: three zones ---------- */
/* Areas, not source order: identity, details, middle, side cards. Wide
   screens get three zones; narrower ones two (side cards under the details);
   phones one, with the middle (the reason you opened the page) right after
   the identity. */
.record {
  display: grid; gap: 14px 18px; align-items: start;
  grid-template-columns: 320px minmax(0, 1fr) 300px; grid-template-rows: auto 1fr;
  grid-template-areas: "id mid right" "left mid right";
}
.record.wide { grid-template-columns: 320px minmax(0, 1fr); grid-template-rows: auto auto 1fr; grid-template-areas: "id mid" "left mid" "right mid"; }
.record > .zone-id { grid-area: id; min-width: 0; }
.record > .zone-left { grid-area: left; }
.record > .zone-mid { grid-area: mid; min-width: 0; }
.record > .zone-right { grid-area: right; }
/* An aside (an employee's checklist) leads the details — and on a phone comes right after the identity. */
.record > .zone-aside { grid-area: aside; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.record.has-aside { grid-template-rows: auto auto auto 1fr; grid-template-areas: "id mid right" "aside mid right" "left mid right"; }
.record.wide.has-aside { grid-template-rows: auto auto auto auto 1fr; grid-template-areas: "id mid" "aside mid" "left mid" "right mid"; }
.zone-left, .zone-right { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.identity { padding: 18px; }
.identity .top { display: flex; gap: 14px; align-items: flex-start; }
.identity h1 { font-size: 19px; font-weight: 700; letter-spacing: -0.015em; line-height: 1.25; word-break: break-word; }
.identity .sub { color: var(--text-2); font-size: 13px; margin-top: 3px; }
.identity .badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.identity .quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.props { padding: 4px 0; }
.prop { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 10px; padding: 9px 16px; align-items: start; border-top: 1px solid var(--border); }
.prop:first-child { border-top: 0; }
.prop dt { color: var(--text-3); font-size: 12.5px; font-weight: 560; padding-top: 2px; }
.prop dd { min-width: 0; word-break: break-word; }
.prop dd [data-prop-view] { display: flex; align-items: center; gap: 6px; min-width: 0; }
.prop dd [data-prop-view] > .v { min-width: 0; }
.prop dd .edit-btn { flex: none; width: 26px; height: 26px; margin: -3px 0; opacity: 0; transition: opacity 0.1s; }
.prop:hover dd .edit-btn, .prop dd .edit-btn:focus-visible { opacity: 1; }
/* No hover on touch screens: the pencil is always there. */
@media (hover: none) { .prop dd .edit-btn { opacity: 1; width: 36px; height: 36px; margin: -6px 0; } }
.prop-group-title { padding: 12px 16px 4px; font-size: 11.5px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; }
.prop.editing { background: var(--surface-2); }
.prop form .btn-row { margin-top: 8px; }
.assoc .item { display: flex; align-items: center; gap: 10px; padding: 9px 16px; border-top: 1px solid var(--border); min-width: 0; }
.assoc .item:first-child { border-top: 0; }
.assoc .item .grow { min-width: 0; flex: 1; }
.assoc .item a { color: var(--text); font-weight: 600; }
.assoc .item a:hover { color: var(--accent); }
.assoc .item .sub { color: var(--text-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.assoc .more { display: block; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 13px; font-weight: 600; }
.assoc .none { padding: 12px 16px; color: var(--text-3); font-size: 13px; }

/* tabs (record middle zone) */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs a { display: inline-flex; align-items: center; gap: 7px; height: 42px; padding: 0 14px; color: var(--text-2); font-weight: 580; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs .tab-more { display: inline-flex; align-items: center; gap: 5px; height: 42px; padding: 0 14px; background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; color: var(--text-2); font: inherit; font-weight: 580; white-space: nowrap; cursor: pointer; }
.tabs .tab-more:hover, .tabs .tab-more[aria-current="page"] { color: var(--text); }
.tabs .tab-more[aria-current="page"] { border-bottom-color: var(--accent); }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.tabs .n { min-width: 20px; height: 19px; padding: 0 6px; border-radius: 10px; background: var(--surface-3); color: var(--text-2); font-size: 11.5px; font-weight: 650; display: inline-grid; place-items: center; }
.tabs a[aria-current="page"] .n { background: var(--accent-soft); color: var(--accent); }

/* key/value blocks (four questions etc.) */
.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 0; }
.kv dt, .kv dd { padding: 9px 0; border-top: 1px solid var(--border); }
.kv dt:first-of-type, .kv dd:first-of-type { border-top: 0; }
.kv dt { color: var(--text-3); font-weight: 560; font-size: 13px; }
.kv dd { word-break: break-word; white-space: pre-wrap; }
.quote { white-space: pre-wrap; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); line-height: 1.55; }
details.raw summary { cursor: pointer; color: var(--text-2); font-size: 13px; font-weight: 560; margin-top: 12px; }
pre.code { margin: 10px 0 0; padding: 12px; border-radius: 10px; background: var(--surface-sunken); border: 1px solid var(--border); font: 12.5px/1.55 var(--mono); color: var(--text-2); white-space: pre-wrap; word-break: break-word; max-height: 420px; overflow: auto; }

/* timeline */
.timeline { position: relative; }
.tl-item { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; padding: 0 0 18px; position: relative; }
.tl-item::before { content: ""; position: absolute; left: 14px; top: 30px; bottom: 0; width: 2px; background: var(--border); }
.tl-item:last-child::before { display: none; }
.tl-dot { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-3); border: 1px solid var(--border-2); display: grid; place-items: center; color: var(--text-2); }
.tl-dot.accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.tl-dot.success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.tl-dot.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.tl-dot.warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.tl-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; padding-top: 5px; }
.tl-head strong { font-weight: 620; }
.tl-head .when { color: var(--text-3); font-size: 12.5px; }
.tl-body { margin-top: 4px; color: var(--text-2); white-space: pre-wrap; word-break: break-word; }

/* composer (notes / decisions) */
.composer { display: flex; flex-direction: column; gap: 10px; }

/* ---------- decision card (employee requests) ---------- */
.decision { border: 1px solid var(--accent-line); background: linear-gradient(180deg, var(--accent-soft), transparent 70%), var(--surface); }
.decision .summary { font-size: 15.5px; line-height: 1.5; }
.decision .effects { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.decision .effect { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); font-size: 13px; }
.decision .effect b { display: block; font-size: 12px; color: var(--text-3); margin-bottom: 3px; text-transform: uppercase; letter-spacing: 0.05em; }
.staged { margin-top: 14px; }
.staged h3 { font-size: 12.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; font-weight: 650; }

/* ---------- queue ---------- */
.q-type { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.q-type .ic { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.q-type .ic.accent { background: var(--accent-soft); color: var(--accent); }
.q-type .ic.warning { background: var(--warning-soft); color: var(--warning); }
.q-type .ic.danger { background: var(--danger-soft); color: var(--danger); }
.q-type .ic.violet { background: var(--violet-soft); color: var(--violet); }
.q-type .ic.info { background: var(--info-soft); color: var(--info); }
.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; flex: none; }
.stat-row.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.stat-row.six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.stat { padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit; }
a.stat:hover { border-color: var(--border-2); text-decoration: none; background: var(--surface-2); }
.stat .k { color: var(--text-2); font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.stat .v { font-size: 26px; font-weight: 720; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .v.zero { color: var(--text-3); }
.stat .d { font-size: 12px; color: var(--text-3); }

/* ---------- calendar ---------- */
.cal { flex: 1; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; box-shadow: var(--shadow-1); }
.cal-dow { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--surface-2); border-bottom: 1px solid var(--border-2); }
.cal-dow div { padding: 9px 10px; font-size: 12px; font-weight: 650; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.05em; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); min-height: 0; }
.cal-cell { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px 6px 4px; min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 3px; position: relative; }
.cal-cell:nth-child(7n) { border-right: 0; }
/* Days outside the month recede: page-colored, dimmer numbers. */
.cal-cell.out { background: var(--bg); }
.cal-cell.out .cal-day { color: var(--text-3); opacity: 0.75; }
.cal-cell.today .cal-day span { background: var(--accent-strong); color: #fff; }
.cal-day { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; font-weight: 650; color: var(--text-2); flex: none; }
.cal-day span { min-width: 24px; height: 24px; border-radius: 12px; display: grid; place-items: center; padding: 0 4px; }
.cal-day a { color: inherit; text-decoration: none; }
.cal-day .add { opacity: 0; width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; color: var(--text-3); }
.cal-cell:hover .cal-day .add { opacity: 1; }
.cal-day .add:hover { background: var(--surface-3); color: var(--text); }
.cal-ev {
  display: flex; align-items: center; gap: 6px; height: 24px; padding: 0 7px 0 0; border-radius: 6px; font-size: 12px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text); text-decoration: none; overflow: hidden; flex: none;
}
.cal-ev:hover { background: var(--surface-3); text-decoration: none; border-color: var(--border-2); }
.cal-ev .bar { width: 4px; align-self: stretch; flex: none; }
.cal-ev .t { color: var(--text-3); font-variant-numeric: tabular-nums; flex: none; }
.cal-ev .ttl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.cal-ev.st-awaiting_approval { border-color: color-mix(in srgb, var(--warning) 55%, transparent); }
.cal-ev.st-approved .ttl { font-weight: 600; }
.cal-ev.st-posted { opacity: 0.72; }
.cal-ev.st-missed, .cal-ev.st-failed { border-color: color-mix(in srgb, var(--danger) 55%, transparent); }
.cal-ev.st-cancelled { opacity: 0.5; text-decoration: line-through; }
.cal-ev .stk { width: 7px; height: 7px; border-radius: 4px; flex: none; }
.cal-more { font-size: 12px; color: var(--text-2); padding: 1px 6px; font-weight: 600; }
.cal-week { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
.cal-week .col { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.cal-week .col:last-child { border-right: 0; }
.cal-week .col-head { padding: 10px; border-bottom: 1px solid var(--border-2); background: var(--surface-2); flex: none; }
.cal-week .col-head .dw { font-size: 12px; color: var(--text-2); font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em; }
.cal-week .col-head .dn { font-size: 20px; font-weight: 700; }
.cal-week .col.today .col-head .dn { color: var(--accent); }
.cal-week .col-body { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.cal-week .cal-ev { height: auto; min-height: 40px; align-items: stretch; flex-direction: row; padding: 0; }
.cal-week .cal-ev .inner { padding: 5px 8px 6px 4px; display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.cal-week .cal-ev .ttl { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; font-size: 12.5px; color: var(--text-2); }

/* ---------- misc ---------- */
.empty { padding: 22px 20px; text-align: center; color: var(--text-3); }
.empty strong { display: block; color: var(--text-3); font-size: 14px; font-weight: 600; }
.empty .help { margin-left: 4px; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-top: 1px solid var(--border); min-width: 0; }
.list-row:first-child { border-top: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { font-weight: 600; color: var(--text); }
.list-row .sub { color: var(--text-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check-row .sub { white-space: normal; }
/* An employee's Tools tab: a tool's policy shows once it is ticked (the row keeps its height). */
.list-row:has(> input.cb:not(:checked)) > .tool-policy { visibility: hidden; }
.check-mark { width: 24px; height: 24px; border-radius: 12px; display: inline-grid; place-items: center; flex: none; }
.check-mark.ok { background: var(--success-soft); color: var(--success); }
.check-mark.todo { background: var(--surface-3); color: var(--text-3); }
.check-mark.bad { background: var(--danger-soft); color: var(--danger); }
/* An employee's Tools tab: each kind of tool under its own heading. */
.tool-section { display: flex; align-items: center; gap: 12px; padding: 16px 16px 8px; border-top: 1px solid var(--border); }
.tool-section:first-child { border-top: 0; }
.tool-section-title { font-weight: 650; font-size: 13.5px; }
.tool-section .sub { color: var(--text-3); font-size: 12.5px; margin-top: 2px; }
/* An input with its own button on the same line (e.g. Save). */
.input-with-button { display: flex; gap: 8px; align-items: center; }
.input-with-button > .input { flex: 1; min-width: 0; }
/* A property value taller than about six lines folds; Show more opens it (src/client: data-clamp). */
.v-clamp { display: block; max-height: 9.2em; overflow: hidden; overflow-wrap: anywhere; }
.v-clamp.clamped:not(.open) { -webkit-mask-image: linear-gradient(#000 62%, transparent); mask-image: linear-gradient(#000 62%, transparent); }
.v-clamp.open { max-height: none; }
.clamp-toggle { display: inline-block; margin-top: 4px; padding: 0; border: 0; background: none; color: var(--accent); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.clamp-toggle:hover { text-decoration: underline; }
/* A small action that reads as a link inside a sentence (e.g. a hire's review switch). */
.link-like { padding: 0; border: 0; background: none; color: var(--accent); font: inherit; cursor: pointer; }
.link-like:hover { text-decoration: underline; }
/* A picked channel's check in the practice dialog: what it lacks of what the employee needs. */
.needs-check { margin-top: 10px; padding: 10px 12px; border-radius: var(--radius); font-size: 13px; }
.needs-check.ready { background: var(--success-soft); color: var(--success); }
.needs-check.lacking { background: var(--warning-soft, rgba(240, 180, 80, 0.14)); color: var(--text); }
.needs-check .needs-head { font-weight: 600; }
.needs-check ul { margin: 6px 0 0 18px; padding: 0; }
.check-mark.live { background: var(--accent-soft); color: var(--accent); animation: live-pulse 1.6s ease-in-out infinite; }
@keyframes live-pulse { 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) { .check-mark.live { animation: none; } }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; }
/* 12.1: a long section name ("Auto-approve hand-planned posts") wraps inside its item instead of running past it. */
.settings-nav .sb-link { height: auto; min-height: 38px; padding-block: 7px; white-space: normal; line-height: 1.3; }
.settings-grid { display: grid; grid-template-columns: 220px minmax(0, 760px); gap: 28px; align-items: start; }
.cmd[popover] { position: fixed; inset: 72px auto auto 50%; transform: translateX(-50%); width: min(640px, calc(100vw - 32px)); margin: 0; padding: 0; border: 1px solid var(--border-2); border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-2); }
.cmd input { border: 0; border-bottom: 1px solid var(--border); border-radius: 14px 14px 0 0; height: 52px; padding: 0 18px; font-size: 15px; background: transparent; width: 100%; }
.cmd input:focus { box-shadow: none; outline: none; }
.cmd .results { max-height: 420px; overflow: auto; padding: 6px; }
.cmd .grp { padding: 8px 10px 4px; font-size: 11.5px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; }
.cmd .res { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.cmd .res .sub { color: var(--text-3); font-size: 12.5px; margin-left: auto; }
.cmd .res:hover, .cmd .res.active { background: var(--surface-3); text-decoration: none; }
.cmd .none { padding: 18px; color: var(--text-3); text-align: center; }
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 50% -10%, var(--accent-soft), transparent 70%), var(--bg); }
.login-card { width: min(400px, 100%); padding: 28px; }
.login-card .sb-mark { width: 40px; height: 40px; font-size: 19px; border-radius: 10px; }
.code-block { font: 12.5px/1.6 var(--mono); }
.bar-meter { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.bar-meter > span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

/* ---------- responsive ---------- */
/* Below 1600px the record is two zones: the side cards stack under the
   properties (row 2 starts right after them) and the middle spans both rows. */
@media (max-width: 1599px) {
  .record, .record.wide { grid-template-columns: 300px minmax(0, 1fr); grid-template-rows: auto auto 1fr; grid-template-areas: "id mid" "left mid" "right mid"; }
  .record.has-aside, .record.wide.has-aside { grid-template-rows: auto auto auto 1fr; grid-template-areas: "id mid" "aside mid" "left mid" "right mid"; }
}
@media (max-width: 960px) {
  .app, .app.rail { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 268px; z-index: 300; transform: translateX(-100%); transition: transform 0.18s ease; box-shadow: var(--shadow-2); }
  .app.drawer-open .sidebar { transform: none; }
  .app.drawer-open::after { content: ""; position: fixed; inset: 0; background: var(--overlay); z-index: 299; }
  .app.rail .sb-name, .app.rail .sb-label, .app.rail .sb-section, .app.rail .sb-count { display: revert; }
  .content { padding: 16px 14px 32px; }
  .content.fill { overflow: auto; display: block; }
  .record, .record.wide { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; grid-template-areas: "id" "mid" "left" "right"; }
  .record.has-aside, .record.wide.has-aside { grid-template-areas: "id" "aside" "mid" "left" "right"; }
  .stat-row, .stat-row.five, .stat-row.six { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .settings-nav { position: static; flex-direction: row; overflow-x: auto; }
  .settings-nav .sb-link { white-space: nowrap; }
  .split { grid-template-columns: minmax(0, 1fr); }
  .board { grid-template-columns: minmax(0, 1fr); }
  .toolbar .search { flex: 1 1 100%; max-width: none; order: -1; }
  /* 12.1: on a phone the Queue's four filters sit two to a row, so the list starts a screen sooner. The second of
     each pair is the wider one: it holds the longer words (a business's name, "Only what blocks work"). */
  .toolbar[data-grid-toolbar="queue"] .filter { flex: 1 1 calc(40% - 4px); min-width: 0; max-width: none; }
  .toolbar[data-grid-toolbar="queue"] select.filter:nth-of-type(even) { flex-basis: calc(60% - 4px); }
  .tb-search kbd { display: none; }
  .grid-wrap { max-height: none; }
  .decision .effects { grid-template-columns: minmax(0, 1fr); }
  .cal { min-height: 640px; }
}
@media (min-width: 961px) {
  .only-mobile { display: none !important; }
}
@media (max-width: 700px) {
  /* Rows with actions (the Schedule tab): the text takes the whole width; the actions wrap under it. */
  .list-row.stacks { flex-wrap: wrap; row-gap: 8px; }
  /* Ticket #80: a bank row's actions (Check, Remove) wrap under the title, each a 44px tap target. */
  .list-row.bank-row { flex-wrap: wrap; row-gap: 8px; }
  .list-row.bank-row > .grow { flex: 1 1 100%; }
  .list-row.bank-row .sub { white-space: normal; }
  .list-row.bank-row .btn { min-height: 44px; }
  .list-row.stacks > .grow { flex: 1 1 100%; }
  .list-row.stacks > .when { width: 100% !important; }
  .list-row.stacks .sub, .list-row.wraps .sub { white-space: normal; }
  /* A "Show more" under folded text is a full-size tap target on a phone. */
  .clamp-toggle { min-height: 36px; padding: 0 2px; }
  /* The grid becomes a stack of record cards: identity first, key properties labelled. */
  .grid-wrap { border: 0; background: transparent; box-shadow: none; overflow: visible; }
  table.grid, .grid thead, .grid tbody, .grid tr, .grid td { display: block; width: 100% !important; min-width: 0; }
  .grid colgroup, .grid thead { display: none; }
  .grid tr { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; padding: 8px 4px 8px 0; position: relative; }
  .grid td { border: 0 !important; height: auto; min-height: 30px; padding: 4px 14px 4px 14px; white-space: normal; display: flex; align-items: center; gap: 10px; }
  .grid td[data-label]::before { content: attr(data-label); flex: none; width: 104px; color: var(--text-3); font-size: 12px; font-weight: 600; }
  .grid td.primary { font-size: 15px; padding-top: 8px; }
  .grid td.primary::before { display: none; }
  .grid td.sel { position: absolute; right: 8px; top: 10px; width: 36px !important; min-height: 36px; padding: 0; }
  .grid td.filler { display: none; }
  .grid .editable { display: inline-flex; align-items: center; min-height: 36px; }
  /* Card titles wrap, clear of the selection checkbox in the corner. */
  .grid td.primary { padding-right: 52px; }
  .grid td.primary .cell-stack > *, .grid td.primary .cell-name a { white-space: normal; }
  /* A phone's top bar: menu, search, and icon-only actions. */
  .topbar { gap: 8px; padding: 0 10px; }
  .tb-right { gap: 6px; }
  .tb-right .btn.primary > span { display: none; }
  .tb-right .btn.primary { width: var(--control-h); padding: 0; }
  .env-pill { padding: 0 8px; }
  .page-head { flex-wrap: wrap; row-gap: 10px; }
  .page-head .actions { flex-wrap: wrap; }
  /* Month on a phone: each post is a colored bar; tap the day to read it. */
  .cal-grid .cal-cell { padding: 4px 3px; gap: 3px; }
  .cal-grid .cal-ev { height: 6px; min-height: 0; padding: 0; border: 0; border-radius: 3px; overflow: hidden; }
  .cal-grid .cal-ev > :not(.bar) { display: none; }
  .cal-grid .cal-ev .bar { width: 100%; height: 100%; }
  .cal-day .add { display: none; }
  .grid tbody tr:hover td, .grid tbody tr.selected td { background: transparent; }
  .grid tbody tr.selected { border-color: var(--accent-line); background: var(--row-selected); }
  .pager .per { margin-left: 0; }
  .pager { flex-wrap: wrap; }
  .page-head h1 { font-size: 19px; }
  .stat .v { font-size: 22px; }
  .kv { grid-template-columns: minmax(0, 1fr); }
  .kv dt { padding-bottom: 0; }
  .kv dd { border-top: 0; padding-top: 2px; }
  .cal-grid .cal-ev .t { display: none; }
}

/* Search pickers (select[data-picker], src/client/main.ts) */
.picker { position: relative; }
.picker-native { display: none !important; }
.picker-input { padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%238b99ab' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; }
.picker-list { position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; right: 0; max-height: 300px; overflow: auto; padding: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-2); }
.picker.inline .picker-list { position: static; margin-top: 4px; max-height: 248px; box-shadow: var(--shadow-1); }
.picker-opt { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.picker-opt.active, .picker-opt:hover { background: var(--surface-3); }
.picker-opt[aria-selected="true"] .picker-main { font-weight: 650; }
.picker-opt.none .picker-main { color: var(--text-2); font-style: italic; }
.picker-text { flex: 1; min-width: 0; }
.picker-main, .picker-sub { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-main { color: var(--text); font-size: 13.5px; }
.picker-sub { color: var(--text-3); font-size: 12px; margin-top: 1px; }
.picker-tag { flex: none; font-size: 12px; color: var(--text-3); white-space: nowrap; }
.picker-tag.ok { color: var(--success); }
.picker-tag.warn { color: var(--warning); }
.picker-note { padding: 8px 10px; font-size: 12.5px; color: var(--text-3); }
.toolbar .picker { width: 220px; }
.assoc-more > summary { padding: 9px 16px; border-top: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--accent); cursor: pointer; list-style: none; }
.assoc-more > summary::-webkit-details-marker { display: none; }
.assoc-more > summary:hover { text-decoration: underline; }
.assoc-more .when-open, .assoc-more[open] .when-shut { display: none; }
.assoc-more[open] .when-open { display: inline; }
.assoc .item .sub a { color: var(--text-2); font-weight: 500; }
.assoc .item .sub a:hover { color: var(--accent); }
.prop-more > summary { cursor: pointer; color: var(--accent); font-size: 13px; font-weight: 600; list-style: none; }
.prop-more > summary::-webkit-details-marker { display: none; }

/* Formatted / Raw long text (ticket #43). The page's <html data-md> holds the person's choice; one switch flips all. */
html[data-md="raw"] .lt-fmt, html:not([data-md="raw"]) .lt-raw { display: none; }
.md-toggle { height: var(--control-h-sm); }
.md-toggle button { padding: 0 10px; font-size: 12.5px; }
html:not([data-md="raw"]) .md-toggle [data-md-set="fmt"], html[data-md="raw"] .md-toggle [data-md-set="raw"] { background: var(--accent-soft); color: var(--text); }
.longtext .lt-fmt { margin-top: 6px; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); max-height: 640px; overflow: auto; }
.md { line-height: 1.6; color: var(--text); word-break: break-word; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md blockquote, .md .md-table, .md pre { margin: 0 0 10px; }
.md ul, .md ol { padding-left: 22px; }
.md ul { list-style: disc; }
.md ol { list-style: decimal; }
.md li ul { list-style: circle; }
.md li + li { margin-top: 3px; }
.md li > ul, .md li > ol { margin: 4px 0 0; }
.md .md-h { font-weight: 680; color: var(--text); margin: 16px 0 6px; line-height: 1.3; }
.md .md-h1 { font-size: 18px; }
.md .md-h2 { font-size: 16px; }
.md .md-h3 { font-size: 14.5px; }
.md .md-h4, .md .md-h5, .md .md-h6 { font-size: 13.5px; color: var(--text-2); }
.md code { font: 12.5px/1.4 var(--mono); padding: 1px 5px; border-radius: 5px; background: var(--surface-sunken); border: 1px solid var(--border); }
.md pre.md-code { margin-top: 0; max-height: 420px; }
.md pre.md-code code { padding: 0; border: 0; background: none; }
.md blockquote { padding: 2px 0 2px 12px; border-left: 3px solid var(--border-strong, var(--border)); color: var(--text-2); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.md a { color: var(--accent); }
.md .md-href { color: var(--text-3, var(--text-2)); font-size: 12px; }
.md .md-table { overflow-x: auto; }
.md table { border-collapse: collapse; font-size: 13px; min-width: 50%; }
.md th, .md td { border: 1px solid var(--border); padding: 5px 9px; text-align: left; vertical-align: top; }
.md th { background: var(--surface-3); font-weight: 640; }
.md li.md-task { list-style: none; margin-left: -20px; }
.md .md-box { display: inline-block; width: 13px; height: 13px; border: 1.5px solid var(--text-2); border-radius: 3px; margin-right: 7px; vertical-align: -1px; }
.md .md-box.done { background: var(--success, var(--accent)); border-color: var(--success, var(--accent)); }

/* A video's page (ticket #40): where it stands, its thumbnail options, its Studio steps. */
.status-strip .card-body { padding: 12px 16px; }
.strip-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.strip-head strong { font-size: 14.5px; }
.strip { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.strip-step { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 560; border: 1px solid var(--border); color: var(--text-3); background: var(--surface-2); }
.strip-step.done { color: var(--success); border-color: color-mix(in srgb, var(--success) 35%, transparent); background: color-mix(in srgb, var(--success) 10%, transparent); }
.strip-step.you { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 50%, transparent); background: color-mix(in srgb, var(--warning) 14%, transparent); font-weight: 650; }
.strip-step.you a { color: inherit; }
.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.thumb-option { margin: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.thumb-option.picked { border-color: var(--success); box-shadow: 0 0 0 2px color-mix(in srgb, var(--success) 40%, transparent); }
.thumb-option img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--surface-3); }
.thumb-option figcaption { display: flex; align-items: center; gap: 8px; padding: 8px 10px; flex-wrap: wrap; min-height: 46px; }
.thumb-letter { font-size: 15px; width: 22px; }
.thumb-option.suggested { border-color: var(--accent); }
.thumb-notes { padding: 8px 10px 0; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.thumb-headline { font-weight: 640; line-height: 1.35; }
/* Ticket #86: a business's brand tab. */
.brand-now-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.brand-now { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.brand-now-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.brand-now .sub { overflow-wrap: anywhere; }
.brand-none { display: flex; align-items: center; justify-content: center; min-height: 96px; border: 1px dashed var(--border); border-radius: 10px; text-align: center; padding: 8px; }
.brand-img { display: block; width: 100%; background: var(--surface-3); object-fit: contain; }
.brand-img.is-avatar { aspect-ratio: 1 / 1; max-width: 160px; border-radius: 50%; object-fit: cover; margin: 10px auto; }
.brand-img.is-banner { aspect-ratio: 16 / 5; object-fit: cover; }
.brand-now .brand-img.is-avatar { margin: 0; }
.brand-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.brand-grid.is-banner { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.swatch { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 3px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); font-size: 12.5px; }
.swatch-chip { width: 22px; height: 22px; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--text) 25%, transparent); }
/* Ticket #88: title options and test sets. */
.title-opts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.title-opt { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.title-opt.picked { border-color: var(--success); box-shadow: 0 0 0 2px color-mix(in srgb, var(--success) 40%, transparent); }
.title-opt.suggested { border-color: var(--accent); }
.title-opt .thumb-letter { margin-top: 1px; }
.title-opt > .grow { flex: 1; min-width: 0; }
.test-state > span:nth-child(2) { flex: 1 1 260px; }
.title-text { font-weight: 640; line-height: 1.35; overflow-wrap: anywhere; }
.title-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.test-tick { width: 16px; height: 16px; margin: 3px 0 0; accent-color: var(--accent); flex: none; }
.test-tick-label { display: flex; align-items: center; gap: 6px; padding: 6px 10px 0; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.test-tick-label .test-tick { margin: 0; }
.test-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.test-state { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; padding: 8px 12px; border: 1px dashed var(--accent); border-radius: 10px; font-size: 13px; }
.studio-steps { list-style: none; margin: -4px 0 0; padding: 0; }
.studio-step { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.studio-step:last-child { border-bottom: 0; }
.studio-step.done > .grow > div:first-child { color: var(--text-3); text-decoration: line-through; }
.studio-step .tick { width: 20px; height: 20px; border-radius: 5px; border: 1.5px solid var(--text-2); background: transparent; display: inline-flex; align-items: center; justify-content: center; color: #fff; cursor: pointer; padding: 0; }
.studio-step.done .tick { background: var(--success); border-color: var(--success); }
.studio-step .tick:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* The lead card (ticket #39 phase 1): the essentials first on a phone; fields, not a text box. */
.glance .glance-top { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.glance .glance-name { font-size: 18px; font-weight: 680; line-height: 1.25; }
.glance .glance-said { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); white-space: pre-wrap; word-break: break-word; display: -webkit-box; -webkit-line-clamp: 8; -webkit-box-orient: vertical; overflow: hidden; }
.glance .glance-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.field-grid > .btn-row { grid-column: 1 / -1; }
.field-grid > .field + .field { margin-top: 0; }
details.provider > summary { display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none; }
details.provider > summary::-webkit-details-marker { display: none; }
details.provider { display: block; }
details.provider.archived .title { color: var(--text-3); }
.proposals { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.proposal + .proposal { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.proposal ul { margin: 6px 0 10px; padding-left: 20px; list-style: disc; }

/* ---------- D42: keywords, ranks, recipe checklists, stats (tickets #44 + #55) ---------- */
/* Chart series: the dataviz reference categorical order, validated (scripts/validate_palette.js) against this app's
   own surfaces — dark #18202b all checks pass; light #ffffff passes with slots 3–4 under 3:1, so every chart carries
   direct labels and a table view (the relief rule). Text never wears a series color. */
:root, [data-theme="dark"] { --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --viz-grid: #2a3646; --viz-marker: #8b99ab; }
[data-theme="light"] { --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100; --viz-grid: #e3e8ee; --viz-marker: #7e8b9d; }
.kw-list { display: flex; flex-direction: column; gap: 10px; }
.kw-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.kw { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border-radius: 14px; border: 1px solid var(--border-2); background: var(--surface-2); font-size: 13px; font-weight: 600; color: var(--text); max-width: 100%; }
.kw.main { border-color: var(--accent-line); background: var(--accent-soft); }
.kw .tag-main { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); }
.kw-evidence { font-size: 12px; color: var(--text-3); }
.rank { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 12px; background: var(--surface-3); font-size: 12px; font-weight: 600; color: var(--text-2); white-space: nowrap; text-decoration: none; }
a.rank:hover { color: var(--text); text-decoration: none; background: var(--border); }
.rank .pos { color: var(--text); font-weight: 720; font-variant-numeric: tabular-nums; }
.trend { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.trend.better { color: var(--success); }
.trend.worse { color: var(--danger); }
.trend.same, .trend.new { color: var(--text-3); }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; font-size: 12px; font-weight: 650; color: var(--text-3); padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: 9px 10px; border-top: 1px solid var(--border); vertical-align: top; }
.data-table tr:first-child td { border-top: 0; }
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .sub { display: block; color: var(--text-3); font-size: 12px; margin-top: 2px; }
.table-wrap { overflow-x: auto; margin: -14px -16px -16px; }
.table-wrap .data-table th:first-child, .table-wrap .data-table td:first-child { padding-left: 16px; }
.table-wrap .data-table th:last-child, .table-wrap .data-table td:last-child { padding-right: 16px; }
.tier-head td { background: var(--surface-2); font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); padding-top: 7px; padding-bottom: 7px; }
.meter { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; min-width: 80px; }
.meter > span { display: block; height: 100%; border-radius: 4px; background: var(--series-1); }
.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.stats-grid > .card + .card { margin-top: 0; }
@media (max-width: 900px) { .stats-grid { grid-template-columns: minmax(0, 1fr); } }
.viz { margin: 0; }
.viz .legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 8px; font-size: 12.5px; color: var(--text-2); }
.viz .legend .key { display: inline-flex; align-items: center; gap: 6px; }
.viz .legend .swatch { width: 14px; height: 2px; border-radius: 1px; }
.viz .plot { position: relative; }
.viz svg { display: block; width: 100%; height: auto; overflow: visible; }
.viz svg .grid-line { stroke: var(--viz-grid); stroke-width: 1; }
.viz svg .axis-text { fill: var(--text-3); font-size: 11px; font-family: inherit; }
.viz svg .label-text { fill: var(--text-2); font-size: 11.5px; font-weight: 600; font-family: inherit; }
.viz svg .series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz svg .event-line { stroke: var(--viz-marker); stroke-width: 1; stroke-dasharray: 3 3; }
.viz svg .crosshair { stroke: var(--text-3); stroke-width: 1; }
.viz .tip { position: absolute; top: 0; pointer-events: none; background: var(--surface); border: 1px solid var(--border-2); border-radius: 8px; box-shadow: var(--shadow-2); padding: 8px 10px; font-size: 12px; min-width: 140px; z-index: 5; }
.viz .tip .when { color: var(--text-3); font-weight: 600; margin-bottom: 4px; }
.viz .tip .row { display: flex; align-items: center; gap: 8px; }
.viz .tip .row b { color: var(--text); font-variant-numeric: tabular-nums; }
.viz .tip .row span { color: var(--text-2); }
.viz .tip .key { width: 12px; height: 2px; border-radius: 1px; flex: none; }
.viz .note { font-size: 12px; color: var(--text-3); margin-top: 6px; }
.viz details { margin-top: 8px; font-size: 12.5px; }
.viz details summary { cursor: pointer; color: var(--text-2); }
.dot-cell { display: inline-block; width: 10px; height: 10px; border-radius: 5px; border: 1.5px solid var(--text-3); }
.dot-cell.on { background: var(--series-1); border-color: var(--series-1); }
.nowrap { white-space: nowrap; }
.kw { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viz .plot { overflow-x: auto; }
.viz svg { min-width: 520px; }

/* #58: the employee's recommended answer — marked beside the buttons, never chosen for the person. */
.decision .recommendation { display: grid; gap: 3px; margin: 0 0 10px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--accent-line); background: var(--accent-soft); font-size: 13px; }
.decision .recommendation .rec-label { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.decision .recommendation .rec-label b { color: var(--text); }
.decision .recommendation .rec-why { color: var(--text); line-height: 1.45; }
.decision .recommendation .rec-foot { font-size: 12px; }
.btn[data-recommended="true"] { box-shadow: 0 0 0 2px var(--accent-line); }
.btn[data-recommended="true"]::after { content: "Recommended"; margin-left: 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.02em; color: var(--accent); }
/* A pick-one's options are sentences: they wrap inside the card instead of running off a phone screen. */
.decision .composer .btn-row .btn { white-space: normal; height: auto; min-height: var(--control-h); padding-block: 8px; line-height: 1.3; text-align: left; max-width: 100%; }

/* D131: a carousel piece — one square slide per view, scroll-snap; its caption beside it on a wide screen, below on a narrow one. */
.carousel-wrap { display: grid; grid-template-columns: minmax(0, 480px) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 800px) { .carousel-wrap { grid-template-columns: minmax(0, 1fr); } }
.carousel-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth; border: 1px solid var(--border); border-radius: 10px; aspect-ratio: 1 / 1; width: 100%; background: var(--surface-3); scrollbar-width: none; }
.carousel-track::-webkit-scrollbar { display: none; }
.carousel-track:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.carousel-slide { flex: 0 0 100%; aspect-ratio: 1 / 1; scroll-snap-align: start; position: relative; margin: 0; overflow: hidden; }
.carousel-slide img { display: block; width: 100%; height: 100%; object-fit: cover; }
.carousel-text { width: 100%; height: 100%; box-sizing: border-box; display: flex; align-items: center; justify-content: center; text-align: center; padding: 12% 14%; background: var(--surface); color: var(--text); font-size: 1.15rem; line-height: 1.4; white-space: pre-wrap; overflow: auto; }
.carousel-btn { position: absolute; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 24px; line-height: 1; text-decoration: none; background: color-mix(in srgb, var(--surface-sunken) 85%, transparent); color: var(--text); border: 1px solid var(--border-2); }
.carousel-btn.prev { left: 8px; } .carousel-btn.next { right: 8px; }
.carousel-btn:hover { border-color: var(--accent); }
.carousel-btn:focus-visible { outline: 2px solid var(--accent); }
.carousel-btn[aria-disabled="true"] { opacity: .35; pointer-events: none; }
.carousel-status { margin-top: 6px; font-size: 13px; color: var(--text-2); text-align: center; }
.carousel-plan { white-space: pre-wrap; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); font-size: 13px; }
@media (prefers-reduced-motion: reduce) { .carousel-track { scroll-behavior: auto; } }
