/* Spine Rotation — styled after the Montefiore Einstein design system
   (navy #003769, Leitura News serif display type, Arial body, 2px radii,
   4px navy top rule, dark hero bands, pale blue-gray section tints). */

:root {
  --navy: #003769;
  --navy-dark: #00274a;
  --navy-mid: #153764;
  --blue: #4e79bd;
  --blue-light: #5d8fdf;
  --text: #33383e;
  --text-muted: #6a6a73;
  --gray-400: #9da2ad;
  --border: #d0d7e0;
  --gray-100: #e4e9ee;
  --gray-50: #f5f5f5;
  --tint: #f1f7fb;
  --gold: #d9a900;
  --green: #1e8a33;
  --green-bg: #e7ffea;
  --red: #c0392b;
  --red-bg: #fff3f3;
  --amber-bg: #fff8e1;
  --serif: "Leitura News", ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  --sans: Arial, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --radius: 2px;
  --shadow: 0 1px 2px rgba(0, 39, 74, .06), 0 2px 8px rgba(0, 39, 74, .05);
  --wrap: 1200px;
  --bottom-nav-h: 0px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--sans); font-size: 16px; line-height: 1.5; color: var(--text);
  background: #fff; min-height: 100vh; display: flex; flex-direction: column;
  padding-bottom: var(--bottom-nav-h);
}
main { flex: 1 0 auto; }
a { color: var(--navy); text-underline-offset: 3px; }
a:hover { color: var(--blue); }
img, svg { max-width: 100%; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; color: var(--text); letter-spacing: -0.01em; }
h1 { font-size: 2rem; line-height: 1.2; margin: 0 0 .25rem; letter-spacing: -0.03125rem; }
h2 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 .75rem; }
h3 { font-size: 1.2rem; line-height: 1.3; margin: 0 0 .5rem; }
h4 { font-size: 1rem; margin: 0 0 .4rem; }
p { margin: 0 0 .75rem; }
.small { font-size: .875rem; }
.xsmall { font-size: .78rem; }
.muted { color: var(--text-muted); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--navy); color: #fff; padding: .5rem 1rem; z-index: 100; }
.skip-link:focus { left: 1rem; }
:focus-visible { outline: 3px solid var(--blue-light); outline-offset: 2px; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 1.25rem; }

