/* ============================================
   GLP-1 Tracker — Letisztult, "Longevity" design
   ============================================ */

:root {
  /* Brand */
  --primary:        #0f7d6a;
  --primary-dark:   #0a5a4d;
  --primary-soft:   #e6f3f0;
  --accent:         #4759f5;
  --accent-soft:    #eef0ff;

  /* Surface */
  --bg:             #f4f5f7;
  --surface:        #ffffff;
  --surface-2:      #fafbfc;
  --border:         #ececef;
  --border-strong:  #d8dadf;

  /* Text */
  --text:           #0e1320;
  --text-muted:     #6b7280;
  --text-light:     #9ca3af;

  /* Semantic */
  --success:        #10b981;
  --success-soft:   #d7f5e8;
  --warning:        #f59e0b;
  --warning-soft:   #fef3c7;
  --danger:         #ef4444;
  --danger-soft:    #fee2e2;
  --info:           #3b82f6;
  --info-soft:      #dbeafe;
  --muscle:         #14b8a6;
  --fat:            #a78bfa;

  --shadow-xs:      0 1px 1px rgba(15,20,32,0.03);
  --shadow-sm:      0 1px 3px rgba(15,20,32,0.04);
  --shadow:         0 4px 14px rgba(15,20,32,0.06);
  --shadow-lg:      0 12px 32px rgba(15,20,32,0.08);

  --radius-sm:      10px;
  --radius:         18px;
  --radius-lg:      24px;
  --radius-xl:      32px;
  --radius-pill:    999px;

  --topbar-h:       60px;
  --bottom-nav-h:   72px;
  --safe-bottom:    env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  letter-spacing: -0.005em;
}

a { color: var(--text); text-decoration: none; }
a:hover { color: var(--primary); }

h1, h2, h3, h4 { margin: 0 0 12px; line-height: 1.2; letter-spacing: -0.02em; }
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem;    font-weight: 600; }
p  { margin: 0 0 12px; }

/* ===== Topbar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  background: var(--bg);
  backdrop-filter: blur(10px);
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: 100%;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 0.95rem;
}
.brand-text { display: none; }
@media (min-width: 480px) { .brand-text { display: inline; } }

.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e3a8a, #0e1320);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-page-title {
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.icon-btn {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: background 0.15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.lang-switch {
  display: flex;
  gap: 2px;
  background: var(--surface);
  border-radius: var(--radius-pill);
  padding: 3px;
  box-shadow: var(--shadow-sm);
}
.lang-switch a {
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius-pill);
}
.lang-switch a.active {
  background: var(--text);
  color: white;
}

/* ===== Main layout ===== */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 16px;
  padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 16px);
  min-height: calc(100vh - var(--topbar-h));
}
.main-guest {
  padding: 24px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

/* Page heading row */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0 16px;
}
.page-head h1 { margin: 0; font-size: 1.6rem; }

/* ===== Status chips row ===== */
.status-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 8px 0 16px;
  padding-bottom: 4px;
  scroll-snap-type: x mandatory;
}
.status-row::-webkit-scrollbar { display: none; }
.status-chip {
  flex: 0 0 auto;
  scroll-snap-align: start;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-width: 150px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-xs);
  color: var(--text);
  border: 1.5px solid transparent;
}
.status-chip .chip-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2);
  flex-shrink: 0;
}
.status-chip.success { border-color: rgba(16,185,129,0.25); }
.status-chip.success .chip-icon { background: var(--success-soft); color: var(--success); }
.status-chip.warning { border-color: rgba(245,158,11,0.3); }
.status-chip.warning .chip-icon { background: var(--warning-soft); color: var(--warning); }
.status-chip.danger  { border-color: rgba(239,68,68,0.3); }
.status-chip.danger  .chip-icon { background: var(--danger-soft); color: var(--danger); }
.status-chip.muted   { color: var(--text-muted); }
.status-chip.muted .chip-icon { background: var(--border); color: var(--text-muted); }

.chip-label { font-size: 0.7rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.chip-value { font-size: 0.9rem; font-weight: 700; line-height: 1.2; margin-top: 2px; }

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-xs);
}
.card-lg { padding: 24px; }
.card-flat { box-shadow: none; border: 1px solid var(--border); }

