:root {
  --sidebar-w: 240px;
  --sidebar-bg: #16332a;
  --sidebar-text: #bfd3c7;
  --sidebar-active: #245b45;
  --primary: #2d6a4f;
  --primary-hover: #1f4d38;
  --primary-soft: #e6f2ec;
  --gold: #c9a227;
  --topbar-h: 58px;

  --bg: #f3f5f4;
  --surface: #ffffff;
  --border: #e7ece9;
  --border-soft: #f1f4f2;
  --text: #1d2a23;
  --text-muted: #6b7a72;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 40, 28, .04), 0 2px 10px rgba(16, 40, 28, .05);
  --shadow-hover: 0 4px 22px rgba(16, 40, 28, .10);

  --bs-primary: #2d6a4f;
  --bs-primary-rgb: 45, 106, 79;
  --bs-link-color: #2d6a4f;
  --bs-link-hover-color: #1f4d38;
}

* { box-sizing: border-box; }
body {
  font-family: 'Inter', 'Hind Siliguri', system-ui, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
html[lang="bn"] body { font-family: 'Hind Siliguri', 'Inter', system-ui, sans-serif; }

/* Money columns line up */
.summary-card, table, .fs-3, .fs-4, .fs-5, .display-5 { font-variant-numeric: tabular-nums; }

.text-muted { color: var(--text-muted) !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ==================== LAYOUT ==================== */
#wrapper { display: flex; min-height: 100vh; }

#sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 200;
  transition: transform 0.25s cubic-bezier(.4,0,.2,1);
  overflow-y: auto;
}

#content-wrap {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-left 0.25s cubic-bezier(.4,0,.2,1);
}

/* Backdrop (mobile) */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 25, 18, 0.5);
  z-index: 150;
  cursor: pointer;
}

/* ==================== SIDEBAR ==================== */
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 20px 16px;
  color: #fff; font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.sidebar-brand i { color: var(--gold); font-size: 1.45rem; }

.sidebar-nav { list-style: none; padding: 12px 0; margin: 0; flex: 1; }

.sidebar-nav li a,
.sidebar-bottom a {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 18px;
  color: var(--sidebar-text);
  text-decoration: none; font-size: 0.9rem; font-weight: 500;
  transition: background 0.15s, color 0.15s;
  border-radius: 10px;
  margin: 2px 10px; min-height: 44px;
}
.sidebar-nav li a:hover, .sidebar-bottom a:hover {
  background: rgba(255,255,255,0.07); color: #fff;
}
.sidebar-nav li a.active {
  background: var(--sidebar-active); color: #fff; font-weight: 600;
}
.sidebar-nav li a.active::before {
  content: ''; position: absolute; left: -10px; top: 10px; bottom: 10px;
  width: 4px; border-radius: 0 4px 4px 0; background: var(--gold);
}
.sidebar-nav li a i, .sidebar-bottom a i { font-size: 1.1rem; width: 20px; text-align: center; }
.sidebar-bottom { padding: 10px 0; border-top: 1px solid rgba(255,255,255,0.08); flex-shrink: 0; }
.sidebar-logout { color: #ff9f9f !important; }

/* Collapsed (desktop) */
body.sidebar-collapsed #sidebar { transform: translateX(-100%); }
body.sidebar-collapsed #content-wrap { margin-left: 0; }

/* ==================== TOPBAR ==================== */
.topbar {
  height: var(--topbar-h);
  background: rgba(255,255,255,0.88);
  backdrop-filter: saturate(160%) blur(8px);
  -webkit-backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 14px; gap: 8px;
  position: sticky; top: 0; z-index: 100;
}
.topbar-title { font-weight: 600; font-size: 1.02rem; color: var(--text); letter-spacing: -.01em; }
.topbar-date { font-size: 0.8rem; color: var(--text-muted); }
.btn-topbar { color: #4a5a52; padding: 8px 10px; font-size: 1.3rem; line-height: 1; border: none; background: none; border-radius: 10px; }
.btn-topbar:hover { background: var(--border-soft); }
.btn-topbar-action { padding: 6px 10px; border: none; background: none; border-radius: 10px; font-size: 1.25rem; transition: background .15s, transform .15s; }
.btn-topbar-action:hover { background: var(--border-soft); transform: translateY(-1px); }
.lang-toggle { font-size: 0.78rem; font-weight: 700; padding: 5px 10px; border: 1px solid var(--border); border-radius: 8px; text-decoration: none; color: #4a5a52; background: var(--surface); }

.page-body { padding: 24px; flex: 1; max-width: 1400px; width: 100%; }

/* ==================== MOBILE ==================== */
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); }
  #content-wrap { margin-left: 0; }

  body.sidebar-open #sidebar { transform: translateX(0); box-shadow: 8px 0 30px rgba(0,0,0,.25); }
  body.sidebar-open .sidebar-backdrop { display: block; }

  .page-body { padding: 14px; }

  .topbar { padding: 0 8px; }
  .topbar-title { font-size: 0.95rem; }
}

