:root {
  /* Design tokens — everything below references these, not literals.
     Accent = the brand-kit blue (src/brand/, #3a5ae0 … #8fb0ff). */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  --text-xs: 12px;
  --text-sm: 14px;
  --text-md: 16px;
  --text-lg: 18px;
  --text-xl: 22px;
  --text-2xl: 28px;

  --surface-0: #f6f7fb;
  --surface-1: #fff;
  --surface-2: #eef2fb;
  --surface-3: #e2e8f5;

  --border: #dfe4ee;
  --border-strong: #c5cddd;

  --text: #141a2b;
  --text-muted: #5d6679;
  --text-inverse: #fff;

  --accent: #3a5ae0;
  --accent-hover: #2f47c4;
  --accent-soft: #e8edff;
  --ok: #1a7a3c;
  --ok-soft: #e5f4ea;
  --warn: #b86e00;
  --warn-soft: #fff4e2;
  --danger: #b42828;
  --danger-soft: #fbeaea;
  --info: #1d4f9e;
  --info-soft: #e4edfb;

  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 6%);
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 2px 8px rgb(0 0 0 / 5%);
  --shadow-lg: 0 8px 28px rgb(0 0 0 / 14%);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: var(--text-sm)/1.45 var(--font);
  color: var(--text);
  background: var(--surface-0);
}

a { color: var(--accent); }
h1 { font-size: var(--text-2xl); margin: 0 0 var(--space-1); }
h2 { font-size: var(--text-lg); margin: 0 0 var(--space-3); }
.muted { color: var(--text-muted); }

/* --- Top bar — ported from Route Care (../../app/src/app.css) ------------ */

header.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
header.topbar .brand {
  display: inline-flex; align-items: center; gap: var(--space-2);
  text-decoration: none; color: var(--text);
  padding-right: var(--space-4);
  border-right: 1px solid var(--border);
  height: 36px;
}
header.topbar .brand:hover .brand-line { color: var(--accent); }
header.topbar .brand-logo { width: 28px; height: 28px; display: block; flex-shrink: 0; }
header.topbar .brand-wordmark { display: inline-flex; flex-direction: column; justify-content: center; line-height: 1.15; white-space: nowrap; }
header.topbar .brand-line { font-size: var(--text-md); font-weight: 500; color: var(--text-muted); letter-spacing: -0.01em; transition: color .12s ease; }
header.topbar .brand-sub { font-size: 11px; font-weight: 500; color: var(--text-muted); letter-spacing: .02em; opacity: .75; }
header.topbar .brand-strong { font-weight: 700; color: var(--text); }
header.topbar nav { display: flex; gap: var(--space-1); flex-wrap: nowrap; }
header.topbar nav a {
  text-decoration: none; color: var(--text-muted);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius); font-weight: 500; font-size: var(--text-sm); white-space: nowrap;
  transition: background-color .12s ease, color .12s ease;
}
header.topbar nav a:hover { background: var(--surface-2); color: var(--text); }
header.topbar nav a.active { background: var(--accent-soft); color: var(--accent); }
header.topbar .spacer { flex: 1; }

