.lock { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: grid; place-items: center; padding: 16px; }
.lock[hidden] { display: none; }
.lock-card { width: min(360px, 100%); padding: 24px; display: grid; gap: 12px; text-align: center; }
.lock-card .logo { font-size: 40px; }
.lock-card p { margin: 0; font-size: 14px; }
.lock-card input { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; text-align: center; font-size: 16px; }
.lock-err { color: var(--warn); }
body { padding-bottom: env(safe-area-inset-bottom); }
.top { padding-top: env(safe-area-inset-top); }

:root {
  --bg: #f6f7f4;
  --card: #ffffff;
  --ink: #1b1f1a;
  --muted: #687064;
  --line: #e3e6df;
  --accent: #2f7d4f;
  --accent-ink: #ffffff;
  --accent-soft: #e4f2e8;
  --warn: #b4531a;
  --warn-soft: #fbeadf;
  --vegan: #2f7d4f;
  --veg: #6c8a1f;
  --fish: #2563a8;
  --meat: #a4473b;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111411; --card: #1a1e1a; --ink: #e8ebe6; --muted: #9aa396; --line: #2b302a;
    --accent: #5cc285; --accent-ink: #0d1a12; --accent-soft: #1d3326;
    --warn: #f0995e; --warn-soft: #3a2518;
    --vegan: #5cc285; --veg: #b5cf5c; --fish: #6aa8ee; --meat: #ee8a7d;
    --shadow: none; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 Inter, system-ui, -apple-system, sans-serif;
}
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
a { color: var(--accent); }
.muted { color: var(--muted); }
button { font: inherit; cursor: pointer; }