/* ==================== SUMMARY CARDS ==================== */
.summary-card {
  border-radius: var(--radius); padding: 18px 20px; color: #fff;
  position: relative; overflow: hidden; min-height: 96px;
  box-shadow: 0 6px 20px rgba(16, 40, 28, .12);
}
.summary-card::after {
  content: ''; position: absolute; right: -30px; bottom: -40px;
  width: 130px; height: 130px; border-radius: 50%;
  background: rgba(255,255,255,0.10);
}
.summary-card .card-label {
  font-size: 0.72rem; opacity: 0.9; text-transform: uppercase;
  letter-spacing: 0.6px; margin-bottom: 6px; font-weight: 600;
}
.summary-card .card-value {
  font-size: clamp(1.1rem, 1.9vw, 1.55rem); font-weight: 700; line-height: 1.2; letter-spacing: -.01em;
  position: relative; z-index: 1; overflow-wrap: anywhere;
}
.summary-card .card-label { position: relative; z-index: 1; padding-right: 34px; }
.summary-card .card-sub { font-size: 0.78rem; opacity: 0.85; margin-top: 4px; }
.summary-card .card-icon {
  position: absolute; right: 16px; top: 14px; font-size: 1.8rem; opacity: 0.3;
}

@media (max-width: 576px) {
  .summary-card { padding: 14px 16px; min-height: 84px; }
  .summary-card .card-value { font-size: 1.2rem; }
  .summary-card .card-label { font-size: 0.68rem; }
}

