/*! pitwall-theme 1.0.0 | MIT | source of truth: pitwall src/web/shared/pitwall-theme.css | copy verbatim, never edit a copy */
/*
 * The look of the Pitwall pages (dashboard, Pitwall Mem, Pitwall Compact): design tokens, light and dark themes and the
 * shared components. Framework-free. Pages add their own layout after this file. Classes and tokens: docs/notes/shared-theme.md.
 * Theme: the system's (prefers-color-scheme) unless <html data-theme="light|dark"> forces one; pitwall-theme.js toggles it.
 */
:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --bg: #FAFAF9; --surface: #FFFFFF; --surface-2: #F5F5F4; --border: #E7E5E4; --text: #1C1917; --muted: #78716C;
  --accent: #F59E0B; --on-accent: #1C1917; --accent-text: #B45309;
  --ok: #15803D; --warn: #A16207; --err: #B91C1C; --info: #1D4ED8;
  --track: #EDEBE9; --bar: #44403C; --ring: #B45309;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #6250d6; --s-other: #A8A29E;
  --shadow: 0 1px 2px rgba(28,25,23,.05);
  --pop: 0 12px 32px -8px rgba(28,25,23,.25);
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0C0A09; --surface: #1C1917; --surface-2: #292524; --border: #2E2A27; --text: #FAFAF9; --muted: #A8A29E;
  --accent: #FBBF24; --on-accent: #1C1917; --accent-text: #FCD34D;
  --ok: #4ADE80; --warn: #FACC15; --err: #F87171; --info: #60A5FA;
  --track: #2E2A27; --bar: #D6D3D1; --ring: #FCD34D;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #9085e9; --s-other: #78716C;
  --shadow: none; --pop: 0 12px 32px -8px rgba(0,0,0,.7);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0C0A09; --surface: #1C1917; --surface-2: #292524; --border: #2E2A27; --text: #FAFAF9; --muted: #A8A29E;
    --accent: #FBBF24; --on-accent: #1C1917; --accent-text: #FCD34D;
    --ok: #4ADE80; --warn: #FACC15; --err: #F87171; --info: #60A5FA;
    --track: #2E2A27; --bar: #D6D3D1; --ring: #FCD34D;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #9085e9; --s-other: #78716C;
    --shadow: none; --pop: 0 12px 32px -8px rgba(0,0,0,.7);
  }
}

/* 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; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent-text); }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
svg.i { width: 16px; height: 16px; flex: none; }

/* Top bar: brand (P logo), tabs, tools (status, language switch, theme button) */
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.top-in { max-width: 1280px; margin: 0 auto; padding: 0 24px; height: 56px; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); flex: none; }
.brand svg { width: 24px; height: 24px; }
.brand .stem { fill: var(--text); }
.brand .bars { fill: var(--accent); }
.word { font-weight: 600; font-size: 16px; letter-spacing: .02em; }
.tabs { display: flex; gap: 4px; height: 100%; }
.tab { position: relative; display: inline-flex; align-items: center; height: 100%; padding: 0 12px; border: 0; background: none; color: var(--muted); font-weight: 500; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
.tab .badge { margin-left: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--surface-2); color: var(--text); font-size: 11px; font-weight: 600; display: inline-grid; place-items: center; }
.tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.status { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.status.off .dot { background: var(--err); }
.status b { color: var(--text); font-weight: 500; }
.ro { display: inline-flex; align-items: center; height: 32px; padding: 0 10px; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: 12.5px; }
.seg { display: inline-flex; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.seg button { height: 26px; padding: 0 9px; border: 0; border-radius: 6px; background: none; color: var(--muted); font-size: 12.5px; font-weight: 600; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); }
.icon-btn { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--muted); cursor: pointer; }
.icon-btn:hover { color: var(--text); }

