/* ============================================================
   SOCIETY PAYMENT APP — GLOBAL STYLESHEET v3
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg:           #eef1fb;
  --surface:      #ffffff;
  --surface2:     #f7f8fd;
  --border:       #dde3f5;
  --primary:      #4f46e5;
  --primary-dk:   #3730a3;
  --primary-lt:   #eef2ff;
  --success:      #10b981;
  --success-lt:   #ecfdf5;
  --danger:       #ef4444;
  --danger-lt:    #fef2f2;
  --warning:      #f59e0b;
  --warning-lt:   #fffbeb;
  --text:         #1e1b4b;
  --muted:        #64748b;
  --light:        #94a3b8;
  --sh-sm:        0 1px 4px rgba(79,70,229,.08);
  --sh:           0 4px 18px rgba(79,70,229,.10);
  --sh-lg:        0 12px 40px rgba(79,70,229,.14);
  --r-sm:         8px;
  --r:            12px;
  --r-lg:         16px;
  --font:         'Plus Jakarta Sans', sans-serif;
  --mono:         'JetBrains Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── NAVBAR ─────────────────────────────────────────────── */
.navbar {
  background: linear-gradient(135deg,#1e1b4b 0%,#312e81 100%);
  padding: 0 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 60px;
  box-shadow: 0 2px 20px rgba(30,27,75,.35);
  position: sticky;
  top: 0;
  z-index: 200;
}
.navbar-brand { font-size: 16px; font-weight: 800; color: #fff; letter-spacing: -.3px; }
.navbar-brand span { color: #a5b4fc; }
.nav-links { display: flex; gap: 4px; }
.nav-item {
  text-decoration: none;
  color: #c7d2fe;
  padding: 7px 14px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  transition: all .18s;
}
.nav-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-item.active { background: #4f46e5; color: #fff; box-shadow: 0 2px 8px rgba(79,70,229,.5); }

/* ── PAGE LAYOUT ─────────────────────────────────────────── */
.page-wrap { padding: 28px; max-width: 1200px; margin: 0 auto; }
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 800; letter-spacing: -.4px; }
.page-header p { font-size: 13px; color: var(--muted); margin-top: 3px; }

/* ── CARD ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh);
  border: 1px solid var(--border);
  padding: 22px;
}

/* ── KPI GRID ────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit,minmax(180px,1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  border: 1px solid var(--border);
  box-shadow: var(--sh-sm);
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
}
.kpi-card.blue::before  { background: linear-gradient(90deg,#4f46e5,#818cf8); }
.kpi-card.green::before { background: linear-gradient(90deg,#10b981,#34d399); }
.kpi-card.red::before   { background: linear-gradient(90deg,#ef4444,#f87171); }
.kpi-card.amber::before { background: linear-gradient(90deg,#f59e0b,#fbbf24); }
.kpi-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); margin-bottom: 8px; }
.kpi-value { font-size: 26px; font-weight: 800; color: var(--text); font-family: var(--mono); letter-spacing: -.5px; }
.kpi-sub { font-size: 11px; color: var(--light); margin-top: 4px; }

/* ── TOOLBAR ─────────────────────────────────────────────── */
.toolbar {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
  align-items: center;
}
.toolbar-left, .toolbar-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── BUTTONS ─────────────────────────────────────────────── */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 14px;
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font);
  background: var(--primary);
  color: #fff;
  transition: all .18s;
  white-space: nowrap;
  line-height: 1;
}
button:hover { background: var(--primary-dk); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(79,70,229,.35); }
button:active { transform: translateY(0); box-shadow: none; }

button.secondary { background: var(--surface); color: var(--text); border: 1.5px solid var(--border); box-shadow: var(--sh-sm); }
button.secondary:hover { background: var(--surface2); box-shadow: var(--sh); }

button.success { background: var(--success); }
button.success:hover { background: #059669; box-shadow: 0 4px 12px rgba(16,185,129,.35); }

button.danger { background: var(--danger); }
button.danger:hover { background: #dc2626; box-shadow: 0 4px 12px rgba(239,68,68,.35); }

button.warning { background: var(--warning); }
button.warning:hover { background: #d97706; }

button.sm { padding: 5px 10px; font-size: 11.5px; }
button.xs { padding: 3px 8px; font-size: 11px; }
button.icon-btn { padding: 5px 8px; font-size: 13px; min-width: 30px; }

/* ── INPUTS ──────────────────────────────────────────────── */
input[type="text"],
input[type="number"],
input[type="tel"],
select {
  padding: 9px 12px;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--border);
  font-size: 13px;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
select option { color: var(--text); }

.field-group { margin-bottom: 14px; }
.field-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  margin-bottom: 5px;
}

/* ── TABLE ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--r); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; background: var(--surface); min-width: 600px; }
thead { background: #1e1b4b; }
th {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  padding: 12px 14px;
  color: #a5b4fc;
  text-align: left;
  white-space: nowrap;
}
td {
  font-size: 13px;
  padding: 11px 14px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--primary-lt); }
td.actions { white-space: nowrap; }
td.actions button { margin-right: 4px; }
td.actions button:last-child { margin-right: 0; }

/* ── BADGES ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge.paid   { background: var(--success-lt); color: #065f46; }
.badge.unpaid { background: var(--danger-lt);  color: #991b1b; }
.badge.manual { background: var(--warning-lt); color: #92400e; }
.badge.upi    { background: #ede9fe; color: #5b21b6; }

/* ── RECORD INFO ─────────────────────────────────────────── */
.record-info { font-size: 12.5px; color: var(--muted); font-weight: 500; margin-bottom: 12px; }

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty-state .icon { font-size: 38px; margin-bottom: 10px; }
.empty-state p { font-size: 14px; }

/* ── MODAL ───────────────────────────────────────────────── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(10,10,30,.6);
  backdrop-filter: blur(4px);
}
.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn .2s ease;
}
.modal-box {
  background: #fff;
  border-radius: var(--r-lg);
  box-shadow: var(--sh-lg);
  width: min(440px, 94vw);
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp .25s ease;
  padding: 28px;
}
.modal-box.wide { width: min(580px, 94vw); }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.modal-header h3 { font-size: 16px; font-weight: 800; }
.modal-close {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  width: 30px; height: 30px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all .15s;
}
.modal-close:hover { background: var(--danger); color: #fff; border-color: var(--danger); transform: none; box-shadow: none; }

.modal-footer { display: flex; gap: 10px; margin-top: 20px; }
.modal-footer button { flex: 1; justify-content: center; padding: 10px; }

/* ── UNPAID PANEL ────────────────────────────────────────── */
.unpaid-panel {
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1px solid #fecaca;
  margin-top: 20px;
  overflow: hidden;
}
.unpaid-header {
  background: linear-gradient(135deg,#fef2f2,#fff5f5);
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #fecaca;
  flex-wrap: wrap;
  gap: 8px;
}
.unpaid-header h3 { font-size: 14px; font-weight: 800; color: #991b1b; }
.unpaid-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill,minmax(210px,1fr));
  gap: 8px;
  padding: 14px;
  max-height: 380px;
  overflow-y: auto;
}
.unpaid-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--danger-lt);
  border: 1px solid #fecaca;
  border-radius: var(--r-sm);
  padding: 9px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: #7f1d1d;
  gap: 6px;
}
.unpaid-item .wa-btn {
  flex-shrink: 0;
  background: #25D366;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 700;
  transition: background .15s;
}
.unpaid-item .wa-btn:hover { background: #128C7E; transform: none; box-shadow: none; }

/* ── TXN CHIP ────────────────────────────────────────────── */
.txn-chip {
  display: inline-flex;
  align-items: center;
  background: #ede9fe;
  color: #5b21b6;
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--mono);
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── LOADER ──────────────────────────────────────────────── */
#loader {
  position: fixed;
  bottom: 24px; right: 24px;
  background: #1e1b4b;
  color: #fff;
  padding: 10px 18px;
  border-radius: 99px;
  font-size: 12.5px;
  font-weight: 700;
  display: none;
  z-index: 500;
  box-shadow: var(--sh-lg);
  gap: 8px;
  align-items: center;
}
#loader.show { display: flex; }
.spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ── TOAST ───────────────────────────────────────────────── */
#toast {
  position: fixed;
  top: 76px; right: 24px;
  padding: 12px 20px;
  border-radius: var(--r);
  font-size: 13.5px;
  font-weight: 700;
  color: #fff;
  z-index: 9999;
  opacity: 0;
  transform: translateX(30px);
  transition: all .28s ease;
  pointer-events: none;
  max-width: 320px;
  box-shadow: var(--sh-lg);
}
#toast.show { opacity: 1; transform: translateX(0); }
#toast.success { background: var(--success); }
#toast.error   { background: var(--danger);  }
#toast.info    { background: var(--primary); }
#toast.warning { background: var(--warning); }

/* ── ANIMATIONS ──────────────────────────────────────────── */
@keyframes fadeIn  { from { opacity: 0; }                             to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes spin    { to   { transform: rotate(360deg); } }

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .page-wrap { padding: 16px; }
  .kpi-grid { grid-template-columns: repeat(2,1fr); gap: 12px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-left, .toolbar-right { flex-wrap: wrap; }
  .navbar { padding: 0 14px; }
  .nav-item { padding: 6px 10px; font-size: 12px; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 22px; }
  th, td { padding: 9px 10px; }
}
