/* ═══════════════════════════════════════════════════
   Carnivore Diet Tracker — Dark theme, red/black accents
   ═══════════════════════════════════════════════════ */

:root {
  --bg: #0c0c0e;
  --bg-elevated: #141418;
  --bg-card: #1a1a20;
  --bg-hover: #22222a;
  --bg-input: #121216;
  --border: #2a2a34;
  --border-soft: #1f1f28;
  --text: #f2f0ed;
  --text-muted: #8a8794;
  --text-dim: #5c5968;
  --red: #e6392e;
  --red-bright: #ff4d42;
  --red-dim: #a32018;
  --red-glow: rgba(230, 57, 46, 0.25);
  --red-soft: rgba(230, 57, 46, 0.12);
  --accent: #e6392e;
  --green: #3dd68c;
  --green-soft: rgba(61, 214, 140, 0.12);
  --amber: #f0b429;
  --blue: #5b8def;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --header-h: 72px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  background-image:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(230, 57, 46, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 90% 0%, rgba(80, 20, 20, 0.2), transparent);
  background-attachment: fixed;
}

/* ── Layout ── */
.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.25rem 2rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 0;
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(to bottom, var(--bg) 70%, transparent);
  backdrop-filter: blur(12px);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.logo-icon {
  font-size: 1.85rem;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--red-dim), #3a0a08);
  border-radius: 12px;
  border: 1px solid rgba(230, 57, 46, 0.35);
  box-shadow: 0 0 24px var(--red-glow);
}

.logo h1 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.95rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  white-space: nowrap;
  color: var(--text);
  background: var(--bg-card);
  border-color: var(--border);
}

.btn:hover {
  background: var(--bg-hover);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(145deg, var(--red-bright), var(--red-dim));
  border-color: rgba(255, 255, 255, 0.08);
  color: #fff;
  box-shadow: 0 4px 16px var(--red-glow);
}

.btn-primary:hover {
  background: linear-gradient(145deg, #ff5c52, var(--red));
  box-shadow: 0 6px 22px var(--red-glow);
}

.btn-accent {
  background: var(--red-soft);
  border-color: rgba(230, 57, 46, 0.4);
  color: var(--red-bright);
}

.btn-accent:hover {
  background: rgba(230, 57, 46, 0.2);
}

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

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--text-dim);
  background: var(--bg-card);
}

.btn-danger {
  background: rgba(230, 57, 46, 0.15);
  border-color: rgba(230, 57, 46, 0.35);
  color: var(--red-bright);
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  border-radius: 8px;
  line-height: 1;
}

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

.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  border-radius: 6px;
}

/* ── Dropdown ── */
.dropdown {
  position: relative;
}

.dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 180px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 0.35rem;
  z-index: 100;
  animation: fadeSlide 0.18s var(--ease);
}

.dropdown.open .dropdown-menu {
  display: block;
}

.dropdown-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.85rem;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
}

.dropdown-menu button:hover {
  background: var(--red-soft);
  color: var(--red-bright);
}

/* ── Round banner ── */
.round-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.65rem 1rem;
  margin-bottom: 0.85rem;
  background: linear-gradient(90deg, var(--red-soft), transparent 70%);
  border: 1px solid rgba(230, 57, 46, 0.22);
  border-radius: var(--radius-sm);
}

.round-banner-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Stats bar ── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  transition: border-color 0.2s, transform 0.2s var(--ease);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}

.stat-card.accent {
  border-color: rgba(230, 57, 46, 0.35);
  background: linear-gradient(160deg, rgba(230, 57, 46, 0.1), var(--bg-card) 60%);
}

.stat-card.accent::before {
  background: linear-gradient(90deg, transparent, var(--red), transparent);
}

.stat-card:hover {
  border-color: rgba(230, 57, 46, 0.3);
  transform: translateY(-2px);
}

.stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-value {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  font-size: 0.72rem;
  color: var(--text-dim);
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.35rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  margin-bottom: 1.25rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab {
  flex: 1;
  min-width: max-content;
  padding: 0.7rem 1.1rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

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

.tab.active {
  background: linear-gradient(145deg, var(--red), var(--red-dim));
  color: #fff;
  box-shadow: 0 4px 14px var(--red-glow);
}

/* ── Panels ── */
.main {
  flex: 1;
}

.panel {
  display: none;
  animation: fadeSlide 0.3s var(--ease);
}

.panel.active {
  display: block;
}

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

.panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.panel-toolbar h2 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.hint {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.toolbar-right {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 0.75rem;
}

.card-header h2 {
  font-size: 1rem;
  font-weight: 700;
}

.badge {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--bg);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Charts ── */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.chart-card .chart-wrap {
  position: relative;
  height: 260px;
}

.chart-wrap-pie {
  height: 280px !important;
  max-width: 320px;
  margin: 0 auto;
}

/* ── Tables ── */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  text-align: left;
  padding: 0.75rem 0.85rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: var(--bg-card);
}

.data-table td {
  padding: 0.8rem 0.85rem;
  border-bottom: 1px solid var(--border-soft);
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background 0.15s;
}

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

.data-table .num {
  font-family: var(--mono);
  font-size: 0.82rem;
}

.data-table .progress-positive {
  color: var(--green);
  font-weight: 600;
}

.data-table .progress-negative {
  color: var(--red-bright);
  font-weight: 600;
}

.row-actions {
  display: flex;
  gap: 0.35rem;
  justify-content: flex-end;
}

/* ── Forms ── */
.entry-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.inline-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.85rem;
  align-items: end;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.85rem;
  align-items: end;
}

.meal-builder {
  display: grid;
  grid-template-columns: 1fr 2fr 0.8fr 0.9fr 0.9fr auto;
  gap: 0.75rem;
  align-items: end;
  padding: 1rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.field input,
.field select,
.search-input,
.select-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.6rem 0.75rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

.field input:focus,
.field select:focus,
.search-input:focus,
.select-input:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-glow);
}

.field-check {
  justify-content: center;
}

.check-label {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 0.5rem;
  text-transform: none !important;
  font-size: 0.875rem !important;
  letter-spacing: 0 !important;
  color: var(--text) !important;
  cursor: pointer;
  padding: 0.55rem 0;
}

.check-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--red);
  cursor: pointer;
}

.field-actions {
  flex-direction: row;
  align-items: flex-end;
  gap: 0.5rem;
}

