:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --ink: #16202e;
  --text: #2a3648;
  --muted: #5d6b80;
  --border: #dbe1ea;
  --faint: #eef1f6;
  --blue: #2a5fd0;
  --blue-soft: #e9effc;
  --amber: #b8761f;
  --amber-soft: #fbf3e4;
  --green: #2e7d4f;
  --green-soft: #e6f3ea;
  --red: #b4452e;
  --sans: 'IBM Plex Sans', 'Segoe UI', Helvetica, Arial, sans-serif;
  --mono: 'IBM Plex Mono', 'SFMono-Regular', Menlo, Consolas, monospace;
  --shadow: 0 1px 2px rgba(22, 32, 46, 0.05);
  --c-match: #b9c6d9;
  --c-cost_share: #2a5fd0;
  --c-rate_lag: #b8761f;
  --c-transfer: #d9a04a;
  --c-outlier: #7c4dbd;
  --c-seq: #2e7d4f;
  --c-letter: #8a94a6;
  --c-capitated: #4fa3c7;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1520; --surface: #161e2b; --ink: #e9eef6; --text: #cdd6e3; --muted: #97a4b8; --border: #263145; --faint: #1c2534;
    --blue: #7ea3ff; --blue-soft: #1a2640; --amber: #d9a04a; --amber-soft: #2a2314; --green: #5fbf85; --green-soft: #17301f; --red: #e07a63;
    --shadow: none; --c-match: #3a4658; --c-cost_share: #7ea3ff; --c-rate_lag: #d9a04a; --c-transfer: #e8c07a; --c-outlier: #a98be0; --c-seq: #5fbf85; --c-letter: #6f7b8f; --c-capitated: #6fc3e6;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1520; --surface: #161e2b; --ink: #e9eef6; --text: #cdd6e3; --muted: #97a4b8; --border: #263145; --faint: #1c2534;
  --blue: #7ea3ff; --blue-soft: #1a2640; --amber: #d9a04a; --amber-soft: #2a2314; --green: #5fbf85; --green-soft: #17301f; --red: #e07a63;
  --shadow: none; --c-match: #3a4658; --c-cost_share: #7ea3ff; --c-rate_lag: #d9a04a; --c-transfer: #e8c07a; --c-outlier: #a98be0; --c-seq: #5fbf85; --c-letter: #6f7b8f; --c-capitated: #6fc3e6;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: none; }
h1 { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); margin: 0 0 6px; text-wrap: balance; }
h2 { font-size: 15px; font-weight: 600; color: var(--ink); margin: 0; }
p { margin: 0; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.right { margin-left: auto; }
.eyebrow { font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.pos { color: var(--amber); }
.neg { color: var(--blue); }
.zero { color: var(--muted); }

/* header */
.top { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.top-row { display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; margin-right: auto; }
.brand img { display: block; height: 24px; width: auto; }
.brand-name { font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); border-left: 1px solid var(--border); padding-left: 10px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a { font-family: var(--mono); font-size: 11.5px; padding: 6px 10px; border-radius: 3px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); }
.tabs a .tab-n { color: var(--muted); margin-right: 6px; opacity: 0.8; }
.tabs a.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tabs a.active .tab-n { color: var(--bg); }
.tabs a:focus-visible, button:focus-visible, .row:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* screens */
.screen { padding: 22px 0 28px; }
.screen-head { display: flex; gap: 16px 28px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }
.screen-head > div:first-child { flex: 1 1 420px; }
.lede { color: var(--muted); max-width: 72ch; text-wrap: pretty; }
.callout { flex: 0 1 380px; background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--blue); border-radius: 4px; padding: 10px 14px; font-size: 13px; color: var(--text); text-wrap: pretty; }
.callout .eyebrow { color: var(--blue); margin-bottom: 4px; }
.note { font-size: 12.5px; color: var(--muted); max-width: 80ch; text-wrap: pretty; margin-top: 12px; }

/* systems */
.input-bar { display: flex; align-items: center; gap: 12px; background: var(--ink); color: var(--bg); border-radius: 4px; padding: 8px 14px; margin-bottom: 6px; flex-wrap: wrap; font-size: 13.5px; }
.input-bar .eyebrow { color: color-mix(in srgb, var(--bg) 70%, transparent); }
.input-bar .muted { color: color-mix(in srgb, var(--bg) 70%, transparent); font-size: 11px; }
.systems { display: flex; flex-direction: column; gap: 4px; }
.sys { display: grid; grid-template-columns: minmax(180px, 1.3fr) minmax(120px, 0.9fr) minmax(130px, 0.9fr) minmax(170px, 1.1fr) minmax(200px, 1.6fr); gap: 6px 14px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--blue); border-radius: 4px; padding: 7px 12px; cursor: pointer; text-align: left; font: inherit; color: inherit; width: 100%; box-shadow: var(--shadow); }
.sys:hover { border-color: var(--blue); }
.sys.letter { border-left-color: var(--amber); }
.sys .k { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); display: block; }
.sys .v { font-family: var(--mono); font-size: 12px; color: var(--text); }
.sys .name { font-weight: 600; color: var(--ink); font-size: 13.5px; }
.sys .note-cell { font-size: 12.5px; color: var(--muted); }
.sys-head { display: grid; grid-template-columns: minmax(180px, 1.3fr) minmax(120px, 0.9fr) minmax(130px, 0.9fr) minmax(170px, 1.1fr) minmax(200px, 1.6fr); gap: 6px 14px; padding: 4px 15px; }
.badge { display: inline-block; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; padding: 1px 6px; border-radius: 2px; margin-left: 6px; vertical-align: middle; }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.grey { background: var(--faint); color: var(--muted); }
.key { font-size: 12px; color: var(--muted); padding: 4px 2px 8px; }
.key .badge { margin-left: 0; }
@media (max-width: 760px) {
  .sys, .sys-head { grid-template-columns: 1fr 1fr; }
  .sys-head { display: none; }
  .sys .note-cell { grid-column: 1 / -1; }
  .sys .k { display: block; }
}
@media (min-width: 761px) { .sys .k { display: none; } }

