/* ================================================================
   TinyHumanMD | Design System & Styles
   Clinical-grade, calm, accessible UI
   ================================================================ */

/* ── Design Tokens ───────────────────────────────────────────── */
:root {
  /* Spacing scale */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px;
  --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px; --s-16: 64px;
  --s-20: 80px;

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --text-xs: 0.6875rem; --text-sm: 0.8125rem; --text-base: 0.9375rem;
  --text-lg: 1.125rem; --text-xl: 1.375rem; --text-2xl: 1.75rem; --text-3xl: 2.25rem;
  --leading-tight: 1.15; --leading-normal: 1.55; --leading-relaxed: 1.7;

  /* Radius */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 20px; --r-full: 9999px;

  /* Colors: calm healthcare palette */
  --c-primary: #2563eb;
  --c-primary-soft: #eff4ff;
  --c-primary-mid: #dbe8fe;
  --c-green: #16a34a; --c-green-soft: #ecfdf3;
  --c-amber: #d97706; --c-amber-soft: #fffbeb;
  --c-purple: #7c3aed; --c-purple-soft: #f3f0ff;
  --c-red: #dc2626; --c-red-soft: #fef2f2;

  --c-text: #111827; --c-text-secondary: #4b5563; --c-text-muted: #9ca3af;
  --c-bg: #f8fafc; --c-surface: #ffffff;
  --c-border: #e5e7eb; --c-border-light: #f3f4f6;

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.04);
  --shadow-xl: 0 20px 60px rgba(0,0,0,.12), 0 4px 12px rgba(0,0,0,.04);

  /* Transition */
  --ease: cubic-bezier(.4,0,.2,1);
  --dur: 200ms;
}

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  font-family: var(--font); font-size: var(--text-base); color: var(--c-text);
  background: var(--c-bg); line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
ul { list-style: none; }
button { cursor: pointer; font-family: inherit; }
img { display: block; max-width: 100%; }

/* ── Utility ─────────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 var(--s-6); }
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 999;
  background: var(--c-primary); color: #fff; padding: var(--s-3) var(--s-4);
  font-weight: 600; border-radius: 0 0 var(--r-sm) var(--r-sm);
}
.skip-link:focus { left: var(--s-4); }

/* ── Badge ───────────────────────────────────────────────────── */
.badge {
  display: inline-block; font-size: var(--text-xs); font-weight: 600;
  padding: 3px 10px; border-radius: var(--r-full);
  text-transform: uppercase; letter-spacing: .06em;
}
.badge-blue { background: var(--c-primary-soft); color: var(--c-primary); }
.badge-green { background: var(--c-green-soft); color: var(--c-green); }
.badge-amber { background: var(--c-amber-soft); color: var(--c-amber); }
.badge-purple { background: var(--c-purple-soft); color: var(--c-purple); }
.badge-neutral { background: var(--c-border-light); color: var(--c-text-secondary); }

/* ── Header ──────────────────────────────────────────────────── */
.header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255,255,255,.88);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--c-border);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; gap: var(--s-6);
}
.logo {
  display: flex; align-items: center; gap: var(--s-2);
  font-weight: 700; font-size: var(--text-lg); color: var(--c-text);
  text-decoration: none; white-space: nowrap;
}
.logo:hover { text-decoration: none; }
.nav { flex: 1; }
.nav-list { display: flex; gap: var(--s-1); }
.nav-link {
  padding: 6px 12px; border-radius: var(--r-full); font-size: var(--text-sm);
  font-weight: 500; color: var(--c-text-secondary); white-space: nowrap;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
  text-decoration: none;
}
.nav-link:hover { color: var(--c-text); background: var(--c-border-light); text-decoration: none; }
.nav-link:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
.nav-link.is-active { color: var(--c-primary); background: var(--c-primary-soft); }

