/* Tuition Center: mobile-first styles */
:root {
  color-scheme: dark;
  --bg: #0e1116;
  --card: #171b22;
  --raised: #1e232c;      /* inputs, buttons, chips */
  --raised-2: #262c37;    /* hover */
  --ink: #e6e8eb;
  --ink-2: #b4bac4;
  --muted: #8b93a1;
  --line: #2a313c;
  --line-2: #3a4250;      /* input borders */
  --brand: #2563eb;       /* filled buttons (white text 5:1) */
  --brand-hover: #1d4ed8;
  --brand-ink: #fff;
  --link: #8ab4ff;        /* accent text on dark */
  --brand-soft: rgba(59, 130, 246, .16);
  --ok: #4ade80;
  --ok-soft: rgba(34, 197, 94, .13);
  --ok-line: rgba(74, 222, 128, .35);
  --due: #f87171;
  --due-soft: rgba(239, 68, 68, .14);
  --due-line: rgba(248, 113, 113, .4);
  --warn: #fbbf24;
  --warn-soft: rgba(245, 158, 11, .14);
  --radius: 12px;
  --nav-h: 64px;
  --tap: 44px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}
body.has-nav { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px); }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.4rem; margin: 0; line-height: 1.2; }
h2 { font-size: 1.02rem; margin: 0 0 .5rem; }
code { background: var(--raised); padding: 1px 4px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.block { display: block; }
.center { text-align: center; }
.pre { white-space: pre-wrap; }
.text-due { color: var(--due); }
.text-ok { color: var(--ok); }
[hidden] { display: none !important; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 12px; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  background: var(--card); color: var(--ink); border-bottom: 1px solid var(--line); padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top));
}
.brand { color: var(--ink); font-weight: 700; font-size: 1.05rem; flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.brand:hover { text-decoration: none; }
.topnav { display: none; }
.topbar .icon-btn { color: var(--ink-2); }
.topbar .icon-btn.on { background: var(--brand-soft); color: var(--link); }

/* Bottom nav (phones) */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 1px solid var(--line); height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: .72rem; }
.bottomnav a:hover { text-decoration: none; }
.bottomnav a.on { color: var(--link); font-weight: 600; }
.bottomnav a.fab .ic {
  background: var(--brand); color: #fff; width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center; margin-top: -22px; box-shadow: 0 4px 14px rgba(37,99,235,.45), 0 0 0 4px var(--card);
}
.bottomnav a.fab { color: var(--link); font-weight: 600; }

@media (min-width: 900px) {
  body.has-nav { padding-bottom: 24px; }
  .bottomnav { display: none; }
  .topnav { display: flex; align-items: center; gap: 4px; }
  .topnav a { color: var(--ink-2); padding: 8px 12px; border-radius: 8px; }
  .topnav a.on, .topnav a:hover { color: var(--ink); background: var(--raised-2); text-decoration: none; }
  .topnav a.btn-primary { background: var(--brand); color: #fff; margin-left: 8px; font-weight: 700; }
  .topnav a.btn-primary:hover { background: var(--brand-hover); }
  .wrap { padding: 20px; }
}

/* Page header */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 4px 0 14px; }
.page-head p { margin: 4px 0 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap);
  padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--raised); color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; background: var(--raised-2); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-hover); }
.btn-danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn-sm { min-height: 34px; padding: 4px 12px; font-size: .85rem; border-radius: 8px; }
.btn-lg { min-height: 52px; font-size: 1.05rem; padding: 10px 20px; }
.btn-block { width: 100%; }
.btn.disabled, .btn:disabled { opacity: .45; pointer-events: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px;
  color: var(--ink-2); background: transparent; border: 0; cursor: pointer;
}
.icon-btn:hover { background: var(--raised-2); }
button.link { background: none; border: 0; color: inherit; cursor: pointer; font: inherit; }

.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }

/* Cards & tiles */
.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.3); border: 1px solid var(--line); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.grid-2 { display: grid; gap: 0 14px; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
@media (min-width: 900px) { .tiles { grid-template-columns: repeat(4, 1fr); } .tiles-3 { grid-template-columns: repeat(3, 1fr); } }
.tiles-3 > :first-child { grid-column: 1 / -1; }
@media (min-width: 900px) { .tiles-3 > :first-child { grid-column: auto; } }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; color: var(--ink); }
.tile-link:hover { text-decoration: none; border-color: var(--link); }
.tile-label { font-size: .8rem; color: var(--muted); }
.tile-value { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; margin: 2px 0; }
.tile-sub { font-size: .8rem; color: var(--muted); }
.tile-line { display: flex; justify-content: space-between; font-size: .9rem; font-variant-numeric: tabular-nums; }

