:root {
  color-scheme: dark;
  --red: #e23744; --red-dark: #ff6b78; --red-soft: #3a1c21; --red-line: #7d2e37;
  --ink: #f4f4f5; --ink-2: #c5c5ca; --muted: #8f8f96; --line: #2c2c31; --bg: #0e0e10; --card: #1a1a1d; --surface: #1a1a1d;
  --veg: #3fc95f; --ok: #3ddc97; --warn: #ffa94d;
  --r: 14px; --shadow: 0 2px 12px rgba(0, 0, 0, .45);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body { font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--ink); background: var(--bg); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
[hidden] { display: none !important; }
.wrap { max-width: 560px; margin: 0 auto; }

/* ---------- top bar ---------- */
.top { position: sticky; top: 0; z-index: 20; background: var(--surface); box-shadow: 0 1px 0 var(--line); }
.top-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 6px; }
.logo { font-weight: 900; font-style: italic; font-size: 26px; letter-spacing: -1px; color: var(--ink); line-height: 1; }
.logo small { display: block; font-style: normal; font-weight: 600; font-size: 11px; letter-spacing: .3px; color: var(--red); margin-top: 3px; text-transform: uppercase; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-2); background: var(--bg); }
.icon-btn svg { width: 19px; height: 19px; }

.dates { display: flex; gap: 8px; overflow-x: auto; padding: 8px 16px 10px; scrollbar-width: none; scroll-snap-type: x proximity; }
.dates::-webkit-scrollbar { display: none; }
.date-chip { flex: 0 0 auto; width: 54px; padding: 7px 0 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); text-align: center; position: relative; scroll-snap-align: center; }
.date-chip .dw { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.date-chip .dd { font-size: 18px; font-weight: 800; line-height: 1.2; }
.date-chip .dm { font-size: 11px; color: var(--muted); }
.date-chip.on { background: var(--red); border-color: var(--red); color: #fff; box-shadow: 0 4px 10px rgba(226, 55, 68, .3); }
.date-chip.on .dw, .date-chip.on .dm { color: #ffe3e6; }
.date-chip.has::after { content: ""; position: absolute; top: 5px; right: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.date-chip.on.has::after { background: #fff; }
.cal { flex: 0 0 auto; width: 54px; border-radius: 12px; border: 1px dashed var(--red-line); display: grid; place-items: center; color: var(--red); position: relative; overflow: hidden; font-size: 11px; font-weight: 700; }
.cal svg { width: 20px; height: 20px; display: block; margin: 0 auto 2px; }
.cal input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }

.meals { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin: 0 16px; border-bottom: 1px solid var(--line); }
.meal-tab { padding: 10px 0 11px; font-weight: 700; color: var(--muted); border-bottom: 3px solid transparent; display: flex; align-items: center; justify-content: center; gap: 7px; }
.meal-tab.on { color: var(--red); border-color: var(--red); }
.meal-tab .badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--bg); color: var(--ink-2); font-size: 12px; display: inline-grid; place-items: center; }
.meal-tab.on .badge { background: var(--red); color: #fff; }

/* ---------- search + menu ---------- */
.bar { display: flex; gap: 10px; padding: 12px 16px 4px; }
.search { flex: 1; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; box-shadow: var(--shadow); }
.search svg { width: 18px; height: 18px; color: var(--red); flex: none; }
.search input { border: 0; outline: 0; background: none; width: 100%; padding: 11px 0; }
.add-new { flex: none; background: var(--red); color: #fff; border-radius: 12px; padding: 0 14px; font-weight: 700; font-size: 14px; box-shadow: var(--shadow); }
.ctx { padding: 8px 18px 0; font-size: 13px; color: var(--ink-2); }
.ctx b { color: var(--ink); }

main { padding: 6px 12px 130px; }
.cat { margin: 14px 4px 8px; font-size: 17px; font-weight: 800; display: flex; align-items: baseline; gap: 8px; }
.cat span { font-size: 12px; font-weight: 600; color: var(--muted); }
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); }
.dish { display: flex; align-items: center; gap: 12px; padding: 14px 14px; border-bottom: 1px dashed var(--line); }
.dish:last-child { border-bottom: 0; }
.dish.flash { animation: flash 1.6s ease; }
@keyframes flash { 0%, 40% { background: #4a3d12; } 100% { background: var(--surface); } }
.dish-info { flex: 1; min-width: 0; }
.veg { display: inline-grid; place-items: center; width: 14px; height: 14px; border: 1.5px solid var(--veg); border-radius: 3px; vertical-align: -2px; margin-right: 6px; }
.veg::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--veg); }
.dish-name { font-weight: 700; font-size: 15px; }
.dish-price { margin-top: 3px; font-weight: 600; }
.dish-price .basis { color: var(--muted); font-weight: 500; font-size: 13px; }
.dish-line { margin-top: 3px; font-size: 12.5px; color: var(--ok); font-weight: 600; }

.add-btn, .stepper { width: 92px; height: 36px; border-radius: 9px; flex: none; }
.add-btn { background: var(--red-soft); border: 1px solid var(--red-line); color: var(--red); font-weight: 800; letter-spacing: .5px; box-shadow: 0 2px 6px rgba(226, 55, 68, .12); position: relative; }
.add-btn::after { content: "+"; position: absolute; top: 1px; right: 7px; font-size: 13px; font-weight: 700; }
.stepper { display: grid; grid-template-columns: 30px 1fr 30px; align-items: center; background: var(--red); color: #fff; box-shadow: 0 3px 8px rgba(226, 55, 68, .3); overflow: hidden; }
.stepper button { height: 100%; color: #fff; font-size: 20px; font-weight: 700; line-height: 1; }
.stepper input { width: 100%; text-align: center; border: 0; background: none; color: #fff; font-weight: 800; outline: 0; padding: 0; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }

/* ---------- floating cart bar ---------- */
.cartbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding: 0 12px calc(12px + env(safe-area-inset-bottom)); pointer-events: none; }
.cartbar .wrap { pointer-events: auto; }
.cart-btn { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 16px; border-radius: 14px; background: var(--red); color: #fff; box-shadow: 0 8px 22px rgba(226, 55, 68, .35); text-align: left; }
.cart-btn.idle { background: var(--surface); color: var(--ink); box-shadow: 0 6px 20px rgba(0, 0, 0, .5); border: 1px solid var(--line); }
.cart-btn .l1 { font-weight: 800; font-size: 15px; }
.cart-btn .l2 { font-size: 12px; opacity: .92; margin-top: 1px; }
.cart-btn .go { font-weight: 800; white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.cart-btn.idle .go { color: var(--red); }
.save-state { display: inline-flex; align-items: center; gap: 4px; }
.save-state.err { background: var(--surface); color: var(--warn); padding: 1px 7px; border-radius: 6px; font-weight: 700; }

/* ---------- bill view ---------- */
.screen { position: fixed; inset: 0; z-index: 40; background: var(--bg); overflow-y: auto; }
.screen-head { position: sticky; top: 0; z-index: 2; background: var(--surface); display: flex; align-items: center; gap: 10px; padding: 12px 12px; box-shadow: 0 1px 0 var(--line); }
.screen-head h2 { margin: 0; font-size: 18px; font-weight: 800; }
.range { padding: 14px 16px 4px; }
.range-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: block; }
.field > span { display: block; font-size: 12px; font-weight: 700; color: var(--ink-2); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .4px; }
.field input { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 12px; outline: 0; }
.field input:focus { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 2px; scrollbar-width: none; }
.chip { flex: none; padding: 6px 12px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 600; color: var(--ink-2); }
.chip:active { background: var(--red-soft); }
.bill-body { padding: 8px 12px 150px; }
.day { margin-top: 12px; padding: 14px 14px 10px; }
.day-h { display: flex; justify-content: space-between; align-items: baseline; font-weight: 800; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.day-h small { color: var(--muted); font-weight: 600; font-size: 12px; }
.meal-h { margin-top: 10px; font-size: 12px; font-weight: 800; color: var(--red); letter-spacing: .6px; text-transform: uppercase; }
.ln { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 6px 0; }
.ln .nm { font-weight: 600; }
.ln .calc { grid-column: 1; font-size: 12.5px; color: var(--muted); }
.ln .amt { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-variant-numeric: tabular-nums; font-weight: 600; }
.sub, .tot { display: flex; justify-content: space-between; padding: 7px 0; font-variant-numeric: tabular-nums; }
.sub { border-top: 1px dashed var(--line); font-weight: 700; color: var(--ink-2); font-size: 14px; }
.tot { border-top: 1px solid var(--line); font-weight: 800; margin-top: 4px; }
.no-order { color: var(--muted); padding: 10px 0 4px; font-style: italic; }
.grand { position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; background: var(--surface); box-shadow: 0 -6px 20px rgba(0, 0, 0, .5); padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
.grand-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.grand-row .lbl { font-weight: 800; font-size: 16px; }
.grand-row .lbl small { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
.grand-row .val { font-weight: 900; font-size: 22px; font-variant-numeric: tabular-nums; }
.btn-primary { width: 100%; padding: 14px; border-radius: 12px; background: var(--red); color: #fff; font-weight: 800; font-size: 16px; box-shadow: 0 6px 16px rgba(226, 55, 68, .3); display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn-primary:disabled { background: #4a2a2f; color: rgba(255, 255, 255, .55); box-shadow: none; cursor: not-allowed; }
.btn-primary svg { width: 20px; height: 20px; }
.note { color: var(--warn); font-size: 13px; font-weight: 600; margin: 0 0 8px; }

/* ---------- add item sheet ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .65); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; background: var(--surface); border-radius: 20px 20px 0 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); animation: up .22s ease; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet h3 { margin: 0 0 14px; font-size: 19px; font-weight: 800; display: flex; justify-content: space-between; align-items: center; }
.sheet .field { margin-bottom: 14px; }
.price-in { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.price-in b { padding: 0 4px 0 12px; color: var(--ink-2); }
.price-in input { border: 0 !important; box-shadow: none !important; padding-left: 2px; }
.price-in:focus-within { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; text-align: center; padding: 10px; border-radius: 10px; border: 1px solid var(--line); font-weight: 700; color: var(--ink-2); }
.seg input:checked + span { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.seg input:focus-visible + span { outline: 2px solid var(--red); }
.preview { background: var(--bg); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 12px; color: var(--ink-2); }
.preview b { color: var(--ink); }
.form-err { color: var(--red-dark); font-weight: 600; font-size: 13.5px; margin: -4px 0 10px; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: 60; background: #2b2b30; color: #fff; border: 1px solid #3a3a40; padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); max-width: calc(100% - 32px); }
.toast.bad { background: #b3202f; border-color: #b3202f; }

/* ---------- login ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 24px; background: linear-gradient(180deg, #0e0e10 0%, #0e0e10 55%, #2a1519 100%); }
.login .logo { font-size: 40px; text-align: center; }
.login .logo small { font-size: 13px; }
.login h1 { font-size: 18px; text-align: center; margin: 34px 0 6px; }
.login p.sub-t { text-align: center; color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.pin-one { display: block; width: 220px; margin: 0 auto 14px; height: 64px; text-align: center; font-size: 30px; font-weight: 800; letter-spacing: 22px; padding-left: 22px; border: 1.5px solid #3a3a40; border-radius: 14px; outline: 0; background: var(--surface); }
.pin-one:focus { border-color: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }
.pin { display: flex; gap: 12px; justify-content: center; margin-bottom: 14px; }
.pin input { width: 58px; height: 64px; text-align: center; font-size: 26px; font-weight: 800; border: 1.5px solid #3a3a40; border-radius: 14px; outline: 0; background: var(--surface); }
.pin input:focus { border-color: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }
.login .err { text-align: center; color: var(--red-dark); font-weight: 700; min-height: 20px; margin: 0 0 14px; }
.login form { max-width: 340px; width: 100%; margin: 0 auto; }
.lock-note { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; display: flex; gap: 6px; justify-content: center; align-items: center; }
.lock-note svg { width: 14px; height: 14px; }

/* ---------- edit / paste ---------- */
.dish-edit { margin-left: 8px; font-size: 12.5px; font-weight: 700; color: var(--red); padding: 2px 6px; border-radius: 6px; }
.dish-edit:active { background: var(--red-soft); }
.btn-ghost { width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--red-line); color: var(--red-dark); font-weight: 800; margin-top: 10px; background: var(--surface); }
.sheet-note { font-size: 12.5px; color: var(--muted); margin: -4px 0 12px; }
.paste-card { display: block; width: calc(100% - 32px); margin: 10px 16px 0; text-align: left; padding: 12px 14px; border-radius: 12px; border: 1px dashed var(--red-line); background: var(--red-soft); }
.paste-card b { display: block; color: var(--red-dark); font-size: 15px; }
.paste-card span { font-size: 12.5px; color: var(--ink-2); }
.paste-area { width: 100%; min-height: 220px; border: 1px solid var(--line); border-radius: 12px; padding: 12px; font: inherit; outline: 0; resize: vertical; background: var(--surface); }
.paste-area:focus { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.pad { padding: 14px 16px; }
.rv-group { margin-top: 12px; padding: 12px; }
.rv-head { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 6px; }
.rv-head input, .rv-head select, .rv-line select, .rv-line input { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px; background: var(--surface); font: inherit; outline: 0; }
.rv-head .bad, .rv-line .bad { border-color: var(--red); background: #3a1c21; }
.rv-warn { font-size: 12.5px; color: var(--warn); font-weight: 600; margin: 4px 0; }
.rv-line { border-top: 1px dashed var(--line); padding: 10px 0 6px; }
.rv-src { font-size: 12px; color: var(--muted); margin-bottom: 6px; display: flex; justify-content: space-between; gap: 8px; }
.rv-src button { color: var(--muted); font-size: 16px; line-height: 1; }
.rv-row { display: grid; grid-template-columns: 64px 1fr; gap: 8px; }
.rv-new { display: grid; grid-template-columns: 1fr 90px; gap: 8px; margin-top: 8px; }
.rv-new .seg { grid-column: 1 / -1; }
.rv-amt { text-align: right; font-size: 13px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.rv-flag { color: var(--warn); font-weight: 700; }
.rv-sub { display: flex; justify-content: space-between; font-weight: 800; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; }
