:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #faf8f4;
  --ink: #1f1b16;
  --muted: #6f675d;
  --line: #e7e1d8;
  --accent: #c0392b;
  --accent-ink: #ffffff;
  --accent-soft: #fbe9e6;
  --green: #2f7d4f;
  --green-soft: #e5f3ea;
  --amber: #a86a12;
  --amber-soft: #fdf3e1;
  --blue: #2b6cb0;
  --blue-soft: #e6f0fa;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 27, 22, .05), 0 4px 16px rgba(31, 27, 22, .05);
  --sidebar: 236px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  background: #1f1b16; color: #efe9e0; padding: 20px 14px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; }
.brand-logo { width: 38px; height: 38px; border-radius: 11px; background: var(--accent); display: grid; place-items: center; font-weight: 800; font-size: 20px; color: #fff; }
.brand b { display: block; font-size: 17px; }
.brand small { color: #a79f93; font-size: 12px; }
.nav-sep { font-size: 11px; color: #8a8276; padding: 14px 10px 4px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px;
  color: #d8d0c4; text-decoration: none; font-weight: 500;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: var(--accent); color: #fff; }
.nav a .badge { margin-inline-start: auto; background: #f0b429; color: #1f1b16; border-radius: 99px; font-size: 11px; padding: 0 7px; font-weight: 700; }
.sidebar-foot { margin-top: auto; font-size: 12px; color: #8a8276; padding: 8px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 14px 28px; border-bottom: 1px solid var(--line);
  background: rgba(246,243,238,.92); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 20; flex-wrap: wrap;
}
.topbar h1 { font-size: 20px; margin: 0; font-weight: 700; }
.topbar .today { color: var(--muted); font-size: 13px; }
.topbar .spacer { flex: 1; }
.rate-pill {
  display: inline-flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 99px; font-weight: 600; text-decoration: none; color: var(--ink);
}
.rate-pill.missing { background: var(--accent-soft); border-color: #f2c4bd; color: var(--accent); }
.rate-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.rate-pill.missing .dot { background: var(--accent); }
.role-switch { display: inline-flex; background: #ebe5dc; border-radius: 99px; padding: 3px; }
.role-switch button { border: 0; background: transparent; padding: 5px 14px; border-radius: 99px; font-weight: 600; font-size: 13px; color: var(--muted); }
.role-switch button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.content { padding: 24px 28px 60px; max-width: 1400px; width: 100%; }

/* ---------- Components ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-h h3 { margin: 0; font-size: 15px; font-weight: 700; }
.card-h .spacer { flex: 1; }
.card-b { padding: 16px 18px; }
.grid { display: grid; gap: 16px; }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.b { font-weight: 700; }
.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--green); }
.neg { color: var(--accent); }

.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 26px; font-weight: 800; margin-top: 4px; letter-spacing: -.3px; }
.kpi .value small { font-size: 14px; font-weight: 600; color: var(--muted); }
.kpi .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.kpi.alert { border-color: #f2c4bd; background: linear-gradient(180deg, #fff, #fff7f5); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line);
  background: var(--surface); padding: 8px 14px; border-radius: 10px; font-weight: 600; font-size: 14px; white-space: nowrap;
  text-decoration: none; color: var(--ink);
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #a83224; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #efe9e0; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.lg { padding: 14px 18px; font-size: 17px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg.i { width: 18px; height: 18px; }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #efe9e0; color: var(--muted); white-space: nowrap; }
.chip.red { background: var(--accent-soft); color: var(--accent); }
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.blue { background: var(--blue-soft); color: var(--blue); }

.tabs { display: inline-flex; gap: 4px; background: #ebe5dc; padding: 3px; border-radius: 11px; flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; padding: 6px 14px; border-radius: 8px; font-weight: 600; font-size: 13.5px; color: var(--muted); }
.tabs button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 9px 12px; outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.big { font-size: 22px; font-weight: 700; padding: 10px 14px; }
.input.ltr { direction: ltr; text-align: right; }
.hint { font-size: 12px; color: var(--muted); }
.err { font-size: 13px; color: var(--accent); font-weight: 600; min-height: 1em; }

table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: start; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
table.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.voided td { color: #a9a196; text-decoration: line-through; }
table.t tr.voided td.keep { text-decoration: none; }
.t-wrap { overflow-x: auto; }
.empty { padding: 36px; text-align: center; color: var(--muted); }

.banner { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: var(--radius); border: 1px solid; flex-wrap: wrap; }
.banner.red { background: var(--accent-soft); border-color: #f2c4bd; color: #7d2117; }
.banner.amber { background: var(--amber-soft); border-color: #f1d9ad; color: #6b4309; }
.banner.blue { background: var(--blue-soft); border-color: #c4dbf2; color: #1d4a7a; }
.banner .grow { flex: 1; min-width: 200px; }

/* bars chart */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 180px; padding-top: 10px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; min-width: 0; }
.bar .col { width: 100%; max-width: 46px; background: #e9c9c3; border-radius: 8px 8px 3px 3px; transition: height .3s; position: relative; }
.bar.today .col { background: var(--accent); }
.bar .v { font-size: 11px; color: var(--muted); white-space: nowrap; }
.bar .d { font-size: 12px; color: var(--muted); white-space: nowrap; }

.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.avatar { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; background: #efe9e0; color: var(--muted); flex-shrink: 0; }
.avatar.red { background: var(--accent-soft); color: var(--accent); }
.avatar.green { background: var(--green-soft); color: var(--green); }
.avatar.amber { background: var(--amber-soft); color: var(--amber); }
.avatar.blue { background: var(--blue-soft); color: var(--blue); }

.progress { height: 6px; background: #efe9e0; border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--green); border-radius: 99px; }

/* ---------- POS ---------- */
.pos-layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 20px; align-items: start; }
.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.ptile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0; text-align: start;
  box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; transition: transform .08s, border-color .15s; width: 100%; height: 100%;
}
.ptile:hover { border-color: var(--accent); }
.ptile:active { transform: scale(.98); }
.ptile:disabled { opacity: .5; }
.ptile .band { height: 8px; }
.ptile .pb { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.ptile .nm { font-weight: 700; font-size: 15px; line-height: 1.4; }
.ptile .vr { font-size: 12.5px; color: var(--muted); }
.ptile .pr { font-size: 22px; font-weight: 800; margin-top: 8px; }
.ptile .pr small { font-size: 13px; color: var(--muted); font-weight: 600; }
.ptile .meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 4px; }
.ptile .in-cart { position: absolute; }
.ptile-wrap { position: relative; }
.ptile-wrap .qty-badge { position: absolute; top: 14px; inset-inline-end: 10px; background: var(--accent); color: #fff; border-radius: 99px; min-width: 26px; height: 26px; display: grid; place-items: center; font-weight: 700; font-size: 13px; padding: 0 6px; }

.cart { position: sticky; top: 84px; }
.cart-lines { max-height: 42vh; overflow-y: auto; }
.cline { padding: 12px 18px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; }
.cline .nm { font-weight: 700; font-size: 14px; }
.cline .sub { font-size: 12px; color: var(--muted); }
.cline .tot { font-weight: 800; text-align: end; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stepper button { border: 0; background: var(--surface-2); width: 34px; height: 34px; display: grid; place-items: center; }
.stepper button:hover { background: #efe9e0; }
.stepper input { width: 52px; border: 0; text-align: center; font-weight: 700; height: 34px; outline: none; }
.unit-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.unit-toggle button { border: 0; background: var(--surface); padding: 0 12px; height: 34px; font-size: 13px; font-weight: 600; color: var(--muted); }
.unit-toggle button.on { background: var(--ink); color: #fff; }
.totals { padding: 14px 18px; display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); border-top: 1px solid var(--line); }
.totals .tr { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.totals .grand { font-size: 24px; font-weight: 800; }
.totals .change { font-size: 18px; font-weight: 800; }
.totals .input { padding: 7px 10px; max-width: 170px; text-align: center; font-weight: 700; }
.quick-cash { display: flex; gap: 6px; flex-wrap: wrap; }
.quick-cash button { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 3px 10px; font-size: 13px; font-weight: 600; }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(31,27,22,.45); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade .15s; }
.modal { background: var(--surface); border-radius: 18px; width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); animation: pop .18s; }
.modal.wide { width: min(820px, 100%); }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-h h3 { margin: 0; font-size: 17px; flex: 1; }
.modal-b { padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-f { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-start; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }

.toast-wrap { 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: 10px 18px; border-radius: 12px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: pop .2s; display: flex; gap: 8px; align-items: center; }
.toast.err { background: var(--accent); }

.denoms { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 16px; }
.denom { display: grid; grid-template-columns: 80px 1fr 110px; gap: 8px; align-items: center; }
.denom .input { padding: 6px 10px; text-align: center; }

.ledger .lrow { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.ledger .lrow:last-child { border-bottom: 0; }
.ledger .lrow.total { border-top: 2px solid var(--ink); border-bottom: 0; font-weight: 800; font-size: 18px; margin-top: 4px; padding-top: 12px; }

/* ---------- Printed documents (A5 / A4) ---------- */
.doc-preview { background: #e4ded5; padding: 18px; border-radius: 12px; display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; overflow: auto; }
.doc-preview .doc, .doc-preview .sheet-a4 { zoom: .58; box-shadow: 0 4px 18px rgba(0,0,0,.15); }
.doc {
  width: 148mm; min-height: 210mm; padding: 10mm 11mm; background: #fff; color: #000; font-family: 'Vazirmatn', Tahoma, sans-serif;
  font-size: 10.5pt; line-height: 1.55; display: flex; flex-direction: column; gap: 4mm; position: relative; overflow: hidden;
}
.sheet-a4 { width: 210mm; height: 297mm; background: #fff; display: grid; grid-template-rows: 1fr 1fr; }
.sheet-a4 .doc { width: 210mm; min-height: 0; height: 148.5mm; padding: 8mm 12mm; box-shadow: none; zoom: 1; gap: 2.5mm; }
.sheet-a4 .doc:first-child { border-bottom: 1.5px dashed #888; }
.sheet-a4 .d-stamp { bottom: 26mm; }
.sheet-a4 .d-sign { padding-top: 4mm; }
.d-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 6mm; border-bottom: 2px solid #000; padding-bottom: 3mm; }
.d-store b { font-size: 17pt; font-weight: 800; display: block; line-height: 1.3; }
.d-store div { font-size: 9pt; }
.d-title { text-align: end; }
.d-title b { font-size: 14pt; display: block; }
.d-copy { display: inline-block; border: 1.5px solid #000; border-radius: 4px; padding: 0 3mm; font-weight: 700; font-size: 9.5pt; margin-top: 1mm; }
.d-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 1mm 6mm; font-size: 10pt; }
.d-meta span { color: #444; }
.d-no { font-size: 13pt; font-weight: 800; }
.d-table { width: 100%; border-collapse: collapse; font-size: 10pt; }
.d-table th { background: #eee; font-weight: 700; border: 1px solid #000; padding: 1.5mm 2mm; text-align: start; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.d-table td { border: 1px solid #000; padding: 1.5mm 2mm; }
.d-table .n { text-align: center; white-space: nowrap; }
.d-table .big { font-size: 15pt; font-weight: 800; text-align: center; }
.d-table .box { width: 12mm; text-align: center; font-size: 14pt; }
.d-totals { display: flex; justify-content: space-between; gap: 6mm; align-items: flex-start; }
.d-totals .pay { font-size: 9.5pt; }
.d-totals .sum { border: 2px solid #000; border-radius: 3px; padding: 2mm 4mm; min-width: 55mm; }
.d-totals .sum div { display: flex; justify-content: space-between; gap: 4mm; }
.d-totals .sum .g { font-size: 13pt; font-weight: 800; border-top: 1px solid #000; margin-top: 1mm; padding-top: 1mm; }
.d-words { font-size: 9pt; color: #333; }
.d-sign { margin-top: auto; display: flex; justify-content: space-around; gap: 8mm; padding-top: 10mm; font-size: 9.5pt; }
.d-sign span { border-top: 1px solid #000; min-width: 40mm; text-align: center; padding-top: 1mm; }
.d-foot { font-size: 8.5pt; text-align: center; color: #333; border-top: 1px dashed #999; padding-top: 2mm; }
.d-stamp { position: absolute; bottom: 42mm; left: 14mm; transform: rotate(-12deg); border: 3px double #000; border-radius: 6px; padding: 1mm 5mm; font-weight: 800; font-size: 14pt; opacity: .8; }
.d-void { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.d-void span { transform: rotate(-25deg); font-size: 46pt; font-weight: 800; color: rgba(0,0,0,.18); border: 6px solid rgba(0,0,0,.18); padding: 2mm 10mm; border-radius: 8px; }
.d-hint { font-size: 9pt; border: 1px solid #000; border-radius: 3px; padding: 1.5mm 3mm; }

#print-area { display: none; }
@media print {
  body { background: #fff; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block; }
  #print-area .doc, #print-area .sheet-a4, #print-area .pricelist { page-break-after: always; break-after: page; }
  #print-area > :last-child { page-break-after: auto; break-after: auto; }
  #print-area .sheet-a4 .doc { page-break-after: auto; break-after: auto; }
}
.pricelist { font-family: 'Vazirmatn', Tahoma, sans-serif; padding: 10mm; }
.pricelist h2 { margin: 0 0 4px; }
.pricelist table { width: 100%; border-collapse: collapse; font-size: 16px; margin-top: 12px; }
.pricelist th, .pricelist td { border: 1px solid #000; padding: 8px 10px; text-align: start; }

/* sparkline */
.spark { width: 100%; height: 120px; }

/* ---------- Mobile ---------- */
@media (max-width: 1100px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main { grid-template-columns: 1fr; }
  .pos-layout { grid-template-columns: 1fr; }
  .cart { position: static; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; bottom: 0; top: auto; inset-inline: 0; height: auto; z-index: 50; flex-direction: row; padding: 6px;
    overflow-x: auto; gap: 2px;
  }
  .brand, .nav-sep, .sidebar-foot { display: none; }
  .nav { display: contents; }
  .nav a { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 10px; min-width: 64px; white-space: nowrap; }
  .nav a .badge { position: absolute; margin: 0; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px 16px 100px; }
  .g-3, .g-2 { grid-template-columns: 1fr; }
  .denoms { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .g-4 { grid-template-columns: 1fr 1fr; }
  .kpi .value { font-size: 20px; }
  .products-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

table.t td.num, .kpi .value { white-space: nowrap; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 20% 10%, #f3ddd8, transparent 50%), var(--bg); }
.login-card { width: min(560px, 100%); padding: 28px; }
.login-card .brand { padding: 0 0 18px; }
.login-card .brand b { color: var(--ink); font-size: 20px; }
.login-card .brand small { color: var(--muted); }
.user-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.user-tile { border: 1.5px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px; display: flex; gap: 10px; align-items: center; text-align: start; }
.user-tile:hover { border-color: var(--accent); }
.user-tile.on { border-color: var(--accent); background: var(--accent-soft); }
.user-tile b { display: block; }
.pin { letter-spacing: 12px; text-align: center; font-size: 26px; font-weight: 800; }
.me-chip { display: inline-flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 99px; padding: 4px 6px 4px 12px; font-weight: 600; font-size: 13.5px; }
.me-chip .chip { font-size: 11px; }

/* ---------- Cart price ---------- */
.cline .price-in { width: 110px; text-align: center; font-weight: 700; padding: 6px 8px; }
.cline .price-in.manual { border-color: var(--amber); background: var(--amber-soft); }
.cline .price-in.below { border-color: var(--accent); background: var(--accent-soft); }
.pay-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pay-grid .field label { font-size: 12px; }
.pay-grid .input { max-width: none; }

/* ---------- Telegram preview ---------- */
.tg { background: #c8dcb6 linear-gradient(135deg, #cfe3bd, #b9d4a5); border-radius: 12px; padding: 18px; }
.tg-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; color: #1f3a12; font-weight: 700; font-size: 14px; }
.tg-head .av { width: 34px; height: 34px; border-radius: 50%; background: #2aa1da; color: #fff; display: grid; place-items: center; }
.tg-bubble { background: #fff; border-radius: 14px 14px 14px 4px; padding: 12px 14px; white-space: pre-wrap; font-size: 14px; line-height: 1.75; max-width: 420px; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.tg-bubble .t { display: block; text-align: end; font-size: 11px; color: #8a9a80; }

/* ---------- Warehouse ---------- */
.wh-search { display: flex; gap: 10px; }
.wh-search .input { font-size: 26px; font-weight: 800; text-align: center; letter-spacing: 2px; }
.wh-result { border: 2px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.wh-result.ok { border-color: var(--green); background: var(--green-soft); }
.wh-result.bad { border-color: var(--accent); background: var(--accent-soft); }
.wh-items { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.wh-items .it { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; font-weight: 600; }
.wh-items .it b { font-size: 18px; margin-inline-start: 6px; }

/* =================== v3: simple calculator UI =================== */
.btn.xl { padding: 16px 22px; font-size: 19px; border-radius: 14px; }
.layout.simple .nav a { font-size: 17px; padding: 13px 14px; }
.layout.simple .nav a svg.i { width: 24px; height: 24px; }
button.rate-pill { cursor: pointer; font: inherit; font-weight: 600; }

/* Start / end of day gate */
.gate { padding: 40px 28px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.gate h2 { margin: 0; font-size: 24px; }
.gate-ic { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; }
.gate-ic svg.i { width: 38px; height: 38px; }
.gate-ic.sun { background: var(--amber-soft); color: var(--amber); }
.gate-ic.moon { background: var(--blue-soft); color: var(--blue); }
.steps { list-style: persian; text-align: start; font-size: 17px; margin: 0; padding-inline-start: 22px; line-height: 2; }

/* Calculator layout */
.calc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.calc-card { padding: 6px 0 0; overflow: hidden; }
table.calc { width: 100%; border-collapse: collapse; }
table.calc th { font-size: 13px; color: var(--muted); font-weight: 600; text-align: start; padding: 10px 14px; border-bottom: 1px solid var(--line); }
table.calc td { padding: 8px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.calc tr.has { background: #fffaf3; }
table.calc td:nth-child(2) { width: 130px; }
table.calc td:nth-child(3) { width: 170px; }
.ltot { font-size: 19px; font-weight: 800; text-align: end; white-space: nowrap; min-width: 110px; }
.pname { border: 0; background: transparent; display: flex; align-items: center; gap: 12px; text-align: start; padding: 6px 4px; border-radius: 10px; width: 100%; }
.pname:hover { background: #f3eee6; }
.pname > span:last-child { font-size: 18px; font-weight: 700; display: flex; flex-direction: column; line-height: 1.35; }
.pname small { font-size: 12px; font-weight: 500; color: var(--muted); }
.pdot { width: 14px; height: 40px; border-radius: 6px; flex-shrink: 0; }
.pchips { display: flex; gap: 4px; margin-top: 3px; min-height: 0; }

.kfield {
  display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 52px; padding: 6px 10px;
  border: 2px solid var(--line); background: #fff; border-radius: 12px; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.kfield small { font-size: 13px; font-weight: 600; color: var(--muted); }
.kfield .ph { color: #c4bcb0; font-weight: 700; }
.kfield:hover { border-color: #d9cfc2; }
.kfield.on { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background: #fff; }
.kfield.price { font-size: 18px; }
.kfield.price.manual { background: var(--amber-soft); border-color: #e9c27a; }
.kfield.price.below { background: var(--accent-soft); border-color: #eaa59b; }
.kfield.price.on { border-color: var(--accent); }

.calc-total { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 18px; background: var(--ink); color: #fff; }
.calc-total span { font-size: 18px; font-weight: 700; display: block; }
.calc-total small { color: #bdb4a7; font-size: 13px; }
.calc-total b { font-size: 34px; font-weight: 800; white-space: nowrap; }
.pay-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 14px 18px 4px; }
.pay-row label { font-size: 13px; font-weight: 600; color: var(--muted); display: block; margin-bottom: 4px; }
.change-box { margin: 10px 18px 18px; padding: 14px 18px; border-radius: 14px; background: var(--green-soft); color: var(--green); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.change-box span { font-weight: 700; font-size: 16px; }
.change-box b { font-size: 30px; font-weight: 800; white-space: nowrap; }
.change-box.short { background: var(--accent-soft); color: var(--accent); }

/* Keypad */
.kp-card { padding: 16px; display: flex; flex-direction: column; gap: 12px; position: sticky; top: 84px; }
.kp-display { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; text-align: end; }
.kp-display small { display: block; text-align: start; color: var(--muted); font-size: 13px; font-weight: 600; }
.kp-display b { font-size: 34px; font-weight: 800; line-height: 1.3; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; direction: ltr; }
.kp-key {
  height: 62px; border: 1px solid var(--line); background: #fff; border-radius: 12px; font-size: 26px; font-weight: 700;
  display: grid; place-items: center; box-shadow: 0 2px 0 #e7e1d8; user-select: none;
}
.kp-key:hover { background: #faf6f0; }
.kp-key:active { transform: translateY(2px); box-shadow: none; }
.kp-key.fn { background: #f1ece4; font-size: 18px; color: var(--muted); }
.kp-key.wide { grid-column: span 2; }
.kp-key svg.i { width: 28px; height: 28px; }

/* Keypad modals (start/end day, rate) */
.kp-modal { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; align-items: start; }
.kp-row label { display: block; font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.diff-box { margin-top: 12px; padding: 12px 14px; border-radius: 12px; font-weight: 800; font-size: 18px; display: flex; gap: 8px; align-items: center; }
.diff-box.ok { background: var(--green-soft); color: var(--green); }
.diff-box.bad { background: var(--accent-soft); color: var(--accent); }

/* Login PIN */
.pin-dots { display: flex; justify-content: center; gap: 16px; padding: 8px 0; }
.pin-dots span { width: 20px; height: 20px; border-radius: 50%; border: 2px solid #c9bfb2; }
.pin-dots span.on { background: var(--ink); border-color: var(--ink); }
.pin-dots.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.login-pad { max-width: 320px; margin: 0 auto; width: 100%; }

/* Sale done */
.done { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.done-ic { width: 70px; height: 70px; border-radius: 50%; background: var(--green-soft); color: var(--green); display: grid; place-items: center; }
.done-ic svg.i { width: 40px; height: 40px; stroke-width: 2.5; }
.done-change { font-size: 46px; font-weight: 800; color: var(--green); }

@media (max-width: 1100px) {
  .calc-layout { grid-template-columns: 1fr; }
  .kp-card { position: static; }
}
@media (max-width: 700px) {
  .kp-modal { grid-template-columns: 1fr; }
  table.calc td:nth-child(2), table.calc td:nth-child(3) { width: auto; }
  table.calc th:nth-child(4), table.calc td:nth-child(4) { display: none; }
  .pay-row { grid-template-columns: 1fr; }
}

/* =================== live version additions =================== */
.net-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 99px; font-size: 13px; font-weight: 600; border: 1px solid var(--line); background: var(--surface); white-space: nowrap; }
.net-pill:empty { display: none; }
.net-pill svg.i { width: 16px; height: 16px; }
.net-pill.on { color: var(--green); }
.net-pill.wait { color: var(--amber); background: var(--amber-soft); border-color: #f1d9ad; }
.net-pill.wait svg.i { animation: spin 1.2s linear infinite; }
.net-pill.off { color: var(--accent); background: var(--accent-soft); border-color: #f2c4bd; }
@keyframes spin { to { transform: rotate(360deg); } }
tr.unpriced td { background: #faf8f4; }
.ltr { direction: ltr; unicode-bidi: isolate; }
