[hidden] { display: none !important; }
/* Urdu Nastaliq font bundled with the app (works offline, on every phone). Only used for Urdu letters. */
@font-face { font-family: "Noto Nastaliq Urdu"; font-weight: 400; font-display: swap; src: url(fonts/noto-nastaliq-urdu-arabic-400-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Noto Nastaliq Urdu"; font-weight: 700; font-display: swap; src: url(fonts/noto-nastaliq-urdu-arabic-700-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --ink: #16202e;
  --muted: #637083;
  --line: #e2e7ef;
  --brand: #0f5c8c;
  --brand-2: #0b4a72;
  --brand-soft: #e6f0f7;
  --ok: #117a4b;
  --ok-soft: #e3f4ec;
  --warn: #a15c00;
  --warn-soft: #fdf1df;
  --bad: #b3261e;
  --bad-soft: #fce8e6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 32, 46, .06), 0 4px 14px rgba(16, 32, 46, .05);
  --nav-w: 220px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-size: 15px; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidenav {
  width: var(--nav-w); background: #0e2233; color: #cfd9e3; flex-shrink: 0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 18px 16px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand b { display: block; color: #fff; font-size: 16px; }
.brand small { color: #8ea3b6; }
.sidenav nav { padding: 8px; flex: 1; overflow-y: auto; }
.navlink {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px;
  color: #cfd9e3; text-decoration: none; margin-bottom: 2px;
}
.navlink svg { width: 19px; height: 19px; flex-shrink: 0; }
.navlink:hover { background: rgba(255,255,255,.06); }
.navlink.active { background: var(--brand); color: #fff; }
.netstate { padding: 12px 16px; font-size: 12.5px; border-top: 1px solid rgba(255,255,255,.08); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: #3ecf8e; }
.dot.off { background: #f0a020; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 14px 22px; background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.topbar h1 { flex: 1; }
.content { padding: 20px 22px 90px; max-width: 1300px; width: 100%; }
.bottomnav { display: none; }

.banner { margin: 14px 22px 0; padding: 10px 14px; border-radius: 10px; font-weight: 600; font-size: 14px; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
@media (max-width: 820px) { .banner { margin: 12px 16px 0; } }

/* ---------- Components ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.stat .lbl { color: var(--muted); font-size: 13px; }
.stat .val { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat.bad .val { color: var(--bad); }
.stat.ok .val { color: var(--ok); }
.stat.warn .val { color: var(--warn); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line);
  background: var(--card); padding: 9px 14px; border-radius: 9px; cursor: pointer; font-weight: 600;
  min-height: 40px; text-decoration: none; color: var(--ink); white-space: nowrap;
}
.btn:hover { border-color: #c8d1dd; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.bad { color: var(--bad); }
.btn.wa { background: #1fa855; border-color: #1fa855; color: #fff; }
.btn.sm { min-height: 32px; padding: 5px 10px; font-size: 13.5px; }
.btn.lg { min-height: 50px; font-size: 16px; padding: 12px 20px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

label.f { display: block; margin-bottom: 10px; }
label.f > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; background: #fff; min-height: 40px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
textarea { min-height: 70px; resize: vertical; }
input[type=checkbox] { width: auto; min-height: 0; }

.seg { display: inline-flex; background: var(--bg); border-radius: 10px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 8px 16px; border-radius: 8px; font-weight: 600; cursor: pointer; color: var(--muted); min-height: 38px; }
.seg button.on { background: var(--card); color: var(--brand); box-shadow: var(--shadow); }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 8px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f8fafc; }
.tablewrap { overflow-x: auto; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; }
.b-cash { background: var(--ok-soft); color: var(--ok); }
.b-credit { background: var(--warn-soft); color: var(--warn); }
.b-installment { background: var(--brand-soft); color: var(--brand); }
.b-bad { background: var(--bad-soft); color: var(--bad); }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-muted { background: var(--bg); color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.big { font-size: 20px; font-weight: 700; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* ---------- POS screen ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 16px; align-items: start; }
.prodgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.prod {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; cursor: pointer; text-align: left;
  display: flex; flex-direction: column; gap: 4px; min-height: 92px;
}
.prod:hover { border-color: var(--brand); }
.prod b { font-size: 14px; line-height: 1.25; }
.prod .p { color: var(--brand); font-weight: 700; margin-top: auto; }
.prod .s { font-size: 12px; color: var(--muted); }
.prod.out { opacity: .55; }
.cart { position: sticky; top: 80px; }
.cartline { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.cartline .qty { display: flex; align-items: center; gap: 6px; }
.cartline .qty input { width: 60px; text-align: center; min-height: 32px; padding: 4px; }
.cartline .qty input.price { width: 95px; }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.totals .grand { font-size: 22px; font-weight: 800; border-top: 2px solid var(--ink); padding-top: 8px; margin-top: 4px; }
.schedule-preview { max-height: 220px; overflow-y: auto; font-size: 13.5px; }

.cartbar {
  display: none; position: fixed; left: 12px; right: 12px; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 15;
  background: var(--ok); color: #fff; border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 700; align-items: center; gap: 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,.2); cursor: pointer;
}
.cartbar.hide { display: none !important; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 20, 30, .45); display: flex; align-items: flex-start; justify-content: center; z-index: 50; padding: 30px 12px; overflow-y: auto; }
.modal { background: var(--card); border-radius: 14px; width: 100%; max-width: 640px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { max-width: 900px; }
.modal header { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal header h2 { margin: 0; flex: 1; }
.modal .body { padding: 18px; }
.modal footer { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.x { border: 0; background: none; font-size: 24px; cursor: pointer; color: var(--muted); line-height: 1; padding: 4px 8px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #16202e; color: #fff; padding: 11px 18px; border-radius: 10px; z-index: 100; box-shadow: var(--shadow); max-width: 90vw; }
.toast.bad { background: var(--bad); }

.photo { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); }
.photos { display: flex; gap: 10px; flex-wrap: wrap; }
.photo-slot { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.photo-slot label { cursor: pointer; }
.photo-slot input { display: none; }
.ph-empty { width: 84px; height: 84px; border-radius: 10px; border: 2px dashed var(--line); display: flex; align-items: center; justify-content: center; font-size: 26px; color: #b4bfcc; }

.sched td.paid { color: var(--ok); }
.sched tr.overdue td { background: var(--bad-soft); }
.sched tr.done td { color: var(--muted); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 14px; }
.kv > :nth-child(odd) { color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button.on { color: var(--brand); border-color: var(--brand); }

/* ---------- v2: login, ratings, field mode ---------- */
.login-screen { position: fixed; inset: 0; z-index: 200; background: linear-gradient(160deg, #0e2233, #0f5c8c); display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; }
.login-box { background: var(--card); border-radius: 18px; padding: 24px 20px; width: 100%; max-width: 360px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-box h1 { font-size: 20px; margin: 10px 0 2px; }
.login-users { display: grid; gap: 8px; margin-top: 14px; }
.login-users .btn { flex-direction: column; gap: 0; }
.login-users small { font-weight: 400; color: var(--muted); font-size: 12px; }
.pin-input { text-align: center; font-size: 26px; letter-spacing: 10px; margin-bottom: 12px; }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pinpad .btn { font-size: 20px; min-height: 56px; }
.shake { animation: shake .35s; border-color: var(--bad) !important; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.rt-good { background: var(--ok-soft); color: var(--ok); }
.rt-average { background: var(--brand-soft); color: var(--brand); }
.rt-late { background: var(--warn-soft); color: var(--warn); }
.rt-defaulter, .rt-blacklist { background: var(--bad); color: #fff; }
.rt-new { background: var(--bg); color: var(--muted); }
.mono { font-family: ui-monospace, Consolas, "Courier New", monospace; }
.scope-sel { width: auto; min-height: 38px; font-weight: 600; }
.route-card { padding: 14px; margin-bottom: 10px; }
.bar { height: 10px; border-radius: 5px; background: var(--ok); min-width: 2px; }
.bar.neg { background: var(--bad); }
tr.done td { color: var(--muted); }
.user-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.user-chip svg { width: 16px; height: 16px; }
[dir=rtl], .ur { font-family: "Jameel Noori Nastaleeq", "Noto Nastaliq Urdu", "Noto Naskh Arabic", "Segoe UI", Tahoma, sans-serif; }
textarea[dir=rtl], input[dir=rtl] { font-size: 16px; line-height: 1.8; }

/* ---------- Print ---------- */
#print { display: none; }
@media print {
  body * { visibility: hidden; }
  #print, #print * { visibility: visible; }
  #print { display: block; position: absolute; left: 0; top: 0; width: 100%; color: #000; background: #fff; }
  @page { margin: 8mm; }
}
.rcpt { width: 72mm; font-family: "Courier New", monospace; font-size: 12px; margin: 0 auto; }
.rcpt h3 { text-align: center; margin: 0; font-size: 15px; }
.rcpt .c { text-align: center; }
.rcpt table td, .rcpt table th { padding: 2px 0; border: 0; font-size: 12px; text-transform: none; color: #000; }
.rcpt hr { border: 0; border-top: 1px dashed #000; margin: 6px 0; }
.rcpt .lr { display: flex; justify-content: space-between; gap: 8px; }
.rcpt .b { font-weight: 700; }
.rcpt .big { font-size: 14px; }
.rcpt .sm { font-size: 10.5px; }
.rcpt.ur { font-size: 13px; line-height: 1.8; }
.rcpt img { image-rendering: pixelated; }
.a4 { font-size: 13px; color: #000; max-width: 190mm; margin: 0 auto; }
.a4 h2 { text-align: center; font-size: 18px; }
.a4 table td, .a4 table th { border: 1px solid #999; padding: 4px 6px; color: #000; }
.a4 .sig { display: grid; grid-template-columns: repeat(3, 1fr); gap: 30px; margin-top: 60px; text-align: center; }
.a4 .sig div { border-top: 1px solid #000; padding-top: 4px; }
.a4 .ph { display: flex; gap: 10px; }
.a4 .ph img { width: 90px; height: 90px; object-fit: cover; border: 1px solid #999; }

/* ---------- Responsive (phones & tablets) ---------- */
@media (max-width: 1100px) {
  .pos { grid-template-columns: minmax(0, 1fr); }
  .cart { position: static; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .sidenav { display: none; }
  .topbar { padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top)); }
  .topbar h1 { font-size: 18px; }
  .content { padding: 14px 16px 100px; }
  .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  .cartbar { display: flex; }
  .bottomnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--card); border-top: 1px solid var(--line);
    z-index: 20; padding-bottom: env(safe-area-inset-bottom);
  }
  .bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px; font-size: 11px; color: var(--muted); text-decoration: none; }
  .bottomnav a svg { width: 22px; height: 22px; }
  .bottomnav a.active { color: var(--brand); }
  .kv { grid-template-columns: 110px 1fr; }
  .hide-m { display: none; }
  .prodgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modal-bg { padding: 0; }
  .modal { border-radius: 0; min-height: 100vh; }
}

/* ---------- keyboard use (desktop) ---------- */
.kfocus td, .kfocus.cartline { background: var(--brand-soft) !important; }
.kfocus { outline: 2px solid var(--brand); outline-offset: -2px; }
.prod:focus-visible, .btn:focus-visible, .navlink:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
kbd { display: inline-block; min-width: 22px; text-align: center; font: 600 12px/1.6 ui-monospace, Consolas, monospace; padding: 0 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: #f7f9fb; color: #1d2b36; }
.kbd-table { width: 100%; }
.kbd-table td { padding: 5px 6px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.kbd-table td:first-child { white-space: nowrap; width: 1%; padding-right: 14px; }
.kbd-btn { margin-left: 8px; }
@media (min-width: 821px) and (hover: hover) {
  body.kbd-hints [data-kbd]::after { content: attr(data-kbd); display: inline-block; margin-left: 7px; font-size: 10.5px; line-height: 1.5; padding: 0 5px; border: 1px solid currentColor; border-radius: 4px; opacity: .6; font-weight: 600; letter-spacing: .02em; vertical-align: middle; white-space: nowrap; }
  body.kbd-hints .navlink[data-kbd]::after { margin-left: auto; opacity: .4; }
}
@media (max-width: 820px) { .kbd-btn { display: none; } }

/* shortcuts page */
.kbd-edit { width: 100%; }
.kbd-edit td { padding: 7px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.kbd-edit .kl { font-size: 13.5px; }
.kbd-edit .kk { white-space: nowrap; text-align: right; }
.kbd-edit .ko { width: 1%; }
.kbd-off td, tr.kbd-off .kl { color: var(--muted); }
.kbd-off kbd { opacity: .45; }
.kchip { display: inline-flex; align-items: center; margin-left: 4px; border-radius: 6px; }
.kchip .kbtn { border: 0; background: none; padding: 2px; cursor: pointer; border-radius: 6px; }
.kchip .kbtn:hover kbd, .kchip .kbtn:focus-visible kbd { border-color: var(--brand); background: var(--brand-soft); }
.kchip .kx { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 3px; }
.kchip .kx:hover { color: var(--bad); }
.kadd { margin-left: 6px; min-height: 28px !important; padding: 2px 8px !important; font-size: 12px !important; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: #c5d0d9; border-radius: 22px; transition: .15s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--ok, #15885a); }
.switch input:checked + span::before { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 3px solid var(--brand); outline-offset: 2px; }
.switch input:disabled + span { opacity: .5; cursor: default; }
.cap-key { margin: 14px 0; padding: 22px; text-align: center; border: 2px dashed var(--line); border-radius: 12px; font-size: 18px; color: var(--muted); }
.cap-key kbd { font-size: 20px; padding: 2px 10px; }
.cap-key.bad { border-color: var(--bad); }

/* login screen */
.modal-bg { z-index: 250; }
.login-box.wide { max-width: 640px; }
.login-users { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 10px; }
.login-tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 16px 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); cursor: pointer; font: inherit; color: inherit; }
.login-tile:hover, .login-tile.kf, .login-tile:focus-visible { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); outline: none; }
.login-tile b { font-size: 15px; margin-top: 4px; }
.login-tile small { color: var(--muted); font-size: 12px; }
.login-tile .lt-last { font-size: 11px; }
.login-tile .lt-n { position: absolute; top: 7px; left: 9px; font-size: 11px; font-weight: 700; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; }
.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; object-fit: cover; color: #fff; font-weight: 700; flex: 0 0 auto; }
.login-sel { display: flex; align-items: center; gap: 12px; justify-content: center; margin: 10px 0 14px; text-align: left; }
.login-sel b { font-size: 17px; }

/* products page form */
.prodform { gap: 0 14px; }
.prodform .chk { display: flex; gap: 8px; align-items: center; margin-top: 24px; }
.prodform .chk input { width: auto; min-height: 0; }
.pf-btns { gap: 10px; margin-top: 6px; }
.pf-btns .btn { min-width: 96px; }
.pf-btns .btn:disabled { opacity: .45; cursor: not-allowed; }
#prodForm.editing { box-shadow: 0 0 0 2px var(--brand) inset; }
tr.sel td { background: var(--brand-soft) !important; font-weight: 600; }
tr.flash td { animation: pflash 1.6s ease-out; }
@keyframes pflash { from { background: #d7f5e6; } to { background: transparent; } }
@media (max-width: 820px) { .prodform { grid-template-columns: 1fr 1fr; } .prodform label[style*="span 2"] { grid-column: 1 / -1 !important; } }
