/* ── Variables ───────────────────────────────────────────────── */
:root {
  --bg: #070b18;
  --surface: rgba(255,255,255,0.055);
  --surface2: rgba(255,255,255,0.085);
  --border: rgba(255,255,255,0.10);
  --text: rgba(255,255,255,0.92);
  --text2: rgba(255,255,255,0.70);
  --muted: rgba(255,255,255,0.42);
  /* Solid opaque card backgrounds (dark mode) */
  --card:  #111827;
  --card2: #1a2237;

  --blue: #4f8cff;
  --green: #35d49a;
  --yellow: #ffbf3c;
  --red: #ff4d6d;
  /* Màu nhấn dùng chung (icon, viền hover) — NeoKid / xanh lam */
  --accent: var(--blue);

  --nav-h: 62px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --native-bg: #070b18;

  --r-s: 10px;
  --r-m: 14px;
  --r-l: 20px;
}

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  background: var(--native-bg);
}

body {
  height: 100%;
  overflow: hidden;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji";
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background-color: var(--native-bg);
  background:
    radial-gradient(ellipse 900px 500px at 15% 0%, rgba(79,140,255,0.28) 0%, transparent 60%),
    radial-gradient(ellipse 700px 400px at 85% 5%, rgba(53,212,154,0.14) 0%, transparent 60%),
    radial-gradient(ellipse 600px 500px at 40% 100%, rgba(167,139,250,0.08) 0%, transparent 60%),
    linear-gradient(180deg, #070b18 0%, #060912 100%);
  background-color: var(--native-bg);
  background-attachment: fixed;
}

button, input, select, label { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
input, select { outline: none; }

/* ── App shell ───────────────────────────────────────────────── */
#app {
  position: fixed;
  inset: 0;
  bottom: calc(var(--nav-h) + var(--safe-b));
}

body.onboarding #app {
  bottom: 0;
}

/* ── Screens ─────────────────────────────────────────────────── */
.screen {
  display: none;
  position: absolute;
  inset: 0;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.screen.active { display: flex; }

/* Hide bottom nav while onboarding */
body.onboarding .bottom-nav { display: none !important; }

/* ── Onboarding screen ───────────────────────────────────────── */
.onboard-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: calc(var(--safe-t) + 18px) max(16px, var(--safe-r)) calc(var(--safe-b) + 28px) max(16px, var(--safe-l));
  gap: 16px;
  min-height: 100%;
  position: relative;
}

/* Theme toggle on onboard screen */
.ob-theme-btn {
  position: absolute;
  top: calc(var(--safe-t) + 14px);
  right: max(16px, var(--safe-r));
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.10);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.18s;
}
.ob-theme-btn:hover { background: rgba(255,255,255,0.18); }
html[data-theme="dark"]  .ob-theme-icon-light { display: none; }
html[data-theme="light"] .ob-theme-icon-dark  { display: none; }
html[data-theme="light"] .ob-theme-btn { background: rgba(0,0,0,0.07); }
html[data-theme="light"] .ob-theme-btn:hover { background: rgba(0,0,0,0.13); }

