/* ────────────────────────────────────────────────
   Design tokens — Futuristic Light System
   ──────────────────────────────────────────────── */
:root {
  --bg-deep:      #141820;
  --bg-surface:   #1A1F2B;
  --bg-card:      #1E2433;
  --bg-elevated:  #232A3A;
  --bg-input:     #1A1F2B;
  --border:       rgba(255,255,255,.08);
  --border-glow:  rgba(255,255,255,.12);
  --border-focus: rgba(56,189,248,.35);

  --electric:     #38BDF8;
  --electric-dim: rgba(56,189,248,.15);
  --electric-glow:rgba(56,189,248,.25);
  --cyan:         #22D3EE;
  --cyan-dim:     rgba(34,211,238,.12);
  --violet:       #A78BFA;
  --violet-dim:   rgba(167,139,250,.12);
  --green:        #4ADE80;
  --green-dim:    rgba(74,222,128,.12);
  --amber:        #FBBF24;
  --amber-dim:    rgba(251,191,36,.12);
  --red-soft:     #F87171;
  --red-dim:      rgba(248,113,113,.12);

  --text-primary: #E8ECF4;
  --text-body:    #A0AABE;
  --text-muted:   #6B7A90;
  --text-dim:     #4A5568;

  --font-sans:    'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', monospace;

  --radius:       12px;
  --radius-sm:    8px;
  --radius-lg:    18px;
  --radius-xl:    24px;

  --shadow-sm:    0 1px 3px rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.2);
  --shadow-md:    0 4px 16px rgba(0,0,0,.4), 0 2px 4px rgba(0,0,0,.2);
  --shadow-lg:    0 12px 40px rgba(0,0,0,.5), 0 4px 8px rgba(0,0,0,.3);
  --shadow-glow:  0 0 20px rgba(56,189,248,.08);

  --safe-bottom:  env(safe-area-inset-bottom, 0px);
  --safe-top:     env(safe-area-inset-top, 0px);
  --safe-left:    env(safe-area-inset-left, 0px);
  --safe-right:   env(safe-area-inset-right, 0px);
  --bottom-nav-h: 60px;

  --navbar-bg:    rgba(20,24,32,.92);
  --chart-grid:   rgba(255,255,255,0.04);
  --chart-tick:   #6B7A90;
  --chart-tooltip-bg: rgba(30,36,51,0.95);
  --overlay-bg:   rgba(0,0,0,.6);
  --hover-bg:     rgba(255,255,255,.06);
  --active-bg:    var(--electric-dim);
  --subtle-bg:    rgba(255,255,255,.06);
  --subtle-border:rgba(255,255,255,.04);
  --subtle-wash:  rgba(255,255,255,.03);
}

[data-theme="light"] {
  --bg-deep:      #F3F4F6;
  --bg-surface:   #FFFFFF;
  --bg-card:      #FFFFFF;
  --bg-elevated:  #F9FAFB;
  --bg-input:     #F3F4F6;
  --border:       rgba(0,0,0,.1);
  --border-glow:  rgba(0,0,0,.12);
  --border-focus: rgba(37,99,235,.4);

  --electric:     #2563EB;
  --electric-dim: rgba(37,99,235,.1);
  --electric-glow:rgba(37,99,235,.2);
  --cyan:         #0891B2;
  --cyan-dim:     rgba(8,145,178,.08);
  --violet:       #7C3AED;
  --violet-dim:   rgba(124,58,237,.08);
  --green:        #16A34A;
  --green-dim:    rgba(22,163,74,.08);
  --amber:        #D97706;
  --amber-dim:    rgba(217,119,6,.08);
  --red-soft:     #DC2626;
  --red-dim:      rgba(220,38,38,.08);

  --text-primary: #111827;
  --text-body:    #374151;
  --text-muted:   #6B7280;
  --text-dim:     #9CA3AF;

  --shadow-sm:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:    0 4px 16px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg:    0 12px 40px rgba(0,0,0,.1), 0 4px 8px rgba(0,0,0,.06);
  --shadow-glow:  0 0 20px rgba(37,99,235,.06);

  --navbar-bg:    rgba(255,255,255,.92);
  --chart-grid:   rgba(0,0,0,0.06);
  --chart-tick:   #6B7280;
  --chart-tooltip-bg: rgba(255,255,255,0.95);
  --overlay-bg:   rgba(0,0,0,.3);
  --hover-bg:     rgba(0,0,0,.04);
  --active-bg:    var(--electric-dim);
  --subtle-bg:    rgba(0,0,0,.04);
  --subtle-border:rgba(0,0,0,.06);
  --subtle-wash:  rgba(0,0,0,.02);
}

/* ────────────────────────────────────────────────
   Reset & base
   ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg-deep); color: var(--text-body); font-family: var(--font-sans);
  line-height: 1.6; min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom));
  -webkit-overflow-scrolling: touch;
}
a { color: var(--electric); text-decoration: none; transition: color .15s; -webkit-tap-highlight-color: transparent; }
a:hover { color: var(--cyan); text-decoration: none; }
h1, h2, h3, h4 { font-family: var(--font-sans); font-weight: 600; color: var(--text-primary); letter-spacing: -.02em; }
h1 { font-size: 1.35rem; line-height: 1.2; }
h2 { font-size: 1.05rem; margin-bottom: .75rem; }
h3 { font-size: .92rem; margin-bottom: .5rem; }
ul { list-style: none; }
button, input, select, textarea { font-family: inherit; -webkit-tap-highlight-color: transparent; }

/* ────────────────────────────────────────────────
   Animations
   ──────────────────────────────────────────────── */
@keyframes pulse-glow {
  0%, 100% { opacity: 1; }
  50% { opacity: .7; }
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes bloom {
  0%   { box-shadow: 0 0 0 0 var(--electric-glow); }
  70%  { box-shadow: 0 0 12px 4px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@keyframes arc-fill {
  from { stroke-dashoffset: 251.2; }
}
.animate-in { animation: fade-in .35s ease-out both; }

/* ────────────────────────────────────────────────
   Top navbar (mobile: compact header)
   ──────────────────────────────────────────────── */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--navbar-bg); backdrop-filter: blur(16px) saturate(1.2);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: .55rem 1rem;
  padding-top: calc(.55rem + var(--safe-top));
}
.nav-brand { display: flex; align-items: center; gap: .45rem; font-size: .92rem; color: var(--text-primary); font-weight: 600; letter-spacing: -.01em; }
.nav-icon  { font-size: 1.05rem; filter: drop-shadow(0 0 4px var(--electric-glow)); }

.nav-links { display: none; }
.nav-hamburger {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: none; background: none;
  color: var(--text-muted); font-size: 1.4rem; cursor: pointer;
  border-radius: var(--radius-sm); transition: background .15s;
}
.nav-hamburger:hover { background: var(--hover-bg); }

.nav-drawer {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 200;
}
.nav-drawer.open { display: flex; }
.nav-overlay { position: absolute; inset: 0; background: var(--overlay-bg); backdrop-filter: blur(4px); }
.nav-panel {
  position: absolute; top: 0; right: 0; width: 260px; max-width: 80vw;
  height: 100%; background: var(--bg-surface); border-left: 1px solid var(--border);
  padding: 1.25rem; padding-top: calc(1.25rem + var(--safe-top));
  display: flex; flex-direction: column; gap: .25rem;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  animation: slide-in-right .2s ease;
}
@keyframes slide-in-right {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
.nav-panel-close {
  align-self: flex-end; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: none; color: var(--text-muted);
  font-size: 1.3rem; cursor: pointer; margin-bottom: .5rem;
}
.nav-panel a {
  display: flex; align-items: center; gap: .6rem;
  padding: .7rem .85rem; border-radius: var(--radius-sm);
  font-size: .92rem; color: var(--text-body); font-weight: 500;
  min-height: 44px; transition: background .15s;
}
.nav-panel a:hover { background: var(--hover-bg); }
.nav-panel a.active { color: var(--electric); background: var(--electric-dim); font-weight: 600; }
.nav-panel .nav-badge { margin-left: auto; }

/* ── Bottom navigation (mobile) ── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: rgba(20,24,32,.95); backdrop-filter: blur(16px) saturate(1.2);
  border-top: 1px solid var(--border);
  display: flex; align-items: stretch; justify-content: space-around;
  height: var(--bottom-nav-h);
  padding-bottom: var(--safe-bottom);
  padding-left: var(--safe-left); padding-right: var(--safe-right);
}
.bottom-nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .15rem; flex: 1; min-width: 0;
  color: var(--text-dim); font-size: .62rem; font-weight: 600;
  text-decoration: none; position: relative;
  letter-spacing: .02em; transition: color .15s;
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav-item:hover { color: var(--text-muted); }
.bottom-nav-item.active { color: var(--electric); }
.bottom-nav-icon { font-size: 1.2rem; line-height: 1; }
.bottom-nav-item.active .bottom-nav-icon { filter: drop-shadow(0 0 6px var(--electric-glow)); }
.bottom-nav-badge {
  position: absolute; top: 4px; right: calc(50% - 18px);
  min-width: 15px; height: 15px; border-radius: 8px;
  background: var(--electric); color: var(--bg-deep);
  font-size: .55rem; font-weight: 700; display: flex;
  align-items: center; justify-content: center; padding: 0 3px;
}
.bottom-nav-badge-amber { background: var(--amber); }

/* ────────────────────────────────────────────────
   Main + footer
   ──────────────────────────────────────────────── */
.main-content {
  flex: 1; max-width: 100%; width: 100%;
  padding: 1rem; padding-left: calc(1rem + var(--safe-left)); padding-right: calc(1rem + var(--safe-right));
}
.footer {
  text-align: center; padding: 1rem; font-size: .7rem; color: var(--text-dim);
  border-top: 1px solid var(--border); background: var(--bg-deep); letter-spacing: .01em;
  margin-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom));
}

