/* Tuition Centre Manager — mobile-first styles */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f1f4f6;
  --ink: #111827;
  --ink-2: #374151;
  --muted: #6b7280;
  --line: #e3e7eb;
  --primary: #0f766e;
  --primary-2: #0d9488;
  --primary-soft: #e6f4f2;
  --on-primary: #ffffff;
  --danger: #c2410c;
  --danger-soft: #fff1ea;
  --red: #dc2626;
  --red-soft: #fdecec;
  --ok: #15803d;
  --ok-soft: #e8f6ed;
  --warn: #b45309;
  --warn-soft: #fff6e5;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(17, 24, 39, .05), 0 4px 14px rgba(17, 24, 39, .05);
  --nav-h: 68px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1416; --surface: #171e21; --surface-2: #1e272b; --ink: #f3f4f6; --ink-2: #d1d5db; --muted: #9aa4ad;
    --line: #2a3439; --primary: #2dd4bf; --primary-2: #5eead4; --primary-soft: #11302d; --on-primary: #04201d;
    --danger: #fb923c; --danger-soft: #3a2216; --red: #f87171; --red-soft: #3b1c1c; --ok: #4ade80; --ok-soft: #14301f;
    --warn: #fbbf24; --warn-soft: #3a2e12; --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.45;
  padding-bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom));
}
a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.tiny { font-size: .76rem; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- App bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid transparent;
}
.appbar-inner { max-width: 960px; margin: 0 auto; display: flex; align-items: center; gap: 8px; padding: 10px 16px; min-height: 56px; }
.appbar .brand { font-weight: 700; font-size: 1.05rem; color: var(--ink); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appbar .brand small { display: block; font-weight: 500; font-size: .75rem; color: var(--muted); }
.icon-btn {
  display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; border: 0; background: transparent;
  color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }

.wrap { max-width: 960px; margin: 0 auto; padding: 8px 16px 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 8px 0 16px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }

/* ---------- Bottom navigation ---------- */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav-inner { max-width: 640px; margin: 0 auto; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; height: var(--nav-h); align-items: center; }
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted);
  font-size: .72rem; font-weight: 600; height: 100%;
}
.bottomnav a svg { width: 24px; height: 24px; }
.bottomnav a.active { color: var(--primary); }
.bottomnav a.collect-tab { position: relative; color: var(--on-primary); }
.bottomnav a.collect-tab .fab {
  display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--primary);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--primary) 40%, transparent); margin-top: -26px; border: 4px solid var(--surface);
}
.bottomnav a.collect-tab span.lbl { color: var(--primary); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card, .card + .section, .section + .card, .section + .section { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-head a { font-size: .9rem; font-weight: 600; }
.section { margin-top: 20px; }
.section > h2 { margin: 0 0 10px 2px; }
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) {
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
  .cols-2 > .card + .card { margin-top: 0; }
}

.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); min-width: 0; }
.stat .label { font-size: .8rem; color: var(--muted); font-weight: 600; }
.stat .value { font-size: 1.45rem; font-weight: 750; margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; overflow-wrap: anywhere; }
.stat .sub { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.stat.red .value { color: var(--red); }
.stat.ok .value { color: var(--ok); }

/* ---------- Hero "collect" button ---------- */
.hero-collect {
  display: flex; align-items: center; gap: 14px; background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: var(--on-primary); border-radius: 20px; padding: 18px 20px; box-shadow: 0 10px 24px color-mix(in srgb, var(--primary) 30%, transparent);
  font-weight: 700; font-size: 1.15rem;
}
.hero-collect .ico { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: rgba(255,255,255,.18); flex: none; }
.hero-collect small { display: block; font-weight: 500; font-size: .85rem; opacity: .9; }
.hero-collect .arrow { margin-left: auto; opacity: .9; }

/* ---------- Progress ---------- */
.progress { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.progress.sm { height: 6px; }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 2px; color: inherit; min-height: 56px; }
a.row:hover { background: var(--surface-2); border-radius: var(--radius-sm); }
.row .main { flex: 1; min-width: 0; }
.row .title, .row .meta { display: block; }
.row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { font-size: .82rem; color: var(--muted); }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 700; font-size: .9rem;
  background: var(--primary-soft); color: var(--primary);
}
.avatar.lg { width: 64px; height: 64px; font-size: 1.4rem; }

