/* =====================================================================
   ফিরোজা এন্টারপ্রাইজ ERP — ডিজাইন সিস্টেম (Color Theory + Responsive)
   ----------------------------------------------------------------------
   কালার থিউরি:
   • ব্র্যান্ড = "ফিরোজা" (turquoise/teal) — বিশ্বাসযোগ্যতা + রিফ্রেশিং
   • নিউট্রাল = হালকা teal-টিন্টেড স্লেট (ঠান্ডা ধূসর নয়, UI উষ্ণ আভা রাখে)
   • semantic = success(sage green), warning(amber), danger(clay red), info(sky)
   • কনট্রাস্ট: বডি টেক্সট ≥ 4.5:1 (WCAG AA), সাইডবারে সাদা-on-deep-teal
   • গ্রেডিয়েন্ট: সাইডবার #0A3436 → #0F615C (গাঢ় → প্রাণবন্ত)
   • স্পেসিং স্কেল: 4/8/12/16/24/32 · রেডিয়াস: var(--radius)
   থিম কাস্টমাইজেশন: সেটিংস → থিম থেকে --primary/--sidebar/--radius বদলায়
   ===================================================================== */

:root {
  --primary-50: #ECFDF7;
  --primary-100: #D1FAE9;
  --primary-200: #A7F3DA;
  --primary-300: #6EE7C8;
  --primary-400: #34D3B0;
  --primary-500: #14B8A6;
  --primary-600: #0D9488;
  --primary-700: #0F766E;
  --primary-800: #115E59;
  --primary-900: #0A3436;

  --primary: var(--primary-600);
  --sidebar-bg: #0A3436;
  --sidebar-grad: linear-gradient(180deg, #0E5050 0%, #0A3436 100%);
  --sidebar-fg: #CFF3EC;
  --sidebar-muted: #8FC7BE;
  --accent: #6366F1;         /* ইন্ডিগো — তথ্য/লিংক অ্যাকসেন্ট */

  --bg: #F4F8F8;
  --surface: #FFFFFF;
  --surface-2: #F8FBFB;
  --text: #0E1B1C;
  --muted: #5A6E70;
  --border: #E1EAEA;
  --border-strong: #CBD8D8;

  --success: #16803C;
  --success-bg: #E7F7EC;
  --warning: #B45309;
  --warning-bg: #FEF3DC;
  --danger: #C62828;
  --danger-bg: #FDECEC;
  --info: #0369A1;
  --info-bg: #E6F3FB;

  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(10, 52, 54, .06);
  --shadow: 0 4px 16px rgba(10, 52, 54, .08);
  --shadow-lg: 0 16px 40px rgba(10, 52, 54, .16);

  --sidebar-w: 256px;
  --topbar-h: 64px;
  --font: "Noto Sans Bengali", "Hind Siliguri", "SolaimanLipi", "Segoe UI",
          system-ui, -apple-system, sans-serif;
}

/* ডার্ক থিম (সেটিংস → থিম → ডার্ক চালু থাকলে) */
[data-theme="dark"] {
  --bg: #0C1415;
  --surface: #132021;
  --surface-2: #18292A;
  --text: #E8F2F1;
  --muted: #93A8A7;
  --border: #213636;
  --border-strong: #2C4545;
  --primary-50: #0F2B2A;
  --primary-100: #123A38;
  --success-bg: #10301C;
  --warning-bg: #34230B;
  --danger-bg: #361515;
  --info-bg: #0E2A3B;
  --shadow: 0 4px 16px rgba(0, 0, 0, .35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4 { margin: 0 0 8px; line-height: 1.3; font-weight: 700; }
h1 { font-size: 24px; } h2 { font-size: 19px; } h3 { font-size: 16px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.mono { font-family: "Consolas", "SF Mono", monospace; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.success-t { color: var(--success); }
.danger-t { color: var(--danger); }
.warning-t { color: var(--warning); }

/* ============================ লেআউট ============================ */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-grad);
  color: var(--sidebar-fg);
  position: fixed; inset: 0 auto 0 0;
  display: flex; flex-direction: column;
  z-index: 60; transition: transform .25s ease;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar .brand img { width: 40px; height: 40px; border-radius: 11px; box-shadow: var(--shadow); }
.sidebar .brand .bname { font-weight: 700; color: #fff; font-size: 15.5px; line-height: 1.2; }
.sidebar .brand .btag { font-size: 11px; color: var(--sidebar-muted); }

.nav { padding: 10px 10px 20px; overflow-y: auto; flex: 1; }
.nav-label { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--sidebar-muted); padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; margin: 2px 0; border-radius: 10px;
  color: var(--sidebar-fg); font-size: 14px; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav a svg { width: 19px; height: 19px; flex: 0 0 auto; opacity: .9; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.active {
  background: linear-gradient(90deg, rgba(20,184,166,.28), rgba(20,184,166,.10));
  color: #fff; box-shadow: inset 3px 0 0 var(--primary-400);
}
.sidebar .userbox {
  border-top: 1px solid rgba(255,255,255,.08); padding: 12px 16px;
  display: flex; align-items: center; gap: 10px; font-size: 13px;
}
.sidebar .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary-600); color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
}
.sidebar .userbox .uname { color: #fff; font-weight: 600; line-height: 1.2; }
.sidebar .userbox .urole { font-size: 11px; color: var(--sidebar-muted); }
.icon-btn {
  background: rgba(255,255,255,.08); border: 0; color: #fff;
  width: 32px; height: 32px; border-radius: 9px; cursor: pointer;
  display: grid; place-items: center;
}
.icon-btn:hover { background: rgba(255,255,255,.18); }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: var(--topbar-h); background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px; position: sticky; top: 0; z-index: 40;
}
.topbar .page-title { font-size: 17px; font-weight: 700; }
.topbar .spacer { flex: 1; }
.hamburger { display: none; background: none; border: 0; color: var(--text); cursor: pointer; padding: 6px; }
.hamburger svg { width: 24px; height: 24px; }

.content { padding: 22px; max-width: 1440px; width: 100%; margin: 0 auto; }

/* ============================ কম্পোনেন্ট ============================ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 18px; margin-bottom: 18px;
}
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head .spacer { flex: 1; }

.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
/* যাবতীয় হিসাব নিকাশ — মোবাইলেও ২ কলামে থাকে যাতে স্ক্রল লম্বা না হয় */
.g-total { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-auto { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

/* স্ট্যাট কার্ড */
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; display: flex; gap: 13px;
  align-items: flex-start; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; right: -30px; top: -30px;
  width: 90px; height: 90px; border-radius: 50%;
  background: var(--primary-50); opacity: .7;
}
[data-theme="dark"] .stat::after { background: var(--primary-900); opacity: .5; }
.stat .ic {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: var(--primary-100); color: var(--primary-700); flex: 0 0 auto; z-index: 1;
}
.stat .ic svg { width: 21px; height: 21px; }
.stat .ic.green { background: var(--success-bg); color: var(--success); }
.stat .ic.amber { background: var(--warning-bg); color: var(--warning); }
.stat .ic.red { background: var(--danger-bg); color: var(--danger); }
.stat .ic.blue { background: var(--info-bg); color: var(--info); }
.stat .val { font-size: 22px; font-weight: 800; line-height: 1.15; z-index: 1; }
.stat .lbl { font-size: 12.5px; color: var(--muted); z-index: 1; }

/* ক্লিকযোগ্য স্ট্যাট কার্ড (ড্যাশবোর্ড) */
.stat-link { display: flex; gap: 13px; align-items: center; color: inherit; text-decoration: none; }
.stat-link:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--primary-600); }
.stat-link .lbl::after { content: " →"; font-weight: 700; color: var(--primary-600); }

/* বাটন */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid transparent;
  font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  background: var(--primary); color: #fff; transition: .15s; white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn.ghost { background: transparent; color: var(--primary); border-color: transparent; }
.btn.danger { background: var(--danger); }
.btn.success { background: var(--success); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-icon { padding: 8px; width: 36px; height: 36px; }

/* ফর্ম */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.field label .req { color: var(--danger); }
input, select, textarea {
  width: 100%; padding: 10px 12px; font-family: inherit; font-size: 14.5px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--text); transition: border .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
}
input[readonly] { background: var(--surface-2); color: var(--muted); }
textarea { resize: vertical; min-height: 84px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* টেবিল — মোবাইলে কার্ড মোড সহ */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl thead th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); background: var(--surface-2); padding: 11px 12px;
  border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0;
}
.tbl tbody td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: var(--primary-50); }
[data-theme="dark"] .tbl tbody tr:hover { background: var(--primary-900); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; }

/* ক্লিকযোগ্য লিংক (টেবিলের ভেতরে) */
.link {
  color: var(--primary-600); font-weight: 600; cursor: pointer;
  text-decoration: underline; text-decoration-style: dotted;
  text-underline-offset: 3px;
}
.link:hover { color: var(--primary-700); }

/* ব্যাজ / স্ট্যাটাস */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px;
  font-size: 11.5px; font-weight: 700; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.green { background: var(--success-bg); color: var(--success); border-color: transparent; }
.badge.amber { background: var(--warning-bg); color: var(--warning); border-color: transparent; }
.badge.red { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.badge.blue { background: var(--info-bg); color: var(--info); border-color: transparent; }
.badge.teal { background: var(--primary-100); color: var(--primary-700); border-color: transparent; }
.badge.plain::before { display: none; }

/* ফিল্টার বার */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.filters input, .filters select { width: auto; min-width: 150px; padding: 8px 11px; font-size: 14px; }
.filters .search { flex: 1; min-width: 200px; }

/* মডাল */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(6, 28, 29, .55);
  backdrop-filter: blur(3px); display: none; z-index: 100;
  align-items: center; justify-content: center; padding: 18px;
}
.modal-backdrop.open { display: flex; animation: fadeIn .18s ease; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
  animation: popIn .2s cubic-bezier(.2, .9, .3, 1.2);
}
.modal.lg { max-width: 860px; }
.modal.sm { max-width: 420px; }
.modal-head {
  display: flex; align-items: center; gap: 10px; padding: 16px 20px;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0; z-index: 2;
}
.modal-head h3 { margin: 0; flex: 1; }
.modal-body { padding: 20px; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
  position: sticky; bottom: 0; background: var(--surface);
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes popIn { from { opacity: 0; transform: translateY(14px) scale(.97) } to { opacity: 1; transform: none } }

/* টোস্ট */
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 9px; max-width: min(94vw, 380px); }
.toast {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-left: 4px solid var(--primary); border-radius: 11px; box-shadow: var(--shadow-lg);
  padding: 12px 15px; font-size: 14px; animation: slideIn .25s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warning); }