/* Account dropdown — as Route Care's. */
.user-menu { position: relative; }
.user-menu-trigger {
  display: inline-flex; align-items: center; gap: var(--space-2);
  background: transparent; border: 1px solid var(--border);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius);
  cursor: pointer; font: inherit; font-size: var(--text-sm); color: var(--text);
  transition: background-color .12s ease, border-color .12s ease;
}
.user-menu-trigger:hover, .user-menu-trigger[aria-expanded="true"] { background: var(--surface-2); border-color: var(--border-strong); }
.user-menu-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  font-size: 11px; font-weight: 600; letter-spacing: .02em; flex-shrink: 0;
}
.user-menu-header { padding: var(--space-2) var(--space-3); color: var(--text-muted); font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-chev { transition: transform .12s ease; }
.user-menu-trigger[aria-expanded="true"] .user-menu-chev { transform: rotate(180deg); }
.user-menu-dropdown {
  position: absolute; top: calc(100% + var(--space-1)); right: 0; min-width: 220px;
  background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: var(--space-1); z-index: 200;
  display: flex; flex-direction: column; animation: user-menu-in .12s ease-out;
}
.user-menu-dropdown[hidden] { display: none; }
@keyframes user-menu-in { from { transform: translateY(-4px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .user-menu-dropdown { animation: none; } .user-menu-chev { transition: none; } }
.user-menu-item {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3); text-decoration: none; color: var(--text);
  font: inherit; font-size: var(--text-sm); background: transparent; border: 0;
  border-radius: var(--radius-sm); cursor: pointer; text-align: left; width: 100%;
}
.user-menu-item .icon { color: var(--text-muted); }
.user-menu-item:hover { background: var(--surface-2); }
.user-menu-item.danger { color: var(--danger); }
.user-menu-item.danger:hover { background: var(--danger-soft); }
.user-menu-item.danger .icon { color: var(--danger); }
.user-menu-divider { height: 1px; background: var(--border); margin: var(--space-1) 0; }

.tag { display: inline-block; padding: 1px var(--space-2); border-radius: var(--radius-sm); font-size: var(--text-xs); font-weight: 500; line-height: 1.5; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.draft { background: var(--surface-3); color: var(--text-muted); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.danger { background: var(--danger-soft); color: var(--danger); }
.tag.info { background: var(--accent-soft); color: var(--accent); }

.search { position: relative; width: min(320px, 32vw); }
.search input { width: 100%; }
.search-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  margin: 0; padding: var(--space-1) 0; list-style: none;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  max-height: 60vh; overflow: auto;
}
.search-results li a {
  display: flex; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-2) var(--space-3); color: var(--text); text-decoration: none;
}
.search-results li a.hl, .search-results li a:hover { background: var(--surface-2); }

.poc-banner {
  margin: 0; padding: var(--space-1) var(--space-5);
  font-size: var(--text-xs); color: var(--warn); background: var(--warn-soft);
}

main { max-width: 1180px; margin: 0 auto; padding: var(--space-5); outline: none; }

/* --- Controls --------------------------------------------------------- */

input, select, textarea {
  font: inherit; color: inherit;
  padding: 7px var(--space-3);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface-1);
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
textarea { width: 100%; min-height: 80px; resize: vertical; }

button, .btn {
  font: inherit; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 7px var(--space-4);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface-1); color: var(--text); text-decoration: none;
}
button:hover, .btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--text-inverse); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-sm { padding: 3px var(--space-3); font-size: var(--text-xs); }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-5); }
.toolbar { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin-bottom: var(--space-4); }

/* --- Cards / stats ---------------------------------------------------- */

.grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: var(--space-4);
}
.stats { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: var(--space-5); }
.stat { padding: var(--space-4); }
.stat .n { font-size: var(--text-2xl); font-weight: 700; }
.stat .l { color: var(--text-muted); }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-2) 0; border-bottom: 1px solid var(--border);
}
.list li:last-child { border-bottom: 0; }

/* --- Tables ----------------------------------------------------------- */

.table-wrap { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); background: var(--surface-2); position: sticky; top: 0; }
tbody tr:hover { background: var(--surface-2); }
tbody tr[data-href] { cursor: pointer; }

/* --- Chips ------------------------------------------------------------ */

.chip {
  display: inline-block; padding: 1px var(--space-2); border-radius: 999px;
  font-size: var(--text-xs); font-weight: 600; background: var(--surface-3); color: var(--text-muted);
}
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-danger { background: var(--danger-soft); color: var(--danger); }
.chip-info { background: var(--info-soft); color: var(--info); }

.days { display: inline-flex; gap: 2px; }
.days span {
  width: 22px; text-align: center; font-size: var(--text-xs); border-radius: var(--radius-sm);
  background: var(--surface-3); color: var(--text-muted);
}
.days span.on { background: var(--accent); color: var(--text-inverse); }

