:root {
  --green: #0f9d58;
  --green-dark: #0b7a44;
  --blue: #2b4a8b;
  --blue-light: #a9c6f2;
  --yellow: #ffe600;
  --bg: #f2f4f7;
  --card: #ffffff;
  --text: #1c2431;
  --muted: #6b7583;
  --line: #e3e7ee;
  --danger: #d64545;
  --shadow: 0 2px 10px rgba(20, 30, 50, .08);
}

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

/* hidden অ্যাট্রিবিউট সবসময় কাজ করবে — display:flex/grid একে হারাতে পারবে না */
[hidden] { display: none !important; }

/* দর্শকের জন্য: টেক্সট সিলেক্ট ও লং-প্রেস মেনু বন্ধ (ইনপুট বাদে) */
body.noselect { -webkit-user-select: none; -ms-user-select: none; user-select: none; -webkit-touch-callout: none; }
body.noselect input, body.noselect textarea { -webkit-user-select: text; user-select: text; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans Bengali", "SolaimanLipi", "Nirmala UI", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

/* ---------- App bar ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  color: #fff;
  padding: 12px 14px;
  padding-top: calc(12px + env(safe-area-inset-top));
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.app-logo { width: 40px; height: 40px; flex: none; display: block; }
.appbar-title { font-size: 19px; margin: 0; font-weight: 700; flex: 1; }
.appbar-actions { display: flex; align-items: center; gap: 8px; }
.iconbtn {
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  width: 38px; height: 38px;
  border-radius: 10px;
  font-size: 20px;
  cursor: pointer;
  display: grid; place-items: center;
}
.iconbtn:active { background: rgba(255,255,255,.3); }
.sync-dot { width: 11px; height: 11px; border-radius: 50%; background: #cfd8e3; display: inline-block; }
.sync-dot.local { background: #f0ad4e; }
.sync-dot.cloud { background: #7ef08a; box-shadow: 0 0 6px #7ef08a; }

/* ---------- Layout ---------- */
main { padding: 12px; padding-bottom: 96px; max-width: 720px; margin: 0 auto; }
/* টেবিল/রিপোর্ট ভিউতে বড় স্ক্রিনে পুরো চওড়া (সব মাস একসাথে দেখা যায়) */
main.wide { max-width: 1180px; }

.section-title { font-size: 13px; color: var(--muted); margin: 12px 4px 6px; font-weight: 600; }

/* ---------- Home title ---------- */
.home-title { text-align: center; margin: 0 0 10px; }
.home-title h2 { margin: 0; font-size: 16.5px; font-weight: 800; color: var(--green-dark); line-height: 1.3; }
.home-title p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }

