:root {
  --bg: #0f1117;
  --bg-elevated: #161a24;
  --bg-card: #181d29;
  --bg-input: #111520;
  --bg-pill: #202636;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #818cf8;
  --accent-soft: rgba(129, 140, 248, 0.16);
  --rose: #f43f5e;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --radius-card: 20px;
  --radius-btn: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-height: 68px;
}

[data-theme='light'] {
  --bg: #f6f5f1;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #f1f3f7;
  --bg-pill: #eef0f5;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.16);
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --accent: #4f46e5;
  --accent-soft: rgba(79, 70, 229, 0.1);
  --shadow: 0 6px 20px rgba(15, 23, 42, 0.06);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  min-height: 100dvh;
}

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

button {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

.app-shell {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 18px);
}

/* Header */
.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: block;
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

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

.save-indicator {
  font-size: 12px;
  font-weight: 600;
  color: #22c55e;
  background: rgba(34, 197, 94, 0.14);
  padding: 4px 10px;
  border-radius: 999px;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.save-indicator.visible {
  opacity: 1;
  transform: translateY(0);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--bg-pill);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: transform 0.12s ease, background 0.15s ease;
}

.icon-btn:active {
  transform: scale(0.94);
}

.install-pill {
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.install-pill.hidden {
  display: none;
}

/* Demo banner */
.demo-banner {
  margin: 4px 16px 8px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.35);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
}

.demo-banner.hidden {
  display: none;
}

.demo-banner strong {
  color: #fbbf24;
}

[data-theme='light'] .demo-banner strong {
  color: #b45309;
}

.demo-clear-btn {
  padding: 5px 10px;
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.22);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

/* Main Views */
.view {
  display: none;
  padding: 4px 16px 12px;
  animation: fadeIn 0.18s ease;
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Date Navigation & 7-Day Strip */
.date-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

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

.date-eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.date-quick-pills {
  display: flex;
  align-items: center;
  gap: 5px;
}

.date-pill {
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--bg-pill);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.date-pill.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.date-pill-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  overflow: hidden;
}

.date-picker-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

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

.date-span-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.date-arrow {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--bg-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text);
  transition: transform 0.12s ease, opacity 0.15s ease;
}

.date-arrow:active {
  transform: scale(0.92);
}

.date-arrow:disabled {
  opacity: 0.3;
  cursor: default;
}

.date-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
}

.date-label-btn {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  padding: 6px 10px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.date-label-btn:active {
  background: var(--bg-pill);
}

.date-picker-hidden {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.today-jump {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

.week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}

.week-day-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 7px 2px 6px;
  border-radius: 12px;
  background: transparent;
  border: 1.5px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.week-day-btn:active {
  transform: scale(0.94);
}

.week-day-btn.is-selected {
  background: var(--bg-pill);
  border-color: var(--accent);
}

.week-dow {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.week-num {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.week-dots {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 8px;
}

.week-sweat-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--border-strong);
}

.week-cycle-dot {
  width: 5px;
  height: 5px;
  border-radius: 999px;
}

/* Question Cards */
.q-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 15px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

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

.q-title {
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 7px;
}

.q-subtitle {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.q-badge {
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--bg-pill);
  color: var(--text-secondary);
  white-space: nowrap;
}

.q-badge-action {
  color: var(--accent);
  background: var(--accent-soft);
}

/* 5-level Scales (Night Sweats & Workout) */
.scale-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
}

.scale-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 62px;
  padding: 8px 4px;
  border-radius: var(--radius-btn);
  background: var(--bg-pill);
  border: 1.5px solid var(--border);
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}

.scale-btn:active {
  transform: scale(0.95);
}

.scale-swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--btn-color);
  margin-bottom: 1px;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--btn-color) 20%, transparent);
}

.scale-num {
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.scale-lbl {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.scale-btn.is-active {
  background: var(--btn-soft);
  border-color: var(--btn-color);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--btn-color) 28%, transparent);
}

.scale-btn.is-active .scale-num,
.scale-btn.is-active .scale-lbl {
  color: var(--text);
}