/* Status toggle group (attendance). */
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 4px var(--space-3); }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button.on-present { background: var(--ok); color: var(--text-inverse); }
.seg button.on-absent { background: var(--danger); color: var(--text-inverse); }
.seg button.on-excused { background: var(--warn); color: var(--text-inverse); }

/* --- Forms ------------------------------------------------------------ */

.form { display: grid; gap: var(--space-4); }
.fieldset { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.field { display: grid; gap: var(--space-1); }
.field > span { font-size: var(--text-xs); font-weight: 600; color: var(--text-muted); }
.field.wide { grid-column: 1 / -1; }
.day-toggles { display: flex; gap: var(--space-1); }
.day-toggles label {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 34px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  cursor: pointer; user-select: none; font-weight: 600;
}
.day-toggles input { position: absolute; opacity: 0; pointer-events: none; }
.day-toggles label:has(input:checked) { background: var(--accent); border-color: var(--accent); color: var(--text-inverse); }
.day-toggles label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.form-actions { display: flex; gap: var(--space-2); justify-content: flex-end; position: sticky; bottom: 0; padding: var(--space-3) 0; background: var(--surface-0); border-top: 1px solid var(--border); }

.two-col { display: grid; gap: var(--space-4); grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); align-items: start; }

kbd { font: var(--text-xs) ui-monospace, monospace; padding: 0 5px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-1); }

/* --- Toast ------------------------------------------------------------ */

.toast {
  position: fixed; bottom: var(--space-5); left: 50%; transform: translate(-50%, 20px);
  padding: var(--space-2) var(--space-4); border-radius: var(--radius);
  color: var(--text-inverse); background: var(--ok); box-shadow: var(--shadow-lg);
  opacity: 0; transition: opacity .15s, transform .15s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: var(--danger); }

/* --- Narrow screens (as Route Care: hamburger + slide-in drawer). Route Care
   switches at 720px; chart.care's topbar also carries search, so 900px. ------ */

.nav-toggle {
  display: none; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0; border: 0; background: transparent; color: var(--text);
}
.nav-backdrop { position: fixed; inset: 0; background: rgb(0 0 0 / 40%); z-index: 250; }
.nav-backdrop[hidden] { display: none; }

