:root {
  --blue: #1565c0; --blue-d: #0d47a1; --blue-l: #1e88e5; --tile: #1e88e5; --tile-d: #0d3f8a;
  --bg: #f4efe6; --paper: #fff; --paper2: #fbfaf6; --ink: #1b1b1b; --muted: #6b6b6b;
  --line: #e0dbd0; --line2: #c9c2b4; --th: #eef1f8; --pad: #f1ede4; --zone: #ded8cc;
  --navon: #eef4fb; --toast: #222; --warn: #fff6e0; --shadow: rgba(0,0,0,.08);
  --green: #2ecc40; --red: #e53935; --amber: #f5b400;
  --topbar: 52px;
}
[data-theme="dark"] {
  --blue: #1976d2; --blue-d: #64b5f6; --blue-l: #42a5f5; --tile: #1b5e9e; --tile-d: #0d3f8a;
  --bg: #121417; --paper: #1c2025; --paper2: #232830; --ink: #e6e6e6; --muted: #9aa2ad;
  --line: #2e343c; --line2: #3a4049; --th: #232a36; --pad: #2a3038; --zone: #2a3038;
  --navon: #1a2836; --toast: #3a4049; --warn: #3a3115; --shadow: rgba(0,0,0,.5);
  --green: #43a047; --red: #e53935; --amber: #f5b400;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.35 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink); overscroll-behavior: none;
  display: flex; flex-direction: column;
}
button { font: inherit; cursor: pointer; border: 0; border-radius: 8px; }
button:active { filter: brightness(.92); }
input, select { font: inherit; padding: 9px 10px; border: 1px solid var(--line2); border-radius: 8px; background: var(--paper); width: 100%; }
input[type=checkbox] { width: auto; }
[hidden] { display: none !important; }