/* ────────────────────────────────────────────────
   Page header
   ──────────────────────────────────────────────── */
.page-header { display: flex; flex-direction: column; gap: .65rem; margin-bottom: 1.15rem; }
.page-header-copy .subtitle { color: var(--text-muted); margin-top: .2rem; font-size: .82rem; }
.header-actions, .page-header-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

/* ────────────────────────────────────────────────
   Glass cards
   ──────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  transition: border-color .2s, box-shadow .2s;
}
.card:hover { border-color: var(--border-glow); }
.card-elevated { box-shadow: var(--shadow-md); border-color: var(--border-glow); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .85rem; flex-wrap: wrap; gap: .5rem; }
.card-subtext { font-size: .8rem; color: var(--text-muted); margin-bottom: .85rem; margin-top: -.4rem; }
.card-glass {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--subtle-bg);
}

/* ────────────────────────────────────────────────
   Stat row
   ──────────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; margin-bottom: 1.15rem; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .7rem .85rem; text-align: center; box-shadow: var(--shadow-sm);
  transition: border-color .2s, box-shadow .2s;
}
.stat-card:hover { border-color: var(--electric-dim); box-shadow: var(--shadow-glow); }
.stat-label { font-size: .65rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); margin-bottom: .2rem; }
.stat-value { font-size: 1.4rem; font-weight: 700; color: var(--text-primary); line-height: 1; }
.stat-unit  { font-size: .7rem; color: var(--text-muted); font-weight: 400; }

/* ────────────────────────────────────────────────
   Buttons (touch-friendly)
   ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .6rem 1.1rem; border-radius: var(--radius-sm);
  font-size: .82rem; font-weight: 600; cursor: pointer;
  border: 1.5px solid transparent; transition: all .2s ease; text-decoration: none; line-height: 1;
  letter-spacing: .01em; min-height: 44px; touch-action: manipulation;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn-primary  { background: var(--electric); color: var(--bg-deep); border-color: var(--electric); }
.btn-primary:hover { background: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 12px var(--electric-glow); }
.btn-secondary{ background: var(--bg-elevated); color: var(--text-primary); border-color: var(--border-glow); }
.btn-secondary:hover { background: var(--hover-bg); border-color: var(--border-glow); }
.btn-outline  { background: transparent; color: var(--electric); border-color: var(--electric-dim); }
.btn-outline:hover { background: var(--electric-dim); border-color: var(--electric); }
.btn-ghost    { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { background: var(--hover-bg); color: var(--text-primary); }
.btn-lg  { padding: .7rem 1.4rem; font-size: .9rem; min-height: 48px; }
.btn-sm  { padding: .35rem .7rem; font-size: .75rem; min-height: 36px; }
.btn-block { width: 100%; }

/* ────────────────────────────────────────────────
   Flash messages
   ──────────────────────────────────────────────── */
.flash-container { margin-bottom: 1rem; display: flex; flex-direction: column; gap: .45rem; }
.flash { padding: .6rem .9rem; border-radius: var(--radius-sm); font-size: .82rem; font-weight: 500; border: 1px solid transparent; }
.flash-success { background: var(--green-dim);  color: var(--green);    border-color: rgba(74,222,128,.2); }
.flash-error   { background: var(--red-dim);    color: var(--red-soft); border-color: rgba(248,113,113,.2); }
.flash-warning { background: var(--amber-dim);  color: var(--amber);   border-color: rgba(251,191,36,.2); }
.flash-info    { background: var(--electric-dim);color: var(--electric);border-color: rgba(56,189,248,.2); }

/* ────────────────────────────────────────────────
   Forms (mobile-friendly)
   ──────────────────────────────────────────────── */
.form-card  { max-width: 100%; }
.form-group { margin-bottom: 1.15rem; }
.form-row   { display: flex; flex-direction: column; gap: 1rem; }
.form-label { display: block; font-size: .85rem; font-weight: 600; color: var(--text-primary); margin-bottom: .4rem; }
.form-label-hint { display: block; font-size: .78rem; font-weight: 400; color: var(--text-muted); margin-top: .12rem; }
.required { color: var(--amber); margin-left: .1rem; }
.optional { font-size: .72rem; font-weight: 400; color: var(--text-dim); margin-left: .25rem; }
.form-input, .form-textarea {
  width: 100%; padding: .65rem .85rem; background: var(--bg-input);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 16px; color: var(--text-primary); transition: border-color .2s, box-shadow .2s;
  min-height: 44px; -webkit-appearance: none; appearance: none;
}
.form-input:focus, .form-textarea:focus { outline: none; border-color: var(--electric); box-shadow: 0 0 0 3px var(--electric-dim); background: var(--bg-elevated); }
.form-textarea { resize: vertical; min-height: 90px; }
.form-actions { display: flex; gap: .65rem; align-items: center; margin-top: 1.25rem; flex-wrap: wrap; }
.form-actions .btn { flex: 1; min-width: 120px; }

/* Type selector (insulin category) */
.type-selector { display: grid; grid-template-columns: repeat(3,1fr); gap: .55rem; }
.type-option input { display: none; }
.type-label {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .25rem; padding: .75rem .4rem;
  border: 2px solid var(--border); border-radius: var(--radius); cursor: pointer;
  text-align: center; transition: all .2s; background: var(--bg-card);
  font-weight: 600; font-size: .78rem; color: var(--text-body);
  min-height: 70px;
}
.type-icon { font-size: 1.3rem; display: block; }
.type-sub  { font-size: .68rem; font-weight: 400; color: var(--text-dim); }
.type-option input:checked + .type-label { border-color: var(--electric); background: var(--electric-dim); color: var(--electric); }
.type-label:hover { border-color: rgba(56,189,248,.3); background: var(--electric-dim); }

/* ────────────────────────────────────────────────
   Tables
   ──────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -.25rem; padding: 0 .25rem; }
.data-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.data-table th { text-align: left; font-size: .65rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-dim); padding: .5rem .55rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: .55rem; border-bottom: 1px solid var(--subtle-border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--subtle-wash); }
.data-table tr.row-attention td { background: var(--amber-dim); }
.ts-cell   { color: var(--text-muted); white-space: nowrap; font-family: var(--font-mono); font-size: .75rem; }
.name-cell { font-weight: 500; color: var(--text-primary); }

/* Stacked card layout for tables on mobile */
.mobile-stack { display: flex; flex-direction: column; gap: .55rem; }
.mobile-stack-item {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .75rem .85rem;
  display: flex; flex-wrap: wrap; gap: .35rem .65rem; align-items: center;
}
.mobile-stack-primary { font-weight: 600; color: var(--text-primary); flex: 1; min-width: 100px; }
.mobile-stack-secondary { font-size: .78rem; color: var(--text-muted); }

/* ────────────────────────────────────────────────
   Badges & pills
   ──────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: .2rem .55rem; border-radius: 5px; font-size: .72rem; font-weight: 700; letter-spacing: .02em; text-transform: capitalize; white-space: nowrap; }
.badge-meal       { background: var(--amber-dim);   color: var(--amber); }
.badge-walk       { background: var(--cyan-dim);     color: var(--cyan); }
.badge-note       { background: var(--subtle-bg); color: var(--text-body); }
.badge-activity   { background: var(--cyan-dim);     color: var(--cyan); }
.badge-insulin    { background: var(--violet-dim);   color: var(--violet); }
.badge-bolus      { background: var(--amber-dim);   color: var(--amber); }
.badge-basal      { background: var(--green-dim);    color: var(--green); }
.badge-correction { background: var(--violet-dim);   color: var(--violet); }

.status-pill { display: inline-flex; align-items: center; padding: .18rem .5rem; border-radius: 20px; font-size: .7rem; font-weight: 600; white-space: nowrap; }
.status-confirmed { background: var(--green-dim);  color: var(--green); }
.status-pending   { background: var(--amber-dim);  color: var(--amber); }
.status-estimated { background: var(--violet-dim); color: var(--violet); }

.source-tag { display: inline-flex; align-items: center; padding: .16rem .5rem; border-radius: 4px; background: var(--subtle-bg); color: var(--text-muted); font-size: .7rem; font-weight: 600; margin-left: .25rem; }

/* ────────────────────────────────────────────────
   Chart
   ──────────────────────────────────────────────── */