/* ── Nav Dropdown (hover-reveal) ─────────────────────────────── */
.nav-dropdown { position: relative; }
.nav-dropdown > .nav-link {
  display: inline-flex; align-items: center; gap: 3px;
}
.nav-chev {
  opacity: .45; transition: transform 200ms var(--ease), opacity 200ms var(--ease);
}
.nav-dropdown:hover .nav-chev,
.nav-dropdown.is-open .nav-chev { opacity: .8; transform: rotate(180deg); }
.nav-dd-panel {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  min-width: 180px; padding: 14px 6px 6px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid rgba(0,0,0,.06); border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.04);
  z-index: 100;
  opacity: 0; pointer-events: none;
  transform: translateX(-50%) translateY(4px);
  transition: opacity 180ms var(--ease), transform 180ms var(--ease);
}
.nav-dropdown:hover .nav-dd-panel,
.nav-dropdown.is-open .nav-dd-panel {
  opacity: 1; pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.nav-dd-link {
  display: block; padding: 7px 12px; border-radius: 8px;
  font-size: 13px; font-weight: 500; color: var(--c-text-secondary);
  text-decoration: none; white-space: nowrap;
  transition: background 120ms var(--ease), color 120ms var(--ease);
}
.nav-dd-link:hover { background: var(--c-primary-soft); color: var(--c-primary); text-decoration: none; }
.nav-dd-link:focus-visible { outline: 2px solid var(--c-primary); outline-offset: -2px; }

.mobile-menu-btn {
  display: none; background: none; border: none; color: var(--c-text);
  padding: var(--s-2); border-radius: var(--r-sm);
}

/* ── Mobile Nav ──────────────────────────────────────────────── */
.mobile-nav-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.3); backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur) var(--ease);
}
.mobile-nav-overlay.is-open { opacity: 1; pointer-events: auto; }
.mobile-nav-panel {
  position: absolute; top: 0; right: 0; width: 280px; height: 100%;
  background: var(--c-surface); box-shadow: var(--shadow-xl);
  padding: var(--s-6);
  transform: translateX(100%);
  transition: transform 300ms var(--ease);
}
.mobile-nav-overlay.is-open .mobile-nav-panel { transform: translateX(0); }
.mobile-nav-close {
  display: flex; background: none; border: none; color: var(--c-text-secondary);
  margin-bottom: var(--s-6);
}
.mobile-nav-list { display: flex; flex-direction: column; gap: var(--s-2); }
.mobile-nav-list a {
  display: block; padding: var(--s-3) var(--s-4); border-radius: var(--r-sm);
  font-size: var(--text-base); font-weight: 500; color: var(--c-text);
  transition: background var(--dur) var(--ease); text-decoration: none;
}
.mobile-nav-list a:hover { background: var(--c-border-light); }

/* Mobile nav labels & grouping */
.mobile-nav-label {
  padding: var(--s-1) var(--s-4); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; color: var(--c-text-muted);
}
.mobile-nav-sub-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px;
  padding: 0 var(--s-2); list-style: none;
}
.mobile-nav-sub-grid a {
  display: block; padding: 10px 12px; border-radius: 8px;
  font-size: var(--text-sm); font-weight: 500; color: var(--c-text-secondary);
  text-decoration: none; text-align: center;
  transition: background 120ms var(--ease), color 120ms var(--ease);
}
.mobile-nav-sub-grid a:hover { background: var(--c-primary-soft); color: var(--c-primary); }
.mobile-nav-divider {
  height: 1px; background: var(--c-border); margin: var(--s-3) var(--s-4);
}