@keyframes slideIn { from { opacity: 0; transform: translateX(30px) } to { opacity: 1; transform: none } }

/* খালি অবস্থা / লোডার */
.empty { text-align: center; padding: 42px 16px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 8px; }
.loader { display: inline-block; width: 18px; height: 18px; border: 2.5px solid var(--border-strong);
  border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -4px; }
@keyframes spin { to { transform: rotate(360deg) } }

/* অফলাইন বার */
#offline-bar {
  display: none; background: var(--warning-bg); color: var(--warning);
  padding: 8px 16px; font-size: 13.5px; font-weight: 600; text-align: center;
  position: sticky; top: var(--topbar-h); z-index: 45;
}
body.is-offline #offline-bar { display: block; }

/* ============ PWA ইনস্টল ব্যানার ============ */
#install-bar {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(120deg, var(--primary-600, #0F766E), var(--sidebar-bg, #0A3436));
  color: #fff; padding: 11px 14px; font-size: 13.5px; font-weight: 600;
  position: sticky; top: var(--topbar-h); z-index: 46;
  box-shadow: 0 4px 16px rgba(0,0,0,.16);
}
#install-bar[hidden] { display: none; }
#install-bar .ib-txt {
  flex: 1; min-width: 0; line-height: 1.45;
  overflow-wrap: anywhere;
}
#install-bar .ib-btn {
  flex: none; border: 0; border-radius: 999px; padding: 8px 18px;
  background: #fff; color: var(--primary-700, #0B5C58); font-weight: 800;
  font-size: 13.5px; cursor: pointer; font-family: inherit;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