.top { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top-inner { display: flex; align-items: center; justify-content: space-between; padding-block: 12px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 28px; }
.brand h1 { font-size: 18px; }
.sub { margin: 0; font-size: 13px; color: var(--muted); }
.pill { font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.pill.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill.off { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.controls { margin-top: 16px; padding: 16px; display: grid; gap: 14px; }
.ctrl { display: grid; gap: 6px; min-width: 0; }
.ctrl > label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.ctrl-row { display: flex; flex-wrap: wrap; gap: 14px 24px; }

.seg { display: flex; flex-wrap: wrap; gap: 4px; background: var(--bg); padding: 4px; border-radius: 10px; width: fit-content; max-width: 100%; }
.seg button { border: 0; background: transparent; color: var(--ink); padding: 6px 12px; border-radius: 7px; font-weight: 500; }
.seg button.active { background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.12); color: var(--accent); font-weight: 600; }
.seg button:disabled { opacity: .4; cursor: not-allowed; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 5px 12px; border-radius: 999px; font-size: 13px; }
.chips button.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.money { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 9px; padding: 0 10px; background: var(--card); width: 120px; }
.money input { border: 0; background: transparent; color: var(--ink); font: inherit; padding: 7px 6px; width: 100%; outline: none; }

.days { display: flex; gap: 8px; margin: 20px 0 12px; overflow-x: auto; }
.days button { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 12px; padding: 10px 16px; text-align: left; min-width: 150px; }
.days button b { display: block; font-size: 15px; }
.days button span { font-size: 13px; color: var(--muted); }
.days button.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.stat { padding: 14px 16px; }
.stat .k { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 26px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .d { font-size: 13px; color: var(--muted); margin-top: 2px; }
.stat.hero { background: var(--accent-soft); border-color: transparent; }
.stat.hero .v { color: var(--accent); }

.ai { margin-top: 16px; padding: 16px; }
.ai-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.ai-head h2 { font-size: 17px; }
.ai-head p { margin: 2px 0 0; font-size: 13px; }
.primary { background: var(--accent); color: var(--accent-ink); border: 0; padding: 9px 18px; border-radius: 9px; font-weight: 600; }
.primary:disabled { opacity: .5; cursor: wait; }
.picks { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; margin-top: 14px; }
.pick { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: grid; gap: 10px; align-content: start; }
.pick-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.pick h3 { font-size: 15px; }
.pick .total { font-size: 22px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.pick .total.over { color: var(--warn); }
.pick ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 14px; }
.pick li { display: flex; justify-content: space-between; gap: 10px; }
.pick li span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pick .why { font-size: 13px; color: var(--muted); margin: 0; }
.macros { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; }
.macros span { background: var(--bg); padding: 3px 8px; border-radius: 6px; }
.score { font-size: 12px; font-weight: 600; }
.tip { margin: 12px 0 0; font-size: 13px; padding: 10px 12px; background: var(--bg); border-radius: 9px; }
.notice.info { background: var(--accent-soft); color: var(--accent); }
.notice { margin-top: 12px; font-size: 13px; padding: 10px 12px; border-radius: 9px; background: var(--warn-soft); color: var(--warn); }

.add { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 7px; padding: 3px 10px; font-size: 12px; font-weight: 600; margin-left: auto; }
.add.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.ghost { border: 1px solid var(--accent); background: transparent; color: var(--accent); border-radius: 8px; padding: 6px 12px; font-size: 13px; font-weight: 600; justify-self: start; }

.calc { margin-top: 16px; padding: 16px; display: grid; gap: 16px; }
.calc-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: end; }
.calc-head h2 { font-size: 17px; }
.calc-head p { margin: 2px 0 0; font-size: 13px; }
.calc-settings { display: flex; gap: 12px; flex-wrap: wrap; }
.calc-settings label { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.calc-settings input { font: inherit; color: var(--ink); }
.calc-settings > label > input { width: 90px; border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; background: var(--card); }
.calc-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 16px; }
@media (max-width: 760px) { .calc-grid { grid-template-columns: 1fr; } }
.tray { border: 1px dashed var(--line); border-radius: 12px; padding: 12px 14px; display: grid; gap: 8px; align-content: start; }
.tray h3, .plans-t h3, .month h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.tray ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 14px; }
.tray li { display: flex; gap: 8px; align-items: center; }
.tray li .n { flex: 1; min-width: 0; }
.tray li .p { font-variant-numeric: tabular-nums; color: var(--muted); }
.x { border: 0; background: transparent; color: var(--muted); font-size: 16px; line-height: 1; padding: 0 2px; }
.tray .sum { display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 8px; font-weight: 700; }
.tray .sum span:last-child { color: var(--accent); font-size: 18px; }
table.plans { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.plans th, .plans td { text-align: right; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.plans th:first-child, .plans td:first-child { text-align: left; }
.plans th { font-size: 12px; color: var(--muted); font-weight: 600; }
.plans td small { display: block; color: var(--muted); font-size: 12px; }
.plans tr.you td { font-weight: 700; }
.over-b { color: var(--warn); }
.ok-b { color: var(--accent); }
.month { display: grid; gap: 10px; }
.bar { height: 10px; border-radius: 999px; background: var(--bg); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.bar.over > i { background: var(--warn); }
.mstats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.mstats div { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.mstats b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.mstats span { font-size: 12px; color: var(--muted); }

#menu { margin-top: 20px; display: grid; gap: 22px; }
.group h2 { font-size: 15px; margin-bottom: 10px; display: flex; gap: 8px; align-items: baseline; }
.group h2 small { color: var(--muted); font-weight: 500; font-size: 13px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.item { padding: 12px 14px; display: grid; gap: 6px; align-content: start; }
.item.dim { opacity: .45; }
.item.pickd { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.item-top { display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.item .name { font-weight: 600; }
.item .orig { font-size: 12px; color: var(--muted); }
.price { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.price small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); text-align: right; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; }
.diet { font-weight: 600; padding: 2px 8px; border-radius: 999px; border: 1px solid currentColor; }
.diet.vegan { color: var(--vegan); } .diet.vegetarian { color: var(--veg); }
.diet.fish { color: var(--fish); } .diet.meat { color: var(--meat); }
.nut { color: var(--muted); }
details { font-size: 12px; color: var(--muted); }
details summary { cursor: pointer; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.skeleton { height: 76px; background: linear-gradient(90deg, var(--line), var(--card), var(--line)); background-size: 200% 100%; animation: sh 1.2s infinite; border-radius: 14px; }
@keyframes sh { to { background-position: -200% 0; } }
.foot { font-size: 12px; padding: 28px 0 40px; }

@media (max-width: 560px) {
  .stat .v { font-size: 22px; }
  .days button { min-width: 130px; }
}

/* ---------- views ---------- */
.views { display: flex; gap: 6px; margin-top: 16px; overflow-x: auto; }
.views button { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px; padding: 8px 16px; font-weight: 600; white-space: nowrap; }
.views button.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.view[hidden] { display: none; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 10px; }

/* ---------- tracker ---------- */
.tracker-head { margin: 20px 0 12px; padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; }
.tracker-head h2 { font-size: 18px; }
.nav-btn { border: 1px solid var(--line); background: var(--card); color: var(--ink); width: 36px; height: 36px; border-radius: 9px; font-size: 20px; line-height: 1; }
.chart-card { margin-top: 12px; padding: 14px 16px; }
.chart-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.chart-top h3 { margin: 0; }
.chart { position: relative; margin-top: 10px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--accent); }
.chart .bar.over { fill: var(--warn); }
.chart .bar.future { fill: var(--line); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .bar.hl { opacity: .75; }
.chart .ref { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 4; fill: none; }
.chart .ref-label { fill: var(--muted); font-size: 11px; }
.chart .line-you { stroke: var(--accent); stroke-width: 2; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.chart .line-pace { stroke: var(--muted); stroke-width: 2; stroke-dasharray: 5 5; fill: none; }
.chart .dot { fill: var(--accent); stroke: var(--card); stroke-width: 2; }
.chart .cross { stroke: var(--muted); stroke-width: 1; }
.chart .direct { font-size: 11px; font-weight: 600; fill: var(--ink); }
.tooltip { position: absolute; pointer-events: none; background: var(--ink); color: var(--bg); font-size: 12px; padding: 6px 9px; border-radius: 7px; white-space: nowrap; transform: translate(-50%, -100%); margin-top: -8px; z-index: 2; }
.tooltip b { font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 16px; height: 0; border-top: 2px solid var(--accent); }
.sw.pace { border-top: 2px dashed var(--muted); }
.link { border: 0; background: none; color: var(--accent); font-size: 13px; font-weight: 600; padding: 0; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; margin-top: 10px; }
table.data th, table.data td { text-align: right; padding: 6px; border-bottom: 1px solid var(--line); }
table.data th:first-child, table.data td:first-child { text-align: left; }
.tracker-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 12px; margin-top: 12px; }
.tracker-grid > .card { padding: 14px 16px; }
@media (max-width: 760px) { .tracker-grid { grid-template-columns: 1fr; } }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal .dow { font-size: 11px; color: var(--muted); text-align: center; font-weight: 600; padding-bottom: 2px; }
.cal button { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 8px; min-height: 52px; padding: 4px; display: grid; align-content: space-between; text-align: left; font-size: 12px; }
.cal button .num { font-weight: 600; }
.cal button .amt { font-size: 11px; color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.cal button.weekend { background: var(--bg); color: var(--muted); }
.cal button.today { border-color: var(--ink); }
.cal button.sel { box-shadow: inset 0 0 0 2px var(--accent); }
.cal button.has { background: var(--accent-soft); }
.cal .blank { min-height: 52px; }
.dl { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 14px; }
.dl li { display: flex; justify-content: space-between; gap: 10px; }
.dl li span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.dl li.tot { border-top: 1px solid var(--line); padding-top: 6px; font-weight: 700; }
.dl li.tot span:last-child { color: var(--ink); }

/* ---------- week plan ---------- */
.week-head { margin-top: 20px; padding: 16px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: end; }
.week-head h2 { font-size: 17px; }
.week-head p { margin: 2px 0 0; font-size: 13px; }
.week-ctrl { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.week-ctrl label { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.week-summary { margin-top: 12px; }
.week-days { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; margin-top: 12px; }
.wday { padding: 14px; display: grid; gap: 8px; align-content: start; }
.wday .when { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.wday h4 { margin: 0; font-size: 15px; }
.wmeal { display: grid; gap: 6px; padding-top: 8px; border-top: 1px solid var(--line); }
.wmeal:first-of-type { border-top: 0; padding-top: 0; }
.wmeal .mt { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.wmeal .mt span { font-weight: 700; font-variant-numeric: tabular-nums; }
.wmeal .tag { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.prelim { font-size: 11px; font-weight: 600; color: var(--warn); background: var(--warn-soft); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.loc { font-size: 12px; color: var(--muted); }
.wday .total { font-size: 20px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