/* ── Hero ────────────────────────────────────────────────────── */
.hero { padding: var(--s-16) 0 var(--s-10); text-align: center; background: linear-gradient(180deg, #fff 0%, var(--c-bg) 100%); }
.hero-inner { max-width: 640px; margin: 0 auto; }
.hero .badge { margin-bottom: var(--s-4); }
.hero-title {
  font-size: clamp(1.75rem, 4.5vw, var(--text-3xl)); font-weight: 800;
  line-height: var(--leading-tight); letter-spacing: -.025em;
  color: var(--c-text); margin-bottom: var(--s-4);
}
.hero-sub {
  font-size: var(--text-lg); color: var(--c-text-secondary);
  max-width: 520px; margin: 0 auto; line-height: var(--leading-relaxed);
}

/* ── Table Toolbar ────────────────────────────────────────────── */
.table-toolbar {
  background: var(--c-bg); border: 1px solid var(--c-border);
  border-bottom: none; border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: var(--s-4);
}
.table-toolbar + .table-wrap { border-radius: 0 0 var(--r-lg) var(--r-lg); }
.toolbar-row { display: flex; gap: var(--s-3); align-items: center; flex-wrap: wrap; }
.search-box {
  position: relative; flex: 1; min-width: 200px;
}
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--c-text-muted); }
.search-input {
  width: 100%; height: 40px; padding: 0 var(--s-4) 0 40px;
  border: 1px solid var(--c-border); border-radius: var(--r-full);
  font-family: var(--font); font-size: var(--text-sm);
  background: var(--c-surface); color: var(--c-text);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.search-input::placeholder { color: var(--c-text-muted); }
.search-input:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.filter-group { display: flex; align-items: center; gap: var(--s-2); }
.filter-label { font-size: var(--text-sm); font-weight: 500; color: var(--c-text-secondary); white-space: nowrap; }
.filter-select {
  height: 40px; padding: 0 var(--s-8) 0 var(--s-3);
  border: 1px solid var(--c-border); border-radius: var(--r-md);
  font-family: var(--font); font-size: var(--text-sm); font-weight: 500;
  background: var(--c-surface); color: var(--c-text);
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  cursor: pointer; transition: border-color var(--dur) var(--ease);
}
.filter-select:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }

/* Chips */
.chip-bar { display: flex; gap: var(--s-2); flex-wrap: wrap; padding-top: var(--s-2); }
.chip-bar:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: var(--s-1);
  padding: 4px 10px 4px 12px; border-radius: var(--r-full);
  font-size: var(--text-xs); font-weight: 600;
  background: var(--c-primary-soft); color: var(--c-primary);
  border: none; cursor: pointer; transition: background var(--dur) var(--ease);
}
.chip:hover { background: var(--c-primary-mid); }
.chip svg { flex-shrink: 0; }
.chip-clear {
  padding: 4px 12px; border-radius: var(--r-full);
  font-size: var(--text-xs); font-weight: 600;
  background: none; color: var(--c-text-muted); border: 1px solid var(--c-border);
  cursor: pointer; transition: all var(--dur) var(--ease);
}
.chip-clear:hover { color: var(--c-text); border-color: var(--c-text-muted); }

/* Legend */
.legend { display: flex; gap: var(--s-5); flex-wrap: wrap; padding: var(--s-4) var(--s-6); }
.legend-item { display: flex; align-items: center; gap: var(--s-2); font-size: var(--text-sm); color: var(--c-text-secondary); font-weight: 500; }
.dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.dot-rec { background: var(--c-primary); }
.dot-catch { background: var(--c-green); }
.dot-risk { background: var(--c-purple); }
.dot-shared { background: var(--c-amber); }

/* ── Sections ────────────────────────────────────────────────── */
.section { padding: var(--s-12) 0; }
.section-alt { background: var(--c-surface); }
.section-heading {
  font-size: var(--text-2xl); font-weight: 700; letter-spacing: -.02em;
  color: var(--c-text); margin-bottom: var(--s-2);
}
.section-sub { font-size: var(--text-base); color: var(--c-text-secondary); margin-bottom: var(--s-8); line-height: var(--leading-relaxed); }
.section-sub a { font-weight: 500; }

