@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@700;800;900&family=Onest:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #f5f3ff;
  --surface: #ffffff;
  --header-bg: #130229;
  --header-fg: #f8fafc;
  --accent: #8418FE;
  --accent-hover: #6c13d4;
  --orange: #FFA502;
  --orange-hover: #e6940f;
  --border: #e5e0f5;
  --text: #0f0a1e;
  --muted: #6b6489;
  --green: #10b981;
  --red: #ef4444;
  --yellow: #f59e0b;
  --gray: #94a3b8;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(132,24,254,.07), 0 1px 2px rgba(0,0,0,.05);
  --font-heading: 'Montserrat', 'Onest', sans-serif;
  --font-body: 'Onest', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

body {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ── */
.header {
  background: var(--header-bg);
  color: var(--header-fg);
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 16px rgba(132,24,254,.25);
}
.header-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.header-nav {
  display: flex;
  gap: 4px;
  flex: 1;
}
.header-nav a {
  color: rgba(255,255,255,.55);
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.header-nav a:hover {
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.9);
  text-decoration: none;
}
.header-nav a.active {
  background: rgba(132,24,254,.25);
  color: #fff;
  text-decoration: none;
}
.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,.5);
  font-size: 13px;
  margin-left: auto;
}
.header-user span { color: rgba(255,255,255,.8); }

/* ── Layout ── */
.page { max-width: 1400px; margin: 0 auto; padding: 20px; }
.page-title {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
}

/* ── Card ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card-body { padding: 16px 20px; }

/* ── Filters ── */
.filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.filter-group label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ── Search ── */
.search-wrap {
  position: relative;
  flex: 1;
  min-width: 220px;
}
.search-wrap input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.search-wrap input:focus { border-color: var(--accent); }
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

/* ── Inputs & Selects ── */
input, select {
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: var(--font-body);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(132,24,254,.1); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background .15s, opacity .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 4px 12px rgba(132,24,254,.3); }
.btn-orange { background: var(--orange); color: #130229; }
.btn-orange:hover { background: var(--orange-hover); box-shadow: 0 4px 12px rgba(255,165,2,.3); }
.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
}
.btn-outline:hover { background: rgba(132,24,254,.06); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { background: transparent; color: var(--muted); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }

/* ── Period buttons ── */
.period-btns { display: flex; gap: 4px; flex-wrap: wrap; }
.period-btn {
  padding: 6px 10px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  color: var(--muted);
  transition: all .15s;
}
.period-btn:hover { border-color: var(--accent); color: var(--accent); }
.period-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(132,24,254,.3); }

/* ── Table ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  background: #f8f5ff;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #faf8ff; }
td { padding: 10px 12px; vertical-align: middle; }

/* ── Status badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-green { background: #dcfce7; color: #166534; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-blue { background: #ede9fe; color: #5b21b6; }
.badge-orange { background: #fff3cd; color: #8a5500; }

.tr-pk-only td { background: #fff5f5; }
.tr-pk-only:hover td { background: #fee2e2; }
.card-pk-only { border-left: 3px solid #f87171; background: #fff5f5; }

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}
.pagination-btns { display: flex; gap: 4px; }
.page-btn {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  transition: all .15s;
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(19,2,41,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}
.modal {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(132,24,254,.2);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  padding: 20px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
}
.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--muted);
  line-height: 1;
  padding: 4px;
}
.modal-body { padding: 16px 24px 24px; }
.modal-footer {
  padding: 0 24px 20px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── Form ── */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--muted); }
.form-group input, .form-group select { width: 100%; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

.radio-group { display: flex; gap: 16px; margin: 8px 0; }
.radio-label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; }

/* ── Stats ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  border-top: 3px solid var(--accent);
}
.stat-label { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.stat-value { font-family: var(--font-heading); font-size: 24px; font-weight: 700; color: var(--text); }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ── Mobile cards ── */
.payment-cards { display: none; gap: 10px; flex-direction: column; }
.payment-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.payment-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.payment-card-name { font-weight: 600; font-size: 14px; }
.payment-card-amount { font-weight: 700; font-size: 16px; color: var(--text); }
.payment-card-meta { font-size: 12px; color: var(--muted); line-height: 1.6; }
.payment-card-footer { margin-top: 10px; display: flex; gap: 8px; justify-content: flex-end; }

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}
.toast {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  animation: slideIn .2s ease;
  min-width: 240px;
}
.toast-success { background: #dcfce7; color: #166534; border-left: 3px solid var(--green); }
.toast-error { background: #fee2e2; color: #991b1b; border-left: 3px solid var(--red); }
.toast-info { background: #ede9fe; color: #5b21b6; border-left: 3px solid var(--accent); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Empty state ── */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-text { font-size: 15px; font-weight: 500; }
.empty-sub { font-size: 13px; margin-top: 4px; }

/* ── Loading ── */
.loading { display: flex; align-items: center; justify-content: center; padding: 48px; color: var(--muted); gap: 10px; }
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Login page ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #130229 0%, #2d0a6e 60%, #4a1aaa 100%);
}
.login-card { width: 100%; max-width: 380px; border-radius: 16px; overflow: hidden; box-shadow: 0 24px 64px rgba(0,0,0,.4); }
.login-header {
  background: linear-gradient(135deg, var(--accent) 0%, #5b10c7 100%);
  padding: 32px 32px 24px;
  text-align: center;
}
.login-sub { color: rgba(255,255,255,.75); font-size: 13px; margin-top: 4px; }
.login-body { background: var(--surface); padding: 28px 32px; }

/* ── Chart placeholder ── */
.chart-bar-wrap { display: flex; flex-direction: column; gap: 6px; }
.chart-bar-row { display: grid; grid-template-columns: 120px 1fr 80px; gap: 10px; align-items: center; font-size: 12px; }
.chart-bar-label { color: var(--muted); text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.chart-bar-track { background: #ede9fe; border-radius: 4px; height: 10px; overflow: hidden; }
.chart-bar-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width .4s ease; }
.chart-bar-val { text-align: right; font-weight: 600; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .page { padding: 12px; }
  .header { padding: 0 12px; gap: 12px; }
  .header-nav a { padding: 5px 8px; font-size: 12px; }
  .filters { padding: 12px; gap: 8px; }
  .table-wrap table { display: none; }
  .payment-cards { display: flex; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .search-wrap { min-width: 100%; width: 100%; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .header-nav { display: none; }
  .period-btns { flex-wrap: wrap; }
}

/* ── Utility ── */
.hidden { display: none !important; }
.text-right { text-align: right; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 12px; }
.font-mono { font-family: monospace; }
.fw-600 { font-weight: 600; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mt-12 { margin-top: 12px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.indicator { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.indicator-green { background: var(--green); }
.indicator-red { background: var(--red); }
