:root {
  --blue-100: #0053e2;
  --blue-110: #003db5;
  --blue-120: #001a7a;
  --spark-100: #ffc220;
  --spark-140: #995213;
  --spark-10:  #fef9ec;
  --red-100:   #ea1100;
  --green-100: #2a8703;
  --gray-160:  #1a1f36;
  --gray-100:  #6d7a95;
  --gray-50:   #c5c9d5;
  --gray-10:   #f5f6f8;
  /* Light mode tokens */
  --bg:        #eef2ff;
  --card-bg:   rgba(255,255,255,0.85);
  --card-border: rgba(255,255,255,0.8);
  --text:      #1a1f36;
  --text-sub:  #6d7a95;
  --kpi-bg:    rgba(255,255,255,0.9);
  --input-bg:  white;
  --input-border: #d1d5e0;
  --table-stripe: #f8faff;
  --stat-box-bg: #f5f6f8;
}

/* ── Dark mode ───────────────────────────────────────── */
#root.dark {
  --bg:         #0d1117;
  --card-bg:    rgba(22,27,34,0.95);
  --card-border: rgba(48,54,61,0.8);
  --text:       #e6edf3;
  --text-sub:   #8b949e;
  --kpi-bg:     rgba(28,33,48,0.95);
  --input-bg:   #161b22;
  --input-border: #30363d;
  --table-stripe: #1c2130;
  --stat-box-bg:  #1c2130;
  --gray-160:   #e6edf3;
  --gray-100:   #8b949e;
}
#root.dark body {
  background-color: #0d1117;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(0,83,226,0.12) 0%, transparent 70%),
    radial-gradient(ellipse 60% 40% at 90% 60%,  rgba(255,194,32,0.04) 0%, transparent 60%);
}
#root.dark body::before { background-image: radial-gradient(rgba(0,83,226,0.04) 1px, transparent 1px); }
#root.dark .card        { background: var(--card-bg); border-color: var(--card-border); color: var(--text); }
#root.dark .kpi         { background: var(--kpi-bg) !important; }
#root.dark .stat-box    { background: var(--stat-box-bg) !important; }
#root.dark .stat-box .label { color: var(--text-sub) !important; }
#root.dark .stat-box .val   { color: var(--text) !important; }
#root.dark .stat-box .sub   { color: var(--text-sub); }
#root.dark .kpi-unit    { color: var(--text-sub); }
#root.dark .kpi-label   { opacity: 0.85; }
#root.dark .streak-banner { background: #1c2130; border-color: #2d3250; }
#root.dark .trend-hero  { background: #161b22; border-color: #30363d; }
#root.dark .goal-input-row input { background: var(--input-bg); border-color: var(--input-border); color: var(--text); }
#root.dark .btn-secondary { background: #1c2130; border-color: #30363d; color: var(--text); }
#root.dark .data-table th { color: var(--text-sub); }
#root.dark .data-table td { color: var(--text); border-color: #21262d; }
#root.dark .data-table tr.today-row td { background: #1c2130; }
#root.dark .progress-track { background: #21262d; }
#root.dark .card-title { background: linear-gradient(135deg,#1c2d4f,#1a2640); border-color: rgba(0,83,226,0.25); }
#root.dark .cal-box    { background: #1c2130 !important; }
#root.dark .range-pill { background: #161b22; border-color: #30363d; color: var(--text-sub); }
#root.dark .range-pill.active { background: var(--blue-100); color: white; }
#root.dark .milestone-ring.future { background: #21262d; border-color: #30363d; color: var(--text-sub); }
#root.dark .bmi-step   { background: #1c2130; border-color: #30363d; }
#root.dark .bmi-step.current { border-color: var(--blue-100); background: #1c2d4f; }
#root.dark .journey-insights  { background: #1c2130; border-color: #30363d; }
#root.dark .insight-chip      { background: #161b22; border-color: #21262d; }
#root.dark .insight-label     { color: var(--text-sub); }
#root.dark .insight-val       { color: var(--text); }

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

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  color: var(--gray-160);
  min-height: 100vh;
  /* Rich mesh background */
  background-color: #eef2ff;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(0,83,226,0.18) 0%, transparent 70%),
    radial-gradient(ellipse 60% 40% at 90% 60%,  rgba(255,194,32,0.07) 0%, transparent 60%);
}