.chart-container { height: 220px; width: 100%; position: relative; }
.chart-legend { display: flex; gap: .65rem; align-items: center; font-size: .72rem; color: var(--text-muted); flex-wrap: wrap; }
.legend-dot  { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 3px; }
.legend-glucose .legend-dot { background: var(--electric); }
.legend-meal    .legend-dot { background: var(--amber); }
.legend-walk    .legend-dot { background: var(--cyan); }
.legend-insulin .legend-dot { background: var(--violet); }

/* ────────────────────────────────────────────────
   Caregiver insight cards
   ──────────────────────────────────────────────── */
.insight-cards-row  { display: flex; flex-direction: column; gap: .65rem; margin-bottom: 1rem; }
.insight-quick-card { display: flex; gap: .65rem; align-items: flex-start; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem; box-shadow: var(--shadow-sm); }
.insight-quick-ok         { border-left: 3px solid var(--green); }
.insight-quick-attention  { border-left: 3px solid var(--amber); }
.insight-quick-neutral    { border-left: 3px solid var(--border-glow); }
.iq-icon  { font-size: 1.2rem; flex-shrink: 0; }
.iq-title { font-weight: 700; font-size: .82rem; color: var(--text-primary); margin-bottom: .12rem; }
.iq-body-text { font-size: .78rem; color: var(--text-muted); line-height: 1.45; }
.iq-link  { font-size: .75rem; font-weight: 600; color: var(--electric); display: inline-block; margin-top: .2rem; }

/* Missing context prompt */
.missing-prompt { display: flex; gap: .5rem; align-items: flex-start; padding: .6rem .85rem; background: var(--electric-dim); border: 1px solid rgba(56,189,248,.15); border-radius: var(--radius-sm); font-size: .8rem; color: var(--electric); margin-bottom: .4rem; }
.missing-icon { flex-shrink: 0; }

.nudge-section { margin-bottom: 1rem; }
.nudge-list { display: flex; flex-direction: column; gap: .5rem; }
.nudge-card { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .7rem .85rem; background: linear-gradient(135deg, rgba(6,182,212,.08), rgba(139,92,246,.06)); border: 1px solid rgba(6,182,212,.18); border-radius: var(--radius-sm); }
.nudge-content { display: flex; align-items: flex-start; gap: .5rem; flex: 1; min-width: 0; }
.nudge-icon { flex-shrink: 0; font-size: 1.1rem; }
.nudge-msg { font-size: .8rem; color: var(--text-body); line-height: 1.4; }
.nudge-btn { flex-shrink: 0; white-space: nowrap; font-size: .75rem; padding: .35rem .75rem; }

.consent-box { background: rgba(6,182,212,.06); border: 1px solid rgba(6,182,212,.15); border-radius: var(--radius-sm); padding: .85rem; }
.consent-text { font-size: .78rem; color: var(--text-body); line-height: 1.55; }
.consent-text strong { color: var(--text-primary); font-size: .85rem; display: block; margin-bottom: .4rem; }
.consent-text p { margin: .3rem 0; }
.consent-text ul { margin: .4rem 0 .6rem 1.2rem; padding: 0; }
.consent-text ul li { margin-bottom: .3rem; }
.consent-checkbox { display: flex; align-items: flex-start; gap: .5rem; margin-top: .75rem; font-size: .82rem; color: var(--text-primary); cursor: pointer; }
.consent-checkbox input[type="checkbox"] { margin-top: .15rem; width: 18px; height: 18px; accent-color: var(--electric); flex-shrink: 0; }
.consent-record { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid var(--subtle-bg); }
.consent-record:last-child { border-bottom: none; }
.consent-revoked { opacity: .55; }
.consent-record-info { flex: 1; min-width: 0; }

/* ────────────────────────────────────────────────
   "Did Bailey take insulin?" card
   ──────────────────────────────────────────────── */
.did-bailey-card { border-left: 4px solid var(--electric); }
.did-bailey-header { display: flex; align-items: center; gap: .55rem; margin-bottom: .6rem; }
.did-bailey-icon  { font-size: 1.2rem; }
.did-bailey-title { font-size: .9rem; font-weight: 700; color: var(--text-primary); }
.did-bailey-answer { font-size: .85rem; padding: .5rem .8rem; border-radius: var(--radius-sm); margin-bottom: .4rem; }
.did-bailey-yes   { background: var(--green-dim);    color: var(--green); }
.did-bailey-none  { background: var(--subtle-bg); color: var(--text-muted); }
.did-bailey-pending { font-size: .78rem; color: var(--amber); }

/* ────────────────────────────────────────────────
   Timeline
   ──────────────────────────────────────────────── */
.timeline-wrap  { padding: 1rem; }
.tl-item { display: grid; grid-template-columns: 44px 14px 1fr; gap: .3rem .6rem; align-items: start; padding: .5rem 0; border-bottom: 1px solid var(--subtle-border); }
.tl-item:last-child { border-bottom: none; }
.tl-time { font-size: .7rem; font-weight: 600; color: var(--text-dim); padding-top: .1rem; text-align: right; font-family: var(--font-mono); }
.tl-dot  { width: 10px; height: 10px; border-radius: 50%; margin-top: .3rem; border: 2px solid transparent; }
.tl-dot-reading  { background: var(--electric); border-color: var(--electric-dim); box-shadow: 0 0 6px var(--electric-glow); }
.tl-dot-meal     { background: var(--amber);    border-color: var(--amber-dim); }
.tl-dot-walk     { background: var(--cyan);     border-color: var(--cyan-dim); }
.tl-dot-note     { background: var(--text-dim); border-color: var(--subtle-bg); }
.tl-dot-insulin  { background: var(--violet);   border-color: var(--violet-dim); }
.tl-body { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; min-width: 0; }
.tl-glucose { font-size: .88rem; font-weight: 700; color: var(--text-primary); }
.tl-event-badge { display: inline-flex; align-items: center; padding: .14rem .42rem; border-radius: 5px; font-size: .7rem; font-weight: 700; }
.tl-badge-meal     { background: var(--amber-dim);  color: var(--amber); }
.tl-badge-walk     { background: var(--cyan-dim);    color: var(--cyan); }
.tl-badge-note     { background: var(--subtle-bg); color: var(--text-body); }
.tl-badge-insulin  { background: var(--violet-dim); color: var(--violet); }
.tl-event-title { font-size: .8rem; color: var(--text-primary); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.tl-insulin-pending { opacity: .7; }
.tl-context { width: 100%; font-size: .72rem; color: var(--text-dim); margin-top: .1rem; display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.tl-context-label { font-weight: 600; color: var(--text-muted); }
.tl-context-item  { background: var(--subtle-bg); padding: .06rem .3rem; border-radius: 4px; }
.tl-change-down { color: var(--cyan); }
.tl-change-up   { color: var(--amber); }

/* ────────────────────────────────────────────────
   Caregiver summary helpers
   ──────────────────────────────────────────────── */
.summary-section { margin-bottom: .75rem; padding-bottom: .55rem; border-bottom: 1px solid var(--subtle-border); }
.summary-section:last-child { border-bottom: none; margin-bottom: 0; }
.summary-section-header { display: flex; align-items: center; gap: .4rem; margin-bottom: .4rem; }
.summary-entry-row { display: flex; align-items: center; gap: .45rem; padding: .25rem 0; font-size: .8rem; }
.summary-time { font-size: .72rem; color: var(--text-dim); font-weight: 600; min-width: 40px; font-family: var(--font-mono); }
.summary-val  { font-weight: 500; color: var(--text-primary); }

/* ────────────────────────────────────────────────
   Insulin pattern bars
   ──────────────────────────────────────────────── */
.pattern-bar-group { display: flex; flex-direction: column; gap: .65rem; margin-top: .4rem; }
.pattern-bar-row   { display: flex; align-items: center; gap: .55rem; }
.pattern-bar-label { font-size: .75rem; font-weight: 600; text-transform: capitalize; width: 72px; color: var(--text-muted); flex-shrink: 0; }
.pattern-bar-track { flex: 1; height: 10px; background: var(--subtle-bg); border-radius: 5px; overflow: hidden; }
.pattern-bar-fill  { height: 100%; border-radius: 5px; transition: width .4s ease; min-width: 4px; }
.pattern-bar-basal      { background: var(--green); }
.pattern-bar-bolus      { background: var(--amber); }
.pattern-bar-correction { background: var(--violet); }
.pattern-bar-val { font-size: .75rem; color: var(--text-muted); min-width: 44px; text-align: right; }

/* ────────────────────────────────────────────────
   Info card
   ──────────────────────────────────────────────── */
.info-card { background: var(--electric-dim); border-color: rgba(56,189,248,.15); margin-top: 1rem; }
.info-card h3 { color: var(--electric); }
.info-list { display: flex; flex-direction: column; gap: .4rem; margin-top: .4rem; }
.info-list li { font-size: .8rem; color: var(--electric); padding-left: 1rem; position: relative; }
.info-list li::before { content: '·'; position: absolute; left: 0; font-weight: 700; color: var(--electric); }

/* ────────────────────────────────────────────────
   Notification card
   ──────────────────────────────────────────────── */
.notif-card { border-color: rgba(56,189,248,.2); background: var(--electric-dim); }

/* ────────────────────────────────────────────────
   Upload hub
   ──────────────────────────────────────────────── */
.upload-hub { display: flex; flex-direction: column; gap: .85rem; }
.upload-option {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; gap: .55rem;
  padding: 1.5rem 1rem; background: var(--bg-card);
  border: 2px solid var(--border); border-radius: var(--radius-lg);
  cursor: pointer; text-decoration: none; color: inherit;
  transition: border-color .2s, box-shadow .2s;
  box-shadow: var(--shadow-sm); min-height: 80px;
}
.upload-option:hover { border-color: var(--electric-dim); box-shadow: var(--shadow-glow), var(--shadow-md); text-decoration: none; }
.upload-option:active { transform: scale(.98); }
.upload-option-icon { font-size: 2rem; }
.upload-option-title { font-size: 1rem; color: var(--text-primary); font-weight: 600; }
.upload-option-sub   { font-size: .8rem; color: var(--text-muted); max-width: 260px; }
.upload-option-featured { border-color: rgba(56,189,248,.25); background: linear-gradient(135deg, var(--bg-card) 0%, rgba(56,189,248,.05) 100%); position: relative; }
.upload-option-featured:hover { border-color: var(--electric); }
.upload-option-badge { position: absolute; top: .7rem; right: .7rem; background: var(--electric); color: var(--bg-deep); font-size: .62rem; font-weight: 700; padding: .15rem .5rem; border-radius: 20px; letter-spacing: .04em; text-transform: uppercase; }

/* ── LibreSync page ────────────────────────────────────────────────────────── */
.libre-section-header { display: flex; gap: 1rem; align-items: flex-start; margin-bottom: 1.1rem; }
.libre-section-icon { font-size: 1.5rem; line-height: 1; margin-top: .1rem; flex-shrink: 0; }
.libre-section-title { font-size: .95rem; font-weight: 700; color: var(--text-primary); margin-bottom: .2rem; }
.libre-section-sub { font-size: .82rem; color: var(--text-muted); line-height: 1.5; }

.libre-last-sync { font-size: .8rem; color: var(--text-muted); padding: .45rem .65rem; background: var(--bg-elevated); border-radius: var(--radius-sm); display: inline-block; }

.libre-status-card { display: flex; flex-direction: column; gap: .5rem; padding: .9rem 1.1rem; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg-elevated); margin-bottom: 1rem; }
.libre-status-inner { display: flex; align-items: center; gap: .65rem; }
.libre-status-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot-loading { background: var(--amber); box-shadow: 0 0 6px var(--amber); animation: pulse-dot .8s infinite; }
.dot-ok  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot-err { background: var(--red-soft); box-shadow: 0 0 6px var(--red-soft); }
@keyframes pulse-dot { 0%,100% { opacity:1; } 50% { opacity:.35; } }
.libre-status-msg { font-size: .88rem; font-weight: 600; color: var(--text-primary); }
.libre-status-detail { font-size: .8rem; color: var(--text-muted); padding-left: 1.65rem; line-height: 1.5; }

.password-wrap { position: relative; }
.password-toggle { position: absolute; right: .6rem; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; font-size: 1rem; color: var(--text-muted); padding: .2rem; line-height: 1; }
.password-toggle:hover { color: var(--text-primary); }

/* ── Smart meal entry ──────────────────────────────────────────────────────── */
.smart-entry-bar { display: flex; gap: .6rem; margin-bottom: 1rem; flex-wrap: wrap; }
.smart-entry-btn { display: flex; align-items: center; gap: .45rem; padding: .55rem .9rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card-bg); color: var(--text-primary); font-size: .82rem; font-weight: 600; cursor: pointer; transition: border-color .15s, background .15s; }
.smart-entry-btn:hover:not(:disabled) { border-color: var(--accent); background: rgba(56,189,248,.06); }
.smart-entry-btn:disabled { opacity: .5; cursor: not-allowed; }
.smart-entry-icon { font-size: 1rem; line-height: 1; }

