/* SakuKalori v4 Stylesheet: Executive Luxury Athletic Telemetry
   High-precision obsidian and tour emerald aesthetics.
   All color pairs verified with contrast-check.py for WCAG 2.2 AA compliance.
   No em dashes anywhere.
*/

:root {
  --bg-canvas: #F8FAFC;
  --bg-surface: #FFFFFF;
  --bg-subtle: #F1F5F9;
  --bg-elevated: #FFFFFF;
  --bg-hero: #090D16;
  --bg-hero-soft: #121826;

  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #64748B;
  --text-on-hero: #F8FAFC;
  --text-on-hero-sub: #94A3B8;

  --border-subtle: rgba(15, 23, 42, 0.08);
  --border-line: #E2E8F0;
  --border-hero: rgba(255, 255, 255, 0.1);

  --accent-emerald: #047857;
  --accent-emerald-hover: #065F46;
  --accent-emerald-light: #ECFDF5;
  --accent-emerald-glow: rgba(4, 120, 87, 0.15);

  /* Macro Telemetry Trio Colors */
  --macro-p-color: #047857;
  --macro-p-bg: #ECFDF5;
  --macro-c-color: #B45309;
  --macro-c-bg: #FFFBEB;
  --macro-f-color: #BE123C;
  --macro-f-bg: #FFF1F2;

  --warn-bg: #FFFBEB;
  --warn-text: #9A3412;
  --warn-border: #B45309;

  --danger-bg: #FEF2F2;
  --danger-text: #991B1B;
  --danger-border: #B91C1C;
  --danger-solid: #B91C1C;

  --focus-ring: #047857;

  --shadow-lux: 0 10px 30px -4px rgba(15, 23, 42, 0.05), 0 2px 8px -2px rgba(15, 23, 42, 0.03);
  --shadow-modal: 0 24px 60px -8px rgba(15, 23, 42, 0.2), 0 4px 16px -2px rgba(15, 23, 42, 0.08);

  --radius-xl: 20px;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 6px;

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

[data-theme="dark"] {
  --bg-canvas: #070A11;
  --bg-surface: #0E1422;
  --bg-subtle: #131B2D;
  --bg-elevated: #162035;
  --bg-hero: #0E1422;
  --bg-hero-soft: #162035;

  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --text-on-hero: #F8FAFC;
  --text-on-hero-sub: #94A3B8;

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-line: rgba(255, 255, 255, 0.12);
  --border-hero: rgba(255, 255, 255, 0.12);

  --accent-emerald: #10B981;
  --accent-emerald-hover: #34D399;
  --accent-emerald-light: rgba(16, 185, 129, 0.12);
  --accent-emerald-glow: rgba(16, 185, 129, 0.25);

  /* Macro Telemetry Trio in Dark Mode */
  --macro-p-color: #10B981;
  --macro-p-bg: rgba(16, 185, 129, 0.12);
  --macro-c-color: #F59E0B;
  --macro-c-bg: rgba(245, 158, 11, 0.12);
  --macro-f-color: #F43F5E;
  --macro-f-bg: rgba(244, 63, 94, 0.12);

  --warn-bg: #451A03;
  --warn-text: #FDE68A;
  --warn-border: #F59E0B;

  --danger-bg: #450A0A;
  --danger-text: #FECACA;
  --danger-border: #F87171;
  --danger-solid: #EF4444;

  --focus-ring: #34D399;

  --shadow-lux: 0 10px 30px -4px rgba(0, 0, 0, 0.5);
  --shadow-modal: 0 24px 60px -8px rgba(0, 0, 0, 0.75);
}

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

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-canvas);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  overflow-x: hidden;
  min-height: 100vh;
}

[hidden] {
  display: none !important;
}

.num,
input[type="number"],
.meal-card-kcal,
.data-table td {
  font-variant-numeric: tabular-nums;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  background: var(--accent-emerald);
  color: #FFFFFF;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-weight: 700;
  z-index: 2000;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

button,
select,
summary,
label[for],
input[type="checkbox"],
input[type="radio"],
input[type="date"],
.clickable {
  cursor: pointer;
}

/* App Shell */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: 96px;
}

