/* Watchkeep console design system (C22, from the approved mockups). Tokens first: every color, radius, shadow and size is
   a custom property, light by default and dark by the system preference or [data-theme="dark"]. No external font or
   asset. Then the base, the shell (sidebar, top bar) and the components used everywhere; page layouts are in pages.css. */
:root {
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Inter", Roboto, "Helvetica Neue", sans-serif;
  --mono: "Cascadia Code", "Cascadia Mono", ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --bg: #f6f6f7; --surface: #ffffff; --surface-2: #fafafa; --sidebar: #fbfbfc; --hover: #f1f1f3; --active: #ebebef;
  --text: #18181b; --text-2: #3f3f46; --muted: #63636c; --faint: #a1a1aa;
  --border: #e4e4e7; --border-strong: #d4d4d8;
  --accent: #4f46e5; --accent-hover: #4338ca; --accent-soft: #eef2ff; --accent-text: #ffffff; --accent-ink: #3730a3;
  --green: #15803d; --green-soft: #dcfce7; --amber: #a3480b; --amber-soft: #fef3c7; --red: #b91c1c; --red-soft: #fee2e2;
  --blue: #1d4ed8; --blue-soft: #dbeafe; --violet: #6d28d9; --violet-soft: #ede9fe; --grey-soft: #f4f4f5;
  --bar-merged: #22c55e; --bar-done: #86efac; --bar-review: #3b82f6; --bar-progress: #6366f1; --bar-todo: #d4d4d8;
  --bar-parked: #f59e0b; --bar-abandoned: #f87171;
  --logo-from: #4f46e5; --logo-to: #7c3aed; --on-color: #ffffff; --knob: #ffffff;
  --term-bg: #0f1115; --term-text: #d4d4d8; --term-dim: #9a9aa3; --term-ok: #4ade80; --term-bad: #fca5a5;
  --scrim: rgba(9, 9, 11, .45); --skeleton: #ececef; --skeleton-hi: #f6f6f8;
  --r-sm: 6px; --r: 8px; --r-lg: 12px; --r-full: 999px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12), 0 2px 6px rgba(16, 24, 40, .06);
  --ring: 0 0 0 3px rgba(79, 70, 229, .35);
  --side-w: 248px; --tap: 32px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0c0e; --surface: #141417; --surface-2: #18181b; --sidebar: #101013; --hover: #1d1d21; --active: #26262b;
    --text: #f4f4f5; --text-2: #d4d4d8; --muted: #a1a1aa; --faint: #71717a;
    --border: #26262b; --border-strong: #3f3f46;
    --accent: #818cf8; --accent-hover: #a5b4fc; --accent-soft: rgba(129, 140, 248, .14); --accent-text: #0c0c0e; --accent-ink: #c7d2fe;
    --green: #4ade80; --green-soft: rgba(74, 222, 128, .12); --amber: #fbbf24; --amber-soft: rgba(251, 191, 36, .12);
    --red: #f87171; --red-soft: rgba(248, 113, 113, .12); --blue: #60a5fa; --blue-soft: rgba(96, 165, 250, .12);
    --violet: #a78bfa; --violet-soft: rgba(167, 139, 250, .14); --grey-soft: #1d1d21;
    --bar-todo: #3f3f46; --bar-done: #166534;
    --term-bg: #09090b; --skeleton: #1d1d21; --skeleton-hi: #26262b; --scrim: rgba(0, 0, 0, .6);
    --shadow-sm: none; --shadow: 0 0 0 1px rgba(255, 255, 255, .02); --shadow-lg: 0 16px 40px rgba(0, 0, 0, .5);
    --ring: 0 0 0 3px rgba(129, 140, 248, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #0c0c0e; --surface: #141417; --surface-2: #18181b; --sidebar: #101013; --hover: #1d1d21; --active: #26262b;
    --text: #f4f4f5; --text-2: #d4d4d8; --muted: #a1a1aa; --faint: #71717a;
    --border: #26262b; --border-strong: #3f3f46;
    --accent: #818cf8; --accent-hover: #a5b4fc; --accent-soft: rgba(129, 140, 248, .14); --accent-text: #0c0c0e; --accent-ink: #c7d2fe;
    --green: #4ade80; --green-soft: rgba(74, 222, 128, .12); --amber: #fbbf24; --amber-soft: rgba(251, 191, 36, .12);
    --red: #f87171; --red-soft: rgba(248, 113, 113, .12); --blue: #60a5fa; --blue-soft: rgba(96, 165, 250, .12);
    --violet: #a78bfa; --violet-soft: rgba(167, 139, 250, .14); --grey-soft: #1d1d21;
    --bar-todo: #3f3f46; --bar-done: #166534;
    --term-bg: #09090b; --skeleton: #1d1d21; --skeleton-hi: #26262b; --scrim: rgba(0, 0, 0, .6);
    --shadow-sm: none; --shadow: 0 0 0 1px rgba(255, 255, 255, .02); --shadow-lg: 0 16px 40px rgba(0, 0, 0, .5);
    --ring: 0 0 0 3px rgba(129, 140, 248, .45);
    color-scheme: dark;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { letter-spacing: -.01em; line-height: 1.3; }
h2 { font-size: 16px; font-weight: 650; margin: 4px 0 10px; }
h3 { font-size: 14px; font-weight: 600; margin: 14px 0 8px; }
code, pre, kbd, .mono { font-family: var(--mono); font-size: 12px; }
.num, td, .stat .value, .count, .n { font-variant-numeric: tabular-nums; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.vh, .sr { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
.grow { flex: 1; }
.note { color: var(--muted); margin: 0 0 10px; overflow-wrap: anywhere; }
.note.warn, .meta.warn, .warn > .panel-line { color: var(--amber); }
.note.error, .error, .meta.bad { color: var(--red); }
.meta { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.meta.ok { color: var(--green); }
.text { overflow-wrap: anywhere; margin: 6px 0; }

/* focus: every interactive element keeps a visible ring */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible,
.btn:focus-visible, .card:focus-visible, .navlink:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; box-shadow: var(--ring); }
.toggle input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.file input:focus-visible + .file-name, .file label:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- the shell: sidebar + main ---------- */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 1px; padding: 14px 10px; background: var(--sidebar); border-right: 1px solid var(--border); overflow-y: auto; scrollbar-width: thin; z-index: 30; }
.side > * { flex: none; }
.logo { display: flex; align-items: center; gap: 10px; padding: 2px 8px 12px; color: var(--text); font-weight: 650; font-size: 15px; letter-spacing: -.01em; }
.logo:hover { text-decoration: none; }
.logo .mark { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; background: linear-gradient(135deg, var(--logo-from), var(--logo-to)); }
.logo .mark svg.i { stroke: var(--on-color); vertical-align: 0; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.navlink { display: flex; align-items: center; gap: 10px; min-height: var(--tap); padding: 5px 10px; border-radius: var(--r-sm); color: var(--text-2); font-weight: 500; }
.navlink:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.navlink[aria-current="page"] { background: var(--active); color: var(--text); font-weight: 600; }
.navlink[aria-current="page"] svg.i { color: var(--accent); }
.navlink .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.navlink .count { min-width: 20px; padding: 0 6px; border-radius: var(--r-full); background: var(--grey-soft); color: var(--text-2); font-size: 11.5px; font-weight: 600; text-align: center; line-height: 18px; }
.navlink .count.hot { background: var(--amber-soft); color: var(--amber); }
.navlink .count.live { background: var(--green-soft); color: var(--green); }
.side .spacer { flex: 1; min-height: 16px; }
.newproj { width: 100%; justify-content: center; }
.newproj[aria-current="page"] { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }
.me { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 12px 8px 4px; margin-top: 8px; border-top: 1px solid var(--border); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); font-weight: 650; font-size: 12px; }
.me .who { flex: 1; min-width: 0; line-height: 1.25; }
.me .who .name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.me .who small { display: block; color: var(--muted); font-size: 12px; }
.me-actions { display: flex; flex-basis: 100%; align-items: center; gap: 2px; }
.me-actions .theme-toggle { margin-left: auto; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-height: 57px; padding: 10px 28px; background: var(--bg); border-bottom: 1px solid var(--border); }
@supports (backdrop-filter: blur(8px)) { .topbar { background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); } }
.crumbs { min-width: 0; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumbs b { color: var(--text); font-weight: 600; }
.fresh { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.fresh:empty { display: none; }
#fresh:not(.stale) { display: none; } /* C31: shown only when the data is stale (past twice its refresh period) */
.fresh::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.fresh.stale { color: var(--amber); }
.fresh.stale::before { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.reqbar { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.reqbar:empty { display: none; }
.topmore { position: relative; display: none; }
.topmore > summary { list-style: none; }
.topmore > summary::-webkit-details-marker { display: none; }
.topmore-menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 25; display: flex; flex-direction: column; align-items: stretch; gap: 8px; width: min(280px, calc(100vw - 32px)); padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); }
.topmore-menu .reqbar { display: flex; flex-direction: column; align-items: stretch; }
.topmore-menu .reqbar:empty { display: none; }
.topbar .menu-btn { display: none; }
.scrim { display: none; }
.content { min-width: 0; padding: 24px 28px 96px; }
.pagehead { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; margin-bottom: 20px; }
.pagehead h1 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -.02em; overflow-wrap: anywhere; }
.pagehead p { margin: 4px 0 0; color: var(--muted); }
.pagehead .grow { flex: 1; }
.content > h2:first-child, .content > section > h2:first-child, .content > div > h2:first-child, .content > .row > h2 { margin: 0 0 16px; font-size: 22px; font-weight: 650; letter-spacing: -.02em; }
.back { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 12px; color: var(--muted); font-size: 13px; font-weight: 500; }
.back:hover { color: var(--text); }

/* ---------- buttons ---------- */
button, .btn, a.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 32px; padding: 5px 12px; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 500 13px/1.3 var(--font); box-shadow: var(--shadow-sm); cursor: pointer; text-decoration: none; }
button:hover, .btn:hover, a.button:hover { background: var(--hover); text-decoration: none; }
button:disabled, .btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary, button[type="submit"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover, button[type="submit"]:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.secondary, button.secondary { background: var(--surface); color: var(--text); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.warn { background: var(--amber-soft); border-color: transparent; box-shadow: none; color: var(--amber); }
.btn.danger, button.chat-deny { color: var(--red); }
.btn.danger:hover { background: var(--red-soft); }
.btn.sm { min-height: 28px; padding: 3px 10px; font-size: 12.5px; }
.btn.block { width: 100%; }
.btn.icon-only { width: 32px; padding: 0; }
button.link { display: inline; min-height: 0; padding: 0; border: 0; background: none; box-shadow: none; color: var(--accent); font: inherit; text-decoration: underline; }
.close { float: right; margin: 0 0 8px 8px; }

/* ---------- inputs, selects, checkboxes, toggles, the file picker ---------- */
.input, select, textarea, input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"], input:not([type]) {
  min-height: 34px; max-width: 100%; padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: var(--r); background-color: var(--surface); color: var(--text); font: inherit; font-size: 13.5px;
}
textarea { min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.5; width: 100%; }
select { appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; cursor: pointer; }
.input:focus, select:focus, textarea:focus, input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
::placeholder { color: var(--faint); opacity: 1; }
input:disabled, select:disabled, textarea:disabled { color: var(--faint); background-color: var(--surface-2); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; margin: 0 6px 0 0; accent-color: var(--accent); vertical-align: -3px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-2); }
.flabel { font-weight: 550; color: var(--text-2); }
.stack { display: flex; flex-direction: column; gap: 10px; margin: 8px 0; }
fieldset { border: 1px solid var(--border); border-radius: var(--r-lg); padding: 10px 14px; margin: 0; }
legend { padding: 0 6px; color: var(--text-2); font-weight: 600; }
.toggle { display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); color: var(--text-2); font-size: 13px; cursor: pointer; }
.toggle .track { position: relative; width: 30px; height: 18px; border-radius: var(--r-full); background: var(--border-strong); transition: background .15s; }
.toggle .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--knob); box-shadow: var(--shadow-sm); transition: transform .15s; }
.toggle input:checked + .track { background: var(--accent); }
.toggle input:checked + .track::after { transform: translateX(12px); }
.file { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; color: var(--muted); font-size: 13px; }
.file label { position: relative; }
.file-name { min-width: 0; overflow-wrap: anywhere; }