.lookup-chip { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .75rem 1rem; background: rgba(56,189,248,.07); border: 1px solid rgba(56,189,248,.25); border-radius: var(--radius); margin-bottom: .85rem; flex-wrap: wrap; }
.lookup-chip-body { flex: 1; min-width: 0; }
.lookup-chip-name { font-size: .88rem; font-weight: 700; color: var(--text-primary); margin-bottom: .2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lookup-chip-meta { display: flex; flex-wrap: wrap; gap: .35rem .7rem; align-items: center; }
.lookup-chip-carbs { font-size: .82rem; font-weight: 700; color: var(--accent); }
.lookup-chip-note { font-size: .75rem; color: var(--text-muted); }
.lookup-chip-actions { display: flex; gap: .4rem; align-items: center; flex-shrink: 0; }

.lookup-error-chip { display: flex; align-items: center; padding: .65rem .9rem; background: rgba(248,113,113,.07); border: 1px solid rgba(248,113,113,.2); border-radius: var(--radius); margin-bottom: .85rem; font-size: .82rem; color: var(--red-soft); }

/* ── Barcode scanner modal ─────────────────────────────────────────────────── */
.scanner-modal { position: fixed; inset: 0; z-index: 9999; background: rgba(0,0,0,.82); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.scanner-modal-inner { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); width: 100%; max-width: 380px; overflow: hidden; }
.scanner-modal-header { display: flex; align-items: center; justify-content: space-between; padding: .9rem 1rem .75rem; border-bottom: 1px solid var(--border); }
.scanner-modal-title { font-size: .95rem; font-weight: 700; color: var(--text-primary); }
.scanner-close-btn { background: none; border: none; cursor: pointer; font-size: 1.1rem; color: var(--text-muted); padding: .2rem .4rem; border-radius: 4px; }
.scanner-close-btn:hover { color: var(--text-primary); background: var(--border); }
.scanner-hint { font-size: .78rem; color: var(--text-muted); padding: .45rem 1rem 0; margin: 0; }
#reader { width: 100% !important; border: none !important; padding: .5rem !important; box-sizing: border-box; }
#reader video { border-radius: 8px; }
#reader img { display: none !important; }
.scanner-status { padding: .5rem 1rem .9rem; font-size: .8rem; color: var(--text-muted); min-height: 1.5rem; text-align: center; }

/* ── Data management ───────────────────────────────────────────────────────── */
.data-action-list { display: flex; flex-direction: column; gap: 0; }
.data-action-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 0; border-bottom: 1px solid var(--border); }
.data-action-row:last-child { border-bottom: none; padding-bottom: 0; }
.data-action-info { flex: 1; min-width: 0; }
.data-action-title { font-size: .88rem; font-weight: 600; color: var(--text-primary); margin-bottom: .15rem; }
.data-action-sub { font-size: .75rem; color: var(--text-muted); }

/* Drop zones */
.drop-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 1.5rem; text-align: center; cursor: pointer;
  transition: border-color .2s, background .2s; background: var(--bg-card);
  margin: .5rem 0;
}
.drop-zone.active, .drop-zone:hover { border-color: var(--electric); background: var(--electric-dim); }
.drop-zone-icon  { font-size: 1.6rem; margin-bottom: .4rem; }
.drop-zone-label { font-weight: 600; color: var(--text-primary); font-size: .88rem; }
.drop-zone-sub   { font-size: .75rem; color: var(--text-muted); margin-top: .15rem; }

/* ────────────────────────────────────────────────
   Empty state
   ──────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 2.5rem 1.25rem; }
.empty-icon  { font-size: 2.5rem; margin-bottom: .75rem; }
.empty-state h2   { margin-bottom: .4rem; }
.empty-state p    { color: var(--text-muted); max-width: 320px; margin: 0 auto 1.15rem; font-size: .88rem; }

/* ────────────────────────────────────────────────
   Review image page
   ──────────────────────────────────────────────── */
.review-grid { display: flex; flex-direction: column; gap: 1rem; }
.review-image-wrap img { width: 100%; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.conf-pill-high   { background: var(--green-dim);    color: var(--green);   display: inline-flex; align-items: center; gap: .3rem; padding: .22rem .6rem; border-radius: 20px; font-size: .75rem; font-weight: 700; }
.conf-pill-medium { background: var(--amber-dim);    color: var(--amber);   display: inline-flex; align-items: center; gap: .3rem; padding: .22rem .6rem; border-radius: 20px; font-size: .75rem; font-weight: 700; }
.conf-pill-low    { background: var(--red-dim);      color: var(--red-soft);display: inline-flex; align-items: center; gap: .3rem; padding: .22rem .6rem; border-radius: 20px; font-size: .75rem; font-weight: 700; }

/* ────────────────────────────────────────────────
   Analysis pages (meals/walks)
   ──────────────────────────────────────────────── */
.analysis-grid { display: flex; flex-direction: column; gap: .85rem; }
.analysis-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow-sm); }
.analysis-card h3 { margin-bottom: .5rem; font-size: .92rem; }
.analysis-stat-row { display: flex; gap: .45rem; flex-wrap: wrap; margin-top: .5rem; }
.analysis-stat { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .3rem .55rem; font-size: .75rem; }
.analysis-stat .label { color: var(--text-muted); }
.analysis-stat .value { font-weight: 700; color: var(--text-primary); }

