/* Restaurant Management System — shared styles (POS, KDS, console). Touch-first, no external assets. */
:root {
  --bg: #f3f4f6; --panel: #ffffff; --ink: #1f2933; --muted: #6b7280; --line: #e5e7eb;
  --brand: #0f766e; --brand-ink: #ffffff; --brand-soft: #ccfbf1;
  --top: #111827; --top-ink: #f9fafb;
  --ok: #15803d; --ok-soft: #dcfce7; --warn: #b45309; --warn-soft: #fef3c7; --bad: #b91c1c; --bad-soft: #fee2e2; --info: #1d4ed8; --info-soft: #dbeafe;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.06);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Ethiopic", sans-serif; color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body { font-size: 15px; line-height: 1.4; -webkit-tap-highlight-color: transparent; }
a { color: var(--brand); }
h1, h2, h3 { margin: 0 0 .6em; line-height: 1.2; }
h1 { font-size: 1.4rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
code { background: #eef2f7; padding: 1px 5px; border-radius: 4px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: 10px; }
.num { font-variant-numeric: tabular-nums; }

/* Buttons and inputs */
.btn { appearance: none; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 8px; padding: 9px 14px; font: inherit; font-weight: 600; cursor: pointer; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; touch-action: manipulation; }
.btn:hover { border-color: #cbd5e1; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.big { min-height: 56px; font-size: 1.05rem; padding: 12px 18px; }
.btn.sm { min-height: 30px; padding: 4px 10px; font-size: .85rem; }
.btn.block { width: 100%; }
input, select, textarea { font: inherit; padding: 9px 10px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; color: var(--ink); min-height: 40px; width: 100%; }
input[type=checkbox] { width: auto; min-height: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
label { display: block; font-size: .85rem; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 4px; color: var(--ink); }
label.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 1rem; }
.form { display: grid; gap: 12px; }
.form.cols { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 700; background: #eef2f7; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); } .badge.info { background: var(--info-soft); color: var(--info); }
.card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card.narrow { max-width: 560px; margin: 30px auto; }
.ok { color: var(--ok); } .err { color: var(--bad); }
.notice { padding: 10px 12px; border-radius: 8px; background: var(--info-soft); color: var(--info); }
.notice.warn { background: var(--warn-soft); color: var(--warn); } .notice.bad { background: var(--bad-soft); color: var(--bad); }

/* Tables */
table.data { width: 100%; border-collapse: collapse; background: var(--panel); }
table.data th, table.data td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data th { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; background: #f9fafb; position: sticky; top: 0; }
table.data td.num, table.data th.num { text-align: right; }
table.data tr.click { cursor: pointer; } table.data tr.click:hover { background: #f8fafc; }
table.data tfoot td { font-weight: 700; background: #f9fafb; }
.table-wrap { overflow: auto; border-radius: var(--radius); box-shadow: var(--shadow); }

/* Top bar */
.topbar { background: var(--top); color: var(--top-ink); display: flex; align-items: center; gap: 12px; padding: 8px 14px; min-height: 52px; }
.topbar .brand { font-weight: 800; letter-spacing: .01em; }
.topbar .btn { background: #1f2937; border-color: #374151; color: #f9fafb; }
.topbar .btn.primary { background: var(--brand); border-color: var(--brand); }
.pill { padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; }
.pill.online { background: #064e3b; color: #a7f3d0; } .pill.offline { background: #7f1d1d; color: #fecaca; }

/* Modal and toast */
.modal-back { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border-radius: 14px; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 18px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.modal.wide { width: min(980px, 100%); }
.modal header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal header h2 { margin: 0; }
.modal footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; }
.toast { background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); max-width: 90vw; }
.toast.bad { background: var(--bad); } .toast.ok { background: var(--ok); }

/* Keypad */
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad button { min-height: 58px; font-size: 1.4rem; font-weight: 700; border-radius: 10px; border: 1px solid var(--line); background: #f9fafb; cursor: pointer; }
.keypad button:active { background: var(--brand-soft); }
.pin-dots { display: flex; gap: 12px; justify-content: center; margin: 12px 0 16px; }
.pin-dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--brand); }
.pin-dots span.on { background: var(--brand); }

/* ---------- POS ---------- */
.pos { display: flex; flex-direction: column; height: 100vh; }
.pos main { flex: 1; display: flex; min-height: 0; }
.login-screen { flex: 1; display: flex; align-items: center; justify-content: center; padding: 20px; }
.user-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.user-grid button { min-height: 80px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); font: inherit; font-weight: 700; cursor: pointer; box-shadow: var(--shadow); }
.floor { flex: 1; padding: 14px; overflow: auto; }
.tables { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.table-tile { position: relative; border-radius: 14px; padding: 12px; min-height: 104px; background: var(--panel); border: 2px solid var(--line); cursor: pointer; text-align: left; font: inherit; box-shadow: var(--shadow); }
.table-tile .no { font-size: 1.6rem; font-weight: 800; }
.table-tile.free { border-color: #d1d5db; }
.table-tile.occupied { border-color: var(--info); background: var(--info-soft); }
.table-tile.bill_requested { border-color: var(--warn); background: var(--warn-soft); }
.table-tile.needs_cleaning { border-color: #9ca3af; background: #e5e7eb; }
.table-tile.reserved { border-color: #7c3aed; background: #ede9fe; }
.table-tile .ready { position: absolute; top: 8px; right: 8px; background: var(--ok); color: #fff; border-radius: 999px; padding: 2px 8px; font-weight: 800; font-size: .8rem; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 7px 14px; font: inherit; font-weight: 600; cursor: pointer; }
.tabs button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.order-view { flex: 1; display: grid; grid-template-columns: 1fr 380px; min-height: 0; }
.menu-pane { display: flex; flex-direction: column; min-height: 0; padding: 12px; }
.menu-pane .cats { flex: none; overflow-x: auto; }
.items { flex: 1; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; align-content: start; padding-bottom: 20px; }
.item-btn { border-radius: 12px; border: 1px solid var(--line); background: var(--panel); min-height: 84px; padding: 10px; text-align: left; font: inherit; cursor: pointer; box-shadow: var(--shadow); display: flex; flex-direction: column; justify-content: space-between; }
.item-btn b { font-size: .98rem; }
.item-btn .price { color: var(--brand); font-weight: 700; }
.item-btn.off { opacity: .45; cursor: not-allowed; background: repeating-linear-gradient(135deg, #fff, #fff 8px, #f3f4f6 8px, #f3f4f6 16px); }
.ticket { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.ticket header { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.ticket .lines { flex: 1; overflow: auto; }
.ticket .line { padding: 9px 14px; border-bottom: 1px solid #f1f5f9; cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; }
.ticket .line:hover { background: #f8fafc; }
.ticket .line .mods { grid-column: 1 / -1; color: var(--muted); font-size: .85rem; }
.ticket .line.voided { text-decoration: line-through; color: var(--muted); }
.ticket .line.pending { background: #fffbeb; }
.ticket footer { padding: 12px 14px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.ticket .total { display: flex; justify-content: space-between; font-size: 1.3rem; font-weight: 800; }
.actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.choice { border: 2px solid var(--line); border-radius: 10px; padding: 10px; background: #fff; font: inherit; cursor: pointer; text-align: left; min-height: 52px; }
.choice.on { border-color: var(--brand); background: var(--brand-soft); }
.choice:disabled { opacity: .45; }
.pay-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.qty-stepper { display: flex; align-items: center; gap: 10px; }
.qty-stepper button { width: 46px; height: 46px; border-radius: 10px; border: 1px solid var(--line); background: #f9fafb; font-size: 1.3rem; font-weight: 800; cursor: pointer; }
.qty-stepper span { font-size: 1.3rem; font-weight: 800; min-width: 30px; text-align: center; }
@media (max-width: 860px) {
  .order-view { grid-template-columns: 1fr; grid-template-rows: 1fr 46vh; }
  .ticket { border-left: 0; border-top: 1px solid var(--line); }
  .pay-grid { grid-template-columns: 1fr; }
}

/* ---------- KDS ---------- */
.kds { background: #0b1220; color: #e5e7eb; min-height: 100vh; display: flex; flex-direction: column; }
.kds .topbar { background: #020617; }
.kds-board { flex: 1; padding: 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; align-content: start; }
.kot { background: #111827; border: 3px solid #334155; border-radius: 12px; display: flex; flex-direction: column; overflow: hidden; }
.kot header { padding: 8px 12px; display: flex; justify-content: space-between; align-items: center; background: #1e293b; }
.kot header .t { font-size: 1.2rem; font-weight: 800; }
.kot .timer { font-weight: 800; font-variant-numeric: tabular-nums; }
.kot.amber { border-color: #f59e0b; } .kot.amber header { background: #78350f; }
.kot.red { border-color: #ef4444; } .kot.red header { background: #7f1d1d; }
.kot.void { border-color: #ef4444; background: #450a0a; }
.kot.bumped { opacity: .45; }
.kot ul { list-style: none; margin: 0; padding: 8px 12px; flex: 1; }
.kot li { padding: 5px 0; border-bottom: 1px solid #1f2937; font-size: 1.05rem; }
.kot li .q { font-weight: 800; color: #fbbf24; margin-right: 6px; }
.kot li .m { display: block; color: #93c5fd; font-size: .9rem; margin-left: 24px; }
.kot li .n { display: block; color: #fca5a5; font-size: .9rem; margin-left: 24px; font-style: italic; }
.kot li.voided { text-decoration: line-through; color: #64748b; }
.kot .tag { font-size: .75rem; font-weight: 800; padding: 2px 8px; border-radius: 6px; background: #334155; }
.kot .tag.add_on { background: #1d4ed8; } .kot .tag.void { background: #dc2626; }
.kot footer { padding: 8px; }
.kot footer .btn { width: 100%; min-height: 52px; font-size: 1.1rem; }
.kds .btn { background: #1f2937; border-color: #374151; color: #f9fafb; }
.kds .btn.primary { background: #059669; border-color: #059669; }
.kds .modal, .kds .modal input { color: var(--ink); }

/* ---------- Console ---------- */
.console { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.console nav { background: var(--top); color: var(--top-ink); padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.console nav .brand { font-weight: 800; font-size: 1.05rem; padding: 4px 10px 14px; }
.console nav a { display: block; color: #cbd5e1; text-decoration: none; padding: 8px 10px; border-radius: 8px; font-weight: 600; }
.console nav a:hover { background: #1f2937; color: #fff; }
.console nav a.on { background: var(--brand); color: #fff; }
.console nav .grp { color: #6b7280; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; padding: 14px 10px 4px; }
.console > section { padding: 20px 24px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.kpi .v { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: .85rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.toolbar label { min-width: 150px; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px; }
@media (max-width: 800px) {
  .console { grid-template-columns: 1fr; }
  .console nav { height: auto; position: static; display: flex; flex-wrap: wrap; gap: 4px; }
  .console nav .grp { display: none; }
  .grid2 { grid-template-columns: 1fr; }
}
.install { padding: 10px; }

/* ---------- Print (80 mm slips) ---------- */
#print-area { display: none; }
@media print {
  @page { size: 80mm auto; margin: 3mm; }
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area { display: block; position: absolute; left: 0; top: 0; width: 74mm; font: 12px/1.35 "Courier New", monospace; color: #000; }
  #print-area .c { text-align: center; } #print-area .r { text-align: right; }
  #print-area .big { font-size: 16px; font-weight: 700; }
  #print-area hr { border: 0; border-top: 1px dashed #000; margin: 4px 0; }
  #print-area table { width: 100%; border-collapse: collapse; }
  #print-area td { padding: 1px 0; vertical-align: top; }
  #print-area .mark { border: 2px solid #000; text-align: center; font-weight: 700; font-size: 16px; margin: 4px 0; }
}