#install-bar .ib-btn:active { transform: translateY(1px); }
#install-bar .ib-x {
  flex: none; border: 0; background: rgba(255,255,255,.16); color: #fff;
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  font-size: 14px; line-height: 1; font-family: inherit;
}
#install-bar .ib-x:hover { background: rgba(255,255,255,.28); }
@media (max-width: 480px) {
  #install-bar { flex-wrap: wrap; font-size: 13px; padding: 10px 12px; }
  #install-bar .ib-txt { flex: 1 1 100%; }
  #install-bar .ib-btn { flex: 1; }
}

/* স্ক্যান সেন্টার */
.scan-stage {
  position: relative; border-radius: var(--radius); overflow: hidden;
  background: #06181A; aspect-ratio: 4 / 3; display: grid; place-items: center;
}
.scan-stage video { width: 100%; height: 100%; object-fit: cover; }
.scan-frame {
  position: absolute; inset: 14% 8%; border: 3px solid var(--primary-400);
  border-radius: 16px; box-shadow: 0 0 0 2000px rgba(4, 20, 21, .45);
  pointer-events: none;
}
.scan-frame::after {
  content: ""; position: absolute; left: 4px; right: 4px; top: 0; height: 3px;
  background: var(--primary-400); box-shadow: 0 0 14px var(--primary-300);
  animation: scanline 2.2s ease-in-out infinite;
}
@keyframes scanline { 0%,100% { top: 4% } 50% { top: 94% } }
.scan-result {
  border: 2px solid var(--primary-300); background: var(--primary-50);
  border-radius: var(--radius); padding: 16px;
}
[data-theme="dark"] .scan-result { background: var(--primary-900); }

