/* A Real Change Health — Doctor Referral design system.
   Tokens and layout rules are defined by docs/design-reference.md (binding):
   brand language extracted from arealchange.com + arealchange.ai. The contract
   is AIR — generous section rhythm, max 3-up grids, pill CTAs, Playfair display
   headings over Poppins UI. */

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --ink: rgb(27, 42, 50);
  --ink-soft: rgb(98, 120, 132);
  --teal: rgb(41, 163, 151);
  --teal-deep: rgb(13, 148, 136);
  --teal-tint: rgba(41, 163, 151, 0.1);
  --coral: rgb(240, 113, 66);
  --coral-soft: rgb(233, 122, 106);
  --gold: rgb(244, 192, 37);
  --bg: rgb(245, 249, 249);
  --bg-warm: rgb(251, 249, 248);
  --bg-band: rgb(209, 224, 224);
  --card: #ffffff;
  --footer: rgb(27, 42, 50);
  --danger: rgb(186, 64, 47);
  --ok: var(--teal-deep);
  --line: rgba(27, 42, 50, 0.12);
  --shadow: 0 10px 30px rgba(27, 42, 50, 0.08);
  --radius: 16px;
  --radius-sm: 10px;
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 48px;
  --space-6: 72px;
  --space-7: 96px;
  --wrap: 1120px;
  --font-ui: "Poppins", Arial, sans-serif;
  --font-display: "Playfair Display", Georgia, serif;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body, #app { max-width: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
#app.boot { padding: var(--space-6); color: var(--ink-soft); text-align: center; }
img { max-width: 100%; }
main { display: block; }

h1, h2 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
  margin: 0 0 var(--space-2);
  letter-spacing: -0.01em;
}
h1 { font-size: clamp(34px, 5vw, 58px); }
h2 { font-size: clamp(26px, 3.2vw, 38px); }
h3 { font-size: 19px; font-weight: 600; line-height: 1.35; margin: 0 0 var(--space-1); }
h1 em, h2 em { font-style: normal; color: var(--teal); }
p { margin: 0 0 var(--space-2); }
a { color: var(--teal-deep); }

.eyebrow {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--teal);
  margin: 0 0 var(--space-1);
}
.lede { font-size: 19px; line-height: 1.6; color: var(--ink); max-width: 56ch; }
.sublede, .panel-copy { color: var(--ink-soft); max-width: 60ch; }

.skip-link {
  position: absolute; left: -999px; top: 8px; z-index: 50;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px;
}
.skip-link:focus { left: 16px; }

:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; border-radius: 4px; }

/* ---------- Buttons ---------- */
button, .link-button {
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 600;
  border-radius: 999px;
  border: 1.5px solid transparent;
  padding: 14px 28px;
  min-height: 48px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
button.primary, .link-button.primary {
  background: var(--coral);
  color: #fff;
  box-shadow: 0 8px 20px rgba(240, 113, 66, 0.32);
}
button.primary:hover, .link-button.primary:hover { background: var(--coral-soft); transform: translateY(-1px); }
button.secondary, .link-button.secondary {
  background: var(--card);
  color: var(--teal-deep);
  border-color: var(--teal);
}
button.secondary:hover, .link-button.secondary:hover { background: var(--teal-tint); }
button:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.ghost-link {
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
  padding: 10px 14px;
  border-radius: 999px;
}
.ghost-link:hover { background: var(--teal-tint); color: var(--teal-deep); }

/* ---------- Sections & layout ---------- */
section { padding: var(--space-6) var(--space-3); }
section > .eyebrow, section > h2, section > .panel-copy, section > .lede,
section > ol, section > div, section > article, section > form, section > p,
section > blockquote, section > strong {
  max-width: var(--wrap);
  margin-left: auto;
  margin-right: auto;
}
section > h2 { margin-bottom: var(--space-2); }
section > .panel-copy { margin-bottom: var(--space-4); }

/* ---------- Landing: nav + hero ---------- */
.hero {
  background:
    radial-gradient(1100px 500px at 85% -10%, var(--teal-tint), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-warm) 100%);
  padding: var(--space-3) var(--space-3) var(--space-7);
}
.site-nav {
  max-width: var(--wrap);
  margin: 0 auto var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.site-nav .eyebrow { margin: 0; font-size: 12px; }
.site-nav strong { font-size: 20px; font-weight: 700; }
.nav-links { display: flex; gap: 4px; flex-wrap: wrap; }
.hero-grid {
  max-width: var(--wrap);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 4fr);
  gap: var(--space-5);
  align-items: center;
}
.hero-copy h1 { margin-bottom: var(--space-3); }
.hero-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-top: var(--space-4); }
.hero-subaction { margin-top: var(--space-2); font-size: 15px; }
.hero-subaction a { color: var(--ink-soft); text-decoration: underline; }
.hero-subaction a:hover { color: var(--teal-deep); }
.hero-visual { display: flex; justify-content: center; }
.brand-proof {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-4);
  display: grid;
  gap: var(--space-1);
  max-width: 340px;
  border-top: 6px solid var(--teal);
}
.brand-proof span {
  font-size: 13px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--teal-deep);
}
.brand-proof b { font-size: 30px; font-family: var(--font-display); }
.brand-proof small { color: var(--ink-soft); font-size: 14px; line-height: 1.55; }

