/* NovaSalvia - shared styles (front page, provider portal, and client portal). No inline styles: CSP forbids them. */
:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef1ec;
  --text: #1d2621;
  --muted: #5d6a62;
  --border: #d9dfd8;
  --brand: #2f6b5a;
  --brand-ink: #ffffff;
  --brand-soft: #e2efe9;
  --accent: #b5673a;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --warn: #8a5a00;
  --warn-soft: #fff4dc;
  --ok: #1f6f43;
  --ok-soft: #e3f3e8;
  --info-soft: #e8eef8;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 4px 16px rgba(20, 30, 25, .06);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121714;
    --surface: #1a211d;
    --surface-2: #222b26;
    --text: #e5ebe7;
    --muted: #9aa8a0;
    --border: #2f3a34;
    --brand: #6fb49d;
    --brand-ink: #0d1612;
    --brand-soft: #1f3a31;
    --accent: #e0a176;
    --danger: #f2877e;
    --danger-soft: #3a1f1d;
    --warn: #f0c060;
    --warn-soft: #3a3020;
    --ok: #7cd09e;
    --ok-soft: #1c3326;
    --info-soft: #1f2838;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: var(--mono); font-size: .85em; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; }

/* ---- layout ---- */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 1rem .75rem; display: flex; flex-direction: column; gap: .25rem; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.1rem; padding: .25rem .5rem 1rem; color: var(--brand); text-decoration: none; }
/* The NovaSalvia logo's mark (leaves and star) on its own light background. */
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: #f8f8f6; object-fit: cover; flex: none; }
.nav a { display: flex; align-items: center; justify-content: space-between; padding: .5rem .75rem; border-radius: 8px; color: var(--text); text-decoration: none; }
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
/* Alerts not yet acknowledged: red in the menu (and on the phone Menu button), with a count.
   Urgent ones also fade slowly in and out, once every 2.4 s (a fade, far under three flashes
   a second). The count and its hidden words carry the meaning, not the color alone. */
.nav-count { min-width: 1.4rem; padding: 0 .4rem; border-radius: 999px; background: var(--danger); color: var(--surface); font-size: .78rem; font-weight: 700; line-height: 1.4rem; text-align: center; }
.mobile-bar .nav-count { margin-left: .4rem; display: inline-block; }
.nav a.has-alerts { background: var(--danger-soft); color: var(--text); font-weight: 600; box-shadow: inset 3px 0 0 var(--danger); }
.mobile-bar button.has-alerts { background: var(--danger-soft); color: var(--text); border-color: var(--danger); }
.nav a.has-urgent, .mobile-bar button.has-urgent { animation: alertpulse 2.4s ease-in-out infinite; }
@keyframes alertpulse { 50% { background-color: color-mix(in srgb, var(--danger) 30%, var(--danger-soft)); } }
@media (prefers-reduced-motion: reduce) {
  .nav a.has-urgent, .mobile-bar button.has-urgent { animation: none; background-color: color-mix(in srgb, var(--danger) 30%, var(--danger-soft)); }
}
.sidebar .spacer { flex: 1; }
.sidebar .who { font-size: .85rem; color: var(--muted); padding: .5rem .75rem; border-top: 1px solid var(--border); }
.main { padding: 1.5rem 2rem 3rem; max-width: 1200px; width: 100%; }
.topbar { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.topbar h1 { margin: 0; flex: 1; }

.mobile-bar { display: none; }
@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 30% 0 0; z-index: 30; transform: translateX(-105%); transition: transform .2s; height: 100%; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .mobile-bar { display: flex; align-items: center; gap: .75rem; padding: .75rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
  .main { padding: 1rem 16px 3rem; }
}

/* ---- components ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; gap: .75rem; margin-bottom: .75rem; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; flex: 1; }
.grid { display: grid; gap: 1rem; margin-bottom: 1rem; }
.grid > .card { margin-bottom: 0; }
fieldset.card { min-width: 0; }
/* The question sits inside its box, not on the border (float takes the legend out of the border). */
fieldset.card > legend { float: left; width: 100%; padding: 0; margin: 0 0 .75rem; }
fieldset.card > legend + * { clear: both; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: .5rem; }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); text-decoration: none; color: inherit; display: block; }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }

button, .btn { font: inherit; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: .45rem .9rem; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: .35rem; min-height: 36px; }
button:hover, .btn:hover { background: var(--surface-2); }
button.primary, .btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
button.primary:hover { filter: brightness(1.07); }
button.danger { color: var(--danger); border-color: var(--danger); }
button.link { border: none; background: none; color: var(--brand); padding: 0; min-height: 0; text-decoration: underline; }
button:disabled { opacity: .55; cursor: not-allowed; }
button.small, .btn.small { padding: .2rem .6rem; min-height: 28px; font-size: .85rem; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .table-wrap:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* The hidden attribute always hides, even on elements given a display above or below. */
[hidden] { display: none !important; }
label.field, div.field { display: flex; flex-direction: column; gap: .25rem; font-size: .88rem; color: var(--muted); }
.field > span.lbl { font-weight: 600; color: var(--text); }
div.field > label.check { color: var(--text); font-size: .95rem; }
label.check { display: flex; gap: .5rem; align-items: flex-start; cursor: pointer; }
label.check input { margin-top: .3rem; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .45rem .6rem; width: 100%; min-height: 36px; }
textarea { min-height: 90px; resize: vertical; line-height: 1.45; }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem 1rem; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }

table.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; padding: .5rem .5rem; border-bottom: 1px solid var(--border); }
.table td { padding: .55rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }
.badge.info { background: var(--info-soft); color: var(--text); }

.notice { border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: 1rem; border: 1px solid var(--border); background: var(--surface-2); }
.notice.warn { background: var(--warn-soft); border-color: transparent; }
.notice.danger { background: var(--danger-soft); border-color: transparent; color: var(--text); }
.notice.ok { background: var(--ok-soft); border-color: transparent; }
.notice.info { background: var(--info-soft); border-color: transparent; }
.notice strong { display: block; margin-bottom: .15rem; }

.crisis { background: var(--danger-soft); border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: 1rem; font-size: .92rem; }
.crisis strong { display: block; }
.crisis ul { margin: .35rem 0 0; padding-left: 1.2rem; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: .55rem .85rem; color: var(--muted); white-space: nowrap; }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

.list-item { padding: .65rem 0; border-bottom: 1px solid var(--border); display: flex; gap: .75rem; align-items: flex-start; }
.list-item:last-child { border-bottom: none; }

.evidence { border-left: 3px solid var(--brand); background: var(--surface-2); padding: .5rem .75rem; margin: .5rem 0; font-size: .9rem; border-radius: 0 6px 6px 0; }
.dir-up { color: var(--ok); }
.dir-down { color: var(--danger); }

.thread { display: flex; flex-direction: column; gap: .5rem; max-height: 480px; overflow-y: auto; padding: .5rem 0; }
.bubble { max-width: 75%; padding: .5rem .8rem; border-radius: 12px; background: var(--surface-2); white-space: pre-wrap; }
.bubble.mine { align-self: flex-end; background: var(--brand-soft); }
.bubble.system { align-self: center; background: var(--info-soft); font-size: .88rem; max-width: 90%; }
.bubble .meta { font-size: .75rem; color: var(--muted); margin-top: .2rem; }

.note-field { margin-bottom: 1rem; }
.note-field .hint { font-size: .8rem; color: var(--muted); }
.note-readonly { white-space: pre-wrap; background: var(--surface-2); border-radius: 8px; padding: .6rem .8rem; }
.placeholder-mark { background: var(--warn-soft); color: var(--warn); border-radius: 4px; padding: 0 .25rem; }

.chart svg { width: 100%; height: auto; display: block; }
.chart .axis { stroke: var(--border); }
.chart .gridline { stroke: var(--border); stroke-dasharray: 2 4; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .line-phq { stroke: var(--brand); }
.chart .line-gad { stroke: var(--accent); }
.chart .line-mood { stroke: var(--muted); }
.chart .dot-phq { fill: var(--brand); }
.chart .dot-gad { fill: var(--accent); }
.chart .dot-mood { fill: var(--muted); }
.chart .dot-risk { fill: var(--danger); }
.legend { display: flex; gap: 1rem; font-size: .82rem; color: var(--muted); flex-wrap: wrap; }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .35rem; vertical-align: middle; }
.sw-phq { background: var(--brand); }
.sw-gad { background: var(--accent); }
.sw-mood { background: var(--muted); }