/* ---------- Summary cards ---------- */
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat {
  background: var(--card);
  border-radius: 13px;
  padding: 11px 14px;
  box-shadow: var(--shadow);
}
.stat.big { grid-column: 1 / -1; background: linear-gradient(135deg, var(--blue), #35509c); color: #fff; }
.stat .label { font-size: 12px; color: var(--muted); }
.stat.big .label { color: #d7e2ff; }
.stat .value { font-size: 21px; font-weight: 800; margin-top: 2px; }
.stat.big .value { font-size: 27px; }
.stat .unit { font-size: 13px; font-weight: 600; opacity: .8; }

/* ---------- Member list ---------- */
.list-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  background: #eaf1fd; border: 1px solid #cadcf7; border-radius: 10px;
  padding: 5px 12px; margin: 0 0 9px;
}
.list-count { font-size: 13px; color: var(--blue); font-weight: 800; }
.page-select { font-size: 12.5px; color: var(--text); font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.page-select select {
  border: 1.5px solid var(--green); border-radius: 8px; padding: 3px 9px;
  font-size: 13px; font-family: inherit; font-weight: 800;
  background: #eef8f0; color: var(--green-dark); cursor: pointer;
}
.page-select select:focus { outline: none; box-shadow: 0 0 0 3px rgba(15,157,88,.18); }
.member-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 640px) { .member-grid { grid-template-columns: 1fr 1fr; } }
.member-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border-radius: 12px;
  padding: 9px 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .08s ease;
}
.member-card:active { transform: scale(.985); }
.avatar {
  width: 38px; height: 38px; flex: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--green), var(--blue));
  color: #fff; font-weight: 700; font-size: 16px;
  display: grid; place-items: center;
}
.member-main { flex: 1; min-width: 0; }
.member-name { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-tags { margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 1px 8px; border-radius: 20px; }
.chip-ok { background: #dff5e3; color: #0b7a44; }
.chip-no { background: #fdeede; color: #b5721a; }
.chip-cancel { background: #f3d9d9; color: #b23a3a; }
.member-card.is-cancelled { opacity: .62; }
.member-total { text-align: right; flex: none; }
.member-total .amt { font-weight: 800; color: var(--green-dark); font-size: 15px; }
.member-total .cap { font-size: 10px; color: var(--muted); white-space: nowrap; }
.show-more { margin-top: 10px; border: 1px dashed var(--line); color: var(--muted); }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 50px 20px;
}
.empty .big-emoji { font-size: 48px; }

/* ---------- Search (3 boxes) ---------- */
.search3 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.search3 .full { grid-column: 1 / -1; }
/* বড় স্ক্রিনে তিনটাই এক লাইনে */
@media (min-width: 560px) {
  .search3 { grid-template-columns: repeat(3, 1fr); }
  .search3 .full { grid-column: auto; }
}
.search3 input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  box-shadow: var(--shadow);
}
.search3 input:focus { border-color: var(--green); }

/* ---------- Member detail ---------- */
.detail-head {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.detail-head h2 { margin: 0 0 8px; font-size: 20px; }
.kv { display: flex; font-size: 14px; padding: 3px 0; color: var(--text); }
.kv .k { color: var(--muted); width: 78px; flex: none; }
.detail-head .actions { display: flex; gap: 10px; margin-top: 12px; }
.btn {
  border: none; border-radius: 10px; padding: 10px 14px;
  font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
}
.btn.primary { background: var(--green); color: #fff; }
.btn.ghost { background: #eef1f6; color: var(--text); }
.btn.danger { background: #fde8e8; color: var(--danger); }
.btn.block { width: 100%; }

/* ---------- Month rows ---------- */
.month-list { display: flex; flex-direction: column; gap: 10px; }
.month-row {
  background: var(--card);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.month-row .mtop { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.month-row .mname { font-weight: 700; }
.month-row .mcount { font-weight: 400; font-size: 12px; color: var(--blue); margin-left: 6px;
  background: #eaf0fb; padding: 1px 8px; border-radius: 12px; }
.month-row .mamt { font-weight: 800; color: var(--green-dark); }
.month-row .mamt.zero { color: #c2c8d2; }

/* খোলা/বন্ধ বডি */
.month-body { display: none; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.month-row.open .month-body { display: block; }

/* সম্পাদনযোগ্য জমার সারি */
.entry-list { display: flex; flex-direction: column; gap: 8px; }
.entry { display: flex; gap: 8px; align-items: center; }
.entry input {
  min-width: 0;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px; font-size: 15px; font-family: inherit; outline: none;
}
.entry .e-date { flex: 1.3; }
.entry .e-amt { flex: 1; }
.entry input:focus { border-color: var(--green); }
.entry .e-del {
  flex: none; width: 38px; height: 40px;
  border: none; border-radius: 10px; cursor: pointer;
  background: #fde8e8; color: var(--danger); font-size: 16px;
}
.month-actions { display: flex; gap: 8px; margin-top: 10px; }
.btn.sm { padding: 8px 12px; font-size: 13px; flex: 1; }

/* view-only জমার তালিকা */
.entry-ro { display: flex; justify-content: space-between; padding: 7px 2px; border-bottom: 1px solid var(--line); font-size: 14px; }
.entry-ro:last-child { border-bottom: none; }
.entry-ro .ed { color: var(--muted); }
.entry-ro .ea { font-weight: 700; color: var(--green-dark); }
.entry-ro.none { color: var(--muted); justify-content: center; }

.member-total-banner {
  margin-top: 14px;
  background: linear-gradient(135deg, var(--blue), #35509c);
  color: #fff; border-radius: 14px; padding: 14px 16px;
  display: flex; justify-content: space-between; align-items: center;
}
.member-total-banner .amt { font-size: 24px; font-weight: 800; }

/* ---------- FAB ---------- */
.fab {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  width: 60px; height: 60px;
  border-radius: 50%;
  background: var(--green);
  color: #fff; border: none;
  font-size: 32px; line-height: 1;
  box-shadow: 0 6px 18px rgba(15,157,88,.45);
  cursor: pointer; z-index: 25;
}
.fab:active { transform: scale(.94); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(15,22,34,.5);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--card);
  width: 100%; max-width: 560px;
  border-radius: 20px 20px 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  max-height: 92vh; overflow-y: auto;
  animation: slideUp .22s ease;
}
/* বড় স্ক্রিনে (PC) ফর্ম নিচে না দিয়ে মাঝখানে দেখাও */
@media (min-width: 600px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 20px; max-height: 88vh; padding-bottom: 18px; }
}
@keyframes slideUp { from { transform: translateY(30px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
.modal h3 { margin: 0 0 14px; font-size: 18px; }
.pho-toggle {
  width: 100%; text-align: left; border: 1px dashed var(--line);
  background: #f6f8fb; color: var(--muted);
  border-radius: 10px; padding: 9px 12px; margin-bottom: 12px;
  font-size: 12.5px; font-family: inherit; cursor: pointer; font-weight: 600;
}
.pho-toggle.on { border-color: var(--green); background: #eef8f0; color: var(--green-dark); }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; font-size: 15px; font-family: inherit; outline: none;
}
.field input:focus { border-color: var(--green); }
.field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; font-size: 15px; font-family: inherit; outline: none; resize: vertical;
  line-height: 1.5;
}
.field textarea:focus { border-color: var(--green); }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.modal-actions { display: flex; gap: 10px; margin-top: 8px; }

.bulk-home { margin-bottom: 8px; padding: 9px 12px; border: 1px dashed var(--blue); color: var(--blue); background: #eef3fc; }

/* ---------- Settings ---------- */
.setting-card { background: var(--card); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px; }
.setting-card h3 { margin: 0 0 10px; font-size: 16px; }
.setting-card p { color: var(--muted); font-size: 13px; margin: 6px 0; line-height: 1.5; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.badge.on { background: #dff5e3; color: var(--green-dark); }
.badge.off { background: #fdeede; color: #b5721a; }

/* ---------- Report / Table view ---------- */
.report-open { margin-bottom: 14px; border: 1px dashed var(--green); color: var(--green-dark); background: #eef8f0; }
.report-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.report-hint { font-size: 12px; color: var(--muted); }
.report { background: var(--card); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); }
.report-title { text-align: center; margin-bottom: 12px; }
.report-title h2 { margin: 0; font-size: 18px; }
.report-title p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.report-title .rdate { font-size: 12px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.report-table { border-collapse: collapse; width: 100%; font-size: 12px; }
.report-table th, .report-table td { border: 1px solid #c9d2df; padding: 5px 7px; white-space: nowrap; }
.report-table thead th { background: var(--green); color: #fff; font-weight: 700; text-align: center; }
.report-table .name { white-space: normal; min-width: 130px; text-align: left; }
.report-table .name .sub { font-size: 10px; color: var(--muted); }
.report-table .num { text-align: right; }
.report-table .c { text-align: center; }
.report-table tbody tr:nth-child(even) { background: #f6f8fb; }
.report-table .tot { font-weight: 800; color: var(--green-dark); }
.report-table tfoot td { background: #eef3fc; font-weight: 800; border-top: 2px solid var(--green); }
.report-table sup { color: var(--blue); font-size: 9px; }
.report-table tbody tr.cancelled-row { background: #fbe6e6 !important; color: #9c3838; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.report-table tbody tr.cancelled-row .tot { color: #b23a3a; }
.tbl-cancel { display: inline-block; background: #f3d0d0; color: #a12b2b; font-size: 8.5px; font-weight: 700; padding: 0 4px; border-radius: 6px; }
.report-note { font-size: 11.5px; color: var(--muted); text-align: center; margin-top: 8px; }
.report-net { text-align: center; margin-top: 10px; font-size: 16px; font-weight: 700; color: var(--green-dark); background: #eef8f0; border: 1px solid #cdeccf; border-radius: 10px; padding: 8px 12px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.report-net b { font-size: 19px; }
.report-summary { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; margin-top: 14px; font-size: 14px; }
.empty-cell { text-align: center; color: var(--muted); padding: 20px; }
/* মোবাইলে কম্প্যাক্ট */
@media (max-width: 560px) {
  .report { padding: 10px; }
  .report-table { font-size: 10.5px; }
  .report-table th, .report-table td { padding: 3px 5px; }
  .report-table .name { min-width: 96px; }
  .report-table .name .sub { font-size: 9px; }
}

@media print {
  .appbar, .fab, .no-print, .report-bar { display: none !important; }
  html, body { background: #fff; }
  main { padding: 0 !important; max-width: none; }
  .report { box-shadow: none; border-radius: 0; padding: 0; }
  .table-scroll { overflow: visible; }
  .report-table { font-size: 9.5px; }
  .report-table th, .report-table td { padding: 3px 5px; }
  .report-table thead th, .report-table tfoot td, .report-table tbody tr:nth-child(even) {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  @page { size: A4 landscape; margin: 8mm; }
}

/* ---------- Home action buttons ---------- */
.home-actions { display: flex; gap: 8px; margin-bottom: 8px; }
.home-actions .btn { margin: 0; padding: 9px 12px; }
.report-open { border: 1px dashed var(--green); color: var(--green-dark); background: #eef8f0; }
.acc-open { border: 1px dashed var(--blue); color: var(--blue); background: #eef3fc; }

/* ---------- Buttons extra ---------- */
.btn.warn { background: #fde7cf; color: #a3651a; }

/* ---------- Accounts / expenses ---------- */
.acc-summary { background: var(--card); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.acc-net { text-align: center; padding-bottom: 12px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.acc-net .label { font-size: 13px; color: var(--muted); }
.acc-net .value { font-size: 30px; font-weight: 800; color: var(--green-dark); }
.acc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.acc-item { display: flex; justify-content: space-between; background: #f6f8fb; border-radius: 10px; padding: 9px 12px; font-size: 14px; }
.acc-item b { font-weight: 800; }
.acc-item.minus b { color: var(--danger); }

/* তিনটি আলাদা রঙের প্যানেল */
.acc-panel { border-radius: 14px; padding: 10px 14px 14px; margin-bottom: 14px; border: 1px solid; }
.acc-panel .section-title { margin-top: 6px; font-weight: 700; }
.panel-exp { background: #fff5ec; border-color: #f6dcc2; }
.panel-exp .section-title { color: #a3651a; }
.panel-refund { background: #fdeef1; border-color: #f4d2d9; }
.panel-refund .section-title { color: #b23a3a; }
.panel-docs { background: #eef3fb; border-color: #d6e2f5; }
.panel-docs .section-title { color: var(--blue); }

.exp-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.exp-row { background: var(--card); border-radius: 12px; padding: 11px 14px; box-shadow: var(--shadow); }
.exp-head { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.exp-body { display: none; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.exp-row.open .exp-body { display: block; }
.exp-main { flex: 1; min-width: 0; }
.exp-title { font-weight: 700; }
.exp-date { font-size: 12px; color: var(--muted); }
.exp-amt { font-weight: 800; color: var(--danger); white-space: nowrap; }
.exp-edit, .exp-del { border: none; background: #eef1f6; width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.exp-del { background: #fde8e8; color: var(--danger); }

/* ---------- Cancel / refund ---------- */
.cancel-calc { background: #f6f8fb; border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }
.cancel-calc div { display: flex; justify-content: space-between; padding: 3px 0; }
.cancel-calc .muted { color: var(--muted); }
.cancel-banner { background: #fbeaea; border: 1px solid #f0cccc; color: #9c3838; border-radius: 12px; padding: 10px 12px; margin: 10px 0; font-size: 13.5px; line-height: 1.5; }
.cancel-banner .cn-note { color: #7a4a4a; margin-top: 3px; }
.detail-head.dim h2 { color: var(--muted); }

/* ---------- Documents / receipts ---------- */
.doc-list { display: flex; flex-direction: column; gap: 7px; }
.doc-item { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.doc-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); }
.doc-ic { font-size: 18px; flex: none; }
.doc-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-del { flex: none; border: none; background: #fde8e8; color: var(--danger); width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.doc-empty { color: var(--muted); font-size: 13px; padding: 8px 2px; }
.doc-upload { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.doc-title-in { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; font-size: 14px; font-family: inherit; outline: none; }
.doc-title-in:focus { border-color: var(--green); }
.doc-pick { flex: none; white-space: nowrap; cursor: pointer; }
.doc-hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.month-doc-title { font-size: 12px; font-weight: 700; color: var(--blue); margin: 12px 0 6px; padding-top: 10px; border-top: 1px dashed var(--line); }

/* ---------- Login gate ---------- */
.gate { min-height: 62vh; display: grid; place-items: center; padding: 20px; }
.gate-card {
  background: var(--card); border-radius: 18px; padding: 30px 22px;
  box-shadow: var(--shadow); text-align: center; max-width: 360px; width: 100%;
}
.gate-icon { font-size: 46px; }
.gate-logo { width: 120px; height: 120px; display: block; margin: 0 auto; }
.gate-card h2 { margin: 10px 0 4px; font-size: 20px; }
.gate-card p { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.gate-card input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 13px; font-size: 15px; font-family: inherit; outline: none;
  text-align: center; margin-bottom: 12px;
}
.gate-card input:focus { border-color: var(--green); }
.gate-err { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 8px; }
.gate-alt { display: inline-block; margin-top: 14px; color: var(--blue); font-size: 13.5px; font-weight: 600; cursor: pointer; text-decoration: underline; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: calc(90px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  background: #1c2431; color: #fff;
  padding: 10px 18px; border-radius: 24px;
  font-size: 14px; z-index: 60;
  box-shadow: 0 4px 14px rgba(0,0,0,.3);
}
