:root {
  --bg: #f4f7f9;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #526074;
  --primary: #0f766e;
  --primary-hover: #0d5f59;
  --primary-soft: rgba(15, 118, 110, 0.11);
  --success: #059669;
  --success-soft: rgba(5, 150, 105, 0.12);
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.14);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.12);
  --info: #0284c7;
  --info-soft: rgba(2, 132, 199, 0.12);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-w: 248px;
  --bottom-nav-h: 66px;
}

[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #131c31;
  --surface-2: #1c2740;
  --border: #253352;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #14b8a6;
  --primary-hover: #0d9488;
  --primary-soft: rgba(20, 184, 166, 0.16);
  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.16);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.16);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.16);
  --info: #38bdf8;
  --info-soft: rgba(56, 189, 248, 0.16);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.45);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

h1, h2, h3, p {
  margin: 0;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

/* ---------- Layout Shell ---------- */
.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.sidebar {
  display: none;
}

.mobile-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.brand-compact {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
}

.brand-icon-sm {
  width: 28px;
  height: 28px;
  border-radius: 7px;
}

.mobile-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-main {
  flex: 1;
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
  padding: 18px 16px calc(var(--bottom-nav-h) + 28px);
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.bottom-item {
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 2px;
}

.bottom-item svg {
  width: 21px;
  height: 21px;
}

.bottom-item.active {
  color: var(--primary);
}

@media (min-width: 900px) {
  .app-shell {
    flex-direction: row;
  }

  .mobile-header, .bottom-nav {
    display: none;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    z-index: 30;
  }

  .brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 4px 8px 22px;
  }

  .brand-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }

  .brand-name {
    display: block;
    font-weight: 800;
    font-size: 17px;
    letter-spacing: -0.02em;
  }

  .brand-sub {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
  }

  .sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
  }

  .nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, color 0.15s;
  }

  .nav-item svg {
    width: 19px;
    height: 19px;
    flex-shrink: 0;
  }

  .nav-item:hover {
    background: var(--surface-2);
    color: var(--text);
  }

  .nav-item.active {
    background: var(--primary-soft);
    color: var(--primary);
  }

  .sidebar-footer {
    padding-top: 14px;
    border-top: 1px solid var(--border);
  }

  .app-main {
    margin-left: var(--sidebar-w);
    padding: 28px 32px 48px;
  }
}

/* ---------- Common Components ---------- */
.view-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}

.view-header h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 2px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
}

.card-sub, .muted-sm {
  font-size: 13px;
  color: var(--text-muted);
}

.muted {
  color: var(--text-muted);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 15px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s, background 0.15s, border-color 0.15s;
  min-height: 40px;
}

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

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 13px;
  min-height: 34px;
}

.btn-xs {
  padding: 4px 10px;
  font-size: 12px;
  min-height: 28px;
}

.btn-lg {
  width: 100%;
  padding: 12px 18px;
  font-size: 15px;
  min-height: 46px;
}

.btn-icon, .btn-icon-box {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.btn-icon-box {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.btn-icon:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-icon.danger:hover, .danger-text {
  color: var(--danger);
}

.text-warning {
  color: var(--warning);
}

.btn-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sync-pill {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sync-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
}

.sync-pill.status-synced::before { background: var(--success); }
.sync-pill.status-synced { color: var(--success); border-color: var(--success-soft); background: var(--success-soft); }
.sync-pill.status-syncing::before { background: var(--info); }
.sync-pill.status-error::before { background: var(--danger); }
.sync-pill.status-error { color: var(--danger); }

.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.pill-success { background: var(--success-soft); color: var(--success); }
.pill-warning { background: var(--warning-soft); color: var(--warning); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-info { background: var(--info-soft); color: var(--info); }
.pill-muted { background: var(--surface-2); color: var(--text-muted); }

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}

.alert-warning {
  background: var(--warning-soft);
  color: var(--warning);
  border: 1px solid rgba(217, 119, 6, 0.28);
}

.color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

.color-dot.lg {
  width: 14px;
  height: 14px;
}

/* ---------- Forms ---------- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.input:focus {
  border-color: var(--primary);
}

.input-sm {
  padding: 6px 10px;
  font-size: 13px;
  width: auto;
}

.form-row-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 560px) {
  .form-row-2, .form-row-3 {
    grid-template-columns: 1fr;
  }
}

.chip {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.chip-lg {
  padding: 7px 14px;
  font-size: 13px;
}

.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.preset-chips, .symptom-chips, .filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-pills {
  margin-bottom: 16px;
}

.segmented-sm {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 2px;
}

.seg-btn {
  border: none;
  background: transparent;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  border-radius: 7px;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* ---------- Today View ---------- */
.date-stepper {
  display: flex;
  align-items: center;
  gap: 6px;
}

.welcome-card {
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--primary-soft), var(--surface));
  border-color: var(--primary);
}

