:root {
  --bg: #15181e;
  --pane: #1e232b;
  --pane-2: #262c36;
  --line: #323a46;
  --text: #eef1f5;
  --text-dim: #9aa4b2;
  --accent: #2f6fed;
  --green: #1f9d55;
  --red: #c0392b;
  --radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}
.hidden { display: none !important; }
.screen { height: 100vh; }
.link-btn {
  background: none; border: none; color: var(--text-dim);
  font-size: 14px; cursor: pointer; padding: 6px 10px;
}
.link-btn:active { color: var(--text); }

/* ---------- login ---------- */
#login-screen { display: flex; align-items: center; justify-content: center; }
.login-card { text-align: center; width: 300px; }
.login-card h1 { font-size: 28px; letter-spacing: 1px; margin-bottom: 4px; }
#login-hint { color: var(--text-dim); margin-bottom: 18px; min-height: 20px; }
#login-hint.error { color: #ff7b6b; }
.pin-dots { display: flex; gap: 12px; justify-content: center; margin-bottom: 22px; min-height: 14px; }
.pin-dots span {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--text-dim);
}
.pin-dots span.filled { background: var(--text); border-color: var(--text); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.pin-pad button {
  font-size: 24px; padding: 18px 0; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--pane); color: var(--text); cursor: pointer;
}
.pin-pad button:active { background: var(--pane-2); }
.pin-pad button.muted { color: var(--text-dim); }