/* Hero (gradient header card) — colored stat */
.card-hero {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card-hero h2 { color: white; margin-bottom: 4px; font-size: 1.25rem; }
.card-hero .subtitle { color: rgba(255,255,255,0.85); font-size: 0.85rem; margin: 0; }
.card-hero .badge { background: rgba(255,255,255,0.22); color: white; }
.card-hero .progress { background: rgba(255,255,255,0.25); }
.card-hero .progress-fill { background: white; }
.card-hero .progress-row { color: rgba(255,255,255,0.9); }
.card-hero .progress-row strong { color: white; }

.card-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
}
.card-title h2 {
  font-size: 1rem;
  margin: 0;
  font-weight: 700;
  color: var(--text);
}
.card-title-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.card-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* Big number stat */
.kpi {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
  letter-spacing: -0.025em;
}
.kpi-value {
  font-size: 2.6rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.kpi-unit {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-muted);
}
.kpi-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 600;
}
.kpi-meta.positive { background: var(--success-soft); color: var(--success); }
.kpi-meta.negative { background: var(--danger-soft); color: var(--danger); }
.kpi-meta.muted    { background: var(--border); color: var(--text-muted); }
.kpi-since { font-size: 0.78rem; color: var(--text-muted); margin-left: 4px; }

/* ===== Stat tiles ===== */
.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.stat {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-xs);
}
.stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.stat-value {
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  letter-spacing: -0.02em;
}
.stat-value small { font-size: 0.85rem; font-weight: 500; color: var(--text-muted); }
.stat-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  margin-top: 8px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--border);
  color: var(--text-muted);
}
.stat-delta.positive { background: var(--success-soft); color: var(--success); }
.stat-delta.negative { background: var(--danger-soft); color: var(--danger); }

/* ===== Progress bar ===== */
.progress {
  height: 8px;
  background: var(--border);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin: 12px 0;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius-pill);
  transition: width 0.6s ease;
}
.progress-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.progress-row strong { color: var(--text); }

/* ===== Two-bar (muscle / fat) ===== */
.dual-bar {
  display: flex;
  height: 10px;
  border-radius: var(--radius-pill);
  overflow: hidden;
  gap: 2px;
  margin-top: 8px;
  background: var(--border);
}
.dual-bar > span {
  display: block;
  height: 100%;
}
.dual-bar .seg-muscle { background: var(--muscle); }
.dual-bar .seg-fat    { background: var(--fat); }
.dual-bar .seg-rest   { background: var(--border-strong); flex: 1; }

.dual-legend {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  margin-bottom: 4px;
}
.dual-legend .muscle { color: var(--muscle); font-weight: 700; }
.dual-legend .fat    { color: var(--fat); font-weight: 700; }

/* ===== Range slider visual ===== */
.range-vis {
  height: 8px;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, #d7f5e8, #fef3c7, #fee2e2);
  position: relative;
  margin: 18px 0 12px;
}
.range-vis .dot {
  position: absolute;
  width: 16px; height: 16px;
  border-radius: 50%;
  top: -4px;
  transform: translateX(-50%);
  background: var(--surface);
  border: 3px solid var(--text);
  box-shadow: var(--shadow-sm);
}
.range-vis-labels {
  display: flex; justify-content: space-between;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

/* ===== Forms ===== */
.form-row { margin-bottom: 14px; }
label {
  display: block;
  font-weight: 600;
  font-size: 0.82rem;
  margin-bottom: 6px;
  color: var(--text);
}
.input, input[type=text], input[type=email], input[type=password],
input[type=number], input[type=date], input[type=tel], input[type=datetime-local],
input[type=search], textarea, select {
  width: 100%;
  padding: 13px 14px;
  font-size: 0.95rem;
  font-family: inherit;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
textarea { resize: vertical; min-height: 90px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 13px 20px;
  border: none;
  border-radius: var(--radius-pill);
  font-size: 0.92rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: var(--text);
  color: white;
  text-decoration: none;
  transition: background 0.15s, transform 0.05s, box-shadow 0.15s;
}
.btn:hover { background: var(--primary-dark); color: white; }
.btn:active { transform: scale(0.97); }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: var(--accent-soft); color: var(--accent); }
.btn-ghost:hover { background: var(--accent-soft); color: var(--accent); }
.btn-sm { padding: 8px 14px; font-size: 0.82rem; }
.btn-xs { padding: 5px 10px; font-size: 0.75rem; }

/* ===== Flash ===== */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 0.9rem;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  border-left: 4px solid;
}
.flash-success { border-color: var(--success); }
.flash-error   { border-color: var(--danger); }
.flash-info    { border-color: var(--info); }
.flash-warning { border-color: var(--warning); }

/* ===== Chart ===== */
.chart-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-xs);
}
.chart-wrap {
  position: relative;
  height: 220px;
  margin-top: 8px;
}
.range-tabs {
  display: inline-flex;
  gap: 0;
  background: var(--bg);
  border-radius: var(--radius-pill);
  padding: 4px;
  margin-bottom: 12px;
}
.range-tabs button {
  background: transparent;
  border: none;
  padding: 8px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-muted);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.range-tabs button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ===== Tip / article cards ===== */
