:root {
  --bar: #1ba1dc;
  --blue: #1e88e5;
  --red: #e53935;
  --green: #43a047;
  --orange: #f08a24;
  --line: #d9dde1;
  --bg: #eef0f2;
  --text: #2b3036;
  --muted: #7b848d;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.35 Arial, Helvetica, sans-serif; -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; border-radius: 3px; touch-action: manipulation; }
input, select { border: 1px solid var(--line); border-radius: 3px; padding: 7px 8px; background: #fff; width: 100%; min-height: 34px; }
#app { height: 100%; }
#print { display: none; }

/* ── Top bar ── */
.bar { background: var(--bar); color: #fff; height: 44px; display: flex; align-items: center; gap: 14px; padding: 0 12px; }
.bar .brand { font-weight: 700; letter-spacing: .3px; display: flex; align-items: center; gap: 8px; }
.bar .brand img { width: 26px; height: 26px; border-radius: 6px; border: 1px solid rgba(255, 255, 255, .7); }
.bar .sp { flex: 1; }
.bar button { background: transparent; color: #fff; padding: 8px 10px; min-height: 36px; }
.bar button:active { background: rgba(255, 255, 255, .2); }
.bar .who { font-size: 12px; opacity: .9; }

/* ── Login ── */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login form { background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 24px; width: 100%; max-width: 340px; display: grid; gap: 12px; }
.login h1 { margin: 0 0 4px; font-size: 22px; text-align: center; color: var(--bar); }
.login .logo { width: 56px; height: 56px; justify-self: center; }
.login .err { color: var(--red); font-size: 13px; min-height: 18px; }

/* ── Buttons ── */
.btn { color: #fff; padding: 9px 14px; min-height: 40px; font-weight: 700; font-size: 13px; }
.btn.blue { background: var(--blue); } .btn.red { background: var(--red); } .btn.green { background: var(--green); }
.btn.grey { background: #8a939b; } .btn.orange { background: var(--orange); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

/* ── Table floor ── */
.floor { padding: 10px 12px 24px; }
.floor-head { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; padding: 4px 4px 10px; font-size: 12px; font-weight: 700; }
.floor-head .sp { flex: 1; }
.floor-head .acts { display: flex; gap: 4px; }
.floor-head .acts .btn { min-height: 36px; padding: 7px 12px; font-size: 12px; }
.tiles { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: 2px; min-height: 76px; padding: 4px 6px 10px; display: flex; flex-direction: column; align-items: center; color: var(--text); }
.tile .st { font-size: 9px; color: var(--muted); align-self: center; height: 14px; }
.tile .nm { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 19px; font-weight: 700; text-align: center; line-height: 1.1; }
.tile .nm small { font-size: 10px; font-weight: 700; }
.tile.running { background: #fff7e8; border-color: var(--orange); }
.tile.running .st { color: #c06a0c; }
.tile:active { background: #e3f1fb; }
.foot { margin-top: 14px; font-size: 11px; color: var(--muted); }

/* ── Order screen ── */
.order { display: grid; grid-template-columns: minmax(300px, 34%) 1fr; gap: 10px; padding: 8px 10px; height: calc(100% - 44px); }
.left, .right { min-height: 0; overflow: auto; }
.left { background: #fff; border: 1px solid var(--line); padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.left-head { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.left-head .back { background: none; color: var(--red); font-weight: 700; padding: 6px 4px; min-height: 36px; }
.left-head .ono { color: var(--blue); font-weight: 700; }
.cart { border: 1px solid var(--line); min-height: 170px; flex: 1 1 170px; overflow: auto; }
.cart table { width: 100%; border-collapse: collapse; font-size: 12px; }
.cart th { background: #f3f5f7; text-align: left; padding: 5px 4px; border-bottom: 1px solid var(--line); position: sticky; top: 0; }
.cart td { padding: 4px; border-bottom: 1px solid #eef0f2; vertical-align: middle; }
.cart td.n, .cart th.n { text-align: right; }
.cart tr.sent td { color: var(--muted); background: #fafbfc; }
.cart .empty { padding: 8px 6px; color: var(--muted); font-size: 12px; }
.cart .ins { font-size: 11px; color: #c06a0c; }
.qty { display: inline-flex; align-items: center; gap: 4px; }
.qty button, .ib { width: 30px; height: 30px; background: #e9edf0; font-weight: 700; }
.ib.del { background: #fde3e2; color: var(--red); }
.fields { display: grid; grid-template-columns: 92px 1fr; gap: 3px 6px; align-items: center; font-size: 12px; }
.fields input, .fields select { min-height: 30px; padding: 4px 8px; }
.fields select.hl { background: #fffbd0; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; font-size: 12px; padding: 2px 0; }
.totals .v { text-align: right; font-weight: 700; }
.totals .net { font-size: 14px; }
.left-acts { display: grid; gap: 5px; }
.left-acts .row { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.right { display: flex; flex-direction: column; gap: 8px; }
.kot-no { color: var(--blue); font-weight: 700; font-size: 13px; padding: 2px 2px 0; }
.panel { background: #fff; border: 1px solid var(--line); padding: 6px; }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
.item { background: #fff; border: 1px solid var(--line); padding: 0 0 6px; min-height: 68px; display: flex; flex-direction: column; color: var(--text); font-size: 11px; font-weight: 700; border-radius: 2px; overflow: hidden; }
.item .pr { background: var(--blue); color: #fff; font-size: 10px; padding: 2px 0; font-weight: 400; }
.item.fav .pr { background: var(--orange); }
.item .tx { flex: 1; display: flex; align-items: center; justify-content: center; padding: 4px 3px 0; text-align: center; line-height: 1.15; }
.item:active { background: #e3f1fb; }
.cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
.cat { background: var(--blue); color: #fff; min-height: 56px; font-size: 11px; font-weight: 700; padding: 4px; line-height: 1.15; border-radius: 0; }
.cat.on { background: #0d5fad; outline: 2px solid #0d5fad; outline-offset: 1px; }

/* ── Modals ── */
.ov { position: fixed; inset: 0; background: rgba(40, 46, 52, .45); display: grid; place-items: center; padding: 12px; z-index: 10; }
.box { background: #fff; border-radius: 4px; width: 100%; max-width: 420px; max-height: 94vh; overflow: auto; padding: 16px; box-shadow: 0 8px 30px rgba(0, 0, 0, .25); }
.box h2 { margin: 0; font-size: 17px; text-align: center; }
.box h3 { margin: 2px 0 10px; font-size: 16px; text-align: center; }
.box .party { text-align: center; font-size: 12px; font-weight: 700; margin-bottom: 8px; }
.box .party button { border: 1px solid #555; background: #f3f3f3; padding: 4px 8px; font-size: 12px; }
.box .grid2 { display: grid; gap: 6px; margin: 8px 0; }
.covers { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 18px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 10px 0; }
.covers button { width: 36px; height: 36px; color: #fff; font-weight: 700; font-size: 18px; }
.covers b { min-width: 36px; text-align: center; font-size: 18px; }
.box .acts { display: flex; justify-content: flex-end; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.box.wide { max-width: 760px; }
.preview { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; background: #dfe3e6; padding: 12px; margin-top: 10px; }
.preview .rc { background: #fff; padding: 4mm; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); }
.msg { text-align: center; padding: 8px 0; }

/* ── Menu management ── */
.menu { padding: 12px; display: grid; grid-template-columns: 240px 1fr; gap: 12px; }
.menu h2 { margin: 0 0 8px; font-size: 15px; }
.menu .list button { display: block; width: 100%; text-align: left; background: #fff; border: 1px solid var(--line); padding: 10px; margin-bottom: 4px; min-height: 40px; }
.menu .list button.on { background: var(--blue); color: #fff; }
.menu .list button.off { opacity: .5; }
.menu table { width: 100%; border-collapse: collapse; background: #fff; }
.menu th, .menu td { border: 1px solid var(--line); padding: 5px 6px; text-align: left; font-size: 13px; }
.menu td input[type=checkbox] { width: 20px; min-height: 20px; }
.menu .add { display: flex; gap: 6px; margin: 8px 0; }
.menu .note { font-size: 12px; color: var(--muted); margin: 6px 0; }

/* ── Receipts (80mm thermal) ── */
.rc { width: 72mm; color: #000; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.3; }
.rc table { width: 100%; border-collapse: collapse; }
.rc td, .rc th { padding: 0; vertical-align: top; }
.rc .r { text-align: right; }
.rc .rule { border-top: 1px solid #000; margin: 5px 0; }
.rc .dots { border-top: 1px dotted #000; margin: 3px 0; }
/* KOT */
.rc.kot { font-size: 16px; line-height: 1.25; }
.rc.kot .title { text-align: center; padding: 6px 0 8px; }
.rc.kot .kv td { padding: 4px 0; }
.rc.kot .kv td:first-child { width: 44%; }
.rc.kot .kv td { white-space: nowrap; }
.rc.kot .lines th { font-weight: 400; text-align: left; }
.rc.kot .lines td { padding-top: 2px; }
.rc.kot .lines .q { width: 14mm; text-align: right; padding-right: 3mm; }
.rc.kot .note { font-size: 13px; padding-left: 3mm; }
/* Provisional bill */
.rc.bill .pb { text-align: center; font-size: 17px; font-weight: 700; letter-spacing: .5px; padding: 4px 0 6px; }
.rc.bill .nm { text-align: center; font-size: 17px; font-weight: 700; }
.rc.bill .ad { text-align: center; font-size: 12px; }
.rc.bill .kv { margin-left: 2mm; width: auto; }
.rc.bill .kv td:first-child { width: 27mm; }
.rc.bill .lines th { text-align: left; font-size: 12px; border-top: 1px solid #000; border-bottom: 1px solid #000; padding: 2px 0; }
.rc.bill .lines td { padding: 4px 0 3px; }
.rc.bill .lines .q { width: 6mm; text-align: right; }
.rc.bill .lines .p { width: 10mm; text-align: right; }
.rc.bill .lines .t { width: 11mm; text-align: right; }
.rc.bill .sum td { padding: 1px 0; }
.rc.bill .sum td:first-child { padding-left: 2mm; }
.rc.bill .kots { text-align: center; padding-top: 2px; }

@media (max-width: 900px) {
  .tiles { grid-template-columns: repeat(6, 1fr); }
  .order { grid-template-columns: minmax(280px, 40%) 1fr; }
}
@media (max-width: 640px) {
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .order { grid-template-columns: 1fr; height: auto; }
  .menu { grid-template-columns: 1fr; }
}

@media print {
  @page { size: 80mm auto; margin: 0; }
  html, body { height: auto; background: #fff; }
  #app, #modal { display: none !important; }
  #print { display: block; }
  #print .rc { padding: 3mm 4mm 8mm; page-break-after: always; break-after: page; }
  #print .rc:last-child { page-break-after: auto; break-after: auto; }
}
