/* Layout: logo bar, sheet list on the left, the open sheet as a run ledger on the right.
   Colours and type follow the Odio app: Roboto, #0077b6 primary, #082545 navy, #f8f9fe page, #525f7f slate text. */
:root {
  --bg: #f8f9fe;
  --surface: #ffffff;
  --ink: #26324d;
  --heading: #082545;
  --muted: #525f7f;
  --line: #e3e8ef;
  --accent: #0077b6;
  --accent-soft: #e5f2f9;
  --on-accent: #ffffff;
  --nav-active-bg: #082545; --nav-active-ink: #ffffff; --nav-active-muted: #b9c6dd;
  --pass: #198754; --pass-bg: #e8f5ee;
  --fail: #dc3545; --fail-bg: #fbe9eb;
  --blocked: #a86400; --blocked-bg: #fff4d6;
  --skip: #6c757d; --skip-bg: #eef0f2;
  --none: #8a94a6;
  --p1: #dc3545; --p2: #a86400; --p3: #6c757d;
  --scrim: rgba(8, 37, 69, .45);
  --logo-filter: none;
  --font-display: "Roboto", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --font-body: "Roboto", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --font-mono: "Roboto Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1424; --surface: #111e33; --ink: #e3e9f4; --heading: #ffffff; --muted: #9aabc7; --line: #22324d;
    --accent: #4db3e6; --accent-soft: #12304a; --on-accent: #04121f;
    --nav-active-bg: #1d4f80; --nav-active-ink: #ffffff; --nav-active-muted: #c3d3ea;
    --pass: #5cc98a; --pass-bg: #133524; --fail: #f07a86; --fail-bg: #3a1a22;
    --blocked: #f0b43c; --blocked-bg: #3a2c10; --skip: #a5afbe; --skip-bg: #1f2a3b; --none: #6d7c95;
    --p1: #f07a86; --p2: #f0b43c; --p3: #a5afbe; --scrim: rgba(0, 0, 0, .6); --logo-filter: brightness(0) invert(1);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a1424; --surface: #111e33; --ink: #e3e9f4; --heading: #ffffff; --muted: #9aabc7; --line: #22324d;
  --accent: #4db3e6; --accent-soft: #12304a; --on-accent: #04121f;
  --nav-active-bg: #1d4f80; --nav-active-ink: #ffffff; --nav-active-muted: #c3d3ea;
  --pass: #5cc98a; --pass-bg: #133524; --fail: #f07a86; --fail-bg: #3a1a22;
  --blocked: #f0b43c; --blocked-bg: #3a2c10; --skip: #a5afbe; --skip-bg: #1f2a3b; --none: #6d7c95;
  --p1: #f07a86; --p2: #f0b43c; --p3: #a5afbe; --scrim: rgba(0, 0, 0, .6); --logo-filter: brightness(0) invert(1);
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font: 14px/1.55 var(--font-body); letter-spacing: .01em; }
.wrap { max-width: 1120px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 28px 64px; display: grid; gap: 20px; }
header.top { display: grid; gap: 6px; }
.eyebrow { font: 500 12px var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
h1 { font: 600 clamp(26px, 4vw, 34px)/1.15 var(--font-display); margin: 0; text-wrap: balance;  color: var(--heading);}
.lede { color: var(--muted); margin: 0; max-width: 68ch; }
.status-line { font: 12px var(--font-mono); color: var(--muted); }


.sheethead { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-end; justify-content: space-between; padding-top: 18px; }
.sheethead .ttl { display: grid; gap: 4px; min-width: 0; }
.sheethead h2 { font: 600 24px/1.2 var(--font-display); margin: 0; overflow-wrap: anywhere;  color: var(--heading);}
.sheethead p { margin: 0; color: var(--muted); max-width: 70ch; overflow-wrap: anywhere; }
.sheethead .meta { font: 12px var(--font-mono); color: var(--muted); }
.acts { display: flex; flex-wrap: wrap; gap: 8px; }

button { font: inherit; }
.btn { font: 500 13px var(--font-body); padding: 7px 13px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.danger { color: var(--fail); border-color: var(--fail); }
.btn.danger.solid { background: var(--fail); color: var(--surface); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.summary { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 760px) { .summary { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; min-width: 0; }
.panel h3.lbl { font: 600 13px var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; }
.bigbar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--line); }
.bigbar span, .minibar span { display: block; height: 100%; }
.counts { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 12px; font-variant-numeric: tabular-nums; }
.counts div { display: flex; align-items: baseline; gap: 6px; }
.counts b { font: 600 22px var(--font-body); }
.counts small { color: var(--muted); font-size: 13px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.area-table { display: grid; gap: 7px; max-height: 260px; overflow: auto; }
.area-row { display: grid; grid-template-columns: minmax(0, 1fr) 90px 52px; gap: 10px; align-items: center; font-size: 13px; }
.area-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.minibar { display: flex; height: 7px; border-radius: 4px; overflow: hidden; background: var(--line); }
.area-row .num { font: 12px var(--font-mono); color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters label { font-size: 12px; color: var(--muted); display: grid; gap: 3px; }
select, input[type="search"], input[type="text"], input[type="password"], textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; min-width: 0;
}
input[type="search"] { width: 220px; max-width: 100%; }
select:focus-visible, input:focus-visible, textarea:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tab { font: 500 13px var(--font-body); border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 6px 12px; border-radius: 999px; cursor: pointer; }
.tab[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.shown { font: 12px var(--font-mono); color: var(--muted); margin-left: auto; padding-bottom: 8px; }

.group-title { font: 600 18px var(--font-display); margin: 8px 0 0; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;  color: var(--heading);}
.group-title small { font: 12px var(--font-mono); color: var(--muted); }
.cases { display: grid; gap: 6px; }
#list { display: grid; gap: 8px; }
details.case { background: var(--surface); border: 1px solid var(--line); border-radius: 9px; }
details.case[data-status="fail"] { border-color: var(--fail); }
details.case > summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: 104px 30px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 12px; }
details.case > summary::-webkit-details-marker { display: none; }
@media (max-width: 600px) { details.case > summary { grid-template-columns: 30px minmax(0, 1fr) auto; } .cid { display: none; } }
.cid { font: 12px var(--font-mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prio { font: 600 11px var(--font-mono); text-align: center; border-radius: 4px; padding: 1px 0; border: 1px solid currentColor; color: var(--p3); }
.prio.P1 { color: var(--p1); } .prio.P2 { color: var(--p2); }
.ctitle { min-width: 0; }
.ctitle .t { display: block; overflow-wrap: anywhere; }
.ctitle .meta { font-size: 12px; color: var(--muted); }
.pill { font: 600 11px var(--font-mono); letter-spacing: .04em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.pill.none { color: var(--none); border: 1px dashed var(--line); }
.pill.pass { color: var(--pass); background: var(--pass-bg); }
.pill.fail { color: var(--fail); background: var(--fail-bg); }
.pill.blocked { color: var(--blocked); background: var(--blocked-bg); }
.pill.skip { color: var(--skip); background: var(--skip-bg); }
.body { padding: 12px 14px 14px; display: grid; gap: 12px; border-top: 1px solid var(--line); }
.kv { display: grid; gap: 4px; min-width: 0; }
.kv h4 { margin: 0; font: 600 11px var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.kv p { margin: 0; max-width: 80ch; overflow-wrap: anywhere; white-space: pre-wrap; }
.kv ol { margin: 0; padding-left: 20px; display: grid; gap: 3px; max-width: 80ch; overflow-wrap: anywhere; }
.expected { background: var(--accent-soft); border-radius: 7px; padding: 9px 11px; }
.record { display: grid; gap: 8px; }
.btns { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.btns button[data-s] { font: 500 13px var(--font-body); padding: 6px 12px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.btns button[data-s="pass"][aria-pressed="true"] { background: var(--pass); border-color: var(--pass); color: var(--surface); }
.btns button[data-s="fail"][aria-pressed="true"] { background: var(--fail); border-color: var(--fail); color: var(--surface); }
.btns button[data-s="blocked"][aria-pressed="true"] { background: var(--blocked); border-color: var(--blocked); color: var(--surface); }
.btns button[data-s="skip"][aria-pressed="true"] { background: var(--skip); border-color: var(--skip); color: var(--surface); }
.btns button:disabled { opacity: .5; cursor: not-allowed; }
.btns .edit { margin-left: auto; }
textarea { width: 100%; min-height: 64px; resize: vertical; }
.who { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.who img { width: 18px; height: 18px; border-radius: 50%; }
.notice { font-size: 13px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: 8px; padding: 10px 12px; }
.src { font: 12px var(--font-mono); color: var(--muted); overflow-wrap: anywhere; }

.emptystate { background: var(--surface); border: 1px dashed var(--line); border-radius: 12px; padding: 32px 20px; display: grid; gap: 12px; justify-items: start; }
.emptystate h2 { font: 600 22px var(--font-display); margin: 0;  color: var(--heading);}
.emptystate p { margin: 0; color: var(--muted); max-width: 62ch; }
.empty { color: var(--muted); padding: 20px; text-align: center; }

/* Dialogs */
dialog { overflow: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); padding: 0; width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
dialog::backdrop { background: var(--scrim); }
dialog form, dialog .dlg { display: grid; gap: 14px; padding: 20px; }
dialog h2 { font: 600 20px var(--font-display); margin: 0;  color: var(--heading);}
dialog .sub { margin: -8px 0 0; color: var(--muted); font-size: 13px; }
.field { display: grid; gap: 4px; min-width: 0; }
.field > span { font-size: 12px; color: var(--muted); }
.field > span b { color: var(--fail); font-weight: 500; }
.field input, .field select, .field textarea { width: 100%; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.dlg-foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; align-items: center; }
.dlg-foot .left { margin-right: auto; }
.err { color: var(--fail); font-size: 13px; margin: 0; }
.hint { font-size: 12px; color: var(--muted); margin: 0; }
.drop { position: relative; border: 1.5px dashed var(--line); border-radius: 10px; padding: 22px 16px; display: grid; gap: 6px; justify-items: center; text-align: center; color: var(--muted); cursor: pointer; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.drop strong { color: var(--ink); font-weight: 500; }
.cols { font: 12px var(--font-mono); color: var(--muted); background: var(--bg); border-radius: 7px; padding: 8px 10px; overflow-x: auto; white-space: nowrap; }
.sets { display: grid; gap: 10px; }
.set { border: 1px solid var(--line); border-radius: 9px; padding: 12px; display: grid; gap: 10px; }
.set-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.set-head .n { font-weight: 600; overflow-wrap: anywhere; }
.set-head .c { font: 12px var(--font-mono); color: var(--muted); }
.warns { font-size: 12px; color: var(--blocked); margin: 0; padding-left: 18px; max-height: 90px; overflow: auto; }
.prev { overflow-x: auto; }
.prev table { border-collapse: collapse; font-size: 12px; width: 100%; }
.prev th, .prev td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.prev th { font: 600 11px var(--font-mono); color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.progress { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 8px; font-size: 13px; z-index: 50; max-width: calc(100vw - 32px); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Standalone app additions */
html, body { margin: 0; }
[hidden] { display: none !important; }
img { max-width: 100%; }
.brandbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.brandbar-in { min-height: 56px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 14px; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--muted); }
.brand img { height: 28px; width: auto; display: block; filter: var(--logo-filter); }
.brand-sub { font: 500 12px var(--font-mono); letter-spacing: .08em; text-transform: uppercase; border-left: 1px solid var(--line); padding-left: 12px; line-height: 20px; }
.me { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.me b { color: var(--ink); font-weight: 500; }
.me .btn { padding-block: 3px; }
.login { min-height: calc(100vh - 57px); display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-left, 0px)); }
.login form { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 24px; display: grid; gap: 14px; }
.login h1 { font-size: 26px; }
.login p { margin: 0; color: var(--muted); font-size: 14px; }
.history { margin: 0; padding-left: 18px; font-size: 12px; color: var(--muted); display: grid; gap: 2px; }
a.btn { text-decoration: none; display: inline-block; }

/* App layout: left navigation + main column */
.layout { display: grid; grid-template-columns: 272px minmax(0, 1fr); align-items: start; }
.layout > .main { margin: 0; padding-left: 32px; padding-right: max(24px, env(safe-area-inset-right, 0px)); width: 100%; max-width: 1180px; }
.sidenav { position: sticky; top: 0; height: calc(100vh - 57px); background: var(--surface); border-right: 1px solid var(--line); min-width: 0; }
.nav-toggle { display: none; }
.nav-body { height: 100%; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding-block: 20px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: 12px; }
.nav-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding-inline: 4px; }
.nav-title { margin: 0; font: 600 12px var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.nav-count { font: 12px var(--font-mono); color: var(--muted); }
.nav-acts { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
#navFilter { width: 100%; }
#sheetNav { display: grid; gap: 2px; }
.nav-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 8px; align-items: baseline; width: 100%; text-align: left; font: 500 14px var(--font-body); color: var(--ink); background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 9px 10px; cursor: pointer; }
.nav-item:hover { background: var(--bg); }
.nav-item[aria-current="page"] { background: var(--nav-active-bg); border-color: var(--nav-active-bg); color: var(--nav-active-ink); }
.nav-item[aria-current="page"] .ct, .nav-item[aria-current="page"] .sub { color: var(--nav-active-muted); }
.nav-item[aria-current="page"] .minibar { background: rgba(255, 255, 255, .22); }
.nav-item .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .ct { font: 12px var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.nav-item .minibar { grid-column: 1 / -1; height: 4px; }
.nav-item .sub { grid-column: 1 / -1; font: 11px var(--font-mono); color: var(--muted); margin-top: -2px; }
.nav-empty { font-size: 13px; color: var(--muted); padding: 8px 4px; }
.nav-status { margin-top: auto; padding: 12px 4px 0; border-top: 1px solid var(--line); }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .layout > .main { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .sidenav { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--line); }
  .nav-toggle { display: flex; align-items: center; gap: 10px; width: 100%; background: transparent; border: none; color: var(--ink); cursor: pointer; text-align: left; font: 500 15px var(--font-body); padding-block: 12px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .nav-toggle-lbl { font: 600 11px var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
  .nav-toggle-cur { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
  .nav-body { display: none; height: auto; max-height: 70vh; padding-top: 4px; padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .sidenav.open .nav-body { display: flex; }
}
@media (min-width: 861px) {
  /* Keep the logo bar and the sheet list in view while the case list scrolls. */
  .brandbar { position: sticky; top: 0; z-index: 20; }
  .sidenav { top: 57px; }
}