@media (max-width: 900px) {
  .nav-toggle { display: inline-flex; }
  header.topbar { gap: var(--space-2); padding: var(--space-2) var(--space-3); }
  header.topbar .brand { padding-right: 0; border-right: 0; }
  header.topbar .brand-wordmark { display: none; }
  header.topbar .spacer { display: none; }
  header.topbar nav {
    position: fixed; top: 0; left: 0; bottom: 0; width: 280px; max-width: 80vw;
    background: var(--surface-1); border-right: 1px solid var(--border-strong); box-shadow: var(--shadow-lg);
    flex-direction: column; flex-wrap: nowrap; align-items: stretch;
    padding: var(--space-5) var(--space-3) var(--space-3); gap: var(--space-1);
    transform: translateX(-100%); transition: transform .2s ease-out; z-index: 300; overflow-y: auto;
  }
  body.nav-open header.topbar { z-index: 300; } /* lift the drawer above the backdrop */
  body.nav-open header.topbar nav { transform: translateX(0); }
  header.topbar nav a { padding: var(--space-3) var(--space-4); font-size: var(--text-md); }
  .search { flex: 1; min-width: 0; width: auto; }
  .search input { padding-left: var(--space-2); padding-right: var(--space-2); }
  .user-menu-trigger { padding: var(--space-1); border: 0; }
  .user-menu-trigger .tag, .user-menu-trigger .user-menu-chev { display: none; }
  .poc-banner { padding: var(--space-1) var(--space-3); }

  main { padding: var(--space-4) var(--space-3); }
  h1 { font-size: var(--text-xl); }
  .page-head { flex-direction: column; align-items: stretch; gap: var(--space-3); margin-bottom: var(--space-4); }
  .page-head .toolbar { flex-wrap: nowrap; }
  .page-head .toolbar input[type=date] { flex: 1; min-width: 0; }
  .page-head > .btn, .page-head > a.btn { align-self: flex-start; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: var(--space-2); }
  .stat .n { font-size: var(--text-xl); }
  .two-col { grid-template-columns: 1fr; }
  .toolbar input[type=search] { min-width: 0 !important; flex: 1; }

  /* Tables → stacked cards. Cells carry data-label for their caption. */
  .table-wrap { background: transparent; border: 0; overflow: visible; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards thead { display: none; }
  table.cards tr {
    background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: var(--space-3); margin-bottom: var(--space-2);
  }
  table.cards td { border: 0; padding: 2px 0; white-space: normal; }
  table.cards td[data-label]:not(:empty)::before {
    content: attr(data-label) ' '; color: var(--text-muted); font-size: var(--text-xs);
  }
  table.cards td.card-title { font-size: var(--text-md); font-weight: 600; }
  table.cards td.card-title::before { content: none; }
  table.cards td:empty { display: none; }
  table.cards .seg { display: flex; margin: var(--space-2) 0; }
  table.cards .seg button { flex: 1; justify-content: center; padding: var(--space-3) 0; font-size: var(--text-md); }
  table.cards td.card-title { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-1); }
  table.cards td.inline { display: inline-block; width: auto; margin: 0 var(--space-2) var(--space-1) 0; vertical-align: middle; }
  table.cards td.meta { display: inline-block; width: auto; margin-right: var(--space-3); font-size: var(--text-xs); white-space: nowrap; }
}
@media (min-width: 901px) { .nav-backdrop { display: none !important; } .mobile-only { display: none; } }
@media (max-width: 900px) { .desktop-only { display: none !important; } }
@media (prefers-reduced-motion: reduce) { header.topbar nav { transition: none; } }
}

code { font: var(--text-xs) ui-monospace, monospace; padding: 0 4px; border-radius: var(--radius-sm); background: var(--surface-2); }
details summary { cursor: pointer; margin-bottom: var(--space-2); }
h3 { font-size: var(--text-md); margin: var(--space-4) 0 var(--space-2); }

/* --- Auth ------------------------------------------------------------- */

body.signed-out header.topbar nav, body.signed-out .search, body.signed-out .user-menu { display: none; }
.auth-card { max-width: 420px; margin: var(--space-6) auto; }
.auth-card .form { margin-top: var(--space-4); }
.auth-demo { margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--border); font-size: var(--text-xs); }

/* --- Settings --------------------------------------------------------- */

.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); margin-bottom: var(--space-5); }
.tabs a {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3); margin-bottom: -1px;
  color: var(--text-muted); text-decoration: none; font-weight: 500;
  border-bottom: 2px solid transparent;
}
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.integration-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-4); margin-bottom: var(--space-4); }
.integration .grid .card { box-shadow: none; }

.sync-card { margin-bottom: var(--space-4); box-shadow: none; }
.file-exchange > summary { cursor: pointer; font-weight: 600; margin: var(--space-3) 0; }

/* --- Care plans ------------------------------------------------------- */

.aside-stack { display: grid; gap: var(--space-4); align-content: start; }
.banner { padding: var(--space-3) var(--space-4); border-radius: var(--radius); margin: 0 0 var(--space-4); }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
h2 .box { font-size: var(--text-xs); font-weight: 500; margin-left: var(--space-2); }
.section-more { float: right; font-size: var(--text-xs); font-weight: 500; }
fieldset.service { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3); margin: 0 0 var(--space-3); }
fieldset.service legend { font-weight: 600; padding: 0 var(--space-1); }
fieldset.service.off .service-body { display: none; }
fieldset.service.off { padding-bottom: 0; border-style: dashed; }
.signatures { position: sticky; top: 76px; }
.signatures .list li { align-items: flex-start; }
.tabs .chip { margin-left: var(--space-1); }
@media (max-width: 900px) {
  .signatures { position: static; }
  .ipc-layout .signatures { order: -1; } /* who still has to sign comes first on phones */
  .tabs { overflow-x: auto; }
  .tabs a { white-space: nowrap; }
  table.cards td.meta.wrap { white-space: normal; display: block; }
}