/* ---------- Landing: opener, legal band ---------- */
.sandi-opener { background: var(--bg-warm); text-align: center; }
.sandi-opener blockquote {
  font-family: var(--font-display);
  font-size: clamp(20px, 2.6vw, 28px);
  line-height: 1.45;
  max-width: 720px;
  margin: 0 auto var(--space-2);
}
.opener-pending { color: var(--ink-soft); }
.placeholder-tag {
  display: block;
  font-family: var(--font-ui);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--coral);
  margin-top: var(--space-2);
}
.opener-attribution { color: var(--ink-soft); font-weight: 500; }

.legal-band {
  background: var(--teal-tint);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: var(--space-3);
  text-align: center;
  font-size: 15px;
  color: var(--ink);
}

/* ---------- Landing: offer + steps ---------- */
.offer-explainer { background: var(--bg); }
.offer-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.offer-strip article {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-4);
}
.offer-strip article .eyebrow { color: var(--coral); }
.offer-strip article p:last-child { margin-bottom: 0; color: var(--ink-soft); }
.fee-note {
  font-size: 14px;
  color: var(--ink-soft);
  border-left: 3px solid var(--teal);
  padding-left: var(--space-2);
}

.how-strip { background: var(--bg-warm); }
.how-steps {
  list-style: none;
  counter-reset: step;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}
.how-steps li {
  counter-increment: step;
  background: var(--card);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: var(--space-3) var(--space-3) var(--space-3) 76px;
  position: relative;
  color: var(--ink-soft);
}
.how-steps li b { color: var(--ink); display: block; margin-bottom: 2px; }
.how-steps li::before {
  content: counter(step);
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--teal-tint);
  color: var(--teal-deep);
  font-weight: 700;
  display: grid;
  place-items: center;
}

/* ---------- Landing: preview + auth panels ---------- */
.public-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
  max-width: var(--wrap);
  margin: 0 auto;
}
.panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-4);
}
.panel h2 { font-size: 26px; }
.auth-panel { border-top: 6px solid var(--coral); }
#preview.panel { border-top: 6px solid var(--teal); }

.tab-row { display: flex; gap: var(--space-1); margin-bottom: var(--space-3); }
.tab-row button {
  flex: 1;
  background: var(--bg);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 12px 16px;
}
.tab-row button.active { background: var(--ink); color: #fff; }

.doctor-strip {
  background: var(--bg-band);
  text-align: center;
  padding: var(--space-7) var(--space-3);
}
.doctor-strip .eyebrow { color: var(--coral); }
.doctor-strip .panel-copy { color: var(--ink-soft); margin-left: auto; margin-right: auto; max-width: 64ch; }

/* ---------- Forms ---------- */
form.stacked { display: grid; gap: var(--space-2); }
label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(--ink); }
input, select, textarea {
  font-family: var(--font-ui);
  font-size: 16px;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  min-height: 48px;
  width: 100%;
}
/* iOS WebKit ignores author min-height on native selects (UA menulist
   appearance) — drop the native appearance and draw our own chevron so the
   48px tap target holds on real iPhones. */
select {
  -webkit-appearance: none;
  appearance: none;
  height: 48px;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23628784' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); outline: none; box-shadow: 0 0 0 3px var(--teal-tint); }
.field-error { color: var(--danger); font-size: 13px; font-weight: 500; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
.loc-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--space-2); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); gap: var(--space-2); }
.privacy-note, .payment-note, .gate-note, .returnable-note, .seed-note {
  font-size: 13px;
  color: var(--ink-soft);
  background: var(--teal-tint);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 0;
}
.hardcase-note {
  font-size: 13px;
  color: var(--ink);
  background: rgba(244, 192, 37, 0.15);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 0;
}