/* ---------- Header (top bar) ---------- */
.mf-top-bar { border-top: 4px solid var(--navy); background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 40; }
.mf-top-bar .wrap { display: flex; align-items: stretch; justify-content: space-between; min-height: 4.5rem; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .9rem; text-decoration: none; color: var(--navy); }
.brand-mark { font-family: var(--serif); font-size: 1.45rem; line-height: 1; color: var(--navy); white-space: nowrap; }
.brand-mark b { font-weight: 700; }
.brand-divider { width: 1px; align-self: stretch; margin: 1.1rem 0; background: var(--border); }
.brand-sub { display: flex; flex-direction: column; line-height: 1.15; font-size: .8rem; color: var(--text-muted); }
.brand-sub strong { color: var(--text); font-size: .92rem; font-weight: 700; }
.primary-nav { display: flex; align-items: flex-end; gap: .15rem; }
.primary-nav a {
  display: block; padding: .55rem .8rem .9rem; color: var(--text); text-decoration: none; font-size: .95rem;
  border-radius: var(--radius) var(--radius) 0 0; position: relative; white-space: nowrap;
}
.primary-nav a:hover { color: var(--navy); background: var(--tint); }
.primary-nav a.active { color: var(--navy); font-weight: 700; }
.primary-nav a.active::after { content: ""; position: absolute; left: .8rem; right: .8rem; bottom: 0; height: 4px; background: var(--navy); }
.nav-badge { display: inline-block; min-width: 1.2rem; padding: 0 .3rem; margin-left: .25rem; border-radius: 1rem; background: var(--red); color: #fff; font-size: .7rem; line-height: 1.2rem; text-align: center; font-weight: 700; }
.user-area { display: flex; align-items: center; gap: .6rem; }
.user-chip { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; font-size: .85rem; }
.user-chip span { color: var(--text-muted); font-size: .75rem; }
.burger { display: none; background: none; border: 1px solid var(--border); border-radius: var(--radius); width: 2.75rem; height: 2.75rem; align-self: center; cursor: pointer; }
.burger span { display: block; width: 1.2rem; height: 2px; background: var(--navy); margin: 4px auto; transition: transform .2s; }

.drawer { display: none; border-top: 1px solid var(--border); background: #fff; }
.drawer.open { display: block; }
.drawer a, .drawer button.linklike { display: block; width: 100%; text-align: left; padding: .9rem 1.25rem; border-bottom: 1px solid var(--gray-100); color: var(--text); text-decoration: none; font-size: 1rem; background: none; border-left: 0; border-right: 0; border-top: 0; font-family: inherit; cursor: pointer; }
.drawer a.active { color: var(--navy); font-weight: 700; border-left: 4px solid var(--navy); }

/* ---------- Hero band ---------- */
.mf-hero {
  position: relative; color: #fff; overflow: hidden;
  background:
    linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,.35) 100%),
    radial-gradient(1200px 400px at 85% -20%, rgba(93,143,223,.35), rgba(0,0,0,0) 60%),
    linear-gradient(115deg, var(--navy-dark) 0%, var(--navy) 55%, var(--navy-mid) 100%);
}
.mf-hero::after { /* subtle vertebral-column motif */
  content: ""; position: absolute; right: 4%; top: -10%; bottom: -10%; width: 90px; opacity: .10;
  background: repeating-linear-gradient(180deg, #fff 0 22px, transparent 22px 34px);
  border-radius: 40px; transform: rotate(8deg);
}
.mf-hero .wrap { position: relative; z-index: 1; padding-top: 1.6rem; padding-bottom: 2rem; }
.mf-hero h1 { color: #fff; font-size: 2.4rem; margin-bottom: .35rem; }
.mf-hero p.lede { color: rgba(255,255,255,.88); max-width: 46rem; margin: 0; font-size: 1.05rem; }
.mf-hero .hero-actions { margin-top: 1.1rem; display: flex; flex-wrap: wrap; gap: .6rem; }
.breadcrumbs { font-size: .82rem; margin-bottom: .9rem; color: rgba(255,255,255,.75); }
.breadcrumbs a { color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.4); }
.breadcrumbs span.sep { margin: 0 .45rem; opacity: .6; }

/* ---------- Sections & layout ---------- */
.section { padding: 2rem 0; }
.wrap.section { padding: 2rem 1.25rem; }
@media (max-width: 520px) { .wrap.section { padding: 1.5rem 1rem; } }
.section.tint { background: var(--tint); border-top: 1px solid var(--gray-100); border-bottom: 1px solid var(--gray-100); }
.section.navy { background: var(--navy); color: #fff; }
.section.navy h2 { color: #fff; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.section-head h2 { margin: 0; }
.grid { display: grid; gap: 1.25rem; }
.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)); }
.span-2 { grid-column: span 2; }
.stack > * + * { margin-top: 1rem; }

