/* admin layer (2026-10-23): the production design of every page except the Assistant. Loaded last. New components are `adm-*`; the pages themselves carry `.adm`, and only `.adm` is restyled, so the Assistant
   (#agent) is untouched. Light is the default theme, dark follows from the tokens. One scale: 4 / 8 / 12 / 16 / 24 spacing, 13px tables, 12px captions, one radius (12), one hairline (var(--border)). */

/* ---------- navigation: the grouped sidebar ---------- */
.nav-group { margin: 18px 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--faint); }
.nav-group:first-child { margin-top: 6px; }
.nav-item { padding: 7px 10px; font-size: 13.5px; }
.nav-item.on { background: var(--primary-soft); color: var(--text); font-weight: 600; box-shadow: inset 2px 0 0 var(--primary); border-radius: 0 8px 8px 0; }
.nav-item.on svg { color: var(--primary-text); }

/* ---------- page header: breadcrumb, title, one sentence ---------- */
.adm-top { margin: 0 0 12px; } .adm-top[hidden] { display: none; }
.adm-crumb { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; } .adm-crumb i { font-style: normal; color: var(--faint); } .adm-crumb [aria-current] { color: var(--text); font-weight: 600; }
.adm-title h1 { margin: 0; font-size: 24px; line-height: 1.2; letter-spacing: -.02em; } .adm-title p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; max-width: 72ch; }
.page-tabs { margin: 0 0 16px; } .page-tabs button small { margin-left: 6px; padding: 0 6px; border-radius: 99px; background: var(--surface-3); color: var(--muted); font-size: 11px; } .page-tabs button.on small { background: var(--primary-soft); color: var(--text); }
.main:has(#agent.on) .adm-top { display: none; }
.main:has(#search.on) .page-tabs { display: none; }
.main:has(#workflows.on) .adm-top { display: none; }
@media (max-width: 899px) { .adm-title h1 { font-size: 21px; } }

/* ---------- the shared parts: card, toolbar, table, status, empty state, steps, banner ---------- */
.adm .card { border-radius: 12px; box-shadow: none; border: 1px solid var(--border); background: var(--surface); padding: 16px 18px; margin-bottom: 16px; }
.adm .card-head h3, .adm-h { margin: 0; font-size: 14.5px; font-weight: 650; letter-spacing: -.005em; } .adm .card-head small { display: block; color: var(--muted); font-size: 12.5px; font-weight: 400; margin-top: 2px; }
.adm table { font-size: 13px; } .adm th { font-size: 11px; letter-spacing: .07em; padding: 8px 12px; background: var(--surface); } .adm td { padding: 9px 12px; } .adm tr.hover:hover td { background: var(--surface-2); }
.adm .tbl-wrap { border-radius: 10px; max-height: min(66vh, 720px); }
.adm .btn { border-radius: 8px; } .adm .btn.ghost { background: transparent; border-color: transparent; color: var(--muted); } .adm .btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.adm-bar { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; margin: 0 0 12px; } .adm-bar .grow { flex: 1 1 240px; } .adm-bar .count { margin-left: auto; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.adm-seg { display: inline-flex; padding: 2px; border-radius: 9px; background: var(--surface-3); gap: 2px; } .adm-seg button { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 500; padding: 4px 11px; border-radius: 7px; cursor: pointer; }
.adm-seg button:hover { color: var(--text); } .adm-seg button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); } .adm-seg button small { margin-left: 5px; color: var(--faint); }
.adm-empty { text-align: center; color: var(--muted); padding: 36px 16px; border: 1px dashed var(--border-strong); border-radius: 12px; background: var(--surface); } .adm-empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.adm-st { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 2px 10px; border-radius: 99px; white-space: nowrap; } .adm-st::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.adm-st.ok { background: var(--green-soft); color: var(--green); } .adm-st.warn { background: var(--amber-soft); color: var(--amber); } .adm-st.bad { background: var(--red-soft); color: var(--red); } .adm-st.run { background: var(--sky-soft); color: var(--sky); } .adm-st.off { background: var(--surface-3); color: var(--muted); }
.adm-st.run::before { animation: admPulse 1.2s ease-in-out infinite; } @keyframes admPulse { 50% { opacity: .25; } }
.adm-link { color: var(--primary-text); cursor: pointer; background: none; border: 0; font: inherit; padding: 0; } .adm-link:hover { text-decoration: underline; }

/* health banner and the figures under it */
.adm-banner { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 18px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); margin-bottom: 14px; }
.adm-banner .dot { width: 12px; height: 12px; } .adm-banner b { font-size: 15px; } .adm-banner .why { color: var(--muted); font-size: 13px; }
.adm-banner.ok { border-color: color-mix(in srgb, var(--green) 40%, var(--border)); background: color-mix(in srgb, var(--green-soft) 70%, var(--surface)); }
.adm-banner.warn { border-color: color-mix(in srgb, var(--amber) 45%, var(--border)); background: color-mix(in srgb, var(--amber-soft) 80%, var(--surface)); }
.adm-banner.bad { border-color: color-mix(in srgb, var(--red) 45%, var(--border)); background: color-mix(in srgb, var(--red-soft) 80%, var(--surface)); }
.adm-banner .dot.bad { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); } .adm-banner .sp { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.adm-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 16px; }
.adm-kpi { padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); } .adm-kpi .k { font-size: 12px; color: var(--muted); } .adm-kpi .v { font-size: 24px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; margin-top: 2px; }
.adm-kpi.bad .v { color: var(--red); } .adm-kpi.hot .v { color: var(--amber); } .adm-kpi small { display: block; color: var(--faint); font-size: 11.5px; }
.adm-fold { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); margin-bottom: 12px; } .adm-fold > summary { list-style: none; cursor: pointer; padding: 12px 16px; display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; font-size: 14px; }
.adm-fold > summary::before { content: "▸"; color: var(--faint); } .adm-fold[open] > summary::before { content: "▾"; } .adm-fold > summary small { font-weight: 400; color: var(--muted); } .adm-fold > .adm-body { padding: 4px 16px 16px; }