/* --- Billing ---------------------------------------------------------- */
.edits { margin: var(--space-2) 0 0; padding-left: var(--space-4); font-size: var(--text-xs); white-space: normal; }
.edits li.error { color: var(--danger); }
.edits li.warning { color: var(--warn); }
td details summary { cursor: pointer; list-style: none; }
button[disabled] { opacity: .5; cursor: not-allowed; }

/* --- Guided tour (tour.js) — ported from Route Care's demo tour --------- */
.tour-layer { position: fixed; inset: 0; z-index: 3000; }
.tour-guard { position: absolute; inset: 0; background: transparent; }
.tour-guard--dim { background: rgb(13 18 32 / 55%); }
.tour-spotlight {
  position: absolute; border-radius: var(--radius);
  box-shadow: 0 0 0 9999px rgb(13 18 32 / 58%);
  outline: 2px solid var(--accent); outline-offset: 2px;
  pointer-events: none;
  transition: top .25s ease, left .25s ease, width .25s ease, height .25s ease;
}
.tour-spotlight[hidden] { display: none; }
.tour-spotlight--click { pointer-events: auto; cursor: pointer; }
.tour-pop {
  position: absolute; width: min(360px, calc(100vw - 28px));
  background: var(--surface-1); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: var(--space-4) var(--space-4) var(--space-3);
}
.tour-pop--center {
  top: 50% !important; left: 50% !important; transform: translate(-50%, -50%);
}
.tour-progress { display: flex; gap: 5px; margin-bottom: var(--space-3); }
.tour-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); }
.tour-dot.on { background: var(--accent); }
.tour-title { margin: 0 0 var(--space-2); font-size: var(--text-lg); }
.tour-body { margin: 0 0 var(--space-4); font-size: var(--text-sm); color: var(--text-muted); line-height: 1.5; }
.tour-footnote { margin: calc(-1 * var(--space-3)) 0 var(--space-4); font-size: var(--text-xs); color: var(--text-muted); }
.tour-footnote-link { color: var(--text-muted); text-decoration: underline; }
.tour-footnote-link:hover { color: var(--text); }
.tour-foot { display: flex; align-items: center; gap: var(--space-2); }
.tour-spacer { flex: 1; }
.tour-btn {
  font: inherit; font-size: var(--text-sm); font-weight: 600;
  padding: var(--space-2) var(--space-4); border-radius: var(--radius);
  border: 1px solid transparent; cursor: pointer;
}
.tour-next { background: var(--accent); color: var(--text-inverse); }
.tour-next:hover { background: var(--accent-hover); }
.tour-back { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.tour-back:hover { background: var(--surface-3); }
.tour-back[hidden] { display: none; }
.tour-skip { background: transparent; color: var(--text-muted); padding-left: 0; }
.tour-skip:hover { color: var(--text); }
@media (prefers-reduced-motion: reduce) { .tour-spotlight { transition: none; } }
.tour-loading { display: flex; align-items: center; gap: var(--space-3); color: var(--text-muted); font-size: var(--text-sm); padding: var(--space-2) 0; }
.tour-spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent); animation: tour-spin .7s linear infinite; }
@keyframes tour-spin { to { transform: rotate(360deg); } }