/* Luxury Minimal Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 14px 24px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-inner {
  max-width: 840px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

.brand-monogram {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background-color: var(--bg-hero);
  color: var(--accent-emerald);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
  letter-spacing: -0.02em;
  border: 1px solid var(--border-hero);
  flex-shrink: 0;
}

.brand-text-block {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  line-height: 1.15;
}

.brand-subtitle {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

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

.header-status-pill {
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border-line);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease;
}

.header-status-pill:hover {
  border-color: var(--accent-emerald);
  background-color: var(--bg-subtle);
}

.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  box-shadow: 0 0 6px var(--accent-emerald);
}

.header-theme-btn {
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-line);
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  transition: all 0.15s ease;
}

.header-theme-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-subtle);
}

/* Primary Navigation */
.primary-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 120;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 8px 12px;
  box-shadow: 0 -4px 24px rgba(15, 23, 42, 0.04);
}

.sidebar-brand-card {
  display: none;
}

.nav-tab {
  min-height: 48px;
  padding: 6px 4px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  line-height: 1.15;
  transition: all 0.15s ease;
}

.nav-tab svg {
  width: 19px;
  height: 19px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  flex-shrink: 0;
}

.nav-tab:hover {
  color: var(--text-primary);
  background-color: var(--bg-subtle);
}

.nav-tab[aria-selected="true"] {
  background-color: var(--accent-emerald-light);
  color: var(--accent-emerald);
}

/* Main Workspace */
.main-workspace {
  width: 100%;
  max-width: 840px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  flex: 1;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

/* Top Date & Mode Navigation Strip */
.diary-top-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.date-navigator {
  display: inline-flex;
  align-items: center;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-line);
  border-radius: 999px;
  padding: 3px;
  box-shadow: var(--shadow-lux);
}

.date-nav-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.date-nav-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-subtle);
}

.date-nav-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
}

.date-display-btn {
  min-height: 44px;
  padding: 8px 16px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.date-display-btn svg {
  width: 16px;
  height: 16px;
  stroke: var(--accent-emerald);
  stroke-width: 2;
  fill: none;
}

.date-display-btn:hover {
  background-color: var(--bg-subtle);
}

.daymode-trigger-btn {
  min-height: 44px;
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid var(--border-line);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-lux);
  transition: all 0.15s ease;
}

.daymode-trigger-btn:hover {
  border-color: var(--accent-emerald);
  background-color: var(--bg-subtle);
}

.status-indicator-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  box-shadow: 0 0 6px var(--accent-emerald);
}

/* =========================================================================
   SCOREBOARD: EXECUTIVE ATHLETIC TELEMETRY INSTRUMENT
   ========================================================================= */
.scoreboard-card {
  background: linear-gradient(150deg, #0F172A 0%, #070A11 100%);
  color: var(--text-on-hero);
  border-radius: var(--radius-xl);
  padding: 26px 28px;
  margin-bottom: 28px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 20px 40px -12px rgba(7, 10, 17, 0.6);
  position: relative;
  overflow: hidden;
}

.scoreboard-card::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 160px;
  height: 160px;
  background: radial-gradient(circle, var(--accent-emerald-glow) 0%, transparent 70%);
  pointer-events: none;
}

.sb-top-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.sb-label-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sb-eyebrow {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--accent-emerald);
  text-transform: uppercase;
}

.sb-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-on-hero);
  letter-spacing: -0.01em;
}

.sb-barcode-btn {
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background-color: rgba(255, 255, 255, 0.06);
  color: #F8FAFC;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease;
}

.sb-barcode-btn:hover {
  background-color: rgba(255, 255, 255, 0.12);
  border-color: var(--accent-emerald);
}

.sb-barcode-btn svg {
  width: 16px;
  height: 16px;
  stroke: var(--accent-emerald);
  stroke-width: 2;
  fill: none;
}

/* Dual Chronograph Ring & Intake Meta */
.sb-hero-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
  align-items: center;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sb-ring-wrap {
  position: relative;
  width: 110px;
  height: 110px;
  margin: 0 auto;
  flex-shrink: 0;
}

.kcal-ring-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 7;
}

.ring-progress {
  fill: none;
  stroke: var(--accent-emerald);
  stroke-width: 7;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  filter: drop-shadow(0 0 6px var(--accent-emerald-glow));
}