/* Avatar section in onboarding */
.ob-avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}
.ob-avatar-preview {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--card2);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  line-height: 1;
  overflow: hidden;
  cursor: pointer;
}
.ob-avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.ob-avatar-change-btn {
  font-size: 13px;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-s);
  cursor: pointer;
  padding: 5px 14px;
  font-weight: 600;
}
.ob-avatar-change-btn:hover { background: var(--border); }
.ob-avatar-picker {
  width: 100%;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: var(--r-s);
  padding: 10px;
  margin-top: 4px;
}
.ob-avatar-emoji-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}
.ob-avatar-emoji-grid .avatar-option {
  width: 100%;
  aspect-ratio: 1;
  font-size: 22px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: var(--card);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ob-avatar-emoji-grid .avatar-option.selected,
.ob-avatar-emoji-grid .avatar-option:hover { border-color: var(--accent); }

/* Upload row (shared between onboard & settings) */
.ob-upload-row,
.avatar-upload-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.ob-upload-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-s);
  padding: 7px 8px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  text-align: center;
}
.ob-upload-btn:hover { border-color: var(--accent); color: var(--accent); }
input[type="file"]#obAvatarFile,
input[type="file"]#obAvatarCamera,
input[type="file"]#settingsAvatarFile,
input[type="file"]#settingsAvatarCamera,
input[type="file"]#editAvatarFile,
input[type="file"]#editAvatarCamera2,
input[type="file"]#addAvatarFile,
input[type="file"]#addAvatarCamera { display: none; }
html[data-theme="light"] .ob-avatar-preview { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.10); }
html[data-theme="light"] .ob-avatar-picker  { background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.10); }
html[data-theme="light"] .ob-upload-btn     { background: #fff; }
.onboard-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.onboard-logo-img {
  height: clamp(58px, 10vh, 80px);
  width: auto;
  object-fit: contain;
}
/* Show correct onboard logo per theme (both imgs in DOM; toggle visibility) */
.onboard-logo-img.onboard-logo-dark,
.onboard-logo-img.onboard-logo-light {
  display: none;
}
html[data-theme="dark"] .onboard-logo-img.onboard-logo-dark,
html[data-theme="light"] .onboard-logo-img.onboard-logo-light {
  display: block;
}

/* Header logo */
.s-header-title {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}
.s-header-title h1 {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
  white-space: nowrap;
}
.s-header-title .header-subtitle {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

/* NeoKid wordmark — xanh lam (Neo) → cyan (Kid), khớp logo */
.brand-neo {
  color: #38bdf8;
}
.brand-kid {
  background: linear-gradient(92deg, #22d3ee 0%, #5eead4 95%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
html[data-theme="light"] .brand-neo {
  color: #0284c7;
}
html[data-theme="light"] .brand-kid {
  background: linear-gradient(92deg, #06b6d4 0%, #14b8a6 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* About dialog */
.about-body {
  padding: 16px 16px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}
.about-body .about-desc,
.about-body .about-features,
.about-body .about-ref,
.about-body .about-disclaimer,
.about-body .about-team,
.about-body .about-version,
.about-body .about-tagline {
  align-self: stretch;
}
.about-logo-hero {
  width: 100%;
  max-width: 360px;
  padding: 24px 20px 20px;
  border-radius: 20px;
  background: linear-gradient(
    155deg,
    rgba(56, 189, 248, 0.2) 0%,
    rgba(59, 130, 246, 0.14) 42%,
    rgba(15, 23, 42, 0.55) 100%
  );
  border: 1px solid rgba(56, 189, 248, 0.28);
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  margin-bottom: 2px;
}
html[data-theme="light"] .about-logo-hero {
  background: linear-gradient(
    155deg,
    rgba(224, 242, 254, 0.95) 0%,
    rgba(186, 230, 253, 0.65) 45%,
    rgba(255, 255, 255, 0.98) 100%
  );
  border-color: rgba(14, 165, 233, 0.28);
  box-shadow:
    0 8px 28px rgba(14, 165, 233, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}
.about-logo-inner {
  min-height: 112px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.about-logo {
  width: min(100%, 300px);
  height: auto;
  max-height: 120px;
  object-fit: contain;
  filter: drop-shadow(0 6px 20px rgba(0, 0, 0, 0.45));
}
html[data-theme="light"] .about-logo {
  filter: drop-shadow(0 6px 18px rgba(79, 70, 229, 0.22));
}
.about-logo.about-logo-dark,
.about-logo.about-logo-light {
  display: none;
}
html[data-theme="dark"] .about-logo.about-logo-dark,
html[data-theme="light"] .about-logo.about-logo-light {
  display: block;
}
.about-brand-name {
  margin: 14px 0 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
}
.about-tagline {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}
.about-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  text-align: justify;
  text-align-last: left;
  text-wrap: pretty;
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.about-desc p { margin: 0; }
.about-features {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.about-feature-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
  background: var(--surface2);
  border-radius: 10px;
  padding: 10px 14px;
}
.about-feature-item svg {
  flex-shrink: 0;
  color: var(--accent);
}
.about-ref {
  width: 100%;
  box-sizing: border-box;
  margin: 2px 0 0;
  text-align: left;
}
.about-ref-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text2);
  margin: 0 0 8px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.about-ref-list {
  margin: 0;
  padding: 0 0 0 18px;
  font-size: 11px;
  line-height: 1.55;
  color: var(--muted);
  text-align: left;
  text-wrap: pretty;
  list-style-type: disc;
}
.about-ref-list li {
  margin-bottom: 10px;
}
.about-ref-list li:last-child {
  margin-bottom: 0;
}
.about-ref-list strong {
  color: var(--text2);
  font-weight: 600;
}
.about-ref-list a.about-ref-link {
  display: block;
  margin-top: 6px;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-word;
}
.about-ref-list a.about-ref-link:hover {
  opacity: 0.85;
}
html[data-theme="light"] .about-ref-list {
  color: rgba(0, 0, 0, 0.48);
}
.about-disclaimer {
  font-size: 11px;
  line-height: 1.55;
  color: var(--muted);
  margin: 16px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  text-align: justify;
  text-align-last: left;
  text-wrap: pretty;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
html[data-theme="light"] .about-disclaimer {
  color: rgba(0, 0, 0, 0.45);
}
.about-team {
  width: 100%;
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  text-align: left;
}
.about-team-copy {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 12px;
}
.about-team-sub {
  font-size: 11px;
  font-weight: 700;
  color: var(--text2);
  margin: 0 0 8px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.about-team-list {
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.about-team-person {
  font-size: 11px;
  line-height: 1.55;
  color: var(--muted);
  background: var(--surface2);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0;
}
.about-team-person p {
  margin: 0 0 4px;
}
.about-team-person p:last-child {
  margin-bottom: 0;
}
.about-team-name {
  color: var(--text);
  font-size: 12px;
}
.about-team-person a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-word;
}
.about-team-support,
.about-team-links {
  font-size: 11px;
  line-height: 1.55;
  color: var(--muted);
  margin: 0 0 8px;
}
.about-team-links a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.settings-about-entry {
  margin-top: 8px;
  padding-top: 4px;
}
.settings-about-btn {
  width: 100%;
  justify-content: center;
  gap: 8px;
}
.about-version {
  font-size: 11px;
  color: var(--muted);
  margin: 10px 0 0;
  text-align: center;
}

/* Giới thiệu: cột có giới hạn trên màn rộng — tránh dòng quá dài & lệch layout */
#aboutDialog .sheet-wrap {
  width: 100%;
  max-width: min(480px, calc(100vw - 32px));
  margin-inline: auto;
  box-sizing: border-box;
}
@media (min-width: 640px) {
  #aboutDialog .sheet-wrap {
    box-shadow: 0 20px 72px rgba(0, 0, 0, 0.38);
  }
  html[data-theme="light"] #aboutDialog .sheet-wrap {
    box-shadow: 0 20px 56px rgba(15, 23, 42, 0.12);
  }
}

.onboard-card {
  width: 100%;
  max-width: 420px;
}

.onboard-intro-card {
  max-height: calc(100dvh - var(--safe-t) - var(--safe-b) - 124px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-height: 720px) {
  .onboard-wrap {
    gap: 12px;
    padding-top: calc(var(--safe-t) + 12px);
    padding-bottom: calc(var(--safe-b) + 18px);
  }

  .onboard-logo-img {
    height: 54px;
  }

  .onboard-intro-card {
    max-height: calc(100dvh - var(--safe-t) - var(--safe-b) - 96px);
  }
}
.onboard-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 6px;
}
.onboard-desc {
  font-size: 13px;
  color: var(--text2);
  margin: 0 0 20px;
  line-height: 1.5;
}
.required-star {
  color: var(--red);
  font-weight: 700;
}
.onboard-err {
  font-size: 13px;
  color: var(--red);
  background: rgba(255,77,109,0.10);
  border-radius: var(--r-s);
  padding: 8px 12px;
  margin: 0 0 12px;
}
.onboard-submit {
  width: 100%;
  margin-top: 8px;
  padding: 13px;
  font-size: 15px;
  font-weight: 700;
}

.onboard-intro-card .onboard-desc {
  margin-bottom: 12px;
}
.onboard-intro-list {
  margin: 0 0 14px 1.1rem;
  padding: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text2);
}
.onboard-intro-list li { margin-bottom: 6px; }
.onboard-intro-disclaimer {
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
  margin: 0 0 16px;
}
.onboard-child-wrap {
  width: 100%;
  max-width: 420px;
}
.ob-vacc-fieldset {
  border: none;
  margin: 0 0 4px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
  color: var(--text);
}
.ob-vacc-legend {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  padding: 0;
  margin-bottom: 4px;
}
.ob-vacc-hint {
  margin: 0 0 10px !important;
  font-size: 12px !important;
}
.ob-vacc-radios {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ob-radio-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  line-height: 1.35;
  min-width: 0;
}
/* Tránh style .field input (width:100%, padding…) áp vào radio — gây vỡ layout */
.ob-checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 10px 0 4px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--text);
  cursor: pointer;
}
.ob-checkbox-label > span {
  color: inherit;
  flex: 1;
  min-width: 0;
}
.ob-checkbox-label input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
  accent-color: var(--blue);
}
.ob-checkbox-label:hover > span {
  color: var(--text);
}
html[data-theme="light"] .ob-checkbox-label {
  color: rgba(0, 0, 0, 0.88);
}
html[data-theme="light"] .ob-checkbox-label:hover > span {
  color: rgba(0, 0, 0, 0.92);
}
.preterm-fields {
  margin-top: 10px;
  padding-top: 4px;
}
.ob-preterm-fieldset {
  margin-bottom: 4px;
}
.settings-preterm {
  margin-top: 12px;
}
.z-ref-tag {
  display: inline-block;
  margin-left: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  opacity: 0.72;
  vertical-align: middle;
}

.ob-vacc-fieldset input[type="radio"] {
  width: auto;
  max-width: none;
  min-width: 0;
  margin: 4px 0 0;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  flex-shrink: 0;
  align-self: flex-start;
  -webkit-appearance: auto;
  appearance: auto;
}
.ob-radio-label input:focus {
  outline: 2px solid rgba(79, 140, 255, 0.5);
  outline-offset: 2px;
}

html[data-theme="light"] .onboard-logo-sub { color: rgba(0,0,0,0.50); }
html[data-theme="light"] .onboard-desc     { color: rgba(0,0,0,0.55); }

/* ── Screen Header ───────────────────────────────────────────── */
.s-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(var(--safe-t) + 14px) 16px 13px;
  background: rgba(7,11,24,0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.s-header h1 {
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
}

.header-subtitle {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.s-header h2 {
  font-size: 17px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
}

/* ── Screen Body ─────────────────────────────────────────────── */
.s-body {
  flex: 1;
  padding: 14px 14px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.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;
}

/* ── Tra cứu sức khỏe trẻ (`tre_em_dictionary`) ─────────────── */
.guide-body {
  padding-bottom: calc(24px + var(--nav-h) + var(--safe-b));
}

.guide-search-wrap {
  margin-bottom: 4px;
}

.guide-search-wrap input[type="search"] {
  width: 100%;
  padding: 11px 12px;
  border-radius: var(--r-m);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 15px;
}

.guide-search-wrap input[type="search"]::placeholder {
  color: var(--muted);
}

.guide-disclaimer {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text2);
  padding: 10px 11px;
  border-radius: var(--r-m);
  border: 1px solid rgba(255, 77, 109, 0.35);
  background: rgba(255, 77, 109, 0.08);
  margin-bottom: 4px;
}

.guide-load-err {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  padding: 12px;
  border-radius: var(--r-m);
  border: 1px solid rgba(255, 77, 109, 0.45);
  background: rgba(255, 77, 109, 0.12);
  margin-bottom: 8px;
}

.guide-load-err code {
  font-size: 11px;
  word-break: break-all;
}

.guide-topic-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guide-loading,
.guide-empty {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  padding: 28px 12px;
}

.guide-search-more {
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
  text-align: center;
  padding: 12px 8px 4px;
  margin: 0;
}

.guide-topic-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  text-align: left;
  padding: 13px 14px;
  border-radius: var(--r-m);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font: inherit;
}

.guide-topic-card:hover,
.guide-topic-card:focus-visible {
  outline: none;
  border-color: var(--accent);
  background: var(--card2);
}

.guide-topic-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}

.guide-topic-snippet {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.guide-panel.is-hidden,
#guideListView[hidden],
#guideDetailView[hidden] {
  display: none !important;
}

.guide-detail-view:not(.is-hidden) {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.guide-to-list {
  align-self: flex-start;
  font-size: 13px;
}

.guide-detail-content {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.guide-detail-article {
  padding: 4px 2px 8px;
}

.guide-detail-h {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
  line-height: 1.35;
  color: var(--text);
}

.guide-detail-lead {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text2);
  margin-bottom: 18px;
}

.guide-detail-sec {
  margin-bottom: 16px;
}

.guide-detail-sec-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  margin-bottom: 6px;
}

.guide-detail-sec-lead {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text2);
  margin: 0 0 8px;
}

.guide-detail-sec--alert .guide-detail-sec-title {
  color: #ff8fa3;
}

.guide-detail-ul {
  margin: 0;
  padding-left: 1.15rem;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
}

.guide-detail-ul li {
  margin-bottom: 6px;
}

.guide-detail-ul li:last-child {
  margin-bottom: 0;
}

.guide-detail-empty {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

html[data-theme="light"] .guide-disclaimer {
  border-color: rgba(220, 38, 38, 0.35);
  background: rgba(220, 38, 38, 0.06);
}

html[data-theme="light"] .guide-load-err {
  border-color: rgba(220, 38, 38, 0.4);
  background: rgba(220, 38, 38, 0.08);
}

html[data-theme="light"] .guide-detail-sec--alert .guide-detail-sec-title {
  color: #be123c;
}

/* ── Card ────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-l);
}

.card-pad { padding: 14px; }

.card-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

/* ── Hero card (screen 1) ────────────────────────────────────── */
.hero-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hero-top {
  display: flex;
  align-items: center;
  gap: 14px;
}

.avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(79,140,255,0.45), rgba(53,212,154,0.45));
  border: 1.5px solid rgba(255,255,255,0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  font-weight: 700;
  color: rgba(255,255,255,0.92);
  flex-shrink: 0;
  user-select: none;
}

