:root {
  --bg: #F7F6F2;
  --card: #FFFFFF;
  --ink: #17201B;
  --muted: #69736D;
  --line: #E6E4DD;
  --brand: #0F5132;
  --brand-ink: #FFFFFF;
  --brand-soft: #E3F1E8;
  --accent: #C2410C;
  --warn-soft: #FEF3C7;
  --warn-ink: #92400E;
  --bad-soft: #FEE2E2;
  --bad-ink: #991B1B;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1311; --card: #181D1A; --ink: #ECEFEC; --muted: #9AA39D; --line: #2A312D;
    --brand: #34A36B; --brand-ink: #06140C; --brand-soft: #173326; --accent: #FB923C;
    --warn-soft: #3A2E10; --warn-ink: #FCD34D; --bad-soft: #3B1515; --bad-ink: #FCA5A5;
    --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1311; --card: #181D1A; --ink: #ECEFEC; --muted: #9AA39D; --line: #2A312D;
  --brand: #34A36B; --brand-ink: #06140C; --brand-soft: #173326; --accent: #FB923C;
  --warn-soft: #3A2E10; --warn-ink: #FCD34D; --bad-soft: #3B1515; --bad-ink: #FCA5A5;
  --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 Manrope, system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
main { flex: 1; padding-top: 20px; padding-bottom: 110px; outline: none; }
h1 { font-size: 28px; line-height: 1.2; margin: 0 0 6px; letter-spacing: -.02em; }
h2 { font-size: 20px; margin: 28px 0 12px; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* header */
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-row { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.logo { font-weight: 800; font-size: 20px; text-decoration: none; display: flex; align-items: center; gap: 2px; letter-spacing: -.02em; }
.logo-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--brand); color: var(--brand-ink); margin-right: 2px; }
.top-nav { display: flex; align-items: center; gap: 14px; }
.link { text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14px; }
.link:hover { color: var(--ink); }
.cart-btn { position: relative; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); }
.badge { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; }

/* hero */
.hero { background: var(--brand); color: var(--brand-ink); border-radius: 22px; padding: 28px 22px; margin-bottom: 8px; position: relative; overflow: hidden; }
.hero h1 { font-size: 30px; max-width: 560px; }
.hero p { margin: 0 0 18px; opacity: .85; max-width: 520px; }
.hero::after { content: "🍚🌯🥟🍢"; position: absolute; right: -10px; bottom: -18px; font-size: 64px; opacity: .18; letter-spacing: 6px; pointer-events: none; }
.search { display: flex; background: var(--card); border-radius: 12px; padding: 4px; max-width: 460px; }
.search input { flex: 1; border: 0; outline: 0; background: transparent; padding: 10px 12px; color: var(--ink); min-width: 0; }