.spectrum-bar {
  height: 5px;
  border-radius: 999px;
  margin-top: 10px;
  background: linear-gradient(90deg, #22c55e 0%, #84cc16 25%, #f59e0b 50%, #f97316 75%, #ef4444 100%);
  opacity: 0.85;
}

.spectrum-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 5px;
  font-weight: 500;
}

.scale-feedback {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--text-secondary);
  min-height: 18px;
}

/* 2x2 Cycle Options Grid */
.cycle-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.cycle-btn {
  min-height: 52px;
  padding: 10px 12px;
  border-radius: var(--radius-btn);
  background: var(--bg-pill);
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  font-weight: 600;
  font-size: 14px;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}

.cycle-btn:active {
  transform: scale(0.97);
}

.cycle-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--btn-color);
  flex-shrink: 0;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--btn-color) 20%, transparent);
}

.cycle-btn.is-active {
  background: var(--btn-soft);
  border-color: var(--btn-color);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--btn-color) 24%, transparent);
}

.period-quick-drawer {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: none;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.period-quick-drawer.open {
  display: flex;
}

.period-quick-drawer label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
}

.period-quick-drawer input[type='date'] {
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 13px;
}

/* Food Textarea */
.food-input {
  width: 100%;
  min-height: 68px;
  resize: vertical;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 11px 13px;
  font-size: 14.5px;
  line-height: 1.4;
  transition: border-color 0.15s ease;
}

.food-input:focus {
  outline: none;
  border-color: var(--accent);
}

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

/* Primary Save Row */
.log-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.btn-primary {
  flex: 1;
  min-height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #ffffff;
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.35);
  transition: transform 0.12s ease, opacity 0.15s ease;
}

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

.btn-primary.is-saved {
  background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
  box-shadow: 0 6px 18px rgba(22, 163, 74, 0.28);
}

.btn-danger-ghost {
  min-width: 52px;
  min-height: 52px;
  border-radius: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-danger-ghost:active {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.4);
}

.btn-danger-ghost.hidden {
  display: none;
}

/* Insights View */
.segmented {
  display: inline-flex;
  background: var(--bg-pill);
  border: 1px solid var(--border);
  padding: 3px;
  border-radius: 12px;
  gap: 2px;
}

.seg-btn {
  padding: 6px 11px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: background 0.15s ease, color 0.15s ease;
}

.seg-btn.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

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

.section-heading {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
}

.pattern-card {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(244, 63, 94, 0.12) 100%);
  border: 1px solid rgba(129, 140, 248, 0.3);
  border-radius: var(--radius-card);
  padding: 15px;
  margin-bottom: 12px;
}

.pattern-eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 4px;
}

.pattern-title {
  font-size: 16px;
  font-weight: 800;
  margin: 0 0 5px;
}

.pattern-detail {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 10px;
  text-align: center;
}

.stat-val {
  font-size: 21px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.stat-lbl {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 3px;
  font-weight: 600;
}

/* Charts */
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}

.timeline-wrap {
  width: 100%;
  overflow: hidden;
}

.timeline-svg {
  width: 100%;
  height: auto;
  display: block;
  touch-action: manipulation;
}

.chart-grid-line {
  stroke: var(--border);
  stroke-width: 1;
}

.chart-axis-text {
  fill: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
}

.band-period {
  fill: rgba(244, 63, 94, 0.22);
}

.band-spotting {
  fill: rgba(251, 113, 133, 0.16);
  stroke: rgba(251, 113, 133, 0.4);
  stroke-width: 1;
  stroke-dasharray: 3 2;
}

.band-midway {
  fill: rgba(167, 139, 250, 0.14);
}

.band-selected {
  fill: rgba(129, 140, 248, 0.18);
  stroke: var(--accent);
  stroke-width: 1.2;
}

.chart-hit-col {
  cursor: pointer;
}

.toggle-chip {
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--bg-pill);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.toggle-chip.active {
  background: rgba(56, 189, 248, 0.18);
  border-color: rgba(56, 189, 248, 0.5);
  color: #38bdf8;
}

.chart-inspector {
  margin-top: 10px;
  padding: 11px 12px;
  border-radius: 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
}

.inspector-top,
.inspector-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.inspector-date {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chip-subtle {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-pill);
  color: var(--text-secondary);
}

.inspector-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.mini-pill {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--bg-pill);
  border-left: 3px solid var(--pill-c, var(--border));
}