.hero-info { flex: 1; min-width: 0; }

.hero-name {
  font-size: 19px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hero-age {
  margin-top: 3px;
  font-size: 13px;
  color: var(--text2);
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
}

.hero-date {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

/* ── Stat boxes ──────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat-box {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  padding: 11px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat-box .sb-label {
  font-size: 10px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-box .sb-value {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1;
  margin-top: 4px;
}

.stat-box .sb-unit {
  font-size: 11px;
  color: var(--text2);
}

.stat-box .sb-z {
  margin-top: 6px;
  font-size: 11px;
  font-weight: 500;
}

.stat-box .sb-who {
  font-size: 11px;
  font-weight: 500;
  margin-top: 2px;
}

.stat-box .sb-delta {
  margin-top: 4px;
  font-size: 10px;
  color: var(--text2);
  white-space: nowrap;
}

/* ── WHO badges ──────────────────────────────────────────────── */
.who-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.badge-ok    { border-color: rgba(53,212,154,0.45); background: rgba(53,212,154,0.10); color: #5de8b4; }
.badge-ok    .badge-dot { background: #35d49a; }
.badge-warn  { border-color: rgba(255,191,60,0.45); background: rgba(255,191,60,0.10); color: #ffd06e; }
.badge-warn  .badge-dot { background: #ffbf3c; }
.badge-danger{ border-color: rgba(255,77,109,0.45); background: rgba(255,77,109,0.10); color: #ff7a94; }
.badge-danger .badge-dot { background: #ff4d6d; }
.badge-neutral{ border-color: var(--border); background: var(--surface2); color: var(--text2); }
.badge-neutral .badge-dot { background: rgba(255,255,255,0.3); }

/* ── Info chips ──────────────────────────────────────────────── */
.info-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.info-chip {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--r-s);
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text2);
}

.info-chip strong { color: var(--text); font-weight: 600; }

/* ── CTA buttons ─────────────────────────────────────────────── */
.cta-group {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--r-m);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  transition: background 0.1s;
  user-select: none;
  text-align: center;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: rgba(79,140,255,0.18);
  border-color: rgba(79,140,255,0.48);
  color: #90bbff;
}
.btn-primary:active { background: rgba(79,140,255,0.24); }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text2);
}
.btn-ghost:active { background: var(--surface2); }

.btn-danger {
  background: rgba(255,77,109,0.13);
  border-color: rgba(255,77,109,0.38);
  color: #ff7a94;
}
.btn-danger:active { background: rgba(255,77,109,0.20); }

.btn-sm {
  padding: 9px 14px;
  font-size: 13px;
  border-radius: var(--r-s);
  width: auto;
}

/* ── Icon button ─────────────────────────────────────────────── */
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 0;
  background: rgba(255,255,255,0.06);
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.1s;
}
.icon-btn:active { background: rgba(255,255,255,0.12); }

/* Sort pill */
.sort-pill {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.05);
  color: var(--text2);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}
.sort-pill:active { background: var(--surface2); }

.history-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
}
.history-action-pill {
  border-color: rgba(129, 140, 248, 0.45);
}
html[data-theme="light"] .history-action-pill {
  border-color: rgba(37, 99, 235, 0.4);
}

.card.card-pad.history-filter-card {
  padding: 10px 12px;
}
.history-filter-card {
  margin-top: 4px;
}
.history-filter-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}
.history-filter-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(108px, 0.9fr) minmax(108px, 0.9fr) auto;
  gap: 6px 8px;
  align-items: end;
}
.history-filter-grid > .field {
  gap: 4px;
  min-width: 0;
}
.history-filter-grid .field input {
  padding: 9px 10px;
  font-size: 14px;
}
.history-filter-actions {
  display: flex;
  align-items: flex-end;
  padding-bottom: 1px;
}
.history-filter-actions .btn {
  padding: 9px 12px;
  font-size: 13px;
  white-space: nowrap;
}
@media (max-width: 560px) {
  .history-filter-grid {
    grid-template-columns: 1fr 1fr auto;
    gap: 8px 6px;
  }
  .history-filter-search {
    grid-column: 1 / -1;
  }
}

/* Báo cáo đi khám */
#clinicReportDialog .sheet-wrap.clinic-report-sheet {
  width: 100%;
  max-width: 100%;
  margin-inline: 0;
  border-radius: 0;
  min-height: 100dvh;
  max-height: 100dvh;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}
#clinicReportDialog .clinic-report-body {
  flex: 1;
  min-height: 0;
  max-height: none;
  padding: 4px 16px 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#clinicReportDialog .clinic-report-footer {
  flex-shrink: 0;
  padding: 0 16px;
}
.clinic-print-hint {
  font-size: 11px;
  line-height: 1.45;
  color: var(--muted);
  margin: 10px 0 0 0;
  text-align: left;
  max-width: none;
}
.clinic-print-hint strong {
  font-weight: 600;
  color: var(--text2);
}
.cr-doc {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  text-align: left;
}
.cr-doc h1 {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 6px;
}
.cr-doc h2 {
  font-size: 14px;
  font-weight: 600;
  margin: 14px 0 8px;
  color: var(--text2);
}
.cr-doc .cr-meta .cr-brand-wordmark {
  font-weight: 700;
  white-space: nowrap;
}

.cr-meta {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 12px;
}
.cr-table-wrap {
  overflow-x: auto;
  margin: 6px 0;
  -webkit-overflow-scrolling: touch;
}
.cr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
.cr-table th,
.cr-table td {
  border: 1px solid var(--border);
  padding: 6px 7px;
  text-align: left;
  vertical-align: top;
}
.cr-table th {
  background: var(--surface2);
  font-weight: 600;
  white-space: nowrap;
}
.cr-table .cr-num {
  text-align: right;
  white-space: nowrap;
}

.cr-doc .cr-table td.cr-num {
  white-space: normal;
  max-width: 11rem;
  line-height: 1.35;
}

.cr-doc .cr-table th.cr-num {
  white-space: nowrap;
}
.cr-kv {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.cr-kv th {
  text-align: left;
  font-weight: 600;
  color: var(--text2);
  width: 38%;
  border: 1px solid var(--border);
  padding: 6px 10px;
  background: var(--surface2);
}
.cr-kv td {
  border: 1px solid var(--border);
  padding: 6px 10px;
}
.cr-highlight {
  background: rgba(79, 140, 255, 0.08);
  border-radius: var(--r-s);
  padding: 10px 12px;
  margin: 8px 0;
}
.cr-foot {
  font-size: 11px;
  color: var(--muted);
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  line-height: 1.5;
}

.cr-nutrition-list {
  margin: 6px 0 10px 1.1rem;
  padding: 0;
  font-size: 12px;
  line-height: 1.45;
}

.cr-cite {
  font-size: 10px;
  margin-top: 8px !important;
}

.cr-charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 8px 0 16px;
}

@media (max-width: 520px) {
  .cr-charts-grid {
    grid-template-columns: 1fr;
  }
}

.cr-chart-cell {
  border: 1px solid var(--border);
  border-radius: var(--r-l);
  padding: 10px;
  background: var(--surface2);
}

.cr-chart-cap {
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text2);
}

.cr-chart-img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
}

.cr-chart-miss {
  font-size: 12px;
  color: var(--muted);
  padding: 8px 4px;
}

/* ── Form ────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
}

.label-opt { color: var(--muted); font-weight: 400; }

.field input:not([type="radio"]):not([type="checkbox"]),
.field select {
  background: rgba(255,255,255,0.065);
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  color: var(--text);
  font-size: 16px;
  padding: 13px 14px;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
}

.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' viewBox='0 0 12 7'%3E%3Cpath d='M1 1l5 5 5-5' stroke='rgba(255,255,255,0.45)' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.field input::placeholder { color: var(--muted); }
/* Make the browser date-picker calendar icon visible in dark mode */
.field input[type="date"] { color-scheme: dark; }
html[data-theme="light"] .field input[type="date"] { color-scheme: light; }

.field input:not([type="radio"]):not([type="checkbox"]):focus,
.field select:focus {
  border-color: rgba(79,140,255,0.55);
  box-shadow: 0 0 0 3px rgba(79,140,255,0.13);
}

/* ── Alert ───────────────────────────────────────────────────── */
.alert {
  margin-top: 12px;
  padding: 11px 14px;
  border-radius: var(--r-m);
  border: 1px solid rgba(255,191,60,0.45);
  background: rgba(255,191,60,0.10);
  color: rgba(255,255,255,0.86);
  font-size: 13px;
  line-height: 1.4;
}

.alert[hidden] { display: none; }

/* ── Android hardware back toast ─────────────────────────────── */
.android-back-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--safe-b) + 18px);
  z-index: 9999;
  max-width: min(86vw, 340px);
  padding: 10px 14px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 999px;
  background: rgba(8,13,28,0.92);
  color: rgba(255,255,255,0.94);
  box-shadow: 0 10px 28px rgba(0,0,0,0.28);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.android-back-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

html[data-theme="light"] .android-back-toast {
  border-color: rgba(0,0,0,0.08);
  background: rgba(20,28,44,0.94);
}

