:root {
  --navy: #010A35;
  --navy-2: #0A1440;
  --slate: #032D72;
  --blue: #0670DE;
  --blue-light: #5AAEFF;
  --pale: #EEF5FE;
  --border: #C9DBF7;
  --muted: #5A6B8C;
  --green: #0E9F6E;
  --red: #DC2626;
  --bg: #F5F8FD;
  --radius: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--navy);
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}

h1, h2, h3, .brand-name, .hero-amount, .stat-val, .pill-val, .tab-btn, .btn-primary {
  font-family: 'Sora', sans-serif;
}

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--navy);
  color: #fff;
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 12px rgba(1,10,53,.25);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { height: 26px; width: auto; display: block; }
.brand .brand-sub { border-left: 1px solid rgba(255,255,255,.25); padding-left: 10px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--blue); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Sora', sans-serif; font-weight: 800; font-size: 20px;
}
.brand-name { font-weight: 800; font-size: 14px; letter-spacing: .08em; }
.brand-sub { font-size: 11px; color: var(--blue-light); }
.icon-btn {
  background: rgba(255,255,255,.12); color: #fff; border: none;
  width: 36px; height: 36px; border-radius: 10px; font-size: 18px;
}
.icon-btn:active { background: rgba(255,255,255,.25); }

main { max-width: 720px; margin: 0 auto; padding: 16px; }

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Hero */
.hero-card {
  background: linear-gradient(135deg, var(--navy) 0%, var(--slate) 60%, var(--blue) 130%);
  color: #fff; border-radius: var(--radius);
  padding: 22px 20px; margin-bottom: 14px;
  box-shadow: 0 8px 24px rgba(1,10,53,.28);
}
.hero-label { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--blue-light); }
.hero-amount { font-size: 36px; font-weight: 800; margin: 6px 0 16px; }
.hero-row { display: flex; gap: 10px; }
.hero-pill {
  flex: 1; display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.10); border-radius: 12px; padding: 10px 12px;
}
.pill-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.pill-dot.in { background: #34D399; }
.pill-dot.out { background: #F87171; }
.pill-label { font-size: 11px; color: var(--blue-light); }
.pill-val { font-size: 15px; font-weight: 700; }

/* Cards */
.card {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.card-title { font-family: 'Sora', sans-serif; font-weight: 700; font-size: 14px; margin-bottom: 12px; color: var(--navy-2); }
.fees-row { display: flex; gap: 8px; justify-content: space-between; }
.fees-row > div { flex: 1; }
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat-val { font-size: 17px; font-weight: 700; margin-top: 2px; }
.stat-val.green, .green { color: var(--green); }
.stat-val.red, .red { color: var(--red); }

.progress { height: 8px; background: var(--pale); border-radius: 99px; margin-top: 12px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--blue), var(--blue-light)); border-radius: 99px; transition: width .4s ease; }

/* Category bars */
.bars .bar-row { margin-bottom: 10px; }
.bar-head { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 4px; }
.bar-head .amt { font-weight: 600; }
.bar-track { height: 6px; background: var(--pale); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--blue); border-radius: 99px; }

