/* Tuition manager — mobile-first, light theme */
:root {
  /* Black & blue theme */
  color-scheme: dark;
  --bg: #050608; --card: #0f1115; --ink: #e8edf5; --muted: #8b95a7; --line: #1f2430; --soft: #171a21; --input: #0b0d11; --input-line: #2a303d;
  --brand: #3b82f6; --brand-ink: #fff; --brand-soft: rgba(59,130,246,.16); --brand-glow: rgba(59,130,246,.35);
  --green: #34d399; --green-soft: rgba(52,211,153,.13); --red: #f87171; --red-soft: rgba(248,113,113,.13);
  --amber: #fbbf24; --amber-soft: rgba(251,191,36,.14); --blue: #60a5fa; --blue-soft: rgba(96,165,250,.15); --gray-soft: #1c2029;
  --late: #f59e0b; --excused: #64748b; --bar: #1e3a8a;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.5);
  --tabbar-h: 64px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Ubuntu, sans-serif;
  color: var(--ink); background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; font-size: 15px; line-height: 1.45; min-height: 100vh; }
body.has-nav { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px); }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 650; }
p { margin: .4em 0; }
.muted { color: var(--muted); }
.small, small { font-size: 12.5px; }
.red { color: var(--red); } .green { color: var(--green); }
.center { text-align: center; }
.ic { flex: none; }

