/* ── Variables ─────────────────────────────────────── */
:root {
  --cream:    #F7F3EE;
  --navy:     #1E3A5F;
  --navy-lt:  #2A4F82;
  --gold:     #C9A84C;
  --gold-lt:  #E8C96A;
  --white:    #FFFFFF;
  --text:     #2C2C2C;
  --text-lt:  #6B7280;
  --red:      #D94F4F;
  --green:    #2E7D5A;
  --yellow:   #C9A84C;
  --card-bg:  #FFFFFF;
  --shadow:   0 2px 16px rgba(30,58,95,0.10);
  --radius:   16px;
  --nav-h:    68px;
}

/* ── Reset ─────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; font-family: -apple-system, 'SF Pro Text', 'Segoe UI', sans-serif; background: var(--cream); color: var(--text); overflow-x: hidden; }

/* ── Page wrapper ──────────────────────────────────── */
.page { display: none; flex-direction: column; min-height: 100vh; padding-bottom: var(--nav-h); }
.page.active { display: flex; }

/* ── Header ────────────────────────────────────────── */
.header {
  background: var(--navy);
  padding: 20px 20px 24px;
  text-align: center;
  position: relative;
}
.header-logo { font-family: Georgia, 'Times New Roman', serif; font-size: 22px; font-weight: 700; color: var(--white); letter-spacing: 2px; text-transform: uppercase; }
.header-sub { font-size: 11px; color: var(--gold); letter-spacing: 3px; text-transform: uppercase; margin-top: 2px; }
.header-decor { color: var(--gold); font-size: 10px; letter-spacing: 2px; margin-top: 6px; opacity: 0.7; }
.header-greeting { font-size: 13px; color: rgba(255,255,255,0.7); margin-top: 8px; }

/* ── Content ───────────────────────────────────────── */
.content { flex: 1; padding: 20px 16px; }

/* ── Cards ─────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-title {
  font-family: Georgia, serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title::after { content: ''; flex: 1; height: 1px; background: var(--cream); }

/* ── Dashboard quick stats ─────────────────────────── */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.stat-box {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 16px 10px;
  box-shadow: var(--shadow);
  text-align: center;
  cursor: pointer;
  transition: transform .15s;
}
.stat-box:active { transform: scale(.97); }
.stat-icon { font-size: 24px; margin-bottom: 6px; }
.stat-label { font-size: 10px; color: var(--text-lt); text-transform: uppercase; letter-spacing: 1px; }
.stat-value { font-size: 18px; font-weight: 700; color: var(--navy); margin-top: 2px; }
.stat-sub { font-size: 10px; color: var(--text-lt); margin-top: 2px; }

/* ── Hero card (empty state) ───────────────────────── */
.hero-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 40px 20px;
  box-shadow: var(--shadow);
  text-align: center;
  margin-bottom: 16px;
}
.hero-icon { font-size: 48px; margin-bottom: 16px; }
.hero-title { font-family: Georgia, serif; font-size: 20px; color: var(--navy); margin-bottom: 8px; }
.hero-decor { color: var(--gold); font-size: 10px; letter-spacing: 4px; margin-bottom: 12px; }
.hero-text { font-size: 14px; color: var(--text-lt); line-height: 1.6; }

/* ── Button ────────────────────────────────────────── */
.btn-primary {
  display: block;
  width: 100%;
  padding: 16px;
  background: var(--navy);
  color: var(--white);
  border: none;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .2s;
  text-align: center;
  text-decoration: none;
}
.btn-primary:active { background: var(--navy-lt); }
.btn-gold {
  background: var(--gold);
  color: var(--navy);
}
.btn-gold:active { background: var(--gold-lt); }

/* ── Profile row ───────────────────────────────────── */
.profile-row { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.profile-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--navy); color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-family: Georgia, serif; font-size: 20px; font-weight: 700; flex-shrink: 0;
}
.profile-name { font-family: Georgia, serif; font-size: 17px; color: var(--navy); font-weight: 700; }
.profile-sub { font-size: 12px; color: var(--text-lt); margin-top: 2px; }

/* ── Field rows ────────────────────────────────────── */
.field-row { display: flex; justify-content: space-between; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--cream); }
.field-row:last-child { border-bottom: none; }
.field-label { font-size: 12px; color: var(--text-lt); flex-shrink: 0; margin-right: 12px; }
.field-value { font-size: 14px; color: var(--text); font-weight: 500; text-align: right; }