/* ────────────────────────────────────────────────
   Summary / insights page
   ──────────────────────────────────────────────── */
.insight-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow-sm); display: flex; gap: .75rem; align-items: flex-start; margin-bottom: .75rem; }
.insight-icon { font-size: 1.2rem; flex-shrink: 0; }
.insight-category { font-size: .65rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--electric); margin-bottom: .2rem; }
.insight-text { font-size: .82rem; color: var(--text-body); line-height: 1.5; }

/* ────────────────────────────────────────────────
   Utility
   ──────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.mt-0 { margin-top: 0; }
.mt-3 { margin-top: .85rem; }
.mt-4 { margin-top: 1.15rem; }
.mb-0 { margin-bottom: 0; }
.mb-3 { margin-bottom: .85rem; }
.mb-4 { margin-bottom: 1.15rem; }
.grid-mobile-stack { display: flex; flex-direction: column; gap: .85rem; }
.hide-mobile { display: none; }
.show-mobile { display: block; }
.no-data { color: var(--text-dim); }

/* ────────────────────────────────────────────────
   Signal hero (alerts page)
   ──────────────────────────────────────────────── */
.alert-hero {
  background: var(--bg-card); border: 1px solid var(--border-glow); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md), var(--shadow-glow); overflow: hidden;
}
.alert-hero-inner     { display: flex; align-items: center; gap: 1.25rem; padding: 1.15rem; flex-wrap: wrap; }
.alert-hero-reading   { text-align: center; min-width: 70px; position: relative; }
.alert-hero-val       { font-size: 2.2rem; font-weight: 800; color: var(--text-primary); line-height: 1; letter-spacing: -.03em; text-shadow: 0 0 20px var(--electric-glow); }
.alert-hero-unit      { font-size: .65rem; color: var(--text-dim); font-weight: 600; margin-top: .12rem; text-transform: uppercase; letter-spacing: .05em; }
.alert-hero-trend     { display: flex; align-items: center; gap: .5rem; flex: 1; min-width: 120px; }
.trend-arrow-big      { font-size: 1.3rem; font-weight: 700; line-height: 1; }
.trend-label-big      { font-size: .85rem; font-weight: 700; color: var(--text-primary); }
.rising_fast          { color: var(--amber); text-shadow: 0 0 8px var(--amber-dim); }
.rising               { color: var(--amber); }
.falling_fast         { color: var(--cyan); text-shadow: 0 0 8px var(--cyan-dim); }
.falling              { color: var(--cyan); }
.stable               { color: var(--green); }
.alert-hero-status    { flex-shrink: 0; }
.obs-badge            { display: inline-block; padding: .35rem .85rem; border-radius: 20px; font-weight: 700; font-size: .75rem; letter-spacing: .02em; }
.obs-clear            { background: var(--green-dim); color: var(--green); }
.obs-active           { background: var(--electric-dim); color: var(--electric); animation: pulse-glow 3s ease-in-out infinite; }

/* Disclaimer */
.obs-disclaimer       { display: flex; gap: .5rem; align-items: flex-start; padding: .55rem .8rem; background: var(--subtle-wash); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .72rem; color: var(--text-dim); line-height: 1.45; }
.obs-disclaimer-icon  { flex-shrink: 0; font-size: .82rem; margin-top: .03rem; }

/* ────────────────────────────────────────────────
   Signal cards (glass)
   ──────────────────────────────────────────────── */
.obs-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  overflow: hidden; transition: border-color .2s, box-shadow .2s;
}
.obs-card:hover       { border-color: var(--border-glow); box-shadow: var(--shadow-md); }
.obs-accent-amber     { border-left: 3px solid var(--amber); }
.obs-accent-teal      { border-left: 3px solid var(--cyan); }
.obs-accent-sage      { border-left: 3px solid var(--green); }

.obs-card-header      { display: flex; align-items: center; gap: .65rem; padding: .85rem 1rem .45rem; }
.obs-icon             { font-size: 1.15rem; flex-shrink: 0; width: 1.6rem; text-align: center; }
.obs-header-body      { flex: 1; min-width: 0; }
.obs-title            { font-size: .88rem; font-weight: 700; color: var(--text-primary); line-height: 1.3; }
.obs-meta             { display: flex; align-items: center; gap: .35rem; margin-top: .18rem; flex-wrap: wrap; }
.obs-toggle           { background: none; border: 1.5px solid var(--border); border-radius: 50%; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; font-size: .65rem; cursor: pointer; color: var(--text-dim); flex-shrink: 0; transition: all .2s; min-height: 32px; }
.obs-toggle:hover     { border-color: var(--electric); color: var(--electric); background: var(--electric-dim); }

/* Score pills — glow-based */
.score-pill           { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; padding: .14rem .5rem; border-radius: 10px; font-size: .7rem; font-weight: 800; letter-spacing: .02em; font-family: var(--font-mono); }
.band-none            { background: var(--subtle-bg); color: var(--text-dim); }
.band-gentle          { background: var(--amber-dim); color: var(--amber); }
.band-pattern         { background: rgba(56,189,248,.15); color: var(--electric); }
.band-consistent      { background: var(--green-dim); color: var(--green); }

/* Confidence pills */
.conf-pill            { display: inline-block; padding: .14rem .45rem; border-radius: 4px; font-size: .65rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.conf-level-0         { background: var(--subtle-bg); color: var(--text-dim); }
.conf-level-1         { background: var(--subtle-bg); color: var(--text-muted); }
.conf-level-2         { background: var(--amber-dim); color: var(--amber); }
.conf-level-3         { background: var(--electric-dim); color: var(--electric); }
.conf-level-4         { background: var(--green-dim); color: var(--green); }

/* Reasons (always visible, scannable) */
.obs-reasons          { padding: 0 1rem .7rem 2.8rem; display: flex; flex-direction: column; gap: .22rem; }
.obs-reason           { display: flex; gap: .4rem; align-items: flex-start; font-size: .78rem; color: var(--text-body); line-height: 1.45; }
.obs-reason-dot       { width: 4px; height: 4px; border-radius: 50%; background: var(--electric); flex-shrink: 0; margin-top: .4rem; opacity: .6; }
.obs-dot-pos          { background: var(--green); }

/* Detail drawer */
.obs-drawer           { border-top: 1px solid var(--subtle-border); background: var(--bg-surface); }
.obs-section-label    { font-size: .62rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-dim); margin: .7rem 1rem .3rem; }

/* Factor breakdown bars */
.obs-factor-list      { padding: 0 1rem; }
.obs-factor-row       { display: flex; align-items: center; gap: .5rem; padding: .22rem 0; }
.obs-factor-name      { min-width: 90px; font-size: .7rem; font-weight: 600; color: var(--text-dim); text-transform: capitalize; }
.obs-factor-bar-wrap  { flex: 1; height: 5px; background: var(--subtle-bg); border-radius: 3px; overflow: hidden; }
.obs-factor-bar       { height: 100%; background: var(--electric); border-radius: 3px; transition: width .4s ease; min-width: 2px; box-shadow: 0 0 6px var(--electric-glow); }
.obs-factor-neg       { background: var(--cyan); box-shadow: 0 0 6px var(--cyan-dim); }
.obs-factor-val       { min-width: 32px; text-align: right; font-size: .68rem; font-weight: 700; color: var(--electric); font-family: var(--font-mono); }
.obs-val-neg          { color: var(--cyan); }
.obs-factor-total     { display: flex; justify-content: space-between; padding: .35rem 0 .22rem; border-top: 1px solid var(--subtle-bg); margin-top: .22rem; font-size: .7rem; font-weight: 700; color: var(--text-primary); }

/* Context rows */
.obs-context-row      { display: flex; justify-content: space-between; align-items: center; padding: .22rem 1rem; font-size: .75rem; flex-wrap: wrap; gap: .25rem; }

/* Suggestions */
.obs-suggestion       { display: flex; gap: .4rem; align-items: flex-start; font-size: .75rem; color: var(--text-body); background: var(--electric-dim); border-radius: var(--radius-sm); padding: .4rem .7rem; margin: .15rem 1rem; }
.obs-suggestion-icon  { flex-shrink: 0; font-size: .78rem; }

/* Drawer footer */
.obs-drawer-foot      { display: flex; align-items: center; gap: .5rem; padding: .5rem 1rem; flex-wrap: wrap; }
.obs-conf-note        { font-size: .68rem; color: var(--text-dim); }

/* Empty / info states */
.obs-empty            { text-align: center; padding: 1.75rem 1rem; }
.obs-info             { background: var(--bg-card); border: 1px solid var(--border); }
.obs-band-legend      { display: flex; flex-direction: column; gap: .4rem; }
.obs-band-item        { display: flex; align-items: center; gap: .5rem; font-size: .75rem; color: var(--text-body); }
.obs-info-grid        { display: flex; flex-direction: column; gap: .65rem; }
.obs-info-tile        { display: flex; gap: .5rem; align-items: flex-start; }
.obs-info-tile-icon   { font-size: 1rem; flex-shrink: 0; }
.obs-info-tile-title  { font-weight: 700; font-size: .8rem; color: var(--text-primary); margin-bottom: .1rem; }
.obs-info-tile-body   { font-size: .72rem; color: var(--text-muted); line-height: 1.4; }

