/* ═══════════════════════════════════════════════════════════════════
   Nawtch — global stylesheet, shared by every page.
   ═══════════════════════════════════════════════════════════════════ */

/* Shared across all 6 pages: variables, reset, nav, page header, generic
   buttons/form fields, modal chrome, footer. Page-specific layout lives in
   each page's own <page>.css. */

:root {
  --bg: #0e0f13;
  --surface: #16181f;
  --surface2: #1e2029;
  --border: #2a2d3a;
  --accent: #c8f060;
  --accent2: #60c8f0;
  --accent3: #f0a060;
  --warn: #f06060;
  --text: #e8eaf0;
  --muted: #7a7f96;
  --protein: #60f0a0;
  --carbs: #f0d060;
  --fat: #f09060;
}
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Syne", sans-serif;
  min-height: 100vh;
  padding: 28px 20px 60px;
}
.page {
  max-width: 900px;
  margin: 0 auto;
}

/* NAV TABS */
.nav-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
}
.nav-tab {
  flex: 1;
  padding: 8px;
  border-radius: 7px;
  border: none;
  background: none;
  color: var(--muted);
  font-family: "Syne", sans-serif;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  text-decoration: none;
  display: block;
}
.nav-tab:hover {
  color: var(--text);
}
.nav-tab.active {
  background: var(--surface2);
  color: var(--accent);
  border: 1px solid var(--border);
}

/* PAGE HEADER */
header {
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
}
.header-left .label {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
h1 {
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  color: var(--accent);
  margin-bottom: 4px;
}
.subtitle {
  color: var(--muted);
  font-size: 13px;
}
.date-badge {
  font-family: "DM Mono", monospace;
  font-size: 12px;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  text-align: right;
}
.date-badge .date-day {
  font-size: 15px;
  font-weight: 500;
}
.date-badge .date-reset {
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}

/* GENERIC CARD CONTAINERS */
.meter-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 24px;
}
.items-section {
  margin-bottom: 24px;
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 12px;
}

/* FORM FIELDS */
.add-row {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
}
.add-row-1 {
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
}
.add-row-2 {
  grid-template-columns: 1fr 1fr 1fr 1fr;
}
.add-row-3 {
  grid-template-columns: 1fr 1fr auto auto;
}
.field-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.field-label {
  font-family: "DM Mono", monospace;
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.field-hint {
  font-family: "DM Mono", monospace;
  font-size: 9px;
  color: var(--accent3);
  margin-top: 2px;
}
input[type="text"],
input[type="number"] {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: "DM Mono", monospace;
  font-size: 12px;
  padding: 6px 9px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}
input:focus {
  border-color: var(--accent);
}
input::placeholder {
  color: var(--muted);
}
input[readonly] {
  color: var(--accent3);
  cursor: default;
}

/* BUTTONS */
.add-btn {
  background: var(--accent);
  color: #0e0f13;
  border: none;
  border-radius: 6px;
  font-family: "Syne", sans-serif;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
  align-self: flex-end;
  height: 30px;
}
.add-btn:hover {
  opacity: 0.85;
}
.edit-btn,
.mgmt-edit-btn {
  background: var(--accent);
  color: #0e0f13;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: "Syne", sans-serif;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
  align-self: flex-end;
}
.edit-btn:hover,
.mgmt-edit-btn:hover {
  opacity: 0.85;
}
.mgmt-edit-btn {
  border-color: var(--accent) !important;
}
.remove-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  padding: 5px 10px;
  cursor: pointer;
  font-family: "Syne", sans-serif;
  transition: all 0.1s;
}
.remove-btn:hover {
  border-color: var(--warn);
  color: var(--warn);
}
.ghost-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 11px;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  display: inline-block;
}
.ghost-btn:hover {
  border-color: var(--warn);
  color: var(--warn);
}
.scan-cf-btn:hover {
  border-color: var(--accent2);
  color: var(--accent2);
}

/* Generic dropdown trigger + floating menu (History's Export CSV/JSON menu,
   Programs' rest/time unit selectors) */