.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.card h3 { margin-bottom: .75rem; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; margin-bottom: .75rem; flex-wrap: wrap; }
.card-head h3 { margin: 0; }
.card.accent { border-top: 4px solid var(--navy); }
.card.flat { box-shadow: none; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; }
.kpi { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; }
.kpi .v { font-family: var(--serif); font-size: 2rem; line-height: 1.1; color: var(--navy); }
.kpi .l { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; }
.kpi.good .v { color: var(--green); }
.kpi.warn .v { color: #9a6b00; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .7rem 1.15rem;
  border-radius: var(--radius); border: 2px solid var(--navy); background: var(--navy); color: #fff;
  font: 700 .95rem/1.1 var(--sans); text-decoration: none; cursor: pointer; transition: background .2s, color .2s, border-color .2s;
  min-height: 2.75rem;
}
.btn:hover { background: var(--navy-dark); border-color: var(--navy-dark); color: #fff; }
.btn.secondary { background: #fff; color: var(--navy); }
.btn.secondary:hover { background: var(--tint); color: var(--navy); }
.btn.light { background: #fff; color: var(--navy); border-color: #fff; }
.btn.light:hover { background: var(--tint); }
.btn.ghost-light { background: transparent; color: #fff; border-color: rgba(255,255,255,.7); }
.btn.ghost-light:hover { background: rgba(255,255,255,.12); }
.btn.danger { background: #fff; color: var(--red); border-color: var(--red); }
.btn.danger:hover { background: var(--red-bg); }
.btn.small { padding: .4rem .7rem; font-size: .82rem; min-height: 2.1rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
form.inline { display: inline; }
button.linklike { background: none; border: none; padding: 0; color: var(--navy); text-decoration: underline; cursor: pointer; font: inherit; }

/* ---------- Badges / pills ---------- */
.badge { display: inline-block; padding: .12rem .5rem; border-radius: 1rem; font-size: .74rem; font-weight: 700; line-height: 1.5; background: var(--gray-100); color: var(--text); white-space: nowrap; }
.badge.navy { background: var(--navy); color: #fff; }
.badge.blue { background: #e3ecfa; color: var(--navy-mid); }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.amber { background: var(--amber-bg); color: #8a6100; }
.badge.gold { background: #fff4c7; color: #7a5b00; }
.flag-badge { display: inline-flex; align-items: center; gap: .3rem; background: #fff4c7; color: #6b4f00; border: 1px solid #f0d77a; }

/* ---------- Progress ---------- */
.progress { height: .6rem; background: var(--gray-100); border-radius: 1rem; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--blue); border-radius: 1rem; }
.progress.met > span { background: var(--green); }
.progress.lg { height: .9rem; }
.mini-bar { display: inline-block; height: .55rem; background: var(--gray-100); border-radius: 1rem; vertical-align: middle; overflow: hidden; }
.mini-bar > span { display: block; height: 100%; }
.goal { padding: .7rem 0; border-bottom: 1px solid var(--gray-100); }
.goal:last-child { border-bottom: 0; }
.goal-top { display: flex; justify-content: space-between; gap: .75rem; align-items: baseline; margin-bottom: .35rem; }
.goal-title { font-weight: 700; font-size: .95rem; }
.clinic-dots { display: flex; gap: .45rem; flex-wrap: wrap; }
.clinic-dots span { width: 2rem; height: 2rem; border-radius: 50%; border: 2px solid var(--border); display: grid; place-items: center; font-size: .8rem; color: var(--text-muted); }
.clinic-dots span.done { background: var(--navy); border-color: var(--navy); color: #fff; }

/* ---------- Phone-first case form ---------- */
button, .btn, .seg label, .chip, summary { touch-action: manipulation; -webkit-tap-highlight-color: rgba(0, 55, 105, .12); }
legend .step-num { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; margin-right: .35rem; border-radius: 50%; background: var(--navy); color: #fff; font: 700 .85rem/1 var(--sans); vertical-align: 2px; }
.chip-row { display: flex; flex-wrap: wrap; gap: .5rem; margin: .35rem 0 .5rem; }
.chip { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-height: 2.75rem; padding: .5rem .9rem; border: 1.5px solid var(--gray-400); border-radius: 2rem; background: #fff; color: var(--text); font: 700 .9rem/1.2 var(--sans); cursor: pointer; user-select: none; }
.chip:hover { border-color: var(--navy); }
.chip[aria-pressed="true"], .chip-input:checked + .chip { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip-input { position: absolute; opacity: 0; pointer-events: none; }
.chip-input:focus-visible + .chip { outline: 3px solid var(--blue-light); outline-offset: 2px; }
.chip-lg { flex-direction: column; align-items: flex-start; border-radius: var(--radius); padding: .6rem 1rem; min-width: 10rem; }
.chip-lg span { font-weight: 400; font-size: .78rem; opacity: .85; }
.chip-sm { min-height: 2.25rem; padding: .3rem .7rem; font-size: .82rem; }
.chip.ghost { border-style: dashed; color: var(--text-muted); }
details.more { margin: .25rem 0 .5rem; }
details.more > summary { cursor: pointer; color: var(--navy); font-weight: 700; font-size: .92rem; padding: .55rem 0; list-style: none; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "▸ "; display: inline-block; transition: transform .15s; }
details.more[open] > summary::before { transform: rotate(90deg); }
details.legend-details { margin-top: .6rem; }
details.legend-details > summary { cursor: pointer; font-size: .82rem; color: var(--text-muted); }
.details-peek { font-weight: 400; color: var(--text-muted); font-size: .85rem; }
.selected-procs { color: var(--navy); font-weight: 700; margin: .2rem 0 .4rem; min-height: 1.2em; }
.date-field { max-width: 15rem; }
.quickfill { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; padding: .6rem .7rem; margin: .2rem 0 .4rem; background: var(--tint); border-radius: var(--radius); }
.quickfill .small { margin-right: .2rem; }
.oscore-row { border-bottom: 0; }
.oscore-row .seg label { min-width: 3.4rem; font-size: 1rem; }
.oscore-desc { font-size: .88rem; color: var(--text-muted); margin: .35rem 0 0; min-height: 2.6em; }
.oscore-desc.chosen { color: var(--text); }
.draft-banner { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between; padding: .75rem 1rem; margin-bottom: 1rem; background: var(--amber-bg); border-left: 4px solid var(--gold); border-radius: var(--radius); }
.dictate-tip { display: none; }
.outbox-banner { background: var(--navy); color: #fff; font-size: .9rem; }
.outbox-inner { display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: center; padding-top: .6rem; padding-bottom: .6rem; }
.install-banner { display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; background: var(--tint); border-bottom: 1px solid var(--gray-100); font-size: .9rem; }
.install-banner img { border-radius: 8px; flex: 0 0 auto; }
.install-banner span { flex: 1; }
.install-close { background: none; border: 0; font-size: 1.6rem; line-height: 1; color: var(--text-muted); padding: .2rem .4rem; cursor: pointer; }
.toast { position: fixed; left: 50%; bottom: calc(var(--bottom-nav-h) + 1rem + env(safe-area-inset-bottom)); transform: translate(-50%, 1rem); max-width: min(92vw, 34rem); padding: .8rem 1.1rem; background: var(--text); color: #fff; border-radius: 10px; font-size: .92rem; box-shadow: 0 6px 24px rgba(0,0,0,.25); opacity: 0; transition: opacity .25s, transform .25s; z-index: 60; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Knowledge bars */
.kbars { display: grid; gap: .65rem; }
.kb-top { display: flex; gap: .5rem; align-items: baseline; font-size: .86rem; margin-bottom: .2rem; }
.kb-top span:first-child { flex: 1; }
.kb-n { font-size: .72rem; color: var(--text-muted); min-width: 2.6rem; text-align: right; }
.kb-track { position: relative; height: .7rem; background: var(--gray-100); border-radius: 1rem; }
.kb-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 1rem; }
.kb-exp { position: absolute; top: -.25rem; bottom: -.25rem; width: 3px; margin-left: -1.5px; background: var(--gold); border-radius: 2px; }
.kb-cohort { position: absolute; top: 50%; width: .7rem; height: .7rem; margin: -.35rem 0 0 -.35rem; border: 2px solid var(--text); border-radius: 50%; background: rgba(255,255,255,.7); }
.kb-scale { display: flex; justify-content: space-between; font-size: .7rem; color: var(--gray-400); margin-top: -.2rem; }

/* Case variety checklist */
.variety { display: grid; gap: .4rem; }
.vt { display: grid; grid-template-columns: 1.6rem 1fr auto; align-items: center; gap: .6rem; padding: .5rem .6rem; border: 1px solid var(--gray-100); border-radius: var(--radius); background: #fff; font-size: .92rem; }
.vt-mark { width: 1.4rem; height: 1.4rem; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 700; border: 2px solid var(--border); }
.vt.seen .vt-mark { background: var(--navy); border-color: var(--navy); color: #fff; }
.vt.gap { background: #fbfcfd; }
.vt.gap .vt-label { color: var(--text-muted); }
.vt-count { font-weight: 700; font-variant-numeric: tabular-nums; }
.vt.gap .vt-count { font-weight: 400; font-size: .8rem; color: #8a6100; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th { text-align: left; background: var(--gray-100); color: var(--text); font-weight: 700; padding: .6rem .75rem; border-bottom: 2px solid var(--navy); white-space: nowrap; }
table.data td { padding: .6rem .75rem; border-bottom: 1px solid var(--gray-100); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: #fafcfe; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data.compact td, table.data.compact th { padding: .4rem .6rem; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.25rem; }
.form-grid .full { grid-column: 1 / -1; }
.field label, .label { display: block; font-weight: 700; font-size: .9rem; margin-bottom: .35rem; }
.field .hint, .hint { font-size: .8rem; color: var(--text-muted); margin-top: .3rem; }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=url], input[type=search], select, textarea {
  width: 100%; padding: .7rem .8rem; border: 1px solid var(--gray-400); border-radius: var(--radius); font: 1rem/1.35 var(--sans); color: var(--text); background: #fff; min-height: 2.75rem;
}
textarea { min-height: 6rem; resize: vertical; }
input:not([type]):focus, input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(78,121,189,.25); }
.check, .field label.check { display: flex; align-items: flex-start; gap: .55rem; font-weight: 400; font-size: .95rem; cursor: pointer; padding: .25rem 0; margin: 0; }
.check input { width: 1.15rem; height: 1.15rem; margin-top: .15rem; flex: 0 0 auto; accent-color: var(--navy); }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; margin: 0 0 1.25rem; background: #fff; }
legend { font-family: var(--serif); font-size: 1.2rem; padding: 0 .4rem; color: var(--navy); }
.phi-note { background: var(--amber-bg); border-left: 4px solid var(--gold); padding: .65rem .9rem; font-size: .88rem; border-radius: var(--radius); }

/* Segmented rating controls */
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--gray-400); border-radius: var(--radius); overflow: hidden; background: #fff; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { margin: 0; padding: .5rem .7rem; font-size: .82rem; font-weight: 700; cursor: pointer; border-right: 1px solid var(--border); color: var(--text); min-width: 2.6rem; text-align: center; user-select: none; min-height: 2.5rem; display: flex; align-items: center; justify-content: center; }
.seg label:last-of-type { border-right: 0; }
.seg input:checked + label { background: var(--navy); color: #fff; }
.seg input:focus-visible + label { outline: 3px solid var(--blue-light); outline-offset: -3px; }
.seg label:hover { background: var(--tint); }
.seg input:checked + label:hover { background: var(--navy-dark); }
.rate-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .5rem 1rem; align-items: center; padding: .55rem 0; border-bottom: 1px solid var(--gray-100); }
.rate-row:last-child { border-bottom: 0; }
.rate-row .rlabel { font-size: .92rem; }
.rate-row.dim .rlabel { color: var(--text-muted); }
.step-group-title { font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin: 1rem 0 .2rem; }
.scale-legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .5rem; font-size: .8rem; margin-bottom: .75rem; }
.scale-legend div { background: var(--tint); border-radius: var(--radius); padding: .45rem .6rem; }
.chip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .35rem .9rem; }
.toggle-more { margin-top: .5rem; }
.sticky-actions { position: sticky; bottom: calc(var(--bottom-nav-h) + .5rem); background: rgba(255,255,255,.96); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem; display: flex; gap: .6rem; flex-wrap: wrap; justify-content: flex-end; box-shadow: var(--shadow); z-index: 5; }

/* ---------- Flash messages ---------- */
.flashes { margin: 1rem 0 0; }
.flash { padding: .8rem 1rem; border-radius: var(--radius); margin-bottom: .6rem; border-left: 4px solid var(--blue); background: #eef4fc; font-size: .95rem; }
.flash.success { border-color: var(--green); background: var(--green-bg); }
.flash.error { border-color: var(--red); background: var(--red-bg); }
.flash.warning { border-color: var(--gold); background: var(--amber-bg); }

/* ---------- Library ---------- */
.res { padding: 1rem 0; border-bottom: 1px solid var(--gray-100); }
.res:last-child { border-bottom: 0; }
.res-title { font-weight: 700; font-size: 1rem; line-height: 1.35; }
.res-meta { font-size: .85rem; color: var(--text-muted); margin: .2rem 0 .4rem; }
.res-points { font-size: .9rem; margin: .3rem 0; }
.flag-list { margin: .5rem 0 0; padding: .55rem .75rem; background: #fffbea; border: 1px solid #f3e3a1; border-radius: var(--radius); font-size: .86rem; }
.flag-list div + div { margin-top: .3rem; }
.res-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .55rem; align-items: center; }
details.flag-form summary { cursor: pointer; color: var(--navy); font-weight: 700; font-size: .85rem; list-style: none; }
details.flag-form summary::-webkit-details-marker { display: none; }
details.flag-form[open] { flex-basis: 100%; }
.filters { display: grid; grid-template-columns: 2fr repeat(4, 1fr) auto; gap: .6rem; align-items: end; }

/* ---------- Assistant ---------- */
.chat-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 1.25rem; }
.chat-side { font-size: .9rem; }
.chat-side a.conv { display: block; padding: .55rem .6rem; border-radius: var(--radius); text-decoration: none; color: var(--text); border-left: 3px solid transparent; }
.chat-side a.conv:hover { background: var(--tint); }
.chat-side a.conv.active { background: var(--tint); border-left-color: var(--navy); font-weight: 700; }
.chat-box { display: flex; flex-direction: column; min-height: 60vh; }
.chat-log { flex: 1; display: flex; flex-direction: column; gap: 1rem; padding-bottom: 1rem; }
.msg { max-width: 100%; }
.msg.user .bubble { background: var(--navy); color: #fff; margin-left: auto; max-width: 85%; border-radius: 12px 12px 2px 12px; padding: .7rem .95rem; white-space: pre-wrap; }
.msg.assistant .bubble { background: #fff; border: 1px solid var(--border); border-radius: 2px 12px 12px 12px; padding: .9rem 1.1rem; }
.msg.assistant .bubble h1, .msg.assistant .bubble h2, .msg.assistant .bubble h3 { font-size: 1.1rem; margin: .8rem 0 .4rem; color: var(--navy); }
.msg.assistant .bubble ul, .msg.assistant .bubble ol { padding-left: 1.3rem; margin: .3rem 0 .7rem; }
.msg.assistant .bubble p:last-child { margin-bottom: 0; }
.msg .status { font-size: .85rem; color: var(--text-muted); font-style: italic; display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem; }
.spinner { width: .9rem; height: .9rem; border: 2px solid var(--border); border-top-color: var(--navy); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sources { margin-top: .6rem; font-size: .84rem; }
.sources summary { cursor: pointer; color: var(--navy); font-weight: 700; }
.sources ul { list-style: none; padding: 0; margin: .4rem 0 0; }
.sources li { padding: .35rem 0; border-bottom: 1px dashed var(--gray-100); }
.src-kind { font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; margin-right: .35rem; }
.chat-input { position: sticky; bottom: calc(var(--bottom-nav-h) + .5rem); background: #fff; border: 1px solid var(--gray-400); border-radius: var(--radius); padding: .5rem; display: flex; gap: .5rem; box-shadow: var(--shadow); }
.chat-input textarea { border: 0; min-height: 2.8rem; max-height: 12rem; padding: .55rem; box-shadow: none !important; }
.suggestions { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: .6rem; }
.suggestion { text-align: left; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem .9rem; cursor: pointer; font: .9rem/1.4 var(--sans); color: var(--text); }
.suggestion:hover { border-color: var(--navy); background: var(--tint); }

/* ---------- Charts ---------- */
svg.chart { width: 100%; height: auto; display: block; font-family: var(--sans); }
svg.strip { width: 100%; max-width: 300px; height: auto; display: block; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .8rem; color: var(--text-muted); margin-top: .4rem; }
.legend i { display: inline-block; width: .8rem; height: .8rem; border-radius: 2px; vertical-align: -1px; margin-right: .3rem; }

/* ---------- Misc ---------- */
.empty { text-align: center; padding: 2rem 1rem; color: var(--text-muted); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; font-size: .92rem; }
.kv dt { font-weight: 700; color: var(--text-muted); }
.kv dd { margin: 0; }
.notice { background: var(--tint); border: 1px solid var(--gray-100); border-left: 4px solid var(--navy); padding: .8rem 1rem; border-radius: var(--radius); font-size: .92rem; }
.prose h2 { font-size: 1.35rem; margin-top: 1.2rem; }
.prose h3 { font-size: 1.15rem; margin: 1.1rem 0 .4rem; color: var(--navy); }
.prose h3:first-child, .prose h2:first-child { margin-top: 0; }
.prose li { margin: .2rem 0; }
.prose .table-wrap { margin: .5rem 0 .8rem; }
.prose.acgme > p { background: var(--tint); border-left: 4px solid var(--navy); padding: .8rem 1rem; border-radius: var(--radius); }
fieldset.new-type { border-style: dashed; }
.prose ul { padding-left: 1.3rem; }
details.disclose { border: 1px solid var(--border); border-radius: var(--radius); background: #fff; margin-bottom: .6rem; }
details.disclose > summary { cursor: pointer; padding: .8rem 1rem; font-weight: 700; color: var(--navy); }
details.disclose > div { padding: 0 1rem 1rem; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .6rem .9rem; text-decoration: none; color: var(--text); border-bottom: 4px solid transparent; white-space: nowrap; }
.tabs a.active { border-color: var(--navy); color: var(--navy); font-weight: 700; }
.issued { background: var(--green-bg); border: 1px solid #a9dfb3; border-radius: var(--radius); padding: 1rem; }
.issued code { font-size: 1.1rem; background: #fff; padding: .15rem .45rem; border: 1px solid var(--border); border-radius: var(--radius); user-select: all; }

/* ---------- Footer ---------- */
.mf-footer { border-top: 1px solid var(--border); background: #fff; margin-top: 2.5rem; }
.mf-footer .wrap { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 1.5rem; padding-top: 2rem; padding-bottom: 2rem; font-size: .88rem; }
.mf-footer h4 { font-family: var(--serif); font-weight: 400; font-size: 1.05rem; color: var(--navy); margin-bottom: .6rem; }
.mf-footer ul { list-style: none; margin: 0; padding: 0; }
.mf-footer li { margin: .3rem 0; }
.mf-footer a { color: var(--text); text-decoration: none; }
.mf-footer a:hover { color: var(--navy); text-decoration: underline; }
.mf-footer .legal { grid-column: 1 / -1; border-top: 1px solid var(--gray-100); padding-top: 1rem; color: var(--text-muted); font-size: .8rem; }

/* ---------- Bottom tab bar (phones) ---------- */
.bottom-nav { display: none; }

/* ---------- Auth ---------- */
.auth-wrap { max-width: 440px; margin: 3rem auto; padding: 0 1.25rem; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .primary-nav a { padding-left: .55rem; padding-right: .55rem; font-size: .9rem; }
  .brand-sub { display: none; }
  .brand-divider { display: none; }
}
@media (max-width: 920px) {
  :root { --bottom-nav-h: 64px; }
  .primary-nav, .user-chip, .user-area form { display: none; }
  .burger { display: block; }
  .mf-top-bar .wrap { min-height: 3.75rem; }
  .brand-mark { font-size: 1.25rem; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .mf-hero h1 { font-size: 1.75rem; }
  .mf-hero .wrap { padding-top: 1.1rem; padding-bottom: 1.4rem; }
  .mf-hero::after { display: none; }
  .chat-layout { grid-template-columns: 1fr; }
  .chat-side { display: none; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .q { grid-column: 1 / -1; }
  .mf-footer .wrap { grid-template-columns: 1fr 1fr; }
  .rate-row { grid-template-columns: 1fr; }
  .rate-row .seg { display: flex; width: 100%; }
  .rate-row .seg label { flex: 1 1 0; padding: .55rem .3rem; min-width: 0; }
  .sticky-actions { flex-wrap: nowrap; padding: .5rem; gap: .4rem; }
  .sticky-actions .btn { flex: 1 1 auto; padding: .55rem .6rem; font-size: .88rem; min-height: 2.75rem; }
  /* While the on-screen keyboard is open, give the form the space the tab bar used. */
  .mf-hero.compact .wrap { padding-top: .75rem; padding-bottom: .85rem; }
  .mf-hero.compact .breadcrumbs { display: none; }
  .mf-hero.compact h1 { font-size: 1.45rem; margin: 0; }
  .mf-hero.compact p.lede { font-size: .85rem; }
  body.kb-open { --bottom-nav-h: 0px; }
  body.kb-open .bottom-nav { display: none; }
  .dictate-tip { display: inline; }
  .case-form-wrap fieldset { padding: .9rem .85rem; margin-bottom: 1rem; }
  .case-form-wrap legend { font-size: 1.1rem; }
  .chip-lg { flex: 1 1 calc(50% - .5rem); min-width: 0; }
  .oscore-row .seg label { min-width: 0; }
  .date-field { max-width: none; }
  .mf-hero p.lede { font-size: .95rem; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: #fff; border-top: 1px solid var(--border); height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -2px 10px rgba(0,39,74,.08);
  }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem; font-size: .68rem; color: var(--text-muted); text-decoration: none; position: relative; }
  .bottom-nav a svg { width: 1.45rem; height: 1.45rem; stroke: currentColor; fill: none; stroke-width: 1.8; }
  .bottom-nav a.active { color: var(--navy); font-weight: 700; }
  .bottom-nav a.primary-action { color: #fff; }
  .bottom-nav a.primary-action .circle { background: var(--navy); border-radius: 50%; width: 2.6rem; height: 2.6rem; display: grid; place-items: center; margin-top: -1.1rem; box-shadow: 0 2px 8px rgba(0,39,74,.3); }
  .bottom-nav a.primary-action span.lbl { color: var(--navy); font-weight: 700; }
  .bottom-nav .nav-badge { position: absolute; top: 4px; right: 22%; margin: 0; }
}
@media (max-width: 520px) {
  .wrap { padding: 0 1rem; }
  h2 { font-size: 1.35rem; }
  .card { padding: 1rem; }
  .kpi .v { font-size: 1.6rem; }
  .mf-footer .wrap { grid-template-columns: 1fr; }
  table.data { font-size: .85rem; }
  .hide-sm { display: none; }
}

/* ---------- Print ---------- */
@media print {
  .mf-top-bar, .bottom-nav, .mf-footer, .no-print, .sticky-actions { display: none !important; }
  .mf-hero { background: none; color: var(--text); }
  .mf-hero h1, .mf-hero p.lede, .breadcrumbs, .breadcrumbs a { color: var(--text); }
  body { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* ---------- Screenshots in editable pages (Joint Commission guides) ---------- */
.prose figure.shot { margin: .9rem 0 1.2rem; max-width: 820px; }
.prose figure.shot img { display: block; max-width: 100%; height: auto; border: 1px solid var(--gray-100); border-radius: var(--radius); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); background: #fff; }
.prose figure.shot figcaption { margin-top: .35rem; font-size: .82rem; color: var(--text-muted); }
.prose a.shot-link { display: inline-block; max-width: 100%; }
.prose code { background: var(--tint); border: 1px solid var(--gray-100); border-radius: 4px; padding: 0 .3rem; font-size: .86em; white-space: normal; }
.prose details.disclose { margin-top: 1rem; }
.prose h4 { font-size: 1.02rem; margin: 1.1rem 0 .4rem; color: var(--navy); }
.prose h4:first-child { margin-top: 0; }

/* ---------- File repository ---------- */
.file-list { list-style: none; padding: 0; margin: .5rem 0 1rem; }
.file-list li { padding: .45rem 0; border-bottom: 1px solid var(--gray-100); display: flex; flex-direction: column; gap: .1rem; }
.file-list li:last-child { border-bottom: 0; }
.file-preview { display: block; max-width: 100%; max-height: 70vh; height: auto; margin: .5rem 0; border: 1px solid var(--gray-100); border-radius: var(--radius); background: #000; }
img.file-preview { background: #fff; }
.copy-row { display: flex; gap: .5rem; align-items: center; }
.copy-row input { flex: 1; min-width: 0; font-family: ui-monospace, Consolas, monospace; font-size: .8rem; }
.link-strip { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1rem; }
/* In-page tab links land below the sticky header */
html { scroll-padding-top: 5.5rem; }

/* ---------- Fit on every screen ---------- */
/* Grid columns may shrink below their content's width (wide tables scroll inside .table-wrap instead of
   pushing the page sideways on phones). */
.grid > * { min-width: 0; }
.prose { overflow-wrap: break-word; }
.prose code { overflow-wrap: anywhere; }
.prose table.data th { white-space: normal; }

/* Header: compact labels and spacing as the screen narrows, so every link fits on one line. */
.mf-top-bar .wrap { max-width: 1520px; }   /* the header may run wider than the 1200px page column */
.user-chip { flex-shrink: 0; max-width: 11.5rem; }  /* wraps to 2 lines at most; never crushed into a tall column */
.nav-short { display: none; }
@media (max-width: 1539px) {
  .brand-sub, .brand-divider { display: none; }
}
@media (max-width: 1419px) {
  .primary-nav a .nav-long { display: none; }
  .primary-nav a .nav-short { display: inline; }
}
@media (max-width: 1339px) and (min-width: 921px) {
  .mf-top-bar .wrap { gap: .6rem; }
  .primary-nav a { padding-left: .42rem; padding-right: .42rem; font-size: .86rem; }
  .primary-nav a.active::after { left: .3rem; right: .3rem; }
  .brand-mark { font-size: 1.25rem; }
}
/* Small laptops: the name, Admin and Password links move into the ☰ menu (which also has Sign out). */
@media (max-width: 1199px) and (min-width: 921px) {
  .user-chip, .user-area form { display: none; }
  .burger { display: block; }
  .primary-nav a { padding-left: .34rem; padding-right: .34rem; font-size: .84rem; }
}

/* ---------- Research (MERITS) ---------- */
.person-chip { display: inline-block; margin: 0 .3rem .25rem 0; padding: .1rem .5rem; border: 1px solid var(--gray-100); border-radius: 1rem; background: var(--tint); font-size: .82rem; white-space: nowrap; }
.person-chip .muted { font-size: .75rem; }
.project-card h3 a { text-decoration: none; }
.project-card h3 a:hover { text-decoration: underline; }
/* Alumni (graduated residents) are highlighted in gold wherever research credit is shown */
.person-chip.alumni { background: #fff8e1; border-color: #ead48a; }
.alumni-card { border-left: 4px solid var(--gold); background: #fffdf5; }
.kpi.alumni-kpi { border-left: 4px solid var(--gold); background: #fffdf5; }
tr.alumni-row td { background: #fffaf0; }
