:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --ink: #16202c;
  --muted: #5a6573;
  --line: #dfe3e8;
  --accent: #0b5cad;
  --accent-ink: #ffffff;
  --accent-soft: #e7f0fa;
  --ok: #18794e;
  --ok-soft: #e6f4ec;
  --warn: #8a5a00;
  --warn-soft: #fff4dc;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141a;
    --surface: #171e26;
    --ink: #e6ebf0;
    --muted: #9aa6b2;
    --line: #2a333d;
    --accent: #5aa2ec;
    --accent-ink: #0b1622;
    --accent-soft: #15283b;
    --ok: #4cc38a;
    --ok-soft: #12291e;
    --warn: #f0b44c;
    --warn-soft: #2d2412;
    --bad: #f47067;
    --bad-soft: #2e1614;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
img { max-width: 100%; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 760px; }

/* Header and footer */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); text-decoration: none; font-size: 1.05rem; }
.brand-mark { width: 30px; height: 30px; border-radius: 7px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: .78rem; letter-spacing: .02em; }
.site-nav { display: flex; gap: 4px 16px; flex-wrap: wrap; margin-left: auto; font-size: .93rem; }
.site-nav a { color: var(--muted); text-decoration: none; padding: 4px 0; }
.site-nav a:hover, .site-nav a[aria-current] { color: var(--ink); }
.site-footer { margin-top: 64px; border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: .9rem; }
.site-footer .wrap { padding-top: 28px; padding-bottom: 28px; }
.footer-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; }
.footer-cols h2 { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink); margin: 0 0 8px; }
.footer-cols ul { list-style: none; padding: 0; margin: 0; }
.footer-cols li { margin: 4px 0; }
.footer-cols a { color: var(--muted); }
.disclaimer { margin-top: 20px; font-size: .82rem; }

/* Content */
main { padding-top: 28px; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 8px; }
.crumbs a { color: var(--muted); }
h1 { font-size: clamp(1.7rem, 4vw, 2.35rem); line-height: 1.2; margin: 0 0 12px; letter-spacing: -.01em; }
h2 { font-size: 1.45rem; line-height: 1.3; margin: 40px 0 12px; }
h3 { font-size: 1.12rem; margin: 24px 0 8px; }
.lede { font-size: 1.12rem; color: var(--muted); max-width: 760px; margin: 0 0 20px; }
.updated { font-size: .85rem; color: var(--muted); }
.prose { max-width: 760px; }
.prose li { margin: 4px 0; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
code, .mono { font-family: var(--mono); font-size: .92em; }
.callout { background: var(--accent-soft); border-left: 4px solid var(--accent); padding: 14px 16px; border-radius: 0 var(--radius) var(--radius) 0; margin: 20px 0; }
.callout p { margin: 0 0 6px; }
.callout p:last-child { margin: 0; }
.keyfacts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 20px 0; }
.keyfact { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.keyfact b { display: block; font-size: 1.35rem; }
.keyfact span { color: var(--muted); font-size: .9rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin: 16px 0; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--bg); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.has-error td { background: var(--bad-soft); }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin: 10px 0; }
.faq summary { font-weight: 600; cursor: pointer; }
.faq details[open] summary { margin-bottom: 8px; }
.sources { font-size: .88rem; }
.related { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; padding: 0; list-style: none; }
.related a { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; text-decoration: none; color: var(--ink); height: 100%; }
.related a:hover { border-color: var(--accent); }
.related small { display: block; color: var(--muted); margin-top: 4px; }