.export-dropdown {
  position: relative;
}
.export-dropdown .ghost-btn.export-dropdown-trigger:hover {
  border-color: var(--text) !important;
  color: var(--text);
}
.export-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  width: 100%;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
.export-dropdown.open .export-dropdown-menu {
  display: block;
}
.export-dropdown-menu button {
  display: block;
  width: 100%;
  padding: 9px 14px;
  background: none;
  border: none;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 11px;
  text-align: center;
  cursor: pointer;
  transition:
    background 0.1s,
    color 0.1s;
}
.export-dropdown-menu button:not(:last-child) {
  border-bottom: 1px solid var(--border);
}
.export-dropdown-menu button:hover {
  background: var(--surface2);
  color: var(--text);
}

.no-history, .no-foods {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 13px;
}

/* CONFIRM MODAL */
#confirm-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.65);
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#confirm-modal.open {
  display: flex;
}
.confirm-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 24px 20px;
  max-width: 360px;
  width: 100%;
}
.confirm-box p {
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  margin-bottom: 20px;
}
.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.confirm-actions button {
  font-family: "DM Mono", monospace;
  font-size: 12px;
  padding: 9px 18px;
  border-radius: 7px;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all 0.15s;
}
#confirm-cancel {
  background: none;
  color: var(--muted);
}
#confirm-cancel:hover {
  border-color: var(--muted);
  color: var(--text);
}
#confirm-ok {
  background: var(--warn);
  border-color: var(--warn);
  color: #0e0f13;
  font-weight: 600;
}
#confirm-ok:hover {
  opacity: 0.85;
}

/* GENERIC MODAL CHROME (used by Foods/Programs/Today/Weight modals + the
   shared alert modal from ui.js) */
.pg-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1001;
  background: rgba(0, 0, 0, 0.7);
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.pg-modal.open {
  display: flex;
}
.pg-modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  max-width: 480px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.pg-modal-box-lg {
  max-width: 680px;
}
.pg-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.pg-modal-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 2px;
}
.pg-modal-subtitle {
  font-size: 12px;
  font-family: "DM Mono", monospace;
  color: var(--muted);
}
.pg-close-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 0 0 0 12px;
  flex-shrink: 0;
  transition: color 0.15s;
}
.pg-close-btn:hover {
  color: var(--text);
}
.pg-modal-body {
  padding: 20px 22px;
  overflow-y: auto;
  flex: 1;
}
.pg-modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  gap: 10px;
}
.pg-delete-btn:hover {
  border-color: var(--warn) !important;
  color: var(--warn) !important;
}

/* Generic choice/alert modal sizing (Foods' Add Food modal + ui.js's alert modal) */
.choice-modal-box {
  max-width: 400px;
}
.choice-modal-body {
  padding: 16px 20px 24px;
}
.scanner-error-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 28px 24px 32px;
  text-align: center;
}
.scanner-error-msg {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  max-width: 300px;
  margin: 0;
}

/* Segmented toggle (weight unit lb/kg, chart daily/weekly) */
.wt-toggle {
  display: inline-flex;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.wt-toggle-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 11px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s;
}
.wt-toggle-btn:hover {
  color: var(--text);
}
.wt-toggle-btn.active {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--border);
}

/* ECharts container base sizing (History + Weight) */
.echart-container {
  width: 100%;
  min-width: 0;
  height: 180px;
  max-width: 420px;
  margin: 0 auto 12px auto;
  background: none;
  overflow: visible;
  display: block;
}

/* APP FOOTER */
.app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 10px;
  height: 44px;
  z-index: 100;
}
.footer-settings-btn {
  position: relative;
  background: none;
  border: none;
  color: var(--muted);
  font-family: "Syne", sans-serif;
  font-size: 24px;
  line-height: 24px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  text-decoration: none;
}
.footer-settings-btn:hover {
  color: var(--text);
  background: var(--surface2);
}
.footer-settings-btn.active {
  color: var(--accent);
}

/* One-time hint nudging first-time users toward Settings (see settingsHint.js) */
.settings-hint-arrow {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 4px;
  font-size: 28px;
  line-height: 1;
  color: var(--accent);
  text-shadow: 0 0 8px rgba(200, 240, 96, 0.6);
  pointer-events: none;
  animation: settings-hint-bounce 1.2s ease-in-out infinite;
}
@keyframes settings-hint-bounce {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, -6px); }
}

@media (max-width: 600px) {
  .echart-container {
    height: 220px;
    max-width: 100vw;
  }
}

@media (max-width: 520px) {
  .pg-modal-box,
  .pg-modal-box-lg {
    max-width: 100%;
    border-radius: 10px 10px 0 0;
  }
}

