/* =========================================================================
   Meal Mate — design tokens
   Concept: a market ledger. Dark "stall counter" sidebar + warm paper
   content area, receipt/ticket motifs throughout (dashed rules, perforation
   dots, a literal thermal-receipt shopping list). Mono numerals everywhere
   money or macros appear, to read like a till rather than a brochure.
   ========================================================================= */
:root{
  --ink:        #20281F;
  --shell-dark: #1F2A22;
  --shell-dark-2:#283627;
  --paper:      #FBF7EE;
  --paper-dim:  #F1EAD9;
  --line:       #DDD3BC;
  --maize:      #E8A33D;
  --maize-ink:  #5A3C0E;
  --greens:     #4C7A52;
  --greens-dim: #DCE8DD;
  --clay:       #B5482B;
  --clay-dim:   #F6DDD4;
  --muted:      #6B6657;

  --display: 'Space Grotesk', system-ui, sans-serif;
  --body:    'Inter', system-ui, sans-serif;
  --mono:    'JetBrains Mono', ui-monospace, monospace;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family:var(--body);
  color:var(--ink);
  background:var(--shell-dark);
  -webkit-font-smoothing:antialiased;
}
button, input, select{ font-family:inherit; }

/* ---------------------------------------------------------------- shell */
.shell{
  display:flex;
  min-height:100vh;
}