/* steps: a request, its progress, its documents */
.adm-steps { display: flex; gap: 0; margin: 0 0 16px; padding: 0; list-style: none; }
.adm-steps li { flex: 1; min-width: 0; position: relative; }
.adm-steps li + li::before { content: ""; position: absolute; left: -50%; right: 50%; top: 15px; height: 2px; background: var(--border); }
.adm-steps li.done + li::before, .adm-steps li.on + li::before { background: var(--primary); }
.adm-step { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; background: none; border: 0; font: inherit; color: var(--muted); cursor: pointer; position: relative; padding: 0 4px; }
.adm-step i { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-weight: 700; font-size: 13px; background: var(--surface-3); color: var(--muted); border: 2px solid var(--bg); position: relative; z-index: 1; }
.adm-steps li.on .adm-step i { background: var(--primary); color: var(--primary-ink); } .adm-steps li.done .adm-step i { background: var(--green-soft); color: var(--green); }
.adm-step span { font-size: 13px; font-weight: 600; text-align: center; } .adm-steps li.on .adm-step span { color: var(--text); } .adm-step small { font-size: 12px; color: var(--faint); text-align: center; }
.adm-prog { display: grid; gap: 10px; }
.adm-part { display: grid; grid-template-columns: 34px 1fr auto; gap: 4px 12px; align-items: center; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.adm-part .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); } .adm-part .ic svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.adm-part.ok .ic { background: var(--green-soft); color: var(--green); } .adm-part.bad .ic { background: var(--red-soft); color: var(--red); } .adm-part.run .ic { background: var(--sky-soft); color: var(--sky); }
.adm-part b { font-size: 14px; } .adm-part .sub { grid-column: 2; color: var(--muted); font-size: 12.5px; } .adm-part .meter { grid-column: 2 / 4; height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; } .adm-part .meter i { display: block; height: 100%; background: var(--primary); transition: width .3s; }

/* a summary row that opens into its items */
.adm-grp { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); margin-bottom: 8px; overflow: hidden; } .adm-grp > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 11px 16px; }
.adm-grp > summary::before { content: "▸"; color: var(--faint); width: 10px; } .adm-grp[open] > summary::before { content: "▾"; } .adm-grp > summary b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.adm-grp > summary .n { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; min-width: 28px; text-align: right; } .adm-grp[open] > summary { border-bottom: 1px solid var(--border); } .adm-grp .tbl-wrap { border: 0; border-radius: 0; max-height: 360px; }
.adm-pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin: 10px 0 0; font-size: 12.5px; color: var(--muted); }

/* patient header strip */
.adm-pt { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 14px 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); margin-bottom: 14px; }
.adm-pt .avatar { width: 46px; height: 46px; border-radius: 12px; font-size: 18px; } .adm-pt h2 { margin: 0; font-size: 18px; letter-spacing: -.01em; } .adm-pt .id { color: var(--muted); font-size: 12.5px; }
.adm-pt .figs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; } .adm-pt .fig { border: 0; font: inherit; cursor: pointer; display: inline-flex; align-items: baseline; gap: 5px; padding: 3px 10px; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: 12.5px; }
.adm-pt .fig b { color: var(--text); font-size: 14px; } .adm-pt .fig:hover { background: var(--surface-3); } .adm-pt .acts { margin-left: auto; display: flex; gap: 8px; }

/* search: results first */
.main:has(#search.on) .gs.home .gs-hero { padding-top: 6vh; }
.gs:not(.home) .gs-hero { padding-top: 0; padding-bottom: 8px; }

.adm-field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--muted); min-width: 180px; } .adm-field small { font-weight: 400; color: var(--faint); margin-left: 4px; }
.adm-field input { font-weight: 400; font-size: 14px; color: var(--text); padding: 9px 12px; }
.gr-pane[hidden] { display: none; } .gn-cats { gap: 8px; } .gn-cats .chip { padding: 5px 12px; font-size: 13px; }
tr.cur td { background: var(--primary-soft); }