/* ── Table ───────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto; border: 1px solid var(--c-border); border-radius: var(--r-lg);
  background: var(--c-surface); box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
}
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 860px; }
.tbl th, .tbl td {
  padding: 10px 12px; font-size: var(--text-sm); text-align: center;
  border-bottom: 1px solid var(--c-border-light); border-right: 1px solid var(--c-border-light);
}
.tbl th:last-child, .tbl td:last-child { border-right: none; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl thead th {
  background: var(--c-bg); font-weight: 600; color: var(--c-text-secondary);
  font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .05em;
  position: sticky; top: 0; z-index: 2; white-space: nowrap;
  cursor: pointer; user-select: none;
  transition: background var(--dur) var(--ease);
}
.tbl thead th:hover { background: #eef1f5; }
.tbl thead th:first-child {
  text-align: left; position: sticky; left: 0; z-index: 3;
  min-width: 170px; background: var(--c-bg);
}
.tbl tbody td:first-child {
  text-align: left; font-weight: 600; color: var(--c-text);
  position: sticky; left: 0; background: var(--c-surface); z-index: 1;
  min-width: 170px; border-right: 2px solid var(--c-border-light);
}
.tbl tbody tr { transition: background var(--dur) var(--ease); }
.tbl tbody tr:hover td { background: #f8fafd; }
.tbl tbody tr:hover td:first-child { background: #f1f5f9; }
.tbl tbody tr.is-hidden { display: none; }

/* Column highlighting when age filter is active */
.tbl th.col-dim, .tbl td.col-dim { opacity: .3; }
.tbl th.col-highlight { background: var(--c-primary-soft); }
.tbl td.col-highlight { background: var(--c-primary-soft); }