.inspector-food {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.btn-link {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent);
}

/* Horizontal Correlation Bars */
.hbar-list {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.hbar-row.is-empty {
  opacity: 0.45;
}

.hbar-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
  font-size: 13px;
}

.hbar-label {
  font-weight: 600;
}

.hbar-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
  margin-left: 5px;
}

.hbar-val {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}

.hbar-count {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-left: 3px;
}

.hbar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--bg-pill);
  overflow: hidden;
}

.hbar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* Food Trigger List */
.food-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.food-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 13px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  text-align: left;
  width: 100%;
}

.food-item-text {
  font-size: 13.5px;
  font-weight: 600;
}

.food-item-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.sweat-pill {
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 8px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 26px 16px;
}

.empty-state h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.empty-state p {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--text-secondary);
}

.empty-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin: 4px 0;
}

/* Spreadsheet / Sheet View */
.export-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.btn-secondary {
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 13px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  font-size: 12.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.12s ease, background 0.15s ease;
}

.btn-secondary:active {
  transform: scale(0.96);
  background: var(--bg-pill);
}

.btn-accent-soft {
  background: var(--accent-soft);
  border-color: rgba(129, 140, 248, 0.35);
  color: var(--accent);
}

.sheet-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.search-input {
  width: 100%;
  height: 42px;
  padding: 0 13px;
  border-radius: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  font-size: 14px;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.filter-pills {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.filter-pill {
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--bg-pill);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.filter-pill.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.sheet-table-wrap {
  overflow-x: auto;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  -webkit-overflow-scrolling: touch;
}

.sheet-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  min-width: 520px;
}

.sheet-table th {
  text-align: left;
  padding: 10px 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  white-space: nowrap;
}

.sheet-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}

.sheet-table tbody tr {
  cursor: pointer;
  transition: background 0.12s ease;
}

.sheet-table tbody tr:hover {
  background: var(--bg-pill);
}

.sheet-table tbody tr:last-child td {
  border-bottom: none;
}

.td-date {
  font-weight: 700;
  white-space: nowrap;
}

.td-food {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
}

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

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

.field-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.field-group input {
  height: 40px;
  padding: 0 11px;
  border-radius: 11px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  font-size: 13.5px;
}

.data-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.install-steps {
  margin: 6px 0 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* Bottom Tab Bar */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--border);
  padding: 6px 12px calc(6px + var(--safe-bottom));
}

.bottom-nav-inner {
  max-width: 520px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 52px;
  border-radius: 14px;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 700;
  transition: color 0.15s ease, background 0.15s ease;
}

.nav-tab svg {
  width: 22px;
  height: 22px;
}

.nav-tab.active {
  color: var(--accent);
  background: var(--accent-soft);
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 14px);
  transform: translate(-50%, 16px);
  background: #1e293b;
  color: #f8fafc;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  z-index: 50;
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.muted {
  color: var(--text-muted);
  font-size: 12.5px;
}

.hidden {
  display: none !important;
}

/* Auth Lock Screen */
.auth-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-top)) 18px calc(24px + var(--safe-bottom));
  background: radial-gradient(circle at 20% 10%, rgba(99, 102, 241, 0.14), transparent 50%),
    radial-gradient(circle at 85% 85%, rgba(244, 63, 94, 0.1), transparent 45%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 28px 22px 22px;
  box-shadow: var(--shadow);
  text-align: center;
}

.auth-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  display: block;
  margin: 0 auto 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.auth-title {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.auth-subtitle {
  margin: 0 0 18px;
  font-size: 13.5px;
  color: var(--text-secondary);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-input {
  width: 100%;
  height: 50px;
  padding: 0 64px 0 14px;
  border-radius: 14px;
  background: var(--bg-input);
  border: 1.5px solid var(--border-strong);
  font-size: 16px;
}

.auth-input:focus {
  outline: none;
  border-color: var(--accent);
}

.auth-eye-btn {
  position: absolute;
  right: 10px;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

.auth-error {
  font-size: 12.5px;
  font-weight: 600;
  color: #f87171;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 10px;
  padding: 8px 10px;
}

.auth-submit {
  width: 100%;
  margin-top: 2px;
}

.auth-footnote {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.passcode-change-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
