/* ============================================================
   VitaTrack — Bloom Design System
   ============================================================ */

:root {
  color-scheme: light;

  /* Surfaces */
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #faf8f5;
  --surface-3: #f3efe8;

  /* Text */
  --ink: #14110f;
  --ink-soft: #4a4641;
  --muted: #8a857d;

  /* Borders */
  --line: #ece8e0;
  --line-soft: #f4f0e8;

  /* Accent */
  --accent: #d96b54;
  --accent-soft: #fbe9e2;

  /* Status */
  --ok: #6a9a6e;
  --warn: #c98a3a;
  --bad: #c66060;

  /* Shadows */
  --shadow: 0 8px 32px rgba(20, 17, 15, 0.06);
  --shadow-soft: 0 1px 3px rgba(20, 17, 15, 0.06), 0 0 0 1px rgba(20, 17, 15, 0.05);

  /* Radii */
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;

  /* Fonts */
  --sans: 'Geist', system-ui, -apple-system, sans-serif;
  --mono: 'Geist Mono', ui-monospace, monospace;

  /* Domain palette */
  --c-supps:   #ff5a3c;
  --c-sleep:   #7c4ea8;
  --c-energy:  #f5b400;
  --c-workout: #3aa86b;
  --c-diet:    #9bcf3a;
  --c-breath:  #3a9bd9;
  --c-hydra:   #1f7fc9;
  --c-calm:    #e85aa8;
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

/* ── Screen-reader only ── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ============================================================
   APP SHELL
   ============================================================ */

.app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-right: 1px solid var(--line);
  background: var(--bg);
  padding: 28px 16px 24px;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  margin-bottom: 28px;
}

.brand-mark {
  display: block;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
  object-fit: contain;
}

.brand strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.brand span {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 1px;
}

/* ── Nav tabs ── */
.nav-tabs {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-tab {
  padding: 9px 12px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  letter-spacing: -0.005em;
  transition: background 0.1s, color 0.1s;
}

.nav-tab:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.nav-tab.is-active {
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 600;
}

/* ── Sidebar readiness widget ── */
.sidebar-readiness {
  margin: 16px 0;
  padding: 14px;
  background: var(--surface-2);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.sidebar-readiness-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.18em;
  font-weight: 600;
}

.sidebar-readiness-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--c-sleep);
  margin-top: 4px;
  letter-spacing: -0.04em;
  line-height: 1;
}

.sidebar-readiness-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 4px;
}

/* ── Sidebar bottom ── */
.sidebar-bottom {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.nav-install-btn {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 500;
}

.nav-install-btn:hover {
  background: var(--surface-3);
}

.install-help-text {
  font-size: 11px;
  color: var(--muted);
  margin: 6px 0 0;
  line-height: 1.4;
}

/* ── Main content ── */
.main-content {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
}

/* ── Topbar ── */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 28px 36px 0;
  gap: 16px;
  flex-shrink: 0;
}

.topbar-left {}

.topbar-date {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.18em;
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.topbar h1, #view-title {
  font-size: 38px;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  margin: 0;
  color: var(--ink);
}

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

.date-picker {
  display: flex;
  align-items: center;
}

.date-picker input {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink-soft);
  font-size: 12.5px;
  outline: none;
}

.date-picker input:focus {
  border-color: var(--accent);
}

.ghost-button {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 500;
}

.ghost-button:hover {
  background: var(--surface-2);
}

.accent-button {
  padding: 8px 14px;
  border-radius: 999px;
  border: none;
  background: var(--ink);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.accent-button:hover {
  opacity: 0.88;
}

/* ── Alert zone ── */
.alert-zone {
  padding: 0 36px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: #fff8f0;
  border: 1px solid #f0d5b0;
  font-size: 13px;
  color: var(--ink-soft);
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.alert strong {
  color: var(--warn);
  font-weight: 600;
  flex-shrink: 0;
}

/* ── View shell ── */
.view-shell {
  padding: 24px 36px 48px;
  flex: 1;
}

/* ── Bottom nav (mobile) ── */
.bottom-nav {
  display: none;
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 6px;
  background: var(--ink);
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(20, 17, 15, 0.22);
  z-index: 100;
}

.bottom-nav-item {
  padding: 9px 4px;
  border-radius: 12px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.65);
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  transition: background 0.1s, color 0.1s;
}

.bottom-nav-item.is-active {
  background: #fff;
  color: var(--ink);
}

/* ============================================================
   BLOOM COMPONENTS
   ============================================================ */

/* ── Section label ── */
.section-label {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.18em;
  font-weight: 600;
  text-transform: uppercase;
  margin: 0 0 10px;
}

/* ── Card ── */
.bloom-card {
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.bloom-card-lg {
  padding: 20px 20px 24px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
}

/* ── Flower hero card ── */
.flower-hero {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 28px;
  padding: 24px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  margin-bottom: 18px;
}

.flower-hero-meta {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.flower-tagline {
  font-size: 15px;
  color: var(--ink-soft);
  line-height: 1.4;
}

.flower-tagline strong {
  color: var(--accent);
}

/* ── Domain chips grid ── */
.domain-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

/* ── Domain chip ── */
.domain-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
}

.domain-chip-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
}

.domain-chip-sub {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 1px;
}

/* ── Stat blocks ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.stat-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat-block {
  padding: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.stat-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-weight: 600;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
  letter-spacing: -0.035em;
  margin-top: 8px;
}

.stat-value-unit {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.stat-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 6px;
}

.stat-sub.ok { color: var(--ok); }

/* ── Take rows ── */
.takes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.take-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  position: relative;
}