/* Pills */
.pill {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 3px 10px; border-radius: 6px; font-size: var(--text-xs); font-weight: 600;
  cursor: pointer; transition: transform var(--dur) var(--ease), filter var(--dur) var(--ease);
  border: none; background: none;
}
.pill:hover { transform: scale(1.06); }
.pill:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
.pill-rec { background: var(--c-primary-soft); color: #1d4ed8; }
.pill-catch { background: var(--c-green-soft); color: #15803d; }
.pill-risk { background: var(--c-purple-soft); color: #6d28d9; }
.pill-shared { background: var(--c-amber-soft); color: #b45309; }
.pill-note { background: var(--c-border-light); color: var(--c-text-muted); }

/* Empty state */
.table-empty {
  text-align: center; padding: var(--s-10) var(--s-6);
  font-size: var(--text-base); color: var(--c-text-muted);
}

/* Mobile cards (hidden on desktop) */
.mobile-cards { display: none; }
.mobile-card { cursor: pointer; transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease); }
.mobile-card:active { transform: scale(.98); }
.mc-chips { display: flex; gap: 4px; flex-wrap: wrap; }
.mc-chip {
  font-size: 10px; font-weight: 600; padding: 2px 7px;
  border-radius: 5px; white-space: nowrap;
}
.mc-chip-rec { background: var(--c-primary-soft); color: #1d4ed8; }
.mc-chip-catch { background: var(--c-green-soft); color: #15803d; }
.mc-chip-risk { background: var(--c-purple-soft); color: #6d28d9; }
.mc-chip-shared { background: var(--c-amber-soft); color: #b45309; }
.mc-chip-note { background: var(--c-border-light); color: var(--c-text-muted); }

/* ── Catch-up tabs ───────────────────────────────────────────── */
.catchup-scroll-hint { display: none; }
.tab-bar { display: inline-flex; gap: 2px; background: var(--c-border-light); padding: 3px; border-radius: var(--r-md); margin-bottom: var(--s-6); }
.tab {
  padding: 8px 20px; border: none; border-radius: var(--r-sm);
  font-family: var(--font); font-size: var(--text-sm); font-weight: 600;
  color: var(--c-text-secondary); background: transparent;
  transition: all var(--dur) var(--ease);
}
.tab:hover { color: var(--c-text); }
.tab.is-active { background: var(--c-surface); color: var(--c-text); box-shadow: var(--shadow-xs); }
.tab:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
.catchup-tbl td:not(:first-child) {
  white-space: normal; min-width: 150px; max-width: 230px;
  font-size: var(--text-sm); line-height: var(--leading-normal);
  text-align: left; vertical-align: top;
}
.cu-bold { font-weight: 700; color: var(--c-text); }
.cu-muted { color: var(--c-text-secondary); display: block; margin-top: 2px; font-size: var(--text-xs); }
.cu-badge {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  background: var(--c-primary-soft); color: var(--c-primary);
  font-weight: 600; font-size: var(--text-xs);
}

/* ── Timeline ────────────────────────────────────────────────── */
.timeline-wrap {
  overflow-x: auto; border: 1px solid var(--c-border); border-radius: var(--r-lg);
  background: var(--c-surface); box-shadow: var(--shadow-sm); padding: var(--s-6);
  -webkit-overflow-scrolling: touch;
}
.tl-row { display: flex; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--c-border-light); min-width: 760px; }
.tl-row:last-child { border-bottom: none; }
.tl-label { width: 120px; min-width: 120px; font-size: var(--text-sm); font-weight: 600; color: var(--c-text); }
.tl-track { flex: 1; position: relative; height: 24px; }
.tl-bar { position: absolute; top: 50%; transform: translateY(-50%); height: 4px; border-radius: 2px; opacity: .18; }
.tl-dot {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--c-surface);
  box-shadow: 0 0 0 2px currentColor, var(--shadow-xs);
  cursor: pointer; transition: transform var(--dur) var(--ease); z-index: 1;
}
.tl-dot:hover { transform: translate(-50%, -50%) scale(1.4); }
.tl-dot:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 3px; }
.tl-tooltip {
  display: none; position: absolute; bottom: calc(100% + 8px);
  left: 50%; transform: translateX(-50%);
  background: var(--c-text); color: #fff; font-size: var(--text-xs); font-weight: 500;
  padding: 4px 10px; border-radius: 6px; white-space: nowrap; pointer-events: none;
}
.tl-dot:hover .tl-tooltip { display: block; }
.tl-axis { display: flex; align-items: center; padding: 6px 0 0; min-width: 760px; }
.tl-axis-spacer { width: 120px; min-width: 120px; }
.tl-axis-track { flex: 1; position: relative; height: 18px; }
.tl-axis-label { position: absolute; transform: translateX(-50%); font-size: 10px; font-weight: 500; color: var(--c-text-muted); }

/* ── Card Grid ───────────────────────────────────────────────── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--s-4); }
.card-grid-lg { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.card {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-lg); padding: var(--s-6);
  box-shadow: var(--shadow-xs); transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: var(--s-3); gap: var(--s-3); }
.card-title { font-size: var(--text-lg); font-weight: 700; color: var(--c-text); line-height: var(--leading-tight); }
.card-abbr { font-size: var(--text-xs); font-weight: 600; padding: 3px 10px; border-radius: var(--r-full); background: var(--c-primary-soft); color: var(--c-primary); white-space: nowrap; }
.card-body { font-size: var(--text-sm); color: var(--c-text-secondary); line-height: var(--leading-relaxed); margin-bottom: var(--s-4); }
.card-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: var(--s-4); }
.card-chip {
  font-size: var(--text-xs); font-weight: 600; padding: 4px 10px;
  border-radius: var(--r-sm); background: var(--c-primary-soft); color: #1d4ed8;
}
.card-chip-green { background: var(--c-green-soft); color: #15803d; }
.card-toggle {
  font-size: var(--text-sm); font-weight: 600; color: var(--c-primary);
  background: none; border: none; padding: 0;
  display: flex; align-items: center; gap: 4px;
  transition: opacity var(--dur) var(--ease);
}
.card-toggle:hover { opacity: .7; }
.card-toggle svg { transition: transform var(--dur) var(--ease); }
.card-toggle.is-open svg { transform: rotate(180deg); }
.card-detail {
  display: none; margin-top: var(--s-4); padding-top: var(--s-4);
  border-top: 1px solid var(--c-border-light);
  font-size: var(--text-sm); color: var(--c-text-secondary);
  line-height: var(--leading-relaxed);
}
.card-detail.is-open { display: block; }
.card-detail strong { font-weight: 600; color: var(--c-text); }
.card-detail ul { margin: var(--s-2) 0 0 var(--s-4); }
.card-detail li { margin-bottom: 3px; }

/* ── Pregnancy ───────────────────────────────────────────────── */
.preg-cols { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-6); }
.preg-col {
  padding: var(--s-6); border-radius: var(--r-lg);
  border: 1px solid var(--c-border); background: var(--c-surface);
}
.preg-col-rec { border-left: 4px solid var(--c-green); }
.preg-col-avoid { border-left: 4px solid var(--c-red); }
.preg-col-title { font-size: var(--text-base); font-weight: 700; margin-bottom: var(--s-4); }
.preg-item { margin-bottom: var(--s-3); }
.preg-item:last-child { margin-bottom: 0; }
.preg-name { font-size: var(--text-sm); font-weight: 700; color: var(--c-text); }
.preg-desc { font-size: var(--text-sm); color: var(--c-text-secondary); line-height: var(--leading-normal); margin-top: 2px; }

/* ── Callout ─────────────────────────────────────────────────── */
.callout {
  padding: var(--s-4) var(--s-5); border-radius: var(--r-md);
  font-size: var(--text-sm); line-height: var(--leading-relaxed);
  margin-top: var(--s-6); margin-bottom: var(--s-6);
}
.callout strong { font-weight: 600; }
.callout-blue { background: var(--c-primary-soft); color: var(--c-text); }
.callout-amber { background: var(--c-amber-soft); color: var(--c-text); }

/* ── Mpox specifics ──────────────────────────────────────────── */
.mpox-schedule {
  display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap;
  padding: var(--s-4); background: var(--c-bg); border-radius: var(--r-md);
}
.mpox-dose {
  display: flex; flex-direction: column; align-items: center;
  padding: 10px 20px; background: var(--c-primary-soft); border-radius: var(--r-md);
}
.mpox-dose-num { font-size: var(--text-sm); font-weight: 700; color: #1d4ed8; }
.mpox-dose-sub { font-size: var(--text-xs); color: var(--c-text-secondary); margin-top: 2px; }
.mpox-arrow { font-size: var(--text-sm); font-weight: 600; color: var(--c-text-muted); }
.mpox-stats { display: flex; gap: var(--s-8); margin-bottom: var(--s-4); }
.mpox-stat-num { display: block; font-size: var(--text-3xl); font-weight: 800; color: var(--c-primary); line-height: 1; }
.mpox-stat-label { font-size: var(--text-xs); color: var(--c-text-secondary); margin-top: 4px; display: block; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,.3); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 250ms var(--ease);
}
.modal-overlay.is-open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--c-surface); border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl); max-width: 480px; width: 92%; padding: var(--s-8);
  position: relative;
  transform: translateY(16px) scale(.98);
  transition: transform 300ms var(--ease);
}
.modal-overlay.is-open .modal { transform: translateY(0) scale(1); }
.modal-close {
  position: absolute; top: var(--s-4); right: var(--s-4);
  background: var(--c-border-light); border: none; border-radius: var(--r-full);
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  color: var(--c-text-secondary); transition: background var(--dur) var(--ease);
}
.modal-close:hover { background: var(--c-border); }
.modal h3 { font-size: var(--text-xl); font-weight: 700; margin-bottom: var(--s-2); padding-right: var(--s-10); }
.modal-sub { font-size: var(--text-sm); color: var(--c-text-secondary); margin-bottom: var(--s-4); line-height: var(--leading-relaxed); }
.modal-body { font-size: var(--text-sm); color: var(--c-text); line-height: var(--leading-relaxed); }
.modal-body strong { font-weight: 600; }
.modal-body ul { margin: var(--s-2) 0 0 var(--s-4); }
.modal-body li { margin-bottom: 3px; }