/* ── Chart ───────────────────────────────────────────────────── */
.chart-tabs-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  overflow: hidden;
  margin-bottom: 12px;
}

.chart-tab {
  padding: 10px 6px;
  border: 0;
  background: transparent;
  color: var(--text2);
  font-size: 12px;
  font-weight: 500;
  transition: background 0.1s, color 0.1s;
  min-width: 0;
  line-height: 1.25;
}

.chart-tab:not(:last-child) { border-right: 1px solid var(--border); }
.chart-tab[aria-selected="true"] { background: rgba(255,255,255,0.08); color: var(--text); }

.chart-wrap {
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  background: rgba(255,255,255,0.02);
  padding: 8px 6px 4px;
  overflow: hidden;
}

canvas { width: 100%; height: auto; display: block; }

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text2);
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 5px;
}

/* ── History cards ───────────────────────────────────────────── */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-notice {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  padding: 10px 14px;
  border-radius: var(--r-l);
  background: rgba(53,212,154,0.12);
  border: 1px solid rgba(53,212,154,0.35);
  color: #5de8b4;
}

html[data-theme="light"] .history-notice {
  background: rgba(53,212,154,0.14);
  border-color: rgba(53,212,154,0.35);
  color: #0d8f5a;
}

.hcard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-l);
  overflow: hidden;
}

.hcard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  background: rgba(255,255,255,0.028);
  border-bottom: 1px solid var(--border);
  gap: 8px;
}

.hcard-date {
  font-size: 14px;
  font-weight: 600;
}

.hcard-age {
  font-size: 12px;
  color: var(--muted);
  background: rgba(255,255,255,0.06);
  border-radius: 6px;
  padding: 3px 8px;
  white-space: nowrap;
}

.hcard-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* metrics grid in each card */
.hcard-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.hcard-metrics--no-bmi {
  grid-template-columns: repeat(3, 1fr);
}

.chart-tab[hidden] {
  display: none;
}

.hm {
  text-align: center;
}

.hm-k {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--muted);
  margin-bottom: 3px;
}

.hm-v {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.hm-z {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 500;
}

.hm-rate {
  margin-top: 3px;
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
}

.hm-rate-up   { color: #35d49a; }
.hm-rate-down { color: #ff4d6d; }
.hm-rate-zero { color: var(--muted); }

/* z-score colours */
.z-ok      { color: #35d49a; }
.z-warn    { color: #ffbf3c; }
.z-danger  { color: #ff4d6d; }
.z-neutral { color: var(--muted); }

/* deltas */
.hcard-deltas {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.dchip {
  font-size: 12px;
  color: var(--text2);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 4px 9px;
}

.dchip-up   { color: #35d49a; border-color: rgba(53,212,154,0.22); background: rgba(53,212,154,0.06); }
.dchip-down { color: #ff4d6d; border-color: rgba(255,77,109,0.22); background: rgba(255,77,109,0.06); }

/* footer */
.hcard-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hcard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
  justify-content: flex-end;
}

.hcard-note {
  font-size: 12px;
  color: var(--muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Inline edit on history card */
.hcard-head--edit {
  flex-wrap: wrap;
  align-items: flex-start;
}

.hcard-edit-date {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.hcard-edit-date-lab {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--muted);
}

.hcard-inp {
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 6px 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.hcard-inp::placeholder {
  color: var(--muted);
  font-weight: 500;
}

.hcard-inp:focus {
  outline: 2px solid rgba(53, 212, 154, 0.35);
  outline-offset: 1px;
}

.hm--edit .hcard-inp {
  text-align: center;
}

.hcard-bmi-preview {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  padding: 6px 4px;
}

.hcard-foot--edit {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.hcard-foot--edit .hcard-actions {
  justify-content: flex-end;
}

.hcard-field-note {
  font-weight: 500;
  text-align: left;
}

.hcard-inline-err {
  font-size: 12px;
  font-weight: 500;
  color: #ff4d6d;
  line-height: 1.35;
}

/* ── Settings screen ─────────────────────────────────────────── */
.settings-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 2px;
}

.settings-btn-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Empty state ─────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 36px 20px;
}

.empty-icon { font-size: 38px; margin-bottom: 10px; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text2); margin-bottom: 5px; }
.empty-desc  { font-size: 13px; color: var(--muted); line-height: 1.5; }

/* ── WHO footnote ────────────────────────────────────────────── */
.who-note {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  line-height: 1.45;
  padding: 4px 8px;
}

/* ── Bottom Nav ──────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(6,9,18,0.88);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: row;
  align-items: stretch;
  z-index: 100;
}

.nav-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 0;
  transition: color 0.12s;
  -webkit-tap-highlight-color: transparent;
  flex: 1;
  min-width: 0;
}

.nav-btn span {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1px;
}

.nav-btn.active { color: var(--blue); }

.nav-btn.nav-btn--feature-off:not(.active) {
  opacity: 0.62;
}

/* ── Hướng dẫn lần đầu (coach marks) ─────────────────────────── */
.usage-guide-layer {
  position: fixed;
  inset: 0;
  z-index: 450;
  pointer-events: none;
}
.usage-guide-blocker {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  background: transparent;
}
.usage-guide-spotlight {
  display: none;
  position: fixed;
  pointer-events: none;
  box-sizing: border-box;
  border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.74);
  border: 2px solid rgba(79, 140, 255, 0.9);
  z-index: 1;
  transition: top 0.2s ease, left 0.2s ease, width 0.2s ease, height 0.2s ease;
}
.usage-guide-tooltip {
  pointer-events: auto;
  position: fixed;
  left: max(16px, env(safe-area-inset-left, 0));
  right: max(16px, env(safe-area-inset-right, 0));
  width: auto;
  max-width: 400px;
  margin: 0 auto;
  padding: 14px 16px 16px;
  z-index: 2;
  max-height: min(44vh, 300px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
.usage-guide-progress {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.usage-guide-title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
}
.usage-guide-text {
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text2);
}
.usage-guide-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
body.usage-guide-open {
  overflow: hidden;
}

html[data-theme="light"] .usage-guide-spotlight {
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.55);
  border-color: rgba(37, 99, 235, 0.85);
}

/* ── Dialog ──────────────────────────────────────────────────── */
/* ── Confirm dialog ──────────────────────────────────────────── */
#confirmDialog {
  border: 0;
  background: transparent;
  padding: 0;
  /* Center in viewport */
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(360px, calc(100vw - 40px));
  height: fit-content;
  max-height: calc(100dvh - 40px);
  z-index: 300;
}
#confirmDialog[open] { display: block; }
#confirmDialog::backdrop {
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(6px) saturate(0.6);
}

#measureConflictDialog {
  border: 0;
  background: transparent;
  padding: 0;
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(560px, calc(100vw - 32px));
  height: fit-content;
  max-height: calc(100dvh - 32px);
  z-index: 300;
  overflow: hidden;
}
#measureConflictDialog[open] { display: block; }
#measureConflictDialog::backdrop {
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(6px) saturate(0.6);
}

.measure-conflict-card .measure-conflict-lead {
  color: var(--text2);
  font-size: 14px;
  line-height: 1.45;
  margin-bottom: 16px;
}

.measure-conflict-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}
@media (max-width: 520px) {
  .measure-conflict-cols {
    grid-template-columns: 1fr;
  }
}

.measure-conflict-col {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  min-width: 0;
}

.measure-conflict-colhead {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  margin-bottom: 8px;
}

.measure-conflict-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 13px;
  line-height: 1.45;
}

.measure-conflict-list li {
  margin-bottom: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
}

.mc-k { color: var(--muted); min-width: 4.2em; }
.mc-v { font-weight: 600; color: var(--text); }
.mc-v-note { font-weight: 500; word-break: break-word; }

.measure-conflict-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

html[data-theme="light"] .measure-conflict-col {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.10);
}

.dialog-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-l);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  padding: 22px 20px 18px;
  color: var(--text);
}

.dialog-card h3 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

.dialog-card p {
  color: var(--text2);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 20px;
}

.dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.dialog-actions .btn {
  min-width: 80px;
  font-weight: 600;
  font-size: 14px;
  padding: 9px 16px;
}
.dialog-actions .btn-danger {
  background: rgba(255,77,109,0.18);
  border-color: rgba(255,77,109,0.45);
  color: #ff4d6d;
}
.dialog-actions .btn-danger:active { background: rgba(255,77,109,0.28); }

html[data-theme="light"] .dialog-card {
  background: #ffffff;
  border-color: rgba(0,0,0,0.10);
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
}
html[data-theme="light"] .dialog-card h3 { color: rgba(0,0,0,0.88); }
html[data-theme="light"] .dialog-card p  { color: rgba(0,0,0,0.60); }

/* ── Profile card (Home panel 1) ─────────────────────────────── */
.profile-card {
  overflow: hidden;
}

.profile-header {
  padding: 18px 16px 20px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 14px;
  background: linear-gradient(150deg, rgba(79,140,255,0.22) 0%, rgba(53,212,154,0.14) 100%);
}