/* ---------- chips, dots, badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; min-height: 20px; padding: 0 8px; margin: 0 4px 2px 0; border-radius: var(--r-full); background: var(--grey-soft); color: var(--text-2); font-size: 11.5px; font-weight: 550; white-space: nowrap; vertical-align: middle; }
.chip.green, .chip.ok, .chip.live, .chip.status.fixed { background: var(--green-soft); color: var(--green); }
.chip.amber, .chip.warn, .chip.waiting { background: var(--amber-soft); color: var(--amber); }
.chip.red, .chip.bad, .chip.sev.critical, .chip.sev.high, .chip.status.open { background: var(--red-soft); color: var(--red); }
.chip.blue, .chip.working { background: var(--blue-soft); color: var(--blue); }
.chip.violet { background: var(--violet-soft); color: var(--violet); }
.chip.mono { font-family: var(--mono); font-weight: 500; font-size: 11px; }
.chip.proj { background: transparent; border: 1px solid var(--border-strong); color: var(--text-2); }
.chip.guess { font-style: italic; }
.chip.off { color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--faint); }
.dot.green { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.dot.amber { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.dot.red { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.dot.blue { background: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.dot.violet { background: var(--violet); box-shadow: 0 0 0 3px var(--violet-soft); }
.dot.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ---------- banners, skeletons, empty states ---------- */
.banner { display: block; margin: 0 0 16px; padding: 10px 14px; border-radius: var(--r); background: var(--blue-soft); color: var(--blue); font-weight: 550; overflow-wrap: anywhere; }
.banner.warn { background: var(--amber-soft); color: var(--amber); }
.banner.error, .banner.over { background: var(--red-soft); color: var(--red); }
.main > .banner { margin: 0; border-radius: 0; padding: 10px 28px; }
.skeleton { display: grid; gap: 12px; padding: 4px 0; max-width: 760px; }
.sk-line { display: block; height: 14px; border-radius: var(--r-sm); background: linear-gradient(90deg, var(--skeleton) 25%, var(--skeleton-hi) 50%, var(--skeleton) 75%); background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite; }
.sk-line:first-child { width: 40%; height: 22px; }
.sk-line:nth-child(3n) { width: 70%; }
.emptystate { max-width: 520px; margin: 48px auto; padding: 28px; text-align: center; background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--r-lg); }
.emptystate .es-icon { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); }
.emptystate .es-icon svg.i { width: 22px; height: 22px; vertical-align: 0; }
.emptystate h2 { margin: 12px 0 6px; font-size: 16px; }
.emptystate p { margin: 0; color: var(--muted); }

