:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1c2230;
  --muted: #687083;
  --border: #e3e6ec;
  --primary: #4338ca;
  --primary-soft: #eef0ff;
  --success: #15803d;
  --success-soft: #e8f6ed;
  --warning: #b45309;
  --warning-soft: #fdf3e2;
  --danger: #b91c1c;
  --danger-soft: #fdecec;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 88px;
}
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 1.35rem; margin: 0 0 4px; }
h2 { font-size: 1.05rem; margin: 0 0 12px; }
h3 { font-size: .95rem; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- Layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1100px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-size: .85rem;
}
.who { display: flex; align-items: center; gap: 10px; font-size: .85rem; color: var(--muted); }
.nav {
  max-width: 1100px; margin: 0 auto; padding: 0 12px;
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 10px 12px; color: var(--muted); font-weight: 500; white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.nav a.active { color: var(--primary); border-bottom-color: var(--primary); }
.nav .count {
  background: var(--danger); color: #fff; border-radius: 99px; font-size: .7rem;
  padding: 1px 6px; margin-left: 4px; vertical-align: 1px;
}
main { max-width: 1100px; margin: 0 auto; padding: 20px 16px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px;
}
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr; }
@media (min-width: 800px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (min-width: 800px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.kpi .label { font-size: .8rem; color: var(--muted); }
.kpi .value { font-size: 1.4rem; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: .78rem; color: var(--muted); }
.kpi.good .value { color: var(--success); }
.kpi.warn .value { color: var(--warning); }
.kpi.bad .value { color: var(--danger); }

.bar { height: 8px; border-radius: 99px; background: var(--border); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--success); border-radius: 99px; }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 9px 14px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer;
  min-height: 40px; white-space: nowrap;
}
.btn:hover { filter: brightness(.97); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-danger { color: var(--danger); }
.btn-whatsapp { background: #1fa855; border-color: #1fa855; color: #fff; }
.btn-sm { padding: 5px 10px; min-height: 32px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 4px; }
input, select, textarea {
  width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 10px; background: #fff; color: var(--text); min-height: 42px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; }
.field { margin-bottom: 12px; }
.form-grid { display: grid; gap: 0 12px; grid-template-columns: 1fr; }
@media (min-width: 600px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.inline-form { display: inline; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters > * { flex: 1 1 140px; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .75rem; font-weight: 600; text-transform: capitalize; }
.badge-paid, .badge-approved, .badge-present { background: var(--success-soft); color: var(--success); }
.badge-due, .badge-pending { background: var(--warning-soft); color: var(--warning); }
.badge-overdue, .badge-rejected, .badge-absent { background: var(--danger-soft); color: var(--danger); }
.badge-neutral { background: var(--primary-soft); color: var(--primary); }

/* ---------- Tables (stack into cards on phones) ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
.table th, .table td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .table.stack thead { display: none; }
  .table.stack, .table.stack tbody, .table.stack tr, .table.stack td { display: block; width: 100%; }
  .table.stack tr { border-bottom: 1px solid var(--border); padding: 8px 0; }
  .table.stack tr:last-child { border-bottom: 0; }
  .table.stack td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .table.stack td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; text-align: left; }
  .table.stack td.num { text-align: right; }
}

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 12px 0; border-bottom: 1px solid var(--border); display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.list li:last-child { border-bottom: 0; }
.list .title { font-weight: 600; }
.empty { color: var(--muted); text-align: center; padding: 20px 0; }

/* ---------- Flash ---------- */
.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; }
.flash-success { background: var(--success-soft); color: var(--success); }
.flash-error { background: var(--danger-soft); color: var(--danger); }

/* ---------- Floating collect button ---------- */
.fab {
  position: fixed; right: 16px; bottom: 20px; z-index: 20;
  background: var(--primary); color: #fff; font-weight: 700; padding: 14px 20px;
  border-radius: 99px; box-shadow: 0 8px 24px rgba(67, 56, 202, .35);
  display: flex; align-items: center; gap: 8px;
}
.fab:hover { filter: brightness(1.08); }

/* ---------- Collect page ---------- */
.student-due { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; background: var(--surface); }
.student-due summary { padding: 14px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 8px; list-style: none; }
.student-due summary::-webkit-details-marker { display: none; }
.student-due[open] summary { border-bottom: 1px solid var(--border); }
.due-item { padding: 14px; border-bottom: 1px solid var(--border); }
.due-item:last-child { border-bottom: 0; }
.method-pick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 10px 0; }
.method-pick label {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px; text-align: center;
  font-weight: 600; cursor: pointer; margin: 0;
}
.method-pick input { display: none; }
.method-pick input:checked + span { color: var(--primary); }
.method-pick label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }

/* ---------- Slots ---------- */
.slot { display: flex; gap: 14px; align-items: center; }
.slot-date {
  min-width: 54px; text-align: center; background: var(--primary-soft); color: var(--primary);
  border-radius: 10px; padding: 6px 4px; line-height: 1.15;
}
.slot-date .d { font-size: 1.2rem; font-weight: 700; display: block; }
.slot-date .m { font-size: .72rem; text-transform: uppercase; font-weight: 600; }
.slot-info { flex: 1; min-width: 0; }

/* ---------- Progress ---------- */
.progress-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.stat-row { display: flex; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.stat-row div { flex: 1; min-width: 110px; }
.stat-row .v { font-size: 1.2rem; font-weight: 700; }
.comment { background: var(--bg); border-radius: 8px; padding: 8px 10px; margin-top: 6px; font-size: .9rem; }

/* ---------- Login & mock checkout ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; }
.checkout { max-width: 420px; margin: 0 auto; }
.checkout-head { background: #0b1e4a; color: #fff; border-radius: var(--radius) var(--radius) 0 0; padding: 18px; margin: -16px -16px 16px; }
.checkout-head .amt { font-size: 1.8rem; font-weight: 700; }
.demo-tag { background: #fde68a; color: #78350f; font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.success-icon {
  width: 64px; height: 64px; border-radius: 50%; background: var(--success-soft); color: var(--success);
  display: grid; place-items: center; font-size: 2rem; margin: 8px auto 12px;
}
.spinner { display: none; width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.loading .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

pre.mail { white-space: pre-wrap; font: inherit; font-size: .88rem; background: var(--bg); padding: 10px; border-radius: 8px; margin: 8px 0 0; }
[hidden] { display: none !important; }