.card-green  { background: linear-gradient(135deg, #245b45, #52b788); }
.card-red    { background: linear-gradient(135deg, #b83227, #e5604f); }
.card-blue   { background: linear-gradient(135deg, #1a5f8a, #3c9ad6); }
.card-gold   { background: linear-gradient(135deg, #8f740b, #cfa92c); }
.card-teal   { background: linear-gradient(135deg, #0c6464, #1aa3b3); }
.card-purple { background: linear-gradient(135deg, #5e2d78, #9b5cc0); }
.card-success-light { background: linear-gradient(135deg, #1a6b3a, #2fb36a); }
.card-danger-light  { background: linear-gradient(135deg, #7b241c, #c64236); }

/* ==================== APP CARD ==================== */
.app-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); background: var(--surface);
}
.app-card .card-header {
  background: var(--surface); border-bottom: 1px solid var(--border-soft);
  border-radius: var(--radius) var(--radius) 0 0 !important;
  font-weight: 600; font-size: 0.92rem; padding: 14px 18px;
}
.app-card > .table-responsive:last-child,
.app-card > .table-responsive:last-child table { border-radius: 0 0 var(--radius) var(--radius); }

/* ==================== WALLET CARDS ==================== */
.wallet-card { cursor: pointer; transition: transform 0.15s, box-shadow 0.15s, border-color .15s; }
.wallet-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: #d5e3db; }
.wallet-card-icon {
  width: 46px; height: 46px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.35rem; color: var(--primary); background: var(--primary-soft);
}

@media (max-width: 576px) {
  .wallet-card .btn-sm { padding: 6px 8px; font-size: 0.82rem; }
}

/* ==================== TABLES ==================== */
.table { --bs-table-hover-bg: #f6faf8; margin-bottom: 0; }
.table > :not(caption) > * > * { border-color: var(--border-soft); }
.table thead th, .table-light th {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .5px;
  font-weight: 600; color: var(--text-muted); background: #f8faf9 !important;
}
.table-sm > :not(caption) > * > * { padding: .6rem .75rem; }
.txn-table td { padding: 11px 14px; vertical-align: middle; }
.txn-table tbody tr { transition: background .12s; }
.txn-table tbody tr:hover { background: #f6faf8; }
.txn-table tr:last-child td { border-bottom: none; }

@media (max-width: 576px) {
  .txn-table td { padding: 9px 10px; font-size: 0.86rem; }
}

/* ==================== ENTRY LIST (construction) ==================== */
.entry-list { list-style: none; margin: 0; padding: 0; }
.entry-month {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 18px; background: #f8faf9;
  border-top: 1px solid var(--border-soft); border-bottom: 1px solid var(--border-soft);
  font-size: .75rem; font-weight: 600; letter-spacing: .5px; text-transform: uppercase;
  color: var(--text-muted);
}
.entry-list > .entry-month:first-child { border-top: none; border-radius: var(--radius) var(--radius) 0 0; }
.entry-month .entry-month-total { font-size: .82rem; text-transform: none; letter-spacing: 0; color: var(--text); }
.entry-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 18px; border-bottom: 1px solid var(--border-soft);
  transition: background .12s;
}
.entry-row:hover { background: #f6faf8; }
.entry-list > .entry-row:last-child { border-bottom: none; }
.entry-date {
  flex: 0 0 48px; text-align: center; line-height: 1.1;
  border-radius: 10px; background: var(--primary-soft); color: var(--primary); padding: 6px 0;
}
.entry-date .d { display: block; font-size: 1.05rem; font-weight: 700; }
.entry-date .m { display: block; font-size: .66rem; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.entry-main { flex: 1; min-width: 0; }
.entry-title { font-weight: 600; font-size: .93rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-meta { font-size: .78rem; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 2px; }
.entry-amount { font-weight: 700; font-size: .98rem; white-space: nowrap; }
.entry-actions { flex: 0 0 auto; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px; border-radius: 999px; font-size: .72rem; font-weight: 500;
  background: #eef2f0; color: #4a5a52; border: 0; line-height: 1.6;
}
.chip-warn { background: #fff4d6; color: #7a5b00; cursor: pointer; }
.chip-warn:hover { background: #ffe9a8; }
.chip-ok { background: var(--primary-soft); color: var(--primary); }

@media (max-width: 576px) {
  .entry-row { gap: 10px; padding: 11px 12px; }
  .entry-month { padding: 9px 12px; }
  .entry-date { flex-basis: 42px; }
  .entry-title { white-space: normal; }
}

.txn-dot {
  flex: 0 0 38px; height: 38px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 1rem;
}
.txn-in  { background: #e3f4ea; color: #1d7a45; }
.txn-out { background: #fdecee; color: #c0392b; }
.entry-row .wallet-card-icon { flex: 0 0 38px; width: 38px; height: 38px; font-size: 1.05rem; border-radius: 12px; }

/* Search box above lists */
.list-search { position: relative; max-width: 260px; }
.list-search i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: .85rem; }
.list-search input { padding-left: 32px; }

/* ==================== ZAKAT ==================== */
.zakat-result-card {
  background: linear-gradient(135deg, #16332a 0%, #2d6a4f 100%); color: #fff; border: none;
}
.zakat-result-card .card-header {
  background: transparent; border-color: rgba(255,255,255,0.15); color: #fff;
}
.zakat-result-card .text-muted { color: rgba(255,255,255,0.7) !important; }
.zakat-icon { font-size: 3rem; color: var(--gold); }
.rate-input {
  width: 80px; display: inline-block; padding: 2px 6px;
  border: 1px solid #ccc; border-radius: 6px; font-size: 0.85rem;
}

/* Yearly zakat breakdown */
.month-row { padding: 8px 0; border-bottom: 1px solid var(--border-soft); font-size: 0.88rem; }
.month-row:last-child { border-bottom: none; }

/* ==================== LOGIN ==================== */
.login-body {
  background: radial-gradient(1200px 600px at 20% 0%, #52b788 0%, transparent 60%),
              linear-gradient(135deg, #16332a, #2d6a4f);
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
}
.login-wrapper { width: 100%; max-width: 400px; padding: 20px; }
.login-card { background: #fff; border-radius: 20px; padding: 36px; box-shadow: 0 24px 60px rgba(0,0,0,0.28); }
.login-icon {
  width: 72px; height: 72px;
  background: linear-gradient(135deg, #16332a, #2d6a4f);
  border-radius: 20px; display: flex; align-items: center; justify-content: center;
  margin: 0 auto; font-size: 2rem; color: var(--gold);
}

@media (max-width: 450px) {
  .login-card { padding: 28px 20px; }
}

/* ==================== BUTTONS ==================== */
.btn { border-radius: var(--radius-sm); font-weight: 500; }
.btn-primary { background-color: var(--primary); border-color: var(--primary); }
.btn-primary:hover, .btn-primary:focus { background-color: var(--primary-hover); border-color: var(--primary-hover); }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background-color: var(--primary); border-color: var(--primary); }
.btn:focus-visible, .form-control:focus, .form-select:focus {
  border-color: #7fb89c; box-shadow: 0 0 0 .2rem rgba(45, 106, 79, .15);
}

.btn-xs { padding: 3px 7px; font-size: 0.75rem; line-height: 1.4; border-radius: 6px; }
.btn-icon-danger {
  border: 0; background: transparent; color: #b8c3bd; padding: 6px 8px; border-radius: 8px;
  transition: color .15s, background .15s;
}
.btn-icon-danger:hover { color: #dc3545; background: #fdecee; }

/* ==================== TABS ==================== */
.nav-tabs { border-bottom: 1px solid var(--border); gap: 4px; }
.nav-tabs .nav-link {
  color: var(--text-muted); border: none; border-bottom: 2px solid transparent;
  padding: 10px 14px; font-size: 0.88rem; font-weight: 500; margin-bottom: -1px;
  border-radius: 8px 8px 0 0;
}
.nav-tabs .nav-link:hover { color: var(--text); background: var(--border-soft); }
.nav-tabs .nav-link.active {
  color: var(--primary); border-bottom-color: var(--primary);
  background: transparent; font-weight: 600;
}
.nav-tabs .badge { font-weight: 600; }
.tab-content { padding-top: 6px; }

/* ==================== MISC ==================== */
.progress { border-radius: 999px; background: #edf1ef; }
.alert { border-radius: var(--radius-sm); border: 0; }
.alert-warning { background: #fff6dd; color: #6b5000; }
.alert-success { background: #e3f4ea; color: #1d5b3b; }
.badge { border-radius: 6px; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c9d3ce; border-radius: 3px; }

/* Forms */
.form-control, .form-select {
  font-size: 0.95rem; padding: 9px 12px; border-radius: var(--radius-sm); border-color: #dfe6e2;
}
.form-control-lg { padding: 11px 14px; font-size: 1.05rem; }
.form-control-sm, .form-select-sm { padding: 5px 10px; font-size: .85rem; }
.form-label { font-size: .86rem; color: #3b4a42; }
.input-group-text { border-radius: var(--radius-sm) 0 0 var(--radius-sm); background: #f6f8f7; border-color: #dfe6e2; color: var(--text-muted); }
.modal-content { border-radius: 18px; border: none; box-shadow: 0 24px 60px rgba(0,0,0,.18); }
.modal-header { border-bottom: 1px solid var(--border-soft); padding: 16px 20px; }
.modal-body { padding: 20px; }
.modal-footer { border-top: 1px solid var(--border-soft); padding: 12px 20px; }
.modal-backdrop.show { opacity: .4; }

/* Toasts */
.toast { border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.15); }

/* Badge */
.wallet-type-badge i { font-size: 1rem; }
.badge-bank    { color: #1a6b9a; }
.badge-mobile  { color: #2d6a4f; }
.badge-cash    { color: #9a7d0a; }
.badge-savings { color: #6c3483; }