/* ---------- Operations > Usage: charts, the who-pays bar, number columns ---------- */
.us-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 16px; } .us-grid > .card { margin-bottom: 0; }
.us-chart svg { width: 100%; height: auto; display: block; } .us-chart text { fill: var(--muted); font: 11px var(--sans); } .us-rule { stroke: var(--border); stroke-width: 1; }
.us-bar { fill: var(--primary); } .us-bar.spike { fill: var(--amber); } .us-bar:hover { opacity: .8; } .us-line { fill: none; stroke: var(--sky); stroke-width: 2; stroke-linejoin: round; } .us-dot-pt { fill: var(--primary); }
.us-stack { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--surface-3); margin: 4px 0 12px; } .us-stack i { display: block; height: 100%; }
.us-legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 10px 18px; } .us-legend small { margin-left: 6px; } .us-legend .why { display: block; margin: 1px 0 0 18px; color: var(--faint); }
.us-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; }
.adm table .num, .adm th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; } .adm tr[data-us-user] { cursor: pointer; } .adm tr[data-us-user]:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }

/* ---------- the pager (core/pager.js): count, rows per page, previous / next ---------- */
.adm-pager { flex-wrap: wrap; } .adm-pager .pg-size { display: inline-flex; align-items: center; gap: 6px; margin-left: 4px; } .adm-pager select { font: inherit; font-size: 12.5px; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 7px; padding: 3px 6px; }
nav.adm-pager span { margin-right: auto; font-variant-numeric: tabular-nums; }

/* ---------- Usage: sortable columns and the conversation drawer (the transcript behind a number) ---------- */
.th-sort { all: unset; cursor: pointer; font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; } .th-sort:hover, .th-sort[aria-sort] { color: var(--text); } .th-sort:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
.th-sort[aria-sort="descending"]::after { content: " ↓"; }
.adm .linkish { all: unset; cursor: pointer; color: var(--amber); font-family: var(--mono); } .adm .linkish:hover { text-decoration: underline; } .adm .linkish:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
.us-scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 60; } .us-scrim[hidden], .us-drawer[hidden] { display: none; }
.us-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100vw); z-index: 61; background: var(--bg); border-left: 1px solid var(--border-strong); box-shadow: -14px 0 40px rgba(0, 0, 0, .18); display: flex; flex-direction: column; }
.us-dh { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); } .us-dh b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; }
.us-db { flex: 1; overflow-y: auto; padding: 14px 16px 24px; overscroll-behavior: contain; }
.us-row { all: unset; box-sizing: border-box; display: grid; grid-template-columns: 1fr auto; gap: 2px 14px; width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); margin-bottom: 8px; cursor: pointer; }
.us-row:hover { background: var(--surface-2); } .us-row:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; } .us-row b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .us-row small { grid-column: 1; } .us-row .us-cost { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.us-chat-head { display: grid; gap: 8px; margin-bottom: 14px; } .us-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.us-turn { margin-bottom: 18px; } .us-q { background: var(--primary-soft); border-radius: 12px; padding: 9px 13px; margin-bottom: 8px; white-space: pre-wrap; overflow-wrap: anywhere; } .us-a { padding: 2px 4px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.us-m { margin: 6px 4px 0; color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; } .us-ref { color: var(--faint); font: 11px var(--mono); border: 1px solid var(--border); border-radius: 5px; padding: 0 4px; margin: 0 1px; white-space: nowrap; }

/* ---------- Operations > Metrics ---------- */
.mt-chips { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 4px 0 12px; } .mt-chips:empty { display: none; }
.mt-mix { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px; } .mt-mix > small { color: var(--muted); font-size: 12px; margin-right: 2px; } .mt-mix .chip b { margin-left: 4px; }
.mt-note { margin: 10px 2px 0; font-size: 12.5px; }
.mt-dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0 0 16px; font-size: 13px; } .mt-dl dt { color: var(--muted); } .mt-dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.mt-code { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); padding: 12px 14px; margin-bottom: 10px; } .mt-code p { margin: 8px 0 0; font-size: 13px; }
.mt-code-h { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; } .mt-code-h b { font-size: 15px; } .mt-code-h small { margin-left: auto; }
.mt-ev { margin: 8px 0 0; padding-left: 18px; font-size: 13px; } .mt-ev li + li { margin-top: 6px; } .mt-ev small { display: block; font-size: 12px; }

/* ---------- Erase a patient (Indexer > Overview) ---------- */
.adm .btn.danger, .btn.ghost.danger { color: var(--red); } .adm .btn.ghost.danger:hover { background: var(--red-soft); color: var(--red); }
.btn.danger-fill { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; } .btn.danger-fill:disabled { opacity: .45; cursor: not-allowed; }
.ove-list { margin: 0 0 12px; padding-left: 18px; font-size: 13.5px; } .ove-list li + li { margin-top: 4px; }
.ove-confirm { display: grid; gap: 6px; margin-top: 10px; font-size: 13px; font-weight: 600; } .ove-confirm input { font-weight: 400; }
