/* Layout: fixed top bar + section tabs; each section is a full-width working surface. Prototype uses app-shell (nav rail | screen | guide). */
:root {
  --paper: #f7f7f3;
  --panel: #ffffff;
  --sunk: #eff0ea;
  --ink: #22332d;
  --ink-2: #4b5a54;
  --muted: #7a847e;
  --line: #e1e4dc;
  --line-2: #cfd4ca;
  --brand: #2f5747;
  --brand-soft: #e5ede7;
  --accent: #c2704f;
  --accent-soft: #f7e9e1;
  /* semantic */
  --ok: #2f7a50;      --ok-bg: #e4f2e8;
  --warn: #9a6a12;    --warn-bg: #fbf1d9;
  --crit: #b23f2e;    --crit-bg: #f9e3de;
  --wait: #3d5f8a;    --wait-bg: #e4ecf6;
  --unk: #6b4f8f;     --unk-bg: #eee8f5;
  --neutral-bg: #eceee8;
  --demo: #8a5a00;    --demo-bg: #fff3cc;
  /* lanes */
  --lane-guest: #f4ece4; --lane-ai: #e8eef3; --lane-human: #f6e7e2; --lane-ops: #eaf1e6; --lane-ext: #eeedf3;
  --shadow: 0 1px 2px rgba(30,45,38,.06), 0 6px 18px rgba(30,45,38,.06);
  --font: 'Avenir Next', 'Mulish', 'Segoe UI', system-ui, sans-serif;
  --display: 'Iowan Old Style', 'Source Serif 4', 'Palatino Linotype', Georgia, serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --r: 8px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #141a17; --panel: #1b2420; --sunk: #111613; --ink: #e6ece8; --ink-2: #bcc8c1; --muted: #8d9a93;
    --line: #2a3530; --line-2: #3a4741; --brand: #8fc2a9; --brand-soft: #1f3129; --accent: #e3956f; --accent-soft: #3a261d;
    --ok: #7fcf9c; --ok-bg: #19301f; --warn: #e6bb5c; --warn-bg: #33290f; --crit: #f08f7f; --crit-bg: #3a1c17;
    --wait: #94b6e3; --wait-bg: #1b2738; --unk: #c2a6e6; --unk-bg: #2a2236; --neutral-bg: #232d28;
    --demo: #f3cd64; --demo-bg: #3a300e;
    --lane-guest: #2a2420; --lane-ai: #1d252c; --lane-human: #2e211e; --lane-ops: #1f2a1e; --lane-ext: #23222b;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #141a17; --panel: #1b2420; --sunk: #111613; --ink: #e6ece8; --ink-2: #bcc8c1; --muted: #8d9a93;
  --line: #2a3530; --line-2: #3a4741; --brand: #8fc2a9; --brand-soft: #1f3129; --accent: #e3956f; --accent-soft: #3a261d;
  --ok: #7fcf9c; --ok-bg: #19301f; --warn: #e6bb5c; --warn-bg: #33290f; --crit: #f08f7f; --crit-bg: #3a1c17;
  --wait: #94b6e3; --wait-bg: #1b2738; --unk: #c2a6e6; --unk-bg: #2a2236; --neutral-bg: #232d28;
  --demo: #f3cd64; --demo-bg: #3a300e;
  --lane-guest: #2a2420; --lane-ai: #1d252c; --lane-human: #2e211e; --lane-ops: #1f2a1e; --lane-ext: #23222b;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { background: var(--paper); color: var(--ink); font-family: var(--font); font-size: 13.5px; line-height: 1.5; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; text-wrap: balance; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 26px; line-height: 1.15; }
h2 { font-size: 20px; line-height: 1.2; }
h3 { font-size: 15.5px; line-height: 1.3; }
p { margin: 0; }
.eyebrow { font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.mono { font-family: var(--mono); font-size: 11.5px; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.small { font-size: 12px; }
.prose { max-width: 68ch; color: var(--ink-2); }
.prose p + p { margin-top: 8px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 40; background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; gap: 14px; padding: 10px 16px; flex-wrap: wrap; }
.brandmark { display: flex; align-items: baseline; gap: 8px; }
.brandmark b { font-family: var(--display); font-size: 19px; letter-spacing: -.02em; }
.brandmark span { color: var(--muted); font-size: 12px; }
.demo-pill { display: inline-flex; align-items: center; gap: 6px; background: var(--demo-bg); color: var(--demo); border: 1px dashed var(--demo); font-weight: 700; font-size: 11px; letter-spacing: .05em; text-transform: uppercase; border-radius: 999px; padding: 3px 10px; }
.topbar .spacer { flex: 1; }
.tabs { display: flex; gap: 2px; padding: 0 12px; overflow-x: auto; scrollbar-width: thin; }
.tabs button { border: 0; background: none; padding: 9px 12px 10px; color: var(--ink-2); font-weight: 600; font-size: 13px; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tabs button:hover { color: var(--ink); }
.tabs .tabnum { font-family: var(--mono); font-size: 10.5px; color: var(--muted); margin-right: 5px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: var(--panel); color: var(--ink); border-radius: 6px; padding: 5px 11px; font-weight: 600; font-size: 12.5px; line-height: 1.4; }
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--panel); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--crit); border-color: var(--crit); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 3px 8px; font-size: 11.5px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn.pulse { box-shadow: 0 0 0 3px var(--accent-soft), 0 0 0 5px var(--accent); }
.btnrow { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* ---------- Badges (glyph + label = non-colour cue) ---------- */
.b { display: inline-flex; align-items: center; gap: 4px; border-radius: 4px; padding: 1px 7px; font-size: 11px; font-weight: 700; line-height: 1.6; white-space: nowrap; background: var(--neutral-bg); color: var(--ink-2); }
.b .g { font-family: var(--mono); font-weight: 700; font-size: 10.5px; }
.b.ok { background: var(--ok-bg); color: var(--ok); }
.b.warn { background: var(--warn-bg); color: var(--warn); }
.b.crit { background: var(--crit-bg); color: var(--crit); }
.b.wait { background: var(--wait-bg); color: var(--wait); }
.b.unk { background: var(--unk-bg); color: var(--unk); }
.b.demo { background: var(--demo-bg); color: var(--demo); border: 1px dashed var(--demo); }
.b.brand { background: var(--brand-soft); color: var(--brand); }
.b.outline { background: transparent; border: 1px solid var(--line-2); }
.chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line-2); border-radius: 999px; padding: 1px 8px; font-size: 11px; color: var(--ink-2); white-space: nowrap; }

/* ---------- Generic surfaces ---------- */
.section { padding-inline: 16px; padding-block: 20px 60px; max-width: 1480px; margin: 0 auto; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.panel-h { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-b { padding: 12px 14px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: minmax(110px, max-content) 1fr; gap: 3px 12px; font-size: 12.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.hr { height: 1px; background: var(--line); margin: 10px 0; }
.note { border-left: 3px solid var(--line-2); padding: 6px 10px; color: var(--ink-2); font-size: 12.5px; background: var(--sunk); border-radius: 0 6px 6px 0; }
.note.warn { border-color: var(--warn); }
.note.crit { border-color: var(--crit); }
.note.demo { border-color: var(--demo); background: var(--demo-bg); color: var(--ink); }
.note.ok { border-color: var(--ok); }
.scroll-x { overflow-x: auto; }
table.t { border-collapse: collapse; width: 100%; font-size: 12.5px; }
table.t th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr.sel td { background: var(--brand-soft); }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--sunk); }

/* ---------- Overview ---------- */
.ov-hero { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 28px; align-items: start; }
@media (max-width: 900px) { .ov-hero { grid-template-columns: 1fr; } }
.ov-units { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.unit { border: 1px solid var(--line); background: var(--panel); border-radius: var(--r); padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.unit .who { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.lane-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; border: 1px solid var(--line-2); }

/* ---------- Drawer (register / evidence) ---------- */
.drawer-back { position: fixed; inset: 0; background: rgba(10,20,15,.35); z-index: 80; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--panel); z-index: 81; box-shadow: var(--shadow); display: flex; flex-direction: column; border-left: 1px solid var(--line); }
.drawer-h { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
.drawer-b { padding: 14px 16px; overflow-y: auto; flex: 1; }
.toast { position: fixed; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 8px 14px; border-radius: 6px; z-index: 90; font-size: 12.5px; max-width: calc(100% - 32px); box-shadow: var(--shadow); }

/* ---------- Overview extras ---------- */
.ov-modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.ov-modes > div { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--sunk); }
.ov-modes > div:nth-child(1) { border-left: 3px solid var(--line-2); }
.ov-modes > div:nth-child(2) { border-left: 3px solid var(--wait); }
.ov-modes > div:nth-child(3) { border-left: 3px solid var(--warn); }
.ov-modes > div:nth-child(4) { border-left: 3px solid var(--ok); }
.ov-list { margin: 0; padding-left: 18px; display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 6px 28px; color: var(--ink-2); }

/* ---------- Browsers (workflows, wireframes) ---------- */
.browse { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 18px; align-items: start; }
.browse-list { position: sticky; top: calc(100px + env(safe-area-inset-top, 0px)); display: flex; flex-direction: column; gap: 1px; max-height: calc(100vh - 120px); overflow-y: auto; }
.browse-list button { display: flex; gap: 8px; align-items: baseline; text-align: left; border: 0; background: transparent; padding: 6px 8px; border-radius: 6px; color: var(--ink-2); font-size: 12.5px; line-height: 1.35; }
.browse-list button .mono { color: var(--muted); min-width: 36px; }
.browse-list button:hover { background: var(--sunk); color: var(--ink); }
.browse-list button[aria-current="true"] { background: var(--brand-soft); color: var(--ink); font-weight: 700; }
.browse-main { min-width: 0; }
@media (max-width: 900px) {
  .browse { grid-template-columns: 1fr; }
  .browse-list { position: static; flex-direction: row; flex-wrap: wrap; max-height: none; gap: 4px; }
  .browse-list button { border: 1px solid var(--line); padding: 3px 8px; }
  .browse-list button span:not(.mono) { display: none; }
  .browse-list button .mono { min-width: 0; }
}
.ho-list{margin:0;padding-left:18px;display:flex;flex-direction:column;gap:5px;color:var(--ink-2);font-size:12.5px}

/* ---------- Tablet and touch ---------- */
html { -webkit-text-size-adjust: 100%; }
.fit-toggle[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
@media (max-width: 1000px) { .brandmark span { display: none; } .topbar-inner { flex-wrap: nowrap; } .topbar .demo-pill { font-size: 10px; padding: 2px 8px; } }
@media (max-width: 600px) { .topbar-inner { flex-wrap: wrap; } }
@media (pointer: coarse) {
  .btn { min-height: 38px; padding: 7px 13px; }
  .btn.sm { min-height: 34px; padding: 5px 10px; }
  .tabs button { padding: 12px 14px; }
  .browse-list button { padding: 9px 10px; }
  select, input, textarea { font-size: 16px; }
  select, input[type="search"] { min-height: 40px; }
  .pt-navg button { padding: 9px 8px; }
  .pt-tabs button { padding: 10px 12px; }
  .pt-crow { padding: 11px 12px; }
  .bp-check { min-height: 36px; }
  .bp-check input { width: 20px; height: 20px; }
}