.take-row.is-next {
  background: var(--surface-2);
  border-color: var(--accent);
}

.take-now-badge {
  position: absolute;
  top: -8px;
  left: 12px;
  font-family: var(--mono);
  font-size: 9px;
  padding: 2px 7px;
  background: var(--accent);
  color: white;
  border-radius: 4px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.take-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.take-dot.taken { opacity: 1; }
.take-dot.pending { opacity: 0.3; }

.take-info {}

.take-time-name {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.take-time {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.04em;
}

.take-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.012em;
}

.take-detail {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

.take-done-time {
  color: var(--ok);
}

.take-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 0.1s, border-color 0.1s;
}

.take-btn.taken {
  border: none;
  color: white;
}

.take-btn.is-next {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* ── Takes section header ── */
.takes-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.takes-done-label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ok);
  letter-spacing: 0.1em;
}

/* ── Next take card ── */
.next-take-card {
  padding: 14px 16px;
  background: var(--surface-2);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
}

.next-take-time {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.12em;
}

.next-take-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

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

.next-take-btn {
  margin-left: auto;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  border: none;
  font-weight: 600;
  font-size: 12.5px;
  flex-shrink: 0;
}

/* ── Insights charts ── */
.insight-chart-card {
  padding: 18px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  margin-bottom: 12px;
}

.insight-chart-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 14px;
}

.insight-chart-title {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.18em;
  font-weight: 600;
  text-transform: uppercase;
}

.insight-chart-current {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.035em;
  margin-top: 4px;
  line-height: 1;
}

.insight-chart-avg {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
}

/* ── Finding cards ── */
.findings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.finding-card {
  padding: 14px 16px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.finding-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.finding-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.finding-badge-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.16em;
}