/* Rows */
.rows { list-style: none; margin: 0; padding: 0; }
.rows.card { padding: 0 14px; }
.row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.row:last-child { border-bottom: 0; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; color: var(--ink); }
.row-main:hover { text-decoration: none; }
.row-main strong { overflow: hidden; text-overflow: ellipsis; }
.row-actions { display: flex; align-items: center; gap: 4px; }
.amount { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.voided { opacity: .6; }
.voided .amount, .voided strong { text-decoration: line-through; }
.receipt-row .void { flex-basis: 100%; }
.void summary { cursor: pointer; padding: 2px 0; }

/* Pills */
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-due { background: var(--due-soft); color: var(--due); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-info { background: var(--brand-soft); color: var(--link); }
.pill-muted { background: var(--raised-2); color: var(--ink-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.chip { border: 1px solid var(--line-2); background: var(--raised); color: var(--ink); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: .85rem; cursor: pointer; min-height: 36px; }
.chip:hover { border-color: var(--link); color: var(--link); }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.table th { color: var(--muted); font-weight: 600; font-size: .8rem; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr:last-child td { border-bottom: 0; }
.table-scroll { overflow-x: auto; }
.extra-row { display: none; }
.show-extra .extra-row { display: table-row; }

/* Forms */
.form label, label[for] { display: block; font-weight: 600; font-size: .88rem; margin: 12px 0 4px; }
.form > label:first-of-type { margin-top: 0; }
input[type=text], input[type=search], input[type=tel], input[type=email], input[type=number], input[type=password],
input[type=date], input[type=month], select, textarea {
  width: 100%; min-height: var(--tap); padding: 8px 12px; font: inherit; font-size: 16px; color: var(--ink);
  border: 1px solid var(--line-2); border-radius: 10px; background: var(--raised);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--link); outline-offset: 0; border-color: var(--link); }
.hint { font-size: .78rem; color: var(--muted); margin: 4px 0 0; }
.two-col { display: grid; gap: 0 12px; }
@media (min-width: 600px) { .two-col { grid-template-columns: 1fr 1fr; } }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.form .btn-primary, .form > .btn { margin-top: 16px; }
.inline-form { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.wrap-form { flex-wrap: wrap; }
.wrap-form input { flex: 1 1 160px; width: auto; }
fieldset { border: 0; padding: 0; margin: 12px 0 0; }
legend { font-weight: 600; font-size: .88rem; margin-bottom: 4px; padding: 0; }

/* Segmented radio/checkbox options */
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg legend { width: 100%; }
.seg-opt { margin: 0 !important; font-weight: 500 !important; }
.seg-opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg-opt span {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: 6px 14px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--raised); cursor: pointer; user-select: none;
}
.seg-opt input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.seg-opt input:focus-visible + span { outline: 2px solid var(--link); outline-offset: 2px; }

/* Filters */
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.filters input[type=search] { grid-column: 1 / -1; }
.filters .btn { grid-column: 1 / -1; }
@media (min-width: 700px) { .filters { grid-template-columns: 2fr 1fr 1fr auto; } .filters input[type=search], .filters .btn { grid-column: auto; } }
.js .filters .btn { display: none; }
@media (min-width: 700px) { .js .filters { grid-template-columns: 2fr 1fr 1fr; } }

/* Flash */
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; font-weight: 500; }
.flash-ok { background: var(--ok-soft); color: var(--ok); border: 1px solid var(--ok-line); }
.flash-error { background: var(--due-soft); color: #fca5a5; border: 1px solid var(--due-line); }

/* Collect page */
.pick-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 55vh; overflow-y: auto; border-radius: 10px; }
.pick-list li button {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px; text-align: left;
  padding: 10px 12px; min-height: 52px; border: 0; border-bottom: 1px solid var(--line); background: var(--raised); font: inherit; cursor: pointer; color: var(--ink);
}
.pick-list li button:hover, .pick-list li button:focus { background: var(--brand-soft); outline: none; }
.pick-list .pk-name { font-weight: 600; display: block; }
.pick-list .pk-meta { font-size: .8rem; color: var(--muted); }
.pick-list .pk-due { font-weight: 700; color: var(--due); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pick-list .pk-ok { color: var(--ok); font-size: .82rem; font-weight: 600; white-space: nowrap; }
.pick-empty { padding: 12px; color: var(--muted); }
.picked { background: var(--brand-soft); border-radius: 10px; padding: 12px; }
.picked-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.picked-due { display: flex; justify-content: space-between; align-items: baseline; margin-top: 8px; }
.picked-due .big { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
#amount { font-size: 1.4rem; font-weight: 700; }

.receipt-ready { border-color: var(--ok-line); background: var(--ok-soft); }
.receipt-ready .btn-row { margin: 10px 0 0; }

/* Classes */
.section-title { font-size: .9rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 16px 0 8px; }
.batch-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 700px) { .batch-cards { grid-template-columns: repeat(4, 1fr); } }
.batch-card { color: var(--ink); margin: 0; }
.batch-card:hover { text-decoration: none; border-color: var(--link); }
.batch-name { font-size: 1.3rem; font-weight: 700; }

.batch-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 14px; }
@media (min-width: 900px) { .card .batch-grid { grid-template-columns: repeat(4, 1fr); } }
.batch-chip {
  display: flex; flex-direction: column; align-items: center; padding: 8px 4px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--raised); color: var(--ink); font-size: .78rem; min-height: 52px; justify-content: center;
}
.batch-chip strong { font-size: .95rem; }
.batch-chip:hover { text-decoration: none; border-color: var(--link); }
.batch-chip.done { background: var(--ok-soft); border-color: var(--ok-line); }
.batch-chip.done span { color: var(--ok); font-weight: 600; }
.batch-chip.todo span { color: var(--warn); }
.batch-chip.empty { opacity: .55; }
.batch-chip.selected { outline: 3px solid var(--link); outline-offset: -1px; }

/* Attendance */
.date-nav { display: flex; gap: 8px; align-items: center; justify-content: center; margin-bottom: 6px; }
.date-nav input { max-width: 200px; text-align: center; }
.date-nav form { margin: 0; }
.att-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
@media (min-width: 700px) { .att-list { grid-template-columns: 1fr 1fr; } }
.att-item {
  display: flex !important; align-items: center; justify-content: space-between; gap: 10px; margin: 0 !important;
  padding: 10px 12px; min-height: 52px; border-radius: 10px; border: 1px solid var(--ok-line); background: var(--ok-soft);
  cursor: pointer; user-select: none; font-weight: 500 !important; font-size: .95rem !important;
}
.att-item input { position: absolute; opacity: 0; pointer-events: none; }
.att-state::after { content: "Present"; font-weight: 700; color: var(--ok); font-size: .85rem; }
.att-item:has(input:checked) { background: var(--due-soft); border-color: var(--due-line); }
.att-item:has(input:checked) .att-state::after { content: "Absent"; color: var(--due); }
.att-item:has(input:focus-visible) { outline: 2px solid var(--link); }

/* Settings */
.fee-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 12px; }
@media (min-width: 700px) { .fee-grid { grid-template-columns: repeat(4, 1fr); } }
.fee-cell { margin: 0 !important; }
.fee-cell span:first-child { display: block; margin-bottom: 2px; }
.fee-all { background: var(--raised); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
.fee-all label { margin-top: 0; }
.info { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
.info dt { color: var(--muted); font-size: .85rem; }
.info dd { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.small-title { font-size: .9rem; margin: 16px 0 4px; }

/* Charts */
.chart { position: relative; overflow-x: auto; padding-bottom: 8px; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .grid { stroke: #232a33; stroke-width: 1; }
.chart .baseline { stroke: #4a5361; stroke-width: 1; }
.chart .bar path { fill: #4a7fe8; }
.chart .bar.current path { fill: #4a7fe8; }
.chart .bar .hit { fill: transparent; }
.chart .bar:hover path, .chart .bar:focus path, .chart .bar.active path { fill: #6f9af0; }
.chart .bar:focus { outline: none; }
.chart text { font-size: 11px; fill: var(--muted); font-family: inherit; }
.chart text.val { fill: var(--ink); font-weight: 700; }
.chart .bar.current text.axis { fill: var(--ink); font-weight: 700; }
.chart .tip {
  position: absolute; top: 0; left: 0; transform: translate(-50%, -100%); pointer-events: none; white-space: nowrap;
  background: var(--ink); color: var(--bg); font-size: .8rem; padding: 4px 8px; border-radius: 6px;
}

/* Login */
.login { max-width: 380px; margin: 12vh auto 0; }
.login h1 { text-align: center; margin-bottom: 18px; }

.empty-state { text-align: center; padding: 28px 14px; }
details summary { cursor: pointer; }

@media print {
  .topbar, .bottomnav, .btn, .icon-btn { display: none !important; }
  body { background: #fff; color: #111; }
  :root { color-scheme: light; --card: #fff; --ink: #111; --line: #ddd; }
  .card { box-shadow: none; }
}