@media (max-width: 660px) {
  .pg-modal-header {
    padding: 16px;
  }
  .pg-modal-body {
    padding: 10px;
  }
  .add-row-1 {
    grid-template-columns: 1fr 1fr;
  }
  .add-row-2 {
    grid-template-columns: 1fr 1fr;
  }
  .add-row-3 {
    grid-template-columns: 1fr 1fr;
  }
}

/* ─────────────────────── barcode scanner modal ─────────────────────── */
/* Barcode scanner modal — shared by Today (scanning a custom food) and Foods
   (scanning a new saved food). Loaded only by those two pages. */

.scanner-modal-box {
  max-width: 520px;
}
.scanner-body {
  padding: 0 !important;
  overflow: hidden;
}
.barcode-video-container {
  background: #000;
  min-height: 260px;
  width: 100%;
  position: relative;
  overflow: hidden;
}
.barcode-video-container video {
  width: 100% !important;
  height: auto !important;
  display: block;
}
#barcode-video-container img[alt="Info icon"] {
  display: none !important;
}
.scanner-status-text {
  padding: 12px 20px;
  font-family: "DM Mono", monospace;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* ─────────────────────────── today page ────────────────────────────── */
/* Today page — daily tracker: status banner, totals, calorie meter, macro
   split, saved/custom food lists, weekly cost, welcome modal. */

.status-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  box-shadow: 0 0 8px var(--accent);
  margin-top: 4px;
}
.status-text {
  font-size: 13px;
  line-height: 1.6;
}

/* TOTALS GRID */
.totals-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: 24px;
}
.total-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
}
.total-card .val {
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 3px;
}
.total-card .lbl {
  font-family: "DM Mono", monospace;
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.total-card .sub {
  font-family: "DM Mono", monospace;
  font-size: 8px;
  color: var(--muted);
  margin-top: 2px;
}
.tc-cal .val {
  color: var(--accent2);
}
.tc-p .val {
  color: var(--protein);
}
.tc-c .val {
  color: var(--carbs);
}
.tc-f .val {
  color: var(--fat);
}
.tc-spent .val {
  color: var(--accent);
  font-size: 16px;
}
.tc-target .val {
  color: var(--muted);
  font-size: 16px;
}

/* CALORIE METER */
.cal-meter {
  position: relative;
  height: 20px;
  background: var(--surface2);
  border-radius: 6px;
  overflow: visible;
  margin-bottom: 8px;
}
.cal-fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  transition: width 0.4s ease;
  max-width: 100%;
}
.target-zone {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(24, 215, 110, 0.253);
  border-left: 2px solid #06DA1B;
  border-right: 2px solid #06DA1B;
  border-radius: 3px;
  pointer-events: none;
}
.zone-label-low,
.zone-label-high {
  position: absolute;
  bottom: -16px;
  font-family: "DM Mono", monospace;
  font-size: 9px;
  color: var(--protein);
  white-space: nowrap;
}
.zone-label-low {
  left: 0;
  transform: translateX(-50%);
}
.zone-label-high {
  right: 0;
  transform: translateX(50%);
}
.cal-scale {
  position: relative;
  height: 12px;
  font-family: "DM Mono", monospace;
  font-size: 9px;
  color: var(--muted);
  margin-top: 20px;
}
.macro-bar-wrap {
  display: flex;
  height: 14px;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 8px;
  background: var(--surface2);
}
.macro-seg {
  transition: width 0.4s ease;
}
.ms-p {
  background: var(--protein);
}
.ms-c {
  background: var(--carbs);
}
.ms-f {
  background: var(--fat);
}
.macro-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.ml-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
}
.ml-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}
.ml-val {
  font-family: "DM Mono", monospace;
  color: var(--muted);
  font-size: 10px;
}

