/* CTP অ্যাপ — একই ফাইল ফোনে (গ্রাহক) আর কাউন্টারের বড় পর্দায় (কর্মী, admin)।
 *
 * হাজিরা অ্যাপের রং-নাম আর নিয়ম রাখা হয়েছে (বড় বোতাম, রঙের সাথে লেখাও),
 * শুধু মূল রং নীল — Selim Papers-এর সবুজ থেকে আলাদা, যাতে কর্মী এক নজরে বোঝেন
 * কোন দোকানের খাতায় আছেন। কোনো বাইরের ফন্ট নয়।
 */

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --a: #1d4ed8; --a-dark: #1e40af; --a-soft: #eff6ff; --a-line: #bfdbfe;
  --ink: #0f172a; --strong: #334155; --muted: #64748b; --faint: #94a3b8;
  --line: #e2e8f0; --bg: #f1f5f9; --card: #fff;
  --ok: #16a34a; --ok-soft: #ecfdf5; --ok-line: #a7f3d0;
  --warn: #b45309; --warn-soft: #fffbeb; --warn-line: #fde68a;
  --danger: #dc2626; --danger-soft: #fef2f2; --danger-line: #fecaca;
}

html, body { height: 100%; }
body {
  font-family: 'Hind Siliguri', 'Noto Sans Bengali', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h2 { font-size: 19px; }
h3 { font-size: 16px; margin-bottom: 6px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.r { text-align: right; }
.nowrap { white-space: nowrap; }

/* ── পর্দা ── */
.screen { display: none; min-height: 100dvh; flex-direction: column; }
.screen.on { display: flex; }
.screen.center { align-items: center; justify-content: center; padding: 20px; gap: 12px; }
.scroll {
  flex: 1; padding: 14px; display: flex; flex-direction: column; gap: 12px;
  width: 100%; max-width: 1200px; margin: 0 auto;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

.bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
  background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.bar b { font-size: 17px; }
.bar .who { color: var(--muted); font-size: 14px; }
.sp { flex: 1; }
.logo {
  display: inline-grid; place-items: center; width: 46px; height: 46px; border-radius: 12px;
  background: var(--a); color: #fff; font-weight: 700; font-size: 14px; letter-spacing: .5px;
}
.logo.sm { width: 34px; height: 34px; border-radius: 9px; font-size: 11px; }

/* ── কার্ড ── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.card.tight { padding: 12px; }
.login { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.brand b { display: block; font-size: 19px; }
.brand small { color: var(--muted); }
.hint { color: var(--muted); font-size: 14px; }
.msg { color: var(--danger); font-size: 14px; min-height: 1px; }
.msg:empty { display: none; }

/* ── ঘর ── */
label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--strong); }
input, select, textarea {
  font: inherit; font-size: 16px; color: var(--ink); background: #fff;
  border: 1px solid #cbd5e1; border-radius: 10px; padding: 10px 12px; min-height: 46px; width: 100%;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--a-line); border-color: var(--a); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 140px; }
.row > .fit { flex: 0 0 auto; }

/* ── বোতাম ── */
.btn {
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  min-height: 44px; padding: 8px 14px; display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; text-decoration: none; white-space: nowrap;
}
.btn.primary { background: var(--a); border-color: var(--a); color: #fff; }
.btn.primary:hover { background: var(--a-dark); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { background: #fff; border-color: var(--danger-line); color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--strong); }
.btn.sm { min-height: 36px; padding: 4px 10px; font-size: 14px; }
.btn.lg { min-height: 54px; font-size: 17px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn[aria-busy="true"]::after {
  content: ''; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.link { background: none; border: none; color: var(--a); font: inherit; font-size: 14px; cursor: pointer; text-align: left; }
a.link, button.link { text-decoration: underline; text-underline-offset: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* নেট নেই — টাকা/Job-এর বোতাম চাপাই যায় না */
body.offline .needs-net { opacity: .4; pointer-events: none; }
.pill { font-size: 13px; padding: 2px 10px; border-radius: 99px; background: var(--danger-soft); color: var(--danger); }

/* ── সংখ্যার ঘর ── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.stat small { display: block; color: var(--muted); font-size: 13px; }
.stat b { font-size: 22px; font-variant-numeric: tabular-nums; }
.stat.due b { color: var(--danger); }
.stat.good b { color: var(--ok); }

/* ── অবস্থা ── */
.chip { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 1px 9px; border-radius: 99px; white-space: nowrap; }
.chip.pending { background: var(--warn-soft); color: var(--warn); }
.chip.made { background: var(--a-soft); color: var(--a); }
.chip.delivered { background: var(--ok-soft); color: var(--ok); }
.chip.cancelled { background: #f1f5f9; color: var(--muted); }
.chip.special { background: #f5f3ff; color: #6d28d9; }

/* ── তালিকা ও টেবিল ── */
.list { display: flex; flex-direction: column; }
.item {
  display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: 10px 2px; border-bottom: 1px solid var(--line);
}
.item:last-child { border-bottom: none; }
.item.click { cursor: pointer; }
.item.click:hover { background: var(--a-soft); }
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.tbl th, .tbl td { padding: 8px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { font-size: 13px; color: var(--muted); font-weight: 600; background: #f8fafc; }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl tr.voided td { text-decoration: line-through; color: var(--faint); }
.tbl tr.neg td { color: var(--danger); }
.tbl tfoot td { font-weight: 700; }
.empty { color: var(--muted); text-align: center; padding: 18px 0; }

/* ── ট্যাব ── */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tabs button {
  font: inherit; font-size: 15px; background: none; border: none; padding: 10px 14px; cursor: pointer;
  color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap;
}
.tabs button.on { color: var(--a); border-bottom-color: var(--a); font-weight: 600; }

/* ── কাউন্টার ── */
.pos-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 980px) { .pos-grid { grid-template-columns: 360px 1fr; align-items: start; } }
.shiftbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font-size: 14.5px;
}
.shiftbar.closed { background: var(--warn-soft); border-color: var(--warn-line); }
.cust-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: flex-start; }
.cust-head .name { font-size: 20px; font-weight: 700; }
.job-card { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.job-card .top { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.lines { font-size: 14px; color: var(--strong); }
.jl { display: grid; grid-template-columns: 1.6fr .7fr .7fr auto; gap: 8px; align-items: end; }
.jl .del { min-height: 46px; }
.preview { background: var(--a-soft); border: 1px solid var(--a-line); border-radius: 10px; padding: 10px 12px; }
.preview .tot { font-size: 20px; font-weight: 700; }

/* ── জানালা ── */
.overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center; padding: 5vh 12px; overflow-y: auto;
}
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 560px; display: flex; flex-direction: column; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-head .x { background: none; border: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); }
.modal-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.modal > .msg { padding: 0 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }

/* ── toast ── */
#toastHost { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; }
.toast { padding: 10px 16px; border-radius: 10px; background: var(--ink); color: #fff; font-size: 15px; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 92vw; }
.toast.err { background: var(--danger); }
.toast.warn { background: var(--warn); }

/* ── ফোন ── */
@media (max-width: 560px) {
  .bar .who { display: none; }
  .jl { grid-template-columns: 1fr 1fr; }
  .jl > label:first-child { grid-column: 1 / -1; }
}

/* পর্দায় বিল দেখা (গ্রাহকের পাতা) — ছাপার রসিদের একই গড়ন */
.receipt-view { max-width: 420px; margin: 0 auto; font-size: 15px; }
.receipt-view h2, .receipt-view .c { text-align: center; }
.receipt-view table { width: 100%; border-collapse: collapse; }
.receipt-view td { padding: 3px 0; vertical-align: top; }
.receipt-view td.r { text-align: right; font-variant-numeric: tabular-nums; }
.receipt-view tr.b td, .receipt-view .b { font-weight: 700; }
.receipt-view hr { border: none; border-top: 1px dashed var(--faint); margin: 8px 0; }

/* ═══════════ ছাপা ═══════════
   #print কেবল ছাপার সময় দেখা যায়; বাকি সব লুকানো। রসিদ ৮০ মিমি কাগজে
   (Papers POS-এর .receipt-এর একই মাপ), হিসাব A4-এ। */
#print { display: none; }
@media print {
  html, body { height: auto !important; overflow: visible !important; margin: 0 !important; padding: 0 !important; background: #fff; }
  body > * { display: none !important; }
  body > #print { display: block !important; color: #000; }
  .print-receipt { width: 72mm; font-size: 11.5px; line-height: 1.45; }
  .print-receipt .c { text-align: center; }
  .print-receipt hr { border: none; border-top: 1px dashed #000; margin: 5px 0; }
  .print-receipt table { width: 100%; border-collapse: collapse; }
  .print-receipt td { padding: 1.5px 0; vertical-align: top; }
  .print-receipt td.r { text-align: right; }
  .print-receipt h2 { font-size: 15px; margin-bottom: 2px; }
  .print-receipt .b { font-weight: 700; }
  .print-receipt .foot { padding-bottom: 5mm; }
  .print-a4 { font-size: 12px; padding: 10mm; }
  .print-a4 h2 { font-size: 17px; }
  .print-a4 table { width: 100%; border-collapse: collapse; margin-top: 8px; }
  .print-a4 th, .print-a4 td { border: 1px solid #999; padding: 4px 6px; text-align: left; }
  .print-a4 td.r, .print-a4 th.r { text-align: right; }
}
/* রসিদের কাগজে কিনারা নয়; A4-এর কিনারা লেখার ভেতরের ফাঁকা দিয়ে */
@page { margin: 0; }
