:root {
  --green: #1f4d3a;
  --green-dark: #163828;
  --accent: #d9a441;
  --bg: #f4f5f2;
  --card: #ffffff;
  --text: #1c1f1d;
  --muted: #6b716d;
  --line: #e2e5e0;
  --up: #b42318;
  --down: #157f3c;
  --radius: 10px;
  --tap: 44px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--green); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--up); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.up { color: var(--up); font-weight: 600; }
.down { color: var(--down); font-weight: 600; }

/* top bar */
.topbar {
  background: var(--green); color: #fff; position: sticky; top: 0; z-index: 10;
  padding: .5rem .75rem 0; box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.brandrow { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding-bottom: .35rem; }
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; display: block; }
.loc-switch {
  background: var(--green-dark); color: #fff; border: 1px solid rgba(255,255,255,.35); border-radius: 8px;
  padding: .35rem .6rem; min-height: 36px; font-weight: 600; max-width: 55vw;
}
.loc-banner { background: #fdf0d5; color: #8a5a00; border: 1px solid #f3d9a0; border-radius: var(--radius); padding: .6rem .8rem; margin-bottom: .75rem; font-size: .9rem; }
.brand span { color: var(--accent); font-weight: 500; }
.tabs { display: flex; gap: .25rem; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tabs a {
  color: rgba(255,255,255,.8); text-decoration: none; padding: .5rem .75rem; white-space: nowrap;
  border-bottom: 3px solid transparent; font-weight: 500; min-height: var(--tap);
}
.tabs a.active { color: #fff; border-bottom-color: var(--accent); }

/* layout */
.view { padding: .75rem; max-width: 1100px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem; margin-bottom: .75rem; }
.toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .75rem; }
.toolbar .grow { flex: 1 1 180px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .5rem; margin-bottom: .75rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .8rem; }
.stat .label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 1.25rem; font-weight: 700; }

/* forms */
input, select, textarea, button { font: inherit; }
input[type=text], input[type=number], input[type=password], input[type=search], select, textarea {
  width: 100%; padding: .55rem .65rem; border: 1px solid #c9cec9; border-radius: 8px; background: #fff; min-height: var(--tap);
}
textarea { min-height: 70px; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
.field { margin-bottom: .7rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .6rem; }
@media (max-width: 480px) { .grid3 { grid-template-columns: 1fr 1fr; } }
.check { display: flex; align-items: center; gap: .5rem; font-size: .95rem; color: var(--text); min-height: var(--tap); }
.check input { width: 1.2rem; height: 1.2rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .3rem;
  padding: .5rem .9rem; border-radius: 8px; border: 1px solid #c9cec9; background: #fff; color: var(--text);
  cursor: pointer; min-height: var(--tap); text-decoration: none; white-space: nowrap;
}
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { color: var(--up); border-color: #f0c2bd; }
.btn.small { min-height: 34px; padding: .25rem .6rem; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: default; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; margin-top: .5rem; }

/* tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: .5rem .45rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #f7f9f5; }
tfoot td { font-weight: 700; }
td input[type=number] { min-height: 36px; padding: .3rem .4rem; width: 6.5rem; }
td input[type=text] { min-height: 36px; padding: .3rem .4rem; width: 9rem; }

/* list cards (mobile dishes) */
.list { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .8rem; cursor: pointer; display: block; color: inherit; text-decoration: none; }
.item:hover { border-color: var(--green); }
.item .title { font-weight: 600; display: flex; justify-content: space-between; gap: .5rem; }
.item .meta { display: flex; justify-content: space-between; color: var(--muted); font-size: .85rem; margin-top: .25rem; }
.pill { display: inline-block; font-size: .7rem; padding: .1rem .45rem; border-radius: 999px; background: #eef1ec; color: var(--muted); vertical-align: middle; }
.pill.ok { background: #e3f3e8; color: var(--down); }
.pill.todo { background: #fdf0d5; color: #8a5a00; }
.pill.food { background: #e9f0ff; color: #2b4ea3; }
.pill.bar { background: #f3e8ff; color: #6b2fb3; }

/* login + modal */
.login { position: fixed; inset: 0; background: var(--green-dark); display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 50; }
.login-card { width: 100%; max-width: 360px; }
.login-card input { margin-bottom: .6rem; }
.login-card .btn { width: 100%; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; padding: 0; }
@media (min-width: 640px) { .modal { align-items: center; padding: 1rem; } }
.modal-body { width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; margin: 0; border-radius: var(--radius) var(--radius) 0 0; }
@media (min-width: 640px) { .modal-body { border-radius: var(--radius); } }

.toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); background: #222; color: #fff; padding: .6rem 1rem; border-radius: 999px; z-index: 60; font-size: .9rem; max-width: 92vw; }
.toast.err { background: var(--up); }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.impact-head { display: grid; grid-template-columns: 1fr auto 1fr; gap: .5rem; align-items: center; text-align: center; }
.impact-head .arrow { font-size: 1.4rem; color: var(--muted); }
.impact-head .big { font-size: 1.3rem; font-weight: 700; }
.loading { opacity: .6; pointer-events: none; }