/* ---------------------------------------------------------------- sidebar */
.sidebar{
  width:260px;
  flex-shrink:0;
  background:
    linear-gradient(180deg, var(--shell-dark) 0%, var(--shell-dark-2) 100%);
  color:#EFE9D8;
  padding:28px 22px;
  display:flex;
  flex-direction:column;
  position:sticky;
  top:0;
  height:100vh;
}
.brand{ display:flex; align-items:center; gap:10px; }
.brand-mark{
  font-family:var(--mono);
  font-weight:700;
  font-size:13px;
  background:var(--maize);
  color:var(--maize-ink);
  width:34px; height:34px;
  border-radius:8px;
  display:flex; align-items:center; justify-content:center;
}
.brand-name{ font-family:var(--display); font-weight:600; font-size:19px; letter-spacing:-0.01em; }
.brand-tag{ font-family:var(--mono); font-size:11px; color:#A9A28C; margin:6px 0 28px; letter-spacing:.02em; }

.steps{ display:flex; flex-direction:column; gap:4px; flex:1; }
.step{
  display:flex; align-items:center; gap:12px;
  background:none; border:none; cursor:pointer;
  color:#C9C2AC;
  text-align:left;
  padding:11px 10px;
  border-radius:8px;
  border-left:2px solid transparent;
  opacity:.55;
  transition:opacity .15s ease, background .15s ease;
}
.step:not(.locked):hover{ opacity:.85; background:rgba(255,255,255,0.04); }
.step.active{
  opacity:1;
  background:rgba(232,163,61,0.12);
  border-left:2px solid var(--maize);
  color:#FBF7EE;
}
.step.done .step-n{ color:var(--greens); }
.step.locked{ cursor:not-allowed; }
.step-n{ font-family:var(--mono); font-size:11px; color:#8C8670; width:18px; }
.step-label{ font-size:13.5px; font-weight:500; }

.sidebar-foot{ margin-top:auto; padding-top:18px; border-top:1px dashed #44503F; }
.user-badge{ display:flex; align-items:center; gap:8px; font-size:13px; margin-bottom:10px; color:#EFE9D8; }
.user-badge .dot{ width:7px; height:7px; border-radius:50%; background:var(--greens); }
.meta{ font-family:var(--mono); font-size:10.5px; color:#7E7861; margin:10px 0 0; }

.ghost-btn{
  background:transparent;
  border:1px solid #44503F;
  color:#D8D2BC;
  padding:8px 12px;
  border-radius:7px;
  font-size:12.5px;
  cursor:pointer;
  transition:border-color .15s ease, color .15s ease;
}
.ghost-btn:hover{ border-color:var(--maize); color:var(--maize); }

.hidden{ display:none !important; }

/* ---------------------------------------------------------------- main */
.main{
  flex:1;
  background:var(--paper-dim);
  min-height:100vh;
  padding:44px 48px 80px;
}
.screen{ display:none; max-width:880px; margin:0 auto; animation:fadeIn .25s ease; }
.screen.active{ display:block; }
@keyframes fadeIn{ from{ opacity:0; transform:translateY(6px);} to{opacity:1; transform:translateY(0);} }

.screen-head{
  display:flex; justify-content:space-between; align-items:flex-end;
  margin-bottom:22px; gap:16px; flex-wrap:wrap;
}
.screen-head h1{ font-family:var(--display); font-size:26px; margin:0 0 4px; letter-spacing:-0.01em; }
.screen-head p{ margin:0; color:var(--muted); font-size:14px; }
.screen-foot{ margin-top:28px; display:flex; justify-content:flex-end; }

h1{ font-family:var(--display); }

/* ---------------------------------------------------------------- card */
.receipt-card{
  background:var(--paper);
  border:1px solid var(--line);
  border-radius:14px;
  padding:36px;
  position:relative;
}
.receipt-card.narrow{ max-width:440px; margin:60px auto; }
.card-head h1{ font-size:24px; margin:0 0 6px; }
.card-head p{ margin:0 0 22px; color:var(--muted); font-size:14px; }

/* perforation accent along card top */
.receipt-card::before{
  content:"";
  position:absolute; top:0; left:24px; right:24px; height:1px;
  background:repeating-linear-gradient(90deg, var(--line) 0 6px, transparent 6px 12px);
}

/* ---------------------------------------------------------------- forms */
.tabs{ display:flex; gap:4px; margin-bottom:20px; background:var(--paper-dim); border-radius:9px; padding:4px; }
.tab{
  flex:1; padding:9px; border:none; background:transparent; border-radius:6px;
  cursor:pointer; font-size:13.5px; font-weight:500; color:var(--muted);
}
.tab.active{ background:var(--paper); color:var(--ink); box-shadow:0 1px 2px rgba(0,0,0,.06); }

.form-panel, .form-grid{ display:flex; flex-direction:column; gap:16px; }
.form-grid{ display:grid; grid-template-columns:1fr 1fr; gap:18px 20px; }
.form-grid .form-actions{ grid-column:1 / -1; margin-top:6px; }

label{ font-size:13px; font-weight:500; color:var(--ink); display:flex; flex-direction:column; gap:6px; }
input, select{
  border:1px solid var(--line);
  background:#fff;
  border-radius:8px;
  padding:10px 12px;
  font-size:14px;
  color:var(--ink);
  outline:none;
}
input:focus, select:focus{ border-color:var(--maize); box-shadow:0 0 0 3px rgba(232,163,61,.18); }

.primary-btn{
  background:var(--ink);
  color:var(--paper);
  border:none;
  padding:12px 18px;
  border-radius:8px;
  font-size:14.5px;
  font-weight:600;
  cursor:pointer;
  transition:transform .1s ease, background .15s ease;
}
.primary-btn:hover{ background:#37412F; }
.primary-btn:active{ transform:scale(.98); }
.primary-btn.wide{ width:100%; }

.hint{ font-size:12px; color:var(--muted); margin:0; }
.form-error{ color:var(--clay); font-size:13px; min-height:18px; margin:14px 0 0; }

/* ---------------------------------------------------------------- budget strip */
.budget-strip{
  display:flex; gap:24px; flex-wrap:wrap;
  background:var(--paper); border:1px solid var(--line); border-radius:12px;
  padding:16px 22px; margin-bottom:22px;
}
.budget-item{ display:flex; flex-direction:column; gap:3px; }
.budget-item .label{ font-size:11.5px; text-transform:uppercase; letter-spacing:.04em; color:var(--muted); }
.budget-item .value{ font-family:var(--mono); font-size:18px; font-weight:700; }
.budget-item .value.over{ color:var(--clay); }
.budget-item .value.under{ color:var(--greens); }

/* ---------------------------------------------------------------- day grid */
.day-grid{ display:grid; grid-template-columns:repeat(auto-fill, minmax(230px,1fr)); gap:14px; }
.day-ticket{
  background:var(--paper); border:1px solid var(--line); border-radius:12px;
  padding:16px 16px 14px; position:relative; overflow:hidden;
}
.day-ticket::after{
  content:"";
  position:absolute; left:0; right:0; bottom:34px; height:1px;
  background:repeating-linear-gradient(90deg, var(--line) 0 5px, transparent 5px 10px);
}
.day-ticket .day-name{ font-family:var(--display); font-weight:600; font-size:15px; margin-bottom:10px; }
.meal-row{ display:flex; justify-content:space-between; gap:8px; padding:5px 0; font-size:12.8px; }
.meal-row .slot{ color:var(--muted); text-transform:capitalize; min-width:64px; }
.meal-row .name{ font-weight:500; text-align:right; }
.day-cost{
  margin-top:14px; padding-top:12px;
  display:flex; justify-content:space-between; align-items:center;
  font-family:var(--mono);
}
.day-cost .tag{
  background:var(--maize); color:var(--maize-ink);
  padding:3px 9px; border-radius:20px; font-size:12px; font-weight:700;
}

/* ---------------------------------------------------------------- receipt (shopping list) */
.receipt-wrap{ display:flex; justify-content:center; }
.receipt{
  font-family:var(--mono);
  background:#fff;
  width:380px;
  max-width:100%;
  padding:26px 24px 36px;
  box-shadow:0 14px 30px rgba(0,0,0,.18);
  position:relative;
  clip-path: polygon(
    0% 0%, 100% 0%, 100% 96%,
    96% 100%, 92% 96%, 88% 100%, 84% 96%, 80% 100%, 76% 96%, 72% 100%,
    68% 96%, 64% 100%, 60% 96%, 56% 100%, 52% 96%, 48% 100%, 44% 96%,
    40% 100%, 36% 96%, 32% 100%, 28% 96%, 24% 100%, 20% 96%, 16% 100%,
    12% 96%, 8% 100%, 4% 96%, 0% 100%
  );
}
.receipt-title{ text-align:center; font-weight:700; font-size:14px; letter-spacing:.06em; margin-bottom:2px; }
.receipt-sub{ text-align:center; font-size:10.5px; color:var(--muted); margin-bottom:16px; }
.receipt-divider{ border:none; border-top:1px dashed #bbb; margin:12px 0; }
.receipt-cat{ font-size:10.5px; font-weight:700; letter-spacing:.05em; color:var(--greens); margin:14px 0 6px; }
.receipt-line{ display:flex; justify-content:space-between; font-size:12px; padding:3px 0; gap:8px; }
.receipt-line .name{ flex:1; }
.receipt-line .qty{ color:var(--muted); white-space:nowrap; }
.receipt-line .cost{ width:64px; text-align:right; }
.receipt-total{ display:flex; justify-content:space-between; font-size:15px; font-weight:700; margin-top:16px; }
.receipt-footnote{ text-align:center; font-size:9.5px; color:var(--muted); margin-top:18px; }

/* ---------------------------------------------------------------- nutrition */
.nutrition-rings{ display:flex; gap:18px; flex-wrap:wrap; margin-bottom:24px; }
.ring-card{
  background:var(--paper); border:1px solid var(--line); border-radius:12px;
  padding:18px; flex:1; min-width:180px;
  display:flex; align-items:center; gap:14px;
}
.ring-card svg{ flex-shrink:0; }
.ring-label{ font-size:12px; color:var(--muted); margin-bottom:2px; }
.ring-value{ font-family:var(--mono); font-size:18px; font-weight:700; }
.ring-target{ font-family:var(--mono); font-size:11px; color:var(--muted); }

.chart-title{ font-family:var(--display); font-size:15px; margin:0 0 16px; }
.bar-chart{ display:flex; align-items:flex-end; gap:14px; height:170px; padding:0 4px; }
.bar-col{ flex:1; display:flex; flex-direction:column; align-items:center; gap:8px; height:100%; justify-content:flex-end; }
.bar{ width:100%; max-width:34px; background:var(--greens); border-radius:5px 5px 2px 2px; position:relative; }
.bar.over{ background:var(--clay); }
.bar-cal{ font-family:var(--mono); font-size:10px; color:var(--muted); }
.bar-day{ font-size:11px; color:var(--muted); }

/* ---------------------------------------------------------------- toast */
.toast{
  position:fixed; bottom:24px; left:50%; transform:translateX(-50%) translateY(20px);
  background:var(--ink); color:var(--paper);
  padding:11px 18px; border-radius:8px; font-size:13px;
  opacity:0; pointer-events:none; transition:opacity .2s ease, transform .2s ease;
  z-index:50;
}
.toast.show{ opacity:1; transform:translateX(-50%) translateY(0); }
.toast.error{ background:var(--clay); }

/* ---------------------------------------------------------------- risk panel (Pillar 5) */
.risk-panel{ display:flex; flex-direction:column; gap:8px; margin-bottom:24px; }
.risk-item{
  display:flex; align-items:flex-start; gap:10px;
  padding:12px 14px; border-radius:9px; font-size:13px; line-height:1.4;
  border:1px solid var(--line);
}
.risk-item .dot{ width:8px; height:8px; border-radius:50%; margin-top:4px; flex-shrink:0; }
.risk-item.warning{ background:var(--clay-dim); border-color:#e0b6a8; }
.risk-item.warning .dot{ background:var(--clay); }
.risk-item.info{ background:#FBF0DC; border-color:#ecd6a8; }
.risk-item.info .dot{ background:var(--maize); }
.risk-item.ok{ background:var(--greens-dim); border-color:#bcd6bd; }
.risk-item.ok .dot{ background:var(--greens); }

/* ---------------------------------------------------------------- meal preference buttons */
.meal-row{ position:relative; }
.meal-actions{ display:flex; gap:3px; margin-left:6px; }
.pref-btn{
  background:none; border:1px solid var(--line); border-radius:5px;
  width:20px; height:20px; line-height:1; font-size:11px; cursor:pointer;
  color:var(--muted); flex-shrink:0; padding:0;
  display:flex; align-items:center; justify-content:center;
}
.pref-btn:hover{ border-color:var(--ink); color:var(--ink); }
.pref-btn.active.like{ background:var(--greens); border-color:var(--greens); color:#fff; }
.pref-btn.active.dislike{ background:var(--clay); border-color:var(--clay); color:#fff; }
.meal-row-top{ display:flex; align-items:center; justify-content:space-between; gap:6px; }

/* ---------------------------------------------------------------- analytics screen */
.analytics-tabs{ max-width:420px; margin-bottom:20px; }
.analytics-panel.hidden{ display:none; }
.stat-grid{ display:grid; grid-template-columns:repeat(auto-fit, minmax(190px,1fr)); gap:14px; margin-bottom:20px; }
.stat-card{ background:var(--paper); border:1px solid var(--line); border-radius:12px; padding:16px 18px; }
.stat-card .label{ font-size:11.5px; text-transform:uppercase; letter-spacing:.04em; color:var(--muted); margin-bottom:6px; }
.stat-card .value{ font-family:var(--mono); font-size:22px; font-weight:700; }
.stat-card .sub{ font-size:11.5px; color:var(--muted); margin-top:4px; }

.popular-list{ background:var(--paper); border:1px solid var(--line); border-radius:12px; padding:8px 0; margin-bottom:20px; }
.popular-row{ display:flex; justify-content:space-between; align-items:center; padding:11px 18px; border-bottom:1px dashed var(--line); font-size:13.5px; }
.popular-row:last-child{ border-bottom:none; }
.popular-row .rank{ font-family:var(--mono); color:var(--muted); margin-right:10px; }
.popular-row .count{ font-family:var(--mono); background:var(--paper-dim); padding:3px 9px; border-radius:20px; font-size:11.5px; }

.flag-list{ display:flex; flex-direction:column; gap:8px; margin-bottom:20px; }
.flag-row{ display:flex; justify-content:space-between; gap:10px; background:var(--clay-dim); border:1px solid #e0b6a8; border-radius:9px; padding:10px 14px; font-size:12.8px; }
.flag-row .count{ font-family:var(--mono); font-weight:700; flex-shrink:0; }

.analytics-note{ font-size:12px; color:var(--muted); font-style:italic; margin:6px 0 0; }
.section-label{ font-family:var(--display); font-size:14.5px; margin:22px 0 10px; }
.section-label:first-child{ margin-top:0; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 820px){
  .shell{ flex-direction:column; }
  .sidebar{ width:100%; height:auto; position:relative; padding:18px 20px; }
  .steps{ flex-direction:row; overflow-x:auto; gap:6px; }
  .step{ flex-direction:column; gap:2px; padding:8px 10px; border-left:none; border-bottom:2px solid transparent; }
  .step.active{ border-left:none; border-bottom:2px solid var(--maize); }
  .sidebar-foot{ display:none; }
  .main{ padding:26px 18px 60px; }
  .form-grid{ grid-template-columns:1fr; }
}

/* ---------------------------------------------------------------- a11y */
button:focus-visible, input:focus-visible, select:focus-visible{
  outline:2px solid var(--maize); outline-offset:2px;
}
@media (prefers-reduced-motion: reduce){
  .screen{ animation:none; }
  *{ transition:none !important; }
}