/* restaurant grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.r-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; box-shadow: var(--shadow); transition: transform .15s ease, box-shadow .15s ease; display: flex; flex-direction: column; }
.r-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.r-cover { height: 112px; display: grid; place-items: center; font-size: 52px; background-size: cover; background-position: center; position: relative; }
.r-body { padding: 14px 16px 16px; }
.r-name { font-weight: 700; font-size: 17px; margin: 0 0 2px; }
.r-meta { font-size: 13px; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.pill.on { background: var(--brand-soft); color: var(--brand); }
.pill.off { background: var(--bad-soft); color: var(--bad-ink); }
.pill.wait { background: var(--warn-soft); color: var(--warn-ink); }
.r-cover .pill { position: absolute; top: 10px; left: 10px; background: rgba(255,255,255,.92); }
.r-cover .pill.off { color: #991B1B; }
.r-cover .pill.on { color: #0F5132; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* restaurant page */
.r-head { border-radius: 22px; padding: 22px; color: #fff; display: flex; gap: 16px; align-items: center; margin-bottom: 6px; background-size: cover; background-position: center; }
.r-head > div:last-child { min-width: 0; overflow-wrap: anywhere; }
.r-head .r-emoji { width: 64px; height: 64px; border-radius: 16px; background: rgba(255,255,255,.18); display: grid; place-items: center; font-size: 36px; flex: none; overflow: hidden; }
.r-head .r-emoji img { width: 100%; height: 100%; object-fit: cover; }
.r-head h1 { color: #fff; font-size: 24px; }
.r-head p { margin: 0; opacity: .9; font-size: 14px; }
.tabs { position: sticky; top: 60px; z-index: 10; background: var(--bg); display: flex; gap: 8px; overflow-x: auto; padding: 12px 0; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; border: 1px solid var(--line); background: var(--card); padding: 7px 14px; border-radius: 999px; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; }
.tab.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.dishes { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.dish { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.dish.stopped { opacity: .55; }
.dish-name { font-weight: 700; }
.dish-img { width: calc(100% + 28px); margin: -14px -14px 2px; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 14px 14px 0 0; display: block; background: var(--line); }
.dish-ph { display: grid; place-items: center; font-size: 44px; aspect-ratio: 16 / 7; }
.dish-desc { font-size: 13px; color: var(--muted); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dish { overflow: hidden; }
.menu-table input, .menu-table select { width: 100%; min-width: 60px; border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 6px 8px; font-size: 13px; }
.menu-table td { padding: 4px; vertical-align: middle; }
.menu-table .num { width: 90px; }
.menu-table .tiny { width: 64px; }
.keybox { background: var(--bg); border: 1px dashed var(--line); border-radius: 12px; padding: 12px; margin-top: 10px; font-size: 13px; }
.keybox pre { margin: 6px 0 0; white-space: pre-wrap; word-break: break-all; font-size: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.dish-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; gap: 8px; }
.price { font-weight: 800; }
.note { font-size: 12px; font-weight: 600; }
.note.warn { color: var(--warn-ink); }
.note.bad { color: var(--bad-ink); }

/* buttons */
.btn { border: 0; cursor: pointer; border-radius: 12px; padding: 11px 18px; font-weight: 700; background: var(--brand); color: var(--brand-ink); display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--bad-soft); color: var(--bad-ink); }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }
.add { width: 38px; height: 38px; padding: 0; border-radius: 11px; font-size: 22px; }
.stepper { display: inline-flex; align-items: center; background: var(--brand-soft); border-radius: 11px; }
.stepper button { width: 36px; height: 38px; border: 0; background: none; font-size: 20px; font-weight: 700; color: var(--brand); cursor: pointer; }
.stepper span { min-width: 44px; text-align: center; font-weight: 700; font-size: 14px; }

/* cart bar */
.cart-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 40%); }
.cart-bar-in { display: flex; justify-content: space-between; align-items: center; background: var(--brand); color: var(--brand-ink); padding: 14px 18px; border-radius: 14px; text-decoration: none; font-weight: 700; max-width: 640px; box-shadow: 0 8px 24px rgba(15,81,50,.3); }

/* panels & forms */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.cols { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 860px) { .cols { grid-template-columns: 1.3fr 1fr; align-items: start; } }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 13px; font-weight: 700; }
.field input, .field textarea, .field select { border: 1px solid var(--line); background: var(--bg); border-radius: 11px; padding: 10px 12px; outline: none; width: 100%; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.field .hint { font-size: 12px; color: var(--muted); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .row2 { grid-template-columns: 1fr; } }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 12px; }
.seg button { border: 0; background: none; padding: 9px; border-radius: 9px; font-weight: 700; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.line { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.line:last-child { border-bottom: 0; }
.total { display: flex; justify-content: space-between; font-weight: 800; font-size: 18px; padding-top: 12px; }
.empty { text-align: center; padding: 48px 16px; }
.empty .big { font-size: 48px; }
.err { background: var(--bad-soft); color: var(--bad-ink); padding: 10px 12px; border-radius: 10px; font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.ok { background: var(--brand-soft); color: var(--brand); padding: 10px 12px; border-radius: 10px; font-size: 14px; font-weight: 600; margin-bottom: 12px; }

/* tracking */
.steps { list-style: none; padding: 0; margin: 18px 0; }
.steps li { display: flex; gap: 12px; align-items: flex-start; padding-bottom: 18px; position: relative; color: var(--muted); }
.steps li::before { content: ""; position: absolute; left: 13px; top: 28px; bottom: 0; width: 2px; background: var(--line); }
.steps li:last-child::before { display: none; }
.steps .ic { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); background: var(--card); flex: none; display: grid; place-items: center; font-size: 13px; z-index: 1; }
.steps li.done { color: var(--ink); }
.steps li.done .ic { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.steps li.now { color: var(--ink); font-weight: 700; }
.steps li.now .ic { border-color: var(--brand); color: var(--brand); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--brand) 40%, transparent); } 50% { box-shadow: 0 0 0 7px transparent; } }

/* admin */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.table-wrap { overflow-x: auto; }
.p-card { display: flex; flex-direction: column; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.p-card:last-child { border-bottom: 0; }
.p-ico { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 24px; flex: none; }
.p-main { flex: 1; min-width: 200px; }
.p-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-tabs { display: flex; gap: 6px; margin: 16px 0; flex-wrap: wrap; }
code { background: var(--bg); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; font-size: 13px; word-break: break-all; }

.skel { background: linear-gradient(90deg, var(--line), var(--card), var(--line)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 14px; }
@keyframes sk { to { background-position: -200% 0; } }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; z-index: 50; max-width: calc(100% - 32px); }

.foot { border-top: 1px solid var(--line); padding: 18px 0 100px; font-size: 13px; color: var(--muted); }
.foot-row { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

@media (max-width: 520px) {
  h1 { font-size: 24px; }
  .hero h1 { font-size: 24px; }
  .link { display: none; }
  .hero::after { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