.finding-title {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.finding-body {
  font-size: 12.5px;
  color: var(--ink-soft);
  margin-top: 4px;
  line-height: 1.5;
}

/* ── Wearable source cards ── */
.source-cards-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.source-card {
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.source-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.source-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

.source-icon.disconnected {
  opacity: 0.25;
}

.source-name {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.source-status {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.source-status.connected { color: var(--ok); }
.source-status.disconnected { color: var(--muted); }

.source-btn {
  margin-left: auto;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.source-btn.manage {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink);
}

.source-btn.connect {
  background: var(--ink);
  border: none;
  color: white;
}

.source-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.source-metric-pill {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 11.5px;
  font-family: var(--mono);
  color: var(--ink-soft);
}

/* ── Export ── */
.export-hero {
  padding: 24px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  margin-bottom: 18px;
}

.export-hero h2 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.035em;
  margin: 8px 0 6px;
  line-height: 1.1;
}

.export-hero p {
  font-size: 14px;
  color: var(--ink-soft);
  max-width: 480px;
  line-height: 1.5;
  margin: 0;
}

.export-formats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.export-format-card {
  padding: 18px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.export-format-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: white;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 12px;
}

.export-format-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.export-format-desc {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.45;
}

.export-download-btn {
  margin-top: 14px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  border: none;
  font-size: 12px;
  font-weight: 600;
  width: 100%;
}

.export-includes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.export-include-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.export-include-dot {
  margin-top: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-workout);
  flex-shrink: 0;
}

.export-include-key {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}

.export-include-val {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* Backup / import section */
.export-textarea {
  width: 100%;
  min-height: 220px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
  resize: vertical;
  outline: none;
}

.import-box {
  width: 100%;
  min-height: 120px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
  resize: vertical;
  outline: none;
}

/* ── Wearables integration forms ── */
.integration-card {
  padding: 20px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  margin-bottom: 12px;
}

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

.integration-card h3 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}

.integration-card p {
  font-size: 12.5px;
  color: var(--muted);
  margin: 0;
  line-height: 1.4;
}

/* ── Supplement protocol cards ── */
.supplement-protocol-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.supplement-card {
  padding: 18px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

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

.supplement-card h3 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 3px;
}

.supplement-card p {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

.protocol-list {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.protocol-list li {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 8px;
  font-size: 12.5px;
}

.protocol-list li strong {
  color: var(--muted);
  font-weight: 600;
}

/* ── Form elements ── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
}

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

.field span, .field > label > span {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.field input,
.field select,
.field textarea {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 13px;
  outline: none;
  transition: border-color 0.1s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
}

.field textarea {
  resize: vertical;
  min-height: 60px;
  font-family: var(--sans);
}

.range-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.range-field .field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.range-value {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.range-field input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  padding: 0;
  border: none;
  background: none;
}

.button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.primary-button {
  padding: 8px 16px;
  border-radius: 999px;
  border: none;
  background: var(--ink);
  color: white;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.primary-button:hover { opacity: 0.88; }

.secondary-button {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
}

.secondary-button:hover { background: var(--surface-3); }

.icon-button {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 16px;
  display: grid;
  place-items: center;
}

.file-input {
  padding: 6px 8px;
  font-size: 12px;
}

/* ── Pills ── */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.pill.ok { background: #edf6ee; color: var(--ok); border-color: #c4dfc5; }
.pill.warn { background: #fef3e2; color: var(--warn); border-color: #f0d5a0; }
.pill.bad { background: #fce8e8; color: var(--bad); border-color: #f0bcbc; }

/* ── Tables ── */
.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.mini-table th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  color: var(--muted);
  padding: 0 8px 8px;
  border-bottom: 1px solid var(--line);
}

.mini-table td {
  padding: 8px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

.mini-table td select,
.mini-table td input {
  font-size: 12.5px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  outline: none;
  max-width: 100%;
}

.small-input { width: 100%; min-width: 60px; }

/* ── Empty state ── */
.empty-state {
  padding: 20px 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* ── Checkbox row ── */
.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.checkbox-row label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
}

/* ── Band / section wrappers ── */
.band {
  margin-bottom: 24px;
}

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

.band-header h2 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 3px;
}

.band-header p {
  font-size: 12.5px;
  color: var(--muted);
  margin: 0;
  line-height: 1.4;
}

/* ── Check-in form section ── */
.checkin-section {
  margin-top: 28px;
}

.checkin-section h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin: 0 0 16px;
}

/* ── Enzyme / change tables ── */
.side-section {
  margin-top: 24px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .bottom-nav {
    display: grid;
  }

  .topbar {
    padding: 20px 18px 0;
    flex-wrap: wrap;
  }

  .topbar h1, #view-title {
    font-size: 28px;
  }

  .view-shell {
    padding: 18px 18px 100px;
  }

  .alert-zone {
    padding: 0 18px;
  }

  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }

  .takes-grid {
    grid-template-columns: 1fr;
  }

  .flower-hero {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .domain-grid {
    grid-template-columns: 1fr 1fr;
  }

  .findings-grid {
    grid-template-columns: 1fr;
  }

  .export-formats {
    grid-template-columns: 1fr;
  }

  .export-includes {
    grid-template-columns: 1fr;
  }

  .supplement-protocol-grid {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }

  .stat-grid-2 {
    grid-template-columns: 1fr 1fr;
  }

  .topbar-actions {
    gap: 6px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   PLANES — sub-nav + dimension plan + files
═══════════════════════════════════════════════════════════════ */

.planes-subnav {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 0 0 14px;
  margin-bottom: 16px;
  scrollbar-width: none;
}
.planes-subnav::-webkit-scrollbar { display: none; }

.planes-subnav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color .15s, color .15s, background .15s;
}
.planes-subnav-btn:hover { background: var(--surface-2); }
.planes-subnav-btn.is-active { background: var(--surface-2); font-weight: 600; }

.planes-subnav-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.plan-notes-area {
  width: 100%;
  min-height: 200px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  resize: vertical;
  box-sizing: border-box;
  line-height: 1.65;
}
.plan-notes-area:focus { outline: none; border-color: var(--accent); }
.plan-notes-area::placeholder { color: var(--muted); }

/* Files */
.files-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 28px 20px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  margin-bottom: 14px;
}
.files-zone:hover { border-color: var(--accent); background: var(--surface-2); }

.files-zone-icon { font-size: 26px; line-height: 1; }
.files-zone-text { font-size: 13px; color: var(--muted); text-align: center; line-height: 1.5; }
.files-zone-text small { font-size: 11px; }

.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.file-item {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px;
  background: var(--surface);
  overflow: hidden;
}
.file-item-img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
  margin-bottom: 8px;
}
.file-item-icon {
  width: 100%;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border-radius: 6px;
  font-size: 26px;
  margin-bottom: 8px;
}
.file-item-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-item-meta {
  font-size: 10.5px;
  color: var(--muted);
  font-family: var(--mono);
  margin-top: 2px;
}
.file-item-del {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.92);
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
}
.file-item-del:hover { color: var(--bad); border-color: var(--bad); }

/* ═══════════════════════════════════════════════════════════════
   AGENTE — chat UI
═══════════════════════════════════════════════════════════════ */

.agent-layout {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 170px);
  min-height: 400px;
}

.agent-setup {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.agent-key-input {
  flex: 1;
  min-width: 180px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink);
  background: var(--surface);
}
.agent-key-input:focus { outline: none; border-color: var(--accent); }
.agent-key-input::placeholder { color: var(--muted); }

.agent-model-select {
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
}
.agent-model-select:focus { outline: none; border-color: var(--accent); }

.agent-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.agent-actions-row span { margin-right: auto; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: var(--surface-2);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  margin-bottom: 12px;
  scroll-behavior: smooth;
}

.chat-empty {
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.7;
  margin: auto;
  padding: 32px 16px;
}

.chat-bubble {
  max-width: 82%;
  padding: 11px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
}
.chat-bubble.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
}
.chat-bubble.agent {
  align-self: flex-start;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  border-bottom-left-radius: 4px;
}
.chat-bubble.loading {
  align-self: flex-start;
  background: var(--surface-3);
  color: var(--muted);
  font-style: italic;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:.5} 50%{opacity:1} }

