/* Tuition app: mobile-first, no framework. */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #16202a;
  --muted: #5d6b78;
  --line: #e3e8ee;
  --primary: #0f766e;
  --primary-dark: #0b5e58;
  --primary-soft: #e6f4f2;
  --danger: #c0262d;
  --danger-soft: #fdecec;
  --warn: #a15c07;
  --warn-soft: #fdf3e1;
  --ok: #1b7a3d;
  --ok-soft: #e7f6ec;
  --whatsapp: #128c4b;
  --cash: #0f766e;
  --upi: #5b4bc4;
  --bank: #c26a12;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .05);
  --nav-h: 64px;
  font-size: 16px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  line-height: 1.45; -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; line-height: 1.2; margin: 0 0 .2rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
h3 { font-size: .95rem; margin: 1.1rem 0 .5rem; }
p { margin: .4rem 0; }
code { font-size: .85em; background: #eef1f4; padding: .05rem .3rem; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.lead { font-size: 1.05rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; }
.text-danger { color: var(--danger); }
.strike { text-decoration: line-through; color: var(--muted); }
.icon { width: 1.25em; height: 1.25em; flex: none; vertical-align: -.25em; }

/* ---------- layout ---------- */
.main { max-width: 1080px; margin: 0 auto; padding: 1rem 1rem calc(var(--nav-h) + 1.5rem + env(safe-area-inset-bottom)); }
.no-nav .main { padding-bottom: 2rem; }

.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .75rem;
  padding: .6rem 1rem; padding-top: calc(.6rem + env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .6rem; color: var(--text); font-weight: 650; min-width: 0; flex: 1; }
.brand:hover { text-decoration: none; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: var(--primary); color: #fff; font-weight: 700;
}
.brand-mark.lg { width: 52px; height: 52px; font-size: 1.5rem; border-radius: 14px; }
.topbar-actions { display: flex; gap: .25rem; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; color: var(--muted);
}
.icon-btn:hover, .icon-btn.active { background: var(--bg); color: var(--text); text-decoration: none; }
.icon-btn.disabled { visibility: hidden; }
.avatar {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary-dark); font-weight: 700; font-size: .85rem;
}

/* Bottom tab bar on phones */
.side-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); height: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
.side-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem;
  color: var(--muted); font-size: .72rem; font-weight: 550;
}
.side-nav a .icon { width: 24px; height: 24px; }
.side-nav a.active { color: var(--primary); }
.side-nav a:hover { text-decoration: none; color: var(--text); }