/* চার্ট (CSS বার) */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 170px; padding-top: 8px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; height: 100%; }
.bars .bar .fill {
  width: 100%; max-width: 46px; background: linear-gradient(180deg, var(--primary-400), var(--primary-700));
  border-radius: 7px 7px 3px 3px; min-height: 4px; transition: height .5s ease;
}
.bars .bar .cap { font-size: 11px; color: var(--muted); white-space: nowrap; }
.bars .bar .amt { font-size: 11.5px; font-weight: 700; }

/* ট্যাব (সেটিংস) */
.tabs { display: flex; gap: 6px; overflow-x: auto; border-bottom: 1px solid var(--border); margin-bottom: 18px; padding-bottom: 2px; }
.tabs button {
  border: 0; background: none; font-family: inherit; font-size: 14px; font-weight: 600;
  color: var(--muted); padding: 10px 14px; cursor: pointer; border-bottom: 2.5px solid transparent;
  white-space: nowrap;
}
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn .2s ease; }

/* পারমিশন ম্যাট্রিক্স */
.perm-group { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; }
.perm-group h4 { padding: 12px 15px; background: var(--surface-2); margin: 0; border-bottom: 1px solid var(--border); }
.perm-list { display: flex; flex-wrap: wrap; gap: 8px 14px; padding: 14px 15px; }
.perm-list label { display: flex; align-items: center; gap: 7px; font-size: 13.5px; cursor: pointer; }
.perm-list input { width: 17px; height: 17px; accent-color: var(--primary); }

/* ড্রয়ার (স্টেটমেন্ট ইত্যাদি) */
.drawer-right {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%);
  background: var(--surface); box-shadow: var(--shadow-lg); z-index: 110;
  transform: translateX(105%); transition: transform .28s ease; overflow-y: auto;
}
.drawer-right.open { transform: none; }
.drawer-backdrop { position: fixed; inset: 0; background: rgba(6,28,29,.45); z-index: 105; display: none; }
.drawer-backdrop.open { display: block; }

/* কিউ টেবিল (বিল তৈরি) */
.queue-item {
  display: flex; gap: 10px; align-items: center; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 11px; margin-bottom: 8px; background: var(--surface-2);
}
.queue-item .imei { font-weight: 700; font-size: 14px; }
.queue-item .spacer { flex: 1; }

/* প্রিন্ট রসিদ */
.receipt { font-size: 13.5px; }
.receipt .r-head { text-align: center; border-bottom: 2px dashed var(--border-strong); padding-bottom: 10px; margin-bottom: 10px; }
.receipt table { width: 100%; border-collapse: collapse; }
.receipt td { padding: 5px 4px; border-bottom: 1px dotted var(--border); }
.receipt .tot { font-weight: 800; font-size: 15px; border-top: 2px solid var(--text); padding-top: 8px; }

/* ======================= মোবাইল / রেসপন্সিভ ======================= */
.bottom-nav { display: none; }