/* ────────────────────────────────────────────────
   Signal history list
   ──────────────────────────────────────────────── */
.obs-history          { display: flex; flex-direction: column; gap: .3rem; }
.obs-hist-row         { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .5rem .7rem; border-radius: var(--radius-sm); background: var(--bg-surface); border: 1px solid var(--subtle-border); flex-wrap: wrap; }
.obs-hist-active      { border-left: 3px solid var(--amber); }
.obs-hist-dismissed   { opacity: .5; }
.obs-hist-reviewed    { border-left: 3px solid var(--green); opacity: .75; }
.obs-hist-body        { display: flex; flex-direction: column; gap: .06rem; min-width: 0; flex: 1; }
.obs-hist-type        { font-size: .78rem; font-weight: 700; color: var(--text-primary); }
.obs-hist-detail      { font-size: .65rem; color: var(--text-dim); }
.obs-hist-actions     { display: flex; gap: .3rem; align-items: center; flex-shrink: 0; }
.obs-status-tag       { display: inline-block; padding: .12rem .45rem; border-radius: 4px; font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.tag-dismissed        { background: var(--subtle-bg); color: var(--text-dim); }
.tag-reviewed         { background: var(--green-dim); color: var(--green); }

/* ────────────────────────────────────────────────
   Dashboard signals widget
   ──────────────────────────────────────────────── */
.dash-insights        { background: var(--bg-card); border: 1px solid var(--border-glow); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.dash-insights-header { display: flex; align-items: center; justify-content: space-between; padding: .7rem 1rem; border-bottom: 1px solid var(--subtle-border); }
.dash-insights-title  { display: flex; align-items: center; gap: .4rem; font-weight: 700; font-size: .82rem; color: var(--text-primary); }
.dash-insights-icon   { font-size: .85rem; }
.dash-insights-link   { font-size: .72rem; font-weight: 600; color: var(--electric); text-decoration: none; }
.dash-insights-link:hover { text-decoration: underline; }
.dash-insights-list   { padding: .25rem 0; }
.dash-insight-item    { padding: .55rem 1rem; border-bottom: 1px solid var(--subtle-border); transition: background .15s; }
.dash-insight-item:last-child { border-bottom: none; }
.dash-insight-amber   { border-left: 3px solid var(--amber); }
.dash-insight-teal    { border-left: 3px solid var(--cyan); }
.dash-insight-sage    { border-left: 3px solid var(--green); }
.dash-insight-top     { display: flex; align-items: center; gap: .4rem; margin-bottom: .22rem; }
.dash-insight-icon    { font-size: .85rem; flex-shrink: 0; }
.dash-insight-label   { flex: 1; font-weight: 700; font-size: .8rem; color: var(--text-primary); min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.dash-insight-reasons { display: flex; flex-direction: column; gap: .1rem; padding-left: 1.3rem; }
.dash-insight-reason  { font-size: .7rem; color: var(--text-muted); line-height: 1.4; position: relative; padding-left: .55rem; }
.dash-insight-reason::before { content: ''; position: absolute; left: 0; top: .35rem; width: 3px; height: 3px; border-radius: 50%; background: var(--electric); opacity: .5; }

/* ────────────────────────────────────────────────
   Dashboard — Clarity Index arc
   ──────────────────────────────────────────────── */
.clarity-card { text-align: center; padding: 1rem; }
.clarity-arc-wrap { position: relative; display: inline-flex; align-items: center; justify-content: center; margin-bottom: .55rem; }
.clarity-arc { width: 80px; height: 80px; transform: rotate(-90deg); }
.clarity-arc-bg { fill: none; stroke: var(--subtle-bg); stroke-width: 6; }
.clarity-arc-fill { fill: none; stroke: var(--electric); stroke-width: 6; stroke-linecap: round; transition: stroke-dashoffset 1s ease; filter: drop-shadow(0 0 6px var(--electric-glow)); }
.clarity-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.clarity-number { font-size: 1.25rem; font-weight: 800; color: var(--text-primary); font-family: var(--font-mono); }
.clarity-label-sm { font-size: .58rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.clarity-hint { font-size: .68rem; color: var(--text-dim); max-width: 180px; margin: 0 auto; }
.clarity-items { display: flex; flex-direction: column; gap: .18rem; align-items: flex-start; width: fit-content; margin: .5rem auto 0; }
.clarity-item { display: flex; gap: .3rem; align-items: center; font-size: .72rem; font-weight: 500; }
.clarity-item-on  { color: var(--green); }
.clarity-item-off { color: var(--text-dim); text-decoration: line-through; }

/* ────────────────────────────────────────────────
   Dashboard — System maturity
   ──────────────────────────────────────────────── */
.maturity-card { padding: 1rem; }
.maturity-stages { display: flex; flex-direction: column; gap: .3rem; }
.maturity-stage { display: flex; align-items: center; gap: .55rem; padding: .3rem .45rem; border-radius: var(--radius-sm); font-size: .75rem; transition: background .15s; }
.maturity-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; background: var(--border-glow); transition: all .3s; }
.maturity-label { color: var(--text-dim); transition: color .3s; }
.maturity-active .maturity-dot { background: var(--electric); box-shadow: 0 0 8px var(--electric-glow); }
.maturity-active .maturity-label { color: var(--electric); font-weight: 700; }
.maturity-complete .maturity-dot { background: var(--green); }
.maturity-complete .maturity-label { color: var(--text-muted); }
.maturity-current { background: var(--electric-dim); }

/* ────────────────────────────────────────────────
   Dashboard — Continuity indicators
   ──────────────────────────────────────────────── */
.continuity-row { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.continuity-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem .85rem; text-align: center; }
.continuity-val { font-size: 1.6rem; font-weight: 800; color: var(--text-primary); line-height: 1; font-family: var(--font-mono); }
.continuity-label { font-size: .62rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); margin-top: .2rem; }
.continuity-sub { font-size: .65rem; color: var(--text-dim); margin-top: .1rem; }

/* ────────────────────────────────────────────────
   Dashboard — Metabolic profile cards
   ──────────────────────────────────────────────── */
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.profile-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .85rem 1rem;
  transition: border-color .2s, box-shadow .2s;
}
.profile-card:hover { border-color: var(--border-glow); box-shadow: var(--shadow-glow); }
.profile-card-title { font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); margin-bottom: .4rem; }
.profile-card-value { font-size: 1rem; font-weight: 700; color: var(--text-primary); margin-bottom: .15rem; }
.profile-card-detail { font-size: .7rem; color: var(--text-muted); line-height: 1.4; }

/* ────────────────────────────────────────────────
   Risk pattern explorer
   ──────────────────────────────────────────────── */