/* ---------- Badges & chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 99px; font-size: .78rem; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.grey { background: var(--surface-2); color: var(--muted); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 8px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  font-weight: 600; font-size: .9rem; cursor: pointer; white-space: nowrap;
}
.chip.active { background: var(--ink); color: var(--surface); border-color: var(--ink); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 18px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 650;
  cursor: pointer; text-align: center; -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--surface-2); }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, var(--line)); }
.btn.wa { background: #1fa855; border-color: #1fa855; color: #fff; }
.btn.block { width: 100%; }
.btn.big { min-height: 56px; font-size: 1.08rem; border-radius: 14px; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: .88rem; border-radius: 10px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1 1 140px; white-space: nowrap; padding-left: 12px; padding-right: 12px; }
.btn-row > .btn.big { font-size: 1rem; }

/* ---------- Forms ---------- */
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: .86rem; font-weight: 650; color: var(--ink-2); margin-bottom: 6px; }
input[type=text], input[type=search], input[type=tel], input[type=number], input[type=date], input[type=password], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  color: var(--ink); font: inherit; font-size: 16px; /* 16px stops iOS zoom */
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 1px; border-color: var(--primary); }
.btn:focus-visible, .chip:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.hint { font-size: .8rem; color: var(--muted); margin-top: 5px; }
.form-grid { display: grid; gap: 0 14px; }
@media (min-width: 560px) { .form-grid.two { grid-template-columns: 1fr 1fr; } }

.search { position: relative; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 44px; min-height: 52px; border-radius: 14px; font-size: 17px; }