/* ── Page wrapper dots ───────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(rgba(0,83,226,0.06) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
  z-index: 0;
}
main, header, #status-bar { position: relative; z-index: 1; }

/* ── Header — glassmorphism ──────────────── */
.header {
  background: linear-gradient(135deg, #0041c4 0%, #0053e2 40%, #0066ff 70%, #0041c4 100%);
  background-size: 300% 300%;
  animation: headerShift 12s ease infinite;
  box-shadow: 0 4px 32px rgba(0,53,226,0.35);
  position: relative;
  overflow: hidden;
}

/* Mesh overlay on header */
.header::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
}

/* Glowing spark accent strip at bottom of header */
.header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--spark-100), transparent);
}

@keyframes headerShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.35rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  color: white;
}

.header-logo {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--spark-100);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; flex-shrink: 0;
  box-shadow: 0 0 0 4px rgba(255,194,32,0.25), 0 4px 12px rgba(0,0,0,0.2);
}

.header-meta { text-align: right; }
.header-meta p      { font-size: 0.72rem; color: rgba(255,255,255,0.6); }
.header-meta strong { font-size: 0.88rem; color: white; }

/* ── Layout ──────────────────────────────── */
main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ── Cards ───────────────────────────────── */
.card {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 1.25rem;
  box-shadow: 0 2px 8px rgba(0,53,226,0.06), 0 1px 2px rgba(0,0,0,0.04);
  border: 1px solid rgba(255,255,255,0.8);
  padding: 1.35rem 1.5rem;
}

/* ── Pill section titles ─────────────────── */
.card-title {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: linear-gradient(135deg, #eff4ff, #e8f0ff);
  color: var(--blue-100);
  padding: 0.3rem 0.875rem 0.3rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin-bottom: 1rem;
  border: 1px solid rgba(0,83,226,0.12);
}
.card-title::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--blue-100);
  flex-shrink: 0;
}

/* ── KPI Grid ────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}
@media (min-width: 640px)  { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .kpi-grid { grid-template-columns: repeat(4, 1fr); } }

.kpi {
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(6px);
  border-radius: 1.125rem;
  box-shadow: 0 2px 8px rgba(0,53,226,0.07);
  border: 1px solid rgba(255,255,255,0.9);
  padding: 1rem 1rem 0.875rem;
  border-top: 3px solid var(--gray-50);
  transition: transform 0.2s, box-shadow 0.2s;
}
.kpi:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 28px rgba(0,83,226,0.14);
}
.kpi-label { font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em; color: var(--gray-100); }
.kpi-value { font-size: 2.1rem; font-weight: 900; line-height: 1.1; margin: 0.2rem 0; }
.kpi-unit  { font-size: 0.72rem; color: var(--gray-100); }
.kpi-sub   { font-size: 0.68rem; margin-top: 0.4rem; }

/* ── Progress bar ────────────────────────── */
.progress-track {
  background: rgba(0,0,0,0.06);
  border-radius: 9999px;
  height: 0.875rem;
  overflow: hidden;
  margin-top: 0.5rem;
}
.progress-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 1s cubic-bezier(.4,0,.2,1);
  background: linear-gradient(90deg, var(--green-100), #7bc67e, var(--spark-100));
}