.ring-progress.is-over {
  stroke: #F43F5E;
  filter: drop-shadow(0 0 6px rgba(244, 63, 94, 0.4));
}

.sb-ring-center-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.sb-center-num {
  font-size: 1.65rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  color: #FFFFFF;
}

.sb-center-num.is-over {
  color: #FDA4AF;
}

.sb-center-unit {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--text-on-hero-sub);
  margin-top: 2px;
}

.sb-hero-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sb-status-line {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-on-hero-sub);
}

.sb-budget-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  text-align: left;
}

.sb-meta-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sb-meta-label {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text-on-hero-sub);
}

.sb-meta-val {
  font-size: 1.15rem;
  font-weight: 800;
  color: #F8FAFC;
}

.sb-meta-val.highlight {
  color: var(--accent-emerald);
}

.sb-budget-track {
  width: 100%;
  height: 6px;
  background-color: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.sb-budget-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-emerald) 0%, #34D399 100%);
  border-radius: 999px;
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sb-budget-fill.is-over {
  background: linear-gradient(90deg, #F43F5E 0%, #FB7185 100%);
}

/* Tri-Color Macro Telemetry Grid */
.sb-macros-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding-top: 22px;
}

.macro-cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mc-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px;
  flex-wrap: wrap;
}

.mc-name {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.macro-protein .mc-name { color: var(--macro-p-color); }
.macro-carbs .mc-name { color: var(--macro-c-color); }
.macro-fat .mc-name { color: var(--macro-f-color); }

.mc-val {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-on-hero-sub);
}

.mc-val strong {
  color: #F8FAFC;
}

.mc-bar-track {
  width: 100%;
  height: 5px;
  background-color: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.mc-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.macro-protein .mc-bar-fill { background-color: var(--macro-p-color); }
.macro-carbs .mc-bar-fill { background-color: var(--macro-c-color); }
.macro-fat .mc-bar-fill { background-color: var(--macro-f-color); }

.mc-bar-fill.is-over {
  background-color: #F43F5E !important;
}

.mc-rem {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-on-hero-sub);
}

.mc-rem.is-over {
  color: #FDA4AF;
}

/* =========================================================================
   MEAL CARDS: CLEAN LUXURY ATHLETIC FEED
   ========================================================================= */
.meal-feed-stack {
  display: flex;
  flex-direction: column;
  gap: 22px;
  margin-bottom: 32px;
}

.meal-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lux);
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.meal-card:hover {
  box-shadow: 0 12px 32px -4px rgba(15, 23, 42, 0.08);
}