/* ── Footer ──────────────────────────────────────────────────── */
.footer { padding: var(--s-10) 0; border-top: 1px solid var(--c-border); text-align: center; }
.footer-inner { max-width: 560px; margin: 0 auto; }
.footer p { font-size: var(--text-sm); color: var(--c-text-secondary); line-height: var(--leading-relaxed); }
.footer-credit { margin-top: var(--s-3); font-weight: 600; color: var(--c-text); opacity: .6; }

.footer-disclaimer-short {
  margin-top: var(--s-3); font-size: 11px; color: var(--c-text-muted); font-style: italic;
}

/* ── FAQ Section ─────────────────────────────────────────────── */
.faq-section {
  padding: var(--s-12) 0; border-top: 1px solid var(--c-border);
}
.faq-section h2 {
  font-size: var(--text-2xl); font-weight: 700; letter-spacing: -.02em;
  margin-bottom: var(--s-6);
}
.faq-item {
  border: 1px solid var(--c-border); border-radius: var(--r-md);
  margin-bottom: var(--s-3); overflow: hidden;
  background: var(--c-surface);
}
.faq-question {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-4) var(--s-5); cursor: pointer;
  font-size: var(--text-base); font-weight: 600; color: var(--c-text);
  background: none; border: none; width: 100%; text-align: left;
  font-family: var(--font);
  transition: background var(--dur) var(--ease);
}
.faq-question:hover { background: var(--c-border-light); }
.faq-question svg {
  flex-shrink: 0; transition: transform var(--dur) var(--ease);
  color: var(--c-text-muted);
}
.faq-item.is-open .faq-question svg { transform: rotate(180deg); }
.faq-answer {
  display: none; padding: 0 var(--s-5) var(--s-5);
  font-size: var(--text-sm); color: var(--c-text-secondary);
  line-height: var(--leading-relaxed);
}
.faq-answer p { margin-bottom: var(--s-3); }
.faq-answer p:last-child { margin-bottom: 0; }
.faq-answer a { color: var(--c-primary); }
.faq-item.is-open .faq-answer { display: block; }

