:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f0efe9;
  --text: #1d1f1c;
  --muted: #676b63;
  --border: #e0ded5;
  --accent: #1d7a4c;
  --accent-soft: #e3f2ea;
  --warn: #b4461b;
  --warn-soft: #fbe9e1;
  --meat: #b23a3a;
  --dairy: #2f6db3;
  --parve: #6b7a2c;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151714; --surface: #1e211d; --surface-2: #262a25; --text: #ecede8; --muted: #a3a89d;
    --border: #343932; --accent: #4fbf85; --accent-soft: #1f3a2b; --warn: #f08a5d; --warn-soft: #3b261c;
    --meat: #e07a7a; --dairy: #7aaee8; --parve: #b5c46b;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Hebrew", Arial, sans-serif;
}
[dir=rtl] .he { color: inherit; }
.he { font-family: "Noto Sans Hebrew", "Segoe UI", Arial, sans-serif; direction: rtl; unicode-bidi: isolate; color: var(--muted); font-weight: 400; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--surface); }
.brand { display: flex; align-items: center; gap: 12px; }
.logo { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 700; font-size: 18px; }
.brand h1 { margin: 0; font-size: 20px; }
.brand p { margin: 0; color: var(--muted); font-size: 13px; }

.layout { display: grid; grid-template-columns: 330px 1fr; gap: 20px; padding: 20px 24px; max-width: 1400px; margin: 0 auto; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; padding: 16px; } }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); align-self: start; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
@media (max-width: 900px) { .panel { position: static; max-height: none; } }
.panel section { padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 8px; }
.panel h3 { font-size: 13px; margin: 10px 0 6px; color: var(--muted); font-weight: 500; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 6px 0; }
input[type=number], select { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; }
input[type=number] { width: 90px; }
select[name=diet] { width: 100%; margin-bottom: 8px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.check { display: block; margin-top: 10px; }
.check small { color: var(--muted); display: block; margin-inline-start: 22px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips.small { margin-top: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-block; padding: 5px 10px; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; background: var(--surface); font-size: 13px; user-select: none; }
.chips.small .chip span { font-size: 12px; padding: 3px 8px; }
.chip input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.seg { display: flex; margin-top: 8px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; text-align: center; padding: 6px 4px; font-size: 13px; cursor: pointer; }
.seg label + label span { border-inline-start: 1px solid var(--border); }
.seg input:checked + span { background: var(--accent); color: #fff; font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }

details { margin-bottom: 12px; }
summary { cursor: pointer; font-weight: 600; font-size: 14px; }
button { font: inherit; cursor: pointer; }
.primary { width: 100%; padding: 11px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 700; font-size: 15px; }
.primary:hover { filter: brightness(1.07); }
.ghost { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.ghost:hover { border-color: var(--accent); color: var(--accent); }

main { min-width: 0; }
.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
@media (max-width: 700px) { .summary { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--muted); font-size: 12px; }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; margin-top: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.over .bar > i { background: var(--warn); }
.over .value { color: var(--warn); }
.alert { background: var(--warn-soft); color: var(--warn); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tabs button { border: 0; background: none; padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; }
.tabs button[aria-selected=true] { color: var(--accent); border-bottom-color: var(--accent); }

.week { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.day { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.day.shabbat { border-color: #c9a227; }
.day h3 { margin: 0 0 8px; font-size: 15px; display: flex; justify-content: space-between; }
.meal { padding: 8px 0; border-top: 1px dashed var(--border); }
.meal-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.meal-note { font-size: 11px; color: #a07f12; }
.recipe-link { display: block; text-align: start; border: 0; background: none; padding: 2px 0; color: var(--text); font-weight: 600; width: 100%; }
.recipe-link:hover { color: var(--accent); }
.recipe-link .he { display: block; font-size: 12px; text-align: end; }
.meta { display: flex; gap: 6px; align-items: center; font-size: 11px; color: var(--muted); }
.swap { border: 0; background: none; color: var(--muted); font-size: 12px; padding: 8px 10px; margin: -8px -10px; min-height: 36px; }
.swap:hover { color: var(--accent); }

.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; border: 1px solid currentColor; }
.badge.meat { color: var(--meat); }
.badge.dairy { color: var(--dairy); }
.badge.parve { color: var(--parve); }
.badge.tag { color: var(--muted); }
.badge.nk { color: var(--warn); }

.list-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.store-group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; box-shadow: var(--shadow); overflow: hidden; }
.store-group > header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--surface-2); font-weight: 700; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-inline-end: 8px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
td, th { padding: 7px 14px; border-top: 1px solid var(--border); text-align: start; font-size: 14px; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; }
td.num, th.num { text-align: end; }
tr.cat td { background: var(--surface); color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding-top: 12px; }
tr.done td { text-decoration: line-through; color: var(--muted); }
.leftover { color: var(--muted); font-size: 12px; }
.top-actions { display: flex; gap: 8px; }
.feedback { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.feedback label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.feedback label.check, .feedback .chip { flex-direction: row; display: inline-flex; align-items: center; }
.feedback textarea, .feedback input[type=text] { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.feedback fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.feedback legend { font-size: 14px; margin-bottom: 6px; padding: 0; }
.fb-status { color: var(--warn); margin: 0; min-height: 1em; }
ul.privacy li { margin-bottom: 8px; }
a { color: var(--accent); }
main.stale .week, main.stale .tabpanel table, main.stale .compare { opacity: .45; }
.stale-note { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.alt.over-repeat { opacity: .6; }
.repeat-note { display: block; color: var(--warn); font-size: 11px; }
@media (max-width: 700px) {
  .swap { min-height: 44px; min-width: 64px; font-size: 13px; }
  .recipe-link { padding: 8px 0; min-height: 44px; }
  .chip span { padding: 9px 12px; }
  .chips.small .chip span { padding: 7px 10px; font-size: 13px; }
  .branch-select, select, input[type=number] { min-height: 40px; }
  td, th { padding: 7px 8px; }
}
.hint { display: block; color: var(--muted); font-size: 11px; margin-top: 6px; line-height: 1.35; }
.chip-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 4px 10px; font-size: 12px; }
.chip-btn:hover { border-color: var(--warn); color: var(--warn); }
.fav { color: #d6336c; }
.day-kcal { font-size: 11px; color: var(--muted); margin: -4px 0 6px; }
.recipe-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 10px; }
.recipe-actions .on { border-color: #d6336c; color: #d6336c; }
.nutrition { font-size: 13px; background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.cart-bar { position: sticky; bottom: 0; margin-top: 12px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); font-weight: 600; text-align: center; }
.cart-bar.complete { border-color: var(--accent); color: var(--accent); }
@media print { .cart-bar { display: none; } }
#cityRow select { max-width: 200px; }
.store-row { display: flex; flex-direction: column; gap: 4px; width: 100%; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.store-row:last-child { border-bottom: 0; }
.branch-select { width: 100%; font-size: 12px; padding: 4px 6px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.real-item { color: var(--muted); font-size: 12px; }
.chip .branch { display: block; font-size: 10px; color: var(--muted); font-weight: 400; }

.compare .row-bar { display: grid; grid-template-columns: 150px 1fr 90px; gap: 10px; align-items: center; padding: 8px 14px; border-top: 1px solid var(--border); }
.compare .track { height: 14px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.compare .track i { display: block; height: 100%; border-radius: 4px; }
.compare .muted { color: var(--muted); font-size: 12px; }

dialog { border: 0; border-radius: 16px; padding: 24px; max-width: 620px; width: calc(100% - 32px); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog .close { position: absolute; top: 10px; inset-inline-end: 14px; border: 0; background: none; font-size: 26px; color: var(--muted); }
dialog h2 { margin: 0 0 2px; padding-inline-end: 24px; }
dialog ol { padding-inline-start: 20px; }
dialog ol li { margin-bottom: 6px; }
dialog ul.ing { columns: 2; padding-inline-start: 18px; }
@media (max-width: 600px) { dialog ul.ing { columns: 1; } }
.alt { display: flex; justify-content: space-between; width: 100%; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: 8px 12px; margin-bottom: 6px; text-align: start; }
.alt:hover { border-color: var(--accent); }
.delta { white-space: nowrap; padding-inline-start: 12px; }
.delta.neg { color: var(--accent); font-weight: 700; }
.delta.pos { color: var(--warn); }

.empty { color: var(--muted); padding: 40px; text-align: center; background: var(--surface); border-radius: var(--radius); border: 1px dashed var(--border); }
.disclaimer { color: var(--muted); font-size: 12px; margin-top: 24px; }

@media print {
  .panel, .tabs, .list-actions, .topbar, .summary, .disclaimer { display: none !important; }
  .layout { display: block; padding: 0; }
  .tabpanel[hidden] { display: none; }
}