/* top bar */
#topbar {
  height: var(--topbar); background: var(--blue); color: #fff; display: flex; align-items: center;
  padding: 0 10px; gap: 10px; flex: 0 0 auto; position: sticky; top: 0; z-index: 5;
  padding-top: env(safe-area-inset-top);
}
#title { flex: 1; text-align: center; font-weight: 600; letter-spacing: .5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#topright { display: flex; gap: 8px; align-items: center; }
.icon-btn { background: transparent; color: #fff; font-weight: 700; padding: 8px 6px; }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: var(--green); margin-right: 6px; box-shadow: 0 0 0 2px rgba(255,255,255,.35); }

#view { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* generic */
.btn { background: var(--blue); color: #fff; padding: 12px 16px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.btn.sec { background: var(--paper); color: var(--blue); border: 1px solid var(--blue); }
.btn.ghost { background: transparent; color: var(--blue); }
.btn.red { background: var(--red); }
.btn.green { background: #2e7d32; }
.btn.big { font-size: 17px; padding: 16px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.card { background: var(--paper); border-radius: 12px; padding: 14px; box-shadow: 0 1px 3px var(--shadow); }
.center { text-align: center; }
h2 { margin: 6px 0 12px; font-size: 18px; }

/* waiter pick */
.waiters { padding: 20px; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); max-width: 700px; margin: 0 auto; width: 100%; }
.waiter { background: var(--paper); padding: 26px 10px; font-size: 20px; font-weight: 700; border-radius: 12px; box-shadow: 0 1px 4px var(--shadow); color: var(--blue-d); }

/* tables */
.zones { display: flex; gap: 6px; padding: 10px 12px 0; }
.zone { padding: 8px 16px; border-radius: 8px 8px 0 0; background: var(--zone); font-weight: 600; text-transform: uppercase; font-size: 13px; }
.zone.on { background: var(--blue); color: #fff; }
.tables { display: grid; gap: 8px; padding: 12px; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
.tbl {
  aspect-ratio: 1; background: var(--tile); color: #fff; border-radius: 10px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-weight: 700; font-size: 20px; position: relative; padding: 4px;
}
.tbl.open { background: #0d3f8a; outline: 3px solid var(--green); outline-offset: -3px; }
.tbl .dot { position: absolute; top: 7px; right: 7px; margin: 0; }
.tbl .tot { font-size: 12px; font-weight: 500; opacity: .95; }
.tbl .who { font-size: 11px; font-weight: 400; opacity: .85; }
.tbl.unsent::after { content: ""; position: absolute; left: 7px; top: 7px; width: 11px; height: 11px; border-radius: 50%; background: var(--amber); }

/* order screen */
.order { display: flex; flex: 1; min-height: 0; }
.order-left { width: 320px; flex: 0 0 auto; background: var(--paper); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.order-left .head { background: #f5b400; color: #333; font-weight: 700; padding: 10px 12px; font-size: 13px; letter-spacing: .3px; }
.lines { flex: 1; overflow: auto; }
.ln { padding: 8px 12px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; }
.ln .nm { font-weight: 600; }
.ln .pr { text-align: right; font-weight: 600; }
.ln .sub { font-size: 12px; color: var(--muted); }
.ln .ctl { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.ln .ctl button { width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--blue); background: var(--paper); color: var(--blue); font-size: 18px; line-height: 1; padding: 0; }
.ln .ctl .rm { border-color: var(--red); color: var(--red); }
.ln.sent { background: var(--paper2); }
.ln .sent-tag { font-size: 10px; background: rgba(46,125,50,.15); color: var(--green); padding: 1px 5px; border-radius: 4px; margin-left: 4px; }
.total { background: var(--blue); color: #fff; padding: 12px 14px; display: flex; justify-content: space-between; font-weight: 700; font-size: 18px; }
.order-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 8px; background: var(--paper); border-top: 1px solid var(--line); }
.order-right { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.tools { display: flex; gap: 8px; padding: 8px 10px; align-items: center; }
.tools input { flex: 1; }
.cats { display: flex; gap: 6px; padding: 0 10px 8px; overflow-x: auto; scrollbar-width: none; flex: 0 0 auto; }
.cats::-webkit-scrollbar { display: none; }
.cat { flex: 0 0 auto; padding: 8px 12px; border-radius: 20px; background: var(--paper); border: 1px solid var(--line2); font-size: 13px; font-weight: 600; white-space: nowrap; }
.cat.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.items { flex: 1; overflow: auto; display: grid; gap: 8px; padding: 0 10px 12px; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); align-content: start; }
.item { background: var(--tile); color: #fff; border-radius: 10px; min-height: 84px; display: flex; flex-direction: column; overflow: hidden; text-align: center; padding: 0; }
.item .nm { flex: 1; display: flex; align-items: center; justify-content: center; padding: 6px; font-weight: 700; font-size: 14px; line-height: 1.15; }
.item .pr { background: rgba(0,0,0,.28); font-size: 12px; padding: 3px; }
.item.noprice .pr { color: #ffd; }

/* mobile bottom sheet */
.sheet-bar { display: none; }
@media (max-width: 760px) {
  .order-left { position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; height: 72vh; border-right: 0; border-radius: 16px 16px 0 0; box-shadow: 0 -4px 16px rgba(0,0,0,.25); transform: translateY(100%); transition: transform .2s; z-index: 6; }
  .order-left.show { transform: translateY(0); }
  .sheet-bar { display: flex; position: sticky; bottom: 0; background: var(--blue); color: #fff; padding: 10px 12px; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 4; }
  .sheet-bar .pill { background: rgba(255,255,255,.2); border-radius: 20px; padding: 4px 10px; font-size: 13px; }
  .items { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); padding-bottom: 8px; }
  .backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 5; }
  .tables { grid-template-columns: repeat(4, 1fr); }
}

/* arka */
.arka { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px; max-width: 900px; margin: 0 auto; width: 100%; }
.arka .card { display: flex; flex-direction: column; gap: 10px; }
.arka .lines { max-height: 40vh; }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pad button { padding: 14px; font-size: 20px; background: var(--pad); font-weight: 600; }
.pad .del { background: var(--red); color: #fff; }
.kv { display: flex; justify-content: space-between; padding: 4px 0; }
.kv b { font-size: 17px; }
.fx { color: var(--muted); font-size: 13px; }
.seg { display: flex; border: 1px solid var(--blue); border-radius: 8px; overflow: hidden; }
.seg button { flex: 1; background: var(--paper); color: var(--blue); padding: 10px; font-weight: 700; border-radius: 0; }
.seg button.on { background: var(--blue); color: #fff; }
.amount { font-size: 26px; font-weight: 700; text-align: right; padding: 8px 12px; background: var(--paper); border: 2px solid var(--blue); border-radius: 8px; }
@media (max-width: 760px) { .arka { grid-template-columns: 1fr; } }

/* ticket preview */
.ticket { background: #fff; color: #000; font-family: "Courier New", Consolas, monospace; font-size: 12px; line-height: 1.25; padding: 14px 10px; width: 100%; max-width: 380px; margin: 0 auto; box-shadow: 0 2px 10px rgba(0,0,0,.25); white-space: pre; overflow-x: auto; }
.ticket .l { min-height: 1.25em; }
.ticket .b { font-weight: 700; }
.ticket .h2 { height: 2.4em; display: flex; align-items: center; transform: scaleY(2); }
.ticket .h2.lr { display: flex; }
.ticket .h2.c { justify-content: center; }
.ticket .w2 { transform: scaleX(2); transform-origin: left center; }
.ticket .w2.c { transform-origin: center; }
.ticket .w2.h2 { transform: scale(2); }
.ticket .c { text-align: center; }
.ticket .r { text-align: right; }
.ticket .lr { display: flex; justify-content: space-between; gap: 6px; }
.ticket .lr span:first-child { white-space: pre; overflow: hidden; }
.ticket .qr { text-align: center; padding: 6px 0; }
.ticket .qr canvas, .ticket .qr img { image-rendering: pixelated; }

/* modal + toast */
#modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 12px; }
#modal-box { background: var(--bg); color: var(--ink); border-radius: 14px; max-width: 460px; width: 100%; max-height: 92vh; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--toast); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 30; max-width: 90vw; }
#toast.err { background: var(--red); }

/* admin */
.admin { display: flex; flex: 1; min-height: 0; }
.admin nav { width: 180px; flex: 0 0 auto; background: var(--paper); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.admin nav button { text-align: left; padding: 12px 14px; background: transparent; border-radius: 0; font-weight: 600; border-left: 4px solid transparent; }
.admin nav button.on { border-left-color: var(--blue); background: var(--navon); color: var(--blue-d); }
.admin section { flex: 1; overflow: auto; padding: 14px; }
table.grid { width: 100%; border-collapse: collapse; background: var(--paper); border-radius: 10px; overflow: hidden; }
table.grid th, table.grid td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.grid th { background: var(--th); font-size: 12px; text-transform: uppercase; }
table.grid input, table.grid select { padding: 5px 6px; }
table.grid td.num { width: 90px; }
table.grid td.act { width: 60px; white-space: nowrap; }
.sbtn { padding: 5px 9px; background: var(--blue); color: #fff; font-size: 12px; font-weight: 600; }
.sbtn.red { background: var(--red); }
.form { display: grid; grid-template-columns: 200px 1fr; gap: 8px 12px; align-items: center; max-width: 720px; }
.form label { font-weight: 600; font-size: 13px; }
@media (max-width: 760px) {
  .admin { flex-direction: column; }
  .admin nav { width: auto; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .admin nav button { border-left: 0; border-bottom: 3px solid transparent; white-space: nowrap; }
  .admin nav button.on { border-bottom-color: var(--blue); }
  .form { grid-template-columns: 1fr; }
}

/* browser print (admin reports) */
@media print {
  #topbar, .admin nav, .row button, #toast, #modal { display: none !important; }
  .admin, .admin section { display: block; overflow: visible; height: auto; }
  body { background: var(--paper); }
  table.grid { page-break-inside: auto; }
  table.grid tr { page-break-inside: avoid; }
}

/* ---------- dashboard / statistics ---------- */
.tiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); margin-bottom: 14px; }
.tile { background: var(--paper); border-radius: 12px; padding: 12px 14px; box-shadow: 0 1px 3px var(--shadow); }
.tile .lbl { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.tile .val { font-size: 24px; font-weight: 700; line-height: 1.2; margin-top: 2px; }
.tile .sub { font-size: 12px; color: var(--muted); }
.tile.hi { background: var(--blue); color: #fff; }
.tile.hi .lbl, .tile.hi .sub { color: rgba(255,255,255,.85); }
.tile.warn { background: var(--warn); }
.panel { background: var(--paper); border-radius: 12px; padding: 12px 14px; box-shadow: 0 1px 3px var(--shadow); margin-bottom: 14px; }
.panel h3 { margin: 0 0 10px; font-size: 14px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.chart { width: 100%; height: 180px; overflow: visible; }
.chart .bar { fill: var(--blue-l); }
.chart .bar:hover { fill: var(--blue-d); }
.chart .ax { stroke: var(--line); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 10px; }
.chart .vlabel { fill: var(--ink); font-size: 10px; font-weight: 600; }
.hbars { display: grid; gap: 6px; }
.hbar { display: grid; grid-template-columns: 1fr auto; gap: 4px; align-items: center; font-size: 13px; }
.hbar .track { grid-column: 1 / -1; height: 8px; background: var(--line); border-radius: 5px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--blue-l); border-radius: 5px; }
.two { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 820px) { .two { grid-template-columns: 1fr; } }

/* ---------- admin extras ---------- */
.admin nav .sep { height: 1px; background: var(--line); margin: 6px 0; }
.switch { display: flex; align-items: center; gap: 10px; padding: 10px 14px; font-weight: 600; }
.switch input { width: auto; }
.badge { display: inline-block; min-width: 18px; padding: 1px 6px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; text-align: center; }
.badge.ok { background: var(--green); }
.guide h3 { margin: 18px 0 6px; }
.guide li { margin: 4px 0; }
.guide code { background: var(--pad); padding: 1px 5px; border-radius: 4px; }

/* ---------- banakieri: recipe cards ---------- */
.cards { display: grid; gap: 10px; padding: 0 12px 16px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.ccard { background: var(--paper); border-radius: 12px; padding: 10px 8px; display: flex; flex-direction: column;
  align-items: center; gap: 2px; box-shadow: 0 1px 3px var(--shadow); color: var(--ink); text-align: center; }
.ccard .pic { color: var(--muted); line-height: 0; }
.ccard .nm { font-weight: 700; font-size: 14px; line-height: 1.15; }
.ccard .mt { font-size: 11px; color: var(--blue-d); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.ccard .ing { font-size: 11px; color: var(--muted); line-height: 1.2; }
.recipe { padding: 12px; max-width: 720px; margin: 0 auto; width: 100%; }
.recipe .head { display: flex; gap: 16px; align-items: center; background: var(--paper); border-radius: 12px;
  padding: 14px; box-shadow: 0 1px 3px var(--shadow); margin-bottom: 14px; }
.recipe .big { color: var(--muted); line-height: 0; flex: 0 0 auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { background: var(--blue); color: #fff; border-radius: 20px; padding: 3px 10px; font-size: 12px; font-weight: 600; }
.steps { margin: 0; padding-left: 20px; }
.steps li { margin: 6px 0; line-height: 1.35; }
.glass { display: block; }