.result {
  margin-top: var(--space-2);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
  background: var(--bg);
  color: var(--ink-soft);
  font-size: 15px;
}
.result.show.good { background: var(--teal-tint); color: var(--teal-deep); font-weight: 500; }
.result.show.warn { background: rgba(240, 113, 66, 0.12); color: var(--danger); font-weight: 500; }
.waitlist-form { margin-top: var(--space-3); border-top: 1px solid var(--line); padding-top: var(--space-3); }

/* ---------- Footer ---------- */
.site-footer {
  background: var(--footer);
  color: rgba(255, 255, 255, 0.75);
  padding: var(--space-6) var(--space-3);
  font-size: 14px;
}
.site-footer > * { max-width: var(--wrap); margin-left: auto; margin-right: auto; }
.site-footer a { color: #fff; }
.disclaimers { display: grid; gap: var(--space-1); margin-bottom: var(--space-3); }
.disclaimers p { margin: 0; }
.footer-brand { color: rgba(255, 255, 255, 0.55); margin: 0; }

/* ---------- App shell (logged-in) ---------- */
.app-shell { max-width: var(--wrap); margin: 0 auto; padding: var(--space-3); }
.app-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  flex-wrap: wrap;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-4);
}
.app-nav strong { font-family: var(--font-display); font-size: 20px; }
.nav-user { display: flex; align-items: center; gap: var(--space-2); color: var(--ink-soft); font-size: 14px; flex-wrap: wrap; }
.nav-user button { padding: 10px 18px; min-height: 40px; }

.dashboard-grid, .portal-grid, .review-grid, .doctor-grid { display: grid; gap: var(--space-3); }
.dashboard-grid > *, .portal-grid > *, .review-grid > *, .doctor-grid > *,
.content-stack > * { min-width: 0; max-width: 100%; }
.portal-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); align-items: start; }
.dashboard-grid { grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); align-items: start; }
.doctor-grid { grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); align-items: start; }
.content-stack { display: grid; gap: var(--space-3); }

.portal-panel, .doctor-panel, .admin-panel, .list-panel, .intake-card, .billing-card, .roi-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-4);
}
.panel-top { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-2); flex-wrap: wrap; min-width: 0; }
.panel-top > * { min-width: 0; }
.status-chip, .timeline li, .audit-detail { overflow-wrap: anywhere; }

.empty-state, .roi-empty, .candidate-empty {
  color: var(--ink-soft);
  background: var(--bg);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  text-align: center;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--teal-tint);
  color: var(--teal-deep);
  font-size: 13px;
  font-weight: 600;
  padding: 4px 12px;
  white-space: nowrap;
}
.status-chip.warn { background: rgba(240, 113, 66, 0.14); color: var(--danger); }
.status-chip.gold { background: rgba(244, 192, 37, 0.18); color: rgb(146, 107, 0); }
.status-explainer { color: var(--ink-soft); font-size: 14px; }

.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-1); }
.timeline li {
  position: relative;
  padding-left: var(--space-3);
  color: var(--ink-soft);
  font-size: 14px;
}
.timeline li::before {
  content: "";
  position: absolute;
  left: 6px; top: 8px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--teal);
}

.referral-list { display: grid; gap: var(--space-2); list-style: none; padding: 0; margin: 0; }
.referral-list button { width: 100%; justify-content: space-between; background: var(--bg); color: var(--ink); border-radius: var(--radius-sm); }
.referral-list button.active, .referral-list button:hover { background: var(--teal-tint); }
.referral-script {
  font-family: var(--font-display);
  font-size: 18px;
  background: var(--teal-tint);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
}
.reach-block { border-top: 1px solid var(--line); padding-top: var(--space-2); margin-top: var(--space-2); }
.why-block { color: var(--ink-soft); }
.followup-form { border-top: 1px solid var(--line); padding-top: var(--space-3); margin-top: var(--space-3); }
.checkline { display: flex; gap: 10px; align-items: center; font-weight: 500; min-height: 44px; }
.checkline input { width: auto; min-height: 0; }
input[type="checkbox"], input[type="radio"] {
  width: 22px; height: 22px; min-height: 0;
  accent-color: var(--teal-deep);
}