/* SAVED / CUSTOM FOOD ITEMS */
.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  transition: opacity 0.2s;
}
.item-card.done {
  opacity: 0.5;
}
.item-card.custom-item {
  border-left: 3px solid var(--accent3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.item-card.custom-item .item-info {
  flex: 1;
  min-width: 0;
}
.item-card.custom-item .item-right {
  display: flex;
  flex-direction: row;
  gap: 6px;
  flex-shrink: 0;
  min-width: unset;
  align-items: center;
}
.serving-ctrl {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.srv-btn {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
  line-height: 1;
}
.srv-btn:hover {
  background: var(--accent);
  color: #0e0f13;
  border-color: var(--accent);
}
.srv-btn:active {
  transform: scale(0.9);
}

/* GLOBAL HALF-SERVING TOGGLE */
.half-step-toggle-wrap {
  margin-bottom: 12px;
}
.half-step-toggle {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--accent2);
  font-family: "Syne", sans-serif;
  font-size: 14px;
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.half-step-toggle:hover {
  border-color: var(--accent2);
}
.half-step-toggle.active {
  background: var(--accent2);
  color: #0e0f13;
  border-color: var(--accent2);
  box-shadow: 0 0 12px rgba(96, 200, 240, 0.45);
}
.srv-count {
  font-family: "DM Mono", monospace;
  font-size: 12px;
  font-weight: 500;
  min-width: 28px;
  text-align: center;
}
.srv-count .target {
  color: var(--muted);
  font-size: 9px;
}
.srv-count .current {
  font-size: 15px;
}
.srv-count .current.over {
  color: var(--warn);
}
.srv-count .current.met {
  color: var(--protein);
}
.srv-count .current.under {
  color: var(--accent2);
}
.item-info {
  min-width: 0;
}
.item-name {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-serving-lbl {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 5px;
}
.item-macros {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.im {
  font-family: "DM Mono", monospace;
  font-size: 10px;
}
.im-cal {
  color: var(--accent2);
}
.im-p {
  color: var(--protein);
}
.im-c {
  color: var(--carbs);
}
.im-f {
  color: var(--fat);
}
.item-right {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  min-width: 80px;
}
.item-cost-lbl {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}
.item-cost-target {
  font-family: "DM Mono", monospace;
  font-size: 9px;
  color: var(--muted);
}

/* ADD CUSTOM FOOD ACCORDION */
.add-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-top: 10px;
}
.add-section .cf-accordion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  padding: 16px 18px;
}
.add-section .cf-accordion-body {
  display: none;
  margin-top: 14px;
  padding: 0px 18px 16px 18px;
}
.add-section.open .cf-accordion-body {
  display: block;
}
.cf-accordion-chevron {
  font-size: 9px;
  color: var(--muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.add-section.open .cf-accordion-chevron {
  transform: rotate(180deg);
}

/* WEEKLY COST SECTION */
.weekly-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 24px;
}
.weekly-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.weekly-col-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.weekly-col-title .badge {
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 700;
}
.badge-target {
  background: rgba(122, 127, 150, 0.2);
  color: var(--muted);
}
.badge-actual {
  background: rgba(200, 240, 96, 0.15);
  color: var(--accent);
}
.cost-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.cost-row:last-child {
  border-bottom: none;
}
.cost-row .amt {
  font-family: "DM Mono", monospace;
}
.cost-row .amt.target-amt {
  color: var(--muted);
}
.cost-row .amt.actual-amt {
  color: var(--accent);
}
.cost-row .amt.custom-amt {
  color: var(--accent3);
}
.cost-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0 0;
  margin-top: 6px;
  border-top: 1px solid var(--border);
  font-weight: 800;
  font-size: 13px;
}
.cost-total-row .amt {
  font-family: "DM Mono", monospace;
  font-size: 16px;
}
.cost-note {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  color: var(--muted);
  margin-top: 10px;
}

/* RESET ROW */
.reset-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 40px;
  gap: 8px;
}

/* WELCOME MODAL (first run) */
.welcome-modal-box {
  max-width: 400px;
  text-align: center;
}
.welcome-modal-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 32px 40px;
  gap: 14px;
}
.welcome-wordmark {
  font-family: "Syne", sans-serif;
  font-size: 42px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -2px;
  line-height: 1;
}
.welcome-title {
  font-family: "Syne", sans-serif;
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  margin: 0;
}
.welcome-subtitle {
  font-family: "DM Mono", monospace;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
  margin: 4px 0 8px;
  max-width: 300px;
}
.welcome-start-btn {
  font-size: 13px;
  padding: 10px 28px;
  height: auto;
  align-self: center;
}

@media (max-width: 660px) {
  .macro-legend {
    flex-direction: column;
    gap: 6px;
  }
  .macro-legend .ml-item {
    display: grid;
    grid-template-columns: 8px 40px 1fr;
  }
  .totals-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .weekly-cols {
    grid-template-columns: 1fr;
  }
  .item-card {
    grid-template-columns: auto 1fr;
  }
  .item-right {
    display: none;
  }
  .item-card.custom-item .item-right {
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: stretch;
  }
  .zone-label-high,
  .zone-label-low {
    display: none;
  }
}

/* ─────────────────────────── foods page ─────────────────────────────── */
/* Foods page — info banners, saved-foods management grid, add-food choice
   modal. */

.info-banners {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 20px;
}
.info-banner {
  border-left: 3px solid transparent;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
.info-banner:not(:last-child) {
  border-bottom: 1px solid var(--border);
}
.info-banner:hover {
  background: var(--surface2);
}
.info-banner-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
}
.info-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.info-banner-label {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
}
.info-label-warn {
  color: var(--accent2);
}
.info-label-warn-2 {
  color: var(--carbs);
}
.info-label-info {
  color: var(--muted);
}
.info-banner-chevron {
  font-size: 9px;
  color: var(--muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.info-banner.open .info-banner-chevron {
  transform: rotate(180deg);
}
.info-banner-body {
  display: none;
  font-family: "DM Mono", monospace;
  padding: 0 14px 12px 32px;
  font-size: 11px;
  line-height: 1.7;
  color: var(--muted);
}
.info-banner-body strong {
  color: var(--text);
}
.info-banner.open .info-banner-body {
  display: block;
}

/* SAVED FOODS MANAGEMENT GRID */
#core-items-mgmt-list {
  margin: 12px 0px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.mgmt-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 12px 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  transition: opacity 0.2s;
}
.mgmt-card.done {
  opacity: 0.5;
}
.mgmt-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.mgmt-card-name {
  font-weight: 600;
  font-size: 12px;
  word-break: break-word;
  flex: 1;
}
.mgmt-card-status {
  font-size: 10px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-weight: 400;
}
.mgmt-card-actions {
  display: flex;
  gap: 6px;
}
.mgmt-card-top button,
.mgmt-card-actions button {
  font-family: "Syne", sans-serif;
  font-weight: 700;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.mgmt-card-actions button {
  flex: 1;
}
.mgmt-delete-btn {
  background: none;
  color: var(--muted);
}
.mgmt-delete-btn:hover {
  border-color: var(--warn) !important;
  color: var(--warn);
}
.mgmt-active-btn {
  background: none;
  color: var(--muted);
}
.mgmt-active-btn:hover {
  border-color: var(--text) !important;
  color: var(--text);
}
.mgmt-active-btn.activate-outline:hover {
  border-color: var(--protein) !important;
  color: var(--protein) !important;
}
.mgmt-edit-form-row {
  grid-column: 1 / -1;
}
.no-foods {
  grid-column: 1 / -1;
}

/* ADD FOOD CHOICE MODAL */
.choice-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.choice-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.choice-btn:hover {
  background: #22253000;
}
.choice-btn-scan:hover {
  border-color: var(--accent2);
}
.choice-btn-manual:hover {
  border-color: var(--accent);
}
.choice-btn-label {
  font-family: "Syne", sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 3px;
}
.choice-btn-desc {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: var(--muted);
}

@media (max-width: 660px) {
  #core-items-mgmt-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ─────────────────────────── weight page ────────────────────────────── */
/* Weight page — everything Weight needs (segmented toggle, meter/items
   section cards, chart container, generic buttons/forms) already lives in
   base.css. Nothing left over that's unique to this page. */

/* ─────────────────────────── programs page ─────────────────────────── */
/* Programs page — program list, program/exercise modals, step indicator,
   day sections, exercise search & form. */

.program-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s;
}
.program-card:hover {
  border-color: var(--accent);
  background: var(--surface2);
}
.program-card-info {
  flex: 1;
  min-width: 0;
}
.program-card-name {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}
.program-card-desc {
  font-size: 12px;
  font-family: "DM Mono", monospace;
  color: var(--muted);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.program-card-meta {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  color: var(--muted);
  display: flex;
  gap: 6px;
  align-items: center;
}
.program-card-meta-sep {
  color: var(--border);
}
.program-card-arrow {
  color: var(--muted);
  font-size: 20px;
  flex-shrink: 0;
  transition: color 0.15s;
}
.program-card:hover .program-card-arrow {
  color: var(--accent);
}

.pg-exercise-manage-btn:hover {
  border-color: var(--text) !important;
  color: var(--text) !important;
}
.pg-exercise-manage-btn {
  height: 30px;
}

/* STEP INDICATOR */
.pg-step-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  font-family: "DM Mono", monospace;
  font-size: 11px;
}
.pg-step {
  color: var(--muted);
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
}
.pg-step-active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(200, 240, 96, 0.08);
}
.pg-step-sep {
  color: var(--muted);
  font-size: 14px;
}

.pg-textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: "DM Mono", monospace;
  font-size: 12px;
  padding: 8px 9px;
  width: 100%;
  min-height: 80px;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
}
.pg-textarea:focus {
  border-color: var(--accent);
}
.pg-textarea::placeholder {
  color: var(--muted);
}

/* DAY SECTIONS (view modal) */
.pg-day-section {
  margin-bottom: 18px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.pg-day-section:last-child {
  margin-bottom: 0;
}
.pg-day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.pg-day-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  font-family: "Syne", sans-serif;
}
.pg-day-count {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  color: var(--muted);
}
.pg-exercise-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.pg-exercise-item:last-child {
  border-bottom: none;
}
.pg-exercise-name {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 3px;
}
.pg-exercise-meta {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: var(--muted);
}
.pg-exercise-notes {
  font-size: 11px;
  font-family: "DM Mono", monospace;
  color: var(--muted);
  margin-top: 4px;
  font-style: italic;
}

/* DAY SECTIONS (form / edit) */
.pg-day-form-section {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 14px;
  overflow: hidden;
}
.pg-day-form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
}
.pg-form-exercise-list {
  padding: 6px 0;
}
.pg-form-exercise {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
}
.pg-form-exercise:last-child {
  border-bottom: none;
}
.pg-form-exercise-info {
  flex: 1;
  min-width: 0;
}
.pg-form-exercise-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.pg-arrow-btn {
  width: 28px;
  height: 28px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
  flex-shrink: 0;
}
.pg-arrow-btn:hover {
  background: var(--surface);
  border-color: var(--muted);
}
.pg-arrow-btn-ph {
  width: 28px;
  flex-shrink: 0;
  display: none;
}
.pg-del-ex-btn {
  width: 28px;
  height: 28px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
  flex-shrink: 0;
}
.pg-del-ex-btn:hover {
  border-color: var(--warn);
  color: var(--warn);
}
.pg-empty-day {
  padding: 14px;
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}
.pg-add-day-btn {
  width: 100%;
  padding: 10px;
  background: none;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-family: "Syne", sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 4px;
}
.pg-add-day-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* EXERCISE SEARCH */
.pg-ex-search-wrap {
  margin-bottom: 16px;
  position: relative;
}
.pg-ex-search-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: "DM Mono", monospace;
  font-size: 13px;
  padding: 10px 14px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}
