/* cmarket: shared stylesheet for the report, the archive and the login page.
   Sober by design: one type family, neutral greys, rules instead of boxes,
   colour reserved for chart series and pass/fail state. */

:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-2: #f7f7f6;
  --ink: #1a1a19;
  --ink-2: #4a4a47;
  --ink-3: #74746f;
  --rule: #e7e6e3;
  --rule-2: #d3d2ce;
  --link: #1f5fb8;
  --pass: #1d7a42;
  --fail: #b42318;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #131415; --bg-2: #1a1b1d; --ink: #e9e9e7; --ink-2: #c2c2bd; --ink-3: #91918b;
    --rule: #27282b; --rule-2: #36373b; --link: #8ab4ff; --pass: #5cc581; --fail: #f08a80;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #131415; --bg-2: #1a1b1d; --ink: #e9e9e7; --ink-2: #c2c2bd; --ink-3: #91918b;
  --rule: #27282b; --rule-2: #36373b; --link: #8ab4ff; --pass: #5cc581; --fail: #f08a80;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 64px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); font-variant-numeric: tabular-nums; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 600; line-height: 1.25; margin: 0; }
h2 { font-size: 15px; }
h3 { font-size: 14px; margin-bottom: 8px; }
p { margin: 0 0 8px; }
code { font: 12px var(--mono); }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.empty { color: var(--ink-3); margin: 4px 0 0; }

/* top bar */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 92%, transparent);
       backdrop-filter: blur(6px); border-bottom: 1px solid var(--rule); }
.top .bar { max-width: 1200px; margin: 0 auto; padding: 10px 16px; display: flex; gap: 8px 20px; align-items: center; flex-wrap: wrap; }
.brand { font-weight: 600; font-size: 15px; color: var(--ink); }
.brand span { font-weight: 400; color: var(--ink-3); margin-left: 6px; }
.top nav { display: flex; gap: 2px 14px; flex-wrap: wrap; font-size: 13px; }
.top nav a { color: var(--ink-2); }
.top .right { margin-left: auto; font-size: 13px; display: flex; gap: 14px; }

main { max-width: 1200px; margin: 0 auto; padding: 8px 16px 72px; }
section { padding-top: 28px; content-visibility: auto; contain-intrinsic-size: auto 600px; }
section > h2 { padding-bottom: 8px; border-bottom: 1px solid var(--rule-2); margin-bottom: 14px; display: flex; align-items: baseline; gap: 10px; }
section > h2 small { font-weight: 400; font-size: 12px; color: var(--ink-3); }
.block { margin: 0 0 22px; }
.note { color: var(--ink-3); font-size: 12px; max-width: 90ch; }

/* overview */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; }
.kpi { padding: 12px 14px; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); margin: 0 -1px -1px 0; }
.kpi b { display: block; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.kpi span { font-size: 12px; color: var(--ink-3); }
.verdict { margin: 14px 0 0; padding: 10px 14px; background: var(--bg-2); border-radius: 6px; color: var(--ink-2); }

/* tables */
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th { text-align: left; font-weight: 500; font-size: 12px; color: var(--ink-3); padding: 6px 10px; border-bottom: 1px solid var(--rule-2); white-space: nowrap; }
td { padding: 6px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
th.n, td.n { text-align: right; white-space: nowrap; }
tbody tr:hover td { background: var(--bg-2); }
table.sortable th { cursor: pointer; user-select: none; }
table.sortable th:hover { color: var(--ink); }
table.sortable th[aria-sort="ascending"]::after { content: " \2191"; }
table.sortable th[aria-sort="descending"]::after { content: " \2193"; }
td .sub { display: block; color: var(--ink-3); font-size: 12px; }

/* disclosure */
details.fold { border-top: 1px solid var(--rule); }
details.fold:last-of-type { border-bottom: 1px solid var(--rule); }
details.fold > summary { cursor: pointer; list-style: none; padding: 10px 2px; display: flex; gap: 10px; align-items: baseline; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: "\25B8"; color: var(--ink-3); width: 10px; transition: transform 0.15s; }
details.fold[open] > summary::before { transform: rotate(90deg); }
details.fold > summary .muted { font-size: 12px; }
details.fold > .inner { padding: 4px 0 16px 20px; }

/* gates */
.gates { list-style: none; padding: 0; margin: 10px 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 4px 20px; font-size: 13px; }
.g { display: inline-block; width: 16px; font-weight: 700; }
.g.pass { color: var(--pass); }
.g.fail { color: var(--fail); }
.g.pend { color: var(--ink-3); }
.gatecount { white-space: nowrap; }

/* charts */
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 24px; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .legend { display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 12px; color: var(--ink-2); margin: 0 0 6px; }
.chart .legend i { display: inline-block; width: 12px; height: 2px; vertical-align: middle; margin-right: 6px; }
.chart .tip { position: absolute; top: 36px; pointer-events: none; background: var(--bg); border: 1px solid var(--rule-2); border-radius: 4px; padding: 6px 8px; font-size: 12px; min-width: 150px; box-shadow: 0 4px 14px rgb(0 0 0 / 0.08); opacity: 0; transition: opacity 0.08s; }
.chart .tip .d { font-size: 11px; color: var(--ink-3); margin-bottom: 2px; }
.chart .tip .r { display: flex; gap: 8px; align-items: center; white-space: nowrap; }
.chart .tip .r b { min-width: 52px; font-weight: 600; }
.chart .tip .r i { width: 10px; height: 2px; display: inline-block; }
.chart details { margin-top: 4px; font-size: 12px; }
.chart summary { cursor: pointer; color: var(--ink-3); }

/* archive */
.archive { list-style: none; padding: 0; margin: 0; columns: 4 160px; }
.archive li { padding: 3px 0; break-inside: avoid; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--bg-2); }
.login form { width: min(100%, 340px); background: var(--bg); border: 1px solid var(--rule); border-radius: 8px; padding: 22px; }
.login h1 { font-size: 18px; margin-bottom: 4px; }
.login label { display: block; font-size: 12px; color: var(--ink-3); margin: 14px 0 6px; }
.login input[type=password] { width: 100%; font: 15px var(--font); padding: 9px 10px; border: 1px solid var(--rule-2); border-radius: 5px; background: var(--bg); color: var(--ink); }
.login input[type=password]:focus { outline: 2px solid var(--link); outline-offset: 1px; }
.login button { margin-top: 14px; width: 100%; padding: 10px; font: 600 14px var(--font); border: 0; border-radius: 5px; background: var(--ink); color: var(--bg); cursor: pointer; }
.login .msg { color: var(--fail); font-size: 13px; min-height: 1.5em; margin: 10px 0 0; }

@media (max-width: 640px) {
  .top { position: static; }            /* a wrapped sticky bar would eat a phone screen */
  html { scroll-padding-top: 8px; }
  .top .right { margin-left: 0; }
  .kpi b { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