/* ---- Top bar ---- */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(5,6,8,.85); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 860px; margin: 0 auto; display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 12px; }
.topbar-in.wide { max-width: 1180px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; min-width: 0; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo, .auth-logo { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--brand); color: #fff; font-weight: 800; flex: none; }
.topbar-title { font-size: 17px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topnav { display: none; margin-left: auto; gap: 4px; }
.topnav a { padding: 8px 12px; border-radius: 9px; color: var(--muted); font-weight: 550; }
.topnav a.on, .topnav a:hover { background: var(--soft); color: var(--ink); }
.logout { margin-left: auto; }
.topnav + .logout { margin-left: 4px; }
.iconbtn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; color: var(--ink); background: none; border: 0; cursor: pointer; }
.iconbtn:hover { background: var(--soft); }

/* ---- Bottom tab bar (mobile) ---- */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; background: #0a0c10; border-top: 1px solid var(--line);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; color: var(--muted); font-weight: 550; }
.tabbar a.on { color: var(--brand); }

/* ---- Floating Collect button ---- */
.fab { position: fixed; z-index: 25; right: 16px; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px);
  display: flex; align-items: center; gap: 8px; padding: 0 20px; height: 52px; border-radius: 26px;
  background: var(--brand); color: #fff; font-weight: 650; box-shadow: 0 8px 24px var(--brand-glow); }
.fab:active { transform: scale(.97); }

/* ---- Page ---- */
.page { max-width: 860px; margin: 0 auto; padding: 16px 12px 24px; display: flex; flex-direction: column; gap: 14px; }
.page.wide { max-width: 1180px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-h { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 6px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.link { color: var(--brand); font-weight: 550; cursor: pointer; }
.grid2 { display: grid; gap: 14px; }
.empty { text-align: center; padding: 32px 16px; }
.empty-sm { color: var(--muted); padding: 10px 0; margin: 0; list-style: none; }

/* ---- Flash ---- */
.flash { padding: 11px 14px; border-radius: 11px; font-weight: 550; }
.flash.ok { background: var(--green-soft); color: var(--green); }
.flash.err { background: var(--red-soft); color: var(--red); }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 42px; padding: 0 16px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.primary, .fab { background: linear-gradient(135deg, #2563eb, #3b82f6); }
.btn.ghost { background: transparent; }
.btn.danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn.danger.ghost { background: transparent; color: var(--red); border-color: var(--red-soft); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 9px; }
.btn.xl { height: 54px; font-size: 17px; border-radius: 14px; }
.btn.block { width: 100%; }
.btn.disabled { opacity: .35; pointer-events: none; }
.btn:disabled { opacity: .6; cursor: default; }

/* ---- Forms ---- */
label { display: flex; flex-direction: column; gap: 6px; font-weight: 550; font-size: 14px; }
input, select, textarea { font: inherit; font-size: 16px; color: var(--ink); background: var(--input); border: 1px solid var(--input-line); border-radius: 10px; padding: 10px 12px; width: 100%; min-height: 44px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
textarea { resize: vertical; }
input[type="radio"], input[type="checkbox"] { width: auto; min-height: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row2, .row3 { display: grid; gap: 14px; }
.form-h { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding-top: 4px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.inline-form input { flex: 1 1 140px; min-height: 38px; padding: 7px 10px; font-size: 15px; }
.danger-zone { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 0 4px; }
label.check { flex-direction: row; align-items: center; gap: 8px; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 550; font-size: 14px; margin-bottom: 6px; padding: 0; }

/* ---- Search & filter chips ---- */
.searchbar { position: relative; }
.searchbar input { padding-left: 40px; border-radius: 12px; }
.searchbar .search-ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); display: flex; }
.searchbar.big input { min-height: 52px; font-size: 17px; }
.chips-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips-row::-webkit-scrollbar { display: none; }
.fchip { flex: none; display: inline-flex; align-items: center; height: 34px; padding: 0 13px; border-radius: 17px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-size: 14px; font-weight: 550; cursor: pointer; }
.fchip.sm { height: 30px; font-size: 13px; }
.fchip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.fchip.on.red { background: #dc2626; border-color: #dc2626; }

/* ---- Chips ---- */
.chip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.red { background: var(--red-soft); color: var(--red); }
.chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.blue { background: var(--blue-soft); color: var(--blue); }
.chip.gray { background: var(--gray-soft); color: var(--muted); }

/* ---- Lists ---- */
.list { list-style: none; margin: 0; padding: 0; }
.list.card { padding: 4px 14px; }
.list li { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list-main { display: flex; align-items: center; gap: 11px; flex: 1; min-width: 0; color: var(--ink); }
.list-main > strong, .list-text strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-main:not(:has(.list-text)) { flex-direction: column; align-items: flex-start; gap: 1px; }
.list-text { display: flex; flex-direction: column; min-width: 0; }
.list-text .small, .list-main .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; max-width: 100%; }
.amt { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 6px; }
li.voided { opacity: .55; }
.avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-weight: 700; flex: none; }
.avatar.lg { width: 54px; height: 54px; font-size: 22px; }

/* ---- Stats ---- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 14px; color: var(--ink); min-width: 0; }
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 550; }
.stat-val { font-size: 22px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-sub { font-size: 12.5px; color: var(--muted); }
.stat.accent { background: linear-gradient(135deg, #1d4ed8, #3b82f6); border-color: #2563eb; color: #fff; }
.stat.accent .stat-label, .stat.accent .stat-sub { color: rgba(255,255,255,.82); }
.stat.warn .stat-val { color: var(--red); }
.progress { height: 7px; background: var(--soft); border-radius: 4px; overflow: hidden; margin-top: 6px; min-width: 60px; }
.progress span { display: block; height: 100%; background: var(--brand); border-radius: 4px; }
.modes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.mode { display: flex; gap: 8px; align-items: center; background: var(--soft); border-radius: 9px; padding: 6px 10px; font-size: 13.5px; }

/* ---- Chart ---- */
.chart { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--bar); } .chart .bar.cur { fill: var(--brand); }
.chart .bar-val { font-size: 19px; font-weight: 650; fill: var(--ink); }
.chart .bar-lbl { font-size: 18px; fill: var(--muted); }
.chart .axis { stroke: var(--line); }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tfoot td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table tr.voided td { opacity: .5; text-decoration: line-through; }
.prog-cell { min-width: 90px; }

/* ---- Attendance ---- */
.att-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.att-tile { display: flex; flex-direction: column; gap: 2px; padding: 10px; border-radius: 11px; background: var(--soft); color: var(--ink); border: 1px solid transparent; font-size: 12.5px; }
.att-tile strong { font-size: 16px; }
.att-tile span { color: var(--muted); }
.att-tile.done { background: var(--green-soft); }
.att-grid.big { grid-template-columns: repeat(2, 1fr); }
.att-grid.big .att-tile { padding: 14px; background: var(--card); border-color: var(--line); box-shadow: var(--shadow); }
.att-grid.big .att-tile strong { font-size: 20px; }
.att-grid.big .att-tile em { font-style: normal; font-weight: 650; color: var(--brand); margin-top: 4px; }
.att-grid.big .att-tile.done { background: var(--green-soft); border-color: rgba(52,211,153,.35); }
.att-grid.big .att-tile.done em { color: var(--green); }
.date-nav { display: flex; align-items: center; gap: 8px; padding: 8px; }
.date-nav input { text-align: center; }
.att-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; position: sticky; top: 64px; z-index: 5; }
.att-counts { display: flex; gap: 12px; font-weight: 650; font-size: 14px; }
.att-list { list-style: none; margin: 0; padding: 4px 12px; }
.att-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.att-list li:last-child { border-bottom: 0; }
.att-name { display: flex; flex-direction: column; min-width: 0; }
.att-name strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; flex: none; }
.seg label { display: block; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: grid; place-items: center; width: 40px; height: 38px; font-weight: 700; color: var(--muted); border-left: 1px solid var(--line); user-select: none; }
.seg label:first-child span { border-left: 0; }
.seg input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: -2px; }
.seg-P input:checked + span { background: #059669; color: #fff; }
.seg-A input:checked + span { background: #dc2626; color: #fff; }
.seg-L input:checked + span { background: var(--late); color: #fff; }
.seg-E input:checked + span { background: var(--excused); color: #fff; }
.sticky-save { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); padding-top: 4px; z-index: 5; }
.dots { display: grid; grid-template-columns: repeat(15, 1fr); gap: 5px; margin: 10px 0 4px; }
.dot { display: inline-block; width: 100%; aspect-ratio: 1; max-width: 18px; border-radius: 5px; background: var(--gray-soft); }
.legend .dot { width: 10px; height: 10px; vertical-align: -1px; margin: 0 3px 0 8px; }
.dot.P { background: var(--green); } .dot.A { background: var(--red); } .dot.L { background: var(--late); } .dot.E { background: var(--excused); }

/* ---- Profile ---- */
.profile { display: flex; flex-direction: column; gap: 14px; }
.profile-top { display: flex; align-items: center; gap: 12px; }
.profile-id { flex: 1; min-width: 0; }
.profile-id h1 { font-size: 20px; }
.pending-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; border-radius: 12px; }
.pending-box > div { display: flex; flex-direction: column; min-width: 0; }
.pending-box.due { background: var(--red-soft); }
.pending-box.clear { background: var(--green-soft); }
.pending-amt { font-size: 28px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.pending-box.due .pending-amt { color: var(--red); }
.pending-box.clear .pending-amt { color: var(--green); }
.contact-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.contact-row > span { font-weight: 550; margin-right: auto; }
.mini-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mini-stats > div { display: flex; flex-direction: column; background: var(--soft); border-radius: 11px; padding: 10px 12px; }
.mini-stats strong { font-size: 22px; }
.details dl, .kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 10px 0 0; }
dt { color: var(--muted); font-size: 13.5px; } dd { margin: 0; overflow-wrap: anywhere; }

/* ---- Ledger ---- */
.ledger { list-style: none; margin: 0; padding: 0; }
.ledger li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ledger li:last-child { border-bottom: 0; }
.ledger-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.ledger-side { display: flex; align-items: center; gap: 8px; }
.ledger.compact li { padding: 7px 0; }
.ledger.compact .ledger-main { flex-direction: row; gap: 6px; align-items: baseline; }
.ledger li.total { border-top: 2px solid var(--line); border-bottom: 0; }
.waive { width: 100%; }
.waive summary { list-style: none; display: inline; }
.waive summary::-webkit-details-marker { display: none; }

/* ---- Collect ---- */
.collect-head { padding: 12px 14px; }
.amount-field { font-size: 14px; }
.amount-input { display: flex; align-items: center; border: 2px solid var(--brand); border-radius: 14px; padding: 0 14px; background: var(--input); }
.amount-input .cur { font-size: 26px; font-weight: 700; color: var(--muted); }
.amount-input input { border: 0; outline: 0; background: transparent; font-size: 32px; font-weight: 800; padding: 8px 8px; min-height: 60px; letter-spacing: -.02em; }
.quick-amts { display: flex; flex-wrap: wrap; gap: 6px; }
.quick-amts:empty { display: none; }
.modes-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.modes-pick legend { grid-column: 1 / -1; }
.mode-opt { display: block; cursor: pointer; }
.mode-opt input { position: absolute; opacity: 0; pointer-events: none; }
.mode-opt span { display: grid; place-items: center; height: 44px; border: 1px solid var(--line); border-radius: 11px; font-weight: 600; font-size: 14px; text-align: center; padding: 0 4px; }
.mode-opt input:checked + span { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.mode-opt input:focus-visible + span { outline: 2px solid var(--brand); }
.advance { margin-top: 10px; font-size: 13.5px; }

/* ---- Receipt ---- */
.success-hero { text-align: center; padding: 18px 0 4px; }
.success-hero .tick { width: 64px; height: 64px; margin: 0 auto 10px; border-radius: 50%; background: #059669; color: #fff; display: grid; place-items: center; font-size: 34px; font-weight: 800; animation: pop .35s ease-out; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.receipt.is-void { opacity: .8; }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.action-grid .btn.primary { grid-column: 1 / -1; height: 50px; }
.void-box summary { cursor: pointer; color: var(--red); font-weight: 600; }

/* ---- Filters / reports ---- */
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px; }
.filters label { font-size: 12.5px; color: var(--muted); }
.report-link { color: var(--ink); display: flex; flex-direction: column; gap: 4px; }
.report-link:hover { border-color: var(--brand); }
.card:is(a):hover { border-color: #2b3445; }
.pager { display: flex; justify-content: space-between; }

/* ---- Settings ---- */
.fee-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.fee-cell { gap: 4px; }
details.sub { margin-top: 12px; }
details.sub summary { cursor: pointer; }
details.sub[open] summary { margin-bottom: 10px; }
.user-actions { text-align: right; }
.user-actions summary { list-style: none; }
.user-actions summary::-webkit-details-marker { display: none; }
.user-actions[open] { flex-basis: 100%; }
.list li:has(.user-actions[open]) { flex-wrap: wrap; }

/* ---- Auth ---- */
.auth { min-height: 90vh; display: grid; place-items: center; }
.auth-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 10px; padding: 26px 22px; }
.auth-logo { width: 48px; height: 48px; border-radius: 14px; font-size: 22px; }

.hide-sm { display: none; }
@media (max-width: 719px) { .hide-col { display: none; } }

/* ---- Larger screens ---- */
@media (min-width: 720px) {
  body.has-nav { padding-bottom: 24px; }
  .tabbar { display: none; }
  .topnav { display: flex; }
  .fab { bottom: 24px; right: 24px; }
  .page { padding: 24px 20px 40px; gap: 16px; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .grid2 { grid-template-columns: 1fr 1fr; }
  .row2 { grid-template-columns: 1fr 1fr; }
  .row3 { grid-template-columns: 1fr 1fr 1fr; }
  .att-grid.big { grid-template-columns: repeat(4, 1fr); }
  .att-grid { grid-template-columns: repeat(6, 1fr); }
  .fee-grid { grid-template-columns: repeat(4, 1fr); }
  .filters { grid-template-columns: repeat(5, auto); justify-content: start; align-items: end; }
  .action-grid { grid-template-columns: repeat(4, auto); justify-content: start; }
  .action-grid .btn.primary { grid-column: auto; height: 42px; }
  .sticky-save { bottom: 12px; }
  .hide-sm { display: inline-flex; }
  .att-bar { top: 64px; }
}
@media (max-width: 380px) {
  .seg span { width: 34px; }
  .stat-val { font-size: 19px; }
}
@media print {
  .topbar, .tabbar, .fab, .action-grid, .void-box { display: none !important; }
  body { background: #fff; color: #000; }
}
