:root {
  --bg: #f4f5f7; --panel: #ffffff; --ink: #1d2433; --muted: #667085; --line: #e3e6eb;
  --line-strong: #cfd4dc; --accent: #2457c5; --accent-soft: #e9effc; --total: #f7f8fa;
  --side: #121826; --side-ink: #c9d1e1; --side-active: #ffffff; --danger: #b42318;
  --radius: 10px; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }

.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 18px 10px; position: sticky; top: 0;
        height: 100vh; overflow-y: auto; }
.brand { color: #fff; font-weight: 650; font-size: 15px; padding: 0 10px 14px; }
.brand small { display: block; color: #8e98ad; font-weight: 400; font-size: 12px; margin-top: 2px; }
.nav-link { display: block; color: var(--side-ink); padding: 6px 10px; border-radius: 6px; font-size: 13.5px; }
.nav-link:hover { background: #1e2638; color: #fff; }
.nav-link.active { background: #2a3550; color: var(--side-active); font-weight: 600; }
.signout { margin-top: 18px; color: #8e98ad; }
.signout .who { display: block; font-size: 11px; padding: 0 10px; overflow-wrap: anywhere; }
.signout .nav-link { color: inherit; }
.login-form { display: grid; gap: 10px; }
.login-card .or { text-align: center; margin: 2px 0; }
.login-card .google { justify-content: center; }

.main { padding: 20px 24px 40px; min-width: 0; }
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.note { color: var(--muted); margin: 6px 0 0; font-size: 13px; }
.asof { display: flex; gap: 18px; margin: 0; flex-wrap: wrap; }
.asof div { text-align: right; }
.asof dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.asof dd { margin: 2px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
        padding: 16px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.head-right { display: flex; align-items: center; gap: 12px; }
.count { color: var(--muted); font-variant-numeric: tabular-nums; }
.count strong { color: var(--ink); }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: #fff;
       color: var(--ink); border-radius: 8px; padding: 7px 12px; font: inherit; font-weight: 550; cursor: pointer; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); color: #fff; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.pill { display: inline-block; background: var(--accent-soft); color: var(--accent); border-radius: 999px;
        padding: 0 7px; font-size: 12px; font-weight: 600; }

/* Filters */
.filters { padding: 10px 16px; }
.filter-toggle > summary { cursor: pointer; font-weight: 600; padding: 4px 0; list-style: none; }
.filter-toggle > summary::-webkit-details-marker { display: none; }
.filter-toggle > summary::before { content: "▸"; display: inline-block; width: 14px; color: var(--muted); }
.filter-toggle[open] > summary::before { content: "▾"; }
.ctl-section { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 12px 0 4px; }
.ctl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px 14px; margin-top: 10px; }
.ctl label { display: block; font-size: 12px; font-weight: 600; color: #344054; margin-bottom: 4px; }
.ctl input[type=text], .ctl input[type=date], .ctl input[type=number], .ctl select, .ms > summary {
  width: 100%; border: 1px solid var(--line-strong); border-radius: 7px; padding: 6px 8px; font: inherit;
  background: #fff; min-height: 32px; }
.ctl-daterange, .ctl-numrange { grid-column: span 2; }
.range { display: flex; align-items: center; gap: 6px; }
.range span { color: var(--muted); }
.ctl-actions { display: flex; gap: 8px; margin: 14px 0 4px; }

.ms { position: relative; }
.ms > summary { cursor: pointer; list-style: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms > summary::-webkit-details-marker { display: none; }
.ms > summary .ph { color: #98a2b3; }
.ms-pop { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; width: max(100%, 300px); background: #fff;
          border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: 0 8px 24px rgba(16, 24, 40, .14); padding: 8px; }
.ms-find { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font: inherit; margin-bottom: 6px; }
.ms-list { max-height: 260px; overflow-y: auto; }
.ms-opt { display: flex !important; gap: 8px; align-items: flex-start; font-weight: 400 !important; padding: 4px 4px;
          border-radius: 5px; font-size: 13px !important; color: var(--ink) !important; cursor: pointer; margin: 0 !important; }
.ms-opt:hover { background: var(--bg); }

/* Tables */
.scroll { overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.scroll.short { max-height: 420px; }
.tablewrap { max-height: 70vh; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { font-weight: 600; font-size: 12.5px; color: #344054; background: #fafbfc; }
thead th { position: sticky; top: 0; z-index: 2; }
.pivot thead tr:nth-child(2) th { top: 31px; }
.pivot thead tr:nth-child(3) th { top: 62px; }
.num { text-align: right; }
.pivot tbody th { background: #fff; position: sticky; left: 0; z-index: 1; font-weight: 500; }
.pivot .axis { color: var(--muted); font-weight: 500; }
.pivot .grp { text-align: center; border-left: 1px solid var(--line); }
.pivot .corner { color: var(--muted); }
.pivot tr.total th, .pivot tr.total td { background: var(--total); font-weight: 700; }
.strong { font-weight: 650; }
.grid th a { color: inherit; display: block; }
.grid th.sorted { color: var(--accent); }
.grid th.sorted a { color: var(--accent); }
.grid tbody tr:hover td { background: #f9fafc; }
.grid td.wrap { max-width: 380px; overflow: hidden; text-overflow: ellipsis; }
.arrow { font-size: 10px; }
.empty { color: var(--muted); text-align: center; padding: 28px; }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 14px; margin-top: 10px; color: var(--muted); }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi span { display: block; font-size: 12px; color: var(--muted); }
.kpi strong { font-size: 20px; font-variant-numeric: tabular-nums; }

.login { display: grid; place-items: center; min-height: 100vh; }
.login-card { width: 340px; display: grid; gap: 10px; }
.login-card input { border: 1px solid var(--line-strong); border-radius: 7px; padding: 8px; font: inherit; }
.muted { color: var(--muted); margin: 0; }
.err { color: var(--danger); margin: 0; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .main { padding: 16px; }
  .ctl-daterange, .ctl-numrange { grid-column: span 1; }
}

/* Side-by-side ranked lists (Code Breakdown + Statistics by Payor) and the Summary Top 30 grid */
.duo { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 16px; }
.bars { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; }
.duo > .card, .bars > .card { margin-bottom: 16px; }
.ranked th.wraplabel { white-space: normal; max-width: 420px; word-break: break-word; font-weight: 500; }
.barcell { width: 30%; min-width: 80px; }
.bar { display: block; height: 10px; border-radius: 3px; background: var(--accent); opacity: .75; }
.sumchip { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.sumchip strong { color: var(--ink); }
@media (max-width: 1100px) { .duo { grid-template-columns: 1fr; } }
/* Collapsible sidebar: workbook sections, and groups inside them */
nav details > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; user-select: none; }
nav details > summary::-webkit-details-marker { display: none; }
nav .chev { width: 0; height: 0; border-left: 4px solid currentColor; border-top: 4px solid transparent;
  border-bottom: 4px solid transparent; transition: transform .12s; flex: none; opacity: .7; }
nav details[open] > summary > .chev { transform: rotate(90deg); }
.nav-book { margin: 6px 0 2px; border-top: 1px solid rgba(255,255,255,.08); padding-top: 6px; }
.nav-book:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.nav-book > summary { font-size: 12.5px; font-weight: 700; color: #e8ecf4; padding: 8px 10px; border-radius: 6px; }
.nav-book > summary:hover { background: #1e2638; }
.nav-book-title { flex: 1; }
.nav-n { font-size: 11px; font-weight: 500; color: #7d879b; }
.nav-book:not([open]) > summary { color: #a9b2c4; }
details.nav-group > summary { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #7d879b;
  padding: 10px 10px 4px; }
details.nav-group > summary:hover { color: #c3cad8; }
