/* GastroPOS v0.2.4 */
:root {
  --bg: #f4f2ee; --panel: #ffffff; --ink: #1f2328; --muted: #6b7078; --line: #e3dfd8;
  --accent: #9b1c31; --accent-ink: #fff; --ok: #1f7a4d; --warn: #b26b00; --bad: #b42318;
  --radius: 10px; font-size: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html, body { max-width: 100%; overflow-x: hidden; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; }
.right { text-align: right; }

.btn { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: var(--radius); padding: .6rem .9rem; font: inherit; cursor: pointer; min-height: 44px; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; font-weight: 600; }
.btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sel { outline: 3px solid var(--accent); }
.btn:disabled { opacity: .45; }

/* Top bar */
.topbar { display: flex; align-items: center; gap: .75rem; overflow-x: auto; white-space: nowrap; padding: .5rem .9rem; background: var(--ink); color: #fff; }
.topbar a, .topbar .btn.ghost { color: #fff; text-decoration: none; }
.topbar .brand { font-weight: 700; letter-spacing: .02em; }
.topbar .tab { padding: .4rem .7rem; border-radius: 8px; color: #cfd3d8; cursor: pointer; }
.topbar .tab.on { background: #ffffff22; color: #fff; }

/* Login */
.login { max-width: 320px; margin: 8vh auto; text-align: center; }
.pin-dots { height: 2rem; font-size: 1.6rem; letter-spacing: .4rem; }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin-top: 1rem; }
.pinpad .btn { font-size: 1.4rem; min-height: 64px; }
.error { color: var(--bad); min-height: 1.2rem; }

/* Kasa */
.pos { display: grid; grid-template-columns: 1fr 380px; height: calc(100vh - 52px); }
.pos-left { display: flex; flex-direction: column; min-width: 0; }
.cats { display: flex; gap: .4rem; padding: .6rem; overflow-x: auto; background: var(--panel); border-bottom: 1px solid var(--line); }
.cats .btn { white-space: nowrap; color: #fff; border: none; font-weight: 600; font-size: .85rem; }
.products { flex: 1; overflow: auto; padding: .6rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .5rem; align-content: start; }
.prod { text-align: left; min-height: 86px; display: flex; flex-direction: column; justify-content: space-between; border-left: 6px solid var(--muted); }
.prod .price { font-weight: 700; }
.prod .alg { font-size: .7rem; color: var(--warn); }
.ticket { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.ticket-head { padding: .7rem .9rem; border-bottom: 1px solid var(--line); }
.ticket-items { flex: 1; overflow: auto; }
.item { padding: .55rem .9rem; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: .2rem; cursor: pointer; }
.item.void { text-decoration: line-through; color: var(--muted); }
.item .mods, .item .note { font-size: .8rem; color: var(--muted); }
.item .sent { font-size: .7rem; color: var(--ok); }
.ticket-foot { padding: .7rem .9rem; border-top: 1px solid var(--line); }
.total { font-size: 1.6rem; font-weight: 700; }
.ticket-foot .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; margin-top: .5rem; }

/* Sala */
.sala { display: flex; flex-wrap: wrap; }
.sala-side { flex: 1; min-width: 280px; }
.floor { position: relative; flex: 1 1 480px; min-width: 480px; margin: .8rem; background: var(--panel); border-radius: var(--radius); border: 1px solid var(--line); min-height: 380px; }
.table { position: absolute; width: 110px; height: 90px; border-radius: 14px; border: 2px solid var(--line); background: #faf8f5; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; }
.table.busy { border-color: var(--accent); background: #9b1c3112; }
.table b { font-size: 1.1rem; }
.list { padding: .8rem; display: grid; gap: .5rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; }
.card.click { cursor: pointer; }
.badge { display: inline-block; font-size: .72rem; padding: .1rem .45rem; border-radius: 99px; background: #eee; }
.badge.nowe { background: #fde68a; } .badge.w_przygotowaniu { background: #bfdbfe; } .badge.gotowe { background: #bbf7d0; }
.badge.blad { background: #fecaca; } .badge.oczekuje { background: #fde68a; } .badge.wydrukowany { background: #bbf7d0; }

/* Modal / formularze */
#modal { position: fixed; inset: 0; background: #0007; display: flex; align-items: center; justify-content: center; z-index: 50; padding: 1rem; }
.modal-box { background: var(--panel); border-radius: 14px; width: min(460px, 100%); max-height: 92vh; display: flex; flex-direction: column; }
.modal-box.wide { width: min(900px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 1rem; overflow: auto; }
.form { display: grid; gap: .7rem; }
.form label { display: grid; gap: .25rem; font-size: .9rem; color: var(--muted); }
input, select, textarea { font: inherit; padding: .55rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); min-height: 42px; }
.checks { display: flex; flex-wrap: wrap; gap: .4rem; }
.checks label { display: flex; gap: .3rem; align-items: center; background: #f6f4f0; padding: .3rem .55rem; border-radius: 8px; color: var(--ink); font-size: .85rem; }
.checks input { min-height: auto; }

/* Tabele panelu */
.page { padding: 1rem; max-width: 1200px; margin: 0 auto; }
table.data { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; }
table.data th, table.data td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); text-align: left; font-size: .92rem; }
table.data th { background: #f6f4f0; font-weight: 600; }
table.data tr.off td { color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; }
.kpi b { display: block; font-size: 1.4rem; }

/* KDS */
.kds { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .7rem; padding: .8rem; }
.kds .card h3 { display: flex; justify-content: space-between; }
.kds .late { border-color: var(--bad); box-shadow: 0 0 0 2px var(--bad); }
.kds li { margin: .25rem 0; }

#toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); display: grid; gap: .4rem; z-index: 60; }
.toast { background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: 10px; }
.toast.error { background: var(--bad); } .toast.ok { background: var(--ok); }

/* Bon kuchenny / paragon niefiskalny do druku */
#print-area { display: none; }
@media print {
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block; font: 13px/1.35 monospace; width: 72mm; }
  #print-area h2 { font-size: 16px; }
}

@media (max-width: 900px) {
  .pos { grid-template-columns: 1fr; height: auto; }
  .products { max-height: 52vh; }
  .ticket { border-left: none; border-top: 1px solid var(--line); }
  .ticket-items { max-height: 40vh; }
  .ticket-foot { position: sticky; bottom: 0; background: var(--panel); }
}

/* Telefon i wąskie okna (0.2.4) */
@media (max-width: 700px) {
  :root { font-size: 15px; }
  .topbar { gap: .25rem; padding: .4rem .5rem; }
  .topbar .tab { padding: .4rem .5rem; }
  .topbar .muted.small { display: none; }
  .sala-side { min-width: 0; flex-basis: 100%; }
  .floor { min-width: 0; flex-basis: 100%; min-height: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .5rem; padding: .6rem; }
  .floor .table { position: static; width: auto; height: 80px; }
  .products { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .page { padding: .6rem; }
  table.data { display: block; overflow-x: auto; white-space: nowrap; }
  #modal { padding: .4rem; align-items: flex-start; }
  .modal-box { max-height: calc(100dvh - .8rem); width: 100%; }
  .modal-body { padding: .8rem; }
  .row > label { flex: 1 1 140px; }
  input, select, textarea { font-size: 16px; }   /* bez automatycznego powiększania na iPhonie */
  .kpis { grid-template-columns: 1fr 1fr; }
  .kds { grid-template-columns: 1fr; }
}