.agent-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.agent-textarea {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  resize: none;
  min-height: 44px;
  max-height: 120px;
  line-height: 1.5;
  overflow-y: auto;
}
.agent-textarea:focus { outline: none; border-color: var(--accent); }
.agent-textarea::placeholder { color: var(--muted); font-size: 13px; }

.agent-send-btn {
  padding: 10px 22px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  height: 44px;
  transition: opacity .15s;
}
.agent-send-btn:hover { opacity: .88; }
.agent-send-btn:disabled { opacity: .45; cursor: default; }

/* ── Auth overlay ──────────────────────────────────────────────────────────── */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.auth-brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: block;
  object-fit: contain;
}

.auth-brand strong {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}

.auth-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 8px;
}

.auth-input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  background: var(--surface-2);
  outline: none;
  box-sizing: border-box;
  transition: border-color .15s;
}
.auth-input:focus { border-color: var(--accent); background: var(--bg); }

.auth-btn-primary {
  width: 100%;
  padding: 11px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
  margin-top: 4px;
}
.auth-btn-primary:hover { opacity: .88; }
.auth-btn-primary:disabled { opacity: .5; cursor: default; }

.auth-btn-ghost {
  width: 100%;
  padding: 9px;
  background: none;
  color: var(--ink-soft);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.auth-btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.auth-btn-ghost:disabled { opacity: .5; cursor: default; }

.auth-error {
  font-size: 12.5px;
  color: var(--bad);
  min-height: 18px;
  margin: 0;
}

/* ── Sidebar user section ──────────────────────────────────────────────────── */
.sidebar-user {
  padding: 10px 16px;
  border-top: 1px solid var(--line-soft);
  margin-top: auto;
}

.sidebar-user-email {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-logout-btn {
  width: 100%;
  padding: 6px 10px;
  background: none;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 12px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.sidebar-logout-btn:hover { color: var(--bad); border-color: var(--bad); }

/* ── Meal tracking ────────────────────────────────────────── */
.meal-slot {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.meal-slot:last-child { border-bottom: none; margin-bottom: 0; }

.meal-item-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  font-size: 13px;
}
.meal-item-row input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: #9bcf3a;
}

.meal-photo-btn {
  cursor: pointer;
  font-size: 18px;
  opacity: .55;
  transition: opacity .15s;
  line-height: 1;
  user-select: none;
}
.meal-photo-btn:hover { opacity: 1; }

.meal-photo-result {
  background: var(--surface-3);
  border-radius: 8px;
  padding: 8px 10px;
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.5;
  position: relative;
}
.meal-photo-clear {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}
.meal-photo-clear:hover { color: var(--bad); }

/* ── Insights range selector ─────────────────────────────────── */
.insights-range-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.range-pill {
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
}
.range-pill:hover { border-color: var(--accent); color: var(--accent); }
.range-pill.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
