/* Restaurant POS — base styles. Big touch targets, English UI, PKR. */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1a1d21;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #16a34a;      /* green: primary actions */
  --accent-dark: #15803d;
  --warn: #d97706;
  --danger: #dc2626;
  --ink: #111827;
  --radius: 12px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text);
  min-height: 100vh;
}
.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.error {
  background: #fef2f2; color: var(--danger); border: 1px solid #fecaca;
  padding: 10px 14px; border-radius: var(--radius); margin: 10px 0; font-size: 14px;
}

/* ---------- Login ---------- */
#screen-login { display: none; align-items: center; justify-content: center; padding: 20px; }
#screen-login.active { display: flex; }
.login-card {
  background: var(--surface); border-radius: 20px; padding: 36px 32px;
  width: 100%; max-width: 380px; text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,.08);
}
.login-logo { font-size: 52px; }
.login-brand h1 { margin: 8px 0 2px; font-size: 24px; }
.pin-display { display: flex; gap: 14px; justify-content: center; margin: 22px 0 6px; }
.pin-dot {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid #cbd5e1; background: #fff;
}
.pin-dot.filled { background: var(--ink); border-color: var(--ink); }
.pin-pad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0 8px;
}
.pin-pad button {
  font-size: 26px; padding: 16px 0; border-radius: var(--radius);
  border: 1px solid var(--border); background: #f9fafb; cursor: pointer;
}
.pin-pad button:active { background: #e5e7eb; }
.pin-pad .pin-fn { font-size: 20px; color: var(--muted); }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--ink); color: #fff; padding: 12px 18px;
  position: sticky; top: 0; z-index: 10;
}
.topbar .muted { color: #9ca3af; margin-left: 10px; font-size: 13px; }

/* ---------- Buttons ---------- */
.btn {
  border: none; border-radius: var(--radius); padding: 14px 18px;
  font-size: 16px; font-weight: 600; cursor: pointer;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { background: var(--accent-dark); }
.btn-secondary { background: #eef2ff; color: #1e3a8a; }
.btn-ghost { background: transparent; color: #fff; border: 1px solid #374151; padding: 8px 14px; font-size: 14px; }
.btn-toggle { background: #f3f4f6; color: var(--text); padding: 10px 14px; }
.btn-toggle.active { background: var(--ink); color: #fff; }
.link { background: none; border: none; color: #2563eb; font-size: 13px; cursor: pointer; padding: 0 4px; }

/* ---------- POS layout ---------- */
.pos-layout { display: flex; gap: 14px; padding: 14px; height: calc(100vh - 57px); }
.menu-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; }
.tabs .btn-toggle { white-space: nowrap; }
.item-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px; overflow-y: auto; padding-bottom: 20px;
}
.item-btn {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 10px; cursor: pointer; text-align: center;
}
.item-btn:active { background: #ecfdf5; border-color: var(--accent); }
.item-btn .item-name { font-weight: 600; font-size: 15px; display: block; }
.item-btn .item-price { color: var(--accent-dark); font-weight: 700; margin-top: 6px; display: block; }
.item-btn .item-code { color: var(--muted); font-size: 11px; margin-top: 2px; display: block; }

.bill-pane {
  width: 360px; min-width: 320px; background: var(--surface);
  border-radius: 16px; display: flex; flex-direction: column;
  border: 1px solid var(--border); overflow: hidden;
}
.bill-head { padding: 12px; border-bottom: 1px solid var(--border); }
.order-type-toggle { display: flex; gap: 8px; margin-bottom: 10px; }
.order-type-toggle .btn { flex: 1; }
.table-select {
  width: 100%; padding: 12px; font-size: 16px; border-radius: var(--radius);
  border: 1px solid var(--border); background: #fff;
}
.bill-lines { flex: 1; overflow-y: auto; padding: 8px 12px; }
.bill-line {
  display: flex; align-items: center; gap: 8px; padding: 10px 0;
  border-bottom: 1px dashed var(--border);
}
.bill-line .nm { flex: 1; min-width: 0; }
.bill-line .nm small { color: var(--muted); display: block; }
.qty-ctl { display: flex; align-items: center; gap: 6px; }
.qty-ctl button {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border);
  background: #f9fafb; font-size: 18px; cursor: pointer;
}
.bill-line .amt { font-weight: 700; min-width: 76px; text-align: right; }
.bill-totals { padding: 12px; border-top: 1px solid var(--border); background: #fafafa; }
.bill-totals .row { display: flex; justify-content: space-between; padding: 3px 0; font-size: 15px; }
.bill-totals .row.grand { font-size: 20px; font-weight: 800; padding-top: 8px; }
.bill-actions { display: flex; gap: 8px; padding: 12px; }
.bill-actions .btn { flex: 1; }

.placeholder { text-align: center; padding: 80px 20px; }

@media (max-width: 860px) {
  .pos-layout { flex-direction: column; height: auto; }
  .bill-pane { width: 100%; min-width: 0; }
  .menu-pane { min-height: 40vh; }
}

/* ---------- extended components ---------- */
.btn-block { width: 100%; margin-top: 6px; }
.btn-sm { padding: 8px 12px; font-size: 14px; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost-dark { background: transparent; color: var(--text); border: 1px solid var(--border); }
.row-btns { display: flex; gap: 6px; margin-top: 6px; justify-content: flex-end; flex-wrap: wrap; }

.search, .inp {
  width: 100%; padding: 12px 14px; font-size: 16px;
  border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 10px; background: #fff;
}
.bill-subhead {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px 4px; font-weight: 700; font-size: 14px;
}
.shift-bar { color: #9ca3af; font-size: 13px; margin-right: 12px; }
.shift-bar strong { color: #fff; }

.fav-star {
  position: absolute; top: 6px; right: 8px; font-size: 18px; color: #cbd5e1;
  background: none; border: none; cursor: pointer; padding: 4px;
}
.fav-star.on { color: #f59e0b; }
.item-btn { position: relative; }
.item-btn.out-of-stock { opacity: .55; border-style: dashed; }
.stock-badge {
  display: inline-block; font-size: 10px; font-weight: 800;
  padding: 2px 8px; border-radius: 12px; margin-top: 4px;
}
.stock-badge.out { background: #fee2e2; color: #991b1b; }
.stock-badge.low { background: #fef3c7; color: #92400e; }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 16px;
}
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 480px;
  max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal-wide { max-width: 720px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-x {
  background: none; border: none; font-size: 26px; cursor: pointer;
  color: var(--muted); line-height: 1;
}
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot { display: flex; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--border); }
.modal-foot .btn { flex: 1; }

/* ---------- toast ---------- */
#toast-box {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast {
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 12px;
  font-size: 15px; opacity: 0; transform: translateY(8px);
  transition: all .25s; box-shadow: 0 8px 24px rgba(0,0,0,.2);
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error { background: var(--danger); }

/* ---------- forms ---------- */
.fld { margin-bottom: 12px; }
.fld label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.fld input, .fld select {
  width: 100%; padding: 12px; font-size: 16px;
  border: 1px solid var(--border); border-radius: var(--radius); background: #fff;
}
.fld.inline { display: inline-block; margin-right: 12px; }
.fld.inline input { width: auto; }
.seg { display: flex; gap: 8px; margin-bottom: 14px; }
.seg .btn { flex: 1; }

/* ---------- lists / tables ---------- */
.list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 4px; border-bottom: 1px solid var(--border);
}
.list-row.collected { opacity: .55; }
.status-pill {
  display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase;
  padding: 2px 8px; border-radius: 20px; background: #e5e7eb; color: #374151;
}
.st-billed { background: #dcfce7; color: #166534; }
.st-ready { background: #dcfce7; color: #166534; }
.st-voided, .st-cancelled { background: #fee2e2; color: #991b1b; }
.st-refunded { background: #fef3c7; color: #92400e; }
.st-held, .st-pending { background: #fef9c3; color: #854d0e; }
.st-preparing, .st-open { background: #dbeafe; color: #1e40af; }

.tbl { width: 100%; border-collapse: collapse; margin: 10px 0 20px; font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
.tbl th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
.tbl .num { text-align: right; }
.tbl-total td { font-weight: 800; border-top: 2px solid var(--ink); }

/* ---------- payment box ---------- */
.pay-box {
  background: #f8fafc; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 12px;
}
.pay-box .r { display: flex; justify-content: space-between; padding: 3px 0; }
.pay-box .tot { font-size: 18px; font-weight: 800; border-top: 1px dashed var(--border); padding-top: 8px; margin-top: 6px; }
.quick-cash { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- KDS ---------- */
.kds-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px; padding: 14px;
}
.kds-card {
  background: #fff; border: 2px solid var(--border); border-radius: 14px;
  padding: 14px; border-left: 8px solid #eab308;
}
.kds-card.kds-preparing { border-left-color: #3b82f6; }
.kds-card.kds-late { border-left-color: var(--danger); background: #fff7f7; }
.kds-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.kds-head strong { font-size: 18px; }
.kds-age { font-weight: 800; color: var(--warn); font-size: 15px; }
.kds-late .kds-age { color: var(--danger); }
.kds-items { margin: 10px 0; }
.kds-item { padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 16px; }
.kds-item em { color: var(--warn); font-size: 14px; }
.kds-actions { display: flex; gap: 8px; margin-top: 10px; }
.kds-actions .btn { flex: 1; }
.kds-empty { text-align: center; padding: 80px 20px; font-size: 18px; grid-column: 1 / -1; }

.queue { max-height: 40vh; overflow-y: auto; padding: 0 12px 12px; }
.tw-cust { display: flex; gap: 8px; }
.tw-cust .inp { margin-bottom: 10px; }

/* ---------- manager / admin ---------- */
.page { padding: 14px 18px 40px; max-width: 1100px; margin: 0 auto; }
.page .tabs { margin-bottom: 6px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.kpi { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.kpi-v { font-size: 22px; font-weight: 800; }
.kpi-l { font-size: 12px; color: var(--muted); margin-top: 4px; }
.recon {
  padding: 12px 16px; border-radius: var(--radius); font-weight: 700; margin: 10px 0;
}
.recon.ok { background: #dcfce7; color: #166534; }
.recon.bad { background: #fee2e2; color: #991b1b; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 16px; }
.cust-items { padding: 0 4px 12px 12px; }
.tab-admin { border: 1px dashed #f59e0b; }
.page h3 { margin: 22px 0 6px; display: flex; align-items: center; gap: 10px; }

/* ---------- small pin pad (approval modal) ---------- */
.pin-pad-sm { max-width: 260px; margin: 0 auto; }
.pin-pad-sm button { font-size: 20px; padding: 12px 0; }

@media (max-width: 860px) {
  .tw-cust { flex-direction: column; }
  .modal { max-width: 100%; }
}