/* ---- modal and toast ---- */
.backdrop { position: fixed; inset: 0; background: rgba(10, 15, 12, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); width: min(560px, 100%); max-height: 90vh; overflow-y: auto; padding: 1.25rem; }
.modal.wide { width: min(820px, 100%); }
.modal.xwide { width: min(1100px, 100%); }
.modal h2 { margin-top: 0; }
.modal .actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; }
.toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: .5rem; z-index: 60; max-width: calc(100% - 32px); }
.toast { background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 8px; box-shadow: var(--shadow); font-size: .9rem; }
.toast.error { background: var(--danger); color: #fff; }

/* ---- login ---- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(400px, 100%); }
.login-card .brand { justify-content: center; font-size: 1.4rem; padding-bottom: .25rem; }
.tagline { text-align: center; color: var(--muted); margin-bottom: 1.25rem; }

/* ---- portal ---- */
.portal-shell { max-width: 760px; margin: 0 auto; padding: 0 16px 3rem; }
.portal-header { display: flex; align-items: center; gap: 1rem; padding: 1rem 0; flex-wrap: wrap; }
.portal-header nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; justify-content: flex-end; }
.portal-header nav a { padding: .4rem .7rem; border-radius: 8px; text-decoration: none; color: var(--text); }
.portal-header nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.scale { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .35rem; margin: .35rem 0 1rem; }
.scale label { border: 1px solid var(--border); border-radius: 8px; padding: .45rem .5rem; text-align: center; font-size: .82rem; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: .2rem; }
.scale input:checked + span { font-weight: 700; color: var(--brand); }
.scale-10 { grid-template-columns: repeat(10, minmax(0, 1fr)); }
@media (max-width: 600px) { .scale { grid-template-columns: repeat(2, minmax(0, 1fr)); } .scale-10 { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.question { margin-bottom: .25rem; font-weight: 500; }

@media print {
  .sidebar, .mobile-bar, .topbar button, .no-print, .toasts { display: none !important; }
  .shell { display: block; }
  .card { box-shadow: none; border: none; }
  body { background: #fff; color: #000; }
}

/* ---- security ---- */
.qr { background: #fff; padding: 12px; border-radius: 8px; width: fit-content; margin: .5rem 0; }
.recovery-codes { columns: 2; list-style: none; padding: 0; margin: .5rem 0; font-size: 1rem; }
.recovery-codes li { padding: .15rem 0; }
.code-input { font-size: 1.4rem; letter-spacing: .3em; text-align: center; font-family: var(--mono); }
.login-wrap > .stack { width: min(440px, 100%); }
.login-wrap > .stack > .login-card { width: 100%; }
.row input[type=time] { width: auto; }
.divider { display: flex; align-items: center; gap: .75rem; text-align: center; }
.divider::before, .divider::after { content: ''; flex: 1; border-top: 1px solid var(--border); }
.center { text-align: center; }
.choice { display: grid; gap: .75rem; }
.choice button { justify-content: flex-start; text-align: left; padding: .75rem 1rem; }
.choice button strong { display: block; }

/* Insurance: key-value details, card photos, policyholder box. */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
.kv dt { color: var(--muted); font-size: .9rem; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.card-photo { display: block; max-width: min(260px, 100%); max-height: 170px; border: 1px solid var(--border); border-radius: 8px; margin-top: .35rem; }
.sub-box { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem; }
.ins-item + .ins-item { border-top: 1px solid var(--border); padding-top: 1rem; margin-top: 1rem; }

/* CMS-1500: data laid out on the form's grid (10 characters per inch, 6 lines per inch).
   Courier at 12pt is exactly 10 characters per inch. On screen: a faint one-inch grid. */
.cms1500-wrap { overflow-x: auto; margin-bottom: 1rem; }
.cms1500 { position: relative; width: 8.5in; height: 11in; background-color: #fff; color: #000;
  background-image: linear-gradient(to right, rgba(200, 40, 40, .08) 1px, transparent 1px), linear-gradient(to bottom, rgba(200, 40, 40, .08) 1px, transparent 1px);
  background-size: 1in 1in; border: 1px solid var(--border); box-shadow: var(--shadow);
  font-family: 'Courier New', Courier, monospace; font-size: 12pt; line-height: 1; }
.cms1500 .f { position: absolute; white-space: pre; }
.cms1500.show-boxes .f { outline: 1px dotted rgba(200, 40, 40, .6); }
.cms1500.show-boxes .f::after { content: attr(data-box); position: absolute; top: -.55em; left: 0; font: 600 7pt var(--font); color: #b42318; background: #fff; }
.claim-align { align-items: center; gap: 1rem; margin-bottom: .75rem; }
.claim-align input[type=number] { width: 5.5rem; }
ol.tight { margin: .35rem 0 0; padding-left: 1.2rem; }
@page cms1500 { size: letter; margin: 0; }
@media print {
  body.claim-print .main, body.claim-print .view { padding: 0 !important; margin: 0 !important; }
  /* Everything else is hidden, so the form is the first thing printed and its page has no margins. */
  body.claim-print .cms1500-wrap { page: cms1500; overflow: visible; margin: 0; }
  body.claim-print .cms1500 { border: none; box-shadow: none; background: none; }
}

/* Good Faith Estimate document and the create form. */
.gfe-doc h2 { margin-top: 0; }
.gfe-doc tr.total td { border-top: 2px solid var(--border); }
.gfe-rights li { margin-bottom: .3rem; }
.gfe-row select { flex: 1 1 220px; width: auto; }
.gfe-row input { width: 6rem; }
@media print { .portal-header { display: none !important; } }

/* Letters (server/domain/letters.ts). */
.letter-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 900px) { .letter-layout { grid-template-columns: 1fr; } }
.letter-editor { font-family: inherit; line-height: 1.5; }
.letter-field { border-top: 1px solid var(--border); padding-top: .4rem; }
.letter-field button.link { text-align: left; white-space: pre-wrap; padding: 0; }
.letter-field.missing button.link { color: var(--warn, #8a5a00); }
.letter-doc { max-width: 42rem; margin: 0 auto; line-height: 1.55; }
.letter-head { border-bottom: 1px solid var(--border); padding-bottom: .5rem; margin-bottom: 1rem; }
.letter-body { white-space: pre-wrap; }
.letter-sign { margin-top: 1.5rem; }
@media print { .letter-doc { max-width: none; color: #000; } }
/* The release of information form prints by itself (chart Letters tab). */
.release-print { display: none; }
@media print {
  body.release-printing > *:not(.release-print) { display: none !important; }
  body.release-printing .release-print { display: block; color: #000; font-size: 11pt; line-height: 1.45; }
  .rel-table th, .rel-table td { border-color: #000 !important; }
}
.rel-table { width: 100%; border-collapse: collapse; margin: .75rem 0; }
.rel-table th, .rel-table td { border: 1px solid var(--border); padding: .35rem .5rem; text-align: left; vertical-align: top; }
.rel-table th { width: 28%; }
.rel-table ul { margin: 0; padding-left: 1.1rem; }
.rel-signs { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem 1rem; margin-top: 2rem; }
.rel-sign { display: flex; flex-direction: column; }
.rel-line { border-bottom: 1px solid #000; height: 1.6rem; }

/* A copy of the record (right of access). */
.rec-doc h2 { margin-top: 0; }
.rec-section { margin-top: 1.25rem; }
.rec-item { padding: .6rem 0; border-bottom: 1px solid var(--border); }
.pre { white-space: pre-wrap; }

/* Keyboard: "Skip to main content" appears when tabbed to; main takes focus without a ring. */
.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 100; padding: .5rem .9rem; background: var(--surface); border: 2px solid var(--brand); border-radius: 8px; }
.skip-link:focus { left: 16px; }
main:focus { outline: none; }

/* Front page: one door per portal. */
.doors { display: grid; gap: .75rem; }
.door { display: grid; gap: .2rem; padding: .85rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); text-decoration: none; }
.door:hover { border-color: var(--brand); background: var(--brand-soft); }
.door strong { color: var(--brand); font-size: 1.05rem; }

.health-strip { display: flex; flex-wrap: wrap; gap: .35rem 1.5rem; padding: .55rem 1rem; }
.rows-editor-row input:not([type=checkbox]), .rows-editor-row select { flex: 1 1 140px; width: auto; }
details.card > summary { cursor: pointer; }
.main { min-width: 0; }
.health-strip strong { display: inline; margin: 0; }
.tabs { flex-wrap: wrap; overflow-x: visible; }
.guardian-card { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem; }
.minor-section h3 { margin-top: .5rem; }

/* ---- on/off switches ---- */
.switch-row { display: flex; gap: .85rem; align-items: flex-start; padding: .7rem 0; border-bottom: 1px solid var(--border); }
.switch-row:last-of-type { border-bottom: none; }
.switch-row.disabled strong { color: var(--muted); }
.switch-reason { color: var(--warn); margin-top: .2rem; }
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex: none; margin-top: .1rem; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch .slider { position: absolute; inset: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; transition: background .15s; }
.switch .slider::before { content: ''; position: absolute; width: 20px; height: 20px; left: 2px; top: 2px; background: var(--muted); border-radius: 50%; transition: transform .15s, background .15s; }
.switch input:checked + .slider { background: var(--brand); border-color: var(--brand); }
.switch input:checked + .slider::before { transform: translateX(20px); background: var(--brand-ink); }
.switch input:disabled { cursor: not-allowed; }
.switch input:disabled + .slider { opacity: .45; }
.switch input:focus-visible + .slider { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---- recording ---- */
.rec-controls { margin-top: 1rem; }
.big-rec { font-size: 1.05rem; padding: .7rem 1.3rem; }
.rec-status { font-weight: 600; }
.rec-dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: var(--danger); animation: recpulse 1.2s infinite; }
@keyframes recpulse { 50% { opacity: .25; } }
.rec-preview, .rec-playback { width: min(480px, 100%); border-radius: var(--radius); margin-top: .75rem; background: #000; }
.rec-level { display: inline-block; width: 70px; height: 6px; border-radius: 3px; background: var(--surface-2); border: 1px solid var(--border); vertical-align: middle; overflow: hidden; }
.rec-level-bar { display: block; height: 100%; width: 0; background: var(--ok); transition: width .1s linear; }
.recording-item { align-items: flex-start; }

/* ---- scrubbable player ---- */
.player { margin-top: .5rem; }
.scrubber { position: relative; height: 56px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); cursor: pointer; touch-action: none; }
.scrubber:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.scrub-canvas { display: block; width: 100%; height: 100%; }
.player-controls { margin-top: .4rem; }
.player-clock { min-width: 7.5rem; }
.player-speed { width: auto; }

/* ---- transcript ---- */
.transcript-section { margin-top: .75rem; border-top: 1px solid var(--border); padding-top: .75rem; }
.transcript-section h3 { margin: 0; }
.transcript { margin-top: .5rem; }
.transcript-tools input[type=search] { flex: 1 1 12rem; width: auto; }
.transcript-lines { max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); margin-top: .4rem; padding: .25rem; }
.tline { display: flex; gap: .6rem; width: 100%; text-align: left; background: none; border: none; border-radius: 6px; padding: .35rem .5rem; min-height: 0; color: var(--text); font: inherit; cursor: pointer; }
.tline:hover { background: var(--surface-2); }
.tline.active { background: var(--brand-soft); }
.tline-time { color: var(--muted); flex: none; min-width: 3.2rem; }
.tline-speaker { flex: none; font-weight: 600; color: var(--brand); }
.transcript-plain { white-space: pre-wrap; max-height: 320px; overflow-y: auto; }
.spinner { display: inline-block; width: .9em; height: .9em; border: 2px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -.1em; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- suggested chart updates ---- */
.suggestions h3 { margin: 1rem 0 .25rem; }
.suggestion { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem; margin-top: .6rem; display: flex; flex-direction: column; gap: .5rem; }
.suggestion-risk { border-color: var(--danger); background: var(--danger-soft); }
.suggestion blockquote.evidence { margin: 0; padding: .4rem .7rem; border-left: 3px solid var(--border); color: var(--muted); font-style: italic; }
.suggestion .row input { flex: 1 1 9rem; width: auto; }
@media (prefers-reduced-motion: reduce) { .spinner, .rec-dot { animation: none; } .rec-level-bar { transition: none; } }

/* ---- claim check ---- */
.findings { list-style: none; padding: 0; margin: .5rem 0; display: flex; flex-direction: column; gap: .45rem; }
.finding { display: flex; gap: .6rem; align-items: flex-start; }
.claim-client { border-top: 1px solid var(--border); padding: .5rem 0; }
.claim-client summary { cursor: pointer; }
@media print { .no-print { display: none !important; } }
.claim-range input[type=date] { width: auto; }

/* Authorizations: usage bar, session banner */
.row.wrap { flex-wrap: wrap; }
.text-danger { color: var(--danger); }
.auth-usage { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.auth-bar { flex: 0 0 160px; height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; }
.auth-fill { display: block; height: 100%; background: var(--ok); }
.auth-fill.warn { background: var(--warn); }
.auth-fill.danger { background: var(--danger); }
.auth-banner .row { align-items: center; gap: 8px; flex-wrap: wrap; }
.auth-banner { display: grid; gap: 6px; }
.auth-portal + .auth-portal { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 10px; }

/* Pre-session brief */
.brief h3 { font-size: 0.95rem; margin: 12px 0 4px; }
.brief ul { margin: 4px 0 8px; padding-left: 20px; }
.brief li { margin: 3px 0; }
.brief-src { margin-left: 4px; font-size: 0.72rem; text-decoration: none; }
.brief-risk ul { margin: 6px 0 0; }
.brief-risk q { font-weight: 600; }

/* Signing a form: the full text scrolls in its own box; yes-or-no choices. */
.doc-full { max-height: 45vh; overflow-y: auto; padding: .25rem .75rem; border: 1px solid var(--border); border-radius: 8px; }
.doc-full:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.doc-details > summary { cursor: pointer; font-weight: 600; margin-bottom: .5rem; }
fieldset.choice { border: 1px solid var(--border); border-radius: 8px; padding: .5rem .75rem; }
fieldset.choice legend { font-weight: 600; padding: 0 .25rem; }

/* Pronouns beside a client's name in the chart header. */
.pronouns { font-size: .9rem; font-weight: 500; color: var(--muted); margin-left: .6rem; }

/* Check-in: progress, and "What makes you feel this way?" under each answered question. */
.checkin-progress { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: .5rem 0; display: grid; gap: .3rem; }
.checkin-progress .bar { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.checkin-progress .bar > span { display: block; height: 100%; width: 0; background: var(--brand); transition: width .2s ease; }
.why { display: grid; gap: .35rem; margin-top: .75rem; }
.why .lbl { font-weight: 600; font-size: .95rem; }

/* Provider photo: Home welcome card and beside replies in Messages. */
.avatar { border-radius: 50%; object-fit: cover; flex: none; }
.avatar.lg { width: 72px; height: 72px; }
.avatar.sm { width: 32px; height: 32px; font-size: .8rem; }
.avatar.xl { width: 96px; height: 96px; font-size: 1.4rem; }
.avatar.initials { display: inline-flex; align-items: center; justify-content: center; background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.welcome { display: flex; gap: 1rem; align-items: flex-start; }
.welcome-note { white-space: pre-wrap; margin: 0; }
.msg-row { display: flex; gap: .5rem; align-items: flex-end; max-width: 85%; }
.msg-row .bubble { max-width: none; }

/* Documents: the agreements-and-rights card; unanswered intake questions. */
.rights-row { align-items: flex-end; }
.rights-row .field { flex: 1 1 200px; margin: 0; }
[aria-invalid="true"] { border-color: var(--danger) !important; }
fieldset[aria-invalid="true"] { border: 1px solid var(--danger); }

/* Fee schedule: add a service. */
.add-service { align-items: flex-end; }
.add-service .field { flex: 1 1 140px; margin: 0; }
.removed-services > summary { cursor: pointer; font-weight: 600; margin: .5rem 0; }
/* Text for screen readers only. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Note editor: the codes at a glance, at the top. */
.codes-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: .75rem 1rem; }
.codes-summary { display: flex; flex-wrap: wrap; gap: .4rem 1.5rem; }

/* Documents: grouped forms (privacy and AI; recording and telehealth). */
.doc-group .doc-part { border-top: 1px solid var(--border); padding-top: .9rem; margin-top: .9rem; }
.doc-group .doc-part:first-of-type { border-top: 0; padding-top: 0; margin-top: .25rem; }
.doc-group h3 { font-size: 1.02rem; margin: 0; }

/* Session recording: the device check, the session card, the live transcript, and the
   "Recording" bar that stays on screen on other pages (bottom right; toasts stack above it). */
.block { display: block; }
.session-check .rec-level.check-level { width: 160px; height: 10px; border-radius: 5px; }
.session-check .check-preview { width: min(360px, 100%); }
.record-choices { border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .85rem .75rem; margin: 0; display: grid; gap: .6rem; }
.record-choices legend { font-weight: 600; padding: 0 .3rem; }
.record-choice.disabled strong { color: var(--muted); }
.gate-list { list-style: none; padding: 0; margin: 0 0 .75rem; display: grid; gap: .35rem; }
.live-transcript { max-height: 300px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .75rem; background: var(--surface-2); }
.live-line { margin: 0 0 .45rem; line-height: 1.45; }
.live-line.partial { color: var(--muted); font-style: italic; }
.note-transcripts { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: .75rem; }
.rec-pill { position: fixed; right: 16px; bottom: 16px; z-index: 40; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; max-width: calc(100% - 32px); padding: .55rem .85rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--danger); box-shadow: var(--shadow); font-size: .9rem; }
.rec-pill-text { font-weight: 600; }
body:has(.rec-pill) .toasts { bottom: 84px; }
@media (max-width: 760px) { .rec-pill { left: 16px; right: 16px; border-radius: var(--radius); } }
@media print { .rec-pill { display: none !important; } }

/* Schedule: Outlook-style calendar (day, week, month). Provider colors pc-0..5; status st-*. */
.cal-card { padding-bottom: .75rem; }
.cal-toolbar { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.cal-toolbar .row { gap: .4rem; flex-wrap: wrap; align-items: center; }
.cal-toolbar select { width: auto; }
.cal-title { margin: 0 0 0 .4rem; font-size: 1.1rem; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: none; border-radius: 0; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: none; }
.seg button.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.cal-grid { --days: 1; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cal-grid.days-7 { --days: 7; }
.cal-scroll { max-height: 70vh; overflow: auto; position: relative; }
.cal-head, .cal-body { display: grid; grid-template-columns: 58px repeat(var(--days), minmax(0, 1fr)); }
.cal-grid.days-7 .cal-head, .cal-grid.days-7 .cal-body { min-width: 680px; }
.cal-head { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--border); }
button.cal-day-head { border: none; border-left: 1px solid var(--border); border-radius: 0; background: var(--surface); justify-content: center; min-height: 42px; padding: .3rem; }
button.cal-day-head.today { color: var(--brand); background: var(--brand-soft); }
.cal-gutter { position: relative; }
.cal-hour { position: absolute; right: .4rem; transform: translateY(-.55em); white-space: nowrap; }
.cal-hour:first-child { transform: none; }
.cal-col { position: relative; border-left: 1px solid var(--border); cursor: cell;
  background-image: linear-gradient(to bottom, var(--border) 1px, transparent 1px), linear-gradient(to bottom, color-mix(in srgb, var(--border) 45%, transparent) 1px, transparent 1px);
  background-size: 100% var(--hour), 100% calc(var(--hour) / 2); }
.cal-col.today { background-color: color-mix(in srgb, var(--brand-soft) 35%, transparent); }
.cal-off { position: absolute; left: 0; right: 0; background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.pc-0 { --ev: #2f6b5a; } .pc-1 { --ev: #3a5fa8; } .pc-2 { --ev: #8a4fa3; } .pc-3 { --ev: #b5673a; } .pc-4 { --ev: #1f7a8c; } .pc-5 { --ev: #a23b5a; }
@media (prefers-color-scheme: dark) {
  .pc-0 { --ev: #6fb49d; } .pc-1 { --ev: #8fb0ee; } .pc-2 { --ev: #c79be0; } .pc-3 { --ev: #e0a176; } .pc-4 { --ev: #6cc3d3; } .pc-5 { --ev: #e58aa6; }
}
button.cal-event { position: absolute; z-index: 2; display: block; text-align: left; min-height: 0; padding: .15rem .35rem; border: 1px solid color-mix(in srgb, var(--ev) 35%, transparent); border-left: 4px solid var(--ev); border-radius: 6px; background: color-mix(in srgb, var(--ev) 16%, var(--surface)); color: var(--text); font-size: .8rem; line-height: 1.25; overflow: hidden; }
button.cal-event:hover { background: color-mix(in srgb, var(--ev) 26%, var(--surface)); }
button.cal-event.movable { cursor: grab; }
button.cal-event.dragging { opacity: .45; cursor: grabbing; }
/* A coverage check that needs a person: a warning corner, plus the reason in the label. */
button.cal-event.cov-warn { box-shadow: inset -6px 0 0 var(--warn); }
.coverage { border-top: 1px solid var(--border, var(--surface-2)); padding-top: .6rem; }
/* A claim's electronic timeline: what came back, oldest first. */
.timeline { margin: .4rem 0 0; padding-left: 1.2rem; }
.timeline li { margin: .2rem 0; }
.cal-ev-time { font-weight: 700; }
.cal-ev-meta { display: block; color: var(--muted); font-size: .75rem; }
.cal-grid.days-7 .cal-ev-meta { display: none; } /* week columns are narrow: time and name only */
button.cal-event.st-attended { border-left-style: double; }
button.cal-event.st-no_show, button.cal-event.st-late_cancel { border-style: dashed; border-left-style: solid; background: var(--surface); }
button.cal-event.st-cancelled { opacity: .6; background: var(--surface); }
button.cal-event.st-cancelled .cal-ev-name { text-decoration: line-through; }
.cal-ghost { position: absolute; z-index: 4; padding: .15rem .35rem; border: 2px dashed var(--ev); border-radius: 6px; background: color-mix(in srgb, var(--ev) 22%, var(--surface)); font-size: .8rem; font-weight: 700; pointer-events: none; }
.cal-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 3; pointer-events: none; }
.cal-now::before { content: ''; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.cal-month-wrap { overflow-x: auto; }
.cal-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); min-width: 560px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cal-month-head { padding: .35rem .5rem; border-bottom: 1px solid var(--border); background: var(--surface); }
.cal-month-cell { min-height: 104px; padding: .25rem; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: .2rem; cursor: cell; }
.cal-month-cell:nth-child(7n) { border-right: none; }
.cal-month-cell.other { background: var(--surface-2); }
.cal-month-cell.other .cal-month-day { color: var(--muted); }
.cal-month-cell.today .cal-month-day { background: var(--brand); color: var(--brand-ink); }
.cal-month-cell.drop-target { outline: 2px dashed var(--brand); outline-offset: -3px; }
button.cal-month-day { align-self: flex-start; border: none; background: none; min-height: 0; padding: .05rem .4rem; border-radius: 999px; font-weight: 600; font-size: .85rem; }
.cal-month-cell button.cal-event { position: static; width: 100%; white-space: nowrap; text-overflow: ellipsis; }
@media (prefers-reduced-motion: reduce) { button.cal-event { transition: none; } }

/* Progress: goals with status on the provider's Progress tab and the client's My progress. */
.goal-item { border-bottom: 1px solid var(--border); padding-bottom: .75rem; }
.goal-item:last-child { border-bottom: none; }
.goal-head { display: flex; gap: .75rem; align-items: flex-start; flex-wrap: wrap; }
.goal-status { gap: .4rem; flex-wrap: wrap; align-items: center; }
.goal-status select { width: auto; }
.goal-status .inline-field { display: inline-flex; align-items: center; gap: .3rem; }
.goal-status input[type=date] { width: auto; }
ul.objectives { list-style: none; padding: 0; margin: .5rem 0 0 1rem; display: grid; gap: .4rem; }
ul.objectives li { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.goal-card h3 { margin: 0; }
ul.objective-list { list-style: none; padding: 0; margin: .5rem 0; display: grid; gap: .35rem; }
ul.objective-list .tick { display: inline-block; width: 1.2em; color: var(--muted); }
ul.objective-list li.done .tick { color: var(--ok); font-weight: 700; }

/* Messages: files on a message, and the composer's attached files. */
.attachments-list { gap: .25rem; margin: .35rem 0 .15rem; }
button.attachment { text-align: left; word-break: break-word; }
.bubble.mine button.attachment { color: inherit; }
.attachments { gap: .4rem; }
.chip { display: inline-flex; align-items: center; gap: .5rem; padding: .2rem .6rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); }
.conversation .thread { max-height: 420px; overflow-y: auto; }
.icon-clip { vertical-align: -2px; flex: none; }

/* Client two-step sign-in: the ways to confirm it's you. */
.two-step-choices button.choice { display: flex; flex-direction: column; align-items: flex-start; gap: .2rem; text-align: left; padding: .75rem 1rem; width: 100%; }
.two-step-choices button.choice:hover { border-color: var(--brand); }

/* Video visits: a full-screen call (lobby first). Their video fills the stage; yours is small. */
body.in-video-call { overflow: hidden; }
.video-call { position: fixed; inset: 0; z-index: 45; display: flex; flex-direction: column; background: #101512; color: #eef2ef; }
.video-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem 1rem; padding: .75rem 1rem; }
.video-status { white-space: nowrap; }
.video-status { font-size: .9rem; color: #b9c6bf; }
.video-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
/* Pinned inside the stage: the incoming video must never push the controls off the screen. */
.video-remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.video-local { position: absolute; right: 16px; bottom: 16px; width: min(240px, 34vw); aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; border: 2px solid rgba(255,255,255,.4); background: #222; transform: scaleX(-1); }
.video-waiting { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 1rem; padding: 1.5rem; text-align: center; max-width: 520px; margin: 0 auto; }
.video-waiting .crisis { color: var(--text); text-align: left; }
.video-controls { padding: .75rem 1rem 1rem; display: grid; gap: .75rem; background: #161d19; }
.video-controls .field .lbl { color: #cfd9d3; }
.video-devices { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .5rem; }
.video-buttons { justify-content: center; }
.video-controls button[aria-pressed="true"] { background: #3a1f1d; border-color: var(--danger); color: #fff; }
@media (max-width: 760px) { .video-local { width: 34vw; right: 10px; bottom: 10px; } }
/* Recording notice in the call's title bar (the client sees it whenever the therapist records). */
.video-rec { margin-left: auto; padding: .2rem .6rem; border-radius: 999px; background: #7a1f1a; color: #fff; font-size: .85rem; font-weight: 600; }
.video-rec::before { content: ""; display: inline-block; width: .55rem; height: .55rem; margin-right: .4rem; border-radius: 50%; background: #ff6b5e; vertical-align: .05rem; }
/* Minimized: the call floats in a corner so the session page and the note stay usable. */
.video-call.mini { inset: auto 16px 16px auto; width: min(360px, calc(100% - 32px)); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.video-call.mini .video-head { padding: .4rem .6rem; font-size: .85rem; gap: .5rem; }
.video-call.mini .video-head .video-status { display: none; }
.video-call.mini .video-stage { flex: none; aspect-ratio: 16 / 9; }
.video-call.mini .video-local { width: 28%; right: 8px; bottom: 8px; border-width: 1px; }
.video-call.mini .video-waiting p { font-size: .85rem; }
.video-call.mini .video-controls { padding: .45rem .5rem .55rem; }
.video-call.mini .video-buttons { gap: .35rem; }
.video-call.mini .video-buttons button { padding: .3rem .55rem; font-size: .82rem; }
body:has(.rec-pill) .video-call.mini { bottom: 84px; }
@media (max-width: 760px) {
  .video-call.mini { inset: auto 8px 8px 8px; width: auto; }
  body:has(.rec-pill) .video-call.mini { bottom: 96px; }
  .video-call:not(.mini) .video-rec { order: 3; flex-basis: 100%; margin-left: 0; text-align: center; }
}
@media print { .video-call { display: none !important; } }

/* NovaSalvia support looking at a practice, read-only (provider portal). */
:root[data-read-only] .ro-hide { display: none !important; }
.support-banner { background: var(--danger-soft); color: var(--text, inherit); border-bottom: 2px solid var(--danger); padding: .5rem 1rem; font-size: .9rem; }

/* How to (provider) and Help (portal): step-by-step guides as expandable cards. */
.guide > summary { cursor: pointer; display: flex; flex-direction: column; gap: .15rem; }
.guide-title { font-weight: 600; }
.guide-steps { padding-left: 1.25rem; margin: .75rem 0; }
.guide-steps li { margin: .4rem 0; line-height: 1.5; }
