:root {
  --gm-primary: #4f46e5;
  --gm-primary-dark: #3730a3;
  --gm-primary-soft: #eef2ff;
  --gm-bg: #f1f5f9;
  --gm-card: #ffffff;
  --gm-ink: #0f172a;
  --gm-body: #475569;
  --gm-muted: #64748b;
  --gm-line: #e2e8f0;
  --gm-danger: #dc2626;
  --gm-danger-soft: #fef2f2;
  --gm-ok: #16a34a;
  --gm-ok-soft: #f0fdf4;
  --gm-bottom-nav-h: 64px;
  --gm-sidebar-w: 240px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Bengali", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--gm-bg);
  color: var(--gm-ink);
  font-family: var(--font);
}
button, input, select, textarea { font: inherit; }
a { color: var(--gm-primary); text-decoration: none; }
button { cursor: pointer; border: 0; background: none; color: inherit; }
.app-root { min-height: 100dvh; }

/* —— Admin shell (SMS / Pay parity) —— */
.admin-shell { min-height: 100dvh; }
.admin-sidebar {
  display: none;
  width: var(--gm-sidebar-w);
  flex-shrink: 0;
  background: var(--gm-card);
  border-right: 1px solid var(--gm-line);
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
  flex-direction: column;
}
.sidebar-brand {
  padding: 1rem;
  border-bottom: 1px solid var(--gm-line);
}
.sidebar-brand .title {
  font-weight: 700;
  color: var(--gm-primary);
  font-size: 1rem;
}
.sidebar-brand .sub {
  font-size: 0.8rem;
  color: var(--gm-muted);
  margin-top: 2px;
}
.sidebar-nav { padding: 0.5rem 0; flex: 1; }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1rem;
  color: var(--gm-body);
  border-radius: 0.5rem;
  margin: 0.15rem 0.5rem;
  font-size: 0.9rem;
  width: calc(100% - 1rem);
  text-align: left;
}
.sidebar-link:hover,
.sidebar-link.active {
  background: var(--gm-primary-soft);
  color: var(--gm-primary);
}
.sidebar-link i { font-size: 1.1rem; }
.sidebar-foot {
  padding: 1rem;
  border-top: 1px solid var(--gm-line);
  margin-top: auto;
}
.admin-main { width: 100%; min-width: 0; }
.admin-topbar {
  background: linear-gradient(135deg, var(--gm-primary), var(--gm-primary-dark));
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 1030;
  padding: 0.75rem 1rem;
  padding-top: calc(0.75rem + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.admin-topbar .page-title { font-weight: 600; font-size: 0.95rem; }
.admin-topbar .page-sub { font-size: 0.8rem; opacity: 0.75; }
.admin-topbar .avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.4);
  background: #fff;
  color: var(--gm-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  overflow: hidden;
  flex-shrink: 0;
}
.admin-topbar .avatar img { width: 100%; height: 100%; object-fit: cover; }
.theme-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  color: #fff;
  border: 1px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.12);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.theme-btn:hover { background: rgba(255,255,255,.25); }
.menu-btn {
  width: 36px; height: 36px;
  border-radius: 0.5rem;
  background: #fff;
  color: var(--gm-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.admin-content {
  padding: 1rem;
  max-width: 1200px;
  margin: 0 auto;
  padding-bottom: calc(var(--gm-bottom-nav-h) + 1.25rem + env(safe-area-inset-bottom));
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.stat-card {
  background: var(--gm-card);
  border-radius: 1rem;
  padding: 1rem;
  border: 1px solid var(--gm-line);
}
.stat-card .label { font-size: 0.8rem; color: var(--gm-muted); }
.stat-card .value { font-size: 1.45rem; font-weight: 700; color: var(--gm-primary); margin-top: 0.25rem; }
.stat-card .sub { font-size: 0.75rem; color: #94a3b8; margin-top: 0.2rem; }
.stat-card.due .value { color: var(--gm-danger); }
.stat-card.ok .value { color: var(--gm-ok); }

.panel {
  background: var(--gm-card);
  border: 1px solid var(--gm-line);
  border-radius: 1rem;
  margin-top: 1rem;
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--gm-line);
}
.panel-head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}
.panel-body { padding: 0.5rem 0; }
.panel-body.pad { padding: 1rem; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.data-table th,
.data-table td {
  padding: 0.7rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--gm-line);
}
.data-table th {
  font-size: 0.75rem;
  color: var(--gm-muted);
  font-weight: 600;
  background: rgba(241, 245, 249, 0.7);
}
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr { cursor: pointer; }
.data-table tbody tr:hover { background: var(--gm-primary-soft); }
.data-table .hide-sm { display: none; }

.mobile-card {
  background: var(--gm-card);
  border-radius: 0.875rem;
  border: 1px solid var(--gm-line);
  padding: 0.875rem;
  margin: 0.5rem 0.75rem;
  width: calc(100% - 1.5rem);
  text-align: left;
  color: inherit;
  display: block;
}
.mobile-card strong { display: block; }
.mobile-card .row-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.35rem;
  font-size: 0.82rem;
  color: var(--gm-muted);
}

.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--gm-bottom-nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--gm-card);
  border-top: 1px solid var(--gm-line);
  display: flex;
  z-index: 1040;
}
.bottom-nav button,
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #94a3b8;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.4rem 0.2rem;
}
.bottom-nav button.active,
.bottom-nav a.active { color: var(--gm-primary); }
.bottom-nav i { font-size: 1.25rem; }

