/* ============================================
   SUFFAH FEES — REFINED ADMINISTRATIVE
   Navy + gold on warm paper. Schoolish but sober.
   ============================================ */

/* Ensure the HTML `hidden` attribute always wins over any display: flex rules */
[hidden] { display: none !important; }

:root {
  /* Palette */
  --navy:        #0a2540;
  --navy-soft:   #143659;
  --navy-deep:   #061629;
  --gold:        #b8954a;
  --gold-soft:   #d8b878;
  --paper:       #faf7f0;
  --paper-tint:  #f3eee2;
  --ink:         #1a1a1a;
  --muted:       #6b6657;
  --rule:        #e2dac8;
  --rule-strong: #c9bfa6;
  --success:     #4a7c59;
  --success-bg:  #e9f1ec;
  --warn:        #a37431;
  --warn-bg:     #f7eddb;
  --danger:      #a94442;
  --danger-bg:   #f4e3e2;

  /* Typography */
  --font-brand:    "Cinzel", "Trajan Pro 3", "EB Garamond", serif;
  --font-display:  "Fraunces", "EB Garamond", Georgia, serif;
  --font-body:     "Manrope", system-ui, -apple-system, sans-serif;

  /* Sizing */
  --radius:    6px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 2px rgba(10,37,64,.06), 0 0 0 1px rgba(10,37,64,.04);
  --shadow:    0 4px 16px rgba(10,37,64,.08), 0 0 0 1px rgba(10,37,64,.05);
  --shadow-lg: 0 18px 48px rgba(10,37,64,.18);
}

* { box-sizing: border-box; }
html, body { margin:0; padding:0; }
body {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
  background: var(--paper);
  background-image:
    radial-gradient(1200px 600px at 10% -10%, rgba(184,149,74,.06), transparent 60%),
    radial-gradient(900px 500px at 100% 110%, rgba(10,37,64,.05), transparent 60%);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
}
h1 { font-size: 28px; }
h2 { font-size: 18px; font-weight: 600; }

button { font-family: inherit; }

/* ================== LOGIN ================== */
.login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 48px 40px 40px;
  box-shadow: var(--shadow);
  text-align: center;
}
.brand {
  margin-bottom: 32px;
}
.brand-name {
  font-family: var(--font-brand);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--navy);
}
.brand-divider {
  width: 40px;
  height: 1px;
  background: var(--gold);
  margin: 12px auto;
}
.brand-tag {
  font-family: var(--font-display);
  font-style: italic;
  color: var(--muted);
  font-size: 15px;
}
.login-instruction {
  color: var(--muted);
  margin: 0 0 24px;
  font-size: 13px;
}
.login-error {
  color: var(--danger);
  margin-top: 16px;
  font-size: 13px;
}
.login-footer {
  margin-top: 32px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.05em;
}

/* ================== APP SHELL ================== */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.app-header {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 14px 28px;
  background: var(--navy);
  color: #fff;
  border-bottom: 2px solid var(--gold);
}
.header-left {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.brand-mark {
  font-family: var(--font-brand);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.12em;
  color: #fff;
}
.brand-sub {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 14px;
  color: var(--gold-soft);
}

.app-nav {
  display: flex;
  gap: 4px;
  flex: 1;
}
.nav-btn {
  background: transparent;
  border: 0;
  color: rgba(255,255,255,0.72);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  border-radius: var(--radius);
  transition: all 0.15s;
}
.nav-btn:hover { color: #fff; background: rgba(255,255,255,0.06); }
.nav-btn.active {
  color: var(--navy);
  background: var(--gold-soft);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-email {
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  font-variant-numeric: tabular-nums;
}

.app-main {
  flex: 1;
  padding: 32px 28px 64px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ================== VIEWS ================== */
.view { display: none; }
.view.active { display: block; }

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rule);
}
.view-sub {
  color: var(--muted);
  margin: 4px 0 0;
  font-size: 13px;
}
.view-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ================== STAT CARDS ================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
  background: var(--navy);
}
.stat-card.stat-success::before { background: var(--success); }
.stat-card.stat-warn::before { background: var(--warn); }
.stat-label {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 500;
  margin-top: 6px;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

/* ================== PANELS ================== */
.panel {
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper-tint);
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0;
  padding: 0;
}
.quick-card {
  text-align: left;
  background: #fff;
  border: 0;
  border-right: 1px solid var(--rule);
  padding: 24px;
  cursor: pointer;
  transition: background 0.2s;
}
.quick-card:last-child { border-right: 0; }
.quick-card:hover { background: var(--paper-tint); }
.qc-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  color: var(--navy);
  margin-bottom: 4px;
}
.qc-desc {
  font-size: 13px;
  color: var(--muted);
}

/* ================== TABLES ================== */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper-tint);
  white-space: nowrap;
}
.data-table thead th.num { text-align: right; }
.data-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--rule);
  font-variant-numeric: tabular-nums;
}
.data-table tbody td.num { text-align: right; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: rgba(184,149,74,0.04); }

.empty-state {
  text-align: center !important;
  color: var(--muted);
  font-style: italic;
  padding: 40px 16px !important;
}

.row-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

