@import url("https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,400;8..60,500;8..60,600;8..60,700&family=Inter:wght@400;500;600;700&display=swap");

:root {
  --font-serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;

  /* Midnight (default theme). Dark cinematic with gold. */
  --bg: #0a1620;
  --bg-elevated: #0f1f2e;
  --sidebar-bg: #0c1a28;
  --card: #142a3d;
  --card-alt: #1a3245;

  --ink: #eef1f5;
  --ink-2: #cbd5e1;
  --muted: #94a3b8;
  --muted-2: #64748b;
  --line: #1f3a53;
  --line-soft: #172d42;

  --accent: #fbbf24;
  --accent-dark: #d99e12;
  --accent-soft: rgba(251, 191, 36, 0.18);
  --accent-tint: rgba(251, 191, 36, 0.10);

  --rose: #f87171;
  --rose-soft: rgba(248, 113, 113, 0.15);
  --gold: #fbbf24;
  --gold-dark: #f5b800;
  --gold-soft: rgba(251, 191, 36, 0.18);
  --gold-tint: rgba(251, 191, 36, 0.10);
  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, 0.15);

  --btn-fg: #0a1620;

  /* Layout constants. Must live in :root so every theme resolves them. */
  --sidebar-w: 260px;
  --topbar-h: 56px;
  --bottomnav-h: 68px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --radius-sm: 12px;
  --radius: 20px;
  --radius-lg: 26px;
  --radius-xl: 34px;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.35), 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 22px rgba(0, 0, 0, 0.45), 0 20px 40px rgba(0, 0, 0, 0.30);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.55), 0 40px 80px rgba(0, 0, 0, 0.35);
}

/* Cream: warm cream + deep burgundy. Editorial. */
body.theme-cream {
  --bg: #f7f0dd;
  --bg-elevated: #fdf9ed;
  --sidebar-bg: #fdf9ed;
  --card: #fdf9ed;
  --card-alt: #ebe1c3;
  --ink: #2a1810;
  --ink-2: #3d2a1e;
  --muted: #7a6a55;
  --muted-2: #a89880;
  --line: #d8c99f;
  --line-soft: #e5d9b5;
  --accent: #7a2f3a;
  --accent-dark: #5b2028;
  --accent-soft: rgba(122, 47, 58, 0.13);
  --accent-tint: rgba(122, 47, 58, 0.06);
  --rose: #b91c1c;
  --rose-soft: rgba(185, 28, 28, 0.10);
  --gold: #a67c25;
  --gold-dark: #7d5c1c;
  --gold-soft: rgba(166, 124, 37, 0.14);
  --gold-tint: rgba(166, 124, 37, 0.06);
  --ok: #15803d;
  --ok-soft: rgba(21, 128, 61, 0.10);
  --btn-fg: #ffffff;
}

/* Ivory: near-white + muted sage. Calming, natural. */
body.theme-ivory {
  --bg: #f8faf7;
  --bg-elevated: #ffffff;
  --sidebar-bg: #ffffff;
  --card: #ffffff;
  --card-alt: #e8eee5;
  --ink: #1a2e28;
  --ink-2: #2d443c;
  --muted: #67766f;
  --muted-2: #98a49d;
  --line: #d5ddd3;
  --line-soft: #e6ebe4;
  --accent: #5a7c66;
  --accent-dark: #3f5c48;
  --accent-soft: rgba(90, 124, 102, 0.14);
  --accent-tint: rgba(90, 124, 102, 0.06);
  --rose: #b91c1c;
  --rose-soft: rgba(185, 28, 28, 0.10);
  --gold: #a67c25;
  --gold-dark: #7d5c1c;
  --gold-soft: rgba(166, 124, 37, 0.13);
  --gold-tint: rgba(166, 124, 37, 0.05);
  --ok: #15803d;
  --ok-soft: rgba(21, 128, 61, 0.10);
  --btn-fg: #ffffff;
}

/* Sepia: warm paper + rich walnut brown. */
body.theme-sepia {
  --bg: #f2eadb;
  --bg-elevated: #faf5e8;
  --sidebar-bg: #faf5e8;
  --card: #faf5e8;
  --card-alt: #eadeba;
  --ink: #3d2a17;
  --ink-2: #5b4229;
  --muted: #7a6748;
  --muted-2: #a0906c;
  --line: #d8c8a3;
  --line-soft: #e6dab6;
  --accent: #6b3410;
  --accent-dark: #4d260b;
  --accent-soft: rgba(107, 52, 16, 0.14);
  --accent-tint: rgba(107, 52, 16, 0.06);
  --rose: #9c2222;
  --rose-soft: rgba(156, 34, 34, 0.10);
  --gold: #a3801f;
  --gold-dark: #7d5f14;
  --gold-soft: rgba(163, 128, 31, 0.14);
  --gold-tint: rgba(163, 128, 31, 0.06);
  --ok: #4d6b34;
  --ok-soft: rgba(77, 107, 52, 0.12);
  --btn-fg: #faf5e8;
}

/* Glass: frosted glassmorphism. Rich gradient background, translucent cards. */
body.theme-glass {
  --bg: #1a0f3d;
  --bg-elevated: transparent;
  --sidebar-bg: rgba(15, 10, 40, 0.55);
  --card: rgba(30, 30, 60, 0.32);
  --card-alt: rgba(255, 255, 255, 0.06);
  --ink: #f2f0ff;
  --ink-2: #d8d4ee;
  --muted: #a8a4cc;
  --muted-2: #7d789e;
  --line: rgba(255, 255, 255, 0.10);
  --line-soft: rgba(255, 255, 255, 0.05);
  --accent: #a78bfa;
  --accent-dark: #8b6fdf;
  --accent-soft: rgba(167, 139, 250, 0.20);
  --accent-tint: rgba(167, 139, 250, 0.10);
  --rose: #fb7185;
  --rose-soft: rgba(251, 113, 133, 0.16);
  --gold: #fbbf24;
  --gold-dark: #f5b800;
  --gold-soft: rgba(251, 191, 36, 0.16);
  --gold-tint: rgba(251, 191, 36, 0.08);
  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, 0.15);
  --btn-fg: #1a0f3d;
}
body.theme-glass {
  background:
    radial-gradient(circle at 12% 18%, rgba(107, 33, 168, 0.7) 0%, transparent 42%),
    radial-gradient(circle at 88% 24%, rgba(3, 105, 161, 0.7) 0%, transparent 42%),
    radial-gradient(circle at 28% 82%, rgba(131, 24, 67, 0.6) 0%, transparent 45%),
    radial-gradient(circle at 76% 88%, rgba(22, 78, 99, 0.7) 0%, transparent 45%),
    linear-gradient(135deg, #0a0724 0%, #1a1240 60%, #150b30 100%);
  background-attachment: fixed;
  min-height: 100vh;
}
body.theme-glass .card,
body.theme-glass .stat,
body.theme-glass .setup-card,
body.theme-glass .modal,
body.theme-glass .profile-hero,
body.theme-glass .provider-summary,
body.theme-glass .provider-row,
body.theme-glass .template-tile,
body.theme-glass .faq-item,
body.theme-glass .splash-card {
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.30);
}
body.theme-glass .hero-card {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.30) 0%, rgba(59, 130, 246, 0.25) 100%);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.15);
}
body.theme-glass .hero-card .amount { color: #e0b356; }
body.theme-glass .hero-card .amount-label { color: rgba(255,255,255,0.7); }
body.theme-glass .hero-card .amount-sub { color: rgba(255,255,255,0.95); }
body.theme-glass .wizard-preview {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.30) 0%, rgba(59, 130, 246, 0.25) 100%);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.15);
}
body.theme-glass .wizard-preview .n { color: #e0b356; }
body.theme-glass .wizard-preview .lbl { color: rgba(255,255,255,0.7); }
body.theme-glass .wizard-preview .items { color: rgba(255,255,255,0.9); }
body.theme-glass .sidebar {
  background: rgba(15, 10, 40, 0.55);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-right-color: rgba(255, 255, 255, 0.06);
}
body.theme-glass .top-bar {
  background: rgba(15, 10, 40, 0.55);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
}
body.theme-glass .bottom-nav {
  background: rgba(15, 10, 40, 0.7);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
}
body.theme-glass .modal-backdrop {
  background: rgba(10, 5, 30, 0.65);
}
body.theme-glass input,
body.theme-glass select,
body.theme-glass textarea {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.14);
  color: var(--ink);
}
body.theme-glass input::placeholder,
body.theme-glass textarea::placeholder { color: var(--muted-2); }
body.theme-glass .radio-group label,
body.theme-glass .check-item,
body.theme-glass .filter-bar button,
body.theme-glass .time-filter button,
body.theme-glass .coverage-multi > label {
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink-2);
  border-color: rgba(255, 255, 255, 0.10);
}
body.theme-glass .radio-group label:has(input:checked) {
  background: rgba(167, 139, 250, 0.2);
  border-color: var(--accent);
  color: var(--ink);
}
body.theme-glass .check-item:has(input:checked) {
  background: rgba(167, 139, 250, 0.15);
  border-color: var(--accent);
  color: var(--ink);
}
body.theme-glass .disclaimer {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.10);
}
body.theme-glass .theme-select-btn {
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-color: rgba(255, 255, 255, 0.14);
  color: var(--ink);
}
body.theme-glass .theme-menu {
  background: rgba(15, 12, 40, 0.92);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}
body.theme-glass .theme-option:hover {
  background: rgba(255, 255, 255, 0.08);
}
body.theme-glass .theme-option.active {
  background: rgba(167, 139, 250, 0.18);
}
body.theme-glass .theme-preview {
  border-color: rgba(255, 255, 255, 0.14);
}
body.theme-glass .add-provider-btn {
  background: rgba(255, 255, 255, 0.04);
  color: var(--accent);
  border-color: rgba(167, 139, 250, 0.4);
}
body.theme-glass .empty {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.14);
}
body.theme-glass .danger-card {
  background: rgba(251, 113, 133, 0.08);
  border-color: rgba(251, 113, 133, 0.30);
}

/* Onyx: pure black + creamy gold. Restrained luxury. */
body.theme-onyx {
  --bg: #000000;
  --bg-elevated: #0a0a0a;
  --sidebar-bg: #0a0a0a;
  --card: #141414;
  --card-alt: #1c1c1c;
  --ink: #f5f5f4;
  --ink-2: #d6d3d1;
  --muted: #a8a29e;
  --muted-2: #78716c;
  --line: #262626;
  --line-soft: #171717;
  --accent: #c5a555;
  --accent-dark: #9d8340;
  --accent-soft: rgba(197, 165, 85, 0.18);
  --accent-tint: rgba(197, 165, 85, 0.08);
  --rose: #fb7185;
  --rose-soft: rgba(251, 113, 133, 0.15);
  --gold: #c5a555;
  --gold-dark: #9d8340;
  --gold-soft: rgba(197, 165, 85, 0.18);
  --gold-tint: rgba(197, 165, 85, 0.08);
  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, 0.15);
  --btn-fg: #000000;
}