/* ── Stat grid inside journey/goal ──────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 0.875rem;
}
@media (min-width: 640px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }

.stat-box {
  border-radius: 1rem;
  padding: 0.875rem;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.6);
}
.stat-box .label { font-size: 0.58rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.3rem; }
.stat-box .val   { font-size: 1.65rem; font-weight: 900; line-height: 1; }
.stat-box .sub   { font-size: 0.62rem; color: var(--gray-100); margin-top: 0.25rem; }

/* ── Journey insight chips ────────────────── */
.journey-insights {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.75rem;
  background: #f5f6f8;
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 1rem;
  padding: 0.75rem 1rem;
  flex-wrap: wrap;
}
.insight-chip {
  flex: 1;
  min-width: 7rem;
  text-align: center;
  background: white;
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 0.75rem;
  padding: 0.6rem 0.75rem;
}
.insight-label {
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gray-100);
  margin-bottom: 0.25rem;
}
.insight-val {
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--gray-160);
  line-height: 1.1;
}
.insight-sub {
  font-size: 0.62rem;
  color: var(--gray-100);
  margin-top: 0.15rem;
}

/* ── Chart wrapper ───────────────────────── */
.chart-wrap { position: relative; height: 300px; }

/* ── Composition chart row ───────────────── */
.comp-charts { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 768px) { .comp-charts { grid-template-columns: 1fr 1fr; } }
.comp-chart-wrap { position: relative; height: 220px; }

/* ── Table ───────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.data-table th { padding: 0.6rem 0.875rem; font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--gray-100); background: rgba(0,83,226,0.04); text-align: left; }
.data-table td { padding: 0.6rem 0.875rem; border-bottom: 1px solid rgba(0,0,0,0.04); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(0,83,226,0.03); }
.overflow-x { overflow-x: auto; }

/* ── Badges ──────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.63rem;
  font-weight: 700;
}

/* ── Calorie row ─────────────────────────── */
.cal-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
@media (max-width: 540px) { .cal-grid { grid-template-columns: 1fr; } }
.cal-box { border-radius: 1rem; padding: 1rem; text-align: center; border: 1px solid rgba(255,255,255,0.6); }
.cal-box .cal-label { font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.3rem; }
.cal-box .cal-val   { font-size: 1.75rem; font-weight: 900; }
.cal-box .cal-sub   { font-size: 0.68rem; color: var(--gray-100); margin-top: 0.25rem; }

/* ── Streak banner ───────────────────────── */
.streak-banner {
  background: linear-gradient(135deg, #fffbeb, #fef9ec);
  border: 1px solid rgba(255,194,32,0.4);
  border-radius: 1.25rem;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  box-shadow: 0 2px 12px rgba(255,194,32,0.12);
}
.streak-number { font-size: 2.75rem; font-weight: 900; color: var(--spark-140); line-height: 1; }

/* ── Goal input row ──────────────────────── */
.goal-input-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.goal-input-row label { font-size: 0.8rem; font-weight: 600; color: var(--gray-160); }
.goal-input-row input {
  width: 7rem; padding: 0.5rem 0.75rem;
  border: 2px solid var(--gray-50); border-radius: 0.75rem;
  font-size: 1rem; font-weight: 700; text-align: center; color: var(--blue-100);
  transition: border-color 0.2s, box-shadow 0.2s; outline: none;
  background: white;
}
.goal-input-row input:focus { border-color: var(--blue-100); box-shadow: 0 0 0 3px rgba(0,83,226,0.12); }
.btn-primary {
  padding: 0.5rem 1.25rem; border-radius: 0.75rem; border: none;
  background: var(--blue-100); color: white; font-weight: 700; font-size: 0.82rem;
  cursor: pointer; transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  box-shadow: 0 2px 8px rgba(0,83,226,0.3);
}
.btn-primary:hover  { background: var(--blue-110); box-shadow: 0 4px 16px rgba(0,83,226,0.35); }
.btn-primary:active { transform: scale(0.97); }
.btn-secondary {
  padding: 0.5rem 1rem; border-radius: 0.75rem;
  border: 1px solid var(--gray-50); background: white; color: var(--gray-100);
  font-size: 0.82rem; cursor: pointer; transition: border-color 0.15s, color 0.15s;
}
.btn-secondary:hover { border-color: var(--red-100); color: var(--red-100); }

/* ── Up/down arrows ──────────────────────── */
.up   { color: var(--red-100); }
.down { color: var(--green-100); }

/* ── Calorie Log Table ──────────────────── */
.cal-log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.cal-log-table th {
  text-align: left;
  color: #6d7a95;
  font-weight: 600;
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid #eee;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cal-log-table td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid #f4f5f7;
  color: #374151;
}
.cal-log-table tr:last-child td { border-bottom: none; }
.cal-log-table tr.today-row td { font-weight: 700; background: #f8faff; }
.cal-log-delete {
  background: none;
  border: none;
  color: #c5c9d5;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.25rem;
  transition: color 0.15s;
}
.cal-log-delete:hover { color: var(--red-100); }

/* ── Trend Weight Hero ─────────────────── */
.trend-hero {
  background: white;
  border-radius: 1rem;
  padding: 1.5rem 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
  border-left: 4px solid var(--blue-100);
}
.trend-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6d7a95;
  margin-bottom: 0.15rem;
}
.trend-value {
  font-size: 3.5rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--blue-100);
}
.trend-value.down { color: var(--green-100); }
.trend-value.up   { color: var(--red-100); }
.trend-sub {
  font-size: 0.78rem;
  color: #6d7a95;
  margin-top: 0.35rem;
}