.welcome-card p {
  color: var(--text-muted);
  font-size: 14px;
  margin: 6px 0 14px;
}

.today-summary-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: 20px;
}

@media (min-width: 720px) {
  .today-summary-grid {
    grid-template-columns: 1.4fr 1fr;
  }
}

.progress-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.progress-count {
  font-size: 15px;
  margin-top: 2px;
}

.progress-pct {
  font-size: 24px;
  font-weight: 800;
  color: var(--primary);
}

.progress-bar {
  width: 100%;
  height: 9px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.progress-fill.low {
  background: var(--warning);
}

.today-quick-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.schedule-section {
  margin-bottom: 20px;
}

.section-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.checklist-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dose-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent-stripe, var(--primary));
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.dose-card.logged {
  opacity: 0.85;
  background: var(--surface-2);
}

.dose-card.skipped {
  opacity: 0.72;
}

.dose-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dose-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 5px;
  font-size: 13px;
}

.dose-amount-badge {
  font-weight: 700;
}

.unit-pill {
  background: var(--primary-soft);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 12px;
}

.dose-sub, .dose-note {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.dose-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-take {
  min-width: 72px;
}

@media (max-width: 520px) {
  .dose-card {
    flex-direction: column;
    align-items: stretch;
  }
  .dose-card-actions {
    justify-content: flex-end;
    padding-top: 8px;
    border-top: 1px solid var(--border);
  }
}

/* ---------- Calculator View ---------- */
.calc-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

@media (min-width: 920px) {
  .calc-layout {
    grid-template-columns: 1fr 1.15fr;
    align-items: start;
  }
}

.syringe-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.syringe-opt {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.syringe-opt span {
  font-size: 12px;
  color: var(--text-muted);
}

.syringe-opt.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.calc-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--primary-soft);
  border: 1px solid rgba(15, 118, 110, 0.24);
  border-radius: var(--radius);
  padding: 18px;
  margin: 12px 0 16px;
}

.calc-hero.has-warning {
  background: var(--warning-soft);
  border-color: rgba(217, 119, 6, 0.35);
}

.calc-hero-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
}

.calc-hero-value {
  font-size: 36px;
  font-weight: 800;
  line-height: 1.1;
  margin: 4px 0;
}

.calc-hero-value small {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-muted);
}

.calc-hero-sub {
  font-size: 13px;
  color: var(--text-muted);
}

.calc-hero-badge {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  text-align: center;
  min-width: 96px;
}

.calc-hero-badge span {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

.calc-hero-badge strong {
  font-size: 22px;
  font-weight: 800;
}

.syringe-visual-wrap {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 12px 10px;
  margin-bottom: 16px;
}

.syringe-svg {
  width: 100%;
  height: auto;
  display: block;
}

.syringe-caption {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

.calc-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.metric-tile {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.metric-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

.metric-value {
  font-size: 15px;
  font-weight: 700;
}

.helper-note {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 12px;
}

/* ---------- Vials & Protocols Grid ---------- */
.vials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}

.vial-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.vial-head h3 {
  font-size: 16px;
  font-weight: 700;
}

.proto-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.vial-expired { border-color: var(--danger); }
.vial-warning { border-color: var(--warning); }
.protocol-paused { opacity: 0.72; }

.vial-fill-section {
  margin-bottom: 12px;
}

.vial-fill-labels {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 5px;
}

.vial-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 12px;
}

.vial-meta-grid span {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
}

.vial-notes {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.vial-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* ---------- Notes / Check-ins ---------- */
.notes-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

@media (min-width: 920px) {
  .notes-layout {
    grid-template-columns: 1.05fr 1fr;
    align-items: start;
  }
}

.ratings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.rating-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface-2);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.rating-row label {
  font-size: 13px;
  font-weight: 600;
}

.rating-pills {
  display: flex;
  gap: 5px;
}

.rate-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

.rate-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.inline-add-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.inline-add-row .input {
  flex: 1;
}

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

.biomarker-row {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 0.7fr auto;
  gap: 6px;
  align-items: center;
}

.biomarker-row .input {
  width: 100%;
}

.journal-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.journal-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--surface-2);
}

.journal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.journal-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.journal-metrics, .journal-tags, .journal-biomarkers {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
}

.tag-good { background: var(--success-soft); color: var(--success); }
.tag-warn { background: var(--warning-soft); color: var(--warning); }

.bm-chip {
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 8px;
}