/* Slate: cool gray + rich violet. Modern professional. */
body.theme-slate {
  --bg: #eef1f5;
  --bg-elevated: #ffffff;
  --sidebar-bg: #ffffff;
  --card: #ffffff;
  --card-alt: #dfe4ec;
  --ink: #0f172a;
  --ink-2: #1e293b;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #cbd5e1;
  --line-soft: #e2e8f0;
  --accent: #7c3aed;
  --accent-dark: #6828d1;
  --accent-soft: rgba(124, 58, 237, 0.13);
  --accent-tint: rgba(124, 58, 237, 0.05);
  --rose: #dc2626;
  --rose-soft: rgba(220, 38, 38, 0.10);
  --gold: #b45309;
  --gold-dark: #92400e;
  --gold-soft: rgba(180, 83, 9, 0.12);
  --gold-tint: rgba(180, 83, 9, 0.05);
  --ok: #15803d;
  --ok-soft: rgba(21, 128, 61, 0.10);
  --btn-fg: #ffffff;
}

/* Forest: cream + deep forest green. Nature. */
body.theme-forest {
  --bg: #f5efdb;
  --bg-elevated: #ffffff;
  --sidebar-bg: #ffffff;
  --card: #ffffff;
  --card-alt: #e6dcbf;
  --ink: #14342b;
  --ink-2: #244a3e;
  --muted: #5c7a6f;
  --muted-2: #8ba398;
  --line: #d5c9a4;
  --line-soft: #e6dcbc;
  --accent: #2d5a3b;
  --accent-dark: #1e4028;
  --accent-soft: rgba(45, 90, 59, 0.15);
  --accent-tint: rgba(45, 90, 59, 0.06);
  --rose: #a13e2b;
  --rose-soft: rgba(161, 62, 43, 0.12);
  --gold: #9c6b1a;
  --gold-dark: #74501a;
  --gold-soft: rgba(156, 107, 26, 0.14);
  --gold-tint: rgba(156, 107, 26, 0.06);
  --ok: #2d5a3b;
  --ok-soft: rgba(45, 90, 59, 0.12);
  --btn-fg: #ffffff;
}

/* Contrast: off-white + indigo. Bold minimal. */
body.theme-contrast {
  --bg: #fafafa;
  --bg-elevated: #ffffff;
  --sidebar-bg: #ffffff;
  --card: #ffffff;
  --card-alt: #f0f0f0;
  --ink: #0a0a0a;
  --ink-2: #1f1f1f;
  --muted: #6b7280;
  --muted-2: #9ca3af;
  --line: #e5e5e5;
  --line-soft: #f3f3f3;
  --accent: #6366f1;
  --accent-dark: #4f46e5;
  --accent-soft: rgba(99, 102, 241, 0.12);
  --accent-tint: rgba(99, 102, 241, 0.05);
  --rose: #dc2626;
  --rose-soft: rgba(220, 38, 38, 0.10);
  --gold: #b45309;
  --gold-dark: #92400e;
  --gold-soft: rgba(180, 83, 9, 0.12);
  --gold-tint: rgba(180, 83, 9, 0.05);
  --ok: #15803d;
  --ok-soft: rgba(21, 128, 61, 0.10);
  --btn-fg: #ffffff;

  --male: #2e5199;
  --male-soft: #d9e3f5;
  --female: #9d3e6e;
  --female-soft: #f5d9e5;

  --radius-sm: 12px;
  --radius: 20px;
  --radius-lg: 26px;
  --radius-xl: 34px;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.35), 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 22px rgba(0, 0, 0, 0.45), 0 20px 40px rgba(0, 0, 0, 0.30);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.55), 0 40px 80px rgba(0, 0, 0, 0.35);

  --sidebar-w: 260px;
  --topbar-h: 56px;
  --bottomnav-h: 68px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Motion. Respects reduced-motion. */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}
img, svg { display: block; max-width: 100%; }

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--ink);
}
h1 { font-size: clamp(32px, 4.5vw, 48px); line-height: 1.05; letter-spacing: -0.028em; }
h2 { font-size: clamp(24px, 3vw, 32px); line-height: 1.12; }
h3 { font-size: 19px; line-height: 1.3; }
em { font-style: italic; color: var(--accent); }
p { color: var(--ink-2); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }

/* Splash */
.splash {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(251, 191, 36, 0.10) 0%, transparent 55%),
    radial-gradient(ellipse at 70% 80%, rgba(59, 130, 246, 0.08) 0%, transparent 55%),
    var(--bg);
}
.splash-card {
  background: var(--card);
  border-radius: 32px;
  padding: 56px 44px 44px;
  max-width: 480px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
}
.splash-mark {
  width: 84px;
  height: 84px;
  border-radius: 24px;
  overflow: hidden;
  margin: 0 auto 24px;
  display: inline-block;
  box-shadow: 0 14px 32px rgba(15, 35, 64, 0.22), 0 4px 8px rgba(15, 35, 64, 0.12);
}
.splash-mark svg { width: 100%; height: 100%; display: block; }
.splash h1 {
  font-family: var(--font-sans);
  font-size: 38px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.028em;
  color: var(--ink);
}
.splash .tagline {
  color: var(--muted);
  font-size: 15px;
  margin-bottom: 32px;
}
.splash-features {
  text-align: left;
  margin-bottom: 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.splash-feature {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 14.5px;
  color: var(--ink-2);
}
.splash-feature .tile {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--accent-tint);
  color: var(--accent-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.splash-feature .tile svg { width: 16px; height: 16px; }
.splash .btn { width: 100%; justify-content: center; }
.splash-fine { margin-top: 14px; font-size: 12.5px; color: var(--muted); }

/* App shell */
.app-frame { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px 22px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-sans);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  overflow: hidden;
  display: inline-flex;
  flex-shrink: 0;
}
.brand-mark svg { width: 100%; height: 100%; display: block; }
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
}
.sidebar-item:hover { background: var(--card-alt); color: var(--ink); }
.sidebar-item.active { background: var(--accent); color: var(--btn-fg); }
.sidebar-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.sidebar-footer {
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid var(--line-soft);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--ink);
}
.sidebar-user:hover { background: var(--card-alt); color: var(--ink); }
.sidebar-user.active { background: var(--accent); color: var(--btn-fg); }
.sidebar-user.active .sidebar-user-name,
.sidebar-user.active .sidebar-user-meta { color: var(--btn-fg); }
.sidebar-user.active .sidebar-avatar { background: rgba(255,255,255,0.2); color: var(--btn-fg); }

.sidebar-secondary {
  display: flex;
  gap: 16px;
  padding: 10px 12px 0;
  margin-top: 8px;
  border-top: 1px solid var(--line-soft);
  padding-top: 12px;
}
.sidebar-secondary-link {
  font-size: 12.5px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.12s;
}
.sidebar-secondary-link:hover { color: var(--ink); }
.sidebar-secondary-link.active { color: var(--accent); }
.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gold-tint);
  color: var(--gold-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}
.sidebar-user-info { min-width: 0; flex: 1; }
.sidebar-user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-user-meta { font-size: 12px; color: var(--muted); }

.top-bar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-h);
  background: rgba(10, 22, 32, 0.85);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  z-index: 30;
  padding: 0 16px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s, background 0.15s;
}
.top-bar.scrolled { border-bottom-color: var(--line); }
.top-bar .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 17px;
  text-decoration: none;
  letter-spacing: -0.02em;
}
.top-bar .brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}
.top-bar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gold-tint);
  color: var(--gold-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
}

.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--bottomnav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(12, 26, 40, 0.94);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
  z-index: 30;
}
.bottom-nav-inner {
  display: flex;
  height: var(--bottomnav-h);
  align-items: stretch;
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted-2);
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
  padding-top: 4px;
}
.bottom-nav-item svg { width: 22px; height: 22px; }
.bottom-nav-item.active { color: var(--ink); }

.app-main { flex: 1; padding: 40px 64px 80px; min-width: 0; }
.app-container { max-width: 1360px; margin: 0 auto; }
.page-title { margin: 8px 0 8px; }
.page-subtitle { color: var(--muted); font-size: 16px; margin-bottom: 36px; line-height: 1.55; }
.greeting-time {
  color: var(--gold-dark);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.section-title {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 500;
  margin: 40px 0 18px;
  color: var(--ink);
  display: flex;
  align-items: baseline;
  gap: 10px;
  letter-spacing: -0.015em;
}
.section-title .count {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  background: var(--card-alt);
  padding: 2px 8px;
  border-radius: 999px;
}

/* Calendar sync card on dashboard */
.sync-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 26px 26px 26px 26px;
  margin-bottom: 24px;
  display: flex;
  gap: 20px;
  align-items: flex-start;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.15s, transform 0.15s;
}
.sync-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  background: var(--card-alt);
  color: var(--muted);
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  transition: background 0.15s, color 0.15s;
}
.sync-close:hover { background: var(--rose-soft); color: var(--rose); }
.sync-close svg { width: 16px; height: 16px; }
.sync-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.sync-card::after {
  content: "";
  position: absolute;
  top: -30%;
  right: -10%;
  width: 40%;
  height: 160%;
  background: radial-gradient(ellipse, var(--accent-tint) 0%, transparent 65%);
  pointer-events: none;
}
.sync-card > * { position: relative; z-index: 1; }
.sync-icon-wrap {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--accent-tint);
  color: var(--accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
}
.sync-icon-wrap svg { width: 28px; height: 28px; }
.sync-body { flex: 1; min-width: 0; }
.sync-eyebrow {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-dark);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.sync-body h3 {
  font-family: var(--font-serif);
  font-size: clamp(20px, 3vw, 26px);
  line-height: 1.15;
  margin-bottom: 10px;
  color: var(--ink);
  letter-spacing: -0.015em;
}
.sync-body p {
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink-2);
  margin-bottom: 12px;
}
.sync-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 14px 0 16px;
}
.sync-step {
  background: var(--card-alt);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.4;
}
.sync-step .step-n {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 500;
  color: var(--accent-dark);
  margin-bottom: 4px;
  display: block;
}
@media (max-width: 700px) {
  .sync-card { flex-direction: column; gap: 14px; padding: 22px; }
  .sync-icon-wrap { width: 48px; height: 48px; }
  .sync-steps { grid-template-columns: 1fr; gap: 6px; }
  .sync-step { display: flex; gap: 10px; align-items: baseline; }
  .sync-step .step-n { margin-bottom: 0; }
}

/* Hero card. Adapts to theme via accent-tinted gradient. */
.hero-card {
  background: linear-gradient(135deg, var(--accent-tint) 0%, var(--card-alt) 100%);
  color: var(--ink);
  border: 1px solid var(--accent-soft);
  border-radius: 24px;
  padding: 32px 30px;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.hero-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
}
.hero-card::after {
  content: "";
  position: absolute;
  top: -50%;
  right: -20%;
  width: 60%;
  height: 200%;
  background: radial-gradient(ellipse, var(--accent-soft) 0%, transparent 65%);
  pointer-events: none;
}
.hero-card > * { position: relative; z-index: 1; }
.hero-card .amount {
  font-family: var(--font-serif);
  font-size: clamp(40px, 5vw, 56px);
  font-weight: 500;
  line-height: 1;
  color: var(--accent-dark);
  letter-spacing: -0.02em;
}
.hero-card .amount-label { color: var(--muted); font-size: 13px; margin-top: 10px; font-weight: 500; letter-spacing: 0.02em; }
.hero-card .amount-sub { color: var(--ink-2); font-size: 15px; margin-top: 6px; font-weight: 500; }
.hero-card .btn { flex-shrink: 0; background: var(--accent); color: var(--btn-fg); }
.hero-card:hover .btn { background: var(--accent-dark); }