/* ── Decade Badge ─────────────────────── */
.decade-badge {
  background: linear-gradient(135deg, var(--spark-100), #ff9f1c);
  color: white;
  font-weight: 800;
  font-size: 0.85rem;
  padding: 0.6rem 1.1rem;
  border-radius: 0.75rem;
  text-align: center;
  line-height: 1.4;
  box-shadow: 0 2px 10px rgba(255,194,32,0.4);
  white-space: nowrap;
}

/* ── Time Range Pills ────────────────── */
.range-pills {
  display: flex;
  gap: 0.25rem;
}
.range-pill {
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  border: 1.5px solid #d1d5e0;
  background: white;
  color: #6d7a95;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.range-pill:hover { border-color: var(--blue-100); color: var(--blue-100); }
.range-pill.active { background: var(--blue-100); border-color: var(--blue-100); color: white; }

/* -- Activity level pills ------------------------------------ */
.activity-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.25rem;
}
.activity-pill {
  padding: 0.3rem 0.85rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 9999px;
  border: 1.5px solid #d1d5e0;
  background: white;
  color: var(--gray-100);
  cursor: pointer;
  transition: all 0.15s;
}
.activity-pill:hover  { border-color: #7c3aed; color: #7c3aed; }
.activity-pill.active { background: #7c3aed; border-color: #7c3aed; color: white; }
#root.dark .activity-pill        { background: #161b22; border-color: #30363d; color: var(--text-sub); }
#root.dark .activity-pill:hover  { border-color: #7c3aed; color: #a78bfa; }
#root.dark .activity-pill.active { background: #7c3aed; border-color: #7c3aed; color: white; }

/* ── Dark mode toggle ──────────────────── */
.dark-toggle {
  background: rgba(255,255,255,0.15);
  border: 1.5px solid rgba(255,255,255,0.25);
  border-radius: 9999px;
  width: 38px; height: 38px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}
.dark-toggle:hover { background: rgba(255,255,255,0.25); }

/* ── Milestone rings ──────────────────── */
.milestones-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}
.milestone-ring {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  min-width: 56px;
}
.milestone-circle {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 3px solid #e5e7eb;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  position: relative;
  transition: all 0.3s;
}
.milestone-ring.done .milestone-circle {
  background: linear-gradient(135deg, #2a8703, #4caf50);
  border-color: #2a8703;
  color: white;
  box-shadow: 0 2px 8px rgba(42,135,3,0.35);
}
.milestone-ring.current .milestone-circle {
  background: linear-gradient(135deg, #0053e2, #0066ff);
  border-color: #0053e2;
  color: white;
  box-shadow: 0 2px 12px rgba(0,83,226,0.4);
  animation: pulseMilestone 2s ease-in-out infinite;
}
.milestone-ring.future .milestone-circle {
  background: white;
  border-color: #e5e7eb;
  color: #c5c9d5;
}
@keyframes pulseMilestone {
  0%, 100% { box-shadow: 0 2px 12px rgba(0,83,226,0.4); }
  50%       { box-shadow: 0 2px 20px rgba(0,83,226,0.7); }
}
.milestone-label {
  font-size: 0.62rem;
  font-weight: 700;
  color: #6d7a95;
  text-align: center;
}
.milestone-ring.done  .milestone-label { color: #2a8703; }
.milestone-ring.current .milestone-label { color: #0053e2; }

/* ── BMI Timeline ────────────────────── */
.bmi-timeline {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.25rem;
}
.bmi-step {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.9rem;
  border-radius: 0.75rem;
  border: 1.5px solid #e5e7eb;
  background: #f8faff;
  font-size: 0.8rem;
}
.bmi-step.achieved {
  border-color: #2a8703;
  background: #f0fdf4;
}
.bmi-step.current {
  border-color: #0053e2;
  background: #eff4ff;
  font-weight: 700;
}
.bmi-step.future {
  opacity: 0.6;
}
.bmi-step-icon { font-size: 1.2rem; flex-shrink: 0; }
.bmi-step-info { flex: 1; }
.bmi-step-cat  { font-weight: 700; font-size: 0.82rem; }
.bmi-step-range { font-size: 0.68rem; color: #6d7a95; }
.bmi-step-date { font-size: 0.72rem; font-weight: 600; text-align: right; white-space: nowrap; }

/* ── Glucose / CGM section ──────────────── */
.glucose-hero {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
}
.glucose-reading {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  line-height: 1;
}
.glucose-value {
  font-size: 3.75rem;
  font-weight: 900;
  letter-spacing: -0.04em;
  color: var(--green-100);
  transition: color 0.4s;
}
.glucose-unit  {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-sub);
  align-self: flex-end;
  margin-bottom: 0.4rem;
}
.glucose-arrow {
  font-size: 2rem;
  font-weight: 900;
  color: var(--text-sub);
  margin-left: 0.25rem;
}
.glucose-meta {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.glucose-status {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}
.glucose-desc {
  font-size: 0.75rem;
  color: var(--gray-100);
  font-weight: 600;
}
.glucose-ago {
  font-size: 0.7rem;
  color: var(--gray-100);
}

/* Stats chips row */
.glucose-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin-bottom: 0.25rem;
}
@media (max-width: 640px) {
  .glucose-stats { grid-template-columns: repeat(2, 1fr); }
}
.glucose-chip {
  background: #f5f6f8;
  border-radius: 0.875rem;
  padding: 0.7rem 0.875rem;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.7);
}
.glucose-chip .chip-label {
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--gray-100);
  margin-bottom: 0.25rem;
}
.glucose-chip .chip-val {
  font-size: 1.5rem;
  font-weight: 900;
  line-height: 1.1;
  color: var(--gray-160);
}
.glucose-chip .chip-sub {
  font-size: 0.62rem;
  color: var(--gray-100);
  margin-top: 0.2rem;
}

/* Dark mode */
#root.dark .glucose-chip    { background: #1c2130; border-color: #30363d; }
#root.dark .glucose-chip .chip-val { color: var(--text); }
#root.dark .glucose-card    { background: var(--card-bg); }

/* Mobile */
@media (max-width: 480px) {
  .glucose-value { font-size: 2.75rem; }
  .glucose-arrow { font-size: 1.5rem; }
}

/* ── Footer ──────────────────── */
footer { text-align: center; font-size: 0.72rem; color: var(--gray-100); padding: 1.5rem 0 2rem; }

/* ── Update toast ───────────────────────── */
.update-toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: #1a1f36;
  color: white;
  padding: 0.75rem 1.1rem;
  border-radius: 9999px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
  font-size: 0.82rem;
  font-weight: 600;
  z-index: 9999;
  white-space: nowrap;
  animation: slideUp 0.3s ease;
}
.update-toast button {
  background: var(--blue-100);
  color: white;
  border: none;
  border-radius: 9999px;
  padding: 0.3rem 0.85rem;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.update-toast button:hover { background: var(--blue-110); }
@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Animations ───────────────────────── */
@keyframes fadeUp { from { opacity:0; transform:translateY(14px); } to { opacity:1; transform:translateY(0); } }
.fade-in { animation: fadeUp 0.5s ease both; }
.fade-in:nth-child(2) { animation-delay: 0.07s; }
.fade-in:nth-child(3) { animation-delay: 0.14s; }
.fade-in:nth-child(4) { animation-delay: 0.21s; }

/* ── Mobile ─────────────────────────── */
@media (max-width: 480px) {
  /* Tighter layout */
  main { padding: 0.75rem; gap: 1rem; }
  .card { padding: 1rem; }

  /* Header — shrink logo and stack meta below on very narrow */
  .header-inner { padding: 0.9rem 1rem; gap: 0.5rem; }
  .header-logo  { width: 40px; height: 40px; font-size: 1.2rem; }
  .header-meta  { text-align: left; }

  /* Trend hero — shrink the big number */
  .trend-hero   { padding: 1.1rem 1rem; flex-wrap: wrap; gap: 0.75rem; }
  .trend-value  { font-size: 2.4rem; }
  .decade-badge { font-size: 0.75rem; padding: 0.45rem 0.8rem; }

  /* KPI cards — tighter */
  .kpi         { padding: 0.85rem 0.75rem; }
  .kpi-value   { font-size: 1.6rem; }

  /* Streak banner */
  .streak-banner { padding: 0.75rem 1rem; gap: 0.6rem; }
  .streak-number { font-size: 2rem; }

  /* Goal input row — stack label above inputs */
  .goal-input-row        { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .goal-input-row input  { width: 100%; }

  /* Calorie log — hide deficit column on tiny screens */
  .cal-log-table th:nth-child(3),
  .cal-log-table td:nth-child(3) { display: none; }

  /* Range pills — make them smaller */
  .range-pill { padding: 0.2rem 0.5rem; font-size: 0.68rem; }

  /* Charts — less height on mobile */
  .chart-wrap     { height: 220px; }
  .comp-chart-wrap { height: 160px; }

  /* Stat boxes */
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .val       { font-size: 1.4rem; }

  /* Data table — smaller text */
  .data-table th,
  .data-table td { font-size: 0.7rem; padding: 0.4rem 0.35rem; }

  /* Week-Over-Week — on mobile just show Week + Lost */
  .data-table th:nth-child(2), .data-table td:nth-child(2),
  .data-table th:nth-child(3), .data-table td:nth-child(3),
  .data-table th:nth-child(5), .data-table td:nth-child(5) { display: none; }

  /* Prevent date wrapping in first column */
  .data-table td:nth-child(1) { white-space: nowrap; font-size: 0.68rem; }
}

/* ── Tab navigation ────────────────────────────────────────────────────── */
/* ── Tab nav — mobile-safe horizontal scroll ───────────────────────────── */
.tab-nav {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 1rem 0;
  background: var(--blue-100);
  position: sticky;
  top: 0;
  z-index: 40;
  /* Mobile overflow: scroll instead of squish */
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;        /* Firefox */
  -ms-overflow-style: none;     /* IE/Edge */
}
.tab-nav::-webkit-scrollbar { display: none; } /* Chrome/Safari */
.tab-btn {
  flex: none;      /* tabs keep their natural width — don't shrink on mobile */
  min-width: fit-content;
  padding: 0.55rem 1.25rem;
  border: none;
  border-radius: 8px 8px 0 0;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.8);
  transition: background 0.15s, color 0.15s;
  letter-spacing: 0.01em;
}
.tab-btn:hover {
  background: rgba(255,255,255,0.25);
  color: #fff;
}
.tab-btn.active {
  background: #fff;
  color: var(--blue-100);
}
#root.dark .tab-btn {
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.6);
}
#root.dark .tab-btn.active {
  background: #1e2535;
  color: #60a5fa;
}