.offcanvas {
  position: fixed;
  inset: 0;
  z-index: 1050;
  display: none;
}
.offcanvas.open { display: block; }
.offcanvas-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, 0.45);
}
.offcanvas-panel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: var(--gm-card);
  border-radius: 1rem 1rem 0 0;
  max-height: 70vh;
  overflow: auto;
  padding: 1rem;
}
.offcanvas-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.offcanvas-head h3 { margin: 0; font-size: 1rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 40px;
  padding: 0 0.9rem;
  border-radius: 0.65rem;
  font-weight: 600;
  font-size: 0.9rem;
}
.btn-primary {
  background: linear-gradient(135deg, var(--gm-primary), var(--gm-primary-dark));
  color: #fff;
  box-shadow: 0 8px 18px rgba(79, 70, 229, 0.25);
}
.btn-primary:active { transform: scale(0.98); }
.btn-ghost {
  background: var(--gm-card);
  border: 1px solid var(--gm-line);
  color: var(--gm-ink);
}
.btn-outline-danger {
  background: transparent;
  border: 1px solid var(--gm-danger);
  color: var(--gm-danger);
  width: 100%;
}
.btn-danger { background: var(--gm-danger); color: #fff; }
.btn-sm { min-height: 34px; padding: 0 0.7rem; font-size: 0.82rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.fab-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-top: 0.85rem;
}

.search {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border-radius: 0.65rem;
  border: 1px solid var(--gm-line);
  background: var(--gm-card);
  margin-bottom: 0.75rem;
  color: var(--gm-ink);
}
.search:focus { outline: 2px solid rgba(79, 70, 229, 0.25); border-color: var(--gm-primary); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}
.badge-ok { background: var(--gm-ok-soft); color: var(--gm-ok); }
.badge-danger { background: var(--gm-danger-soft); color: var(--gm-danger); }
.badge-soft { background: var(--gm-primary-soft); color: var(--gm-primary-dark); }

.amount { font-weight: 700; white-space: nowrap; }
.amount.pos { color: var(--gm-danger); }
.amount.neg { color: var(--gm-ok); }
.amount.zero { color: var(--gm-muted); }

.muted { color: var(--gm-muted); }
.empty { text-align: center; padding: 1.75rem 0.75rem; color: var(--gm-muted); }
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--gm-primary);
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.txn {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--gm-line);
}
.txn:last-child { border-bottom: 0; }
.txn .note { color: var(--gm-muted); font-size: 0.84rem; }
.txn .date { color: var(--gm-muted); font-size: 0.8rem; grid-column: 1 / -1; }

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 1060; padding: 12px;
}
.modal {
  width: min(520px, 100%);
  background: var(--gm-card);
  color: var(--gm-ink);
  border-radius: 1.25rem 1.25rem 1rem 1rem;
  padding: 18px;
  max-height: 90dvh;
  overflow: auto;
}
.modal h3 { margin: 0 0 14px; }