@media (min-width: 900px) {
  .side-nav { position: static; height: auto; border: 0; padding: 0; gap: .25rem; flex: none; background: none; }
  .side-nav a { flex-direction: row; font-size: .92rem; padding: .5rem .8rem; border-radius: 10px; gap: .45rem; }
  .side-nav a .icon { width: 20px; height: 20px; }
  .side-nav a.active { background: var(--primary-soft); color: var(--primary-dark); }
  .main { padding: 1.5rem 1.5rem 3rem; }
}

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem; margin: .25rem 0 1rem; }
.page-head > div:first-child { min-width: 0; }
.back-link { display: inline-flex; align-items: center; gap: .2rem; font-size: .88rem; color: var(--muted); margin-bottom: .3rem; }
.grid-2 { display: grid; gap: 1rem; }
.grid-2.tight { gap: 0 .9rem; }
@media (min-width: 720px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.collect-grid { align-items: start; }
.form-narrow { max-width: 640px; }
.action-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .75rem 0; }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1rem; margin-bottom: 1rem;
}
.grid-2 > .card { margin-bottom: 0; }
.grid-2 { margin-bottom: 1rem; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .list { padding: 0 1rem; }
.padded { padding: 1rem; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: .5rem; }
.card-head h2 { margin: 0; }
.card-head.padded { margin: 0; border-bottom: 1px solid var(--line); }
.empty-state { text-align: center; padding: 2rem 1rem; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin-bottom: 1rem; }
@media (min-width: 900px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat {
  display: flex; flex-direction: column; gap: .1rem; padding: .9rem 1rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
a.stat:hover { text-decoration: none; border-color: #c9d2db; }
.stat-label { font-size: .8rem; color: var(--muted); font-weight: 550; display: flex; align-items: center; gap: .35rem; }
.stat-value { font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: .78rem; color: var(--muted); }
.stat-warn .stat-value { color: var(--danger); }

.progress { height: 10px; border-radius: 99px; background: #edf1f4; overflow: hidden; margin: .5rem 0; }
.progress span { display: block; height: 100%; width: 0; background: var(--primary); border-radius: 99px; transition: width .4s; }
.progress-row { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.badge { background: var(--primary-soft); color: var(--primary-dark); font-weight: 700; font-size: .85rem; padding: .15rem .55rem; border-radius: 99px; }

.mode-list { list-style: none; padding: 0; margin: 0; }
.mode-list li { display: grid; grid-template-columns: auto 1fr auto auto; gap: .6rem; align-items: center; padding: .45rem 0; border-top: 1px solid var(--line); }
.mode-list li:first-child { border-top: 0; }
.mode-list strong { font-variant-numeric: tabular-nums; min-width: 5.5rem; text-align: right; }
.mode-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--muted); }
.mode-cash { background: var(--cash); } .mode-upi { background: var(--upi); } .mode-bank { background: var(--bank); }

.bars { display: flex; align-items: stretch; gap: .5rem; height: 190px; padding-top: .25rem; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .3rem; color: var(--muted); min-width: 0; }
.bar-col:hover { text-decoration: none; color: var(--text); }
.bar-val { font-size: .72rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.bar-track { flex: 1; width: 100%; max-width: 44px; display: flex; align-items: flex-end; }
.bar { display: block; width: 100%; height: 0; min-height: 2px; background: #9fd3cd; border-radius: 6px 6px 2px 2px; transition: height .4s; }
.bar-current { background: var(--primary); }
.bar-label { font-size: .75rem; }

.att-summary { display: flex; gap: 2rem; flex-wrap: wrap; }
.att-summary > div { display: flex; flex-direction: column; }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-row { display: flex; align-items: center; gap: .6rem; padding: .7rem 0; border-top: 1px solid var(--line); }
.list > .list-row:first-child, .list-group + .list-row { border-top: 0; }
.list.compact .list-row { padding: .45rem 0; }
.list-main { flex: 1; min-width: 0; display: flex; flex-direction: column; color: var(--text); }
a.list-main:hover { text-decoration: none; }
a.list-main:hover strong { color: var(--primary); }
.list-main strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-group { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: .9rem 0 .3rem; border-top: 1px solid var(--line); }
.list > .list-group:first-child { border-top: 0; padding-top: .7rem; }
.amount { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.is-cancelled .amount, .is-cancelled strong { color: var(--muted); }
.is-cancelled .list-main strong { text-decoration: line-through; }

.pill { display: inline-block; font-size: .75rem; font-weight: 650; padding: .15rem .55rem; border-radius: 99px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-muted { background: #eef1f4; color: var(--muted); }
h1 .pill { vertical-align: middle; font-size: .8rem; }

.row-menu { position: relative; }
.row-menu > summary { list-style: none; cursor: pointer; padding: .3rem .55rem; border-radius: 8px; color: var(--muted); font-size: 1.1rem; line-height: 1; }
.row-menu > summary::-webkit-details-marker { display: none; }
.row-menu > summary:hover, .row-menu[open] > summary { background: var(--bg); color: var(--text); }
.row-menu-body {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 10; min-width: 250px; display: flex; flex-direction: column; gap: .5rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .75rem; box-shadow: 0 8px 24px rgba(16, 24, 40, .14);
}

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: .3rem; margin: 0 0 .9rem; border: 0; padding: 0; min-width: 0; }
.field > span:first-child, .field legend { font-size: .86rem; font-weight: 600; color: #34424f; padding: 0; }
.field.inline { flex-direction: row; align-items: center; gap: .5rem; margin: 0; }
.field.inline > span:first-child { white-space: nowrap; }
.hint { font-size: .78rem; color: var(--muted); }
input, select, textarea {
  font: inherit; color: inherit; width: 100%; padding: .65rem .75rem; min-height: 44px;
  background: #fff; border: 1px solid #cfd7df; border-radius: 10px;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, .chip:focus-visible {
  outline: 3px solid rgba(15, 118, 110, .25); outline-offset: 1px; border-color: var(--primary);
}
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; }
input[type="file"] { padding: .45rem; }
textarea { resize: vertical; }
.input-sm { width: 7rem; }
.input-amount { font-size: 1.6rem; font-weight: 700; padding: .55rem .8rem; font-variant-numeric: tabular-nums; }
.check { display: inline-flex; align-items: center; gap: .45rem; font-size: .9rem; }
.inline-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.inline-form input:not([type=hidden]), .inline-form select { flex: 1 1 10rem; width: auto; }
.inline-form .input-sm { flex: 0 0 7rem; }

.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.filters select { width: auto; flex: 1 1 9rem; }
.filters .search-box { flex: 2 1 14rem; }
.filters .chips { flex-basis: 100%; }

.search-box { position: relative; display: block; }
.search-box .icon { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-box input { padding-left: 2.4rem; }
#student-search { font-size: 1.1rem; min-height: 52px; }
.search-results:empty { display: none; }
.search-results { margin-top: .5rem; }

.segmented { display: flex; background: #edf1f4; border-radius: 12px; padding: 4px; gap: 4px; }
.segmented label { flex: 1; position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; }
.segmented span {
  display: block; text-align: center; padding: .6rem .5rem; border-radius: 9px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.segmented input:checked + span { background: #fff; color: var(--primary-dark); box-shadow: var(--shadow); }
.segmented input:focus-visible + span { outline: 3px solid rgba(15, 118, 110, .25); }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: -.4rem 0 .6rem; }
.filters .chips { margin: 0; }
.chip {
  font: inherit; font-size: .84rem; font-weight: 600; padding: .35rem .75rem; border-radius: 99px; cursor: pointer;
  background: var(--primary-soft); color: var(--primary-dark); border: 1px solid transparent;
}
.chip:hover { border-color: var(--primary); text-decoration: none; }

details.more { margin: .25rem 0 1rem; }
details.more > summary { cursor: pointer; color: var(--primary); font-weight: 600; font-size: .9rem; padding: .3rem 0; }
details.more[open] > summary { margin-bottom: .6rem; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 600; font-size: .92rem;
  min-height: 42px; padding: .5rem 1rem; border-radius: 10px; cursor: pointer; white-space: nowrap;
  background: #fff; color: var(--text); border: 1px solid #cfd7df;
}
.btn:hover { text-decoration: none; background: #f7f9fb; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: #f0b8bb; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-whatsapp { color: var(--whatsapp); border-color: #b5dfc8; }
.btn-whatsapp:hover { background: #ebf7f0; }
.btn-link { background: none; border: 0; color: var(--danger); padding-left: 0; }
.btn-sm { min-height: 36px; padding: .3rem .7rem; font-size: .84rem; }
.btn-lg { min-height: 52px; font-size: 1.05rem; padding: .7rem 1.3rem; border-radius: 12px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: default; }

.collect-cta { box-shadow: 0 6px 16px rgba(15, 118, 110, .28); }
@media (max-width: 599px) {
  .collect-cta { width: 100%; }
}

/* ---------- flash ---------- */
.flash { padding: .75rem 1rem; border-radius: 12px; margin-bottom: 1rem; font-size: .92rem; border: 1px solid; }
.flash-success { background: var(--ok-soft); border-color: #bfe5cc; color: #14532d; }
.flash-error { background: var(--danger-soft); border-color: #f5c2c4; color: #7f1d1d; }

/* ---------- collect ---------- */
.due-banner { display: flex; flex-direction: column; padding: .85rem 1rem; border-radius: 12px; margin-bottom: 1rem; }
.due-banner strong { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.due-banner span:first-child { font-size: .82rem; font-weight: 600; }
.due-overdue { background: var(--danger-soft); color: #7f1d1d; }
.due-pending { background: var(--warn-soft); color: #6b3d06; }
.due-clear { background: var(--ok-soft); color: #14532d; }

.success-hero { text-align: center; padding: 1.5rem 0 .5rem; }
.success-check { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); margin-bottom: .5rem; }
.success-check .icon { width: 34px; height: 34px; }
.success-hero + .flash + .action-row, .success-hero + .action-row { justify-content: center; }

.receipt-card.is-cancelled { opacity: .7; }
.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem 1rem; margin: 0 0 1rem; }
.kv dt { font-size: .76rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.kv dd { margin: 0; font-weight: 550; }

/* ---------- profile ---------- */
.balance-card { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1rem; border-left: 5px solid var(--ok); }
.balance-card.is-pending { border-left-color: #e0a43a; }
.balance-card.is-overdue { border-left-color: var(--danger); }
.balance-main { display: flex; flex-direction: column; }
.balance-value { font-size: 2.1rem; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.is-overdue .balance-value { color: var(--danger); }
.balance-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
@media (max-width: 599px) { .balance-actions, .balance-actions .btn { width: 100%; } }

.danger-zone > summary { cursor: pointer; font-weight: 600; color: var(--muted); }
.danger-zone[open] > summary { margin-bottom: .6rem; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: .6rem 1rem; text-align: left; border-bottom: 1px solid var(--line); }
.table thead th { font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #fafbfc; }
.table tfoot th { border-bottom: 0; font-size: 1rem; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.is-cancelled td { color: var(--muted); text-decoration: line-through; }
.table tr.is-selected td { background: var(--primary-soft); }
.receipt-card .table th, .receipt-card .table td { padding-left: 0; padding-right: 0; }

.att-table th, .att-table td { padding: .45rem .5rem; }
.att-table .day { text-align: center; min-width: 2rem; font-size: .8rem; }
.att-table .day-A { background: var(--danger-soft); color: var(--danger); font-weight: 700; }
.att-table .day-P { color: var(--ok); }
.sticky-col { position: sticky; left: 0; background: var(--surface); z-index: 1; white-space: nowrap; }
thead .sticky-col { background: #fafbfc; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: .25rem; margin-bottom: 1rem; background: #e9edf1; padding: 4px; border-radius: 12px; overflow-x: auto; }
.tabs a { flex: 1; text-align: center; padding: .55rem .75rem; border-radius: 9px; color: var(--muted); font-weight: 600; font-size: .9rem; white-space: nowrap; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.active { background: #fff; color: var(--primary-dark); box-shadow: var(--shadow); }

/* ---------- attendance ---------- */
.date-nav { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .5rem; }
.date-nav form { flex: 1; max-width: 14rem; }
.date-nav input { text-align: center; }
.date-nav.compact { padding: 0; }
.date-nav strong { flex: 1; text-align: center; }
.batch-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin-top: 1rem; }
@media (min-width: 720px) { .batch-grid { grid-template-columns: repeat(4, 1fr); } }
.batch-tile {
  display: flex; flex-direction: column; gap: .3rem; padding: 1rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.batch-tile:hover { text-decoration: none; border-color: var(--primary); }
.batch-tile.is-done { background: var(--ok-soft); border-color: #bfe5cc; }
.batch-name { font-size: 1.15rem; font-weight: 700; }
.batch-status { font-size: .82rem; display: flex; align-items: center; gap: .3rem; }
.is-done .batch-status { color: var(--ok); font-weight: 600; }

.att-toolbar { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .6rem 1rem; position: sticky; top: 62px; z-index: 5; }
.att-list { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .5rem; }
@media (min-width: 720px) { .att-list { grid-template-columns: 1fr 1fr; } }
.att-item {
  display: flex; align-items: center; gap: .75rem; padding: .85rem 1rem; cursor: pointer; user-select: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; min-height: 56px;
  -webkit-tap-highlight-color: transparent;
}
.att-item input { position: absolute; opacity: 0; pointer-events: none; }
.att-name { flex: 1; font-weight: 600; }
.att-state .p { color: var(--ok); background: var(--ok-soft); }
.att-state .a { display: none; color: #fff; background: var(--danger); }
.att-state span { font-size: .8rem; font-weight: 700; padding: .3rem .7rem; border-radius: 99px; }
.att-item:has(input:checked) { border-color: #f0b8bb; background: var(--danger-soft); }
.att-item:has(input:checked) .p { display: none; }
.att-item:has(input:checked) .a { display: inline; }
.att-item:has(input:focus-visible) { outline: 3px solid rgba(15, 118, 110, .25); }
.att-item:has(input:disabled) { cursor: default; opacity: .8; }
.sticky-submit {
  position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + .5rem); z-index: 5;
}
@media (min-width: 900px) { .sticky-submit { bottom: 1rem; } }

/* ---------- auth & misc ---------- */
.auth-wrap { min-height: 85vh; display: grid; place-items: center; }
.auth-card { width: 100%; max-width: 380px; padding: 1.5rem; }
.auth-brand { text-align: center; margin-bottom: 1.25rem; }
.auth-brand h1 { margin-top: .6rem; }
.settings-links { display: grid; gap: .75rem; margin-bottom: 1rem; }
@media (min-width: 720px) { .settings-links { grid-template-columns: repeat(3, 1fr); } }
.link-card { display: flex; align-items: center; gap: .75rem; margin: 0; color: var(--text); }
.link-card:hover { text-decoration: none; border-color: var(--primary); }
.link-card > span { flex: 1; display: flex; flex-direction: column; }
.link-card > .icon:first-child { color: var(--primary); width: 24px; height: 24px; }
.logo-preview { max-width: 120px; max-height: 120px; display: block; margin-bottom: .75rem; border-radius: 8px; border: 1px solid var(--line); }

@media print {
  .topbar, .side-nav, .action-row, .danger-zone, .filters { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