/* Page, headings, cards */
main { max-width: 1280px; margin: 0 auto; padding: 28px 24px 64px; }
h1 { margin: 0 0 4px; font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
h2 { margin: 0; font-size: 15px; font-weight: 600; }
.lede { margin: 0 0 24px; color: var(--muted); max-width: 72ch; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; padding: 16px 20px 12px; }
.card-head .hint { color: var(--muted); font-size: 13px; margin-top: 2px; max-width: 72ch; }
.more { border: 0; background: none; padding: 4px 0; color: var(--accent-text); font-weight: 500; cursor: pointer; }
.more:hover { text-decoration: underline; }
.quiet { padding: 20px; color: var(--muted); }
.quiet strong { display: block; color: var(--text); font-weight: 600; margin-bottom: 2px; }
code { font: 12.5px var(--mono); background: var(--surface-2); border: 1px solid var(--border); padding: 1px 5px; border-radius: 4px; }

/* KPI tiles (.card.kpi inside .kpis), two-column split */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { padding: 16px 20px 18px; }
.kpi .k { color: var(--muted); font-size: 13px; }
.kpi .v { margin-top: 6px; font: 600 28px/1.15 var(--mono); letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .v small { font: 500 15px var(--font); color: var(--muted); letter-spacing: 0; margin-left: 4px; }
.kpi .s { margin-top: 6px; color: var(--muted); font-size: 12.5px; min-height: 19px; }
.kpi .s b { color: var(--text); font-weight: 500; }
.kpi .s.warn b { color: var(--warn); }
.split { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 20px; align-items: start; }

/* Timing board: one row per item, two thin usage bars like the logo's. */
.board { list-style: none; margin: 0; padding: 0 0 8px; }
.board li { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(118px, max-content); gap: 16px; align-items: center; padding: 10px 20px; border-top: 1px solid var(--border); }
.board .nm { min-width: 0; }
.board .nm b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .nm > span { color: var(--muted); font-size: 12.5px; }
.bars2 { display: grid; gap: 5px; }
.bline { display: grid; grid-template-columns: 22px minmax(0, 1fr) 40px; gap: 8px; align-items: center; font-size: 11.5px; color: var(--muted); }
.bline .p { text-align: right; color: var(--text); font-family: var(--mono); font-size: 12px; }
.btrack { height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.bfill { height: 100%; border-radius: 3px; background: var(--bar); }
.bfill.warn { background: var(--warn); }
.bfill.bad { background: var(--err); }
.board li.dim .nm, .board li.dim .bars2 { opacity: .6; }
.btrack.none { background: repeating-linear-gradient(135deg, var(--track) 0 4px, transparent 4px 8px); }

/* State labels: icon plus text, never color alone. Generic tones: ok, warn, err, info, muted. */
.state { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.state.available, .state.ok { color: var(--ok); }
.state.limited, .state.warn { color: var(--warn); }
.state.err { color: var(--err); }
.state.info { color: var(--info); }
.state.disabled, .state.nologin, .state.muted { color: var(--muted); }
.tag { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px; border-radius: 4px; background: var(--surface-2); color: var(--text); font-size: 11.5px; font-weight: 500; white-space: nowrap; }
.tag.pick { background: var(--accent); color: var(--on-accent); }
.tag.line { background: none; border: 1px solid var(--border); color: var(--muted); }
button.tag { border: 0; cursor: pointer; }
button.tag.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
button.tag.live.ask::before { background: var(--warn); }

/* Status dot with its label: busy (breathes), idle, waiting, stalled. */
.sd { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; white-space: nowrap; }
.sd::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.sd.busy { color: var(--info); } .sd.busy::before { background: var(--info); }
.sd.idle { color: var(--ok); } .sd.idle::before { background: var(--ok); }
.sd.waiting { color: var(--warn); } .sd.waiting::before { background: var(--warn); }
.sd.stalled { color: var(--err); } .sd.stalled::before { background: var(--err); }
@media (prefers-reduced-motion: no-preference) { .sd.busy::before { animation: breathe 1.8s ease-in-out infinite; } }
@keyframes breathe { 50% { opacity: .35; } }

/* Chip rows, checkboxes, link buttons */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--muted); }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.linkish { padding: 0; border: 0; background: none; color: var(--accent-text); font-weight: 500; font-size: 12.5px; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.linkish:disabled { opacity: .5; cursor: default; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-weight: 500; text-decoration: none; white-space: nowrap; cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(.96); }
.btn.icon { width: 32px; padding: 0; }

/* Tables (one card per row on narrow screens: label cells with data-label) */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12.5px; font-weight: 500; color: var(--muted); padding: 10px 12px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.tbl td { padding: 14px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl th:first-child, .tbl td:first-child { padding-left: 20px; }
.tbl th:last-child, .tbl td:last-child { padding-right: 20px; }
.tbl th.grp { text-align: right; border-bottom: 0; padding-bottom: 0; color: var(--text); }
.tbl tr + tr th { border-top: 0; }
.tbl .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tr.dim td:not(.keep) { opacity: .6; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; align-items: center; }
.meter { min-width: 130px; }
.meter .mh { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 5px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.meter .mh b { font: 600 13px var(--mono); color: var(--text); }
.acts { display: flex; justify-content: flex-end; gap: 6px; }
.sub2 { display: block; color: var(--muted); font-size: 12px; }

/* Small figures: <dl class="stats"><div><dt>Label</dt><dd>12,345</dd></div>...</dl> */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px 20px; margin: 0; padding: 0 20px 16px; }
.stats > div { min-width: 0; }
.stats dt { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats dd { margin: 2px 0 0; font: 600 18px/1.3 var(--mono); letter-spacing: -.01em; }

/* Charts: legend with swatches, SVG area with hover tip, stacked bar, bar per row */
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 0 20px; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw-color { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.chart { position: relative; padding: 8px 20px 4px; }
.chart svg { display: block; width: 100%; height: 220px; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font: 11px var(--font); }
.chart .hit { fill: transparent; }
.chart .hit.on { fill: var(--surface-2); }
.chart path, .chart line, .chart text { pointer-events: none; }
.tip { position: absolute; z-index: 5; pointer-events: none; min-width: 170px; padding: 10px 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--pop); font-size: 12.5px; color: var(--muted); }
.tip b { display: block; color: var(--text); margin-bottom: 4px; font-weight: 600; }
.tip div { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.tip em { margin-left: auto; padding-left: 14px; font-style: normal; color: var(--text); font-variant-numeric: tabular-nums; }
.big { font: 600 34px/1.1 var(--mono); letter-spacing: -.02em; }
.stackbar { display: flex; gap: 2px; height: 10px; border-radius: 4px; overflow: hidden; background: var(--track); margin: 14px 0 12px; }
.stackbar span { height: 100%; min-width: 2px; }
.note { margin-top: 12px; color: var(--muted); font-size: 12.5px; }
.mbar { height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.mbar span { display: block; height: 100%; background: var(--bar); border-radius: 3px; }

footer { max-width: 1280px; margin: 0 auto; padding: 0 24px 32px; color: var(--muted); font-size: 12.5px; display: flex; flex-wrap: wrap; gap: 4px 20px; }

/* Dialog: <dialog><form><div class="dlg-h">..</div><div class="dlg-b">..</div><div class="dlg-f">buttons</div></form></dialog> */
dialog { width: min(520px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); box-shadow: var(--pop); }
dialog::backdrop { background: rgba(12,10,9,.45); }
.dlg-h { padding: 18px 20px 4px; }
.dlg-h h2 { font-size: 16px; }
.dlg-h p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.dlg-b { padding: 12px 20px; }
.dlg-f { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; }
fieldset { border: 0; margin: 0 0 14px; padding: 0; }
legend { font-size: 13px; font-weight: 600; margin-bottom: 8px; padding: 0; }
.opt { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.opt + .opt { margin-top: 6px; }
.opt input { margin: 0; accent-color: var(--accent); }
.opt .grow { flex: 1; min-width: 0; }
.opt small { display: block; color: var(--muted); font-size: 12px; }
.opt.dis { opacity: .55; cursor: default; }
.opt:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
input[type="datetime-local"] { height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.input { width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.input[aria-invalid="true"] { border-color: var(--err); }
.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.err { color: var(--err); font-size: 13px; margin-top: 8px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 8px; background: var(--text); color: var(--bg); box-shadow: var(--pop); font-size: 13px; }

@media (max-width: 1000px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .top-in { height: auto; flex-wrap: wrap; gap: 0 12px; padding: 10px 16px 0; }
  .tools { margin-left: auto; }
  .status .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .tabs { order: 3; width: 100%; height: 44px; overflow-x: auto; margin: 6px -16px 0; padding: 0 4px; }
  main { padding: 20px 16px 48px; }
  footer { padding: 0 16px 24px; }
  .kpi .v { font-size: 22px; }
  .board li { grid-template-columns: minmax(0, 1fr) auto; padding: 10px 16px; }
  .board .bars2 { grid-column: 1 / -1; grid-row: 2; }
  .card-head, .legend, .chart, .stats { padding-left: 16px; padding-right: 16px; }
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tr { padding: 14px 16px; border-top: 1px solid var(--border); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 16px; }
  .tbl td, .tbl td:first-child, .tbl td:last-child { padding: 0; border: 0; }
  .tbl td.wide { grid-column: 1 / -1; }
  .tbl .n { text-align: left; }
  .tbl td[data-label]::before { content: attr(data-label); display: block; color: var(--muted); font-size: 12px; }
  .acts { justify-content: flex-start; }
}
@media (max-width: 420px) {
  .kpis { gap: 10px; }
  .kpi { padding: 12px 14px 14px; }
  .kpi .v { font-size: 20px; }
  .seg button { padding: 0 7px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
@media (forced-colors: active) { .bfill, .sw-color, .stackbar span, .mbar span { forced-color-adjust: none; } }