.patterns-grid        { display: flex; flex-direction: column; gap: 1rem; }
.pattern-card         { display: flex; flex-direction: column; }
.pattern-card-full    { }
.pattern-card-title   { font-size: .92rem; font-weight: 700; color: var(--text-primary); margin: 0 0 .4rem; }
.pattern-table-wrap   { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.pattern-table        { width: 100%; border-collapse: collapse; font-size: .78rem; }
.pattern-table th     { text-align: left; padding: .4rem .5rem; background: var(--bg-elevated); font-weight: 700; font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); border-bottom: 1px solid var(--border); }
.pattern-table td     { padding: .45rem .5rem; border-bottom: 1px solid var(--subtle-border); vertical-align: middle; }
.pattern-table tr:last-child td { border-bottom: none; }
.pt-meal-name         { font-weight: 600; color: var(--text-primary); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pt-muted             { color: var(--text-muted); }
.spike-bar-wrap       { display: flex; align-items: center; gap: .45rem; }
.spike-bar            { height: 7px; border-radius: 4px; min-width: 4px; transition: width .3s; }
.spike-val            { font-size: .75rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; }
.pattern-empty        { font-size: .8rem; color: var(--text-muted); padding: .4rem 0; }
.pattern-disclaimer   { font-size: .68rem; color: var(--text-dim); font-style: italic; margin-top: .75rem; }

/* Intensity stats */
.intensity-stats      { display: flex; gap: .55rem; flex-wrap: wrap; }
.intensity-stat-card  { flex: 1; min-width: 85px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .65rem .75rem; text-align: center; }
.intensity-label      { font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; margin-bottom: .25rem; }
.intensity-light      { color: var(--green); }
.intensity-moderate   { color: var(--amber); }
.intensity-intense    { color: var(--cyan); }
.intensity-change     { font-size: 1.2rem; font-weight: 800; line-height: 1; }
.intensity-sublabel   { font-size: .65rem; color: var(--text-dim); margin-top: .12rem; }
.change-down          { color: var(--cyan); }
.change-up            { color: var(--amber); }

/* Carb range bars */
.carb-range-bars      { display: flex; flex-direction: column; gap: .5rem; }
.carb-range-row       { display: flex; align-items: center; gap: .55rem; }
.carb-range-label     { min-width: 48px; font-size: .75rem; font-weight: 600; color: var(--text-muted); }
.carb-bar-wrap        { flex: 1; background: var(--subtle-bg); border-radius: 4px; height: 9px; overflow: hidden; }
.carb-bar             { height: 100%; background: var(--electric); border-radius: 4px; transition: width .4s; box-shadow: 0 0 4px var(--electric-glow); }
.carb-spike-val       { min-width: 80px; font-size: .75rem; font-weight: 600; color: var(--text-primary); }

/* Time-of-day variability */
.var-insight          { display: flex; gap: .5rem; align-items: flex-start; padding: .5rem .7rem; background: var(--electric-dim); border-radius: var(--radius-sm); font-size: .8rem; color: var(--electric); }
.var-insight-icon     { flex-shrink: 0; }

/* ────────────────────────────────────────────────
   Intensity selector (event form)
   ──────────────────────────────────────────────── */
.intensity-selector   { display: flex; flex-direction: column; gap: .4rem; }
.intensity-option     { display: flex; gap: .6rem; align-items: flex-start; padding: .65rem .85rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; transition: border-color .2s, background .2s; min-height: 48px; }
.intensity-option input[type=radio] { margin-top: .25rem; flex-shrink: 0; accent-color: var(--electric); width: 18px; height: 18px; }
.intensity-option:hover, .intensity-selected { border-color: var(--electric); background: var(--electric-dim); }
.intensity-option-body  { display: flex; flex-direction: column; }
.intensity-option-title { font-weight: 700; font-size: .82rem; color: var(--text-primary); }
.intensity-option-desc  { font-size: .72rem; color: var(--text-dim); margin-top: .06rem; }

/* Tag selector (meal tags, activity tags) */
.tag-selector         { display: flex; gap: .4rem; flex-wrap: wrap; }
.tag-option           { cursor: pointer; }
.tag-option input     { display: none; }
.tag-label            { display: inline-flex; align-items: center; padding: .35rem .75rem; border-radius: 20px; border: 1.5px solid var(--border); font-size: .78rem; font-weight: 600; color: var(--text-muted); transition: all .2s; min-height: 36px; }
.tag-option input:checked + .tag-label { border-color: var(--electric); background: var(--electric-dim); color: var(--electric); }
.tag-option:hover .tag-label { border-color: rgba(56,189,248,.3); color: var(--electric); }

/* ────────────────────────────────────────────────
   Clarity Index ring (caregiver)
   ──────────────────────────────────────────────── */
.score-card    { text-align: center; min-width: unset; }
.score-label   { font-size: .65rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-dim); margin-bottom: .55rem; }
.score-ring-wrap { position: relative; display: inline-flex; align-items: center; justify-content: center; margin: 0 auto .55rem; }
.score-ring    { width: 70px; height: 70px; }
.score-center  { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.score-number  { font-size: 1.1rem; font-weight: 700; color: var(--electric); font-family: var(--font-mono); }
.score-items   { display: flex; flex-direction: column; gap: .22rem; align-items: flex-start; width: fit-content; margin: 0 auto; }
.score-item    { display: flex; gap: .3rem; align-items: center; font-size: .72rem; font-weight: 500; }
.score-item-on  { color: var(--green); }
.score-item-off { color: var(--text-dim); text-decoration: line-through; }

/* ────────────────────────────────────────────────
   Memory assistant nudge
   ──────────────────────────────────────────────── */
.memory-nudge { display: flex; gap: .55rem; align-items: center; padding: .65rem .85rem; background: var(--violet-dim); border: 1px solid rgba(167,139,250,.15); border-radius: var(--radius-sm); margin-bottom: .45rem; }
.memory-nudge-icon { font-size: 1rem; flex-shrink: 0; }

/* ────────────────────────────────────────────────
   Timeline filter bar
   ──────────────────────────────────────────────── */
.tl-filter-bar { display: flex; align-items: center; gap: .3rem; flex-wrap: nowrap; padding: .65rem 1rem; border-bottom: 1px solid var(--border); background: var(--bg-surface); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tl-filter-btn { padding: .3rem .65rem; border-radius: 20px; border: 1.5px solid var(--border); background: var(--bg-card); font-size: .75rem; font-weight: 600; cursor: pointer; color: var(--text-muted); transition: all .2s; white-space: nowrap; min-height: 36px; flex-shrink: 0; }
.tl-filter-btn:hover { border-color: var(--electric); color: var(--electric); background: var(--electric-dim); }
.tl-filter-active { border-color: var(--electric); background: var(--electric-dim); color: var(--electric); }

/* ────────────────────────────────────────────────
   Relationship drawer
   ──────────────────────────────────────────────── */
.tl-drawer-toggle { background: none; border: none; padding: .2rem; font-size: .72rem; font-weight: 600; color: var(--electric); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; margin-top: .12rem; min-height: 28px; }
.tl-drawer-toggle:hover { color: var(--cyan); }
.tl-drawer { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .6rem .8rem; margin-top: .35rem; width: 100%; }
.drawer-section-label { font-size: .65rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-dim); margin-bottom: .3rem; }
.drawer-row { display: flex; justify-content: space-between; align-items: center; padding: .2rem 0; font-size: .75rem; border-bottom: 1px solid var(--subtle-border); }
.drawer-row:last-of-type { border-bottom: none; }
.drawer-row-label { color: var(--text-dim); }
.drawer-row-val   { font-weight: 600; color: var(--text-primary); }
.drawer-change    { font-size: .72rem; font-weight: 600; padding: .22rem .5rem; border-radius: var(--radius-sm); background: var(--bg-elevated); margin-top: .3rem; display: inline-block; }
.drawer-disclaimer { font-size: .65rem; color: var(--text-dim); margin-top: .5rem; font-style: italic; }
.drawer-loading { font-size: .75rem; color: var(--text-muted); }

/* ────────────────────────────────────────────────
   Confirmation nudge buttons
   ──────────────────────────────────────────────── */
.nudge-group { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .25rem; }
.nudge-btn { display: inline-flex; align-items: center; padding: .3rem .7rem; border-radius: 20px; font-size: .72rem; font-weight: 600; cursor: pointer; border: 1.5px solid transparent; transition: all .2s; text-decoration: none; white-space: nowrap; min-height: 34px; }
.nudge-confirm  { background: var(--green-dim);    color: var(--green);   border-color: rgba(74,222,128,.2); }
.nudge-confirm:hover  { background: var(--green); color: var(--bg-deep); }
.nudge-estimate { background: var(--violet-dim);   color: var(--violet);  border-color: rgba(167,139,250,.2); }
.nudge-estimate:hover { background: var(--violet); color: var(--bg-deep); }
.nudge-edit     { background: var(--subtle-bg); color: var(--text-body); border-color: var(--border); }
.nudge-edit:hover     { background: var(--border-glow); text-decoration: none; }

/* ────────────────────────────────────────────────
   Trust mode (shared trust settings)
   ──────────────────────────────────────────────── */
.trust-banner { display: flex; align-items: center; gap: .5rem; padding: .55rem .85rem; background: var(--violet-dim); border: 1px solid rgba(167,139,250,.15); border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: .8rem; color: var(--violet); }
.trust-options { display: flex; flex-direction: column; gap: .55rem; }
.trust-option { display: flex; flex-direction: column; gap: .5rem; padding: .85rem 1rem; border: 2px solid var(--border); border-radius: var(--radius); cursor: pointer; transition: border-color .2s, background .2s; }
.trust-option input[type=radio] { flex-shrink: 0; accent-color: var(--electric); width: 18px; height: 18px; }
.trust-option:hover { border-color: var(--electric); background: var(--electric-dim); }
.trust-option-selected { border-color: var(--electric); background: var(--electric-dim); }
.trust-option-header { display: flex; align-items: flex-start; gap: .6rem; }
.trust-option-title { font-weight: 700; font-size: .88rem; color: var(--text-primary); margin-bottom: .15rem; }
.trust-option-desc  { font-size: .78rem; color: var(--text-muted); line-height: 1.45; }
.trust-option-tag { display: inline-flex; padding: .12rem .45rem; border-radius: 4px; font-size: .65rem; font-weight: 700; letter-spacing: .04em; margin-top: .35rem; }
.trust-tag-full      { background: var(--green-dim);    color: var(--green); }
.trust-tag-confirmed { background: var(--cyan-dim);     color: var(--cyan); }
.trust-tag-limited   { background: var(--amber-dim);    color: var(--amber); }
.trust-tag-private   { background: var(--violet-dim);   color: var(--violet); }

/* ────────────────────────────────────────────────
   Morning briefing
   ──────────────────────────────────────────────── */
.briefing-night-card { border-left: 4px solid var(--cyan); }
.briefing-section-label { font-size: .65rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-dim); margin-bottom: .65rem; }
.briefing-stat-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: .55rem; margin-bottom: .75rem; }
.briefing-stat { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .6rem .75rem; text-align: center; }
.briefing-stat-label { font-size: .65rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); margin-bottom: .12rem; }
.briefing-stat-value { font-size: 1.3rem; font-weight: 700; color: var(--text-primary); line-height: 1; font-family: var(--font-mono); }
.briefing-narrative  { font-size: .82rem; color: var(--text-body); padding: .5rem .75rem; background: var(--cyan-dim); border-radius: var(--radius-sm); }
.briefing-empty { font-size: .82rem; color: var(--text-muted); padding: .4rem 0; }