/* ── Lab results ───────────────────────────────────── */
.lab-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--cream); }
.lab-item:last-child { border-bottom: none; }
.lab-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.lab-dot.ok { background: var(--green); }
.lab-dot.high { background: var(--red); }
.lab-dot.low { background: #3B82F6; }
.lab-dot.unknown { background: #D1D5DB; }
.lab-name { flex: 1; font-size: 14px; color: var(--text); }
.lab-value { font-size: 14px; font-weight: 600; color: var(--navy); }
.lab-ref { font-size: 11px; color: var(--text-lt); margin-top: 1px; text-align: right; }
.lab-col { display: flex; flex-direction: column; align-items: flex-end; }
.lab-date { font-size: 11px; color: var(--text-lt); margin-bottom: 4px; }

/* ── Section title ─────────────────────────────────── */
.section-title {
  font-family: Georgia, serif;
  font-size: 12px;
  color: var(--text-lt);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin: 20px 0 10px;
}

/* ── Chat ──────────────────────────────────────────── */
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - var(--nav-h) - 80px); }
.chat-messages { flex: 1; overflow-y: auto; padding: 8px 0; }
.bubble { max-width: 80%; padding: 12px 16px; border-radius: 16px; margin-bottom: 10px; font-size: 14px; line-height: 1.5; }
.bubble.user { background: var(--navy); color: var(--white); margin-left: auto; border-bottom-right-radius: 4px; }
.bubble.bot { background: var(--white); color: var(--text); box-shadow: var(--shadow); border-bottom-left-radius: 4px; }
.chat-input-row { display: flex; gap: 8px; padding: 12px 0 4px; }
.chat-input {
  flex: 1; padding: 12px 16px; border: 1.5px solid #E5E7EB; border-radius: 24px;
  font-size: 14px; background: var(--white); color: var(--text);
  outline: none; resize: none;
}
.chat-input:focus { border-color: var(--navy); }
.chat-send {
  width: 44px; height: 44px; border-radius: 50%; background: var(--navy);
  border: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; align-self: flex-end;
}
.chat-send svg { fill: white; width: 18px; height: 18px; }

/* ── BMI badge ─────────────────────────────────────── */
.bmi-row { display: flex; align-items: center; gap: 12px; padding: 14px 0; }
.bmi-bar { flex: 1; height: 6px; background: #E5E7EB; border-radius: 3px; overflow: hidden; }
.bmi-fill { height: 100%; border-radius: 3px; transition: width .5s ease; }
.bmi-badge { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 20px; white-space: nowrap; }
.bmi-norm  { background: #D1FAE5; color: #065F46; }
.bmi-over  { background: #FEF3C7; color: #92400E; }
.bmi-under { background: #DBEAFE; color: #1E40AF; }
.bmi-obese { background: #FEE2E2; color: #991B1B; }

/* ── Bottom Nav ────────────────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--nav-h);
  background: var(--white); box-shadow: 0 -1px 0 #E5E7EB, 0 -4px 20px rgba(0,0,0,.06);
  display: flex; z-index: 100;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 4px; cursor: pointer; padding-bottom: 8px;
  transition: color .15s;
}
.nav-item .nav-icon { font-size: 22px; }
.nav-item .nav-label { font-size: 10px; color: var(--text-lt); letter-spacing: .5px; }
.nav-item.active .nav-label { color: var(--navy); font-weight: 600; }
.nav-item.active .nav-icon { filter: none; }
.nav-dot {
  position: relative;
}
.nav-dot::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--navy);
}

/* ── Empty state ───────────────────────────────────── */
.empty { text-align: center; padding: 40px 20px; }
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-text { font-size: 14px; color: var(--text-lt); line-height: 1.6; }

/* ── Loading ───────────────────────────────────────── */
.loader { display: flex; align-items: center; justify-content: center; padding: 40px; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--cream); border-top-color: var(--navy); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ─────────────────────────────────────────── */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + 16px); left: 50%; transform: translateX(-50%);
  background: var(--navy); color: var(--white); padding: 10px 20px;
  border-radius: 24px; font-size: 13px; z-index: 200; opacity: 0;
  transition: opacity .3s; pointer-events: none; white-space: nowrap;
}
.toast.show { opacity: 1; }