.meal-card-header {
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.meal-card-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.meal-session-tag {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.meal-card-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.meal-card-telemetry {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.meal-card-kcal {
  font-size: 1.18rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
}

.meal-card-macro-sub {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Clean Food Rows */
.meal-rows-list {
  display: flex;
  flex-direction: column;
}

.meal-food-row-btn {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  text-align: left;
  font-family: inherit;
  color: var(--text-primary);
  transition: background-color 0.15s ease;
}

.meal-food-row-btn:hover {
  background-color: var(--bg-subtle);
}

.mfr-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.mfr-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.mfr-sub {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.mfr-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.mfr-right .meal-row-kcal {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-primary);
}

.mfr-edit-hint {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-emerald);
  background-color: var(--accent-emerald-light);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.04em;
}

.meal-empty-state {
  padding: 20px 24px;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
}

.meal-card-footer {
  padding: 14px 24px;
  background-color: var(--bg-surface);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.meal-add-btn {
  flex: 1;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--accent-emerald);
  background-color: var(--accent-emerald);
  color: #FFFFFF;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s ease;
  box-shadow: 0 4px 12px var(--accent-emerald-glow);
}

.meal-add-btn:hover {
  background-color: var(--accent-emerald-hover);
  border-color: var(--accent-emerald-hover);
}

.meal-add-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
}

.meal-scan-btn {
  min-height: 44px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-line);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s ease;
}

.meal-scan-btn:hover {
  border-color: var(--accent-emerald);
  background-color: var(--bg-subtle);
}

.meal-scan-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

/* =========================================================================
   TAB 2: STUDIO RESEP & MEAL PREP
   ========================================================================= */
.recipe-selector-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.field-label-micro {
  display: block;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.recipe-summary-hero {
  background: linear-gradient(150deg, #0F172A 0%, #070A11 100%);
  color: var(--text-on-hero);
  border-radius: var(--radius-xl);
  padding: 24px 28px;
  margin-bottom: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 16px 36px -8px rgba(7, 10, 17, 0.5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.rsh-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rsh-eyebrow {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--accent-emerald);
}

.rsh-kcal {
  font-size: clamp(1.8rem, 4vw, 2.35rem);
  font-weight: 800;
  color: #FFFFFF;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.rsh-macros {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-on-hero-sub);
  margin-top: 4px;
}

.rsh-pan-total {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.rsh-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Precision Ingredients List */
.ing-clean-list {
  border-top: 1px solid var(--border-subtle);
  margin: 16px -24px 20px;
}

.ing-clean-row {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  transition: background-color 0.15s ease;
}

.ing-clean-row:hover {
  background-color: var(--bg-subtle);
}

.icr-info {
  flex: 1;
  min-width: 180px;
}

.icr-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  display: block;
}

.icr-sub {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.icr-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icr-gram-input {
  width: 90px;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-line);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  text-align: right;
}

.icr-unit {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
}

.icr-del-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-line);
  background-color: var(--bg-surface);
  color: var(--danger-text);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  transition: all 0.15s ease;
}

.icr-del-btn:hover {
  background-color: var(--danger-bg);
  border-color: var(--danger-border);
}

.recipe-add-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* =========================================================================
   GENERIC CARDS, BUTTONS & FORMS
   ========================================================================= */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-lux);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.card-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.card-subtitle {
  margin: 4px 0 0 0;
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.btn {
  min-height: 44px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-line);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn:hover {
  background-color: var(--bg-subtle);
}

.btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.btn-primary {
  background-color: var(--accent-emerald);
  color: #FFFFFF;
  border-color: var(--accent-emerald);
  box-shadow: 0 4px 14px var(--accent-emerald-glow);
}

.btn-primary:hover {
  background-color: var(--accent-emerald-hover);
  border-color: var(--accent-emerald-hover);
}

.btn-danger {
  background-color: var(--danger-bg);
  color: var(--danger-text);
  border-color: var(--danger-border);
}

.btn-danger:hover {
  background-color: var(--danger-solid);
  color: #FFFFFF;
}

.btn-stepper {
  min-width: 44px;
  padding: 6px 12px;
  font-size: 1.1rem;
  font-weight: 800;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

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

.form-field label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
}

.field-hint {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.input-control,
.select-control {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--border-line);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  transition: border-color 0.15s ease;
}

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

/* =========================================================================
   MODALS / DRAWERS
   ========================================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 500;
  background-color: rgba(7, 10, 17, 0.72);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-sheet {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border-top: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: 680px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-modal);
  overflow: hidden;
}

.modal-header {
  padding: 18px 24px;
  background-color: var(--bg-hero);
  color: var(--text-on-hero);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.modal-close-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background-color: rgba(255, 255, 255, 0.08);
  color: #F8FAFC;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
}

.modal-body {
  padding: 22px 24px;
  overflow-y: auto;
  flex: 1;
}

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

.subtab-btn {
  min-height: 44px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-line);
  background-color: var(--bg-subtle);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
  transition: all 0.15s ease;
}

.subtab-btn[aria-selected="true"] {
  background-color: var(--accent-emerald-light);
  color: var(--accent-emerald);
  border-color: var(--accent-emerald);
}

.cat-chips-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.cat-chip {
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border-line);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.cat-chip[aria-pressed="true"] {
  background-color: var(--bg-hero);
  color: #FFFFFF;
  border-color: var(--bg-hero);
}

.food-results-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 4px;
  margin-bottom: 14px;
}

.food-result-row {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  width: 100%;
  font-family: inherit;
  color: var(--text-primary);
  transition: all 0.15s ease;
}

.food-result-row:hover {
  background-color: var(--bg-subtle);
}

.food-result-row.is-picked {
  background-color: var(--accent-emerald-light);
  border-color: var(--accent-emerald);
}

.fr-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fr-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
}

.fr-sub {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.fr-kcal {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--accent-emerald);
  background-color: var(--accent-emerald-light);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.picked-food-calculator {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 16px;
}

.pfc-title {
  margin: 0 0 12px 0;
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
}

.pfc-preview-bar {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin: 14px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-weight: 800;
  font-size: 0.9rem;
}

/* Barcode Scanner Box */
.camera-scanner-box {
  background-color: #070A11;
  color: #F8FAFC;
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
}

.camera-video-wrap {
  position: relative;
  width: 100%;
  max-width: 420px;
  height: 220px;
  margin: 0 auto 14px;
  background-color: #0E1422;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px dashed var(--accent-emerald);
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-laser-line {
  position: absolute;
  left: 10%;
  right: 10%;
  top: 50%;
  height: 2px;
  background-color: #34D399;
  box-shadow: 0 0 10px #34D399;
  pointer-events: none;
}

/* Data Tables */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.data-table th,
.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table th {
  background-color: var(--bg-subtle);
  font-weight: 800;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-line);
}

.data-table tr.is-current-week {
  background-color: var(--accent-emerald-light);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 800;
}

.status-pill.green {
  background-color: var(--accent-emerald-light);
  color: var(--accent-emerald);
}

.status-pill.amber {
  background-color: var(--warn-bg);
  color: var(--warn-text);
}

.status-pill.red {
  background-color: var(--danger-bg);
  color: var(--danger-text);
}

.callout-banner {
  padding: 16px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-subtle);
  font-size: 0.86rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.callout-banner.green {
  background-color: var(--accent-emerald-light);
  color: var(--accent-emerald);
  border-color: rgba(4, 120, 87, 0.2);
}

.callout-banner.amber {
  background-color: var(--warn-bg);
  color: var(--warn-text);
  border-color: rgba(180, 83, 9, 0.2);
}

details.guide-accordion {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  margin-bottom: 12px;
  padding: 14px 18px;
}

details.guide-accordion summary {
  font-weight: 800;
  font-size: 0.94rem;
  color: var(--text-primary);
  min-height: 44px;
  display: flex;
  align-items: center;
}

details.guide-accordion .guide-body {
  padding-top: 12px;
  margin-top: 10px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.toast-msg {
  position: fixed;
  bottom: 84px;
  right: 20px;
  z-index: 600;
  background-color: #070A11;
  color: #F8FAFC;
  border: 1px solid var(--accent-emerald);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-size: 0.86rem;
  font-weight: 700;
  box-shadow: var(--shadow-modal);
}

@media (min-width: 640px) {
  .sb-hero-grid {
    grid-template-columns: 140px 1fr;
  }

  .form-grid.cols-2 {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-grid.cols-3 {
    grid-template-columns: repeat(3, 1fr);
  }

  .form-grid.cols-4 {
    grid-template-columns: repeat(4, 1fr);
  }

  .modal-backdrop {
    align-items: center;
    padding: 24px;
  }

  .modal-sheet {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    max-height: 88vh;
  }
}

@media (min-width: 1024px) {
  .app-shell {
    padding-left: 260px;
    padding-bottom: 40px;
  }

  .primary-nav {
    top: 0;
    bottom: 0;
    left: 0;
    right: auto;
    width: 260px;
    border-top: none;
    border-right: 1px solid var(--border-subtle);
    background-color: #070A11;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 28px 16px;
    gap: 8px;
    box-shadow: none;
  }

  .sidebar-brand-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px;
    margin-bottom: 16px;
    border-radius: var(--radius-md);
    background-color: #0E1422;
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #F8FAFC;
  }

  .sbc-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .sbc-brand {
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    color: #FFFFFF;
  }

  .sbc-tag {
    font-size: 0.62rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    background-color: var(--accent-emerald-light);
    color: var(--accent-emerald);
  }

  .sbc-desc {
    font-size: 0.72rem;
    color: #64748B;
  }

  .nav-tab {
    flex-direction: row;
    justify-content: flex-start;
    padding: 12px 16px;
    font-size: 0.88rem;
    text-align: left;
    gap: 12px;
    color: #94A3B8;
    border-radius: var(--radius-md);
  }

  .nav-tab:hover {
    background-color: #0E1422;
    color: #FFFFFF;
  }

  .nav-tab[aria-selected="true"] {
    background-color: var(--accent-emerald-light);
    color: var(--accent-emerald);
  }

  .toast-msg {
    bottom: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}