.pg-ex-search-input:focus {
  border-color: var(--accent);
}
.pg-ex-search-input::placeholder {
  color: var(--muted);
}
.pg-ex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.pg-ex-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s;
}
.pg-ex-card:hover {
  border-color: var(--muted);
}
.pg-ex-card-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}
.pg-ex-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  flex: 0;
}
.pg-ex-badge {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 3px;
  color: var(--muted);
}
.pg-ex-card-notes {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  color: var(--muted);
  padding: 0px 6px 0px 0px;
  flex: 1;
}
.pg-ex-add-btn {
  background: var(--accent);
  color: #0e0f13;
  border: none;
  border-radius: 6px;
  font-family: "Syne", sans-serif;
  font-size: 12px;
  font-weight: 700;
  padding: 7px 0;
  cursor: pointer;
  width: 100%;
  transition: opacity 0.15s;
}
.pg-ex-add-btn:hover {
  opacity: 0.85;
}
.pg-ex-create-card {
  border: 2px dashed var(--accent);
  cursor: pointer;
  align-items: center;
  text-align: center;
  background: rgba(200, 240, 96, 0.04);
}
.pg-ex-create-card:hover {
  background: rgba(200, 240, 96, 0.09);
}
.pg-ex-create-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(200, 240, 96, 0.15);
  color: var(--accent);
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}
.pg-ex-create-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}
.pg-ex-create-sub {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  color: var(--muted);
}