.profile-avatar-lg {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  border: 2px solid rgba(255,255,255,0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  user-select: none;
  flex-shrink: 0;
}

.profile-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.profile-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* Edit / switch action buttons on profile card */
.profile-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}
.profile-action-btn {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.10);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}
.profile-action-btn:hover { background: rgba(255,255,255,0.22); }
html[data-theme="light"] .profile-action-btn {
  border-color: rgba(0,0,0,0.14);
  background: rgba(0,0,0,0.05);
}
html[data-theme="light"] .profile-action-btn:hover { background: rgba(0,0,0,0.10); }
.profile-count-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
}

/* ── Bottom-sheet dialog ──────────────────────────────────────── */
dialog.bottom-sheet {
  position: fixed;
  inset: 0;
  margin: 0;
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  padding: 0;
  display: none;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  z-index: 200;
}
dialog.bottom-sheet[open] {
  display: flex;
}
dialog.bottom-sheet::backdrop {
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(6px) saturate(0.6);
}
.sheet-wrap {
  background: var(--card);
  border-radius: 0 0 20px 20px;
  padding: 0 0 calc(16px + var(--safe-b));
  max-height: 92dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 0 auto 10px;
  flex-shrink: 0;
  order: 99;  /* sits at the bottom of the sheet */
}
.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-t) + 14px) max(16px, var(--safe-r)) 10px max(16px, var(--safe-l));
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sheet-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.sheet-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--card2);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.sheet-close:hover { color: var(--text); background: var(--border); }
.sheet-form { padding: 16px max(16px, var(--safe-r)) 16px max(16px, var(--safe-l)); }
.sheet-footer {
  padding: 12px max(16px, var(--safe-r)) 16px max(16px, var(--safe-l));
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
/* Sheet action buttons — always solid/high-contrast regardless of gender theme */
.sheet-footer .btn-primary,
.sheet-form .onboard-submit {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px;
  font-size: 15px;
  font-weight: 700;
  background: #4f46e5 !important;
  border: none !important;
  color: #fff !important;
  border-radius: var(--r-m);
  box-shadow: 0 2px 12px rgba(79,70,229,0.35) !important;
}
.sheet-footer .btn-primary:active,
.sheet-form .onboard-submit:active {
  background: #4338ca !important;
  box-shadow: none !important;
}

/* ── Switch child list ────────────────────────────────────────── */
.switch-sheet-hint {
  margin: 0 14px 10px;
  padding: 0 2px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text2);
}
.switch-child-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.switch-child-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r-m);
  border: 2px solid var(--border);
  background: var(--card2);
  background: var(--card2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}
.switch-child-item.active {
  border-color: var(--accent);
  background: rgba(99,102,241,0.07);
}
.switch-child-item:hover:not(.active) { border-color: var(--text2); }
.switch-child-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--card);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  overflow: hidden;
}
.switch-child-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.switch-child-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.switch-child-age {
  font-size: 12px;
  color: var(--text2);
  margin-top: 2px;
}
.switch-child-active-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.switch-child-delete {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: none;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.switch-child-delete:hover { color: var(--red); background: rgba(255,77,109,0.12); }
html[data-theme="light"] .switch-child-item { background: #fff; }
html[data-theme="light"] .switch-child-item.active { background: rgba(99,102,241,0.06); }

.profile-name {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 5px;
}

.profile-sex-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.profile-age {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.4;
}

.pmeta-chip {
  font-size: 13px;
  color: var(--text2);
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 10px;
}

.profile-last {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

/* ── Status card (Home panel 2) ───────────────────────────────── */
.status-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}

.status-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
}

.status-card-date {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
  flex-shrink: 0;
}

.status-card-body {
  padding: 12px 12px 10px;
}

/* Faltering weight / nutrition alerts (home) */
.nutrition-alert-inline {
  margin: 0 0 12px;
  padding: 10px 11px;
  border-radius: var(--r-m);
  border: 1px solid rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.10);
}
.nutrition-alert-inline-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.nutrition-alert-inline-lead {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text2);
  margin: 0 0 8px;
}
.nutrition-alert-list {
  margin: 0 0 8px 1rem;
  padding: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text);
}
.nutrition-alert-inline-limit {
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
  margin: 0 0 6px;
}
.nutrition-alert-cite {
  font-size: 10px;
  line-height: 1.35;
  color: var(--muted);
  margin: 0;
}

html[data-theme="light"] .nutrition-alert-inline {
  border-color: rgba(217, 119, 6, 0.40);
  background: rgba(251, 191, 36, 0.12);
}

.usage-guide-layer {
  position: fixed;
  inset: 0;
  z-index: 450;
  pointer-events: none;
}
.usage-guide-blocker {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  background: transparent;
}
.usage-guide-spotlight {
  display: none;
  position: fixed;
  pointer-events: none;
  box-sizing: border-box;
  border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.74);
  border: 2px solid rgba(79, 140, 255, 0.9);
  z-index: 1;
  transition: top 0.2s ease, left 0.2s ease, width 0.2s ease, height 0.2s ease;
}
.usage-guide-tooltip {
  pointer-events: auto;
  position: fixed;
  left: max(16px, env(safe-area-inset-left, 0));
  right: max(16px, env(safe-area-inset-right, 0));
  width: auto;
  max-width: 400px;
  margin: 0 auto;
  padding: 14px 16px 16px;
  z-index: 2;
  max-height: min(44vh, 300px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
.usage-guide-progress {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.usage-guide-title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
}
.usage-guide-text {
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text2);
}
.usage-guide-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
body.usage-guide-open {
  overflow: hidden;
}

html[data-theme="light"] .usage-guide-spotlight {
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.55);
  border-color: rgba(37, 99, 235, 0.85);
}

/* ── Gender-based light theme ─────────────────────────────────── */

/* Boy (male) - blue */
html[data-theme="light"][data-sex="male"] .profile-header {
  background: linear-gradient(150deg, #bfdbfe 0%, #dbeafe 100%);
}
html[data-theme="light"][data-sex="male"] .nav-btn.active { color: #2563eb; }
html[data-theme="light"][data-sex="male"] .btn-primary {
  background: rgba(37,99,235,0.14);
  border-color: rgba(37,99,235,0.42);
  color: #1d4ed8;
}
html[data-theme="light"][data-sex="male"] .field input:not([type="radio"]):not([type="checkbox"]):focus,
html[data-theme="light"][data-sex="male"] .field select:focus {
  border-color: rgba(37,99,235,0.55);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.10);
}
html[data-theme="light"][data-sex="male"] .avatar-option.selected { border-color: #2563eb; }
html[data-theme="light"][data-sex="male"] .theme-toggle[aria-checked="true"] {
  background: rgba(37,99,235,0.22);
  border-color: rgba(37,99,235,0.50);
}
html[data-theme="light"][data-sex="male"] .pmeta-chip {
  background: rgba(37,99,235,0.06);
  border-color: rgba(37,99,235,0.18);
  color: #1e40af;
}

/* Girl (female) - rose */
html[data-theme="light"][data-sex="female"] .profile-header {
  background: linear-gradient(150deg, #fbcfe8 0%, #fce7f3 100%);
}
html[data-theme="light"][data-sex="female"] .nav-btn.active { color: #db2777; }
html[data-theme="light"][data-sex="female"] .btn-primary {
  background: rgba(219,39,119,0.12);
  border-color: rgba(219,39,119,0.40);
  color: #be185d;
}
html[data-theme="light"][data-sex="female"] .field input:not([type="radio"]):not([type="checkbox"]):focus,
html[data-theme="light"][data-sex="female"] .field select:focus {
  border-color: rgba(219,39,119,0.50);
  box-shadow: 0 0 0 3px rgba(219,39,119,0.10);
}
html[data-theme="light"][data-sex="female"] .avatar-option.selected { border-color: #db2777; }
html[data-theme="light"][data-sex="female"] .theme-toggle[aria-checked="true"] {
  background: rgba(219,39,119,0.20);
  border-color: rgba(219,39,119,0.48);
}
html[data-theme="light"][data-sex="female"] .pmeta-chip {
  background: rgba(219,39,119,0.06);
  border-color: rgba(219,39,119,0.18);
  color: #9d174d;
}

/* Light mode overrides for profile/status cards */
html[data-theme="light"] .profile-avatar-lg {
  background: rgba(0,0,0,0.06);
  border-color: rgba(255,255,255,0.80);
}
html[data-theme="light"] .pmeta-chip {
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.09);
  color: rgba(0,0,0,0.62);
}
html[data-theme="light"] .status-card-header { border-bottom-color: rgba(0,0,0,0.07); }

/* ── Theme toggle ─────────────────────────────────────────────── */
.theme-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.theme-row-label {
  font-size: 14px;
  font-weight: 500;
}

.theme-row-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.theme-toggle {
  position: relative;
  width: 50px;
  height: 28px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: rgba(255,255,255,0.08);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}

.theme-toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255,255,255,0.55);
  transition: transform 0.2s, background 0.2s;
}

.theme-toggle[aria-checked="true"] {
  background: rgba(79,140,255,0.30);
  border-color: rgba(79,140,255,0.55);
}

.theme-toggle[aria-checked="true"]::after {
  transform: translateX(22px);
  background: var(--blue);
}

.theme-toggle-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 5px;
  pointer-events: none;
  font-size: 10px;
  line-height: 1;
}

/* ── Avatar picker ────────────────────────────────────────────── */
.avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 6px 0 10px;
}