/* Segmented control (radio buttons styled as tabs) */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; background: var(--surface-2); padding: 5px; border-radius: 14px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; border-radius: 10px; font-weight: 650; cursor: pointer; color: var(--ink-2); }
.seg input:checked + label { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
.seg input:focus-visible + label { outline: 2px solid var(--primary); }

/* Amount input */
.amount-box { display: flex; align-items: center; gap: 6px; border: 2px solid var(--primary); border-radius: 16px; padding: 6px 16px; background: var(--surface); }
.amount-box .cur { font-size: 1.8rem; font-weight: 700; color: var(--muted); }
.amount-box input { border: 0; outline: 0; font-size: 2rem; font-weight: 750; padding: 6px 0; min-height: 56px; background: transparent; font-variant-numeric: tabular-nums; }
.amount-box input:focus { outline: 0; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 14px; border-radius: 12px; font-weight: 600; margin-bottom: 14px; display: flex; gap: 10px; align-items: flex-start; }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.error { background: var(--red-soft); color: var(--red); }
.alert.info { background: var(--primary-soft); color: var(--primary); }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50;
  max-width: calc(100% - 32px); width: max-content; padding: 12px 18px; border-radius: 12px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.18);
  background: var(--ink); color: var(--surface); animation: toast-in .25s ease-out;
}
.toast.error { background: var(--red); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ---------- Month strip (student profile) ---------- */
.months { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.month {
  flex: none; min-width: 86px; padding: 8px 10px; white-space: nowrap; border-radius: 12px; text-align: center; border: 1px solid var(--line); background: var(--surface);
}
.month .m { font-size: .78rem; font-weight: 700; color: var(--muted); }
.month .s { font-size: .82rem; font-weight: 700; margin-top: 2px; }
.month.paid { background: var(--ok-soft); border-color: transparent; }
.month.paid .s { color: var(--ok); }
.month.due { background: var(--red-soft); border-color: transparent; }
.month.due .s { color: var(--red); }
.month.part { background: var(--warn-soft); border-color: transparent; }
.month.part .s { color: var(--warn); }
.month.waived .s { color: var(--muted); }
.month.advance { background: var(--primary-soft); border-color: transparent; }
.month.advance .s { color: var(--primary); }

/* Balance card */
.balance { border-radius: 20px; padding: 18px; color: #fff; background: linear-gradient(135deg, #b91c1c, #dc2626); }
.balance.clear { background: linear-gradient(135deg, #15803d, #16a34a); }
.balance .lbl { font-weight: 600; opacity: .9; font-size: .9rem; }
.balance .amt { font-size: 2.2rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.balance .btn { background: #fff; color: #111827; border-color: #fff; }

/* ---------- Attendance ---------- */
.class-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; aspect-ratio: 1 / 1; max-height: 110px; width: 100%;
  border-radius: 16px; border: 2px dashed color-mix(in srgb, var(--warn) 55%, var(--line)); background: var(--warn-soft); color: var(--ink);
}
.tile .n { font-size: 1.35rem; font-weight: 800; }
.tile .s { font-size: .72rem; font-weight: 700; color: var(--warn); text-align: center; }
.tile.done { border: 2px solid transparent; background: var(--ok-soft); }
.tile.done .s { color: var(--ok); }
.tile.empty { border: 2px solid var(--line); background: var(--surface); opacity: .6; }
.tile.empty .s { color: var(--muted); }

.att-list { list-style: none; margin: 0; padding: 0; }
.att-item { display: flex; align-items: center; gap: 12px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.att-item .roll { width: 30px; text-align: center; color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.att-item .nm { flex: 1; font-weight: 600; min-width: 0; }
.att-toggle { position: relative; }
.att-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.att-toggle label {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 116px; min-height: 46px; border-radius: 12px;
  font-weight: 750; cursor: pointer; user-select: none; background: var(--ok-soft); color: var(--ok); -webkit-tap-highlight-color: transparent;
}
.att-toggle label .a { display: none; }
.att-toggle input:checked + label { background: var(--red); color: #fff; }
.att-toggle input:checked + label .p { display: none; }
.att-toggle input:checked + label .a { display: inline; }
.att-toggle input:focus-visible + label { outline: 2px solid var(--primary); outline-offset: 2px; }
.att-item.is-absent .nm { color: var(--red); }

.sticky-bar {
  position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 10; margin: 16px -16px 0; padding: 12px 16px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-top: 1px solid var(--line);
}

/* ---------- Charts (simple bars) ---------- */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; padding-top: 8px; }
.bars .bar { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.bars .bar i { display: block; width: 100%; max-width: 34px; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .bar i.zero { background: var(--line); }
.bars .bar span { font-size: .66rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.hbar { display: grid; grid-template-columns: 48px 1fr auto; gap: 10px; align-items: center; padding: 7px 0; }
.hbar .lbl { font-weight: 700; }
.hbar .val { font-variant-numeric: tabular-nums; font-weight: 650; font-size: .9rem; text-align: right; min-width: 72px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table.t { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.t th { text-align: left; font-size: .76rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 8px 8px; border-bottom: 1px solid var(--line); }
table.t td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t .r { text-align: right; font-variant-numeric: tabular-nums; }
tr.void td { color: var(--muted); text-decoration: line-through; }

/* ---------- Receipt page ---------- */
.receipt-ok { text-align: center; padding: 8px 0 4px; }
.receipt-ok .tick { width: 64px; height: 64px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; margin: 0 auto 10px; }
.receipt-ok .tick svg { width: 34px; height: 34px; }
.receipt-ok .amt { font-size: 2.2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: .95rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 600; }
.void-banner { background: var(--red-soft); color: var(--red); padding: 12px 14px; border-radius: 12px; font-weight: 700; margin-bottom: 14px; }

details.more > summary { cursor: pointer; font-weight: 650; color: var(--primary); list-style: none; padding: 8px 0; }
details.more > summary::-webkit-details-marker { display: none; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; }
.login-logo { width: 64px; height: 64px; border-radius: 18px; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; margin: 0 auto 14px; }
.login-logo svg { width: 34px; height: 34px; }

.empty-state { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty-state svg { width: 40px; height: 40px; margin-bottom: 8px; opacity: .6; }

.suggest { margin-top: 10px; }
.suggest:empty { display: none; }

@media (min-width: 900px) {
  h1 { font-size: 1.75rem; }
}
@media print {
  .appbar, .bottomnav, .no-print { display: none !important; }
  body { padding: 0; background: #fff; }
}
