/* TS এজেন্ট হিসাব — মূল স্টাইল */
:root {
  --bg: #f3f5f8;
  --card: #ffffff;
  --ink: #18212f;
  --muted: #6b7686;
  --line: #e3e7ee;
  --side: #0f2a3d;
  --side-ink: #c9d6e2;
  --brand: #0e7c6b;
  --brand-dk: #0a6656;
  --brand-lt: #e3f4f0;
  --gold: #e8a33a;
  --danger: #d0443a;
  --danger-lt: #fdecea;
  --warn: #b7791f;
  --warn-lt: #fff6e5;
  --ok: #18865b;
  --ok-lt: #e6f6ee;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Hind Siliguri', 'SolaimanLipi', system-ui, sans-serif;
  font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg);
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.3; }
h3 { font-size: 17px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
small, .small { font-size: 13px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.mono { font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace; letter-spacing: .02em; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 14px; } .mb { margin-bottom: 14px; }
.pos { color: var(--ok); } .neg { color: var(--danger); }
.ok { color: var(--ok); } .bad { color: var(--danger); }

/* ---------- লেআউট ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; flex-shrink: 0; background: var(--side); color: var(--side-ink);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand b { display: block; color: #fff; font-size: 16px; }
.brand small { color: #8fa6ba; font-size: 12px; }
.logo-mark {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), #14a38c); color: #fff; font-weight: 700; font-size: 20px; flex-shrink: 0;
}
.sidebar nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.sidebar nav a {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 9px;
  color: var(--side-ink); font-weight: 500; margin-bottom: 2px;
}
.sidebar nav a svg { width: 19px; height: 19px; opacity: .8; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.sidebar nav a.on { background: var(--brand); color: #fff; }
.side-foot { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.07); font-size: 13px; }
.side-foot .who { color: #fff; font-weight: 500; }
.side-foot .logout { color: #f5b4ad; }
.side-foot .ver { color: #6d8597; margin-top: 4px; font-size: 12px; }

.main { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 14px 26px; background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 19px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-search input { width: 260px; }
.menu-btn { display: none; background: none; border: 0; padding: 6px; cursor: pointer; }
.menu-btn span { display: block; width: 22px; height: 2px; background: var(--ink); margin: 4px 0; border-radius: 2px; }
.content { padding: 22px 26px 90px; max-width: 1400px; }
.overlay { display: none; }

/* ---------- কার্ড ও গ্রিড ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.grid-2 > .card, .stack > .card { margin-bottom: 0; }
.grid-2 + .grid-2, .grid-2 + .card, .card + .grid-2 { margin-top: 18px; }
.stack { display: grid; gap: 18px; }
.link { font-size: 14px; font-weight: 500; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 18px; box-shadow: var(--shadow); }
.stat span { color: var(--muted); font-size: 13px; display: block; }
.stat b { font-size: 24px; display: block; margin: 2px 0; font-weight: 700; letter-spacing: -.01em; }
.stat small { color: var(--muted); }
.stat.accent { background: linear-gradient(135deg, var(--side), #17405c); border: 0; color: #fff; }
.stat.accent span, .stat.accent small { color: #a9c0d3; }
.quick { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }

/* ---------- ফর্ম ---------- */
input, select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid #cfd6e0; border-radius: 8px;
  padding: 8px 11px; width: 100%; min-height: 38px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(14,124,107,.15); }
label { display: flex; flex-direction: column; gap: 5px; font-weight: 500; font-size: 14px; }
.form-grid { display: grid; gap: 14px; }
.form-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.span-2 { grid-column: span 2; } .span-3 { grid-column: 1 / -1; }
.section-label { color: var(--brand); font-size: 14px; margin-top: 6px; }
.filters { display: flex; gap: 8px; align-items: center; }
.filters.wrap { flex-wrap: wrap; }
.filters input, .filters select { width: auto; min-width: 150px; }
.inline-lbl { flex-direction: row; align-items: center; gap: 6px; font-weight: 400; color: var(--muted); }
.row-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-form input { width: auto; flex: 1; min-width: 120px; }
.row-form .grow { flex: 2; }
.row-form select { width: auto; }
.w-num { max-width: 70px; flex: 0 0 70px !important; min-width: 0 !important; }
.w-code { max-width: 56px; flex: 0 0 56px !important; min-width: 0 !important; text-align: center; text-transform: uppercase; font-weight: 600; }
.chk { flex-direction: row; align-items: center; gap: 5px; font-weight: 400; white-space: nowrap; }
.chk input { width: auto; min-height: 0; }
.inline { display: inline; }

/* ---------- বাটন ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 500;
  padding: 8px 15px; border-radius: 8px; border: 1px solid #cfd6e0; background: #fff; color: var(--ink);
  cursor: pointer; white-space: nowrap; min-height: 38px; text-decoration: none !important;
}
.btn:hover { background: #f4f6f9; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dk); }
.btn-danger { color: var(--danger); border-color: #f0c4bf; }
.btn-danger:hover { background: var(--danger-lt); }
.btn-sm { padding: 6px 12px; min-height: 34px; font-size: 14px; }
.btn-xs { padding: 3px 9px; min-height: 28px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- টেবিল ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; background: #f8fafc; }
.tbl th, .tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:hover { background: #fafbfd; }
.tbl.compact th, .tbl.compact td { padding: 6px 8px; }
.tbl .r { text-align: right; } .tbl .c { text-align: center; }
.tbl tr.dim td { opacity: .6; }
.tbl tfoot td { font-weight: 500; }
.tbl .empty, .empty { text-align: center; color: var(--muted); padding: 22px; }
.files-cell { max-width: 280px; word-break: break-word; }
.rate-grid th:first-child { min-width: 160px; }
.rate-grid tbody th { color: var(--ink); background: #fff; }
.rate-in { width: 100px; text-align: right; min-height: 34px; padding: 5px 8px; }
.rate-in.manual { background: #fffbea; border-color: var(--gold); }
.sumline { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; padding: 12px 0; color: var(--muted); font-size: 14px; }
.sumline b { color: var(--ink); }
.pager { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 14px; }
.pager a { padding: 4px 11px; border: 1px solid var(--line); border-radius: 6px; }
.pager a.on { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- ব্যাজ ---------- */
.pill { display: inline-block; padding: 1px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 500; }
.pill-ok { background: var(--ok-lt); color: var(--ok); }
.pill-off { background: #eef0f3; color: var(--muted); }
.pill-warn { background: var(--warn-lt); color: var(--warn); }
.tag { display: inline-block; font-size: 11.5px; padding: 0 7px; border-radius: 5px; background: #eef0f3; color: var(--muted); vertical-align: middle; }
.due { font-weight: 600; white-space: nowrap; }
.due-pos { color: var(--danger); } .due-neg { color: var(--ok); } .due-zero { color: var(--muted); font-weight: 500; }
.code { display: inline-block; font-size: 11px; font-weight: 700; background: var(--brand-lt); color: var(--brand); border-radius: 4px; padding: 0 5px; }

/* ---------- অ্যালার্ট ও টোস্ট ---------- */
.alert { padding: 11px 15px; border-radius: 9px; margin-bottom: 14px; border: 1px solid transparent; }
.alert-success { background: var(--ok-lt); color: #11603f; border-color: #bfe5d2; }
.alert-danger { background: var(--danger-lt); color: #9b2b23; border-color: #f3c6c1; }
.alert-warning { background: var(--warn-lt); color: #8a5a12; border-color: #f2dcb0; }
.alert.small { padding: 8px 12px; font-size: 13.5px; }
.toast-wrap { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 100; max-width: 380px; }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.18); font-size: 14px; transition: opacity .4s, transform .4s; }
.toast-success { background: var(--ok); } .toast-error { background: var(--danger); } .toast-warn { background: var(--warn); }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---------- ড্যাশবোর্ড তালিকা ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list li a { display: flex; flex-direction: column; color: var(--ink); min-width: 0; }
.list li a span { color: var(--muted); font-size: 13px; }
.list li em { font-style: normal; font-weight: 600; white-space: nowrap; }

/* ---------- এজেন্ট পেজ ---------- */
.agent-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.agent-head h2 { font-size: 22px; display: flex; align-items: center; gap: 10px; }
.agent-head p { margin: 4px 0 0; }

/* ---------- নতুন বিল ---------- */
.input-panels { margin-bottom: 18px; }
.dropzone {
  border: 2px dashed #b9c4d2; border-radius: 12px; padding: 30px 20px; text-align: center; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--muted); font-weight: 400; transition: .15s;
  min-height: 210px; justify-content: center;
}
.dropzone svg { width: 40px; height: 40px; color: var(--brand); }
.dropzone b { color: var(--ink); font-weight: 600; }
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-lt); }
.agent-hint { align-self: end; padding-bottom: 9px; font-size: 14px; }
.bill-card h3 { font-size: 16px; }
.bill-card .row-form label { flex-direction: row; white-space: nowrap; color: var(--muted); }
.bill-card td small { display: block; }
.row-warn td { background: #fffaf0; }
.row-bad td { background: #fdf0ee; }
.x { border: 0; background: none; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; padding: 2px 8px; border-radius: 6px; }
.x:hover { background: var(--danger-lt); color: var(--danger); }
.savebar {
  position: sticky; bottom: 14px; z-index: 15; display: flex; gap: 26px; align-items: center; justify-content: flex-end;
  background: var(--side); color: #fff; border-radius: 12px; padding: 12px 18px; box-shadow: 0 10px 30px rgba(15,42,61,.3);
}
.savebar[hidden] { display: none; }
.savebar span { display: block; font-size: 12px; color: #a9c0d3; }
.savebar b { font-size: 18px; }
.savebar .btn { min-width: 140px; }

/* ---------- ইনভয়েস / স্টেটমেন্ট ---------- */
.invoice { padding: 28px 30px; }
.inv-head { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 16px; border-bottom: 2px solid var(--ink); margin-bottom: 18px; }
.inv-head h2 { font-size: 22px; }
.inv-head p { margin: 4px 0 0; color: var(--muted); }
.inv-no { text-align: right; }
.inv-no span { display: block; color: var(--muted); font-size: 13px; }
.inv-no b { display: block; font-size: 20px; }
.inv-meta { display: flex; gap: 32px; flex-wrap: wrap; margin-bottom: 18px; }
.inv-meta div { display: flex; flex-direction: column; }
.inv-meta span { color: var(--muted); font-size: 13px; }
.inv-meta small { color: var(--muted); }
.inv-tbl tfoot .grp td { color: var(--muted); font-size: 13px; border-bottom: 0; padding-top: 4px; padding-bottom: 4px; }
.inv-tbl tfoot .total td { font-size: 17px; font-weight: 700; border-top: 2px solid var(--ink); border-bottom: 0; }
.inv-tbl tbody tr.grp td { background: #f8fafc; }
.inv-balance { display: flex; gap: 14px; margin-top: 18px; flex-wrap: wrap; }
.inv-balance div { flex: 1; min-width: 200px; background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.inv-balance span { display: block; color: var(--muted); font-size: 13px; }
.inv-balance b { font-size: 18px; }
.inv-foot { text-align: center; margin: 18px 0 0; }

/* ---------- লগইন / ইনস্টল ---------- */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 20% 10%, #16455f, var(--side) 60%); }
.auth-card { background: #fff; width: 100%; max-width: 380px; border-radius: 16px; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.3); display: grid; gap: 14px; }
.auth-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 6px; }
.auth-brand b { display: block; font-size: 18px; }
.auth-brand small { color: var(--muted); }
.code-box { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 8px; font-size: 12px; overflow-x: auto; }

/* ---------- রেসপন্সিভ ---------- */
@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr; }
  .form-grid.cols-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 820px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  body.menu-open .sidebar { transform: none; }
  body.menu-open .overlay { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; }
  .menu-btn { display: block; }
  .topbar { padding: 10px 16px; }
  .top-search { display: none; }
  .content { padding: 16px 16px 90px; }
  .form-grid.cols-2, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .filters { flex-wrap: wrap; }
  .filters input, .filters select { min-width: 0; flex: 1 1 140px; }
  .savebar { gap: 14px; flex-wrap: wrap; justify-content: space-between; }
  .invoice { padding: 18px 16px; }
  .inv-head { flex-direction: column; }
  .inv-no { text-align: left; }
}

/* ---------- প্রিন্ট ---------- */
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 13px; }
  .sidebar, .topbar, .no-print, .toast-wrap, .alert, .btn, .savebar { display: none !important; }
  .content { padding: 0; max-width: none; }
  .card { border: 0; box-shadow: none; padding: 0; }
  .invoice { padding: 0; }
  .inv-head { border-bottom-color: #000; }
  a { color: inherit; }
  .tbl th { background: #f2f2f2 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body > .app > .main > .content > *:not(.invoice) { display: none !important; }
}

/* ---------- v1.1 ---------- */
.logo-img { width: 40px; height: 40px; border-radius: 10px; background: #fff; object-fit: contain; padding: 3px; flex-shrink: 0; }
.manual-panel { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--line); }
.manual-panel[hidden] { display: none; }
#manualToggle.on { background: var(--brand-lt); border-color: var(--brand); color: var(--brand); }
.end { display: flex; align-items: flex-end; }
.agent-hint { font-weight: 400; min-height: 18px; }
.savebar .disc { flex-direction: column; gap: 2px; font-weight: 400; }
.savebar .disc span { color: #a9c0d3; }
.savebar .disc input { width: 120px; min-height: 34px; padding: 4px 8px; text-align: right; }
.bad-in { border-color: var(--danger) !important; background: var(--danger-lt) !important; }
.inv-scroll { overflow-x: auto; padding: 4px 0 20px; }
.inv-scroll .inv { box-shadow: 0 6px 30px rgba(16,24,40,.10); border-radius: 4px; overflow: hidden; }
.src-strip { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.chip { display: inline-block; padding: 3px 12px; border-radius: 99px; border: 1px solid var(--line); background: #fff; font-size: 13px; }
.btn.busy, .icon-btn.busy { opacity: .55; pointer-events: none; }
.icon-btn { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; min-height: 28px; font-size: 12.5px; border-radius: 7px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; font-family: inherit; text-decoration: none !important; }
.icon-btn:hover { border-color: var(--brand); color: var(--brand); }
.disc-tag { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }

/* মিশন × ক্যাটাগরি ম্যাট্রিক্স */
.period-tabs { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.period-tabs a { padding: 5px 13px; border-radius: 99px; border: 1px solid var(--line); color: var(--ink); font-size: 13.5px; text-decoration: none; }
.period-tabs a.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.matrix td, .matrix th { text-align: right; }
.matrix th:first-child, .matrix td:first-child { text-align: left; }
.matrix a.cell { display: block; color: var(--ink); text-decoration: none; border-radius: 6px; padding: 2px 4px; }
.matrix a.cell:hover { background: var(--brand-lt); }
.matrix a.cell b { display: block; font-size: 14.5px; }
.matrix a.cell small { color: var(--muted); }
.matrix .tot td, .matrix .tot th, .matrix td.tot { background: #f4f8f7; font-weight: 600; }
.matrix .empty-cell { color: #c3cad4; }
.mission-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.mission-cards a { display: block; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; color: var(--ink); text-decoration: none; background: #fff; }
.mission-cards a:hover { border-color: var(--brand); }
.mission-cards span { color: var(--muted); font-size: 13px; display: block; }
.mission-cards b { font-size: 18px; display: block; }
.mission-cards small { color: var(--muted); }
.bar-line { height: 6px; border-radius: 3px; background: #eef1f5; overflow: hidden; margin-top: 4px; min-width: 80px; }
.bar-line i { display: block; height: 100%; background: linear-gradient(90deg, #13995e, #1c6fa6); }