/* --- Claim viewer ----------------------------------------------------- */
.claim-dialog {
  width: min(960px, calc(100vw - 24px)); max-height: calc(100vh - 48px);
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5); box-shadow: var(--shadow-lg); color: var(--text); background: var(--surface-1);
}
.claim-dialog::backdrop { background: rgb(13 18 32 / 50%); }
.claim-head { display: flex; justify-content: space-between; gap: var(--space-4); align-items: flex-start; margin-bottom: var(--space-3); }
.claim-head h2 { margin: 0; }
.ub-grid { display: grid; gap: var(--space-2); grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: var(--space-4); }
.ub { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-2) var(--space-3); font-size: var(--text-sm); }
.ub > span { display: block; font-size: var(--text-xs); font-weight: 600; color: var(--text-muted); margin-bottom: 2px; }
.claim-dialog tr.total td { font-weight: 600; background: var(--surface-2); }
.x12 { list-style: none; margin: 0; padding: 0; counter-reset: seg; font-size: var(--text-xs); }
.x12 li { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: var(--space-3); padding: 3px 0; border-bottom: 1px solid var(--border); }
.x12 code { background: none; padding: 0; word-break: break-all; }
.x12 span { color: var(--text-muted); }
@media (max-width: 900px) {
  .claim-dialog { padding: var(--space-3); }
  .x12 li { grid-template-columns: 1fr; gap: 0; }
}

/* Billing clean-up */
.card-actions button { white-space: nowrap; }
.month-nav { flex-wrap: nowrap; }
.month-nav input { width: 17ch; }
.stedi-head { display: flex; align-items: baseline; gap: var(--space-3); margin: var(--space-4) 0 var(--space-2); padding-top: var(--space-3); border-top: 1px solid var(--border); }
.stedi-results > li { align-items: flex-start; padding: var(--space-2) 0; }
.stedi-claim { display: grid; gap: 2px; }
.stedi-claim .edits { margin-top: var(--space-1); }
@media (max-width: 900px) { .card-actions { width: 100%; } .card-actions button { flex: 1; justify-content: center; } }
.row-action { text-align: right; }
@media (max-width: 900px) { table.cards td.row-action { display: block; text-align: left; margin-top: var(--space-2); } }

.row-buttons { display: inline-flex; gap: var(--space-1); align-items: center; justify-content: flex-end; flex-wrap: wrap; }
tr.submit-result td { background: var(--surface-2); padding-top: var(--space-1); }
tr.submit-result .edits { margin: 0; }
.banner.ok { background: var(--ok-soft); color: var(--ok); }
.banner .edits { margin-top: var(--space-2); }
@media (max-width: 900px) { table.cards tr.submit-result { margin-top: calc(-1 * var(--space-2)); border-top: 0; } }

/* --- Time trials ------------------------------------------------------ */
.timing-grid { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.timing-task h2 .muted { font-size: var(--text-sm); margin-right: var(--space-1); }
.timing-modes { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); margin: var(--space-3) 0; }
.timing-mode { display: grid; gap: 2px; align-content: start; justify-items: start; padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius); }
.timing-mode.active { border-color: var(--warn); background: var(--warn-soft); }
.timing-mode .l { font-size: var(--text-xs); font-weight: 600; color: var(--text-muted); }
.timing-mode .v { font-size: var(--text-xl); font-weight: 700; }
.timing-mode .muted { font-size: var(--text-xs); margin-bottom: var(--space-1); }
.timing-delta { font-weight: 600; margin: 0 0 var(--space-2); }
.timing-delta.good { color: var(--ok); }
.timing-delta.bad { color: var(--danger); }
.timer-pill {
  position: fixed; left: 50%; bottom: var(--space-4); transform: translateX(-50%); z-index: 400;
  display: flex; align-items: center; gap: var(--space-2); max-width: calc(100vw - 24px); flex-wrap: wrap;
  padding: var(--space-2) var(--space-3); background: var(--surface-1); border: 1px solid var(--border-strong);
  border-radius: 999px; box-shadow: var(--shadow-lg); font-size: var(--text-sm);
}
.timer-pill[hidden] { display: none; }
.timer-pill .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pill-blink 1s steps(2) infinite; }
.timer-pill .elapsed { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 5ch; }
@keyframes pill-blink { 50% { opacity: .2; } }
@media (prefers-reduced-motion: reduce) { .timer-pill .dot { animation: none; } }
.elig-note { margin: var(--space-2) 0 0; font-size: var(--text-xs); }

