/* POA POS — till styling.
   Built for a shop counter: large tap targets, high contrast under bright light,
   no external fonts or CDNs so the UI renders identically with no network. */

:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --line: #e2e8f0;
  --brand: #0f766e;
  --brand-ink: #ffffff;
  --brand-soft: #ccfbf1;
  --accent: #b45309;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #a16207;
  --warn-soft: #fef9c3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
.app-loading { display: grid; place-items: center; height: 100vh; color: var(--ink-2); }

/* ------------------------------------------------------------------ layout */
.shell { display: grid; grid-template-rows: auto 1fr; height: 100vh; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; background: var(--ink); color: #fff;
  padding-top: max(10px, env(safe-area-inset-top));
}
.brand { font-weight: 800; letter-spacing: .02em; }
.brand small { display: block; font-weight: 500; font-size: 11px; color: #94a3b8; letter-spacing: .06em; text-transform: uppercase; }
.nav { display: flex; gap: 4px; margin-left: 8px; flex-wrap: wrap; }
.nav button {
  background: transparent; color: #cbd5e1; border: 0; padding: 8px 12px;
  border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer;
}
.nav button:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav button[aria-current="page"] { background: var(--brand); color: #fff; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 999px;
  background: rgba(255,255,255,.1); color: #e2e8f0; white-space: nowrap;
}
.pill.ok { background: var(--ok-soft); color: #14532d; }
.pill.warn { background: var(--warn-soft); color: #713f12; }
.pill.bad { background: var(--danger-soft); color: #7f1d1d; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

main { overflow: auto; padding: 14px; }
main.till-main { padding: 0; overflow: hidden; }

/* ------------------------------------------------------------------- till */
.till {
  display: grid; grid-template-columns: 1fr 400px; gap: 0;
  height: 100%; overflow: hidden;
}
.till-left { display: grid; grid-template-rows: auto auto 1fr; overflow: hidden; background: var(--surface-2); }
.till-right { display: grid; grid-template-rows: auto 1fr auto; background: var(--surface); border-left: 1px solid var(--line); overflow: hidden; }

.scanbar { padding: 12px 14px; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; gap: 8px; }
.scanbar input {
  flex: 1; font-size: 17px; padding: 12px 14px; border: 2px solid var(--line);
  border-radius: var(--radius); font-family: inherit;
}
.scanbar input:focus { outline: 0; border-color: var(--brand); }

.cats { display: flex; gap: 6px; padding: 10px 14px; overflow-x: auto; background: var(--surface); border-bottom: 1px solid var(--line); }
.cats button {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  padding: 7px 12px; border-radius: 999px; font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.cats button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px; padding: 14px; overflow: auto; align-content: start;
}
.tile {
  text-align: left; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 11px; cursor: pointer; font: inherit;
  display: grid; gap: 4px; min-height: 92px; align-content: start;
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.tile:hover { border-color: var(--brand); }
.tile:active { transform: scale(.985); }
.tile-name { font-weight: 650; line-height: 1.25; font-size: 14px; }
.tile-price { font-weight: 800; color: var(--brand); }
.tile-meta { font-size: 11px; color: var(--ink-3); display: flex; justify-content: space-between; gap: 6px; }
.tile.out { opacity: .55; }
.tile .badge-promo { font-size: 10px; font-weight: 800; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }

/* cart */
.cart-head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.cart-head h2 { margin: 0; font-size: 15px; }
.cart-lines { overflow: auto; padding: 6px 0; }
.cart-empty { padding: 40px 20px; text-align: center; color: var(--ink-3); }
.line { padding: 10px 14px; border-bottom: 1px solid var(--surface-2); display: grid; gap: 6px; }
.line-top { display: flex; gap: 8px; align-items: baseline; }
.line-name { font-weight: 650; flex: 1; line-height: 1.25; }
.line-total { font-weight: 800; font-variant-numeric: tabular-nums; }
.line-bottom { display: flex; align-items: center; gap: 6px; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.qty button { width: 34px; height: 32px; border: 0; background: var(--surface-2); font-size: 17px; font-weight: 700; cursor: pointer; color: var(--ink); }
.qty button:hover { background: var(--brand-soft); }
.qty input { width: 46px; height: 32px; border: 0; text-align: center; font: inherit; font-weight: 700; font-variant-numeric: tabular-nums; }
.line-unit { font-size: 12px; color: var(--ink-3); }
.line-actions { margin-left: auto; display: flex; gap: 4px; }
.line-note { font-size: 11px; font-weight: 700; }
.line-note.promo { color: var(--accent); }
.line-note.disc { color: var(--ok); }

.totals { border-top: 1px solid var(--line); padding: 12px 14px; background: var(--surface-2); }
.trow { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-2); padding: 2px 0; font-variant-numeric: tabular-nums; }
.trow.grand { font-size: 22px; font-weight: 800; color: var(--ink); padding-top: 8px; margin-top: 6px; border-top: 1px dashed var(--line); }
.trow.disc { color: var(--ok); font-weight: 700; }

/* --------------------------------------------------------------- controls */
button { font-family: inherit; }
.btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 10px 14px; border-radius: var(--radius); font: inherit; font-weight: 650;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 5px 9px; font-size: 12px; }
.btn.block { width: 100%; }
.btn.pay { font-size: 19px; padding: 16px; font-weight: 800; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

label.field { display: grid; gap: 5px; font-size: 12px; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: .03em; }
label.field input, label.field select, label.field textarea {
  font: inherit; text-transform: none; letter-spacing: 0; font-weight: 500;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink);
}
label.field input:focus, label.field select:focus, label.field textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--ink); }
label.check input { width: 18px; height: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }

/* ----------------------------------------------------------------- panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden; }
.panel > header { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.panel > header h2 { margin: 0; font-size: 15px; }
.panel > header .spacer { margin-left: auto; }
.panel-body { padding: 14px; }
.muted { color: var(--ink-2); }
.tiny { font-size: 12px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.right { text-align: right; }
h1.page { margin: 0 0 14px; font-size: 20px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); background: var(--surface-2); position: sticky; top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 700; }
.stat .v { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 3px; }
.stat .s { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.stat.good .v { color: var(--ok); }
.stat.bad .v { color: var(--danger); }

.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.tag.ok { background: var(--ok-soft); color: #14532d; border-color: transparent; }
.tag.bad { background: var(--danger-soft); color: #7f1d1d; border-color: transparent; }
.tag.warn { background: var(--warn-soft); color: #713f12; border-color: transparent; }

/* ------------------------------------------------------------------ modal */
.backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.55);
  display: grid; place-items: center; padding: 16px; z-index: 50;
}
.modal {
  background: var(--surface); border-radius: 14px; box-shadow: 0 24px 64px rgba(0,0,0,.3);
  width: min(560px, 100%); max-height: 92vh; display: grid; grid-template-rows: auto 1fr auto; overflow: hidden;
}
.modal.wide { width: min(860px, 100%); }
.modal > header { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal > header h2 { margin: 0; font-size: 17px; }
.modal > header button { margin-left: auto; }
.modal-body { padding: 16px; overflow: auto; display: grid; gap: 14px; align-content: start; }
.modal > footer { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; background: var(--surface-2); }

/* payment */
.pay-total { text-align: center; padding: 14px; background: var(--ink); color: #fff; border-radius: var(--radius); }
.pay-total .k { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #94a3b8; font-weight: 700; }
.pay-total .v { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; }
.methods { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.methods button { padding: 14px 10px; font-weight: 700; }
.methods button[aria-pressed="true"] { background: var(--brand); color: #fff; border-color: var(--brand); }
.quickcash { display: grid; grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); gap: 6px; }
.tender-list { display: grid; gap: 6px; }
.tender-row { display: flex; align-items: center; gap: 8px; padding: 9px 11px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.tender-row .amt { margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; }
.balance { text-align: center; font-size: 17px; font-weight: 800; padding: 11px; border-radius: var(--radius); }
.balance.due { background: var(--warn-soft); color: #713f12; }
.balance.change { background: var(--ok-soft); color: #14532d; }

/* receipt */
.receipt {
  font-family: var(--mono); font-size: 12.5px; line-height: 1.5;
  background: #fff; color: #000; padding: 14px; border: 1px dashed var(--line); border-radius: 8px;
  max-width: 340px; margin: 0 auto; white-space: pre-wrap;
}
.receipt .c { text-align: center; }
.receipt .r { display: flex; justify-content: space-between; gap: 8px; }
.receipt hr { border: 0; border-top: 1px dashed #999; margin: 6px 0; }
.receipt .big { font-size: 15px; font-weight: 700; }

/* toast */
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 90; width: min(440px, calc(100% - 32px)); }
.toast { padding: 12px 14px; border-radius: var(--radius); background: var(--ink); color: #fff; box-shadow: var(--shadow); font-weight: 600; font-size: 14px; }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }

.empty { padding: 40px 16px; text-align: center; color: var(--ink-3); }
.banner { padding: 11px 14px; border-radius: var(--radius); margin-bottom: 12px; font-weight: 650; font-size: 14px; }
.banner.warn { background: var(--warn-soft); color: #713f12; }
.banner.bad { background: var(--danger-soft); color: #7f1d1d; }
.banner.info { background: var(--brand-soft); color: #134e4a; }

/* sign-in */
.signin { display: grid; place-items: center; height: 100vh; background: var(--ink); padding: 16px; }
.signin-card { background: var(--surface); padding: 26px; border-radius: 16px; width: min(360px, 100%); box-shadow: 0 24px 64px rgba(0,0,0,.4); text-align: center; }
.signin-card h1 { margin: 0 0 4px; font-size: 21px; }
.pin-display { font-size: 30px; letter-spacing: 12px; height: 46px; margin: 16px 0; font-family: var(--mono); color: var(--brand); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad button { padding: 17px 0; font-size: 20px; font-weight: 700; }

/* -------------------------------------------------------------- responsive */
@media (max-width: 980px) {
  .till { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .till-right { border-left: 0; border-top: 1px solid var(--line); max-height: 52vh; }
  .nav button { padding: 8px 10px; font-size: 13px; }
}

/* ------------------------------------------------------------------ print */
@media print {
  body { background: #fff; }
  .shell, .topbar, .backdrop > .modal > header, .backdrop > .modal > footer, .toasts { display: none !important; }
  .backdrop { position: static; background: none; padding: 0; display: block; }
  .modal { box-shadow: none; max-height: none; display: block; }
  .modal-body { padding: 0; overflow: visible; }
  .receipt { border: 0; max-width: 100%; font-size: 12px; }
  #print-root { display: block !important; }
}
#print-root { display: none; }