.doctor-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-3);
  display: grid;
  gap: var(--space-1);
}
.doctor-status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr)); gap: var(--space-2); }

.wizard-progress { display: flex; gap: var(--space-1); margin-bottom: var(--space-3); }
.wizard-progress span { flex: 1; height: 6px; border-radius: 999px; background: var(--line); }
.wizard-progress span.active { background: var(--teal); }
.wizard-actions { display: flex; justify-content: space-between; gap: var(--space-2); margin-top: var(--space-3); }

/* ---------- Admin ---------- */
.admin-section { margin-bottom: var(--space-5); }
.admin-section > h2 { font-size: 24px; }
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: var(--space-3); }
.metric {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-3);
  display: grid;
  gap: 4px;
}
.metric b { font-size: 28px; font-family: var(--font-display); }
.metric span { font-size: 13px; color: var(--ink-soft); }
.metric small { color: var(--teal-deep); font-weight: 600; }

.filter-chips { display: flex; gap: var(--space-1); flex-wrap: wrap; margin-bottom: var(--space-3); }
.filter-chips button { padding: 8px 18px; min-height: 40px; background: var(--bg); color: var(--ink-soft); font-size: 14px; }
.filter-chips button.active { background: var(--ink); color: #fff; }

.ops-row, .admin-row, .doctor-admin-row, .seed-row, .summary-row, .compact-row {
  background: var(--card);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: var(--space-3);
  display: grid;
  gap: var(--space-2);
}
.admin-list, .audit-list { display: grid; gap: var(--space-2); list-style: none; padding: 0; margin: 0; }
.admin-actions { display: flex; gap: var(--space-1); flex-wrap: wrap; }
.admin-actions button { padding: 10px 18px; min-height: 40px; font-size: 14px; }
.candidate-list { display: grid; gap: var(--space-1); list-style: none; padding: 0; margin: 0; }
.candidate-list li { background: var(--bg); border-radius: var(--radius-sm); padding: var(--space-2); font-size: 14px; }
.candidate-meta { color: var(--ink-soft); font-size: 13px; display: block; }
.origin-tag { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--teal-deep); font-weight: 700; }

.table-scroll { overflow-x: auto; min-width: 0; max-width: 100%; }
/* Grid/flex children containing wide content (tables) must be allowed to
   shrink, or they blow out the page width on mobile. */
.ops-row > *, .admin-row > *, .doctor-admin-row > *, .seed-row > *,
.summary-row > *, .compact-row > *, .admin-section > * { min-width: 0; }
.admin-table, .admin-subtable { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td, .admin-subtable th, .admin-subtable td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.admin-table th { color: var(--ink-soft); font-weight: 600; font-size: 13px; }

.audit-filter-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr)); gap: var(--space-2); align-items: end; margin-bottom: var(--space-3); }
.audit-detail { color: var(--ink-soft); font-size: 13px; word-break: break-word; }
.admin-doctor-editor, .profile-editor { display: grid; gap: var(--space-2); }
.waitlist-box { display: grid; gap: var(--space-1); }
.compact-band { background: var(--bg); border-radius: var(--radius-sm); padding: var(--space-2); font-size: 14px; color: var(--ink-soft); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  section { padding: var(--space-5) var(--space-2); }
  .hero { padding-bottom: var(--space-6); }
  .hero-grid, .public-grid, .portal-grid, .offer-strip { grid-template-columns: minmax(0, 1fr); }
  .hero-visual { justify-content: flex-start; }
  .site-nav { margin-bottom: var(--space-5); }
  .app-shell { padding: var(--space-2); padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom)); }
}
@media (max-width: 480px) {
  body { font-size: 16px; }
  .hero-actions .link-button { width: 100%; }
  .loc-row { grid-template-columns: minmax(0, 1fr); }
  .status-chip { white-space: normal; text-align: center; }
  .panel, .portal-panel, .doctor-panel, .admin-panel, .list-panel, .intake-card, .billing-card, .roi-card { padding: var(--space-3); }
}