@media (max-width: 1100px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-total { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; }
  .hamburger { display: block; }
  .content { padding: 15px 14px 70px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  #sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(6,28,29,.5); z-index: 55; display: none;
  }
  #sidebar-backdrop.open { display: block; }

  /* নিচে দ্রুত নেভিগেশন */
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: var(--surface); border-top: 1px solid var(--border);
    box-shadow: 0 -4px 18px rgba(10,52,54,.10); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    font-size: 10.5px; color: var(--muted); font-weight: 600; padding: 4px 2px;
  }
  .bottom-nav a svg { width: 21px; height: 21px; }
  .bottom-nav a.active { color: var(--primary); }
  #toasts { left: 14px; right: 14px; bottom: 76px; max-width: none; }
}
@media (max-width: 700px) {
  .g-2, .g-3, .g-4 { grid-template-columns: 1fr; }
  .g-total { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  h1 { font-size: 20px; }

  /* টেবিল → স্ট্যাকড কার্ড */
  .tbl.stack thead { display: none; }
  .tbl.stack, .tbl.stack tbody, .tbl.stack tr, .tbl.stack td { display: block; width: 100%; }
  .tbl.stack tr {
    border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px;
    padding: 6px 4px; background: var(--surface);
  }
  .tbl.stack td {
    display: flex; justify-content: space-between; gap: 14px;
    border-bottom: 1px dotted var(--border); padding: 7px 11px; text-align: right;
  }
  .tbl.stack td:last-child { border-bottom: 0; }
  .tbl.stack td::before {
    content: attr(data-label); font-size: 12px; color: var(--muted);
    font-weight: 600; text-align: left; flex: 0 0 auto;
  }
  .filters input, .filters select, .filters .search { width: 100%; min-width: 0; }
  .modal { max-height: 96vh; }
}

@media print {
  .sidebar, .topbar, .bottom-nav, .no-print, #toasts { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; }
  body { background: #fff; }
  .card { border: 0; box-shadow: none; }
}

/* ======================= ক্যামেরা স্ক্যান মডিউল ======================= */
.modal.scan-modal { max-width: 460px; }
.scan-modal-body { padding: 14px 16px 18px; }

.scan-stage {
  position: relative; width: 100%; aspect-ratio: 4 / 3;
  background: #0B1D1E; border-radius: 14px; overflow: hidden;
  display: grid; place-items: center;
}
.scan-stage video {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.scan-off {
  position: absolute; inset: 0; display: grid; place-content: center;
  text-align: center; color: #9FC0BE; padding: 20px; gap: 8px;
}
.scan-off .big { font-size: 40px; }
.scan-off p { margin: 0; font-size: 13px; line-height: 1.6; }

.scan-frame {
  position: absolute; inset: 14%; pointer-events: none;
}
.scan-frame i {
  position: absolute; width: 26px; height: 26px;
  border: 3px solid #2DD4BF; border-radius: 5px;
}
.scan-frame .tl { top: 0; left: 0; border-right: 0; border-bottom: 0; }
.scan-frame .tr { top: 0; right: 0; border-left: 0; border-bottom: 0; }
.scan-frame .bl { bottom: 0; left: 0; border-right: 0; border-top: 0; }
.scan-frame .br { bottom: 0; right: 0; border-left: 0; border-top: 0; }
.scan-laser {
  position: absolute; left: 4%; right: 4%; height: 2px;
  background: linear-gradient(90deg, transparent, #2DD4BF, transparent);
  box-shadow: 0 0 12px rgba(45, 212, 191, .9);
  animation: scanMove 2.1s ease-in-out infinite;
}
@keyframes scanMove {
  0%, 100% { top: 6%; }
  50%      { top: 92%; }
}

.scan-status {
  margin-top: 11px; padding: 9px 13px; border-radius: 10px;
  background: var(--surface-2); color: var(--muted);
  font-size: 13px; font-weight: 600; text-align: center;
}
.scan-status.ok  { background: var(--success-bg); color: var(--success); }
.scan-status.err { background: var(--danger-bg);  color: var(--danger); }

.scan-manual { display: flex; gap: 8px; margin-top: 11px; }
.scan-manual input { flex: 1; }
.scan-manual .btn { white-space: nowrap; }

.scan-tools { display: flex; gap: 8px; margin-top: 10px; }
.scan-tools .btn { flex: 1; font-size: 12.5px; padding: 9px 8px; }

.hint.center { text-align: center; }

/* ছোট পর্দায় মডিউল পুরো স্ক্রিনে */
@media (max-width: 520px) {
  .modal.scan-modal { max-width: 100%; }
  .scan-tools { flex-direction: column; }
}

/* ======================= স্ক্যান বাটন ======================= */
.btn-scan {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--primary-600); background: var(--primary-50, #E6F6F4);
  color: var(--primary-700, #0B5C58); font-weight: 700;
  border-radius: 10px; padding: 9px 13px; cursor: pointer; font-size: 13px;
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn-scan:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-scan:active { transform: none; }
.btn-scan svg { width: 17px; height: 17px; }

/* সার্চ বক্সের পাশে ক্যামেরা বাটন */
.search-wrap { position: relative; display: flex; align-items: center; gap: 8px; }
.search-wrap .btn-scan { flex: none; }

/* স্ক্যান ফ্লোটিং বাটন (সব পেইজে) */
.scan-fab {
  position: fixed; right: 16px; bottom: 88px; z-index: 45;
  width: 54px; height: 54px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
  color: #fff; border: 0; cursor: pointer;
  display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(10, 52, 54, .32);
}
.scan-fab svg { width: 24px; height: 24px; }
.scan-fab:active { transform: scale(.94); }
@media (min-width: 901px) { .scan-fab { bottom: 24px; right: 24px; } }
@media (max-width: 900px) { .scan-fab { bottom: 84px; } }

/* স্ক্যান ফলাফলের অ্যাকশন শিট */
.scan-code-box {
  text-align: center; font-size: 20px; font-weight: 700; letter-spacing: 2px;
  color: var(--primary-700, #0B5C58); background: var(--primary-50, #E6F6F4);
  border: 1px dashed var(--primary-600); border-radius: 12px;
  padding: 16px 12px; margin-bottom: 14px; word-break: break-all;
}
.scan-actions { display: flex; flex-direction: column; gap: 9px; }
.scan-actions .btn { width: 100%; justify-content: center; padding: 11px; }

/*
   ============================================================================
   মোবাইল রেসপন্সিভ লেয়ার (360–430px) — ফোনে ঠিকভাবে দেখানোর জন্য
   ============================================================================ */

/* --- যা ছিল না, এখন যোগ হলো --- */
.d-inline { display: inline-flex; }
input[type="checkbox"], input[type="radio"] { width: auto; }
.tbl thead th { top: var(--topbar-h); }
.tabs { scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }

@media (max-width: 700px) {
  /* ঘর ও প্যাডিং — ছোট স্ক্রিনে বেশি জায়গা খালি হচ্ছিল */
  body { overflow-x: hidden; }
  .content { padding: 12px 12px 96px; }
  .card { padding: 13px; border-radius: 12px; margin-bottom: 12px; }
  .field { margin-bottom: 10px; }
  .grid { gap: 12px; }

  /* --- টপবার: লম্বা শিরোনাম যাতে পেজ ওভারফ্লো না করে --- */
  .topbar { padding: 0 10px; gap: 8px; }
  .topbar .page-title {
    font-size: 15px; min-width: 0; flex: 1 1 auto;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .topbar .spacer { display: none; }
  #sync-chip { font-size: 10px; padding: 2px 6px; }
  #sync-chip svg { width: 12px; height: 12px; }
  .icon-btn { width: 40px; height: 40px; }
  .hamburger { padding: 10px; }

  /* --- কার্ড-হেড: শিরোনাম নিজের লাইনে, বাটনগুলো পাশাপাশি --- */
  .card-head { gap: 8px; }
  .card-head h2, .card-head h3 {
    font-size: 15.5px; line-height: 1.35; flex: 1 1 100%;
  }
  .card-head .spacer { display: none; }
  .card-head .btn { flex: 1 1 auto; justify-content: center; }
  .card-head .badge { flex: 0 0 auto; }

  /* --- বাটন: টাচ টার্গেট বড় করা --- */
  .btn { padding: 10px 12px; font-size: 13.5px; }
  .btn.sm { padding: 8px 10px; font-size: 12.5px; min-height: 36px; }
  .btn-icon { width: 40px; height: 40px; }

  /* --- ফর্ম: iOS জুম-ইন এড়ানো + ফিল্টার --- */
  input, select, textarea { font-size: 16px; padding: 10px 11px; }
  .filters { gap: 7px; }
  .filters .btn { width: 100%; }
  .filters .btn-scan { width: 100%; justify-content: center; }
  .search-wrap { flex-wrap: nowrap; }
  .search-wrap .search { flex: 1; min-width: 0; }

  /* --- টেবিল: কার্ড মোড ঠিক করা --- */
  .tbl.stack td { min-width: 0; }
  .tbl.stack td::before { max-width: 45%; }
  .tbl.stack td > * { min-width: 0; overflow-wrap: anywhere; }
  .tbl.stack td.text-center { justify-content: center; }
  .tbl.stack td.text-center::before { display: none; }
  .tbl.stack td .btn.sm { padding: 6px 8px; }
  .tbl:not(.stack) tbody td { padding: 7px 4px; font-size: 13px; }
  .tbl.stack td .badge { font-size: 10.5px; padding: 2px 7px; }

  /* --- মডাল: নিচের শিট (bottom sheet) --- */
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal {
    width: 100%; max-width: 100%; max-height: 94dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .modal-head { padding: 12px 14px; }
  .modal-head h3 {
    min-width: 0; font-size: 15px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .modal-body { padding: 14px; }
  .modal-foot { flex-wrap: wrap; padding: 10px 12px; gap: 8px; }
  .modal-foot .btn { flex: 1 1 28%; }
  /* স্ক্যান মডিউলের ✕ বাটন সাদা হয়ে যাচ্ছিল */
  .modal .icon-btn {
    background: var(--surface-2); color: var(--text);
    width: 40px; height: 40px; flex: none;
  }

  /* --- ড্রয়ার: পুরো স্ক্রিন --- */
  .drawer-right { width: 100%; border-left: 0; }
  .drawer-right .modal-head { border-radius: 0; padding: 12px 14px; }
  .drawer-right .card table td { padding: 6px 4px; font-size: 13px; }
  .drawer-right .grid.g-4 { grid-template-columns: repeat(2, 1fr); }

  /* --- চার্ট, খালি অবস্থা, বার --- */
  .bars { gap: 4px; height: 140px; }
  .bars .bar .cap { font-size: 9px; letter-spacing: -.2px; }
  .bars .bar .amt { font-size: 9.5px; }
  .empty { padding: 26px 10px; }
  .empty .big { font-size: 32px; }

  /* --- অফলাইন বার ও পারমিশন তালিকা --- */
  #offline-bar { font-size: 11.5px; padding: 6px 10px; line-height: 1.45; }
  .perm-list { gap: 6px 10px; padding: 12px; }
  .perm-list label { min-width: 100px !important; }

  /* --- স্ক্যান --- */
  .scan-fab { bottom: 76px; right: 12px; width: 48px; height: 48px; }
  .scan-code-box { font-size: 16px; letter-spacing: 1px; padding: 12px 8px; }
  .scan-manual { flex-wrap: wrap; }
  .scan-manual input { flex: 1 1 100%; }
  .scan-manual .btn { width: 100%; }
  .scan-status { font-size: 12px; }
  .btn-scan { padding: 9px 10px; font-size: 12.5px; white-space: nowrap; }
}

@media (max-width: 430px) {
  .g-total { grid-template-columns: 1fr; }
  .stat .val { font-size: 18px; }
  .g-total .stat { padding: 10px; }
  .g-total .stat .ic { width: 34px; height: 34px; }
  .g-total .stat .ic svg { width: 18px; height: 18px; }
}

/* ===== মোবাইল: রিসিট টেবিল, ক্লোজিং কিউ ও প্রিন্ট পেজ ===== */
@media (max-width: 700px) {
  /* মডালের রিসিট টেবিলে ১৫ ডিজিটের IMEI — ছোট করে না ফেলে দেখানো */
  .receipt table { font-size: 11.5px; }
  .receipt td { padding: 4px 2px; }
  .receipt .mono { font-size: 10.5px; word-break: break-all; }
  .receipt td:first-child { width: 46%; }

  /* ক্লোজিংয়ের সেটেলমেন্ট তালিকা */
  .queue-item { flex-wrap: wrap; }
  .queue-item .badge { font-size: 10.5px; }

  /* প্রিন্ট পেজের টুলবার — ৩টি বাটন এক লাইনে না উঠে যায় */
  .toolbar h1 { font-size: 13px; }
  .tb { padding: 7px 10px; font-size: 12px; }
}

@media (max-width: 430px) {
  .toolbar h1 { flex: 0 0 100%; }
}

/* ======================= Expand / Collapse সিস্টেম ======================= */
.collapse-btn {
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--muted); cursor: pointer; border-radius: 8px;
  width: 30px; height: 30px; display: grid; place-items: center;
  flex: none; padding: 0; transition: transform .18s ease, background .15s;
}
.collapse-btn:hover { background: var(--surface-2); color: var(--text); }
.collapse-btn svg { width: 15px; height: 15px; transition: transform .22s ease; }
.collapse-btn[aria-expanded="false"] svg { transform: rotate(-90deg); }

/* ভাঙা অবস্থা */
.is-collapsed > *:not(.card-head):not(.search):not([data-collapse-btn]) { display: none !important; }
.filters.is-collapsed { padding-top: 2px; padding-bottom: 2px; }
.filters.is-collapsed > *:not(.search):not([data-collapse-btn]) { display: none !important; }
.card.is-collapsed { padding-bottom: 12px; }
.card.is-collapsed .card-head { margin-bottom: 0; border-bottom: 0; }

/* অ্যানিমেশন */
.card > .card-body-anim, .card > * { transition: opacity .15s ease; }

/* ======================= কনটেন্ট মাঝখানে, কাটা না যায় ======================= */
.content {
  max-width: 1400px; margin-inline: auto; padding-inline: clamp(10px, 2.2vw, 22px);
}
/* ফ্লেক্স/গ্রিডের ভেতরের আইটেম যাতে চেপে না যায় */
.content, .content * { min-width: 0; }
.grid > *, .card, .form-row > *, .form-row-3 > *, .filters > * { min-width: 0; }

/* লম্বা লেখা যাতে কাটা না যায় (IMEI, নোট, নাম) */
.tbl tbody td, .tbl thead th { overflow-wrap: anywhere; word-break: normal; }
.tbl .num { overflow-wrap: normal; }
.card p, .card li { overflow-wrap: anywhere; }

/* টেবিল ও কনটেন্ট যেন স্ক্রিনের বাইরে না যায় */
.table-wrap { max-width: 100%; }
.receipt, .pv, .scan-stage, .scan-code-box { max-width: 100%; }

/* সরু পর্দায় ফর্ম ও কার্ডের ভেতরের প্যাডিং */
@media (max-width: 700px) {
  .content { padding-inline: 10px; }
  .card-head .collapse-btn { width: 32px; height: 32px; }
}

/* ======================= টপবার: ইউজার মেনু ======================= */
.icon-btn.light {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border);
}
.icon-btn.light:hover { background: var(--primary-50, #E6F6F4); color: var(--primary-700, #0B5C58); }

.user-menu { position: relative; flex: none; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
  color: #fff; font-family: inherit; font-weight: 800; font-size: 14px;
  display: grid; place-items: center; text-transform: uppercase;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--primary-100, #CDEDE7);
  transition: transform .15s ease, box-shadow .15s ease;
}
.user-avatar:hover { transform: scale(1.06); }
.user-avatar[aria-expanded="true"] {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--primary-600);
}

.user-drop {
  position: absolute; right: 0; top: calc(100% + 10px); z-index: 70;
  min-width: 252px; max-width: calc(100vw - 24px);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-lg); padding: 6px;
  animation: popIn .16s cubic-bezier(.2, .9, .3, 1.2);
  transform-origin: top right;
}
.ud-head { padding: 10px 12px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.ud-name { font-weight: 800; font-size: 14px; line-height: 1.3; }
.ud-role { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.ud-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border: 0; background: none; border-radius: 10px;
  font: inherit; font-size: 13.5px; font-weight: 600; color: var(--text);
  cursor: pointer; text-align: left; text-decoration: none;
}
.ud-item:hover { background: var(--surface-2); }
.ud-item svg { width: 17px; height: 17px; flex: none; opacity: .7; }
.ud-danger { color: var(--danger); }
.ud-danger:hover { background: var(--danger-bg); }
.ud-form { margin: 0; }

/* মোবাইলে টপবার জায়গা বাঁচাতে সিঙ্ক-চিপের লেখা লুকানো */
@media (max-width: 700px) {
  .sync-txt { display: none; }
  #sync-chip { padding: 4px 6px; }
  /* ড্রপডাউন অ্যাভাটারের ডান প্রান্তেই থাকবে — বাইরে চলে যাবে না */
  .user-drop { right: 0; min-width: 232px; }
}

/* ======================= সেটিংস মেনু — ছোট কার্ড গ্রিড ======================= */
.set-menu {
  display: grid; gap: 11px; margin-bottom: 20px;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
}
.set-item { position: relative; display: flex; }
.set-card {
  flex: 1; display: flex; align-items: center; gap: 11px; text-align: left;
  padding: 12px 13px; border-radius: 14px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm); font: inherit; color: var(--text);
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
  min-width: 0; width: 100%;
}
.set-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--primary-600); }
.set-card:focus-visible { outline: 2px solid var(--primary-600); outline-offset: 2px; }
.set-card .sc-ic {
  width: 38px; height: 38px; border-radius: 12px; flex: none;
  display: grid; place-items: center; font-size: 19px;
  background: var(--primary-50, #E6F6F4); color: var(--primary-700, #0B5C58);
}
.set-card .sc-tx { min-width: 0; }
.set-card .sc-t { font-size: 13.5px; font-weight: 800; display: block; line-height: 1.3; }
.set-card .sc-d {
  font-size: 11px; color: var(--muted); display: block; margin-top: 2px;
  line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.set-card.active {
  border-color: var(--primary-600);
  background: var(--primary-50, #E6F6F4);
  box-shadow: 0 0 0 1px var(--primary-600), var(--shadow-sm);
}
.set-card.active .sc-ic { background: var(--primary-600); color: #fff; }
/* কার্ডের ভেতরে "সংশ্লিষ্ট পেজ →" লিংক */
.sc-link {
  position: absolute; right: 9px; bottom: 7px; font-size: 10.5px; font-weight: 700;
  color: var(--primary-600); text-decoration: none; padding: 2px 5px; border-radius: 6px;
  background: var(--surface-2); white-space: nowrap;
}
.sc-link:hover { background: var(--primary-50, #E6F6F4); color: var(--primary-700, #0B5C58); }

/* অ্যাক্টিভ সেকশনে স্ক্রল করলে একটু হাইলাইট */
.tab-panel.flash > .card { animation: panelFlash .9s ease; }
@keyframes panelFlash {
  0%   { box-shadow: 0 0 0 0 rgba(13, 148, 136, 0); }
  25%  { box-shadow: 0 0 0 3px rgba(13, 148, 136, .35); }
  100% { box-shadow: 0 0 0 0 rgba(13, 148, 136, 0); }
}

@media (max-width: 700px) {
  .set-menu { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .set-card { padding: 10px 11px; gap: 9px; }
  .set-card .sc-ic { width: 34px; height: 34px; font-size: 17px; }
  .set-card .sc-t { font-size: 12.5px; }
  .set-card .sc-d { display: none; }
}
