:root {
  --bg: #ffffff;
  --bg-soft: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --ink: #0f172a;
  --ink-text: #ffffff;
  --meat: #475569;
  --veg: #15803d;
  --danger: #b91c1c;
  --focus: #2563eb;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgb(15 23 42 / 0.04), 0 2px 12px rgb(15 23 42 / 0.05);
  --shadow-lg: 0 16px 48px rgb(15 23 42 / 0.2);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --submitbar-h: 76px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --bg-soft: #0f172a;
    --surface: #111827;
    --surface-2: #1e293b;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --line: #1e293b;
    --line-strong: #334155;
    --ink: #f1f5f9;
    --ink-text: #0b1120;
    --meat: #94a3b8;
    --veg: #4ade80;
    --danger: #f87171;
    --focus: #60a5fa;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.35);
    --shadow-lg: 0 16px 48px rgb(0 0 0 / 0.55);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 var(--font); -webkit-font-smoothing: antialiased;
  padding-bottom: calc(40px + var(--safe-b));
}
body.has-submitbar { padding-bottom: calc(var(--submitbar-h) + var(--safe-b) + 32px); }
h1, h2, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.86em; }
.center { text-align: center; }
.pad { padding: 48px 0; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.strong { font-weight: 700; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon-sm { width: 16px; height: 16px; }
.icon-xl { width: 32px; height: 32px; stroke-width: 2.4; }

.container { width: 100%; max-width: 720px; margin: 0 auto; padding: 0 20px; }
.stack { display: grid; gap: 16px; }

/* ---------- header + page nav ---------- */
.appbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.appbar-inner {
  max-width: 720px; margin: 0 auto; padding: 12px 20px 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand-wrap { display: grid; min-width: 0; }
.map-link { justify-self: start; margin-top: 2px; font-size: 12.5px; font-weight: 600; color: var(--focus); text-underline-offset: 2px; }
.brand { display: grid; min-width: 0; text-decoration: none; }
.brand-title { font-weight: 750; font-size: 17px; letter-spacing: -0.01em; line-height: 1.25; }
.brand-sub { display: grid; font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.appbar-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.lang, .status {
  min-height: 34px; border: 1px solid var(--line-strong); background: var(--surface);
  border-radius: 999px; padding: 0 12px; font-size: 13px; font-weight: 650;
}
.status { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); max-width: 42vw; }
.status-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--veg); flex: none; }
.status[data-status="syncing"] .dot { background: #f59e0b; animation: pulse 1.2s ease-in-out infinite; }
.status[data-status="error"] { color: var(--danger); }
.status[data-status="error"] .dot { background: var(--danger); }
@keyframes pulse { 50% { opacity: 0.3; } }

.nav {
  max-width: 720px; margin: 0 auto; padding: 0 20px;
  display: flex; gap: 22px; overflow-x: auto; scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav-link {
  flex: none; padding: 8px 0 10px; font-size: 14px; font-weight: 600; color: var(--muted);
  text-decoration: none; border-bottom: 2px solid transparent;
}
.nav-link[aria-current="page"] { color: var(--text); border-bottom-color: var(--ink); }

.banner {
  margin: 16px 0 0; padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--bg-soft); border: 1px dashed var(--line-strong); color: var(--muted); font-size: 13px;
}
#view { padding-top: 28px; }
.status-wrap { position: relative; height: 0; }
.status-wrap .status { position: absolute; right: 20px; top: 30px; z-index: 2; }

.page-head { margin-bottom: 24px; }
.page-head h1 { font-size: 32px; line-height: 1.12; letter-spacing: -0.025em; font-weight: 750; }
.lead { color: var(--muted); font-size: 16px; margin-top: 8px; max-width: 34em; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

/* ---------- form controls ---------- */
.field { display: grid; gap: 8px; }
.field-label { font-size: 13px; font-weight: 650; color: var(--muted); }
.field-error { color: var(--danger); font-size: 14px; }
.input {
  width: 100%; min-height: 48px; padding: 11px 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); font-size: 16px; transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 12%, transparent); }
.input-lg { min-height: 56px; font-size: 18px; }
.input[aria-invalid="true"] { border-color: var(--danger); }
select.input {
  appearance: none; -webkit-appearance: none; padding-right: 42px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 18px;
}

.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: var(--radius-sm); padding: 4px; gap: 4px; }
.seg-opt { position: relative; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-opt span { display: flex; align-items: center; justify-content: center; min-height: 44px; border-radius: 9px; font-weight: 650; color: var(--muted); transition: 0.15s; }
.seg-opt input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg-opt input:focus-visible + span { outline: 2px solid var(--focus); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 999px; font-weight: 650; font-size: 16px;
  border: 1px solid transparent; background: none; text-decoration: none; transition: transform 0.08s, opacity 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn .icon { width: 18px; height: 18px; }
.btn-primary { background: var(--ink); color: var(--ink-text); }
.btn-primary:disabled { opacity: 0.75; cursor: progress; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-ghost { border-color: var(--line-strong); background: var(--surface); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-wide { min-width: 150px; }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: 14px; }
.danger { color: var(--danger); }
.link { display: inline-flex; align-items: center; gap: 4px; font-weight: 650; text-decoration: none; }
.link:hover { text-decoration: underline; }
.link-btn {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: none;
  font-weight: 650; font-size: 14px; padding: 6px 0; color: var(--muted);
}
.link-btn:hover { color: var(--text); }
.button-row { display: flex; gap: 10px; justify-content: flex-end; }
.button-col { display: grid; gap: 10px; }

/* ---------- registration ---------- */
.reg { display: grid; gap: 28px; }
.days { display: grid; gap: 12px; }
.day-set { border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 16px 4px; margin: 0; min-width: 0; background: var(--surface); }
.day-legend { display: flex; width: 100%; justify-content: space-between; align-items: center; float: left; padding: 0; margin: 8px 0 4px; }
.day-legend + * { clear: both; }
.day-name { font-weight: 700; }
.day-name .muted { font-weight: 500; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 58px; border-top: 1px solid var(--line); cursor: pointer; }
.day-legend + .switch-row { border-top: 0; }
.switch-text { display: grid; line-height: 1.3; }
.switch-label { font-size: 17px; }
.switch-text .muted { font-size: 13px; }
.switch {
  appearance: none; -webkit-appearance: none; flex: none; margin: 0;
  width: 51px; height: 31px; border-radius: 999px; background: var(--line-strong);
  position: relative; cursor: pointer; transition: background 0.2s ease;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 0.25); transition: transform 0.2s ease;
}
.switch:checked { background: var(--ink); }
.switch:checked::after { transform: translateX(20px); }
@media (prefers-color-scheme: dark) { .switch:checked::after { background: #0b1120; } }

.edit-extra { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

.submitbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.submitbar-inner {
  max-width: 720px; margin: 0 auto; padding: 12px 20px; min-height: var(--submitbar-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.total { display: grid; line-height: 1.15; }
.total-label { font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.total-val { font-size: 24px; font-weight: 750; letter-spacing: -0.02em; }

.yours { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 28px; background: var(--bg-soft); }
.yours-list { list-style: none; margin: 8px 0 0; padding: 0; }
.yours-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.yours-list li:first-child { border-top: 0; }

.done { display: grid; gap: 16px; padding-top: 8px; }
.done h1 { font-size: 30px; line-height: 1.15; letter-spacing: -0.02em; font-weight: 750; }
.done .lead { margin-top: 0; }
.done-lead { font-size: 18px; font-weight: 600; }
.save-status { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 14px; font-weight: 600; min-height: 24px; }
.save-ok { display: inline-flex; align-items: center; gap: 6px; color: var(--veg); }
.save-wait { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; }
.tag-pending { margin-left: 8px; }
.done-badge {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ink); color: var(--ink-text); animation: pop 0.35s ease-out;
}
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }
.receipt { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: var(--surface); box-shadow: var(--shadow); margin: 8px 0; }
.receipt-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-bottom: 10px; }
.receipt-name { font-weight: 700; font-size: 17px; overflow-wrap: anywhere; }
.receipt-total { display: flex; justify-content: space-between; padding-top: 12px; font-weight: 750; font-size: 18px; }

/* ---------- shared list pieces ---------- */
.kv-list { display: grid; border-top: 1px solid var(--line); }
.kv { display: grid; grid-template-columns: 92px 1fr auto; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.kv-key { color: var(--muted); font-weight: 600; }
.diet { font-size: 13px; white-space: nowrap; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.diet::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--meat); }
.diet-veg { color: var(--veg); }
.diet-veg::before { background: var(--veg); }
.tag { font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 6px; padding: 1px 6px; }

/* ---------- attendees ---------- */
.count { font-weight: 700; font-size: 15px; }
.roster { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); counter-reset: roster; }
.roster li {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 0;
  border-bottom: 1px solid var(--line); counter-increment: roster;
}
.roster li::before {
  content: counter(roster); min-width: 28px; color: var(--muted); font-size: 13px;
  font-variant-numeric: tabular-nums; text-align: right;
}
.roster-name { flex: 1; min-width: 0; font-size: 17px; overflow-wrap: anywhere; }
.empty { text-align: center; padding: 44px 16px; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.empty-title { color: var(--text); font-weight: 700; font-size: 17px; margin-bottom: 4px; }

/* ---------- kitchen ---------- */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpis .kpi:first-child { grid-column: 1 / -1; }
@media (min-width: 560px) { .kpis { grid-template-columns: repeat(3, 1fr); } .kpis .kpi:first-child { grid-column: auto; } }
.kpi { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 14px; background: var(--surface); min-width: 0; }
.kpi-label { font-size: 13px; color: var(--muted); font-weight: 600; overflow-wrap: anywhere; }
.kpi-value { font-size: 28px; font-weight: 750; letter-spacing: -0.02em; line-height: 1.2; margin-top: 2px; }
.day-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: var(--surface); }
.day-card-head h2 { font-size: 19px; display: flex; align-items: baseline; gap: 10px; letter-spacing: -0.01em; }
.day-card-head .muted { font-size: 14px; font-weight: 500; }
.stats { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 12px; margin-top: 12px; }
.meal-row { padding-top: 14px; margin-top: 14px; border-top: 1px solid var(--line); }
.meal-row:first-of-type { border-top: 0; margin-top: 4px; padding-top: 4px; }
.meal-title { font-size: 15px; font-weight: 650; margin: 0; }
.meal-row .stats { margin-top: 8px; }
.stat { display: grid; gap: 2px; padding-left: 12px; border-left: 3px solid var(--meat); }
.stat-main { border-left-color: var(--ink); }
.stat-veg { border-left-color: var(--veg); }
.stat-value { font-size: 30px; font-weight: 750; letter-spacing: -0.02em; line-height: 1.1; }
.stat-label { font-size: 13px; color: var(--muted); }

/* ---------- program ---------- */
.prog-day { font-size: 19px; display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; letter-spacing: -0.01em; }
.prog-day .muted { font-size: 14px; font-weight: 500; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 56px 1fr; gap: 14px; padding: 10px 0; border-top: 1px solid var(--line); }
.time { font-family: var(--mono); color: var(--muted); text-align: right; font-size: 14px; padding-top: 2px; }

/* ---------- confirm sheet + toast ---------- */
.sheet {
  border: 0; padding: 0; background: var(--surface); color: var(--text);
  width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 22px 22px 0 0; box-shadow: var(--shadow-lg);
}
.sheet::backdrop { background: rgb(15 23 42 / 0.45); }
.sheet[open] { animation: rise 0.22s ease-out; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
@media (min-width: 640px) { .sheet { max-width: 420px; margin: auto; border-radius: 22px; } }
.confirm-body { padding: 24px 20px calc(20px + var(--safe-b)); display: grid; gap: 20px; font-size: 17px; }

.toast {
  position: fixed; left: 50%; z-index: 60; bottom: calc(24px + var(--safe-b));
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--ink-text); padding: 11px 18px; border-radius: 999px;
  font-weight: 600; font-size: 14px; box-shadow: var(--shadow-lg); transition: 0.2s ease;
  max-width: calc(100vw - 32px); text-align: center;
}
.has-submitbar .toast { bottom: calc(var(--submitbar-h) + var(--safe-b) + 16px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast[data-kind="error"] { background: var(--danger); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
  :root { color-scheme: light; }
  body { background: #fff; padding: 0; }
  .appbar { position: static; border: 0; backdrop-filter: none; }
  .appbar-actions, .nav, .toast, .banner, .status-wrap { display: none !important; }
  .card, .kpi, .day-card { break-inside: avoid; }
}