/* mart */
.scope { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.btn { font: inherit; font-family: var(--mono); font-size: 11.5px; padding: 5px 10px; border-radius: 3px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer; }
.btn.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px; margin-bottom: 8px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 9px 12px; box-shadow: var(--shadow); }
.tile .k { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.tile .v { font-family: var(--mono); font-size: 19px; font-weight: 500; letter-spacing: -0.01em; color: var(--ink); font-variant-numeric: tabular-nums; }
.tile .s { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.mart-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 8px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 10px 12px; box-shadow: var(--shadow); min-width: 0; }
#panel-months { grid-column: span 7; }
#panel-reasons { grid-column: span 5; }
#panel-lanes { grid-column: span 5; }
#panel-review { grid-column: span 7; }
#panel-settle { grid-column: span 12; }
#panel-review .table-scroll, #panel-lanes .table-scroll { max-height: 400px; overflow: auto; }
#panel-review table.t th { position: sticky; top: 0; background: var(--surface); }
table.t td.nowrap { white-space: nowrap; }
#lanes-table td:first-child { white-space: nowrap; }
#lanes-table { font-size: 12px; }
table.t td .sub.clip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 980px) { #panel-months, #panel-reasons, #panel-lanes, #panel-review { grid-column: span 12; } }
.panel-title { font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.panel-title .muted { text-transform: none; letter-spacing: 0; font-family: var(--sans); font-size: 11.5px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 2px; background: var(--c); margin-right: 5px; vertical-align: -1px; }
#month-chart svg { width: 100%; height: auto; display: block; }
#month-chart .bar { cursor: pointer; }
#month-chart text { font-family: var(--mono); font-size: 10px; fill: var(--muted); }
#month-chart .axis { stroke: var(--border); }
#month-chart .zero { stroke: var(--muted); }
#month-chart .month-hit { fill: transparent; cursor: pointer; }
#month-chart .month-hit:hover { fill: color-mix(in srgb, var(--blue) 8%, transparent); }
#month-chart .sel { fill: color-mix(in srgb, var(--blue) 12%, transparent); }
#month-chart .lbl { fill: var(--ink); font-weight: 600; }
.reason { display: grid; grid-template-columns: 1fr auto auto; gap: 2px 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--faint); }
.reason:last-child { border-bottom: 0; }
.reason .lab { font-size: 13px; color: var(--ink); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.reason .cnt { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.reason .amt { font-family: var(--mono); font-size: 12.5px; min-width: 88px; text-align: right; font-variant-numeric: tabular-nums; }
.reason .bar { grid-column: 1 / -1; height: 4px; background: var(--faint); border-radius: 1px; overflow: hidden; }
.reason .bar i { display: block; height: 100%; background: var(--c); }
.info { display: inline-flex; width: 15px; height: 15px; border-radius: 50%; border: 1px solid var(--border); color: var(--muted); font-family: var(--mono); font-size: 10px; align-items: center; justify-content: center; cursor: help; background: var(--surface); flex: none; }
.info:hover, .info.open { border-color: var(--blue); color: var(--blue); }
.tip { position: fixed; z-index: 50; max-width: 320px; background: var(--ink); color: var(--bg); font-size: 12.5px; line-height: 1.45; padding: 9px 11px; border-radius: 4px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18); text-wrap: pretty; }
.tip b { display: block; font-weight: 600; margin-bottom: 2px; }
.table-scroll { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.t th { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); text-align: left; font-weight: 500; padding: 4px 6px 5px 0; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.t th.num, table.t td.num { text-align: right; }
table.t td { padding: 5px 6px 5px 0; border-bottom: 1px solid var(--faint); vertical-align: baseline; }
table.t tr:last-child td { border-bottom: 0; }
table.t td.id { font-family: var(--mono); font-size: 11.5px; white-space: nowrap; }
table.t td .sub { display: block; font-size: 11.5px; color: var(--muted); }
table.t tr.total td { font-weight: 600; color: var(--ink); border-top: 1px solid var(--border); }
.toggles { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 11px; padding: 2px 7px; border-radius: 2px; background: var(--faint); color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: var(--c); }

/* trace */
.subtabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 14px; }
.trace-head { margin-bottom: 12px; }
.trace-head h2 { font-size: 16px; }
.trace-head .sub { color: var(--muted); font-size: 13px; max-width: 72ch; text-wrap: pretty; }
.cards { display: flex; flex-direction: column; gap: 8px; max-width: 920px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 12px 14px; box-shadow: var(--shadow); }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.step-n { font-family: var(--mono); font-size: 10.5px; color: var(--blue); background: var(--blue-soft); border-radius: 2px; padding: 2px 6px; }
.by { font-family: var(--mono); font-size: 10.5px; color: var(--muted); border: 1px solid var(--border); border-radius: 2px; padding: 2px 7px; }
.card p { color: var(--text); font-size: 13px; max-width: 70ch; text-wrap: pretty; margin-bottom: 8px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px 16px; }
.facts .k { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.facts .v { font-family: var(--mono); font-size: 12.5px; color: var(--ink); }
.rows { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.1fr) minmax(90px, 0.5fr); gap: 4px 12px; }
.rows > div { padding: 5px 0; border-bottom: 1px solid var(--faint); }
.rows .k { font-size: 13px; color: var(--ink); }
.rows .d { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.rows .v { font-family: var(--mono); font-size: 13px; text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }
.rows .total { font-weight: 600; }
.rows .warn { color: var(--amber); }
.formula { font-family: var(--mono); font-size: 12.5px; background: var(--faint); border: 1px solid var(--border); border-radius: 3px; padding: 10px 12px; white-space: pre-wrap; line-height: 1.6; overflow-x: auto; }
.src { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 8px; }
.warn-text { color: var(--amber); }
.card table.t { margin-top: 4px; }

/* rates */
.providers { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 6px; margin-bottom: 10px; }
.prov { text-align: left; font: inherit; color: inherit; cursor: pointer; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 9px 12px; box-shadow: var(--shadow); }
.prov.on { border-color: var(--blue); background: var(--blue-soft); }
.prov .ccn { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.prov.on .ccn { color: var(--blue); }
.prov .nm { font-weight: 600; color: var(--ink); font-size: 13.5px; line-height: 1.3; }
.prov .ct { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.rate-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 8px; align-items: start; }
.rate-grid .panel:nth-child(1) { grid-column: span 12; }
.rate-grid .panel:nth-child(2) { grid-column: span 6; }
.rate-grid .panel:nth-child(3) { grid-column: span 6; }
@media (max-width: 900px) { .rate-grid .panel:nth-child(2), .rate-grid .panel:nth-child(3) { grid-column: span 12; } }

.foot { border-top: 1px solid var(--border); margin-top: 20px; padding-top: 14px; padding-bottom: 28px; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; text-wrap: pretty; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