/* ════════════════════════════════════════════════
   TABLET (≥640px)
   ════════════════════════════════════════════════ */
@media (min-width: 640px) {
  h1 { font-size: 1.55rem; }
  h2 { font-size: 1.1rem; }
  .main-content { padding: 1.25rem 1.5rem; }
  .card { padding: 1.2rem 1.35rem; }
  .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.15rem; }
  .form-card { max-width: 680px; }
  .stats-row { grid-template-columns: repeat(4, 1fr); }
  .stat-value { font-size: 1.6rem; }
  .hide-mobile { display: block; }
  .show-mobile { display: none; }
  .upload-hub { display: grid; grid-template-columns: 1fr 1fr; }
  .chart-container { height: 280px; }
  .analysis-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
  .insight-cards-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  .review-grid { display: grid; grid-template-columns: 1fr 1.2fr; }
  .review-image-wrap { position: sticky; top: 80px; }
  .obs-info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .briefing-stat-row { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .profile-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .alert-hero-val { font-size: 2.6rem; }
  .alert-hero-inner { padding: 1.35rem 1.5rem; gap: 1.5rem; }
  .page-header { flex-direction: row; align-items: flex-start; justify-content: space-between; }
  .caregiver-top-row { display: grid; grid-template-columns: auto 1fr; gap: 1rem; align-items: start; }
  .hide-mobile table { display: table; }
  .show-mobile { display: none; }
}

/* ════════════════════════════════════════════════
   DESKTOP (≥960px)
   ════════════════════════════════════════════════ */
@media (min-width: 960px) {
  :root { --bottom-nav-h: 0px; }
  body { padding-bottom: 0; }
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.15rem; }
  .main-content { max-width: 1100px; padding: 1.75rem 1.5rem; }
  .card { padding: 1.35rem 1.5rem; }
  .chart-container { height: 340px; }
  .footer { margin-bottom: 0; }

  .navbar { padding: .65rem 1.75rem; gap: 1.5rem; }
  .nav-hamburger { display: none; }
  .nav-links {
    display: flex; align-items: center; gap: .15rem; flex: 1; flex-wrap: wrap;
  }
  .nav-links a {
    position: relative; padding: .35rem .7rem; border-radius: var(--radius-sm);
    font-size: .82rem; color: var(--text-muted); transition: color .2s, background .2s;
    letter-spacing: .01em;
  }
  .nav-links a:hover { color: var(--text-primary); background: var(--hover-bg); }
  .nav-links a.active { color: var(--electric); font-weight: 600; background: var(--electric-dim); }
  .nav-badge { display: inline-flex; align-items: center; justify-content: center; margin-left: .25rem; min-width: 17px; height: 17px; border-radius: 9px; background: var(--electric); color: var(--bg-deep); font-size: .62rem; font-weight: 700; padding: 0 4px; }
  .nav-badge-amber { background: var(--amber); }
  .bottom-nav { display: none; }

  .patterns-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); }
  .pattern-card-full { grid-column: 1 / -1; }
  .btn:hover { transform: translateY(-1px); }
  .btn:active { transform: none; }

  .upload-hub { grid-template-columns: repeat(3, 1fr); }
  .libre-status-card { flex-direction: row; align-items: flex-start; justify-content: space-between; }
}

/* ── Timeline controls ── */
.timeline-controls {
  display: flex; gap: .35rem; flex-wrap: nowrap; align-items: center;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; -ms-overflow-style: none;
}
.timeline-controls::-webkit-scrollbar { display: none; }
.timeline-btn {
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-muted);
  padding: .25rem .55rem; border-radius: var(--radius); font-size: .68rem; font-weight: 600;
  cursor: pointer; transition: all .15s ease; font-family: var(--font-mono);
  white-space: nowrap; flex-shrink: 0;
}
.timeline-btn:hover { border-color: var(--electric); color: var(--text-primary); }
.timeline-btn.active { background: var(--electric); color: #fff; border-color: var(--electric); }
.chart-reset-zoom {
  display: none; background: rgba(56,189,248,0.1); border: 1px solid rgba(56,189,248,0.3);
  color: var(--electric); padding: .2rem .5rem; border-radius: var(--radius); font-size: .65rem;
  font-weight: 600; cursor: pointer; transition: all .15s ease; margin-left: auto;
}
.chart-reset-zoom:hover { background: rgba(56,189,248,0.2); }

/* ── Event popup ── */
.event-popup {
  display: none; position: fixed; z-index: 1000;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 1.2); box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  overflow: hidden; max-height: 60vh; overflow-y: auto;
}
.event-popup-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .6rem .75rem; background: var(--bg-card);
  font-size: .72rem; font-weight: 700; color: var(--text-primary);
  border-bottom: 1px solid var(--border);
}
.event-popup-close {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: .85rem; padding: .15rem .3rem; border-radius: 4px;
}
.event-popup-close:hover { background: var(--bg-card); color: var(--text-primary); }
.event-popup-body { padding: .5rem; }
.event-popup-item {
  display: flex; gap: .5rem; padding: .5rem; border-radius: var(--radius);
  margin-bottom: .35rem;
}
.event-popup-item:last-child { margin-bottom: 0; }
.event-popup-meal { background: rgba(251,191,36,0.06); }
.event-popup-activity { background: rgba(34,211,238,0.06); }
.event-popup-insulin { background: rgba(167,139,250,0.06); }
.event-popup-icon { font-size: 1.1rem; flex-shrink: 0; }
.event-popup-info { min-width: 0; }
.event-popup-title { font-weight: 700; font-size: .78rem; color: var(--text-primary); }
.event-popup-meta { font-size: .65rem; color: var(--text-dim); margin-top: .1rem; }
.event-popup-detail { font-size: .68rem; color: var(--text-muted); margin-top: .15rem; }

/* ── Timeline full page ── */
.timeline-page-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem;
}
.timeline-page-header h1 { margin: 0; font-size: 1.2rem; }
.timeline-stats-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: .5rem; margin-bottom: .75rem;
}
.timeline-stat {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .65rem; text-align: center;
}
.timeline-stat-value { font-size: 1.3rem; font-weight: 800; color: var(--text-primary); font-family: var(--font-mono); }
.timeline-stat-label { font-size: .62rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; margin-top: .1rem; }
.timeline-chart-container { height: 350px; width: 100%; position: relative; }
@media (min-width: 640px) { .timeline-chart-container { height: 500px; } }

.theme-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border: none; background: none;
  color: var(--text-muted); font-size: 1.15rem; cursor: pointer;
  border-radius: var(--radius-sm); transition: background .15s, color .15s;
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--hover-bg); color: var(--text-primary); }
.icon-sun { display: inline; }
.icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: inline; }

.nav-panel .theme-toggle-row {
  display: flex; align-items: center; gap: .6rem;
  padding: .7rem .85rem; border-radius: var(--radius-sm);
  font-size: .92rem; color: var(--text-body); font-weight: 500;
  min-height: 44px; cursor: pointer; transition: background .15s;
  border: none; background: none; width: 100%; text-align: left;
}
.nav-panel .theme-toggle-row:hover { background: var(--hover-bg); }

[data-theme="light"] .event-popup {
  box-shadow: 0 12px 40px rgba(0,0,0,0.15);
}

[data-theme="light"] .chart-reset-zoom {
  background: rgba(37,99,235,0.08);
  border-color: rgba(37,99,235,0.25);
}
[data-theme="light"] .chart-reset-zoom:hover {
  background: rgba(37,99,235,0.15);
}

[data-theme="light"] .event-popup-meal { background: rgba(217,119,6,0.06); }
[data-theme="light"] .event-popup-activity { background: rgba(8,145,178,0.06); }
[data-theme="light"] .event-popup-insulin { background: rgba(124,58,237,0.06); }

.sync-now-floating {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.sync-now-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .78rem;
  padding: .3rem .7rem;
  border-color: var(--electric);
  color: var(--electric);
  white-space: nowrap;
}
.sync-now-btn:hover { background: rgba(56,189,248,0.1); }
.sync-icon { display: inline-block; font-size: .95rem; }
.sync-icon.spinning { animation: spin-sync .8s linear infinite; }
@keyframes spin-sync { to { transform: rotate(360deg); } }
.sync-now-status {
  font-size: .75rem;
  color: var(--text-muted);
  transition: opacity .3s;
}
.sync-now-status.sync-success { color: var(--green-soft,#34d399); }
.sync-now-status.sync-error   { color: var(--red-soft,#f87171); }

[data-theme="light"] .sync-now-btn { border-color: var(--electric); color: var(--electric); }
[data-theme="light"] .sync-now-btn:hover { background: rgba(37,99,235,0.08); }
