/* SNF Monitor | styles
   Clinical ledger: cool paper, blue-green ink, color only where it carries meaning
   (below / near / above the coverage threshold). One typeface, tabular figures. */

@font-face { font-family: "Plex"; src: url("fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex"; src: url("fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }

:root {
  --ink: #17332d;
  --ink-soft: #3f5750;
  --muted: #5e6f69;
  --paper: #f4f6f5;
  --panel: #ffffff;
  --rule: #d3dbd7;
  --rule-soft: #e6ebe8;
  --below: #a63d2a;
  --near: #a86e12;
  --above: #2e6a4e;
  --focus: #1f5fa6;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --t-small: 13px; --t-body: 15px; --t-lead: 18px; --t-h2: 22px; --t-h1: 30px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper); color: var(--ink);
  font: 400 var(--t-body)/1.5 "Plex", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-weight: 600; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: var(--t-h1); line-height: 1.15; }
h2 { font-size: var(--t-h2); line-height: 1.25; }
h3 { font-size: var(--t-lead); line-height: 1.3; }
p { margin: 0 0 var(--s3); max-width: 70ch; }
a { color: var(--focus); }
.muted { color: var(--muted); }
.small { font-size: var(--t-small); }
.num { text-align: right; white-space: nowrap; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------------------------------------------------------------- controls */
button, .button {
  font: 600 var(--t-body)/1 "Plex", system-ui, sans-serif;
  border: 1px solid var(--ink); background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: 3px; cursor: pointer;
}
button.secondary { background: transparent; color: var(--ink); }
button.danger { background: transparent; color: var(--below); border-color: var(--below); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.link { background: none; border: 0; color: var(--ink-soft); padding: 0; font-weight: 400; text-decoration: underline; }
label { display: block; font-size: var(--t-small); color: var(--ink-soft); margin-bottom: var(--s1); }
input[type=email], input[type=password], input[type=text], select, textarea {
  width: 100%; font: 400 var(--t-body)/1.4 "Plex", system-ui, sans-serif; color: var(--ink);
  padding: 9px 10px; border: 1px solid var(--rule); border-radius: 3px; background: #fff;
}
input.code { font-size: 22px; letter-spacing: .3em; width: 9em; text-align: center; }
.field { margin-bottom: var(--s4); }
.error { color: var(--below); margin: var(--s3) 0; }
.row { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }

/* ---------------------------------------------------------------- sign-in shell */
.shell:empty { display: none; }
.shell { min-height: 100vh; display: grid; place-items: center; padding: var(--s5); }
.gate { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--rule); padding: var(--s6); }
.gate h1 { font-size: var(--t-h2); margin-bottom: var(--s2); }
.gate .lede { color: var(--muted); margin-bottom: var(--s5); }
.gate .qr { display: block; width: 200px; height: 200px; margin: var(--s4) 0; border: 1px solid var(--rule-soft); }
.gate .secret { font-size: var(--t-small); word-break: break-all; color: var(--ink-soft); }
.gate .terms { max-height: 260px; overflow: auto; border: 1px solid var(--rule-soft); padding: var(--s3); font-size: var(--t-small); margin-bottom: var(--s4); }
.wordmark { font-weight: 600; letter-spacing: -0.02em; }
.wordmark span { color: var(--muted); font-weight: 400; }

/* ---------------------------------------------------------------- app frame */
.topbar {
  display: flex; align-items: center; gap: var(--s5); padding: var(--s3) var(--s5);
  border-bottom: 1px solid var(--rule); background: var(--panel);
}
.topbar .wordmark { font-size: var(--t-lead); }
.topbar nav { display: flex; gap: var(--s4); flex: 1; }
.topbar nav a { color: var(--ink-soft); text-decoration: none; padding: var(--s1) 0; border-bottom: 2px solid transparent; }
.topbar nav a[aria-current=page] { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
.topbar .who { font-size: var(--t-small); color: var(--muted); }
main { padding: var(--s6) var(--s5) var(--s7); max-width: 1320px; margin: 0 auto; }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s5); flex-wrap: wrap; margin-bottom: var(--s5); }
.pagehead p { margin: var(--s2) 0 0; color: var(--muted); }
section { margin-bottom: var(--s7); }
section > h2 { margin-bottom: var(--s3); }
.note { font-size: var(--t-small); color: var(--muted); margin-top: var(--s3); }
.flag { display: inline-block; font-size: var(--t-small); padding: 1px 6px; border-radius: 2px; border: 1px solid currentColor; }
.flag.below { color: var(--below); } .flag.near { color: var(--near); } .flag.above { color: var(--above); }

/* ---------------------------------------------------------------- coverage ladder */
.ladder { background: var(--panel); border: 1px solid var(--rule); }
.ladder .rung {
  display: grid; grid-template-columns: minmax(150px, 220px) 1fr 150px; gap: var(--s4); align-items: center;
  padding: var(--s3) var(--s4); border-top: 1px solid var(--rule-soft);
}
.ladder .rung:first-child { border-top: 0; }
.ladder .name { font-weight: 600; }
.ladder .name small { display: block; font-weight: 400; color: var(--muted); font-size: var(--t-small); }
.track { position: relative; height: 22px; }
.track .bar { position: absolute; left: 0; top: 5px; height: 12px; border-radius: 0 2px 2px 0; }
.track .bar.below { background: var(--below); } .track .bar.near { background: var(--near); } .track .bar.above { background: var(--above); }
.track .excl { position: absolute; top: 1px; width: 2px; height: 20px; background: var(--ink); }
.track .threshold { position: absolute; top: -6px; bottom: -6px; border-left: 1px dashed var(--ink-soft); }
.track .threshold span { position: absolute; top: -16px; left: 4px; font-size: 11px; color: var(--ink-soft); white-space: nowrap; }
.ladder .scale { position: relative; height: 18px; margin: 0 var(--s4) var(--s2) calc(min(220px, 30%) + var(--s4) * 2); font-size: 11px; color: var(--muted); }
.ladder .values { text-align: right; white-space: nowrap; }
.ladder .values b { font-size: var(--t-lead); }
.ladder .values span { display: block; font-size: var(--t-small); color: var(--muted); }
.ladder-key { display: flex; gap: var(--s5); font-size: var(--t-small); color: var(--muted); margin-top: var(--s2); flex-wrap: wrap; }
.ladder-key i { display: inline-block; vertical-align: middle; margin-right: var(--s1); }
.ladder-key .k-bar { width: 18px; height: 8px; background: var(--ink-soft); }
.ladder-key .k-excl { width: 2px; height: 14px; background: var(--ink); }
.ladder-key .k-thr { width: 0; height: 14px; border-left: 1px dashed var(--ink-soft); }

/* ---------------------------------------------------------------- tables */
.tablewrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--rule); }
table { border-collapse: collapse; width: 100%; font-size: var(--t-small); }
th, td { padding: 8px 10px; border-top: 1px solid var(--rule-soft); vertical-align: top; }
thead th { border-top: 0; border-bottom: 1px solid var(--rule); text-align: left; font-weight: 600; color: var(--ink-soft); vertical-align: bottom; }
thead th.num { text-align: right; }
tbody tr:hover { background: #f9fbfa; }
td .sub { display: block; color: var(--muted); }
tfoot td { border-top: 1px solid var(--rule); font-weight: 600; }

/* ---------------------------------------------------------------- imports */
.drop {
  border: 1px dashed var(--ink-soft); background: var(--panel); padding: var(--s6) var(--s5);
  display: flex; gap: var(--s5); align-items: center; flex-wrap: wrap;
}
.drop.over { background: #eef3f1; border-style: solid; }
.drop p { margin: 0; }
.filecard { background: var(--panel); border: 1px solid var(--rule); margin-top: var(--s3); }
.filecard header { display: flex; justify-content: space-between; gap: var(--s4); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--rule-soft); flex-wrap: wrap; }
.filecard header b { word-break: break-all; }
.filecard .status { font-size: var(--t-small); }
.check { font-size: var(--t-small); }
.check.ok { color: var(--above); } .check.warn { color: var(--near); } .check.fail { color: var(--below); }
.actions { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; margin-top: var(--s4); }
.detail { padding: var(--s4); border-top: 1px solid var(--rule-soft); background: #fafbfb; }
.detail ul { margin: var(--s2) 0; padding-left: var(--s5); }

@media (max-width: 720px) {
  .ladder .rung { grid-template-columns: 1fr; gap: var(--s2); }
  .ladder .values { text-align: left; }
  .ladder .scale { display: none; }
  .topbar { flex-wrap: wrap; gap: var(--s3); }
  main { padding: var(--s5) var(--s3); }
}