/* Tool */
.tool { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 20px; margin: 8px 0 32px; }
.privacy-bar { display: flex; gap: 10px; align-items: flex-start; background: var(--ok-soft); color: var(--ink); border-radius: var(--radius); padding: 10px 12px; font-size: .92rem; margin-bottom: 16px; }
.privacy-bar svg { flex: none; color: var(--ok); margin-top: 2px; }
.controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; }
.field span { color: var(--muted); }
select, input[type=text], input:not([type]), .field input { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); min-width: 0; width: 100%; }
select:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 26px 16px; text-align: center; cursor: pointer; display: block; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop strong { display: block; font-size: 1.08rem; margin-bottom: 4px; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop:focus-within { outline: 2px solid var(--accent); }
.tool-actions { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-top: 12px; font-size: .9rem; }
.btn { font: inherit; font-size: .93rem; border: 1px solid var(--accent); background: var(--surface); color: var(--accent); border-radius: 8px; padding: 8px 14px; cursor: pointer; text-align: left; }
.btn:hover { background: var(--accent-soft); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: var(--line); color: var(--ink); }
.linkbtn { font: inherit; background: none; border: 0; color: var(--accent); text-decoration: underline; cursor: pointer; padding: 0; }
.step { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 16px; }
.step > h2 { margin: 0 0 10px; font-size: 1.15rem; display: flex; gap: 10px; align-items: center; }
.step-num { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: inline-grid; place-items: center; font-size: .85rem; flex: none; }
.tool details.adv { margin-top: 12px; font-size: .92rem; }
.tool details.adv summary { cursor: pointer; color: var(--accent); }
.tool details.adv > div { padding: 10px 0 0; }
.mapgroup { border: 1px solid var(--line); border-radius: var(--radius); margin: 8px 0; padding: 8px 12px; }
.mapgroup summary { cursor: pointer; font-weight: 600; }
.maptable { margin-top: 8px; }
.maprow { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, .8fr); gap: 10px; align-items: center; padding: 5px 0; border-top: 1px solid var(--line); font-size: .9rem; }
.mapfield em { font-style: normal; font-size: .75rem; color: var(--warn); margin-left: 4px; }
.mapsample { color: var(--muted); font-family: var(--mono); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.payer { border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 14px 14px; margin-top: 14px; }
.payer h3 { margin-top: 12px; }
.payergrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.check { display: flex; gap: 8px; align-items: center; margin-top: 10px; font-size: .92rem; }
.run-row { margin-top: 14px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.stat b { display: block; font-size: 1.5rem; line-height: 1.2; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat.ok b { color: var(--ok); }
.stat.warn b { color: var(--warn); }
.stat.bad b { color: var(--bad); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 16px 0 10px; }
.tab { font: inherit; font-size: .9rem; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 5px 12px; cursor: pointer; }
.tab.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.issue-row { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin: 8px 0; }
.issue-head { font-weight: 600; font-size: .92rem; }
.issue-row ul { margin: 6px 0 0; padding-left: 18px; font-size: .9rem; }
.issue-row li { margin: 5px 0; }
.issue-row li.error::marker { color: var(--bad); }
.issue-row li.warning::marker { color: var(--warn); }
.issue-row li.fix::marker { color: var(--ok); }
.issue-row .fld { font-weight: 600; }
.issue-row input.edit { display: block; margin-top: 4px; max-width: 360px; padding: 5px 8px; font-size: .9rem; }
.note { border-radius: var(--radius); padding: 10px 12px; margin: 10px 0; font-size: .93rem; }
.note.info { background: var(--accent-soft); }
.note.bad { background: var(--bad-soft); color: var(--ink); border-left: 4px solid var(--bad); }
.filelist { list-style: none; padding: 0; margin: 0 0 12px; }
.filelist li { margin: 8px 0; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.fileinfo { font-size: .93rem; margin-bottom: 8px; }
.fileinfo ul { margin: 6px 0 0; }
[hidden] { display: none !important; }

@media (max-width: 640px) {
  .tool { padding: 14px; border-radius: 12px; }
  .maprow { grid-template-columns: 1fr; gap: 4px; }
  .mapsample { white-space: normal; }
  .site-nav { margin-left: 0; width: 100%; padding-bottom: 8px; }
  h2 { font-size: 1.3rem; }
}
@media print {
  .site-header, .site-footer, .tool { display: none; }
}
table.wide { min-width: 680px; }