.form { display: flex; flex-direction: column; gap: 12px; }
.field label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--gm-body);
  text-align: left;
}
.field input, .field textarea, .field select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 0.65rem;
  border: 1px solid var(--gm-line);
  background: var(--gm-card);
  color: var(--gm-ink);
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: 2px solid rgba(79, 70, 229, 0.25);
  border-color: var(--gm-primary);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--gm-bottom-nav-h) + 18px);
  transform: translateX(-50%) translateY(20px);
  background: #1e293b;
  color: #fff;
  padding: 12px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: .25s ease;
  z-index: 1100;
  max-width: min(90vw, 420px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: #7f1d1d; }

.loading {
  display: flex; align-items: center; justify-content: center;
  min-height: 30vh; color: var(--gm-muted);
}
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--gm-line);
  border-top-color: var(--gm-primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-right: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.install-banner {
  margin: 0 1rem 0.75rem;
  padding: 12px 14px;
  border-radius: 0.875rem;
  background: linear-gradient(135deg, var(--gm-primary), var(--gm-primary-dark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.install-banner button {
  background: #fff;
  color: var(--gm-primary-dark);
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 10px;
}

/* Login */
.auth-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  padding-top: calc(1.25rem + env(safe-area-inset-top));
  padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
  background: linear-gradient(160deg, #4f46e5 0%, #312e81 50%, #1e1b4b 100%);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 1.25rem;
  padding: 2rem 1.5rem;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
  text-align: center;
}
.logo-circle {
  width: 72px; height: 72px;
  margin: 0 auto 1rem;
  border-radius: 1.25rem;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.logo-circle img { width: 100%; height: 100%; object-fit: cover; }
.login-card h1 { margin: 0 0 4px; font-size: 1.35rem; font-weight: 700; }
.login-card .sub { margin: 0 0 1.35rem; font-size: 0.9rem; color: var(--gm-muted); }
.btn-sso {
  background: linear-gradient(135deg, #4f46e5, #3730a3);
  color: #fff;
  padding: 0.9rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 0.75rem;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.35);
}
.btn-sso:hover { color: #fff; }
.feature-list {
  list-style: none; padding: 0; margin: 1rem 0 0;
  text-align: left; font-size: 0.85rem; color: var(--gm-muted);
}
.feature-list li { margin-bottom: 0.4rem; display: flex; gap: 8px; align-items: flex-start; }
.feature-list .dot {
  width: 8px; height: 8px; margin-top: 6px;
  border-radius: 50%; background: var(--gm-primary); flex-shrink: 0;
}
.auth-foot { margin-top: 1.25rem; text-align: center; }
.auth-foot a { color: rgba(255,255,255,.9); font-size: 0.9rem; }
.chip {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--gm-primary-soft);
  color: var(--gm-primary-dark);
  font-weight: 700;
  font-size: 0.85rem;
}
.chip.danger { background: var(--gm-danger-soft); color: var(--gm-danger); }
.chip.ok { background: var(--gm-ok-soft); color: var(--gm-ok); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }

/* Dark mode — SMS/Pay tokens */
[data-bs-theme="dark"] {
  --gm-bg: #0f172a;
  --gm-card: #1e293b;
  --gm-ink: #e2e8f0;
  --gm-body: #cbd5e1;
  --gm-muted: #94a3b8;
  --gm-line: #334155;
  --gm-primary-soft: rgba(129, 140, 248, 0.16);
}
[data-bs-theme="dark"] .admin-sidebar { background: #1e293b; }
[data-bs-theme="dark"] .sidebar-link:hover,
[data-bs-theme="dark"] .sidebar-link.active { color: #a5b4fc; }
[data-bs-theme="dark"] .stat-card .value { color: #a5b4fc; }
[data-bs-theme="dark"] .bottom-nav button.active { color: #a5b4fc; }
[data-bs-theme="dark"] .data-table th { background: #273449; }
[data-bs-theme="dark"] .data-table tbody tr:hover { background: rgba(129, 140, 248, 0.12); }
[data-bs-theme="dark"] .login-card { background: #1e293b; color: #e2e8f0; }
[data-bs-theme="dark"] .auth-wrap { background: linear-gradient(160deg, #1e1b4b 0%, #0f172a 60%, #020617 100%); }
[data-bs-theme="dark"] .btn-ghost { background: #273449; border-color: #334155; color: #e2e8f0; }

@media (min-width: 768px) {
  .admin-shell { display: flex; min-height: 100vh; }
  .admin-sidebar { display: flex !important; }
  .admin-content { padding-bottom: 1.5rem; }
  .bottom-nav { display: none; }
  .menu-btn { display: none; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .data-table .hide-sm { display: table-cell; }
  .mobile-only { display: none !important; }
  .desktop-only { display: block !important; }
  .toast { bottom: 24px; }
}
@media (max-width: 767.98px) {
  .desktop-only { display: none !important; }
}