/* ── Tools Grid (cross-links) ────────────────────────────────── */
.tools-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--s-3);
}
.tool-link-card {
  display: block; padding: var(--s-4) var(--s-5);
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-md); text-decoration: none;
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.tool-link-card:hover {
  box-shadow: var(--shadow-md); transform: translateY(-2px);
  text-decoration: none;
}
.tool-link-card h3 {
  font-size: var(--text-base); font-weight: 700; color: var(--c-text);
  margin-bottom: var(--s-1);
}
.tool-link-card p {
  font-size: var(--text-xs); color: var(--c-text-secondary);
  line-height: var(--leading-normal); margin: 0;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .nav { display: none; }
  .mobile-menu-btn { display: flex; }

  /* Hero */
  .hero { padding: var(--s-8) 0 var(--s-6); }
  .hero-title { font-size: 1.5rem; letter-spacing: -.02em; }
  .hero-sub { font-size: var(--text-sm); }
  .hero .badge { font-size: 10px; padding: 2px 8px; }

  /* Legend */
  .legend { padding: var(--s-3) var(--s-4); gap: var(--s-2) var(--s-4); }
  .legend-item { font-size: var(--text-xs); }
  .dot { width: 8px; height: 8px; }

  /* Sections */
  .section { padding: var(--s-6) 0; }
  .section-heading { font-size: var(--text-xl); }
  .section-sub { font-size: var(--text-sm); margin-bottom: var(--s-5); }

  /* Toolbar: standalone look on mobile (table is hidden) */
  .table-toolbar {
    border-radius: var(--r-lg);
    border-bottom: 1px solid var(--c-border);
    margin-bottom: var(--s-4);
  }
  .toolbar-row { flex-direction: column; gap: var(--s-3); }
  .search-box { min-width: 100%; }
  .search-input { height: 44px; font-size: var(--text-base); }
  .filter-group { width: 100%; }
  .filter-select { flex: 1; height: 44px; font-size: var(--text-sm); }

  /* Hide desktop table, show mobile cards */
  .table-wrap { display: none; }
  .mobile-cards { display: flex; flex-direction: column; gap: var(--s-3); }

  /* Mobile cards styling */
  .mobile-card {
    padding: var(--s-4) var(--s-5);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-xs);
  }
  .mobile-card .card-top { margin-bottom: var(--s-2); }
  .mobile-card .card-title { font-size: var(--text-base); }
  .mobile-card .card-body { font-size: var(--text-sm); margin-bottom: var(--s-3); line-height: var(--leading-normal); }
  .mobile-card .card-chips { gap: 4px; margin-bottom: 0; }
  .mobile-card .card-chip { font-size: 10px; padding: 3px 8px; }

  /* Catch-up: horizontally scrollable with scroll hint */
  .table-wrap[id="catchupPanel"] { display: block; }
  .tab-bar { gap: 0; width: 100%; }
  .tab { padding: 6px 14px; font-size: var(--text-xs); flex: 1; text-align: center; }
  .catchup-scroll-hint,
  .timeline-scroll-hint {
    display: flex; align-items: center; justify-content: center; gap: var(--s-2);
    padding: var(--s-2) 0; margin-bottom: var(--s-2);
    font-size: var(--text-xs); color: var(--c-text-muted); font-weight: 500;
  }
  .scroll-hint-arrow { animation: scrollHint 1.5s ease-in-out infinite; }
  @keyframes scrollHint { 0%,100%{ transform: translateX(0); } 50%{ transform: translateX(4px); } }

  /* Card grids */
  .card-grid { grid-template-columns: 1fr; gap: var(--s-3); }
  .card-grid .card { padding: var(--s-4) var(--s-5); }
  .card-grid .card-title { font-size: var(--text-base); }
  .card-grid .card-body { font-size: var(--text-sm); }

  /* Pregnancy */
  .preg-cols { grid-template-columns: 1fr; gap: var(--s-3); }
  .preg-col { padding: var(--s-4); }
  .preg-col-title { font-size: var(--text-sm); }

  /* Callouts */
  .callout { font-size: var(--text-xs); padding: var(--s-3) var(--s-4); margin-top: var(--s-4); margin-bottom: var(--s-4); }

  /* Mpox */
  .mpox-schedule { padding: var(--s-3); gap: var(--s-3); }
  .mpox-dose { padding: 8px 14px; }
  .mpox-stats { gap: var(--s-4); }
  .mpox-stat-num { font-size: var(--text-2xl); }

  /* Modal: bottom sheet */
  .modal-overlay { align-items: flex-end; }
  .modal {
    max-width: 100%; width: 100%; padding: var(--s-6) var(--s-5) var(--s-10);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    max-height: 85vh; overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateY(100%);
  }
  .modal-overlay.is-open .modal { transform: translateY(0); }
  .modal h3 { font-size: var(--text-lg); }
  .modal-sub { font-size: var(--text-xs); }
  .modal-body { font-size: var(--text-sm); }

  /* Footer */
  .footer { padding: var(--s-8) 0; }
  .footer p { font-size: var(--text-xs); }
}

@media (max-width: 480px) {
  .container { padding: 0 var(--s-3); }
  .hero-title { font-size: 1.375rem; }
  .hero-sub { max-width: 280px; }
  .search-input { height: 42px; }
  .filter-select { height: 42px; }
  .section-heading { font-size: var(--text-lg); }
  .section-sub { font-size: var(--text-xs); }
  .mobile-card { padding: var(--s-3) var(--s-4); }
  .card-grid .card { padding: var(--s-3) var(--s-4); }
  .preg-col { padding: var(--s-3); }
}

@media (max-width: 360px) {
  .header-inner { height: 48px; }
  .logo span { font-size: var(--text-base); }
  .hero-title { font-size: 1.25rem; }
  .container { padding: 0 var(--s-2); }
}