/* ================== STATUS PILLS ================== */
.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.pill-pending { background: var(--warn-bg); color: var(--warn); }
.pill-paid    { background: var(--success-bg); color: var(--success); }
.pill-overdue { background: var(--danger-bg); color: var(--danger); }
.pill-active  { background: #e8efe9; color: #2e5b3a; }
.pill-inactive{ background: #ece9e2; color: var(--muted); }

/* ================== FILTERS ================== */
.filter-row {
  display: flex;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--rule);
  flex-wrap: wrap;
  background: var(--paper-tint);
}
.filter-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.filter-row .input { min-width: 160px; }

/* ================== INPUTS & BUTTONS ================== */
.input, select.input, textarea.input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(10,37,64,0.08);
}
.input.search { min-width: 240px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--navy);
  color: #fff;
}
.btn-primary:hover { background: var(--navy-soft); }
.btn-ghost {
  background: transparent;
  color: var(--navy);
  border-color: var(--rule-strong);
}
.btn-ghost:hover { background: var(--paper-tint); }
.btn-ghost-sm {
  background: transparent;
  color: rgba(255,255,255,0.85);
  border: 1px solid rgba(255,255,255,0.2);
  padding: 5px 10px;
  font-size: 12px;
  border-radius: var(--radius);
  cursor: pointer;
}
.btn-ghost-sm:hover { background: rgba(255,255,255,0.08); }
.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
  padding: 5px 10px;
  font-size: 12px;
}
.btn-danger:hover { background: var(--danger-bg); }
.btn-link {
  background: transparent;
  border: 0;
  color: var(--navy);
  text-decoration: underline;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 600;
}
.btn-link:hover { color: var(--gold); }
.btn-block { width: 100%; padding: 12px; }

/* ================== MODALS ================== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(10,22,41,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  backdrop-filter: blur(2px);
}
.modal[hidden] { display: none; }
.modal-card {
  background: #fff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  background: var(--navy);
  color: #fff;
}
.modal-head h2 { color: #fff; }
.modal-close {
  background: transparent;
  border: 0;
  color: rgba(255,255,255,0.8);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 10px;
}
.modal-close:hover { color: #fff; }
.modal-body {
  padding: 24px;
  overflow-y: auto;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.form-grid label.full { grid-column: 1 / -1; }
.form-grid label.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  color: var(--ink);
  font-size: 13px;
}
.section-divider {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
  text-transform: none;
  letter-spacing: 0;
  border-top: 1px solid var(--rule);
  padding-top: 16px;
  margin-top: 8px;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
}

#payment-voucher-summary {
  background: var(--paper-tint);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13px;
  color: var(--ink);
  line-height: 1.6;
}

/* ================== TOAST ================== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--navy);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  font-size: 13px;
  font-weight: 500;
  border-left: 3px solid var(--gold);
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }

/* ================== VOUCHER PRINT ================== */
.print-area { display: none; }

@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area {
    display: block !important;
    position: absolute;
    left: 0; top: 0;
    width: 100%;
  }
  @page { margin: 12mm; size: A4; }
}

.voucher-sheet {
  font-family: var(--font-body);
  color: #000;
  background: #fff;
  padding: 0;
}
.voucher-sheet + .voucher-sheet {
  page-break-before: always;
}
.voucher-strips {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0;
  border: 1.5px solid #000;
}
.voucher-strip {
  padding: 14px 14px 12px;
  border-right: 1.5px dashed #555;
  position: relative;
}
.voucher-strip:last-child { border-right: 0; }
.vs-copy-label {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 9px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #555;
  font-weight: 600;
}
.vs-head {
  text-align: center;
  border-bottom: 1px solid #000;
  padding-bottom: 8px;
  margin-bottom: 10px;
}
.vs-school {
  font-family: var(--font-brand);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.vs-tag {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 9px;
  color: #555;
  margin-top: 2px;
}
.vs-title {
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #555;
  margin-top: 6px;
}
.vs-meta {
  font-size: 10px;
  margin-bottom: 8px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 8px;
}
.vs-meta b { font-weight: 600; }
.vs-items {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
  margin-bottom: 8px;
}
.vs-items th, .vs-items td {
  border: 1px solid #000;
  padding: 4px 6px;
  text-align: left;
}
.vs-items td.num, .vs-items th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.vs-items tfoot td {
  font-weight: 700;
}
.vs-foot {
  font-size: 9px;
  color: #333;
  border-top: 1px solid #000;
  padding-top: 6px;
  margin-top: 6px;
}
.vs-sign {
  display: flex;
  justify-content: space-between;
  margin-top: 16px;
  font-size: 9px;
}
.vs-sign div {
  border-top: 1px solid #000;
  padding-top: 2px;
  width: 45%;
  text-align: center;
}

/* ================== RESPONSIVE ================== */
@media (max-width: 760px) {
  .app-header { flex-wrap: wrap; gap: 12px; padding: 12px 16px; }
  .app-nav { order: 3; width: 100%; overflow-x: auto; }
  .app-main { padding: 20px 16px 48px; }
  h1 { font-size: 22px; }
  .form-grid { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: 1fr; }
  .quick-card { border-right: 0; border-bottom: 1px solid var(--rule); }
  .quick-card:last-child { border-bottom: 0; }
}
