/* Clinician Match — front-desk console.
   Layout: sticky top bar with tabs; each view is a two-column console
   (form or list on one side, results on the other) that stacks on phones. */

:root {
  --bg: #f2f5f4;
  --surface: #ffffff;
  --sunk: #e8eeec;
  --ink: #1b2a29;
  --muted: #566765;
  --line: #d5dfdc;
  --accent: #1f6b64;
  --accent-ink: #ffffff;
  --accent-soft: #dfeeeb;
  --good: #2b7a4b;
  --good-soft: #e2f2e7;
  --warn: #93600f;
  --warn-soft: #f8eedc;
  --bad: #a93d36;
  --bad-soft: #f7e3e1;
  --shadow: 0 1px 2px rgb(16 38 36 / 0.08), 0 4px 16px rgb(16 38 36 / 0.06);
  --display: "Spectral", Georgia, "Times New Roman", serif;
  --body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1615; --surface: #162120; --sunk: #111b1a; --ink: #e3ebe9; --muted: #97a9a6; --line: #293a38;
    --accent: #5cbfb2; --accent-ink: #0b1a18; --accent-soft: #18332f;
    --good: #6cc894; --good-soft: #163024; --warn: #e2aa4e; --warn-soft: #33270f; --bad: #ec8077; --bad-soft: #3a1d1a;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 6px 20px rgb(0 0 0 / 0.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1615; --surface: #162120; --sunk: #111b1a; --ink: #e3ebe9; --muted: #97a9a6; --line: #293a38;
  --accent: #5cbfb2; --accent-ink: #0b1a18; --accent-soft: #18332f;
  --good: #6cc894; --good-soft: #163024; --warn: #e2aa4e; --warn-soft: #33270f; --bad: #ec8077; --bad-soft: #3a1d1a;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 6px 20px rgb(0 0 0 / 0.3);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
}
h1, h2, h3, h4 { font-family: var(--display); font-weight: 600; margin: 0; text-wrap: balance; letter-spacing: -0.005em; }
h2 { font-size: 22px; line-height: 1.2; }
h3 { font-size: 18px; line-height: 1.25; }
h4 { font-size: 15px; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 6px; z-index: 50; }
.skip:focus { left: 16px; }
.muted { color: var(--muted); }
.eyebrow { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.sub { color: var(--muted); font-size: 14px; max-width: 70ch; }
.hint { font-weight: 400; color: var(--muted); font-size: 13px; }
.hint::before { content: "· "; }

/* ---------- frame ---------- */
.app {
  max-width: 1240px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0 32px;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 24px;
  padding-block: 14px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.app-name { font-family: var(--display); font-weight: 600; font-size: 26px; line-height: 1.15; }
.tabs { display: flex; gap: 4px; background: var(--sunk); border: 1px solid var(--line); border-radius: 999px; padding: 4px; max-width: 100%; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 7px 14px; border-radius: 999px; cursor: pointer; color: var(--muted); font-weight: 700; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.tab-badge { background: var(--bad); color: #fff; border-radius: 999px; font-size: 11px; min-width: 18px; padding: 1px 6px; line-height: 16px; text-align: center; font-variant-numeric: tabular-nums; }
.user { display: none; }
.theme-switch { display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; color: var(--muted); font-size: 13px; font-weight: 700; cursor: pointer; padding: 4px; border-radius: 999px; }
.theme-switch:hover { color: var(--ink); }
.sw-track { position: relative; width: 38px; height: 22px; border-radius: 999px; background: var(--sunk); border: 1px solid var(--line); transition: background-color 0.15s; }
.sw-thumb { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow); transition: transform 0.15s; }
.theme-switch[aria-checked="true"] .sw-track { background: var(--accent); border-color: var(--accent); }
.theme-switch[aria-checked="true"] .sw-thumb { transform: translateX(16px); background: var(--accent-ink); }

.notice { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13.5px; color: var(--muted); }
.notice strong, .notice b { color: var(--ink); }
.crisis { margin-left: auto; font-variant-numeric: tabular-nums; }
main { display: block; min-width: 0; }
.loading { padding: 40px 0; color: var(--muted); display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.loading h2 { color: var(--ink); }
.foot { margin-top: auto; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-wrap: wrap; gap: 6px 20px; justify-content: space-between; }

/* ---------- shared pieces ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.view-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.view-head > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.section-label { display: flex; align-items: baseline; gap: 10px; margin: 22px 0 10px; font-size: 17px; }
.section-label span { font-family: var(--body); font-size: 13px; color: var(--muted); font-weight: 400; }
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--line); align-self: center; }

.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); border-radius: 8px; padding: 8px 14px; font-weight: 700; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.small { padding: 5px 10px; font-size: 13.5px; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger-ghost { background: transparent; border-color: transparent; color: var(--bad); }
.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; font-weight: 700; padding: 2px; }
.link-btn:hover { text-decoration: underline; }
.icon-btn { border: 1px solid transparent; background: none; color: var(--muted); border-radius: 6px; cursor: pointer; display: inline-grid; place-items: center; padding: 6px; }
.icon-btn:hover { color: var(--accent); border-color: var(--line); }
.icon-btn.small { padding: 3px; }

.field { display: flex; flex-direction: column; gap: 6px; border: 0; margin: 0; padding: 0; min-width: 0; }
.field > legend, .field > label { font-weight: 700; font-size: 14px; padding: 0; margin-bottom: 4px; }
.field.inline { flex-direction: row; align-items: center; }
input[type="text"], input[type="url"], input[type="search"], input[type="date"], input[type="email"], input[type="tel"], input[type="number"], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
}
textarea { resize: vertical; min-height: 70px; }
input:invalid:not(:placeholder-shown) { border-color: var(--bad); }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span { display: inline-flex; align-items: center; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 14px; cursor: pointer; user-select: none; transition: background-color 0.12s, border-color 0.12s; }
.chip:hover span { border-color: var(--accent); }
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card-top { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.who { min-width: 0; }
.card h3 { font-size: 19px; }
.cred { color: var(--muted); font-size: 13px; margin-top: 2px; }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: auto; }
.stamp { color: var(--muted); font-size: 12.5px; }
.ext { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; font-size: 13.5px; text-decoration: none; }
.ext svg { width: 13px; height: 13px; }
.ext:hover { text-decoration: underline; }

.pill { flex: none; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.pill-strong, .pill-ok { background: var(--good-soft); color: var(--good); }
.pill-good { background: var(--accent-soft); color: var(--accent); }
.pill-partial, .pill-upcoming { background: var(--warn-soft); color: var(--warn); }
.pill-soon { background: var(--warn-soft); color: var(--warn); box-shadow: 0 0 0 1px var(--warn) inset; }
.pill-off, .pill-overdue { background: var(--bad-soft); color: var(--bad); }

.checks { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.ck { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; border-radius: 6px; padding: 3px 8px; background: var(--sunk); }
.ck svg { width: 13px; height: 13px; stroke-width: 2.4; }
.ck span { color: var(--ink); }
.ck-yes { color: var(--good); }
.ck-no { color: var(--warn); }
.ck-no-hard { color: var(--bad); background: var(--bad-soft); }
.ck-unknown { color: var(--muted); border: 1px dashed var(--line); background: transparent; }

.meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13.5px; margin: 0; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.meta .missing { color: var(--warn); }
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13.5px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-open { color: var(--good); }
.status-limited { color: var(--warn); }
.status-full { color: var(--bad); }
.status-unset { color: var(--muted); }

.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { font-size: 12.5px; background: var(--sunk); border-radius: 6px; padding: 2px 8px; }
.tag-accent { background: var(--accent-soft); color: var(--accent); }
.openings { font-size: 14px; }
.booking { font-size: 13.5px; background: var(--warn-soft); border-radius: 8px; padding: 7px 10px; }
.booking b, .rule b { color: var(--warn); }
.rule { font-size: 13.5px; background: var(--warn-soft); border-left: 3px solid var(--warn); border-radius: 6px; padding: 8px 10px; }

.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r); padding: 20px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.empty h3 { color: var(--ink); font-size: 17px; }
.flag { background: var(--warn-soft); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.flag b { color: var(--warn); }

.toast { position: fixed; inset: auto auto auto 50%; margin: 0; border: 0; width: max-content; height: auto; overflow: visible; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 999px; font-weight: 700; font-size: 14px; z-index: 60; max-width: calc(100vw - 32px); text-align: center; }
.toast[data-tone="error"] { background: var(--bad); color: #fff; border-radius: 10px; }

/* ---------- match view ---------- */
.match-grid { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 22px; align-items: start; }
.screen-form { position: sticky; top: 96px; max-height: calc(100vh - 112px); overflow-y: auto; }
.results { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.results-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 10px; }
.summary { font-size: 13.5px; background: var(--sunk); border: 1px dashed var(--line); border-radius: 8px; padding: 10px 12px; color: var(--muted); }
.summary b { color: var(--ink); }
#flags { display: flex; flex-direction: column; gap: 8px; }
#flags:empty { display: none; }

/* ---------- clinicians view ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .field:first-child { flex: 1 1 260px; }
.toolbar .field:nth-child(2) { flex: 0 1 220px; }
.count { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.history { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.history li { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; gap: 12px; padding: 9px 14px; border-top: 1px solid var(--line); font-size: 14px; }
.history li:first-child { border-top: 0; }
.history .when, .history .by { color: var(--muted); font-size: 13px; }
.history .by { overflow-wrap: anywhere; }

/* ---------- credentialing view ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: flex; flex-direction: column; }
.stat .n { font-family: var(--display); font-size: 28px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 13px; }
.stat-overdue .n { color: var(--bad); }
.stat-soon .n { color: var(--warn); }
.stat-good .n { color: var(--good); }
.cred-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.table-wrap { overflow-x: auto; position: relative; }
.dl-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.dl-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.dl-table td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.dl-table .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-overdue td:first-child { box-shadow: 3px 0 0 var(--bad) inset; }
.row-soon td:first-child { box-shadow: 3px 0 0 var(--warn) inset; }
.missing-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.missing-list li { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 14px; }
.missing-list span { color: var(--warn); }
.pgroup { display: flex; flex-direction: column; gap: 6px; }
.pgroup h4 { font-size: 12px; font-family: var(--body); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }
.pfields { margin: 0; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.pf { display: grid; grid-template-columns: minmax(120px, 0.8fr) minmax(0, 1.4fr); gap: 10px; padding: 7px 10px; border-top: 1px solid var(--line); font-size: 14px; align-items: center; }
.pf:first-child { border-top: 0; }
.pf dt { color: var(--muted); }
.pf dd { margin: 0; display: flex; justify-content: space-between; align-items: center; gap: 8px; min-width: 0; }
.pv { overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

/* ---------- editor dialog ---------- */
dialog { border: 0; padding: 0; background: transparent; color: var(--ink); max-width: none; max-height: none; }
dialog::backdrop { background: rgb(8 18 17 / 0.45); }
.side-dialog[open] {
  position: fixed; inset: 0 0 0 auto; margin: 0; height: 100%; width: min(760px, 100vw);
  display: flex;
}
.editor { background: var(--surface); width: 100%; height: 100%; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.ed-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: max(18px, env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-right, 0px)) 6px 20px; }
.ed-head > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ed-nav { display: flex; gap: 4px; overflow-x: auto; padding: 4px 20px 10px; border-bottom: 1px solid var(--line); }
.ed-nav a { font-size: 13px; font-weight: 700; color: var(--muted); text-decoration: none; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.ed-nav a:hover { background: var(--sunk); color: var(--ink); }
.ed-body { flex: 1; overflow-y: auto; padding: 4px max(20px, env(safe-area-inset-right, 0px)) 24px 20px; display: flex; flex-direction: column; gap: 6px; }
.ed-body section { display: flex; flex-direction: column; gap: 14px; padding-top: 18px; scroll-margin-top: 6px; }
.ed-body section + section { border-top: 1px solid var(--line); margin-top: 12px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.field-grid .wide { grid-column: 1 / -1; }
.warn-note { background: var(--warn-soft); border-radius: 8px; padding: 8px 12px; font-size: 13.5px; }
.ins-table { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.ins-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 7px 10px; border-top: 1px solid var(--line); }
.ins-row:first-child { border-top: 0; }
.ins-name { font-size: 14px; min-width: 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg-opt { position: relative; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-opt span { display: block; padding: 4px 9px; font-size: 12.5px; cursor: pointer; border-left: 1px solid var(--line); }
.seg-opt:first-child span { border-left: 0; }
.seg-opt input:checked + span { background: var(--accent); color: var(--accent-ink); }
.seg-opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }
.form-error { margin: 0 20px; background: var(--bad-soft); color: var(--ink); border-radius: 8px; padding: 9px 12px; font-size: 14px; }
.ed-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px max(20px, env(safe-area-inset-right, 0px)) max(14px, env(safe-area-inset-bottom, 0px)) 20px; border-top: 1px solid var(--line); background: var(--surface); }
.ed-actions { display: flex; gap: 8px; justify-content: flex-end; }
#confirm[open] { margin: auto; }
.confirm { background: var(--surface); border-radius: var(--r); padding: 20px; width: min(420px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.confirm p { color: var(--muted); }

.ed-sub { font-family: var(--body); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-top: 6px; }
.ed-head.flat { padding: 0; }
.ins-summary { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.ins-sum { display: grid; grid-template-columns: 10px auto minmax(0, 1fr); gap: 4px 10px; align-items: baseline; }
.ins-sum b { white-space: nowrap; }
.ins-dot { width: 10px; height: 10px; border-radius: 50%; background: currentColor; align-self: center; }
.field-grid.tight { grid-template-columns: minmax(0, 0.7fr) minmax(0, 1fr); gap: 12px; }
.back { display: inline-flex; align-items: center; gap: 2px; margin: 0 0 4px -4px; font-size: 13.5px; }

/* ---------- status tones (insurance) ---------- */
.tone-yes { --t: var(--good); --t-soft: var(--good-soft); }
.tone-wait { --t: var(--warn); --t-soft: var(--warn-soft); }
.tone-no { --t: var(--bad); --t-soft: var(--bad-soft); }
.tone-none { --t: var(--muted); --t-soft: transparent; }
.ins-dot { color: var(--t); }

/* ---------- insurance view ---------- */
#view-insurance { display: flex; flex-direction: column; gap: 16px; }
#view-insurance[hidden] { display: none; }
#view-insurance .view-head, #view-insurance .stats { margin-bottom: 0; }
.grid-head { margin-top: 6px; }
.section-label.flat { margin: 0; flex: 1 1 auto; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .cell { min-width: 0; padding: 1px 6px; font-style: normal; font-size: 11.5px; cursor: default; }
/* Fits under the sticky top bar so the clinician names stay visible on short laptop screens. */
.grid-wrap { overflow: auto; max-height: max(300px, calc(100vh - 210px)); scroll-margin-top: 100px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.ins-grid { border-collapse: separate; border-spacing: 0; font-size: 13.5px; min-width: 100%; }
.ins-grid th, .ins-grid td { border-bottom: 1px solid var(--line); padding: 4px; text-align: center; }
.ins-grid thead th { position: sticky; top: 0; z-index: 2; background: var(--surface); font-size: 12.5px; font-weight: 700; color: var(--muted); padding: 10px 6px; white-space: nowrap; border-bottom: 1px solid var(--line); }
.ins-grid tbody th { position: sticky; left: 0; z-index: 1; background: var(--surface); text-align: left; padding: 6px 12px 6px 12px; min-width: 170px; max-width: 220px; border-right: 1px solid var(--line); }
.ins-grid thead th.corner { left: 0; z-index: 3; text-align: left; padding-left: 12px; border-right: 1px solid var(--line); }
.ins-grid tbody tr:last-child > * { border-bottom: 0; }
.ins-grid tbody tr:hover > * { background: var(--sunk); }
.ins-grid tr.inactive th .payer-btn { color: var(--muted); }
.payer-btn { display: block; border: 0; background: none; padding: 0; font-weight: 700; color: var(--ink); cursor: pointer; text-align: left; }
.payer-btn:hover { color: var(--accent); text-decoration: underline; }
.payer-sub { display: block; font-size: 12px; color: var(--muted); }
.cell { position: relative; display: inline-flex; align-items: center; justify-content: center; min-width: 76px; padding: 5px 8px; border-radius: 6px; border: 1px solid transparent; background: var(--t-soft); color: var(--t); font-weight: 700; font-size: 12.5px; cursor: pointer; white-space: nowrap; }
.cell.tone-none { color: var(--muted); border: 1px dashed var(--line); font-weight: 400; }
button.cell:hover { border-color: var(--t); }
.tone-none.cell:hover { border-color: var(--accent); }
.cell-note { position: absolute; top: 3px; right: 3px; width: 6px; height: 6px; border-radius: 50%; background: var(--t); }

.wait-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.wait-list li + li { border-top: 1px solid var(--line); }
.wait-row { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto 120px; gap: 2px 14px; align-items: center; border: 0; background: none; padding: 9px 12px; text-align: left; cursor: pointer; font-size: 14px; }
.wait-row:hover { background: var(--sunk); }
.wait-stage { color: var(--t); background: var(--t-soft); border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.wait-age { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.wait-age.old { color: var(--bad); font-weight: 700; }
.wait-note { grid-column: 1 / -1; color: var(--muted); font-size: 13px; }
.wait-note.blocked { color: var(--warn); font-weight: 700; }
#ins-waiting { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
#ins-waiting .wait-list { align-self: stretch; }

/* cell dialog */
#cell[open] { margin: auto; }
.cell-form { width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 32px); overflow-y: auto; gap: 16px; }
.stages { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.stage { position: relative; }
.stage input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.stage span { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 14px; cursor: pointer; }
.stage span::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--t); flex: none; }
.stage.tone-none span::before { background: transparent; border: 1px dashed var(--muted); }
.stage input:checked + span { border-color: var(--t); background: var(--t-soft); font-weight: 700; box-shadow: 0 0 0 1px var(--t) inset; }
.stage.tone-none input:checked + span { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink) inset; }
.stage input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.howto { background: var(--sunk); border-radius: 8px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; align-items: flex-start; }
.howto h3 { font-size: 15px; }
.howto dl { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; }
.howto dl > div { display: contents; }
.howto dt { color: var(--muted); }
.howto dd { margin: 0; overflow-wrap: anywhere; white-space: pre-line; }
.howto a { display: inline-flex; align-items: center; gap: 4px; }

/* directory */
.dir-tools { display: flex; gap: 10px; align-items: center; padding-top: 14px; }
.dir-tools input { flex: 1; }
.dir-list { display: flex; flex-direction: column; gap: 10px; padding-top: 4px; }
.dir-card { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.dir-card.inactive { opacity: 0.75; }
.dir-card h3 { font-size: 17px; }
.dir-line { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; font-size: 13.5px; }
.dir-line a { display: inline-flex; align-items: center; gap: 4px; overflow-wrap: anywhere; }
.sep { color: var(--line); }
.dir-notes { font-size: 13.5px; white-space: pre-line; }
.policy { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin: 0 0 10px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.policy legend { font-weight: 700; font-size: 14px; padding: 0 4px; }
.policy .field-grid { width: 100%; }

/* credentialing profile */
.profile { display: flex; flex-direction: column; gap: 14px; }
.profile.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 14px 18px; align-items: start; }
.practice-panel { margin-top: 18px; }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  .match-grid, .cred-grid { grid-template-columns: minmax(0, 1fr); }
  .screen-form { position: static; max-height: none; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crisis { margin-left: 0; }
}
@media (max-width: 560px) {
  .topbar { position: static; }
  .app-name { font-size: 22px; }
  .tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; border-radius: 14px; }
  .tabs button { justify-content: center; border-radius: 10px; }
  .field-grid { grid-template-columns: minmax(0, 1fr); }
  .history li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .stages { grid-template-columns: minmax(0, 1fr); }
  .wait-row { grid-template-columns: minmax(0, 1fr) auto; }
  .wait-age { grid-column: 1 / -1; text-align: left; }
  .ins-grid tbody th { min-width: 130px; }
  .cell { min-width: 60px; }
  .pf { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .dl-table thead { display: none; }
  .dl-table, .dl-table tbody { display: block; }
  .dl-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 10px 8px 10px 12px; border-bottom: 1px solid var(--line); }
  .dl-table td { border: 0; padding: 0; }
  .dl-table td:nth-child(2) { font-weight: 700; grid-column: 1; grid-row: 1; }
  .dl-table td:nth-child(1) { grid-column: 1; grid-row: 3; color: var(--muted); }
  .dl-table td:nth-child(3) { grid-column: 1; grid-row: 2; }
  .dl-table td:nth-child(4) { grid-column: 2; grid-row: 1; justify-self: end; }
  .dl-table td:nth-child(5) { grid-column: 2; grid-row: 3; justify-self: end; }
  .row-overdue td:first-child, .row-soon td:first-child { box-shadow: none; }
  .row-overdue { box-shadow: 3px 0 0 var(--bad) inset; }
  .row-soon { box-shadow: 3px 0 0 var(--warn) inset; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
