:root {
  --bg: #f3f5f9; --panel: #fff; --ink: #142033; --muted: #5d6b80; --line: #dfe4ec; --soft: #eef2f7;
  --brand: #1d4ed8; --brand-dark: #1e3a8a; --brand-soft: #e7eeff; --oil: #f59e0b; --oil-soft: #fff4dc;
  --danger: #c62828; --danger-soft: #fdecec; --ok: #15803d; --ok-soft: #e6f6ec; --warn: #b45309; --warn-soft: #fff4e0;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 2px 6px rgba(16,24,40,.06);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; font-size: 15px; color: var(--ink);
}
html[lang=ur] { font-family: "Jameel Noori Nastaleeq", "Noto Nastaliq Urdu", "Urdu Typesetting", "Segoe UI", sans-serif; font-size: 16px; }
html[lang=ur] body { line-height: 1.9; }
html[lang=ur] .num, html[lang=ur] .mono, html[lang=ur] input, html[lang=ur] .money, html[lang=ur] .reg { font-family: "Segoe UI", system-ui, sans-serif; line-height: 1.4; }
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); }
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 10px; } h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .center { text-align: center; } .right { text-align: end; }
.mono { font-family: Consolas, "Cascadia Mono", monospace; } .nowrap { white-space: nowrap; } .pre { white-space: pre-line; }
.hidden { display: none !important; }
.reg { display: inline-block; font-family: Consolas, monospace; font-weight: 800; letter-spacing: .06em; background: #fff8d6; border: 2px solid #1f2937; border-radius: 6px; padding: 1px 8px; color: #111; direction: ltr; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: linear-gradient(180deg, #0f1f45, #142b63); color: #dbe5ff; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .logo { padding: 18px 16px 14px; color: #fff; font-weight: 800; font-size: 17px; line-height: 1.25; display: flex; gap: 10px; align-items: center; }
.side .logo .drop { width: 36px; height: 36px; border-radius: 10px; background: var(--oil); display: grid; place-items: center; font-size: 20px; flex: none; }
.side .logo small { display: block; font-weight: 400; font-size: 12px; color: #9fb2e6; }
.side nav a { display: flex; align-items: center; gap: 12px; padding: 11px 16px; color: #dbe5ff; text-decoration: none; font-size: 15px; border-inline-start: 4px solid transparent; }
.side nav a .ic { font-size: 20px; width: 26px; text-align: center; }
.side nav a:hover { background: rgba(255,255,255,.07); }
.side nav a.active { background: rgba(255,255,255,.12); border-inline-start-color: var(--oil); color: #fff; font-weight: 700; }
.side nav a.big { margin: 10px 12px 8px; border-radius: 12px; background: var(--oil); color: #1b1300; font-weight: 800; border: 0; justify-content: center; padding: 14px; }
.side nav a.big:hover { background: #fbbf24; }
.side .me { margin-top: auto; padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.12); font-size: 13px; }
.side .me .row button { background: none; border: 1px solid rgba(255,255,255,.3); color: #fff; border-radius: 8px; padding: 5px 10px; cursor: pointer; }
.main { padding: 18px 22px 50px; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head .spacer { flex: 1; }
.menu-btn { display: none; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 14px; }
.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)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; }
.stack > * + * { margin-top: 10px; }
.step { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 800; font-size: 14px; margin-inline-end: 8px; }

/* ---------- tiles ---------- */
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile .label { color: var(--muted); font-size: 13px; }
.tile .value { font-size: 25px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .sub { font-size: 12px; color: var(--muted); }
.tile.link { cursor: pointer; } .tile.link:hover { border-color: var(--brand); }
.tile.ok { border-top: 4px solid var(--ok); } .tile.warn { border-top: 4px solid var(--oil); } .tile.danger { border-top: 4px solid var(--danger); } .tile.blue { border-top: 4px solid var(--brand); }
.action-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.action { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 18px 10px; border-radius: 14px; background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); text-decoration: none; color: var(--ink); font-weight: 700; text-align: center; cursor: pointer; min-height: 112px; }
.action .ic { font-size: 34px; } .action:hover { border-color: var(--brand); transform: translateY(-1px); }
.action.primary { background: var(--brand); color: #fff; border-color: var(--brand); } .action.oil { background: var(--oil); border-color: var(--oil); color: #1b1300; }

/* ---------- forms ---------- */
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
label.f > span.req::after { content: " *"; color: var(--danger); }
input, select, textarea { border: 1px solid #c9d2df; border-radius: 10px; padding: 9px 11px; background: #fff; min-height: 42px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 3px solid #bfd3ff; border-color: var(--brand); }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; min-height: 0; accent-color: var(--brand); }
textarea { min-height: 70px; resize: vertical; }
input.big { font-size: 22px; font-weight: 700; min-height: 54px; }
input.plate { text-transform: uppercase; letter-spacing: .08em; font-family: Consolas, monospace; font-weight: 800; background: #fffbea; }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; color: var(--ink); font-weight: 500; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 12px; }
.form-grid .span2 { grid-column: span 2; } .form-grid .span4 { grid-column: 1 / -1; }

.btn { border: 1px solid #c9d2df; background: #fff; border-radius: 10px; padding: 9px 16px; cursor: pointer; font-weight: 700; min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; text-decoration: none; color: var(--ink); }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; } .btn.primary:hover { background: var(--brand-dark); }
.btn.oil { background: var(--oil); border-color: var(--oil); color: #1b1300; } .btn.oil:hover { background: #fbbf24; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--danger); border-color: #efb5b5; } .btn.danger:hover { background: var(--danger-soft); }
.btn.big { font-size: 18px; padding: 14px 22px; min-height: 58px; border-radius: 14px; }
.btn.sm { padding: 5px 10px; min-height: 32px; font-size: 13px; border-radius: 8px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- tables ---------- */
table.t { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.t th { text-align: start; font-size: 12px; color: var(--muted); font-weight: 700; padding: 9px 8px; border-bottom: 1px solid var(--line); background: var(--soft); }
.t td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr.click { cursor: pointer; } .t tr.click:hover td { background: #f6f9ff; }
.t .num { text-align: end; } .t tfoot td { font-weight: 800; border-top: 2px solid var(--line); border-bottom: 0; }
.t tr.cancelled td { color: #9aa3b2; text-decoration: line-through; }
.scroll { overflow: auto; max-height: 64vh; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.scroll .t th { position: sticky; top: 0; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--soft); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); } .badge.danger { background: var(--danger-soft); color: var(--danger); } .badge.blue { background: var(--brand-soft); color: var(--brand); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 7px 14px; cursor: pointer; font-size: 14px; font-weight: 600; text-decoration: none; color: var(--ink); display: inline-flex; gap: 6px; align-items: center; }
.chip:hover { border-color: var(--brand); } .chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; padding: 10px 14px; cursor: pointer; font-weight: 700; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
.alert { padding: 11px 14px; border-radius: 10px; background: var(--warn-soft); color: #7a4a0c; border: 1px solid #f5d79e; }
.alert.danger { background: var(--danger-soft); color: #8f1d1d; border-color: #f3c0c0; } .alert.ok { background: var(--ok-soft); color: #14532d; border-color: #b9e3c7; } .alert.blue { background: var(--brand-soft); color: #1e3a8a; border-color: #c7d6ff; }

/* ---------- sale screen ---------- */
.sale { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 14px; align-items: start; }
.sale .bill { position: sticky; top: 12px; }
.vtypes { display: flex; gap: 8px; flex-wrap: wrap; }
.vtype { border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 8px 12px; cursor: pointer; display: flex; flex-direction: column; align-items: center; min-width: 74px; font-size: 13px; font-weight: 700; }
.vtype span { font-size: 26px; line-height: 1.2; } .vtype.on { border-color: var(--brand); background: var(--brand-soft); }
.found { border: 2px solid #9ad3ad; background: #f3fbf5; border-radius: 12px; padding: 12px 14px; }
.found .who { font-size: 17px; font-weight: 800; }
.products { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; max-height: 470px; overflow-y: auto; padding: 2px; }
.ptile { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 10px; cursor: pointer; text-align: start; display: flex; flex-direction: column; gap: 3px; min-height: 104px; box-shadow: var(--shadow); }
.ptile:hover { border-color: var(--brand); } .ptile:active { transform: scale(.98); }
.ptile .ic { font-size: 22px; } .ptile .nm { font-weight: 700; font-size: 14px; line-height: 1.25; }
.ptile .gr { font-size: 12px; color: var(--muted); } .ptile .pr { margin-top: auto; font-weight: 800; color: var(--brand-dark); }
.ptile .st { font-size: 11px; color: var(--muted); } .ptile .st.low { color: var(--danger); font-weight: 700; }
.ptile.out { opacity: .5; }
.ptile.quick { border-color: #f6c768; background: #fffdf5; }
.cart { margin: 0; padding: 0; list-style: none; }
.cart li { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.cart .nm { font-weight: 700; } .cart .lt { font-weight: 800; text-align: end; }
.qty { display: inline-flex; align-items: center; gap: 4px; }
.qty button { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--soft); font-size: 20px; font-weight: 800; cursor: pointer; line-height: 1; }
.qty input { width: 64px; min-height: 36px; text-align: center; padding: 4px; font-weight: 700; }
.price-in { width: 92px; min-height: 36px; padding: 4px 8px; text-align: end; }
.totals .line { display: flex; justify-content: space-between; padding: 4px 0; font-variant-numeric: tabular-nums; }
.totals .grand { font-size: 26px; font-weight: 900; border-top: 2px solid var(--line); margin-top: 6px; padding-top: 10px; color: var(--brand-dark); }
.paym { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.paym button { border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 4px; cursor: pointer; font-weight: 700; font-size: 13px; display: flex; flex-direction: column; align-items: center; }
.paym button span { font-size: 22px; } .paym button.on { border-color: var(--ok); background: var(--ok-soft); }
.next-box { background: var(--oil-soft); border: 1px solid #f5d79e; border-radius: 12px; padding: 12px; }

/* ---------- modal & toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10,20,40,.5); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 14px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 16px; width: min(720px, 100%); box-shadow: 0 24px 60px rgba(0,0,0,.3); }
.modal.wide { width: min(1000px, 100%); } .modal.narrow { width: min(460px, 100%); }
.modal header { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal header h2 { margin: 0; flex: 1; }
.modal header .x { border: 0; background: none; font-size: 26px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal .body { padding: 16px 18px; }
.modal footer { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding: 12px 18px; border-top: 1px solid var(--line); background: #f8fafc; border-radius: 0 0 16px 16px; }
#toasts { position: fixed; inset-inline-end: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 99; }
.toast { background: #1f2937; color: #fff; padding: 11px 16px; border-radius: 10px; max-width: 440px; box-shadow: 0 8px 20px rgba(0,0,0,.2); font-weight: 600; }
.toast.err { background: var(--danger); } .toast.ok { background: var(--ok); }

.login { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #0f1f45, #1d4ed8); padding: 16px; }
.login .card { width: min(430px, 100%); padding: 26px; }
.login .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.login .brand .drop { width: 48px; height: 48px; border-radius: 14px; background: var(--oil); display: grid; place-items: center; font-size: 26px; }
.lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.lang-switch button { border: 0; background: #fff; padding: 5px 12px; cursor: pointer; font-weight: 700; }
.lang-switch button.on { background: var(--brand); color: #fff; }
.side .lang-switch { border-color: rgba(255,255,255,.3); } .side .lang-switch button { background: transparent; color: #dbe5ff; } .side .lang-switch button.on { background: var(--oil); color: #1b1300; }
.bars { display: flex; align-items: flex-end; gap: 8px; height: 120px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bars .b i { display: block; width: 100%; background: var(--brand); border-radius: 6px 6px 0 0; min-height: 3px; }
.bars .b span { font-size: 11px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 14px; } .kv dt { color: var(--muted); } .kv dd { margin: 0; }

@media (max-width: 1150px) { .sale { grid-template-columns: 1fr; } .sale .bill { position: static; } .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .form-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset-block: 0; inset-inline-start: 0; width: 260px; z-index: 45; transform: translateX(-105%); transition: transform .2s; height: 100vh; }
  [dir=rtl] .side { transform: translateX(105%); }
  .shell.nav-open .side { transform: none; }
  .shell.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 44; }
  .menu-btn { display: flex; align-items: center; justify-content: center; position: fixed; top: 10px; inset-inline-start: 10px; z-index: 43; width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-size: 22px; box-shadow: var(--shadow); cursor: pointer; }
  .main { padding: 66px 12px 40px; }
  .g2, .g3, .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: auto; }
  .card { overflow-x: auto; }
  .tile .value { font-size: 20px; }
  .products { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: none; }
  .action-grid { grid-template-columns: repeat(2, 1fr); }
}