.journal-note {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ---------- Analytics View ---------- */
.analytics-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.empty-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  border-color: var(--primary);
  background: var(--primary-soft);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.kpi-value small {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.charts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 18px;
}

@media (min-width: 980px) {
  .charts-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.chart-canvas-wrap {
  position: relative;
  height: 270px;
  width: 100%;
}

/* Heatmap */
.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 12px;
}

.hm-cell {
  aspect-ratio: 1;
  border-radius: 4px;
  cursor: default;
}

.hm-full { background: var(--success); }
.hm-partial { background: var(--warning); }
.hm-missed { background: var(--danger-soft); border: 1px solid rgba(220, 38, 38, 0.35); }
.hm-today { background: var(--info-soft); border: 1px solid var(--info); }
.hm-rest { background: var(--surface-2); }

.heatmap-legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.legend-items {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.hm-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 4px;
  vertical-align: middle;
}

/* Cycle Timeline Gantt */
.gantt-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gantt-axis {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.gantt-today-tag {
  color: var(--primary);
  font-weight: 700;
}

.gantt-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.gantt-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.gantt-label small {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
}

.gantt-track {
  position: relative;
  height: 26px;
  background: var(--surface-2);
  border-radius: 7px;
  overflow: hidden;
}

.gantt-bar {
  position: absolute;
  top: 2px;
  bottom: 2px;
  border-radius: 5px;
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  padding: 0 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gantt-bar.paused {
  opacity: 0.45;
}

.gantt-today-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--text);
  opacity: 0.65;
}

/* Export & Table */
.export-card {
  margin-bottom: 18px;
}

.export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.table-head-row {
  flex-wrap: wrap;
}

.search-input {
  min-width: 220px;
}

.table-scroll {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th, .data-table td {
  padding: 10px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.data-table td.notes-col {
  white-space: normal;
  max-width: 240px;
  color: var(--text-muted);
}

.empty-cell, .empty-inline, .empty-inline-card {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 24px 16px;
}

/* ---------- Settings ---------- */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 900px) {
  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
}

.sync-status-box {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.sync-status-box.status-synced {
  background: var(--success-soft);
  border-color: rgba(5, 150, 105, 0.3);
}

.config-details {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.config-details summary {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
}

.install-steps {
  margin: 10px 0 0;
  padding-left: 20px;
  font-size: 14px;
  color: var(--text-muted);
}

.install-steps li {
  margin-bottom: 6px;
}

/* ---------- Protocol Pickers ---------- */
.weekday-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.weekday-pill {
  position: relative;
  cursor: pointer;
}

.weekday-pill input {
  position: absolute;
  opacity: 0;
}

.weekday-pill span {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 700;
}

.weekday-pill input:checked + span {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 4px;
}

.swatch-opt {
  position: relative;
  cursor: pointer;
}

.swatch-opt input {
  position: absolute;
  opacity: 0;
}

.swatch-opt span {
  display: block;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
}

.swatch-opt input:checked + span {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text);
}

/* ---------- Modals & Toasts ---------- */
.modal-root {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
}

.modal-root.open {
  display: block;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(3px);
}

.modal-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 17px;
  font-weight: 700;
}

.modal-body {
  padding: 16px 18px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.toast-stack {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + 14px);
  right: 16px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

@media (min-width: 900px) {
  .toast-stack {
    bottom: 22px;
    right: 24px;
  }
}

.toast {
  background: var(--text);
  color: var(--bg);
  padding: 10px 15px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success { background: var(--success); color: #ffffff; }
.toast-warning { background: var(--warning); color: #ffffff; }
.toast-danger { background: var(--danger); color: #ffffff; }

/* ---------- Profile Switcher & SimplePeptide Import Summary ---------- */
.profile-switcher-wrap {
  padding: 0 2px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.profile-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.profile-seg {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.profile-seg .seg-btn {
  padding: 6px 4px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-select-sm {
  appearance: auto;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.import-mode-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.import-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.import-stats-grid > div {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.import-stats-grid span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 700;
}

.import-stats-grid strong {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
}

.import-stats-grid small {
  font-size: 11px;
  color: var(--text-muted);
}

.pinned-profile-badge {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  text-align: center;
}

.partner-glance-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 18px;
  background: var(--surface-2);
  border-left: 4px solid var(--primary);
}

.partner-glance-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 3px;
  font-size: 14px;
}

@media (max-width: 560px) {
  .partner-glance-card {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ---------- Google OAuth & Household Sharing ---------- */
.btn-google {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong, var(--border));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 600;
  padding: 11px 16px;
  box-shadow: var(--shadow-sm);
}

.btn-google:hover {
  background: var(--surface-2);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  color: var(--text-muted);
  font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.household-box {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.household-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.household-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