.avatar-lg {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(79,140,255,0.45), rgba(53,212,154,0.45));
  border: 2px solid rgba(255,255,255,0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  cursor: pointer;
  user-select: none;
  transition: transform 0.1s, box-shadow 0.1s;
}

.avatar-lg:active { transform: scale(0.94); }
.avatar-lg:hover  { box-shadow: 0 0 0 3px rgba(79,140,255,0.25); }

.avatar-hint {
  font-size: 12px;
  color: var(--muted);
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.avatar-option {
  font-size: 26px;
  line-height: 1;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-m);
  border: 1.5px solid transparent;
  background: rgba(255,255,255,0.04);
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, transform 0.05s;
  -webkit-tap-highlight-color: transparent;
}

.avatar-option:hover { background: rgba(255,255,255,0.08); }
.avatar-option:active { transform: scale(0.88); }

.avatar-option.selected {
  border-color: var(--blue);
  background: rgba(79,140,255,0.18);
}

/* ── Light theme ──────────────────────────────────────────────── */
html[data-theme="light"] body {
  background:
    radial-gradient(ellipse 900px 500px at 15% 0%, rgba(79,140,255,0.14) 0%, transparent 60%),
    radial-gradient(ellipse 700px 400px at 85% 5%, rgba(53,212,154,0.10) 0%, transparent 60%),
    linear-gradient(180deg, #dbeafe 0%, #f0f4ff 40%, #f0fdf4 100%);
  background-color: var(--native-bg);
}

html[data-theme="light"] {
  --native-bg: #dbeafe;
  --surface: rgba(255,255,255,0.72);
  --surface2: rgba(255,255,255,0.88);
  --border: rgba(0,0,0,0.10);
  --text: rgba(0,0,0,0.88);
  --text2: rgba(0,0,0,0.62);
  --muted: rgba(0,0,0,0.38);
  --card:  #ffffff;
  --card2: #f3f4f6;
  --accent: #2563eb;
}
html[data-theme="light"][data-sex="female"] {
  --accent: #db2777;
}

html[data-theme="light"] .s-header {
  background: rgba(255,255,255,0.82);
  border-bottom-color: rgba(0,0,0,0.08);
}

html[data-theme="light"] .bottom-nav {
  background: rgba(255,255,255,0.88);
  border-top-color: rgba(0,0,0,0.08);
}

html[data-theme="light"] .card {
  background: rgba(255,255,255,0.72);
  border-color: rgba(0,0,0,0.09);
}

html[data-theme="light"] .stat-box {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.09);
}

html[data-theme="light"] .hcard {
  background: rgba(255,255,255,0.82);
  border-color: rgba(0,0,0,0.09);
}

html[data-theme="light"] .hcard-head {
  background: rgba(0,0,0,0.025);
  border-bottom-color: rgba(0,0,0,0.07);
}

html[data-theme="light"] .hcard-age {
  background: rgba(0,0,0,0.06);
}

html[data-theme="light"] .hcard-inp {
  background: rgba(255,255,255,0.92);
  border-color: rgba(0,0,0,0.12);
  color: rgba(0,0,0,0.88);
}

html[data-theme="light"] .field input:not([type="radio"]):not([type="checkbox"]),
html[data-theme="light"] .field select {
  background: rgba(255,255,255,0.90);
  border-color: rgba(0,0,0,0.15);
  color: rgba(0,0,0,0.88);
}

html[data-theme="light"] .field input::placeholder { color: rgba(0,0,0,0.30); }

html[data-theme="light"] .btn {
  color: rgba(0,0,0,0.80);
  border-color: rgba(0,0,0,0.12);
  background: rgba(255,255,255,0.70);
}

html[data-theme="light"] .btn-primary {
  background: rgba(79,140,255,0.16);
  border-color: rgba(79,140,255,0.45);
  color: #1d5cd6;
}

html[data-theme="light"] .btn-ghost {
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.11);
  color: rgba(0,0,0,0.62);
}

html[data-theme="light"] .btn-danger {
  background: rgba(255,77,109,0.10);
  border-color: rgba(255,77,109,0.35);
  color: #d63050;
}

html[data-theme="light"] .info-chip {
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.09);
  color: rgba(0,0,0,0.60);
}

html[data-theme="light"] .info-chip strong { color: rgba(0,0,0,0.85); }

html[data-theme="light"] .dchip {
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.09);
  color: rgba(0,0,0,0.60);
}

html[data-theme="light"] .dchip-up   { color: #12835c; border-color: rgba(18,131,92,0.25); background: rgba(18,131,92,0.08); }
html[data-theme="light"] .dchip-down { color: #c0243c; border-color: rgba(192,36,60,0.25); background: rgba(192,36,60,0.08); }

html[data-theme="light"] .sort-pill {
  background: rgba(0,0,0,0.05);
  border-color: rgba(0,0,0,0.11);
  color: rgba(0,0,0,0.58);
}

html[data-theme="light"] .chart-tabs-bar,
html[data-theme="light"] .chart-wrap {
  border-color: rgba(0,0,0,0.10);
}

html[data-theme="light"] .chart-tab { color: rgba(0,0,0,0.52); }
html[data-theme="light"] .chart-tab:not(:last-child) { border-right-color: rgba(0,0,0,0.09); }
html[data-theme="light"] .chart-tab[aria-selected="true"] {
  background: rgba(0,0,0,0.06);
  color: rgba(0,0,0,0.88);
}

html[data-theme="light"] .chart-wrap { background: rgba(255,255,255,0.60); }

html[data-theme="light"] .avatar {
  background: linear-gradient(135deg, rgba(79,140,255,0.25), rgba(53,212,154,0.25));
  border-color: rgba(0,0,0,0.10);
}

html[data-theme="light"] .avatar-lg {
  background: linear-gradient(135deg, rgba(79,140,255,0.25), rgba(53,212,154,0.25));
  border-color: rgba(0,0,0,0.10);
}

html[data-theme="light"] .avatar-option { background: rgba(0,0,0,0.04); }
html[data-theme="light"] .avatar-option:hover { background: rgba(0,0,0,0.08); }
html[data-theme="light"] .avatar-option.selected { background: rgba(79,140,255,0.14); }

html[data-theme="light"] .avatar-grid { border-top-color: rgba(0,0,0,0.08); }

html[data-theme="light"] .theme-toggle {
  background: rgba(0,0,0,0.08);
  border-color: rgba(0,0,0,0.15);
}

html[data-theme="light"] .theme-toggle::after {
  background: rgba(0,0,0,0.45);
}

html[data-theme="light"] .who-note { color: rgba(0,0,0,0.36); }

html[data-theme="light"] .empty-title { color: rgba(0,0,0,0.72); }
html[data-theme="light"] .empty-desc  { color: rgba(0,0,0,0.42); }

html[data-theme="light"] .icon-btn {
  background: rgba(0,0,0,0.06);
  color: rgba(0,0,0,0.58);
}

html[data-theme="light"] .badge-neutral {
  border-color: rgba(0,0,0,0.12);
  background: rgba(0,0,0,0.05);
  color: rgba(0,0,0,0.55);
}

html[data-theme="light"] .chart-legend { color: rgba(0,0,0,0.58); }

html[data-theme="light"] .settings-label { color: rgba(0,0,0,0.38); }
html[data-theme="light"] .header-subtitle { color: rgba(0,0,0,0.38); }


html[data-theme="light"] .nav-btn.active { color: var(--blue); }
html[data-theme="light"] .nav-btn { color: rgba(0,0,0,0.38); }

/* ── Back button ─────────────────────────────────────────────── */
.back-btn {
  border: 0;
  background: rgba(255,255,255,0.08);
  color: var(--text2);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.12s;
}
.back-btn:active { background: rgba(255,255,255,0.14); }
html[data-theme="light"] .back-btn {
  background: rgba(0,0,0,0.06);
  color: rgba(0,0,0,0.55);
}

/* ── Vaccination panel (home screen) ─────────────────────────── */
.vacc-panel {
  overflow: hidden;
}
.vacc-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.vacc-panel-icon { font-size: 18px; }
.vacc-panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.vacc-panel-body {
  padding: 12px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.vacc-panel-hint {
  font-size: 13px;
  color: var(--muted);
}
.vacc-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.vacc-stat-ok {
  font-size: 13px;
  color: var(--green);
  font-weight: 500;
}
.vacc-stat-warn {
  font-size: 13px;
  color: var(--yellow);
  font-weight: 500;
}
.vacc-alert {
  font-size: 13px;
  color: var(--yellow);
  background: rgba(255,191,60,0.10);
  border: 1px solid rgba(255,191,60,0.25);
  border-radius: var(--r-s);
  padding: 8px 10px;
  line-height: 1.4;
}

.vacc-preterm-notes {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text2);
  background: rgba(79,140,255,0.08);
  border: 1px solid rgba(79,140,255,0.22);
  border-radius: var(--r-s);
  padding: 10px 12px;
  margin-bottom: 10px;
}
.vacc-preterm-notes-title {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.vacc-preterm-pma {
  margin: 0 0 8px;
  font-size: 12px;
}
.vacc-preterm-list {
  margin: 0 0 8px;
  padding-left: 1.1em;
}
.vacc-preterm-item {
  margin-bottom: 8px;
}
.vacc-preterm-item ul {
  margin: 4px 0 0;
  padding-left: 1.1em;
}
.vacc-preterm-item li {
  margin-bottom: 4px;
}
.vacc-preterm-foot {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
}

.hcard-metrics--no-bmi {
  grid-template-columns: repeat(3, 1fr);
}
.vacc-next {
  font-size: 13px;
  color: var(--text2);
}
.vacc-next strong { color: var(--text); }
.vacc-cta {
  align-self: flex-start;
  border: 0;
  background: rgba(79,140,255,0.15);
  color: var(--blue);
  border-radius: var(--r-s);
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.12s;
}
.vacc-cta:active { background: rgba(79,140,255,0.25); }

html[data-theme="light"] .vacc-panel-header { border-bottom-color: rgba(0,0,0,0.08); }
html[data-theme="light"] .vacc-panel-title  { color: rgba(0,0,0,0.80); }
html[data-theme="light"] .vacc-next         { color: rgba(0,0,0,0.52); }
html[data-theme="light"] .vacc-next strong  { color: rgba(0,0,0,0.80); }
html[data-theme="light"] .vacc-cta {
  background: rgba(79,140,255,0.12);
  color: #2563eb;
}

/* ── Catch-up rows inside home vacc panel ────────────────────── */
.vp-cu-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-s);
  overflow: hidden;
}

.vp-cu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.vp-cu-row:last-child { border-bottom: 0; }

.vp-cu-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}

