/* Shared base: reset, controls, toasts, dialogs. Pages set --bg/--surface/--text/--muted/--brand/--accent/--radius/--font. */
:root { --bg: #f7f7f5; --surface: #fff; --text: #161616; --muted: #6b6b6b; --brand: #2f6b2f; --accent: #c8902e; --radius: 12px;
  --font: 'Inter', system-ui, sans-serif; --line: color-mix(in srgb, var(--text) 12%, transparent); --soft: color-mix(in srgb, var(--text) 5%, var(--surface)); }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
img { max-width: 100%; display: block; }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; text-wrap: balance; }
p { margin: 0 0 .8em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.hidden, [hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px; border-radius: calc(var(--radius) * .75);
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--text);
  transition: transform .12s, background .15s, opacity .15s; touch-action: manipulation; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: #b42318; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn.block { width: 100%; }

label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
input:not([type=checkbox]):not([type=radio]):not([type=color]), select, textarea { width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line);
  border-radius: calc(var(--radius) * .6); background: var(--surface); color: var(--text); font-weight: 400; }
textarea { min-height: 80px; resize: vertical; }
input[type=color] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.check { display: flex; flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-weight: 500; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }

.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; position: absolute; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: color-mix(in srgb, var(--text) 22%, transparent); transition: background .15s; }
.switch span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px #0003; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--soft); white-space: nowrap; }
.badge.green { background: #e3f4e5; color: #1d6b2a; } .badge.amber { background: #fdf0d5; color: #8a5a00; }
.badge.red { background: #fde4e1; color: #a1251a; } .badge.blue { background: #e1ecfd; color: #1d4e9a; } .badge.grey { background: #ececec; color: #555; }
.veg { width: 14px; height: 14px; border: 1.5px solid #1d8a35; display: inline-grid; place-items: center; border-radius: 3px; flex: none; }
.veg::after { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #1d8a35; }
.veg.non { border-color: #b3261e; } .veg.non::after { background: #b3261e; border-radius: 0; width: 0; height: 0; border: 4px solid transparent; border-bottom: 6px solid #b3261e; border-top: 0; }

#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 1000; width: min(92vw, 420px); pointer-events: none; }
.toast { padding: 12px 16px; border-radius: 12px; background: #1d1d1d; color: #fff; box-shadow: 0 8px 24px #0004; animation: pop .2s ease-out; font-size: 14px; }
.toast.err { background: #a1251a; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

dialog { border: 0; padding: 0; background: var(--surface); color: var(--text); border-radius: calc(var(--radius) + 4px); box-shadow: 0 24px 60px #0005; max-width: min(560px, 94vw); width: 100%; }
dialog::backdrop { background: #0008; backdrop-filter: blur(2px); }
dialog .dlg { padding: 20px; display: grid; gap: 14px; max-height: 88vh; overflow: auto; }
dialog .dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
dialog .dlg-head h2 { margin: 0; font-size: 19px; }
/* Neumorphism ("soft 3D"). Shadows derive from --bg so it works on any theme colour.
   Readability guard: text keeps full contrast, primary actions stay solid colour, focus rings stay visible. */
[data-neu] { --surface: var(--bg); --line: transparent; --hi: color-mix(in srgb, #fff 75%, var(--bg)); --lo: color-mix(in srgb, #000 22%, var(--bg));
  --raise: 6px 6px 14px var(--lo), -6px -6px 14px var(--hi); --raise-sm: 3px 3px 7px var(--lo), -3px -3px 7px var(--hi);
  --press: inset 3px 3px 7px var(--lo), inset -3px -3px 7px var(--hi); }
[data-neu][data-dark] { --hi: color-mix(in srgb, #fff 9%, var(--bg)); --lo: color-mix(in srgb, #000 55%, var(--bg)); }
[data-neu] .btn { border: 0; box-shadow: var(--raise-sm); background: var(--bg); }
[data-neu] .btn:active, [data-neu] .btn.on { box-shadow: var(--press); transform: none; }
[data-neu] .btn.primary, [data-neu] .btn.accent { box-shadow: var(--raise-sm); }
[data-neu] .btn.primary { background: var(--brand); } [data-neu] .btn.accent { background: var(--accent); }
[data-neu] .btn.ghost { box-shadow: none; background: transparent; }
[data-neu] input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=range]), [data-neu] select, [data-neu] textarea { border: 0; background: var(--bg); box-shadow: var(--press); }
[data-neu] dialog { background: var(--bg); }
[data-neu] .badge { box-shadow: var(--raise-sm); }
[data-neu] .switch span { box-shadow: var(--press); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