/* Transaction lists */
.list-head { display: flex; align-items: baseline; justify-content: space-between; margin: 4px 2px 12px; }
.list-title { font-family: 'Sora', sans-serif; font-weight: 700; font-size: 18px; }
.list-total { font-weight: 700; font-size: 15px; }
.tx-list { display: flex; flex-direction: column; gap: 8px; }
.tx-item {
  background: #fff; border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 14px; display: flex; align-items: center; gap: 12px;
}
.tx-ico {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 17px;
}
.tx-ico.in { background: #E7F8F1; color: var(--green); }
.tx-ico.out { background: #FEF2F2; color: var(--red); }
.tx-body { flex: 1; min-width: 0; }
.tx-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-amt { font-weight: 700; font-size: 14.5px; white-space: nowrap; }
.tx-del { border: none; background: none; color: var(--border); font-size: 16px; padding: 6px; }
.tx-del:active { color: var(--red); }
.empty-note { font-size: 13px; color: var(--muted); padding: 8px 2px; }

/* Students */
.student-list { display: flex; flex-direction: column; gap: 10px; }
.student-card { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 14px; }
.student-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.student-name { font-weight: 700; font-size: 15px; }
.badge { font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 99px; }
.badge.Paid { background: #E7F8F1; color: var(--green); }
.badge.Partial { background: #FFF7E6; color: #B45309; }
.badge.Unpaid { background: #FEF2F2; color: var(--red); }
.student-meta { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.student-nums { display: flex; gap: 16px; margin-top: 10px; }
.student-nums .stat-label { font-size: 10.5px; }
.student-nums .stat-val { font-size: 14.5px; }
.student-actions { display: flex; gap: 8px; margin-top: 12px; }
.btn-small {
  border: 1px solid var(--border); background: var(--pale); color: var(--slate);
  font-weight: 600; font-size: 12.5px; padding: 8px 14px; border-radius: 10px;
}
.btn-small.danger { background: #FEF2F2; color: var(--red); border-color: #FECACA; }

/* FAB */
.fab {
  position: fixed; right: 18px; bottom: calc(88px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--blue); color: #fff; border: none;
  font-size: 28px; font-weight: 400; line-height: 1;
  box-shadow: 0 6px 18px rgba(6,112,222,.45); z-index: 30;
}
.fab:active { transform: scale(.94); }

/* Tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  background: #fff; border-top: 1px solid var(--border);
  display: flex; padding-bottom: env(safe-area-inset-bottom);
}
.tab-btn {
  flex: 1; border: none; background: none; padding: 10px 0 12px;
  font-size: 11.5px; font-weight: 600; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.tab-btn .tab-ico { font-size: 17px; }
.tab-btn.active { color: var(--blue); }

/* Bottom sheet form */
.overlay {
  position: fixed; inset: 0; background: rgba(1,10,53,.5); z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
}
.overlay.hidden { display: none; }
.sheet {
  background: #fff; width: 100%; max-width: 720px;
  border-radius: 20px 20px 0 0; padding: 12px 20px calc(20px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y: auto; animation: slideUp .22s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-handle { width: 40px; height: 4px; background: var(--border); border-radius: 99px; margin: 2px auto 12px; }
.sheet-title { font-family: 'Sora', sans-serif; font-weight: 700; font-size: 17px; margin-bottom: 14px; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .05em; }
.field input, .field select, .field textarea {
  width: 100%; border: 1.5px solid var(--border); border-radius: 12px;
  padding: 12px 14px; font-size: 15px; font-family: 'Inter', sans-serif;
  background: var(--pale); color: var(--navy); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); background: #fff; }
.field textarea { resize: vertical; min-height: 60px; }
.form-row { display: flex; gap: 10px; }
.form-row .field { flex: 1; }
.form-error { color: var(--red); font-size: 13px; margin-bottom: 10px; min-height: 16px; }

.btn-primary {
  width: 100%; border: none; background: var(--blue); color: #fff;
  font-weight: 700; font-size: 15px; padding: 14px; border-radius: 12px; margin-top: 4px;
}
.btn-primary:active { background: var(--slate); }
.btn-primary:disabled { opacity: .6; }
.btn-ghost {
  width: 100%; border: none; background: none; color: var(--muted);
  font-weight: 600; font-size: 14px; padding: 12px; margin-top: 6px;
}

/* Toast & loading */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(150px + env(safe-area-inset-bottom));
  background: var(--navy); color: #fff; font-size: 13.5px; font-weight: 500;
  padding: 10px 18px; border-radius: 99px; z-index: 50;
  box-shadow: 0 4px 16px rgba(1,10,53,.35);
}
.toast.hidden { display: none; }
.loading {
  position: fixed; inset: 0; background: rgba(245,248,253,.7);
  display: flex; align-items: center; justify-content: center; z-index: 60;
}
.loading.hidden { display: none; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3.5px solid var(--border); border-top-color: var(--blue);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 640px) {
  .hero-amount { font-size: 44px; }
  .card-title { font-size: 15px; }
}

/* PIN gate */
.pin-gate {
  position: fixed; inset: 0; z-index: 100;
  background: var(--navy, #010A35);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.pin-gate.hidden { display: none; }
.pin-card {
  width: 100%; max-width: 340px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.pin-logo { height: 40px; width: auto; margin-bottom: 4px; }
.pin-title { font-family: Sora, sans-serif; font-weight: 700; color: #fff; font-size: 20px; }
.pin-sub { color: #5AAEFF; font-size: 13px; margin-bottom: 14px; }
.pin-card form { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.pin-input {
  width: 100%; padding: 14px 16px; font-size: 17px; text-align: center;
  letter-spacing: .12em; border-radius: 12px; border: 1px solid #C9DBF7;
  background: rgba(255,255,255,.08); color: #fff; outline: none;
  text-transform: uppercase;
}
.pin-input::placeholder { color: #5A6B8C; letter-spacing: normal; text-transform: none; }
.pin-input:focus { border-color: #0670DE; }