.vp-cu-badge {
  font-size: 10px;
  font-weight: 700;
  border-radius: 20px;
  padding: 2px 7px;
  white-space: nowrap;
  flex-shrink: 0;
}
.vp-cu-overdue     { background: rgba(255,77,109,0.13);  color: var(--red); }
.vp-cu-upcoming    { background: rgba(79,140,255,0.12);  color: var(--blue); }
.vp-cu-urgent      { background: rgba(239,68,68,0.18);   color: #ef4444; }
.vp-cu-p2          { background: rgba(249,115,22,0.16);  color: #f97316; }
.vp-cu-expired     { background: rgba(156,163,175,0.18); color: var(--muted); }
.vp-cu-superseded  { background: rgba(139,92,246,0.16);  color: #a78bfa; }
.vp-cu-skipped     { background: rgba(156,163,175,0.16); color: var(--muted); }

.vp-cu-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.vp-cu-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.vp-cu-dose {
  font-size: 11px;
  font-weight: 500;
  background: rgba(255,255,255,0.08);
  border-radius: 5px;
  padding: 1px 5px;
  color: var(--text2);
}

.vp-cu-right {
  font-size: 12px;
  color: var(--text2);
  white-space: nowrap;
  flex-shrink: 0;
  text-align: right;
}
.vp-cu-right strong { color: var(--text); font-weight: 600; }

html[data-theme="light"] .vp-cu-list { border-color: rgba(0,0,0,0.09); }
html[data-theme="light"] .vp-cu-row  { border-bottom-color: rgba(0,0,0,0.07); }
html[data-theme="light"] .vp-cu-name { color: rgba(0,0,0,0.82); }
html[data-theme="light"] .vp-cu-right { color: rgba(0,0,0,0.50); }
html[data-theme="light"] .vp-cu-right strong { color: rgba(0,0,0,0.82); }
html[data-theme="light"] .vp-cu-dose {
  background: rgba(0,0,0,0.06);
  color: rgba(0,0,0,0.48);
}

.vp-cu-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.vp-cu-row-expired { opacity: 0.75; }
.vp-cu-expired-note {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.3;
}
.vp-cu-section-header {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 6px 10px 5px;
  border-top: 1px solid var(--border);
}
.vp-cu-list .vp-cu-section-header:first-child { border-top: none; }
.vp-cu-section-overdue  { color: var(--yellow); background: rgba(255,191,60,0.07); }
.vp-cu-section-upcoming { color: var(--blue);   background: rgba(99,102,241,0.07); }
html[data-theme="light"] .vp-cu-section-header { border-top-color: rgba(0,0,0,0.07); }
html[data-theme="light"] .vp-cu-section-overdue  { background: rgba(234,179,8,0.07); }
html[data-theme="light"] .vp-cu-section-upcoming { background: rgba(99,102,241,0.06); }

.vp-cu-expired-header {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: rgba(255,255,255,0.03);
  padding: 6px 10px;
  border-top: 1px solid var(--border);
}
html[data-theme="light"] .vp-cu-expired-header { border-top-color: rgba(0,0,0,0.07); background: rgba(0,0,0,0.02); }
html[data-theme="light"] .vp-cu-expired-note { color: rgba(0,0,0,0.38); }

/* ── Vaccination screen summary bar ─────────────────────────── */
.vacc-summary-bar {
  padding: 10px 12px 0;
  flex-shrink: 0;
}
.vacc-summary-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-m);
}
.vacc-sum-chip {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}
.vacc-sum-done       { background: rgba(53,212,154,0.12);  color: var(--green); }
.vacc-sum-due        { background: rgba(255,191,60,0.12);  color: var(--yellow); }
.vacc-sum-ok         { background: rgba(53,212,154,0.12);  color: var(--green); }
.vacc-sum-superseded { background: rgba(139,92,246,0.14);  color: #a78bfa; }
.vacc-sum-expired    { background: rgba(156,163,175,0.14); color: var(--muted); }
.vacc-sum-info { background: rgba(255,255,255,0.06); color: var(--muted); }

html[data-theme="light"] .vacc-summary-inner {
  background: rgba(255,255,255,0.72);
  border-color: rgba(0,0,0,0.08);
}
html[data-theme="light"] .vacc-sum-info {
  background: rgba(0,0,0,0.05);
  color: rgba(0,0,0,0.42);
}

/* ── Vaccination list ────────────────────────────────────────── */
.vacc-list {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.vacc-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  overflow: hidden;
}
.vacc-group-future { opacity: 0.65; }
.vacc-group-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
}
.vacc-upcoming-badge {
  font-size: 10px;
  background: rgba(79,140,255,0.15);
  color: var(--blue);
  padding: 1px 7px;
  border-radius: 10px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
}

.vacc-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.vacc-item:last-child { border-bottom: 0; }

.vacc-item-left {
  display: flex;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.vacc-item-icon {
  font-size: 16px;
  line-height: 1.4;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}
.vacc-item-done .vacc-item-icon { color: var(--green); }
.vacc-item-due  .vacc-item-icon { color: var(--muted); }
.vacc-item-future .vacc-item-icon { color: var(--muted); opacity: 0.5; }

.vacc-item-info { flex: 1; min-width: 0; }
.vacc-item-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.vacc-item-done .vacc-item-name { color: var(--green); }
.vacc-dose {
  font-size: 11px;
  font-weight: 500;
  background: rgba(255,255,255,0.08);
  border-radius: 6px;
  padding: 1px 6px;
  color: var(--text2);
  white-space: nowrap;
}
.vacc-item-vaccine {
  font-size: 12px;
  color: var(--text2);
  margin-top: 2px;
  line-height: 1.35;
}
.vacc-item-age {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}

.vacc-item-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.vacc-done-date {
  font-size: 12px;
  color: var(--green);
  font-weight: 500;
}
.vacc-btn-mark {
  border: 1px solid rgba(53,212,154,0.30);
  background: rgba(53,212,154,0.08);
  color: var(--green);
  border-radius: var(--r-s);
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.12s;
}
.vacc-btn-mark:active { background: rgba(53,212,154,0.18); }
.vacc-btn-edit {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: var(--r-s);
  padding: 3px 9px;
  font-size: 11px;
  transition: color 0.12s;
}
.vacc-btn-edit:active { color: var(--text2); }

.vacc-date-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 6px;
}

.vacc-edit-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.vacc-edit-alt {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding-top: 2px;
  border-top: 1px solid var(--border);
  margin-top: 2px;
  padding-top: 6px;
}
.vacc-date-input {
  flex: 1;
  min-width: 130px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-s);
  padding: 7px 10px;
  font-size: 13px;
  color: var(--text);
  outline: none;
}
.vacc-date-input:focus {
  border-color: var(--blue);
}
.vacc-btn-save {
  border: 0;
  background: var(--blue);
  color: #fff;
  border-radius: var(--r-s);
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.vacc-btn-cancel {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: var(--r-s);
  padding: 7px 12px;
  font-size: 13px;
}

.vacc-btn-skip-edit {
  border: 1px solid rgba(255,191,60,0.30);
  background: rgba(255,191,60,0.08);
  color: var(--yellow);
  border-radius: var(--r-s);
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 500;
  transition: background 0.12s;
}
.vacc-btn-skip-edit:active { background: rgba(255,191,60,0.18); }

.vacc-btn-reset {
  border: 1px solid rgba(255,77,109,0.25);
  background: rgba(255,77,109,0.07);
  color: var(--red);
  border-radius: var(--r-s);
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 500;
  transition: background 0.12s;
}
.vacc-btn-reset:active { background: rgba(255,77,109,0.16); }

/* Skip button */
.vacc-btn-skip {
  border: 1px solid rgba(255,255,255,0.10);
  background: transparent;
  color: var(--muted);
  border-radius: var(--r-s);
  padding: 5px 11px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.12s, border-color 0.12s;
}
.vacc-btn-skip:active { color: var(--text2); border-color: rgba(255,255,255,0.20); }

/* Right column layout (two buttons stacked) */
.vacc-item-right-col {
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}

/* Skipped state */
.vacc-item-skipped .vacc-item-icon { color: var(--muted); opacity: 0.6; }
.vacc-item-skipped .vacc-item-name { color: var(--muted); }
.vacc-skipped-label {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

/* Timing labels */
.vacc-timing, .vacc-item-timing {
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  padding: 1px 7px;
  display: inline-block;
  margin-top: 2px;
}
.vacc-timing-ok   { color: var(--green);  background: rgba(53,212,154,0.12); }
.vacc-timing-early{ color: var(--blue);   background: rgba(79,140,255,0.12); }
.vacc-timing-warn { color: var(--yellow); background: rgba(255,191,60,0.12); }
.vacc-timing-late { color: var(--red);    background: rgba(255,77,109,0.12); }

/* Light theme overrides for vacc screen */
html[data-theme="light"] .vacc-group {
  background: rgba(255,255,255,0.72);
  border-color: rgba(0,0,0,0.09);
}
html[data-theme="light"] .vacc-group-label {
  color: rgba(0,0,0,0.38);
  border-bottom-color: rgba(0,0,0,0.07);
}
html[data-theme="light"] .vacc-item { border-bottom-color: rgba(0,0,0,0.07); }
html[data-theme="light"] .vacc-item-name { color: rgba(0,0,0,0.82); }
html[data-theme="light"] .vacc-item-done .vacc-item-name { color: var(--green); }
html[data-theme="light"] .vacc-item-vaccine { color: rgba(0,0,0,0.50); }
html[data-theme="light"] .vacc-item-age  { color: rgba(0,0,0,0.36); }
html[data-theme="light"] .vacc-dose {
  background: rgba(0,0,0,0.06);
  color: rgba(0,0,0,0.50);
}
html[data-theme="light"] .vacc-btn-edit {
  border-color: rgba(0,0,0,0.12);
  color: rgba(0,0,0,0.38);
}
html[data-theme="light"] .vacc-date-input {
  background: rgba(255,255,255,0.90);
  border-color: rgba(0,0,0,0.14);
  color: rgba(0,0,0,0.82);
}
html[data-theme="light"] .vacc-date-input:focus { border-color: #2563eb; }
html[data-theme="light"] .vacc-btn-cancel {
  border-color: rgba(0,0,0,0.12);
  color: rgba(0,0,0,0.42);
}
html[data-theme="light"] .vacc-btn-skip {
  border-color: rgba(0,0,0,0.12);
  color: rgba(0,0,0,0.38);
}
html[data-theme="light"] .vacc-skipped-label { color: rgba(0,0,0,0.38); }
html[data-theme="light"] .vacc-item-skipped .vacc-item-name { color: rgba(0,0,0,0.38); }
html[data-theme="light"] .vacc-alert {
  color: #92400e;
  background: rgba(251,191,36,0.12);
  border-color: rgba(251,191,36,0.30);
}

/* ── Blocked state ───────────────────────────────────────────── */
.vacc-item-blocked { opacity: 0.65; }
.vacc-item-blocked .vacc-item-name { color: var(--muted); }
.vacc-blocked-label {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
  text-align: right;
  max-width: 120px;
  line-height: 1.4;
}

/* Earliest date hint inside action area */
.vacc-earliest-hint {
  font-size: 11px;
  color: var(--blue);
  font-weight: 500;
  text-align: right;
  white-space: nowrap;
}

html[data-theme="light"] .vacc-blocked-label { color: rgba(0,0,0,0.38); }
html[data-theme="light"] .vacc-earliest-hint { color: #2563eb; }

/* Priority + max age badges inside vaccine item list */
.vacc-priority-badge {
  display: inline-flex;
  align-items: center;
  font-size: 9px;
  font-weight: 700;
  border-radius: 12px;
  padding: 1px 6px;
  margin-right: 4px;
  vertical-align: middle;
}
.vacc-priority-1 {
  background: rgba(239,68,68,0.18);
  color: #ef4444;
}
.vacc-priority-expired {
  background: rgba(156,163,175,0.16);
  color: var(--muted);
}
.vacc-priority-superseded {
  background: rgba(139,92,246,0.16);
  color: #a78bfa;
}
.vacc-item-age-warn {
  font-size: 11px;
  color: #f97316;
  line-height: 1.35;
  margin-top: 2px;
}
.vacc-item-superseded-note {
  color: #a78bfa !important;
}
html[data-theme="light"] .vacc-item-age-warn { color: #c2410c; }
html[data-theme="light"] .vacc-item-superseded-note { color: #7c3aed !important; }

/* ── Catch-up schedule section ───────────────────────────────── */
.vacc-catchup-wrap {
  padding: 12px 12px 0;
}

.catch-up-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  overflow: hidden;
}

.catch-up-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px 10px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}

.catch-up-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.catch-up-count {
  font-size: 12px;
  font-weight: 600;
  background: rgba(79,140,255,0.14);
  color: var(--blue);
  border-radius: 20px;
  padding: 2px 9px;
}

.catch-up-list {
  display: flex;
  flex-direction: column;
}

.cu-row {
  display: flex;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.cu-row:last-child { border-bottom: 0; }

.cu-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cu-vaccine {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.cu-dose {
  font-size: 11px;
  font-weight: 500;
  background: rgba(255,255,255,0.08);
  border-radius: 6px;
  padding: 1px 6px;
  color: var(--text2);
}

.cu-vaccine-sub {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.35;
}

.cu-notes {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 3px;
}

.cu-notes span {
  font-size: 11px;
  color: var(--yellow);
}

.cu-row-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  flex-shrink: 0;
  min-width: 110px;
}

.cu-badge {
  font-size: 10px;
  font-weight: 700;
  border-radius: 20px;
  padding: 2px 8px;
  white-space: nowrap;
}
.cu-badge-overdue {
  background: rgba(255,77,109,0.15);
  color: var(--red);
}
.cu-badge-upcoming {
  background: rgba(79,140,255,0.12);
  color: var(--blue);
}
.cu-badge-p1 {
  background: rgba(239,68,68,0.18);
  color: #ef4444;
}
.cu-badge-p2 {
  background: rgba(249,115,22,0.15);
  color: #f97316;
}
.cu-badge-p3 {
  background: rgba(79,140,255,0.12);
  color: var(--blue);
}
.cu-badge-expired {
  background: rgba(156,163,175,0.16);
  color: var(--muted);
}
.cu-badge-superseded {
  background: rgba(139,92,246,0.16);
  color: #a78bfa;
}
.cu-badge-skipped {
  background: rgba(156,163,175,0.14);
  color: var(--muted);
}
.cu-superseded { opacity: 0.80; }
.cu-note-superseded { color: #a78bfa !important; }
.cu-badges {
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: flex-end;
}
.cu-expired {
  opacity: 0.72;
}
.cu-note-expired {
  color: #f97316 !important;
}

.cu-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--border);
}
.cu-leg {
  font-size: 11px;
  font-weight: 600;
}
.cu-leg-expired    { color: var(--yellow); }
.cu-leg-p1         { color: #ef4444; }
.cu-leg-p2         { color: #f97316; }
.cu-leg-p3         { color: var(--blue); }
.cu-leg-superseded { color: #a78bfa; }

.cu-earliest {
  font-size: 12px;
  color: var(--text2);
  text-align: right;
}
.cu-earliest strong { color: var(--text); }

.cu-age-hint {
  font-size: 10px;
  color: var(--muted);
  text-align: right;
}

.catch-up-note {
  font-size: 11px;
  color: var(--muted);
  padding: 8px 14px 10px;
  line-height: 1.4;
}

/* Light theme */
html[data-theme="light"] .catch-up-card {
  background: rgba(255,255,255,0.72);
  border-color: rgba(0,0,0,0.09);
}
html[data-theme="light"] .catch-up-header { border-bottom-color: rgba(0,0,0,0.07); }
html[data-theme="light"] .catch-up-title  { color: rgba(0,0,0,0.82); }
html[data-theme="light"] .cu-row          { border-bottom-color: rgba(0,0,0,0.07); }
html[data-theme="light"] .cu-vaccine      { color: rgba(0,0,0,0.82); }
html[data-theme="light"] .cu-vaccine-sub  { color: rgba(0,0,0,0.40); }
html[data-theme="light"] .cu-earliest     { color: rgba(0,0,0,0.55); }
html[data-theme="light"] .cu-earliest strong { color: rgba(0,0,0,0.82); }
html[data-theme="light"] .cu-age-hint     { color: rgba(0,0,0,0.35); }
html[data-theme="light"] .catch-up-note   { color: rgba(0,0,0,0.35); }
html[data-theme="light"] .cu-dose {
  background: rgba(0,0,0,0.06);
  color: rgba(0,0,0,0.50);
}