/* ---------- register layout ---------- */
.topbar {
  height: 44px; display: flex; align-items: center; gap: 16px;
  padding: 0 14px; background: var(--pane); border-bottom: 1px solid var(--line);
}
.who { font-size: 14px; color: var(--text-dim); flex: 1; }
.sync-status { font-size: 13px; color: var(--text-dim); }
.sync-status.online { color: #58c98a; }
.sync-status.pending { color: #e5b567; }
.register-grid {
  display: grid; grid-template-columns: 340px 150px 1fr;
  height: calc(100vh - 44px);
}

/* ---------- cart ---------- */
.cart-pane { background: var(--pane); display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.cart-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 14px; color: var(--text-dim);
}
.cart-lines { flex: 1; overflow-y: auto; list-style: none; }
.cart-lines li {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 15px;
}
.cart-lines .qty { color: var(--text-dim); min-width: 26px; }
.cart-lines .name { flex: 1; }
.cart-lines .amount { font-variant-numeric: tabular-nums; }
.cart-lines .line-x { background: none; border: none; color: var(--text-dim); font-size: 16px; cursor: pointer; padding: 2px 6px; }
.totals { padding: 10px 14px; border-top: 1px solid var(--line); font-size: 14px; }
.totals .row { display: flex; justify-content: space-between; padding: 3px 0; color: var(--text-dim); }
.totals .grand { color: var(--text); font-size: 18px; font-weight: 600; }
.barcode-row { padding: 8px 14px; }
.barcode-row input {
  width: 100%; padding: 10px 12px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--pane-2); color: var(--text); font-size: 14px;
}
.barcode-row input.error { border-color: var(--red); }
.pay-btn {
  margin: 8px 14px 14px; padding: 16px; font-size: 18px; font-weight: 600;
  background: var(--green); color: #fff; border: none; border-radius: var(--radius); cursor: pointer;
}
.pay-btn:disabled { background: var(--pane-2); color: var(--text-dim); }

/* ---------- categories ---------- */
.category-rail { overflow-y: auto; background: var(--bg); border-right: 1px solid var(--line); }
.category-rail button {
  display: block; width: 100%; padding: 18px 10px; font-size: 14px;
  background: var(--pane); color: var(--text); border: none;
  border-bottom: 1px solid var(--line); cursor: pointer; text-align: center;
}
.category-rail button.active { background: #a8283c; }

/* ---------- item grid ---------- */
.item-grid {
  overflow-y: auto; padding: 10px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px; align-content: start;
}
.item-grid button {
  min-height: 96px; padding: 10px; border-radius: 6px;
  background: var(--pane-2); color: var(--text); border: 1px solid var(--line);
  border-bottom-width: 3px; font-size: 15px; cursor: pointer;
  display: flex; flex-direction: column; justify-content: space-between; text-align: left;
}
.item-grid button:active { background: #313945; }
.item-grid .price { color: var(--text-dim); font-size: 13px; }
.item-grid .low { color: #e5b567; font-size: 12px; }

/* ---------- modals ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
}
.modal-card {
  background: var(--pane); border: 1px solid var(--line); border-radius: 14px;
  padding: 22px; width: 380px; max-width: 92vw; text-align: center;
}
.modal-card h2 { font-size: 20px; margin-bottom: 16px; }
.tender-methods { display: flex; gap: 12px; margin-bottom: 14px; }
.tender-btn {
  flex: 1; padding: 22px 0; font-size: 17px; font-weight: 600; border: none;
  border-radius: var(--radius); cursor: pointer; color: #fff;
}
.tender-btn.cash { background: var(--green); }
.tender-btn.mpesa { background: #0b7d40; }
.tender-btn.selected { outline: 3px solid #fff3; }
.tender-detail input {
  width: 100%; margin-bottom: 10px; padding: 12px; font-size: 18px;
  border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--pane-2); color: var(--text); text-align: center;
}
.change-line { min-height: 22px; margin-bottom: 8px; color: var(--text-dim); }
.receipt-card { text-align: left; }

/* ---------- M-PESA tender panel ---------- */
.mpesa-panel { margin-bottom: 10px; text-align: left; }
.stk-row { display: flex; gap: 8px; margin-bottom: 6px; }
.stk-row input {
  flex: 1; margin: 0; padding: 10px 12px; font-size: 14px; text-align: left;
  border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--pane-2); color: var(--text);
}
.stk-btn {
  padding: 0 14px; font-size: 13px; font-weight: 600; border: none;
  border-radius: var(--radius); background: #0b7d40; color: #fff; cursor: pointer;
}
.stk-btn:disabled { background: var(--pane-2); color: var(--text-dim); }
.mpesa-note { min-height: 18px; font-size: 12.5px; color: var(--text-dim); margin-bottom: 6px; }
.mpesa-note.ok { color: #58c98a; }
.mpesa-note.err { color: #ff7b6b; }
.mpesa-recent { max-height: 150px; overflow-y: auto; }
.mpesa-recent .tx-row {
  display: flex; justify-content: space-between; gap: 8px; width: 100%;
  padding: 9px 10px; margin-bottom: 5px; font-size: 13px; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--pane-2); color: var(--text);
}
.mpesa-recent .tx-row:active, .mpesa-recent .tx-row.picked { border-color: #0b7d40; background: #12331f; }
.mpesa-recent .tx-meta { color: var(--text-dim); }

/* ---------- restaurant: tables + kitchen + splits ---------- */
.send-btn {
  margin: 8px 14px 0; padding: 12px; font-size: 15px; font-weight: 600;
  background: var(--accent); color: #fff; border: none; border-radius: var(--radius); cursor: pointer;
}
.send-btn:disabled { background: var(--pane-2); color: var(--text-dim); }
.tables-grid {
  flex: 1; overflow-y: auto; padding: 16px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px;
  align-content: start;
}
.tables-grid button {
  min-height: 92px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--pane-2); color: var(--text); cursor: pointer; font-size: 15px;
  display: flex; flex-direction: column; justify-content: center; gap: 4px;
}
.tables-grid .t-label { font-size: 18px; font-weight: 600; }
.tables-grid .t-meta { font-size: 12px; color: var(--text-dim); }
.tables-grid button.open { background: #3d2f13; border-color: #e5b567; }
.tables-grid button.open .t-meta { color: #e5b567; }
.tables-grid button.sent { background: #13202f; border-color: var(--accent); }
.tables-grid button.sent .t-meta { color: #7ba7f0; }
.split-chips { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.split-chips .chip {
  padding: 6px 14px; font-size: 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--pane-2); color: var(--text);
}
.paid-so-far {
  text-align: left; font-size: 13px; color: var(--text-dim); margin-bottom: 8px;
  border: 1px dashed var(--line); border-radius: var(--radius); padding: 8px 10px;
}
.partial-btn {
  width: 100%; margin-bottom: 8px; padding: 10px; font-size: 14px; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--pane-2); color: var(--text);
}

/* ---------- terminal name + quick add ---------- */
.terminal-name {
  margin-top: 18px; width: 100%; padding: 10px 12px; font-size: 13px; text-align: center;
  border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--pane); color: var(--text-dim);
}
.qa-input {
  width: 100%; margin-bottom: 8px; padding: 11px 12px; font-size: 15px;
  border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--pane-2); color: var(--text);
}
select.qa-input { appearance: auto; }
.qa-row { display: flex; gap: 8px; }
.qa-row .qa-input { flex: 1; }

/* ---------- per-item split ---------- */
.split-card { text-align: left; }
.split-rows { max-height: 46vh; overflow-y: auto; margin-bottom: 10px; }
.split-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px;
}
.split-row .sp-name { flex: 1; }
.split-row .sp-price { color: var(--text-dim); font-size: 12.5px; min-width: 70px; text-align: right; }
.split-row .stepper { display: flex; align-items: center; gap: 8px; }
.split-row .stepper button {
  width: 32px; height: 32px; font-size: 17px; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--line); background: var(--pane-2); color: var(--text);
}
.split-row .stepper .sp-q { min-width: 44px; text-align: center; font-weight: 600; }
.split-totals {
  display: flex; justify-content: space-between; font-size: 13.5px;
  color: var(--text-dim); margin-bottom: 10px;
}
.split-totals #split-now { color: #58c98a; font-weight: 600; }

/* ---------- QR orders ---------- */
.qr-banner {
  position: fixed; right: 16px; bottom: 16px; z-index: 20;
  padding: 12px 18px; font-size: 14px; font-weight: 600; cursor: pointer;
  border: none; border-radius: 999px; background: #a8283c; color: #fff;
  box-shadow: 0 4px 14px rgba(0,0,0,.45);
}
.qr-card { text-align: left; max-height: 80vh; overflow-y: auto; }
.qr-order {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 10px; font-size: 14px;
}
.qr-order .qh { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 6px; }
.qr-order .qh .qa { color: var(--text-dim); font-weight: 400; font-size: 12.5px; }
.qr-order ul { list-style: none; margin: 0 0 6px; padding: 0; color: var(--text-dim); }
.qr-order .qnote { color: #e5b567; font-size: 12.5px; margin-bottom: 6px; }
.qr-order .qbtns { display: flex; gap: 8px; }
.qr-order .qbtns button {
  flex: 1; padding: 9px 0; font-size: 13px; font-weight: 600; cursor: pointer;
  border: none; border-radius: var(--radius); color: #fff;
}
.qr-order .accept { background: var(--green); }
.qr-order .reject { background: var(--pane-2); color: var(--text-dim); border: 1px solid var(--line); }

/* ---------- stocktake ---------- */
.overlay { position: fixed; inset: 0; background: var(--bg); z-index: 10; display: flex; flex-direction: column; }
.stocktake-tools { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.stocktake-tools input {
  width: 100%; padding: 10px 12px; font-size: 15px;
  border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--pane-2); color: var(--text);
}
.stocktake-list { flex: 1; overflow-y: auto; padding: 6px 14px; }
.stocktake-list .st-row {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 15px;
}
.stocktake-list .st-name { flex: 1; }
.stocktake-list .st-expected { color: var(--text-dim); font-size: 13px; min-width: 90px; text-align: right; }
.stocktake-list .st-count {
  width: 90px; padding: 9px 10px; font-size: 16px; text-align: center;
  border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--pane-2); color: var(--text);
}
.stocktake-list .st-count.changed { border-color: #e5b567; }
.stocktake-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; border-top: 1px solid var(--line); background: var(--pane);
}
.stocktake-footer .pay-btn { margin: 0; min-width: 220px; }
.share-row { margin-bottom: 12px; }
.share-row input {
  width: 100%; margin-bottom: 8px; padding: 10px 12px; font-size: 14px;
  border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--pane-2); color: var(--text);
}
.share-btns { display: flex; gap: 8px; }
.share-btn {
  flex: 1; padding: 10px 0; font-size: 13px; font-weight: 600;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--pane-2); color: var(--text); cursor: pointer;
}
.share-btn:active { background: #313945; }
.share-btn.wa { background: #128c4a; border-color: #128c4a; color: #fff; }
.share-btn.sms { background: var(--accent); border-color: var(--accent); color: #fff; }
.share-btn.flash { background: var(--green); border-color: var(--green); color: #fff; }
.receipt-body {
  background: var(--pane-2); border-radius: 6px; padding: 14px;
  font-family: ui-monospace, Consolas, monospace; font-size: 13px;
  white-space: pre-wrap; margin-bottom: 14px; max-height: 50vh; overflow-y: auto;
}