/* --- Plans & payers --------------------------------------------------- */
.payer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 var(--space-4); }
.payer-row { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-2) 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.payer-row input { margin-top: 3px; }
.payer-row > span:nth-child(2) { flex: 1; }

/* Claim file card — a two-step workflow row */
.claim-file .claim-file-head h3 { margin: 0 0 var(--space-1); }
.claim-file .claim-file-head p { margin: 0 0 var(--space-3); }
.claim-steps { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.claim-step { display: flex; align-items: center; gap: var(--space-2); }
.claim-step button { white-space: nowrap; }
.step-n {
  display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px;
  border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: var(--text-xs); font-weight: 700;
}
.step-meta { font-size: var(--text-xs); white-space: nowrap; }
.step-arrow { color: var(--text-muted); }
.btn-link { margin-left: auto; border: 0; background: none; color: var(--accent); padding: 7px var(--space-2); white-space: nowrap; }
.btn-link:hover { background: var(--accent-soft); }
@media (max-width: 900px) {
  .claim-steps { flex-direction: column; align-items: stretch; }
  .claim-step button { flex: 1; justify-content: center; }
  .step-arrow { display: none; }
  .btn-link { margin-left: 0; align-self: flex-start; }
}

/* --- IPC Boxes 1–11 --------------------------------------------------- */
.ipc-box > summary { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); cursor: pointer; list-style: none; }
.ipc-box > summary::-webkit-details-marker { display: none; }
.ipc-box > summary h2 { margin: 0; }
.ipc-box[open] > summary { margin-bottom: var(--space-3); }
.ipc-box h3 { font-size: var(--text-sm); margin: var(--space-3) 0 var(--space-2); }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-1) var(--space-3); margin: var(--space-2) 0; }
.check-grid.one-col { grid-template-columns: 1fr; }
.check-grid label, .check-line { display: flex; gap: var(--space-2); align-items: flex-start; font-size: var(--text-sm); }
.check-line { margin: var(--space-3) 0 var(--space-1); }
.seg-radio { display: inline-flex; gap: var(--space-3); flex-wrap: wrap; padding: 6px 0; }
.seg-radio label { display: inline-flex; gap: var(--space-1); align-items: center; }
.dx-grid { display: grid; grid-template-columns: 1fr 12ch; gap: var(--space-1) var(--space-2); }
.provider-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-1) var(--space-2); }
.two-lists { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.two-lists input { width: 100%; margin-bottom: var(--space-1); }
.adl-table th, .adl-table td { text-align: center; }
.adl-table tbody th { text-align: left; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--text); background: none; position: static; font-size: var(--text-sm); }
.adl-table tr.group td { text-align: left; font-size: var(--text-xs); font-weight: 700; color: var(--text-muted); background: var(--surface-2); }
.other-health .oh-row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; padding: var(--space-1) 0; border-bottom: 1px solid var(--border); }
.other-health .oh-row > label:first-child { min-width: 260px; display: flex; gap: var(--space-2); }
.other-health .oh-row input:not([type]) , .other-health .oh-row input[name$=".explain"] { flex: 1; min-width: 180px; }
.edits li.info { color: var(--info); }
.edits li.info .btn-sm { margin-left: var(--space-2); }
@media (max-width: 900px) {
  .two-lists, .provider-grid { grid-template-columns: 1fr; }
  .dx-grid { grid-template-columns: 1fr 10ch; }
  .adl-table th, .adl-table td { padding: var(--space-1); font-size: var(--text-xs); }
}

.ipc-aside .mdt .list li { padding: var(--space-1) 0; }
a.tag { text-decoration: none; }