.tip-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-xs);
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.tip-icon {
  width: 40px; height: 40px;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 20px;
}
.tip-body { flex: 1; min-width: 0; }
.tip-title { font-weight: 700; margin-bottom: 4px; color: var(--text); font-size: 0.95rem; }
.tip-body p { font-size: 0.85rem; color: var(--text-muted); margin: 0; line-height: 1.45; }

.article-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-xs);
  text-decoration: none;
  color: inherit;
  display: block;
}
.article-card h3 { margin: 8px 0 6px; color: var(--text); font-size: 1.05rem; }
.article-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.article-excerpt { color: var(--text-muted); font-size: 0.88rem; margin: 6px 0 0; line-height: 1.5; }
.article-content {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px 22px;
  box-shadow: var(--shadow-xs);
}
.article-content h2 {
  font-size: 1.15rem;
  margin: 22px 0 10px;
  color: var(--text);
}
.article-content p, .article-content li { color: var(--text); line-height: 1.6; }

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--border);
  color: var(--text-muted);
}
.badge.primary { background: var(--primary-soft); color: var(--primary); }
.badge.accent  { background: var(--accent-soft);  color: var(--accent); }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger  { background: var(--danger-soft);  color: var(--danger); }
.badge.mounjaro { background: rgba(249,115,22,0.12); color: #c2410c; }
.badge.wegovy   { background: var(--info-soft);    color: #1d4ed8; }

/* ===== Messages ===== */
.thread-list { display: flex; flex-direction: column; gap: 8px; }
.thread-item {
  background: var(--surface);
  padding: 14px 16px;
  border-radius: var(--radius);
  display: flex;
  gap: 12px;
  align-items: flex-start;
  box-shadow: var(--shadow-xs);
  text-decoration: none;
  color: inherit;
}
.thread-item.unread { background: var(--primary-soft); }
.thread-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}
.thread-body { flex: 1; min-width: 0; }
.thread-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}
.thread-from { font-weight: 700; color: var(--text); }
.thread-time { font-size: 0.72rem; color: var(--text-muted); flex-shrink: 0; }
.thread-subject { font-size: 0.85rem; color: var(--text); margin-bottom: 2px; }
.thread-preview {
  font-size: 0.85rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ===== Auth shell ===== */
.auth-shell {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 36px 30px 30px;
  box-shadow: var(--shadow-lg);
}
.auth-shell .brand {
  color: var(--text);
  font-size: 1.3rem;
  justify-content: center;
  margin-bottom: 4px;
}
.auth-shell .brand-mark {
  background: var(--primary);
  color: white;
  width: 40px; height: 40px;
  font-size: 22px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
}
.auth-tagline {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 26px;
  font-size: 0.85rem;
}
.auth-shell h1 {
  text-align: center;
  margin-bottom: 22px;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
}

/* ===== Patient row (doctor view) ===== */
.patient-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: 8px;
  box-shadow: var(--shadow-xs);
  color: var(--text);
  text-decoration: none;
}
.patient-row:hover { background: var(--surface-2); color: var(--text); }
.patient-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.patient-name { font-weight: 700; }
.patient-meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.patient-stat {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--success);
  text-align: right;
}

/* ===== Tables ===== */
.table {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
}
.table th, .table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.table th {
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.7rem;
}
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }

/* ===== Withings card ===== */
.withings-card {
  background: linear-gradient(135deg, #00a4d6, #0080a8);
  color: white;
  padding: 20px;
  border-radius: var(--radius-lg);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.withings-card h3 { color: white; margin: 0 0 4px; font-size: 1rem; }
.withings-card p  { color: rgba(255,255,255,0.85); margin: 0 0 12px; font-size: 0.82rem; }
.withings-card .btn { background: white; color: #0080a8; }
.withings-card .btn:hover { background: rgba(255,255,255,0.92); color: #0080a8; }

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
}
.empty-state-icon {
  font-size: 42px;
  margin-bottom: 8px;
  opacity: 0.4;
}

/* ===== Bottom nav (mobil chip stílus) ===== */
.bottom-nav {
  position: fixed;
  bottom: calc(16px + var(--safe-bottom));
  left: 16px;
  right: 16px;
  z-index: 30;
  background: var(--surface);
  border-radius: var(--radius-pill);
  display: flex;
  padding: 6px;
  box-shadow: var(--shadow-lg);
  max-width: 540px;
  margin: 0 auto;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 600;
  position: relative;
  border-radius: var(--radius-pill);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  min-width: 0;
}
.nav-item .nav-icon { display: flex; }
.nav-item.active {
  background: var(--text);
  color: white;
  padding: 8px 14px;
  flex: 0 0 auto;
}
.nav-item.active .nav-icon { color: white; }
.nav-item:not(.active) .nav-label { display: none; }
.nav-item.active .nav-label { display: inline; font-size: 0.7rem; margin-left: 4px; }
.nav-item.active { flex-direction: row; gap: 6px; align-items: center; }
.nav-badge {
  position: absolute;
  top: 4px;
  right: 50%;
  margin-right: -16px;
  background: var(--danger);
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--surface);
}

/* ===== Injection reminder banner ===== */
.injection-reminder {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 0.92rem;
  text-decoration: none;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xs);
  border: 1.5px solid transparent;
}
.injection-reminder.overdue { border-color: rgba(239,68,68,0.4); }
.injection-reminder.overdue .rem-icon { background: var(--danger-soft); color: var(--danger); }
.injection-reminder.due     { border-color: rgba(245,158,11,0.4); }
.injection-reminder.due     .rem-icon { background: var(--warning-soft); color: var(--warning); }
.injection-reminder.ok      { border-color: rgba(16,185,129,0.3); }
.injection-reminder.ok      .rem-icon { background: var(--success-soft); color: var(--success); }
.rem-icon {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.injection-reminder strong { display: block; margin-bottom: 1px; }

/* ===== Injection: dose chips ===== */
.dose-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.dose-chip {
  background: var(--bg);
  border: 1.5px solid transparent;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--text);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.dose-chip:hover { background: var(--border); }
.dose-chip.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-dark);
}

/* ===== Injection: 6-cell site grid ===== */
.site-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
@media (max-width: 480px) {
  .site-grid { grid-template-columns: repeat(2, 1fr); }
}
.site-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 8px;
  background: var(--bg);
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  position: relative;
}
.site-card:hover { background: var(--border); }
.site-card:active { transform: scale(0.98); }
.site-card.selected {
  background: var(--primary-soft);
  border-color: var(--primary);
}
.site-card.selected .site-name { color: var(--primary-dark); }
.site-card.selected .site-icon { background: var(--primary); color: white; }

.site-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.site-icon::before {
  content: '';
  width: 18px; height: 18px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}
.site-icon[data-icon="belly"]::before { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M12 2a4 4 0 0 0-4 4v3a4 4 0 0 0 8 0V6a4 4 0 0 0-4-4z'/><circle cx='12' cy='15' r='6'/></svg>"); }
.site-icon[data-icon="thigh"]::before { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M9 3v8l-2 10h4l2-10V3M15 3v6'/></svg>"); }
.site-icon[data-icon="arm"]::before   { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M6 3v6a4 4 0 0 0 4 4l3 8M14 3v3'/></svg>"); }
.site-icon[data-icon] { color: currentColor; }
/* Force currentColor for the inline svg */
.site-icon { color: var(--text-muted); }
.site-card.selected .site-icon { color: white; }

.site-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}
.site-count {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ===== Rotation usage list ===== */
.rotation-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.rot-row {
  display: grid;
  grid-template-columns: 100px 1fr 28px;
  align-items: center;
  gap: 12px;
}
.rot-label { font-size: 0.85rem; color: var(--text); font-weight: 500; }
.rot-bar {
  height: 8px;
  background: var(--bg);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.rot-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-soft), var(--primary));
  border-radius: var(--radius-pill);
  transition: width 0.6s ease;
}
.rot-value {
  font-size: 0.85rem;
  font-weight: 700;
  text-align: right;
  color: var(--text);
}

/* ===== Helpers ===== */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-sm     { font-size: 0.85rem; }
.text-xs     { font-size: 0.75rem; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.section-head h2 { margin: 0; font-size: 1.05rem; }
.section-head a { font-size: 0.82rem; color: var(--text-muted); font-weight: 500; }

/* ===== Responsive ===== */
@media (min-width: 768px) {
  .main { padding: 12px 24px; padding-bottom: calc(var(--bottom-nav-h) + 24px); }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .chart-wrap { height: 280px; }
  h1 { font-size: 2rem; }
  h2 { font-size: 1.25rem; }
  .kpi-value { font-size: 3rem; }
  .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .grid-2-tall { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
}

@media (min-width: 1024px) {
  .nav-item:not(.active) .nav-label { display: inline; font-size: 0.78rem; margin-left: 6px; }
  .nav-item:not(.active) { flex-direction: row; gap: 6px; }
  .bottom-nav { max-width: 680px; }
}

@media (max-width: 360px) {
  h1 { font-size: 1.35rem; }
  .kpi-value { font-size: 2.2rem; }
}