/* ---------- Print (delivery portal) ---------- */
@media print {
  body { background: #fff; color: #000; font-size: 13px; }
  .app-nav, .no-print, button, .site-footer, .skip-link { display: none !important; }
  .portal-panel, .panel, .doctor-card { box-shadow: none; border: 1px solid #ccc; }
  section { padding: 12px 0; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  button, .link-button { transition: none; }
}

/* ---------- App shell v2 ---------- */
.loading-page, .auth-page {
  min-height: 100vh;
  background: var(--bg);
}

.loading-screen, .auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-6) var(--space-3);
}

.loading-screen {
  align-content: center;
  text-align: center;
}

.auth-card {
  width: min(100%, 520px);
  border-top: 6px solid var(--coral);
}

.auth-card h1 {
  font-size: clamp(32px, 4vw, 46px);
}

.auth-backlink {
  margin: var(--space-3) 0 0;
  text-align: center;
  font-size: 14px;
}

.access-panel {
  border-top: 6px solid var(--coral);
}

.app-shell-v2 {
  max-width: 1280px;
  min-height: 100vh;
}

.app-brand {
  color: var(--ink);
  text-decoration: none;
  display: grid;
  gap: 2px;
}

.app-brand .eyebrow {
  margin: 0;
}

.app-shell-body {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: var(--space-4);
  align-items: start;
  padding: var(--space-5) 0 var(--space-6);
}

.app-shell-body > .shell-tabs-primary,
.app-shell-body > .app-content {
  max-width: none;
  margin: 0;
  min-width: 0;
}

.app-content {
  display: grid;
  gap: var(--space-3);
}

.shell-tabs {
  gap: var(--space-1);
}

.shell-tabs-primary {
  position: sticky;
  top: var(--space-3);
  display: grid;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-2);
}

.shell-tab {
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 600;
}

.shell-tab:hover {
  background: var(--teal-tint);
  color: var(--teal-deep);
}

.shell-tab.active {
  background: var(--ink);
  color: #fff;
}

.screen-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.screen-heading h1 {
  font-size: clamp(32px, 4vw, 46px);
}

.screen-heading .panel-copy {
  margin-bottom: 0;
}

.patient-home-screen {
  padding: 0;
}

.patient-home-screen > .screen-heading,
.patient-home-screen > .dashboard-grid {
  max-width: none;
}

.referral-list .referral-item {
  min-height: 56px;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  background: var(--bg);
  color: var(--ink);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
}

.referral-list .referral-item b {
  color: var(--teal-deep);
  font-size: 13px;
  text-align: right;
}

.referral-list .referral-item.active,
.referral-list .referral-item:hover {
  background: var(--teal-tint);
  border-color: rgba(41, 163, 151, 0.22);
}

.account-panel {
  display: grid;
  gap: var(--space-3);
}

.wizard-progress {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-1);
}

.wizard-progress li {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink-soft);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
}

.wizard-progress li b {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--teal-tint);
  color: var(--teal-deep);
}

.wizard-progress li.current {
  background: var(--ink);
  color: #fff;
}

.wizard-progress li.current b {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.wizard-progress li.done {
  color: var(--teal-deep);
}

@media (max-width: 900px) {
  .auth-screen, .loading-screen {
    padding: var(--space-5) var(--space-2);
  }

  .app-shell-v2 {
    padding-bottom: calc(88px + env(safe-area-inset-bottom));
  }

  /* Mobile shell: the tab bar is STICKY, not fixed — it pins to the viewport
     bottom while scrolling but participates in layout, so it can never
     overlay/intercept content (flex `order` places it after the content in
     layout flow without changing the DOM). */
  .app-shell-body {
    display: flex;
    flex-direction: column;
    /* Desktop grid sets align-items: start; flex needs stretch so the
       content and tab bar span the full width. */
    align-items: stretch;
    padding: var(--space-4) 0 var(--space-3);
  }

  .app-shell-body > .app-content { order: 1; min-width: 0; }

  .shell-tabs-primary {
    order: 2;
    position: sticky;
    bottom: 0;
    z-index: 40;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--line);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    box-shadow: 0 -8px 24px rgba(27, 42, 50, 0.08);
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    margin-top: var(--space-3);
  }

  .shell-tabs-primary .shell-tab {
    min-height: 48px;
    justify-content: center;
    padding: 8px 6px;
    font-size: 13px;
    text-align: center;
  }

  .screen-heading {
    display: grid;
    align-items: start;
  }

  .screen-heading .link-button {
    width: 100%;
  }

  .wizard-progress {
    grid-template-columns: minmax(0, 1fr);
  }
}
