/* POS (worker / cashier) — iPad-first touch UI */
.pos-body { overflow: hidden; height: 100vh; height: 100dvh; }
.pos-app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

.topbar {
  display: flex; align-items: center; gap: 12px; padding: 8px 14px;
  background: var(--ink); color: #fff; min-height: 60px; padding-top: max(8px, env(safe-area-inset-top));
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; }
.topbar .brand i { color: var(--accent); }
.topbar .brand small { font-weight: 400; opacity: 0.7; font-size: 13px; }
.topbar .tb-btn { min-height: 44px; padding: 0 14px; border-radius: 10px; color: #fff; background: rgba(255,255,255,0.1); font-weight: 700; display: inline-flex; align-items: center; gap: 8px; }
.topbar .tb-btn.active { background: var(--accent); color: var(--accent-ink); }
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; opacity: 0.85; }
.conn .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); }
.conn.off .dot { background: var(--danger); }
.conn.printer-warn .dot { background: var(--warn); }

.pos-main { flex: 1; min-height: 0; display: flex; }

/* ---- Tables screen */
.tables-screen { flex: 1; overflow: auto; padding: 16px; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; font-size: 14px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.tables-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.table-card {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 130px; border-radius: 18px; background: var(--surface); border: 2px solid var(--line);
  box-shadow: var(--shadow); text-align: center; transition: transform 0.08s;
}
.table-card:active { transform: scale(0.97); }
.table-card .tnum { font-size: 34px; font-weight: 800; line-height: 1; }
.table-card .tlabel { font-size: 13px; color: var(--muted); }
.table-card .tinfo { font-size: 14px; font-weight: 700; color: var(--ink-2); }
.table-card .tstate { position: absolute; top: 8px; right: 8px; font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 800; }
.table-card.empty { border-color: var(--line); }
.table-card.empty .tstate { background: #eee; color: #777; }
.table-card.occupied { border-color: var(--accent); background: #fff8e8; }
.table-card.occupied .tstate { background: var(--accent); color: var(--accent-ink); }
.table-card.billing { border-color: var(--info); background: #eef5fb; }
.table-card.billing .tstate { background: var(--info); color: #fff; }
.table-card.awaiting_payment { border-color: var(--ok); background: #e9f7ee; }
.table-card.awaiting_payment .tstate { background: var(--ok); color: #fff; }
.c-empty { background: #ddd; } .c-occ { background: var(--accent); } .c-bill { background: var(--info); } .c-pay { background: var(--ok); }

/* ---- Order screen */
.order-screen { flex: 1; display: grid; grid-template-columns: 1fr 380px; min-height: 0; }
.catalog { display: flex; flex-direction: column; min-height: 0; border-inline-end: 1px solid var(--line); }
.cat-tabs { display: flex; gap: 8px; padding: 10px 14px; overflow-x: auto; background: var(--surface); border-bottom: 1px solid var(--line); scrollbar-width: none; }
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tab { flex: 0 0 auto; min-height: 46px; padding: 0 18px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-weight: 700; display: inline-flex; align-items: center; gap: 8px; }
.cat-tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.products-grid { flex: 1; overflow: auto; padding: 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; align-content: start; }
.product-card {
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
  box-shadow: var(--shadow); text-align: right; min-height: 150px; position: relative; transition: transform 0.08s;
}
.product-card:active { transform: scale(0.96); }
.product-card .pimg { height: 90px; background: var(--surface-2) center/cover no-repeat; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 30px; }
.product-card .pbody { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.product-card .pname { font-weight: 700; font-size: 15px; line-height: 1.3; }
.product-card .pprice { color: var(--brand); font-weight: 800; font-size: 15px; }
.product-card .pqty { position: absolute; top: 6px; left: 6px; background: var(--brand); color: #fff; min-width: 28px; height: 28px; border-radius: 999px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; box-shadow: var(--shadow); }
.product-card.unavailable { opacity: 0.45; filter: grayscale(1); }

.ticket-pane { display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.ticket-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.ticket-head h2 { font-size: 18px; }
.ticket-body { flex: 1; overflow: auto; }
.ticket-section { padding: 10px 14px 4px; font-size: 12px; font-weight: 800; color: var(--muted); letter-spacing: 0.3px; display: flex; justify-content: space-between; }
.line { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.line .lname { flex: 1; font-weight: 700; font-size: 15px; }
.line .lname small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.line .lprice { font-weight: 700; min-width: 70px; text-align: left; direction: ltr; font-variant-numeric: tabular-nums; }
.qty-ctl { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.qty-ctl button { width: 40px; height: 40px; font-size: 18px; font-weight: 800; background: var(--surface-2); }
.qty-ctl button.del { color: var(--danger); }
.qty-ctl span { min-width: 34px; text-align: center; font-weight: 800; }
.line.sent { background: #fbfaf7; }
.line.sent .lname { color: var(--ink-2); }
.ticket-foot { border-top: 1px solid var(--line); padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.total-row { display: flex; justify-content: space-between; align-items: baseline; font-weight: 800; font-size: 20px; }
.total-row .sub { font-size: 13px; color: var(--muted); font-weight: 600; }
.foot-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.foot-actions .span2 { grid-column: 1 / -1; }
.print-status { display: flex; flex-wrap: wrap; gap: 6px; }
.pj { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 8px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); }
.pj.printed { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.pj.failed { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.pj.pending, .pj.printing { background: var(--warn-bg); color: #7a5200; border-color: transparent; }
.pj button { text-decoration: underline; font-weight: 700; color: inherit; }

/* Bill modal */
.bill { font-variant-numeric: tabular-nums; }
.bill .bl { display: grid; grid-template-columns: 1fr 50px 90px 100px; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); align-items: center; }
.bill .bl.head { font-size: 12px; color: var(--muted); font-weight: 800; border-bottom: 1px solid var(--line); }
.bill .bl .n { direction: ltr; text-align: left; }
.bill .btotal { display: flex; justify-content: space-between; font-size: 24px; font-weight: 800; padding-top: 12px; }
.bill .bsec { display: flex; justify-content: space-between; color: var(--muted); font-size: 14px; }
.pay-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.change-box { background: var(--ok-bg); color: var(--ok); border-radius: 12px; padding: 10px 14px; font-weight: 800; font-size: 18px; display: flex; justify-content: space-between; }

/* Responsive: iPad portrait / small */
@media (max-width: 1024px) {
  .order-screen { grid-template-columns: 1fr 340px; }
  .products-grid { grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); }
}
@media (max-width: 820px) {
  .order-screen { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .catalog { border-inline-end: 0; }
  .ticket-pane { max-height: 46vh; border-top: 2px solid var(--line); }
  .ticket-pane.collapsed .ticket-body { display: none; }
}
@media (min-width: 1400px) {
  .order-screen { grid-template-columns: 1fr 440px; }
  .products-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
  .tables-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}