/* EXERCISE FORM GRID */
.pg-ex-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

@media (max-width: 520px) {
  .pg-ex-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ─────────────────────────── history page ───────────────────────────── */
/* History page — stats accordion (echarts), export dropdown, week/day
   breakdown tables. */

.stats-accordion-wrap {
  margin-bottom: 28px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.stats-accordion-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  background: var(--surface);
  border: none;
  cursor: pointer;
  font-family: "Syne", sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  text-align: left;
  transition: background 0.15s;
}
.stats-accordion-toggle:hover {
  background: var(--surface2);
}
.stats-accordion-chevron {
  font-size: 11px;
  color: var(--muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.stats-accordion-wrap.open .stats-accordion-chevron {
  transform: rotate(180deg);
}
.stats-accordion-body {
  display: none;
  padding: 20px 16px 16px;
  background: var(--bg);
}
.stats-accordion-wrap.open .stats-accordion-body {
  display: block;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 20px;
}
.week-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 16px;
}
.week-block:last-child {
  margin-bottom: 0;
}
.week-header {
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
  gap: 12px;
  border-radius: 10px;
}
.week-block.open .week-header {
  border-radius: 10px 10px 0 0;
}
.week-header:hover {
  background: var(--surface2);
}
.week-header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.week-label {
  font-weight: 700;
  font-size: 14px;
  font-family: "Syne", sans-serif;
}
.week-days-logged {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  color: var(--muted);
}
.week-header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}
.week-summary {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: var(--muted);
  text-align: right;
}
.week-summary span {
  color: var(--accent2);
}
.week-summary .wcost {
  color: var(--accent);
}
.week-summary-stat {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: var(--muted);
  text-align: right;
}
.week-summary-stat span {
  color: var(--accent2);
}
.week-summary-stat .wcost {
  color: var(--accent);
}
.week-chevron {
  color: var(--muted);
  font-size: 12px;
  transition: transform 0.2s;
  margin-top: 2px;
}
.week-block.open .week-chevron {
  transform: rotate(180deg);
}
.week-days {
  display: none;
  border-top: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 0 0 10px 10px;
}
.week-block.open .week-days {
  display: block;
}
.month-weeks {
  padding: 0 6px 6px 6px;
}
.days-table {
  width: 100%;
  min-width: 500px;
  border-collapse: collapse;
  font-size: 12px;
}
.days-table th {
  font-family: "DM Mono", monospace;
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 8px 12px 6px;
  background: var(--surface2);
  font-weight: 400;
  text-align: left;
  white-space: nowrap;
}
.days-table th:last-child {
  padding-right: 20px;
  text-align: right;
}
.days-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
}
.days-table td:last-child {
  padding-right: 20px;
}
.days-table tr:last-child td {
  border-bottom: none;
}
.days-table tr.week-total-row {
  background: var(--surface2);
  font-weight: 700;
}
.week-total-label {
  font-family: "Syne", sans-serif;
}
.day-date {
  font-weight: 700;
  font-family: "Syne", sans-serif;
}
.day-cal {
  color: var(--accent2);
  font-family: "DM Mono", monospace;
}
.day-p {
  color: var(--protein);
  font-family: "DM Mono", monospace;
}
.day-c {
  color: var(--carbs);
  font-family: "DM Mono", monospace;
}
.day-f {
  color: var(--fat);
  font-family: "DM Mono", monospace;
}
.day-cost {
  color: var(--accent);
  font-family: "DM Mono", monospace;
  font-weight: 700;
  text-align: right;
}
.in-range {
  color: var(--protein);
  font-size: 9px;
  font-family: "DM Mono", monospace;
}
.out-range {
  color: var(--warn);
  font-size: 9px;
  font-family: "DM Mono", monospace;
}
.partial-week-badge {
  font-size: 10px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  margin-left: 4px;
}

/* Overview chart sizing (promoted out of index.html's old inline <style>) */
.echart-macros {
  min-width: 260px;
  max-width: 340px;
  height: 240px;
}
@media (max-width: 600px) {
  .echart-macros {
    min-width: 0;
    max-width: 100vw;
    height: 260px;
  }
}

/* ─────────────────────────── settings page ──────────────────────────── */
/* Settings page */

.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 16px;
  overflow: hidden;
}
.settings-section-title {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.settings-section-body {
  padding: 14px 16px;
}
.settings-desc {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 12px;
}