/* ---------- cards, stats, kanban ---------- */
.card { display: block; width: 100%; min-height: 0; margin: 0 0 8px; padding: 12px 14px; text-align: left; white-space: normal; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); color: var(--text); font: inherit; cursor: pointer; transition: box-shadow .15s, border-color .15s; }
.card:hover { background: var(--surface); box-shadow: var(--shadow); border-color: var(--border-strong); text-decoration: none; }
.card .title { font-weight: 600; overflow-wrap: anywhere; }
.card h3 { margin: 0; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.card .meta { display: block; margin-top: 4px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat { padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat .value { margin-top: 4px; font-size: 22px; font-weight: 650; letter-spacing: -.02em; }
.stat .value.green { color: var(--green); } .stat .value.amber { color: var(--amber); } .stat .value.red { color: var(--red); }
.stat .sub { margin-top: 2px; color: var(--muted); font-size: 12px; }
.meter { height: 6px; margin-top: 10px; border-radius: var(--r-full); background: var(--grey-soft); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.scroller { display: flex; gap: 16px; align-items: flex-start; overflow-x: auto; padding-bottom: 10px; }
.col { flex: 1 1 260px; min-width: 210px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 10px; }
.col.is-empty { flex: 0 0 180px; min-width: 160px; }
.col > h3, .colhead h3 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--text); }
.colhead { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; }
.colhead .n { color: var(--muted); font-weight: 500; font-size: 13px; }
.colbody > .card:last-child { margin-bottom: 0; }
.empty { padding: 20px 10px; border: 1px dashed var(--border-strong); border-radius: var(--r); color: var(--muted); font-size: 12.5px; text-align: center; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.cards > .card { margin: 0; }
.seg { display: flex; gap: 2px; height: 6px; margin-top: 14px; border-radius: var(--r-full); overflow: hidden; background: var(--grey-soft); }
.seg i { display: block; height: 100%; flex-basis: 0; }
.seg .m { background: var(--bar-merged); } .seg .d { background: var(--bar-done); } .seg .r { background: var(--bar-review); } .seg .p { background: var(--bar-progress); }
.seg .t { background: var(--bar-todo); } .seg .k { background: var(--bar-parked); } .seg .a { background: var(--bar-abandoned); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; color: var(--muted); font-size: 12px; }
.card .foot { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12.5px; }
.card .foot .driver { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .foot .chip { margin: 0; }
.card.run .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.card.run .meta .chip { margin: 0; }
.card .id { color: var(--muted); font-family: var(--mono); font-size: 11.5px; }
.card .note { margin: 8px 0 0; font-size: 12.5px; }

/* ---------- tables, key-value lists, tabs ---------- */
table.grid, .table, table.findings { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
table.grid th, table.grid td, .table th, .table td, table.findings th, table.findings td { padding: 9px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); overflow-wrap: break-word; }
table.grid th, .table th, table.findings th { background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
table.grid tr:last-child td, .table tr:last-child td, table.findings tr:last-child td { border-bottom: 0; }
table.grid tr:hover td, table.findings tr:hover td { background: var(--surface-2); }
td.nw { white-space: nowrap; }
td button { margin: 0 4px 4px 0; }
.tablewrap { max-width: 100%; overflow-x: auto; margin: 0 0 12px; }
dl.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 14px; margin: 10px 0; font-size: 13px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.subtabs, .tabs { display: flex; flex-wrap: wrap; gap: 2px; margin: 0 0 16px; border-bottom: 1px solid var(--border); }
.subtabs a, .tab { display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap); padding: 6px 12px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 550; font-size: 13px; }
.subtabs a:hover, .tab:hover { color: var(--text); text-decoration: none; }
.subtabs a[aria-current="page"], .tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.term, pre.raw { margin: 8px 0; padding: 12px 14px; border-radius: var(--r); background: var(--term-bg); color: var(--term-text); font: 12px/1.6 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 420px; overflow: auto; }

/* ---------- panels and the drawer ---------- */
.panels { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.panel { flex: 1 1 260px; min-width: 0; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.panel.wide { flex-basis: 100%; }
.panel h3 { margin: 0 0 8px; color: var(--text); font-size: 13px; font-weight: 650; letter-spacing: 0; text-transform: none; }
.panel-line { margin: 3px 0; overflow-wrap: anywhere; color: var(--text-2); }
.panel-line.ok { color: var(--green); } .panel-line.warn, .panel.warn .panel-line { color: var(--amber); } .panel.over .panel-line { color: var(--red); }
.panel > p.meta { margin: 0 0 6px; }
.bar { height: 6px; margin: 8px 0 4px; border-radius: var(--r-full); background: var(--grey-soft); overflow: hidden; }
.bar .fill { height: 100%; border-radius: inherit; background: var(--green); }
.bar.warn .fill { background: var(--amber); } .bar.over .fill { background: var(--red); } .bar.none .fill { background: var(--faint); }
.drawer, #drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 40; width: min(460px, 100vw); overflow-y: auto; padding: 18px 20px 40px; background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); }
.drawer h2 { overflow-wrap: anywhere; font-size: 17px; }
.drawer ol, .drawer ul { padding-left: 20px; }
.drawer li { overflow-wrap: anywhere; margin: 2px 0; }

/* ---------- Markdown typography (chatmd.js, documents, the timeline, sessions) ---------- */
.md p, .chat-assistant p, .doc-text p, .tl-text p, .sess-msg p { margin: 6px 0; white-space: pre-wrap; }
.chat-assistant h1, .chat-assistant h2, .chat-assistant h3, .doc-text h1, .doc-text h2, .doc-text h3 { margin: 14px 0 6px; font-size: 15px; }
.chat-assistant ul, .chat-assistant ol, .doc-text ul, .doc-text ol, .tl-text ul, .tl-text ol, .sess-msg ul, .sess-msg ol { margin: 6px 0; padding-left: 22px; }
.chat-assistant li, .doc-text li, .tl-text li, .sess-msg li { margin: 2px 0; }
.chat-assistant code, .doc-text code, .tl-text code, .sess-msg code, .pinned code { padding: 1px 5px; border-radius: 4px; background: var(--grey-soft); color: var(--text); font-size: 12px; }
.chat-assistant pre, .doc-text pre, .tl-text pre, .sess-msg pre, .pinned pre, .chat-tool pre { margin: 8px 0; padding: 10px 12px; border-radius: var(--r); background: var(--term-bg); color: var(--term-text); white-space: pre-wrap; overflow-x: auto; }
.chat-assistant pre code, .doc-text pre code, .tl-text pre code, .sess-msg pre code, .pinned pre code { padding: 0; background: none; color: inherit; }
.chat-assistant table, .doc-text table { border-collapse: collapse; margin: 8px 0; display: block; overflow-x: auto; }
.chat-assistant th, .chat-assistant td, .doc-text th, .doc-text td { padding: 4px 8px; border: 1px solid var(--border); }
.chat-assistant blockquote, .doc-text blockquote { margin: 8px 0; padding: 2px 12px; border-left: 3px solid var(--border-strong); color: var(--text-2); }

/* ---------- motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .dot.pulse, .sk-line { animation: none; }
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- phone: under 900 px the sidebar is a slide-over ---------- */
@media (max-width: 900px) {
  :root { --tap: 44px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: min(300px, 86vw); height: auto; transform: translateX(-105%); visibility: hidden; transition: transform .2s, visibility 0s .2s; box-shadow: var(--shadow-lg); z-index: 50; }
  .side.open { transform: none; visibility: visible; transition: transform .2s; }
  .side.open + .scrim { display: block; position: fixed; inset: 0; z-index: 45; background: var(--scrim); }
  .topbar .menu-btn { display: inline-flex; width: 44px; min-height: 44px; }
  .topbar { padding: 8px 16px; gap: 8px; }
  .content { padding: 16px 16px 96px; }
  .main > .banner { padding: 10px 16px; }
  button, .btn, a.button, .input, select, input[type="text"], input[type="email"], input[type="password"], input:not([type]) { min-height: 44px; }
  .btn.sm { min-height: var(--tap); }
  .navlink { min-height: 44px; }
  .scroller { flex-direction: column; align-items: stretch; overflow-x: visible; }
  .col, .col.is-empty { flex: none; width: 100%; min-width: 0; }
  .col.is-empty { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
  .col.is-empty .colhead { padding: 4px 6px; }
  .col.is-empty .empty { flex: 1; padding: 6px 10px; }
  .cards { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .reqbar { flex: none; }
  .topmore { display: block; flex: none; }
  .topmore:not(:has(.topmore-menu > :not([hidden]):not(:empty))) { display: none; }
  .topbar .topmore > summary { width: 44px; min-height: 44px; }
  .topbar { position: relative; flex-wrap: nowrap; }
  .crumbs { flex: 1; }
  .crumbs .crumb-up { display: none; }
  .topbar .grow { display: none; }
  table.grid, table.findings, .table { display: block; overflow-x: auto; }
}