/* Stats */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}
@media (max-width: 640px) { .stat-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; } }
.stat {
  background: var(--card);
  padding: 22px 20px;
  border-radius: 20px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-xs);
  min-height: 108px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.stat .n {
  font-family: var(--font-serif);
  font-size: 44px;
  font-weight: 500;
  line-height: 1;
  color: var(--ink);
  letter-spacing: -0.025em;
}
.stat .n.danger { color: var(--rose); }
.stat .n.warn { color: var(--gold); }
.stat .n.accent { color: var(--gold-dark); }
.stat .label { font-size: 12.5px; color: var(--muted); margin-top: 8px; line-height: 1.25; }

.stat.clickable {
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}
.stat.clickable:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  border-color: var(--ink);
}
.stat.clickable:active { transform: translateY(0); }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
  animation: fadeInUp 0.28s ease both;
}
.card:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); border-color: rgba(251, 191, 36, 0.25); }
.stat, .hero-card, .feature, .template-tile, .faq-item, .empty {
  animation: fadeInUp 0.28s ease both;
}
.stat-grid > *:nth-child(1) { animation-delay: 0.02s; }
.stat-grid > *:nth-child(2) { animation-delay: 0.06s; }
.stat-grid > *:nth-child(3) { animation-delay: 0.10s; }
.card:nth-of-type(1) { animation-delay: 0.04s; }
.card:nth-of-type(2) { animation-delay: 0.08s; }
.card:nth-of-type(3) { animation-delay: 0.12s; }
.card:nth-of-type(4) { animation-delay: 0.16s; }
.card:nth-of-type(5) { animation-delay: 0.20s; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
.card:hover { box-shadow: var(--shadow-sm); }
.card.overdue { border-left: 4px solid var(--rose); }
.card.soon { border-left: 4px solid var(--gold); }
.card.done { opacity: 0.55; }

.card-head {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.card-body { flex: 1; min-width: 0; }
.card-title {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 500;
  margin-bottom: 3px;
  color: var(--ink);
  line-height: 1.25;
}
.card-cat {
  font-size: 11.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
  margin-bottom: 4px;
}
.card-status { flex-shrink: 0; text-align: right; min-width: 110px; }
.card-status .lastdone { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.card .desc { color: var(--ink-2); font-size: 13.5px; margin: 10px 0 4px; line-height: 1.5; }
.card .where { color: var(--muted); font-size: 12.5px; font-style: italic; }

.cat-tile {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent-tint);
  color: var(--accent-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cat-tile svg { width: 22px; height: 22px; }
/* Category tile colors, default (midnight/dark). Overridden per-theme below. */
.cat-tile.cardiovascular { background: rgba(248, 113, 113, 0.14); color: #fca5a5; }
.cat-tile.metabolic     { background: rgba(96, 165, 250, 0.14); color: #93c5fd; }
.cat-tile.cancer        { background: rgba(251, 191, 36, 0.14); color: #fcd34d; }
.cat-tile.bone          { background: rgba(167, 139, 250, 0.14); color: #c4b5fd; }
.cat-tile.dental        { background: rgba(45, 212, 191, 0.14); color: #5eead4; }
.cat-tile.vision        { background: rgba(129, 140, 248, 0.14); color: #a5b4fc; }
.cat-tile.mental-health { background: rgba(244, 114, 182, 0.14); color: #f9a8d4; }
.cat-tile.vaccines      { background: rgba(74, 222, 128, 0.14); color: #86efac; }

/* Light themes get proper pastel backgrounds. */
body.theme-cream    .cat-tile.cardiovascular, body.theme-ivory .cat-tile.cardiovascular,
body.theme-sepia    .cat-tile.cardiovascular, body.theme-contrast .cat-tile.cardiovascular
                     { background: #fee2e2; color: #b91c1c; }
body.theme-cream    .cat-tile.metabolic, body.theme-ivory .cat-tile.metabolic,
body.theme-sepia    .cat-tile.metabolic, body.theme-contrast .cat-tile.metabolic
                     { background: #dbeafe; color: #1e40af; }
body.theme-cream    .cat-tile.cancer, body.theme-ivory .cat-tile.cancer,
body.theme-sepia    .cat-tile.cancer, body.theme-contrast .cat-tile.cancer
                     { background: #fef3c7; color: #92400e; }
body.theme-cream    .cat-tile.bone, body.theme-ivory .cat-tile.bone,
body.theme-sepia    .cat-tile.bone, body.theme-contrast .cat-tile.bone
                     { background: #ede9fe; color: #6d28d9; }
body.theme-cream    .cat-tile.dental, body.theme-ivory .cat-tile.dental,
body.theme-sepia    .cat-tile.dental, body.theme-contrast .cat-tile.dental
                     { background: #cffafe; color: #0e7490; }
body.theme-cream    .cat-tile.vision, body.theme-ivory .cat-tile.vision,
body.theme-sepia    .cat-tile.vision, body.theme-contrast .cat-tile.vision
                     { background: #e0e7ff; color: #3730a3; }
body.theme-cream    .cat-tile.mental-health, body.theme-ivory .cat-tile.mental-health,
body.theme-sepia    .cat-tile.mental-health, body.theme-contrast .cat-tile.mental-health
                     { background: #fce7f3; color: #9d174d; }
body.theme-cream    .cat-tile.vaccines, body.theme-ivory .cat-tile.vaccines,
body.theme-sepia    .cat-tile.vaccines, body.theme-contrast .cat-tile.vaccines
                     { background: #d1fae5; color: #065f46; }

/* Light-theme pill and badge colors */
body.theme-cream .pill.overdue, body.theme-ivory .pill.overdue,
body.theme-sepia .pill.overdue, body.theme-contrast .pill.overdue { background: #fee2e2; color: #b91c1c; }
body.theme-cream .pill.soon, body.theme-ivory .pill.soon,
body.theme-sepia .pill.soon, body.theme-contrast .pill.soon { background: #fef3c7; color: #92400e; }
body.theme-cream .pill.done, body.theme-ivory .pill.done,
body.theme-sepia .pill.done, body.theme-contrast .pill.done { background: #dcfce7; color: #15803d; }
body.theme-cream .cov-badge.covered, body.theme-ivory .cov-badge.covered,
body.theme-sepia .cov-badge.covered, body.theme-contrast .cov-badge.covered { background: #dcfce7; color: #15803d; }
body.theme-cream .cov-badge.shared, body.theme-ivory .cov-badge.shared,
body.theme-sepia .cov-badge.shared, body.theme-contrast .cov-badge.shared { background: #fef3c7; color: #92400e; }
body.theme-cream .cov-badge.self, body.theme-ivory .cov-badge.self,
body.theme-sepia .cov-badge.self, body.theme-contrast .cov-badge.self { background: var(--accent-tint); color: var(--accent-dark); }
body.theme-cream .cash-pill, body.theme-ivory .cash-pill,
body.theme-sepia .cash-pill, body.theme-contrast .cash-pill { background: #fef3c7; color: #92400e; }
body.theme-cream .history-note, body.theme-ivory .history-note,
body.theme-sepia .history-note, body.theme-contrast .history-note { background: #eef2ff; color: #3730a3; }

.pill.overdue { background: rgba(248, 113, 113, 0.18); color: #fca5a5; }
.pill.soon    { background: rgba(251, 191, 36, 0.18); color: #fcd34d; }
.pill.done    { background: rgba(74, 222, 128, 0.18); color: #86efac; }
.pill.male    { background: rgba(96, 165, 250, 0.18); color: #93c5fd; }
.pill.female  { background: rgba(244, 114, 182, 0.18); color: #f9a8d4; }
.pill         { background: var(--accent-soft); color: var(--accent); }

.cov-badge.covered { background: rgba(74, 222, 128, 0.16); color: #86efac; }
.cov-badge.shared  { background: rgba(251, 191, 36, 0.16); color: #fcd34d; }
.cov-badge.self    { background: rgba(96, 165, 250, 0.16); color: #93c5fd; }
.cov-badge.dental  { background: rgba(45, 212, 191, 0.16); color: #5eead4; }
.cov-badge.vision  { background: rgba(129, 140, 248, 0.16); color: #a5b4fc; }
.cash-pill { background: rgba(251, 191, 36, 0.16); color: #fcd34d; }
.cash-pill.emphasized { background: rgba(251, 191, 36, 0.28); color: #fde68a; border: 1px solid rgba(251, 191, 36, 0.4); }
.history-note { background: rgba(129, 140, 248, 0.14); color: #a5b4fc; }

.pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--accent-soft);
  color: var(--accent-dark);
  white-space: nowrap;
}
.pill.overdue { background: var(--rose-soft); color: var(--rose); }
.pill.soon { background: var(--gold-soft); color: var(--gold); }
.pill.done { background: var(--ok-soft); color: var(--ok); }
.pill.male { background: var(--male-soft); color: var(--male); }
.pill.female { background: var(--female-soft); color: var(--female); }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border-radius: 12px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 14.5px;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  background: var(--ink);
  color: var(--bg);
  transition: background 0.15s, color 0.15s, transform 0.1s, box-shadow 0.15s, border-color 0.15s;
  white-space: nowrap;
}
button:active, .btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); color: var(--btn-fg); }
.btn.primary:hover { background: var(--accent-dark); color: var(--btn-fg); }
.btn.accent { background: var(--accent); color: var(--btn-fg); }
.btn.accent:hover { background: var(--accent-dark); }
.btn.ghost, button.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn.ghost:hover, button.ghost:hover { border-color: var(--accent); background: var(--card-alt); color: var(--ink); }
button.danger { background: var(--rose); color: white; }
button.danger:hover { filter: brightness(0.9); }
.btn.lg { padding: 15px 26px; font-size: 15.5px; border-radius: 14px; }
.btn.sm, button.small { padding: 8px 14px; font-size: 12.5px; border-radius: 10px; }
button.icon-only {
  padding: 8px;
  border-radius: 10px;
  min-width: 40px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

/* Forms */
label {
  display: block;
  font-size: 13.5px;
  font-weight: 500;
  margin: 18px 0 6px;
  color: var(--ink);
}
input[type="text"], input[type="date"], input[type="number"], select, textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  font-family: var(--font-sans);
  background: var(--card);
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.radio-group { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-group label {
  flex: 1;
  min-width: 100px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  margin: 0;
  background: var(--card);
  color: var(--ink);
  text-align: center;
  transition: all 0.15s;
  font-weight: 500;
}
.radio-group label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-tint);
  color: var(--accent-dark);
}
.radio-group input { display: none; }

.filter-bar {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
  scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar { display: none; }
.filter-bar button {
  background: var(--card);
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  flex-shrink: 0;
}
.filter-bar button.active {
  background: var(--accent);
  color: var(--btn-fg);
  border-color: var(--accent);
}

.time-filter {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 16px 0 12px;
}
.time-filter button {
  background: var(--card);
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
}
.time-filter button.active {
  background: var(--accent);
  color: var(--btn-fg);
  border-color: var(--accent);
}

/* Progress bar. Empty state hides the fill entirely to avoid artifacts. */
.progress {
  height: 8px;
  background: var(--line-soft);
  border-radius: 999px;
  overflow: hidden;
  margin: 12px 0 4px;
}
.progress-bar {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s;
  border-radius: 999px;
}
.progress-bar.full { background: var(--ok); }
.progress-bar.empty { display: none; }

.empty {
  padding: 44px 24px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--card);
}
.empty h3 {
  font-family: var(--font-serif);
  font-size: 22px;
  margin-bottom: 6px;
  color: var(--ink);
}
.empty p { font-size: 14px; color: var(--muted); }

.disclaimer {
  font-size: 12px;
  color: var(--muted);
  padding: 14px 16px;
  background: var(--card-alt);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  margin-top: 32px;
  line-height: 1.55;
}
.disclaimer strong { color: var(--ink); }

.feedback-line {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin: 20px 0 4px;
}
.feedback-line a { color: var(--accent); font-weight: 600; }

/* Cash price pill */
.cash-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  background: #f2e6cc;
  color: #7d5b1f;
}
.cash-pill.emphasized {
  background: #fef3c7;
  color: #7a4a0f;
  border: 1px solid #f3d788;
}

/* Progressive-disclosure collapse (uses native <details>) */
.collapse {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line-soft);
}
.collapse > summary {
  cursor: pointer;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}
.collapse > summary::-webkit-details-marker { display: none; }
.collapse > summary::before {
  content: "+";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--card-alt);
  color: var(--muted);
  font-weight: 500;
  font-size: 16px;
  transition: transform 0.15s, background 0.15s;
}
.collapse[open] > summary::before {
  content: "\2212";
  background: var(--accent-tint);
  color: var(--accent-dark);
}
.collapse .collapse-body { padding-top: 14px; }

/* Accessibility: consistent focus-visible */
button:focus-visible,
.btn:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.sidebar-item:focus-visible,
.bottom-nav-item:focus-visible,
.template-tile:focus-visible,
.check-item:focus-visible,
.stat.clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Print styles for doctor visit summary */
@media print {
  html, body { background: white !important; color: black !important; }
  .sidebar, .top-bar, .bottom-nav, .actions, .filter-bar, .time-filter, .modal-backdrop, .toast,
  button, .btn, .disclaimer, .greeting-time { display: none !important; }
  .app-frame { display: block; }
  .app-main { padding: 0 !important; }
  .app-container { max-width: 100% !important; }
  .card, .stat, .hero-card, .setup-card {
    box-shadow: none !important;
    border: 1px solid #cccccc !important;
    break-inside: avoid;
    animation: none !important;
    background: white !important;
    color: black !important;
    page-break-inside: avoid;
  }
  .card-title, h1, h2, h3, .section-title { color: black !important; }
  a { color: black !important; text-decoration: none !important; }
  .card-status .pill { border: 1px solid #999 !important; background: white !important; color: black !important; }
  .cat-tile { display: none !important; }
  .card-head { gap: 0 !important; }
}

/* Coverage badge */
.cov-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.cov-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--ok-soft);
  color: var(--ok);
  white-space: nowrap;
}
.cov-badge.covered { background: var(--ok-soft); color: var(--ok); }
.cov-badge.shared  { background: var(--gold-soft); color: var(--gold); }
.cov-badge.self    { background: var(--accent-soft); color: var(--accent-dark); }
.cov-badge.dental  { background: #cfe5e8; color: #1c5a63; }
.cov-badge.vision  { background: #dcd8ef; color: #3a3078; }
.cov-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}
.cov-note { font-size: 12px; color: var(--muted); line-height: 1.4; }

.uses-list { margin-top: 12px; list-style: none; border-top: 1px solid var(--line-soft); }
.uses-list li {
  padding: 8px 0;
  color: var(--muted);
  font-size: 13px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.uses-list li:last-child { border-bottom: none; }
.uses-list .remove {
  background: none;
  color: var(--muted);
  border: none;
  padding: 2px 8px;
  font-size: 16px;
  cursor: pointer;
  border-radius: 4px;
}
.uses-list .remove:hover { color: var(--rose); background: var(--rose-soft); }

.setup-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 30px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}
.setup-card .form-hint {
  font-size: 12.5px;
  color: var(--muted);
  margin: -3px 0 6px;
  line-height: 1.45;
}
@media (max-width: 640px) { .setup-card { padding: 22px; } }

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.template-tile {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  cursor: pointer;
  text-align: left;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-height: 108px;
}
.template-tile:hover {
  border-color: var(--gold);
  transform: translateY(-3px);
  box-shadow: var(--shadow-sm);
}
.template-tile .tt-name { font-family: var(--font-serif); font-size: 16px; font-weight: 500; }
.template-tile .tt-meta { color: var(--muted); font-size: 12.5px; font-weight: 400; }
.template-tile .tt-add {
  color: var(--gold-dark);
  font-size: 12px;
  font-weight: 600;
  margin-top: auto;
}

/* Provider row on setup */
.provider-row {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  margin-bottom: 8px;
}
.provider-row-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.provider-row-head input, .provider-row-head select { flex: 1; margin: 0; min-width: 0; }
.provider-row .remove-provider {
  background: var(--card-alt);
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.provider-row .remove-provider:hover {
  color: var(--rose);
  border-color: var(--rose);
}
.coverage-multi {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.coverage-multi > label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  margin: 0;
  background: var(--card-alt);
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.coverage-multi > label:has(input:checked) {
  background: var(--accent-tint);
  color: var(--accent-dark);
  border-color: var(--accent);
}
.coverage-multi input {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
}
.coverage-multi-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}
.add-provider-btn {
  background: transparent;
  color: var(--accent);
  border: 1px dashed rgba(251, 191, 36, 0.4);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
}
.add-provider-btn:hover { border-color: var(--accent); border-style: solid; }

/* Profile view page */
.profile-hero {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 26px;
  margin-bottom: 24px;
  background: linear-gradient(135deg, var(--card) 0%, var(--card-alt) 100%);
  border-radius: 24px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.profile-hero-info { flex: 1; min-width: 0; }
.profile-hero-info h2 {
  margin-bottom: 4px;
  font-size: clamp(24px, 3vw, 30px);
  line-height: 1.15;
}
.profile-hero-info p {
  color: var(--muted);
  font-size: 14.5px;
}
.profile-avatar-big {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--gold-tint);
  color: var(--gold-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 32px;
  flex-shrink: 0;
  box-shadow: 0 6px 16px rgba(166, 124, 37, 0.18);
}
.info-list { display: flex; flex-direction: column; }
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14.5px;
}
.info-row:first-child { padding-top: 0; }
.info-row:last-child { border-bottom: none; padding-bottom: 0; }
.info-row .lbl { color: var(--muted); }
.info-row .val { color: var(--ink); font-weight: 500; text-align: right; }
.info-row .val.empty { color: var(--muted-2); font-style: italic; font-weight: 400; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 5px 12px;
  background: var(--card-alt);
  color: var(--ink);
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
}
.provider-summary {
  padding: 16px 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-xs);
}
.provider-summary .name {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 500;
  color: var(--ink);
}
.provider-summary .types {
  margin-top: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.provider-summary .type-chip {
  font-size: 10.5px;
  padding: 3px 8px;
  background: var(--accent-tint);
  color: var(--accent-dark);
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.provider-summary .type-chip.dental   { background: #cfe5e8; color: #1c5a63; }
.provider-summary .type-chip.vision   { background: #dcd8ef; color: #3a3078; }
.provider-summary .type-chip.extended { background: var(--gold-tint); color: var(--gold-dark); }

.danger-card {
  background: rgba(248, 113, 113, 0.06);
  border: 1px solid rgba(248, 113, 113, 0.25);
}

/* Theme selector dropdown */
.theme-select-wrap {
  position: relative;
  margin-top: 8px;
}
.theme-select-btn {
  width: 100%;
  padding: 14px 16px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  font-family: var(--font-sans);
  color: var(--ink);
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.theme-select-btn:hover { border-color: var(--accent); }
.theme-select-btn[aria-expanded="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.theme-preview {
  width: 52px;
  height: 32px;
  border-radius: 8px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  flex-shrink: 0;
  border: 1px solid var(--line-soft);
}
.theme-preview span { display: block; width: 100%; height: 100%; }
.theme-current-label { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.theme-current-name {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.15;
}
.theme-current-desc { font-size: 12.5px; color: var(--muted); }
.theme-select-btn .chevron {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--muted);
  transition: transform 0.15s;
}
.theme-select-btn[aria-expanded="true"] .chevron { transform: rotate(180deg); }

.theme-menu {
  position: fixed;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  max-height: 420px;
  overflow-y: auto;
  padding: 6px;
  animation: fadeInUp 0.15s ease both;
}
.theme-menu[hidden] { display: none; }
.theme-option {
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-family: var(--font-sans);
  color: var(--ink);
  text-align: left;
  transition: background 0.12s;
}
.theme-option:hover { background: var(--card-alt); }
.theme-option .theme-preview {
  width: 42px;
  height: 26px;
  border-radius: 6px;
}
.theme-option .theme-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.theme-option .theme-name { font-size: 14.5px; font-weight: 500; color: var(--ink); }
.theme-option .theme-desc { font-size: 12px; color: var(--muted); }
.theme-option .theme-check {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--accent);
  visibility: hidden;
}
.theme-option.active { background: var(--accent-tint); }
.theme-option.active .theme-check { visibility: visible; }
.danger-card button.danger {
  background: var(--rose);
  color: white;
}

/* Onboarding wizard */
.wizard {
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 24px 60px;
}
.wizard-progress {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 44px;
  padding-top: 20px;
}
.wizard-dot {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  transition: background 0.25s, transform 0.25s;
}
.wizard-dot.active { background: var(--gold); transform: scaleX(1.15); transform-origin: left center; }
.wizard-dot.done { background: var(--ink); }
.wizard-step {
  display: none;
  animation: fadeInUp 0.3s ease both;
}
.wizard-step.active { display: block; }
.wizard-eyebrow {
  color: var(--gold-dark);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 14px;
}
.wizard-step h2 {
  font-size: clamp(30px, 4.5vw, 40px);
  line-height: 1.05;
  letter-spacing: -0.025em;
  margin-bottom: 14px;
  color: var(--ink);
}
.wizard-step .step-sub {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
  margin-bottom: 36px;
}
.wizard-step label {
  margin-top: 16px;
}
.wizard-nav {
  display: flex;
  gap: 10px;
  margin-top: 40px;
  align-items: center;
}
.wizard-nav .btn.primary { flex: 1; }
.wizard-nav .back,
.wizard-nav .skip {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 12px 14px;
  cursor: pointer;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 14px;
  border-radius: 8px;
}
.wizard-nav .back:hover,
.wizard-nav .skip:hover { color: var(--ink); background: var(--card-alt); }
.wizard-mark {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 24px;
  display: inline-block;
  box-shadow: 0 8px 20px rgba(15, 35, 64, 0.16);
}
.wizard-mark svg { width: 100%; height: 100%; display: block; }
.wizard-preview {
  background: linear-gradient(135deg, var(--accent-tint) 0%, var(--card-alt) 100%);
  color: var(--ink);
  border: 1px solid var(--accent-soft);
  border-radius: 24px;
  padding: 28px;
  margin: 20px 0;
  box-shadow: var(--shadow-md);
}
.wizard-preview .n {
  font-family: var(--font-serif);
  font-size: 48px;
  color: var(--accent-dark);
  line-height: 1;
  font-weight: 500;
}
.wizard-preview .lbl {
  color: var(--muted);
  font-size: 14px;
  margin-top: 8px;
}
.wizard-preview .items {
  margin-top: 16px;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.7;
}

/* Checkbox list (used for family history) */
.checkbox-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  cursor: pointer;
  margin: 0;
  font-weight: 500;
  font-size: 13.5px;
  transition: border-color 0.15s, background 0.15s;
  color: var(--ink-2);
}
.check-item:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-tint);
  color: var(--accent-dark);
}
.check-item input[type="checkbox"] {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
  flex-shrink: 0;
}

/* Screening card reason chip */
.history-note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 4px 10px;
  background: #eef2ff;
  color: #3730a3;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 500;
}
.history-note::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

/* Provider tag on benefit card */
.prov-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  background: var(--accent-tint);
  color: var(--accent-dark);
  border: 1px solid var(--accent-soft);
  cursor: pointer;
  margin-top: 6px;
}
.prov-tag.untagged {
  background: var(--card-alt);
  color: var(--muted);
  border: 1px dashed var(--line);
}
.prov-tag:hover { border-color: var(--accent); background: var(--accent-tint); color: var(--accent-dark); }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(14, 31, 28, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  animation: fadeIn 0.15s ease forwards;
}
@keyframes fadeIn { to { opacity: 1; } }
.modal {
  background: var(--bg-elevated);
  color: var(--ink);
  border-radius: 20px;
  padding: 28px;
  border: 1px solid var(--line);
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  transform: translateY(10px);
  animation: slideUp 0.2s ease forwards;
}
@keyframes slideUp { to { transform: translateY(0); } }
.modal h3 { font-family: var(--font-serif); font-size: 22px; margin-bottom: 6px; }
.modal .modal-sub { color: var(--muted); font-size: 14px; margin-bottom: 16px; }
.modal .modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  justify-content: flex-end;
}

.toast {
  position: fixed;
  bottom: calc(20px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  /* var(--bg) inverts correctly in every theme. A literal white was invisible
     on the light --ink of the midnight and glass themes. */
  color: var(--bg);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  z-index: 200;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
@media (max-width: 900px) {
  .toast { bottom: calc(var(--bottomnav-h) + 20px + var(--safe-bottom)); }
}

/* How-to steps (About page) */
.how-step {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 16px 0;
  border-bottom: 1px solid var(--line-soft);
}
.how-step:first-of-type { padding-top: 4px; }
.how-step:last-of-type { border-bottom: none; padding-bottom: 4px; }
.how-step .step-num {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--accent-tint);
  color: var(--accent-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 16px;
}
.how-step .step-body { flex: 1; min-width: 0; }
.how-step h4 {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 6px;
  line-height: 1.3;
}
.how-step p {
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.55;
  margin: 0;
}
.how-step p + p { margin-top: 6px; }

.about-hero {
  padding: 8px 0 24px;
}
.about-hero .eyebrow {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.about-hero h1 {
  font-size: clamp(34px, 5vw, 48px);
  margin-bottom: 14px;
}
.about-hero p {
  font-size: 17px;
  color: var(--muted);
  line-height: 1.6;
  max-width: 640px;
}
.info-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 640px) {
  .info-two-col { grid-template-columns: 1fr; }
}
.info-two-col .card { margin-bottom: 0; }
.info-two-col h4 {
  font-family: var(--font-serif);
  font-size: 17px;
  color: var(--ink);
  margin-bottom: 8px;
}
.info-two-col p {
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-2);
}

/* FAQ */
.faq-list { display: flex; flex-direction: column; gap: 8px; }
.faq-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.faq-q {
  padding: 16px 20px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 500;
  color: var(--ink);
  user-select: none;
}
.faq-q::after {
  content: "+";
  font-family: var(--font-sans);
  font-size: 22px;
  font-weight: 400;
  color: var(--muted);
  flex-shrink: 0;
  transition: transform 0.2s;
}
.faq-item.open .faq-q::after { transform: rotate(45deg); }
.faq-a {
  padding: 0 20px 20px;
  color: var(--ink-2);
  font-size: 14.5px;
  line-height: 1.6;
  display: none;
}
.faq-item.open .faq-a { display: block; }
.faq-a p { margin-bottom: 10px; color: var(--ink-2); }
.faq-a p:last-child { margin-bottom: 0; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .top-bar { display: flex; }
  .bottom-nav { display: block; }
  .app-main {
    padding: calc(var(--topbar-h) + 20px) 18px calc(var(--bottomnav-h) + 32px + var(--safe-bottom));
  }
  .app-container { max-width: 100%; }
  h1 { font-size: 28px; }
  .card-status { min-width: auto; }
  .stat { padding: 14px 12px; min-height: 84px; }
  .stat .n { font-size: 28px; }
  .stat .label { font-size: 11.5px; }
  .cat-tile { width: 40px; height: 40px; }
  .cat-tile svg { width: 20px; height: 20px; }
  .hero-card { flex-direction: column; align-items: flex-start; }
  .hero-card .btn { width: 100%; justify-content: center; }
  .home-header { top: calc(var(--topbar-h) + 12px); }
  .filter-bar { flex-wrap: wrap; overflow-x: visible; }
  .card .actions button, .card .actions .btn {
    flex: 1 1 calc(50% - 4px);
    justify-content: center;
    text-align: center;
  }
}
@media (min-width: 901px) {
  .top-bar, .bottom-nav { display: none !important; }
}

/* ---------------------------------------------------------------------------
   Home page header (sticky) + tabs
   --------------------------------------------------------------------------- */
.home-header {
  position: sticky;
  top: 16px;
  z-index: 30;
  margin: 0 0 28px;
  padding: 22px 26px 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 12px 32px -18px rgba(0, 0, 0, 0.35), 0 2px 4px -2px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.home-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding-bottom: 18px;
}
.home-hero-left { flex: 1; min-width: 0; }
.home-hero-left .greeting-time { margin-bottom: 2px; }
.home-hero-left .page-title { margin: 0 0 4px; }
.home-hero-left .page-subtitle { margin: 0; }
.home-hero-right { flex-shrink: 0; }
.home-score-mini {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  min-width: 96px;
  transition: border-color 0.15s;
}
.home-score-mini.ok     { border-color: rgba(74, 222, 128, 0.4); }
.home-score-mini.warn   { border-color: rgba(251, 191, 36, 0.4); }
.home-score-mini.danger { border-color: rgba(248, 113, 113, 0.4); }
.home-score-mini-num {
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 500;
  line-height: 1;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.home-score-mini.ok     .home-score-mini-num { color: #22a35a; }
.home-score-mini.warn   .home-score-mini-num { color: var(--gold-dark); }
.home-score-mini.danger .home-score-mini-num { color: var(--rose); }
.home-score-mini-lbl {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 600;
}

.tabs {
  display: flex;
  gap: 2px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  margin: 0 -4px;
}
.tab {
  flex: 1;
  padding: 12px 12px 14px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  border-radius: 0;
}
.tab:hover { color: var(--ink-2); }
.tab.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}
.tab-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--btn-fg, #0f2340);
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tab-badge.danger { background: var(--rose); color: #fff; }

@media (max-width: 640px) {
  .home-header { margin: 0 0 20px; padding: 16px 16px 0; top: calc(var(--topbar-h) + 8px); border-radius: 16px; }
  .home-hero { flex-direction: row; gap: 12px; align-items: center; padding-bottom: 12px; }
  .home-hero-left .page-title { font-size: 24px; }
  .home-hero-left .page-subtitle { display: none; }
  .home-score-mini { padding: 8px 14px; min-width: 76px; }
  .home-score-mini-num { font-size: 24px; }
  .tab { font-size: 13px; padding: 10px 6px 12px; }
}
@media (max-width: 400px) {
  .home-score-mini { min-width: 60px; padding: 8px 10px; }
  .home-hero { gap: 8px; }
  .radio-group label { min-width: calc(50% - 4px); }
  .checkbox-list { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------------------
   Catch-up card (Timeline tab)
   --------------------------------------------------------------------------- */
.catchup-card {
  background: linear-gradient(135deg, var(--accent-tint), var(--card-alt));
  border: 1px solid var(--accent-soft);
  border-radius: 20px;
  padding: 24px 26px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-xs);
}
.catchup-eyebrow {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-dark);
  font-weight: 700;
  margin-bottom: 6px;
}
.catchup-head h3 {
  margin: 0 0 6px;
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.catchup-head p {
  margin: 0 0 16px;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.55;
}
.catchup-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.catchup-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.15s, background 0.15s;
}
.catchup-chip:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  background: var(--card-alt);
}
.catchup-chip-name { font-weight: 500; color: var(--ink); }
.catchup-chip-cta {
  font-size: 11.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent-dark);
  font-weight: 700;
}

/* ---------------------------------------------------------------------------
   Health Score card
   --------------------------------------------------------------------------- */
.score-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 24px 28px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  box-shadow: var(--shadow-xs);
  animation: fadeInUp 0.28s ease both;
}
.score-card.ok      { border-color: rgba(110, 180, 140, 0.35); }
.score-card.warn    { border-color: rgba(251, 191, 36, 0.35); }
.score-card.danger  { border-color: rgba(248, 113, 113, 0.35); }
.score-ring {
  position: relative;
  flex-shrink: 0;
  width: 120px;
  height: 120px;
}
.score-ring svg { transform: rotate(-90deg); }
.score-ring circle {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
}
.score-ring-bg { stroke: var(--line); }
.score-ring-fg {
  stroke: var(--accent);
  transition: stroke-dashoffset 0.6s ease;
}
.score-card.ok     .score-ring-fg { stroke: #4ade80; }
.score-card.warn   .score-ring-fg { stroke: var(--gold); }
.score-card.danger .score-ring-fg { stroke: var(--rose); }
.score-value {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.score-num {
  font-family: var(--font-serif);
  font-size: 40px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.score-den {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.score-body { flex: 1; min-width: 0; }
.score-eyebrow {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.score-body h3 {
  margin: 0 0 6px;
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.score-body p {
  margin: 0;
  color: var(--ink-2);
  font-size: 14.5px;
  line-height: 1.5;
}
@media (max-width: 640px) {
  .score-card { flex-direction: column; text-align: center; padding: 22px 20px; gap: 16px; }
  .score-ring { width: 100px; height: 100px; }
  .score-num { font-size: 34px; }
}

/* ---------------------------------------------------------------------------
   Next Recommended Action panel
   --------------------------------------------------------------------------- */
.next-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}
.next-action {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-xs);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  animation: fadeInUp 0.28s ease both;
}
.next-action:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.next-action.screening-overdue  { border-left: 4px solid var(--rose); }
.next-action.benefit-expiring   { border-left: 4px solid var(--gold); }
.next-action.screening-soon     { border-left: 4px solid var(--accent-dark); }
.next-action-marker {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-tint);
  color: var(--accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 16px;
}
.next-action-body { flex: 1; min-width: 0; }
.next-action-title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 4px;
  line-height: 1.35;
}
.next-action-detail {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.45;
}
.next-action-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
@media (max-width: 640px) {
  .next-action { flex-direction: column; gap: 10px; padding: 16px; }
  .next-action-buttons { flex-direction: row; width: 100%; }
  .next-action-buttons > * { flex: 1; }
}

/* ---------------------------------------------------------------------------
   12-month timeline (redesigned)
   --------------------------------------------------------------------------- */
.timeline-hint {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 18px;
  line-height: 1.5;
}
.timeline {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 8px;
}
@media (max-width: 900px) { .timeline { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .timeline { grid-template-columns: repeat(2, 1fr); } }

.tl-month {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 14px 12px;
  min-height: 108px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.12s, box-shadow 0.15s, border-color 0.15s;
}
.tl-month:hover:not(.empty) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  border-color: var(--accent-soft);
}
.tl-month.empty {
  background: transparent;
  border-style: dashed;
  border-color: var(--line-soft);
}
.tl-month.current {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.tl-month-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.tl-month-name {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.tl-month-year {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 600;
}
.tl-count {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tl-items {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-content: flex-start;
}
.tl-chip {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--card-alt);
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.35;
  border: 1px solid var(--line-soft);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tl-month.current .tl-chip {
  background: var(--accent-tint);
  color: var(--accent-dark);
  border-color: var(--accent-soft);
  font-weight: 500;
}
.tl-empty-label {
  font-size: 12px;
  color: var(--muted-2);
  font-style: italic;
}

/* ---------------------------------------------------------------------------
   Learn more link on screening cards
   --------------------------------------------------------------------------- */
.learn-more {
  display: inline-block;
  margin-top: 8px;
  font-size: 13px;
  color: var(--accent-dark);
  text-decoration: none;
  font-weight: 500;
}
.learn-more:hover { text-decoration: underline; }

/* ---------------------------------------------------------------------------
   Roadmap / investor page
   --------------------------------------------------------------------------- */
.roadmap-hero {
  padding: 40px 0 32px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 32px;
}
.roadmap-hero .eyebrow {
  font-size: 11.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-dark);
  margin-bottom: 12px;
}
.roadmap-hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(32px, 5vw, 46px);
  font-weight: 500;
  letter-spacing: -0.02em;
  margin: 0 0 14px;
  color: var(--ink);
}
.roadmap-hero p {
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink-2);
  max-width: 640px;
  margin: 0;
}
.phase {
  padding: 28px 0;
  border-bottom: 1px solid var(--line);
}
.phase:last-of-type { border-bottom: none; }
.phase-header {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.phase-badge {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent-dark);
  font-weight: 600;
}
.phase-badge.now  { background: rgba(74, 222, 128, 0.18); color: #22a35a; }
.phase-badge.next { background: var(--accent-tint); color: var(--accent-dark); }
.phase-badge.future { background: rgba(148, 163, 184, 0.18); color: var(--muted); }
.phase-header h2 {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 500;
  margin: 0;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.phase-header .phase-sub {
  color: var(--muted);
  font-size: 14px;
}
.phase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.phase-item {
  padding: 16px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.phase-item h4 {
  margin: 0 0 6px;
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
}
.phase-item p {
  margin: 0;
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.5;
}
.phase-item.done h4::before {
  content: "✓";
  color: #22a35a;
  margin-right: 6px;
  font-weight: 600;
}
.revenue-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.revenue-item {
  padding: 18px 20px;
  background: var(--card-alt);
  border-radius: 14px;
  border: 1px solid var(--line);
}
.revenue-item .rev-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-dark);
  font-weight: 600;
  margin-bottom: 8px;
}
.revenue-item h4 {
  margin: 0 0 6px;
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 500;
  color: var(--ink);
}
.revenue-item p {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.5;
}
.arch-note {
  margin-top: 24px;
  padding: 20px 24px;
  border-left: 3px solid var(--accent);
  background: var(--accent-tint);
  border-radius: 0 12px 12px 0;
  font-size: 14.5px;
  color: var(--ink-2);
  line-height: 1.6;
}

/* ---------------------------------------------------------------------------
   Emergency Card
   --------------------------------------------------------------------------- */
.ec-card {
  background: var(--card);
  border: 2px solid var(--rose);
  border-radius: 20px;
  padding: 28px 28px 22px;
  box-shadow: var(--shadow-md);
  animation: fadeInUp 0.28s ease both;
  max-width: 640px;
  margin: 0 auto 24px;
}
.ec-section-value:not(.empty):not(.multiline) {
  display: inline-block;
}
.ec-header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.ec-cross {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--rose);
  color: white;
  font-size: 30px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ec-header h2 {
  margin: 4px 0 2px;
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.ec-eyebrow {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--rose);
  font-weight: 700;
}
.ec-meta {
  font-size: 13.5px;
  color: var(--muted);
}
.ec-section {
  padding: 12px 0;
  border-bottom: 1px dashed var(--line);
}
.ec-section:last-child { border-bottom: none; }
.ec-section-label {
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
}
.ec-section-value {
  font-size: 16px;
  color: var(--ink);
  line-height: 1.5;
}
.ec-section-value.multiline { white-space: normal; }
.ec-section-value.empty { color: var(--muted-2); font-style: italic; font-size: 14px; }
.ec-phone {
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--accent-dark);
  text-decoration: none;
  font-weight: 500;
}
.ec-phone:hover { text-decoration: underline; }
.ec-tip {
  margin-top: 20px;
  padding: 14px 18px;
  background: var(--accent-tint);
  border-radius: 12px;
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.55;
}
.ec-field {
  display: block;
  margin-bottom: 14px;
}
.ec-field:last-child { margin-bottom: 0; }
.ec-field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.ec-field input,
.ec-field textarea {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card-alt);
  color: var(--ink);
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.5;
  box-sizing: border-box;
}
.ec-field input:focus,
.ec-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------------------------------------------------------------------------
   Costs table
   --------------------------------------------------------------------------- */
.costs-hero {
  margin-bottom: 24px;
}
.costs-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
@media (max-width: 640px) { .costs-summary { grid-template-columns: 1fr; } }
.cost-summary-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 22px;
}
.cost-summary-card .lbl {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
}
.cost-summary-card .val {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1;
  letter-spacing: -0.02em;
}
.cost-summary-card.savings .val { color: #22a35a; }
.cost-summary-card .sub {
  color: var(--muted);
  font-size: 13.5px;
  margin-top: 6px;
}
.costs-table {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}
.cost-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  align-items: center;
}
.cost-row:last-child { border-bottom: none; }
.cost-row-name {
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 500;
}
.cost-row-cash {
  color: var(--ink-2);
  font-size: 14px;
  font-family: var(--font-serif);
  font-weight: 500;
}
.cost-row-insured {
  color: #22a35a;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-serif);
}
.cost-row-insured.pay { color: var(--gold-dark); }
.cost-head {
  background: var(--card-alt);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 10px 18px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}
@media (max-width: 640px) {
  .cost-row, .cost-head { grid-template-columns: 1fr auto; }
  .cost-row-insured, .cost-head span:last-child { display: none; }
}

/* ---------------------------------------------------------------------------
   Quick theme picker (upper right)
   --------------------------------------------------------------------------- */
.theme-quick-btn {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink-2);
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.theme-quick-btn:hover { color: var(--ink); border-color: var(--accent); }
.theme-quick-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.theme-quick-btn.desktop {
  position: fixed;
  top: 18px;
  right: 22px;
  z-index: 40;
  box-shadow: var(--shadow-xs);
}
@media (max-width: 900px) {
  .theme-quick-btn.desktop { display: none; }
}
.top-bar-right { display: flex; align-items: center; gap: 10px; }
.top-bar .theme-quick-btn { background: transparent; border-color: transparent; color: var(--ink-2); }
.theme-quick-menu {
  position: fixed;
  top: calc(var(--topbar-h) + 8px);
  right: 14px;
  z-index: 95;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px;
  box-shadow: var(--shadow-md);
  width: 190px;
  max-height: 70vh;
  overflow-y: auto;
}
@media (min-width: 901px) {
  .theme-quick-menu { top: 64px; right: 22px; }
}
.theme-quick-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 10px;
  background: transparent;
  border: none;
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.theme-quick-item:hover { background: var(--card-alt); color: var(--ink); }
.theme-quick-item.active { background: var(--accent-tint); color: var(--ink); }
.tq-swatches { display: inline-flex; gap: 3px; flex-shrink: 0; }
.tq-swatches i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(128, 128, 128, 0.35);
}

/* ---------------------------------------------------------------------------
   PWA install prompt
   --------------------------------------------------------------------------- */
.pwa-install {
  position: fixed;
  bottom: calc(92px + var(--safe-bottom));
  left: 20px;
  right: 20px;
  max-width: 420px;
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--accent);
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: var(--shadow-lg);
  z-index: 90;
  display: none;
  align-items: center;
  gap: 12px;
  animation: fadeInUp 0.28s ease both;
}
.pwa-install.visible { display: flex; }
.pwa-install-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent-tint);
  color: var(--accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
}
.pwa-install-body {
  flex: 1;
  min-width: 0;
}
.pwa-install-title {
  font-weight: 600;
  font-size: 14.5px;
  color: var(--ink);
  margin-bottom: 2px;
}
.pwa-install-sub {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.4;
}
.pwa-install-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.pwa-install-actions button {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}
.pwa-install-actions button.primary {
  background: var(--accent);
  color: var(--btn-fg, #0f2340);
  border-color: var(--accent);
  font-weight: 600;
}
@media (min-width: 901px) {
  .pwa-install { bottom: 20px; }
}

/* ---------------------------------------------------------------------------
   Why page (investor pitch)
   --------------------------------------------------------------------------- */
.why-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin: 16px 0 20px;
}
.why-stat {
  padding: 22px 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.why-stat-num {
  font-family: var(--font-serif);
  font-size: 40px;
  font-weight: 500;
  line-height: 1;
  color: var(--accent-dark);
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}
.why-stat-lbl {
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.5;
}
.why-para {
  color: var(--ink-2);
  font-size: 15.5px;
  line-height: 1.65;
  margin: 0 0 16px;
  max-width: 780px;
}
.why-callout {
  padding: 20px 26px;
  background: var(--accent-tint);
  border-left: 3px solid var(--accent);
  border-radius: 0 14px 14px 0;
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
  margin: 16px 0 20px;
}
.how-grid, .method-grid, .impact-grid, .who-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.how-item, .method-item, .who-item {
  padding: 18px 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  position: relative;
}
.how-item h4, .method-item h4, .who-item h4, .impact-item h4 {
  margin: 0 0 6px;
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.how-item p, .method-item p, .who-item p, .impact-item p {
  margin: 0;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.55;
}
.how-num, .method-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-tint);
  color: var(--accent-dark);
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 15px;
  margin-bottom: 10px;
}
.story-card {
  padding: 24px 28px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  max-width: 780px;
}
.story-card p {
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.65;
  margin: 0 0 12px;
}
.story-card p:last-child { margin-bottom: 0; }
.story-card strong { color: var(--accent-dark); font-weight: 600; }
.impact-item {
  padding: 20px 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.impact-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent-tint);
  color: var(--accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
}
.impact-icon svg { width: 22px; height: 22px; }

/* ---- Date of birth: typed entry (Month / Day / Year) --------------------- */
.field-hint {
  font-size: 12.5px;
  color: var(--muted);
  margin: 0 0 10px;
}
.dob-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: nowrap;
}
.dob-part { flex: 0 0 auto; }
.dob-sub {
  display: block;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  margin: 0 0 5px;
  letter-spacing: 0.02em;
}
.wizard-step .dob-sub { margin-top: 0; }
/* 17px keeps iOS Safari from zooming the page when a field takes focus */
input.dob-input {
  width: 70px;
  text-align: center;
  font-size: 17px;
  letter-spacing: 0.06em;
  padding: 11px 8px;
}
input.dob-input-year { width: 94px; }
.dob-sep {
  font-size: 18px;
  color: var(--muted-2);
  padding-bottom: 11px;
}
.dob-calendar {
  margin-left: 4px;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.dob-calendar:hover { border-color: var(--accent); color: var(--accent); }
.dob-calendar:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.dob-calendar svg { width: 20px; height: 20px; }
/* The native date input stays in the DOM as the canonical value. It is only
   revealed if the browser has no showPicker() support. */
input.dob-native {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  pointer-events: none;
}
input.dob-native.dob-native-visible {
  position: static;
  opacity: 1;
  width: 100%;
  height: auto;
  padding: 11px 14px;
  border: 1px solid var(--line);
  pointer-events: auto;
  margin-top: 10px;
}
@media (max-width: 380px) {
  input.dob-input { width: 60px; font-size: 16px; padding: 11px 6px; }
  input.dob-input-year { width: 80px; }
  .dob-calendar { width: 40px; height: 40px; }
  .dob-sep { padding-bottom: 10px; }
}

/* ---- In-app field errors (replaces browser alert dialogs) ---------------- */
.field-error {
  display: block;
  margin: 10px 0 0;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--rose);
  background: var(--rose-soft);
  border: 1px solid var(--rose-soft);
  border-radius: 8px;
}
.field-error[hidden] { display: none; }
input.dob-input.has-error { border-color: var(--rose); }
input.dob-input.has-error:focus {
  border-color: var(--rose);
  box-shadow: 0 0 0 3px var(--rose-soft);
}

/* ---- Date of birth on narrow screens ------------------------------------ */
/* The three boxes share the row and stretch; the calendar drops below as a
   full-width labelled button, rather than an icon squeezed against the year. */
@media (max-width: 480px) {
  .dob-row { flex-wrap: wrap; gap: 6px; }
  .dob-part { flex: 1 1 0; min-width: 0; }
  .dob-part-year { flex: 1.5 1 0; }
  input.dob-input,
  input.dob-input-year { width: 100%; }
  .dob-calendar {
    flex: 1 0 100%;
    width: auto;
    height: 46px;
    margin-left: 0;
    margin-top: 12px;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font-sans);
    color: var(--ink-2);
  }
  .dob-calendar-label { display: inline; }
}
.dob-calendar-label { display: none; }

/* ---- Landing page: theme switcher + calmer card ------------------------- */
.splash-theme-btn {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 96;
}
/* The feature icons sit unboxed on the splash. The filled tiles competed with
   the logo mark and made the card read as cluttered. */
.splash-feature > svg {
  flex-shrink: 0;
  width: 17px;
  height: 17px;
  margin-top: 2px;
  color: var(--accent);
  opacity: 0.85;
}
.splash-feature { gap: 11px; align-items: flex-start; }
.splash-features { gap: 10px; margin-bottom: 26px; }
.splash-links {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted-2);
}
.splash-links a {
  color: var(--muted);
  text-decoration: none;
}
.splash-links a:hover { color: var(--accent); text-decoration: underline; }
@media (max-width: 480px) {
  .splash-theme-btn { top: 12px; right: 12px; }
}

/* ===========================================================================
   2026-09-21 sprint: mobile overflow fix, accessibility, family mode, track
   page, print summary.
   =========================================================================== */

/* ---- Mobile overflow ---------------------------------------------------- */
/* Root cause of the sideways drag: badges were nowrap and a personalised
   coverage label ("Usually covered by your X plan, discuss with doctor") ran
   wider than a phone. Let them wrap. The clip on <html> is a second line of
   defence: unlike overflow-x:hidden it does not create a scroll container, so
   sticky headers and iOS momentum scrolling are unaffected. */
html { overflow-x: clip; }
.cov-badge, .cash-pill, .history-note { white-space: normal; text-align: left; }
.cov-badge { max-width: 100%; }
.card-title, .next-action-title, .tl-chip { overflow-wrap: anywhere; }
@media (max-width: 900px) {
  .tabs { margin: 0; }
  .card .actions button, .card .actions .btn { min-width: 0; }
}

/* ---- Accessibility ------------------------------------------------------ */
.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 1000;
  padding: 10px 14px;
  background: var(--accent);
  color: var(--btn-fg);
  border-radius: 10px;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.15s;
}
.skip-link:focus { top: 12px; outline: 2px solid var(--ink); outline-offset: 2px; }
.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;
}
/* Touch targets: 44px is the WCAG / Apple minimum. */
@media (max-width: 900px) {
  button.small, .btn.sm, .btn.small, .filter-bar button, .time-filter button,
  .catchup-chip, .prov-tag, .theme-quick-item, .people-menu-item, .tab { min-height: 44px; }
  .uses-list .remove, .time-row .remove, .data-table .remove { min-width: 44px; min-height: 44px; }
  .bottom-nav-item { min-height: 44px; }
}
/* Focus ring everywhere it was missing. */
.top-bar-avatar:focus-visible, .people-chip:focus-visible, .people-menu-item:focus-visible,
.theme-quick-btn:focus-visible, .theme-quick-item:focus-visible, .theme-option:focus-visible,
.theme-select-btn:focus-visible, .prov-tag:focus-visible, .catchup-chip:focus-visible,
.dose-check input:focus-visible, .sync-close:focus-visible, .remove:focus-visible,
.tab:focus-visible, .learn-more:focus-visible, .tracker-link:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"], input.has-error {
  border-color: var(--rose);
}
input.has-error:focus { border-color: var(--rose); box-shadow: 0 0 0 3px var(--rose-soft); }
/* Muted-2 was below 4.5:1 on the midnight background for small text. */
:root { --muted-2: #7b8aa0; }
body.theme-onyx { --muted-2: #8a8a8a; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ---- Family mode --------------------------------------------------------- */
.top-bar-avatar { border: none; cursor: pointer; padding: 0; font-family: var(--font-serif); }
.people-chip-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--gold-tint); color: var(--gold-dark);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-serif); font-weight: 600; font-size: 13px; flex-shrink: 0;
}
.people-chip-avatar svg { width: 16px; height: 16px; }
.sidebar-people { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px 4px; }
.people-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 4px; border-radius: 999px;
  background: transparent; border: 1px solid var(--line);
  color: var(--ink-2); font-size: 12.5px; font-weight: 500; text-decoration: none; cursor: pointer;
}
.people-chip:hover { background: var(--card-alt); color: var(--ink); }
.people-chip.add .people-chip-avatar { background: var(--card-alt); color: var(--muted); }
.people-menu {
  position: fixed; top: calc(var(--topbar-h) + 6px); right: 12px; z-index: 60;
  background: var(--bg-elevated); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow-lg); padding: 8px; min-width: 240px; max-width: calc(100vw - 24px);
}
.people-menu[hidden] { display: none; }
.people-menu-title { font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 8px 10px 6px; }
.people-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border-radius: 10px; border: none; background: transparent;
  color: var(--ink); font-size: 14px; text-align: left; text-decoration: none; cursor: pointer;
  white-space: normal;
}
.people-menu-item:hover { background: var(--card-alt); }
.people-menu-item.active { background: var(--accent-tint); }
.people-menu-name { flex: 1; }
.people-menu-check { color: var(--accent-dark); font-weight: 700; }
.people-list { display: flex; flex-direction: column; gap: 8px; }
.people-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card-alt);
}
.people-row.active { border-color: var(--accent-soft); }
.people-row-info { flex: 1; min-width: 0; }
.people-row-name { font-weight: 600; font-size: 14.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.people-row-meta { font-size: 12.5px; color: var(--muted); }
.people-row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 480px) {
  .people-row { flex-wrap: wrap; }
  .people-row-actions { width: 100%; justify-content: flex-start; }
}
body.theme-glass .people-menu, body.theme-glass .people-row { background: rgba(255,255,255,0.08); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }

/* ---- Track page + dashboard trackers ------------------------------------- */
.tracker-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 24px; }
@media (max-width: 900px) { .tracker-grid { grid-template-columns: 1fr; } }
.tracker-card { margin-bottom: 0; display: flex; flex-direction: column; gap: 8px; }
.tracker-card p { font-size: 13.5px; color: var(--muted); line-height: 1.5; margin: 0; }
.tracker-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.tracker-title { font-family: var(--font-serif); font-size: 17px; color: var(--ink); }
.tracker-sub { font-size: 13px; color: var(--muted); margin: 0; }
.tracker-link { font-size: 13.5px; font-weight: 600; color: var(--accent-dark); text-decoration: none; margin-top: auto; }
.tracker-link:hover { text-decoration: underline; }
.muted-card { border-style: dashed; }
.bp-big { font-family: var(--font-serif); font-size: 40px; line-height: 1; color: var(--ink); letter-spacing: -0.02em; }
.bp-slash { color: var(--muted-2); margin: 0 2px; }
.bp-unit { font-family: var(--font-sans); font-size: 13px; color: var(--muted); margin-left: 8px; letter-spacing: 0; }
.bp-form { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 640px) { .bp-form { grid-template-columns: 1fr 1fr; } }
.form-hint-inline { font-weight: 400; color: var(--muted-2); font-size: 12px; }
.bp-result { border-left: 4px solid var(--ok); }
.bp-result.warn { border-left-color: var(--gold); }
.bp-result.danger { border-left-color: var(--rose); }
.bp-result-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.bp-advice { font-size: 14.5px; color: var(--ink-2); line-height: 1.55; margin: 10px 0 0; }
.bp-advice.muted { color: var(--muted); font-size: 13.5px; }
.bp-guideline { font-size: 12.5px; color: var(--muted-2); margin: 12px 0 0; line-height: 1.5; }
.bp-guideline a { color: var(--muted); }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.data-table td { padding: 8px; border-bottom: 1px solid var(--line-soft); color: var(--ink-2); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table .remove { background: transparent; border: none; color: var(--muted); font-size: 18px; padding: 4px 8px; cursor: pointer; border-radius: 8px; }
.data-table .remove:hover { background: var(--rose-soft); color: var(--rose); }
@media (max-width: 640px) {
  .data-table th:nth-child(3), .data-table td:nth-child(3) { display: none; }
  .data-table { font-size: 13px; }
}
.dose-list { list-style: none; padding: 0; margin: 4px 0 0; display: flex; flex-direction: column; gap: 4px; }
.dose-item { border-radius: 10px; }
.dose-item.taken .dose-name { text-decoration: line-through; color: var(--muted); }
.dose-item.late .dose-time { color: var(--rose); }
.dose-check { display: flex; align-items: center; gap: 10px; padding: 8px 6px; cursor: pointer; font-size: 14.5px; color: var(--ink); border-radius: 10px; }
.dose-check:hover { background: var(--card-alt); }
.dose-check input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); flex-shrink: 0; }
.dose-time { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink-2); min-width: 46px; }
.dose-name { flex: 1; }
.dose-dose { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.time-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.time-row { display: flex; align-items: center; gap: 6px; }
.time-row input { flex: 1; margin: 0; }
.time-row .remove { background: transparent; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); font-size: 18px; width: 40px; height: 40px; cursor: pointer; flex-shrink: 0; }
.phq { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px 8px; margin: 14px 0 0; }
.phq legend { font-size: 14px; font-weight: 500; color: var(--ink); padding: 0 6px; }
.phq-options { margin-top: 4px; }
.flag-list { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 8px; }
.flag { padding: 10px 12px; border-radius: 10px; font-size: 14px; line-height: 1.5; color: var(--ink-2); background: var(--card-alt); border-left: 3px solid var(--gold); }
.flag.danger { border-left-color: var(--rose); }
.guideline-stamp { margin-top: 14px; font-size: 13px; font-weight: 600; color: var(--accent-dark); }
.guideline-log { margin-top: 8px; font-size: 13.5px; color: var(--ink-2); }
.guideline-log summary { cursor: pointer; color: var(--muted); font-weight: 500; }
.guideline-log ul { margin: 8px 0 0 18px; line-height: 1.6; }
.guideline-log li + li { margin-top: 6px; }
.disclaimer a { color: inherit; }

/* ---- Native shell: respect the iPhone status bar / notch ----------------- */
/* The viewport meta already has viewport-fit=cover, so the web view extends
   under the status bar. Every fixed/sticky element pinned to the top needs
   the inset added, otherwise the clock covers the brand and theme button. */
:root { --safe-top: env(safe-area-inset-top, 0px); }
.top-bar {
  height: calc(var(--topbar-h) + var(--safe-top));
  padding-top: var(--safe-top);
}
.people-menu { top: calc(var(--topbar-h) + var(--safe-top) + 6px); }
.theme-quick-menu { top: calc(var(--topbar-h) + var(--safe-top) + 8px); }
.theme-quick-btn.desktop { top: calc(18px + var(--safe-top)); }
.splash-theme-btn { top: calc(18px + var(--safe-top)); }
@media (max-width: 900px) {
  /* Only pages with a top bar reserve room for it. The first-run wizard has
     no navigation, so it just clears the status bar. */
  .app-main { padding-top: calc(var(--safe-top) + 12px); }
  body.has-nav .app-main { padding-top: calc(var(--topbar-h) + var(--safe-top) + 20px); }
  .home-header { top: calc(var(--topbar-h) + var(--safe-top) + 12px); }
}

/* ---- Date of birth calendar: real input overlaid on the button ---------- */
.dob-calendar { position: relative; overflow: hidden; }
input.dob-native,
input.dob-native.dob-native-visible {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: auto;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  font-size: 16px; /* stops iOS zooming on focus */
}
.dob-calendar:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Insurer type-to-search ---------------------------------------------- */
.suggest-wrap { position: relative; flex: 1; min-width: 0; }
.suggest-wrap input { width: 100%; margin: 0; font-size: 16px; }
.suggest-list {
  position: absolute;
  left: 0; right: 0; top: calc(100% + 4px);
  z-index: 40;
  margin: 0; padding: 6px;
  list-style: none;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  max-height: 260px;
  overflow-y: auto;
}
.suggest-list[hidden] { display: none; }
.suggest-list li {
  padding: 11px 12px;
  border-radius: 8px;
  font-size: 14.5px;
  color: var(--ink);
  cursor: pointer;
  display: block;
  line-height: 22px; /* 22 + 2×11 padding = 44px touch target */
}
.suggest-list li:hover, .suggest-list li.active { background: var(--card-alt); }
.suggest-list mark { background: transparent; color: var(--accent-dark); font-weight: 600; }
.provider-row { overflow: visible; }
body.theme-glass .suggest-list { background: rgba(30, 20, 60, 0.92); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }

/* ---- Wizard nav: Back and Skip as outlined pills matching Continue ------- */
.wizard-nav .back,
.wizard-nav .skip,
.wizard-nav a.skip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 15px 20px;
  min-height: 52px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 14px;
  text-decoration: none;
  white-space: nowrap;
}
.wizard-nav .back:hover,
.wizard-nav .skip:hover { color: var(--ink); background: var(--card-alt); border-color: var(--muted-2); }
.wizard-nav .back:focus-visible,
.wizard-nav .skip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wizard-nav .btn.primary.lg { min-height: 52px; }
@media (max-width: 900px) {
  .wizard-progress { padding-top: 32px; }
}

/* ---- Print: the doctor summary replaces the screen ---------------------- */
#print-summary { display: none; }
@media print {
  @page { margin: 16mm; }
  body.is-printing > *:not(#print-summary) { display: none !important; }
  body.is-printing { background: white !important; color: black !important; }
  #print-summary {
    display: block !important;
    font-family: Georgia, "Times New Roman", serif;
    color: #111;
    font-size: 11.5pt;
    line-height: 1.45;
  }
  #print-summary p, #print-summary td, #print-summary th, #print-summary div, #print-summary section { color: inherit; }
  #print-summary p { margin: 0 0 6pt; }
  #print-summary h1 { font-size: 22pt; margin: 0 0 2pt; color: #111; }
  #print-summary h2 { font-size: 13pt; margin: 16pt 0 6pt; padding-bottom: 3pt; border-bottom: 1px solid #999; color: #111; }
  #print-summary section { break-inside: avoid; }
  .ps-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #111; padding-bottom: 8pt; margin-bottom: 8pt; }
  .ps-brand { font-family: Helvetica, Arial, sans-serif; font-size: 9pt; letter-spacing: 0.08em; text-transform: uppercase; color: #555; }
  .ps-meta { font-size: 10.5pt; color: #333; }
  .ps-generated { font-family: Helvetica, Arial, sans-serif; font-size: 9pt; color: #555; text-align: right; }
  .ps-table { width: 100%; border-collapse: collapse; font-size: 10pt; }
  .ps-table th { text-align: left; font-family: Helvetica, Arial, sans-serif; font-size: 8.5pt; text-transform: uppercase; letter-spacing: 0.04em; color: #444; padding: 4pt 6pt; border-bottom: 1px solid #999; }
  .ps-table td { padding: 5pt 6pt; border-bottom: 1px solid #ddd; vertical-align: top; }
  .ps-table tr.overdue td:nth-child(2) { font-weight: 700; }
  .ps-note { font-size: 8.5pt; color: #555; margin-top: 2pt; }
  .ps-foot { margin-top: 18pt; padding-top: 8pt; border-top: 1px solid #999; font-family: Helvetica, Arial, sans-serif; font-size: 8.5pt; color: #555; }
}

/* ---------------------------------------------------------------------------
   Collapsible cards (28 Sep 2026 density pass). Closed: title, meta, pill,
   one primary action. Open: everything else. See renderScreeningCard() in app.js.
   --------------------------------------------------------------------------- */
.card { padding: 16px 18px; }
.card-toggle {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  width: 100%;
  padding: 0;
  margin: 0;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.card-toggle:hover, .card-toggle:active { background: none; box-shadow: none; transform: none; color: inherit; }
.card-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 8px; }
.card-toggle .card-title { margin-bottom: 2px; }
.card-meta { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.card-meta strong { color: var(--ink); font-weight: 600; }
.card-toggle .card-status { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; min-width: 0; }
.card .chevron { color: var(--muted); transition: transform 0.15s ease; }
.card.open .chevron { transform: rotate(180deg); }
.card-more { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-soft, var(--line)); }
.card-more[hidden] { display: none; }
.card-more .cov-row { margin-top: 0; }
.card-more .desc { margin-top: 10px; }
.card .note {
  margin: 10px 0 0;
  padding: 0 0 0 10px;
  border-left: 2px solid var(--accent);
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.5;
}
.card-foot { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.card-foot .actions { margin: 0; flex: 1; }
.card-foot .actions[hidden] { display: none; }
.card-toggle .progress { margin-top: 8px; }
.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
}
.filter-toggle input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.inline-link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

/* Home hero: the score ring lives here now, once. */
.score-ring.sm { width: 84px; height: 84px; }
.score-ring.sm .score-num { font-size: 26px; }
.score-ring.sm .score-den { font-size: 9px; margin-top: 2px; }
.score-ring.ok     .score-ring-fg { stroke: #4ade80; }
.score-ring.warn   .score-ring-fg { stroke: var(--gold); }
.score-ring.danger .score-ring-fg { stroke: var(--rose); }
/* The toggle is a <button>, which the global button rule sets to nowrap. Cards must wrap. */
.card-toggle, .card-toggle * { white-space: normal; }
.card-toggle .pill { white-space: nowrap; }
.card-meta { overflow-wrap: anywhere; }
.pill.booked { background: var(--ok-soft); color: var(--ok); }
.next-action.screening-booked { border-left: 4px solid var(--ok); }

/* ---------------------------------------------------------------------------
   Home: the greeting, score ring and tabs are one band with the top bar
   (logo + name), not a card floating under it. Phone and native shells only;
   the desktop layout has a sidebar and no top bar.
   --------------------------------------------------------------------------- */
@media (max-width: 900px) {
  body.home .top-bar { background: var(--card); border-bottom: 0; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
  body.home .app-main { padding-top: calc(var(--topbar-h) + var(--safe-top)); }
  body.home .home-header {
    position: sticky;
    top: calc(var(--topbar-h) + var(--safe-top));
    margin: 0 -18px 20px;
    padding: 4px 18px 0;
    background: var(--card);
    border: 0;
    border-radius: 0 0 24px 24px;
    box-shadow: 0 14px 32px -20px rgba(0, 0, 0, 0.55);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  body.home .home-hero { padding-bottom: 8px; }
  body.home .home-hero-left .page-title { font-size: 26px; }
}