.form-actions {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.day-totals-bar {
  display: flex;
  gap: 1.5rem;
  padding: 0.9rem 1.1rem;
  background: linear-gradient(90deg, var(--red-soft), transparent);
  border: 1px solid rgba(230, 57, 46, 0.25);
  border-radius: var(--radius-sm);
}

.day-totals-bar .muted {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

.day-totals-bar strong {
  font-size: 1.2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* Food combobox */
.food-search-field {
  position: relative;
}

.food-combobox {
  position: relative;
}

.food-dropdown {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 260px;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 40;
}

.food-dropdown.open {
  display: block;
  animation: fadeSlide 0.15s var(--ease);
}

.food-option {
  padding: 0.65rem 0.85rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border-soft);
  transition: background 0.1s;
}

.food-option:hover,
.food-option.active {
  background: var(--red-soft);
}

.food-option .name {
  font-weight: 600;
  font-size: 0.875rem;
}

.food-option .meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

/* ── Entry layout ── */
.entry-layout {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  align-items: start;
}

.sticky-card {
  position: sticky;
  top: 88px;
}

.draft-meals {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.meal-section-block {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.meal-section-title {
  padding: 0.5rem 0.85rem;
  background: var(--bg);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-soft);
}

.meal-item {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.85rem;
}

.meal-item:last-child {
  border-bottom: none;
}

.meal-item .item-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meal-item .item-meta {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.meal-item .btn-remove {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
}

.meal-item .btn-remove:hover {
  color: var(--red-bright);
  background: var(--red-soft);
}

.empty-state {
  color: var(--text-dim);
  text-align: center;
  padding: 2rem 1rem;
  font-size: 0.9rem;
}

/* ── Intake list ── */
.intake-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.day-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: center;
}

.day-card:hover {
  border-color: rgba(230, 57, 46, 0.4);
  transform: translateX(3px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.day-card.done {
  border-left: 3px solid var(--green);
}

.day-check {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.day-card.done .day-check {
  background: var(--green-soft);
  border-color: rgba(61, 214, 140, 0.4);
  color: var(--green);
}

.day-info h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.day-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.day-meta span {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.day-stats {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.day-stats .cal {
  font-size: 1.05rem;
  font-weight: 800;
  display: block;
}

.day-stats .prot {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

/* ── Food library ── */
.food-name-field {
  min-width: 220px;
  flex: 1.5;
}

.source-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.source-badge.source-builtin {
  color: var(--text-muted);
  background: var(--bg);
}

.source-badge.source-custom {
  color: var(--green);
  background: var(--green-soft);
  border-color: rgba(61, 214, 140, 0.35);
}

.source-badge.source-override {
  color: var(--amber);
  background: rgba(240, 180, 41, 0.12);
  border-color: rgba(240, 180, 41, 0.35);
}

#foodFormCard .field-hint {
  margin-top: 0.75rem;
}

/* ── Top foods ── */
.top-foods {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.food-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
}

.food-chip .count {
  background: var(--red-soft);
  color: var(--red-bright);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  font-family: var(--mono);
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 1rem;
  animation: fadeIn 0.2s;
}

.modal-overlay.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: min(640px, 100%);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  animation: fadeSlide 0.25s var(--ease);
}

.modal.modal-sm {
  width: min(420px, 100%);
}

.modal-copy {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  line-height: 1.55;
}

.field-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.35rem;
}

/* ── History tab ── */
.history-layout {
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: 1rem;
  align-items: start;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 70vh;
  overflow-y: auto;
}

.history-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.history-item:hover {
  border-color: rgba(230, 57, 46, 0.4);
  background: var(--bg-hover);
}

.history-item.active {
  border-color: var(--red);
  background: var(--red-soft);
  box-shadow: 0 0 0 1px rgba(230, 57, 46, 0.25);
}

.history-item-title {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.history-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

.history-item-range {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.history-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}

.history-stat {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.history-stat strong {
  font-size: 1.05rem;
  font-weight: 800;
}

.history-sections {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.history-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.65rem;
  letter-spacing: -0.01em;
}

.history-days {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 420px;
  overflow-y: auto;
}

.history-day-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.65rem;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  font-size: 0.82rem;
}

.history-table {
  font-size: 0.82rem;
}

@media (max-width: 900px) {
  .history-layout,
  .history-sections {
    grid-template-columns: 1fr;
  }
}

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

.modal-header h2 {
  font-size: 1.05rem;
}

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-soft);
}

.detail-grid {
  display: grid;
  gap: 1rem;
}

.detail-section h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.detail-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.875rem;
}

.detail-item .meta {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.detail-totals {
  display: flex;
  gap: 1.5rem;
  padding: 0.85rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

.detail-totals strong {
  font-size: 1.15rem;
  font-weight: 800;
}

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 3px solid var(--red);
  padding: 0.85rem 1.15rem;
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 0.875rem;
  font-weight: 500;
  animation: fadeSlide 0.25s var(--ease);
  max-width: 320px;
}

.toast.success {
  border-left-color: var(--green);
}

.toast.error {
  border-left-color: var(--red-bright);
}

/* ── Footer ── */
.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 0 0.5rem;
  font-size: 0.75rem;
  color: var(--text-dim);
  gap: 1rem;
  flex-wrap: wrap;
}

.save-status {
  color: var(--green);
  font-weight: 600;
}

/* ── Utils ── */
.hidden {
  display: none !important;
}

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

/* ── Responsive ── */
@media (max-width: 1100px) {
  .stats-bar {
    grid-template-columns: repeat(3, 1fr);
  }
  .charts-grid {
    grid-template-columns: 1fr;
  }
  .entry-layout {
    grid-template-columns: 1fr;
  }
  .sticky-card {
    position: static;
  }
  .meal-builder {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 700px) {
  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
  }
  .btn-label {
    display: none;
  }
  .header {
    flex-wrap: wrap;
  }
  .logo h1 {
    font-size: 1.05rem;
  }
  .day-card {
    grid-template-columns: auto 1fr;
  }
  .day-stats {
    grid-column: 2;
    text-align: left;
  }
  .meal-builder {
    grid-template-columns: 1fr;
  }
  .inline-form {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 420px) {
  .stats-bar {
    grid-template-columns: 1fr 1fr;
  }
  .stat-value {
    font-size: 1.2rem;
  }
  .app {
    padding: 0 0.75rem 1.5rem;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}
