:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #111827;
  --ink-2: #374151;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #0f766e;
  --accent-2: #14b8a6;
  --accent-soft: #e6f4f1;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --nav-h: 64px;
  --side-w: 232px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
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; }
h3 { font-size: 14px; font-weight: 650; }
.ic { flex: none; vertical-align: middle; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt { margin-top: 16px; } .mt-s { margin-top: 8px; } .mb { margin-bottom: 16px; }
.hide { display: none !important; }

/* ---- Shell ---------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 16px;
}
.brand { font-weight: 700; color: var(--ink); display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center;
  font-size: 14px; font-weight: 800; flex: none;
}
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.who { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.iconbtn {
  border: 0; background: transparent; color: var(--ink-2); width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; cursor: pointer;
}
.iconbtn:hover { background: #f1f5f9; }

.main { padding: 16px; padding-bottom: calc(var(--nav-h) + 88px); max-width: 1100px; margin: 0 auto; }

.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; height: var(--nav-h); background: #fff; border-top: 1px solid var(--line);
  display: flex; justify-content: space-around; padding-bottom: env(safe-area-inset-bottom);
}
.nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: 11px; font-weight: 550; text-decoration: none;
}
.nav a.on { color: var(--accent); }
.nav .label-long { display: none; }
.nav .nav-extra { display: none; }

@media (min-width: 900px) {
  .nav {
    top: 56px; bottom: 0; right: auto; width: var(--side-w); height: auto; flex-direction: column; justify-content: flex-start;
    border-top: 0; border-right: 1px solid var(--line); padding: 14px 10px; gap: 2px;
  }
  .nav a { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 10px 12px; border-radius: 10px; font-size: 14px; color: var(--ink-2); }
  .nav a:hover { background: #f3f4f6; text-decoration: none; }
  .nav a.on { background: var(--accent-soft); color: var(--accent); }
  .nav .label-short { display: none; }
  .nav .label-long { display: inline; }
  .nav .nav-more { display: none; }
  .nav .nav-extra { display: flex; }
  .nav .sep { height: 1px; background: var(--line); margin: 8px 6px; }
  .main { margin-left: var(--side-w); padding: 24px 28px 48px; max-width: none; }
  .main > .wrap { max-width: 1080px; }
}

/* Floating "Collect fee" button */
.fab {
  position: fixed; right: 16px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 40;
  background: var(--accent); color: #fff; border-radius: 999px; padding: 14px 20px; display: flex; align-items: center; gap: 8px;
  font-weight: 650; box-shadow: 0 8px 20px rgba(15,118,110,.35); text-decoration: none;
}
.fab:hover { text-decoration: none; background: #0d6961; }
@media (min-width: 900px) { .fab { bottom: 24px; right: 28px; } }

/* ---- Page header ---------------------------------------------------------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; margin-bottom: 6px; }

/* ---- Cards & grid ---------------------------------------------------------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols { display: grid; gap: 14px; }
@media (min-width: 700px) {
  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1000px) { .grid-cols { grid-template-columns: 1.4fr 1fr; align-items: start; } }

.stat { padding: 14px 16px; }
.stat .k { font-size: 12px; color: var(--muted); font-weight: 550; text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 24px; font-weight: 750; margin-top: 4px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .d { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.stat.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.stat.accent .k, .stat.accent .d { color: rgba(255,255,255,.82); }
.bar { height: 6px; background: #eef2f2; border-radius: 99px; overflow: hidden; margin-top: 10px; }
.bar > i { display: block; height: 100%; background: var(--accent-2); border-radius: 99px; }
.stat.accent .bar { background: rgba(255,255,255,.25); }
.stat.accent .bar > i { background: #fff; }

/* ---- Lists ---------------------------------------------------------------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.list .meta { font-size: 12.5px; color: var(--muted); }
.list a.row { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; width: 100%; }
.amt { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amt.due { color: var(--bad); }
.amt.ok { color: var(--ok); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center;
  font-weight: 700; font-size: 13px; flex: none;
}

/* ---- Tables ----------------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0 16px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #fafafa; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr:hover { background: #fafcfc; }
tfoot td { font-weight: 700; }

/* ---- Badges ----------------------------------------------------------------- */
.badge { display: inline-block; font-size: 11.5px; font-weight: 650; padding: 2px 8px; border-radius: 99px; background: #f3f4f6; color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.acc { background: var(--accent-soft); color: var(--accent); }

/* ---- Forms -------------------------------------------------------------------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.field { margin-bottom: 14px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=tel], input[type=search], select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: #fff; border: 1px solid #d1d5db; border-radius: 10px;
  padding: 10px 12px; min-height: 44px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(20,184,166,.18); }
textarea { min-height: 80px; resize: vertical; }
.row2 { display: grid; gap: 0 12px; grid-template-columns: 1fr; }
@media (min-width: 600px) { .row2 { grid-template-columns: 1fr 1fr; } }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 650; font-size: 14.5px;
  border-radius: 10px; padding: 10px 16px; min-height: 44px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; text-decoration: none;
}
.btn:hover { background: #f9fafb; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #0d6961; }
.btn.danger { color: var(--bad); border-color: #fecaca; }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.big { min-height: 52px; font-size: 16px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }

/* Segmented control (Cash / UPI etc.) */
.seg { display: flex; background: #f3f4f6; border-radius: 12px; padding: 4px; gap: 4px; }
.seg label { flex: 1; margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 10px; border-radius: 9px; font-weight: 650; cursor: pointer; color: var(--muted); }
.seg input:checked + span { background: #fff; color: var(--accent); box-shadow: var(--shadow); }
.seg input:focus-visible + span { outline: 2px solid var(--accent-2); }

/* Chip filters */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 7px 14px; border-radius: 99px; background: #fff; border: 1px solid var(--line); color: var(--ink-2);
  font-size: 13.5px; font-weight: 600; white-space: nowrap; cursor: pointer; text-decoration: none;
}
.chip:hover { text-decoration: none; border-color: #cbd5e1; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.filters { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; align-items: end; }
.filters .field { margin: 0; }
@media (min-width: 800px) { .filters { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* Flash messages */
.flash { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-size: 14px; font-weight: 550; word-break: break-word; }
.flash.ok { background: var(--ok-soft); color: #14532d; }
.flash.err { background: var(--bad-soft); color: #7f1d1d; }

/* ---- Attendance toggles ------------------------------------------------------- */
.att-list li { padding: 8px 0; }
.toggle { position: relative; }
.toggle input { position: absolute; opacity: 0; }
.toggle span {
  display: inline-flex; align-items: center; justify-content: center; min-width: 92px; padding: 9px 12px; border-radius: 10px;
  font-weight: 700; font-size: 13.5px; background: var(--ok-soft); color: var(--ok); cursor: pointer; user-select: none;
}
.toggle input:checked + span { background: var(--bad-soft); color: var(--bad); }
.toggle span::before { content: "Present"; }
.toggle input:checked + span::before { content: "Absent"; }
.sticky-save {
  position: sticky; bottom: calc(var(--nav-h) + 10px); margin-top: 14px; background: #fff; border: 1px solid var(--line);
  border-radius: 14px; padding: 10px; box-shadow: 0 6px 18px rgba(0,0,0,.08); display: flex; gap: 10px; align-items: center;
}
@media (min-width: 900px) { .sticky-save { bottom: 16px; } }

/* Month status grid on profile */
.months { display: grid; grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); gap: 8px; }
.month { border-radius: 10px; padding: 8px 10px; font-size: 12.5px; border: 1px solid var(--line); }
.month b { display: block; font-size: 13px; }
.month.Paid { background: var(--ok-soft); border-color: #bbf7d0; }
.month.Partial { background: var(--warn-soft); border-color: #fde68a; }
.month.Due { background: var(--bad-soft); border-color: #fecaca; }

.dots { display: flex; flex-wrap: wrap; gap: 4px; }
.dot { width: 14px; height: 14px; border-radius: 4px; background: var(--ok); }
.dot.A { background: var(--bad); }

/* Search dropdown */
.search { position: relative; }
.search .ic { position: absolute; left: 12px; top: 12px; color: var(--muted); }
.search input { padding-left: 40px; }
.results { margin-top: 8px; }

/* Login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: 100%; max-width: 380px; padding: 26px; }

.empty { text-align: center; color: var(--muted); padding: 28px 10px; }
.big-due { font-size: 30px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 10px 12px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--accent); border-color: var(--accent); }
.chart-box { position: relative; height: 220px; }
details.menu > summary { list-style: none; cursor: pointer; }
details.menu > summary::-webkit-details-marker { display: none; }
.receipt-amt { font-size: 34px; font-weight: 800; color: var(--accent); letter-spacing: -.02em; }
dl.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; margin: 0; font-size: 14px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; font-weight: 600; }
.att-row { display: flex; align-items: center; gap: 12px; width: 100%; margin: 0; cursor: pointer; font-weight: 500; font-size: 15px; color: var(--ink); }
.att-name { flex: 1; min-width: 0; font-weight: 600; }
.att-name small { display: block; font-weight: 400; font-size: 12.5px; }
/* Grid children must be allowed to shrink, or wide chip rows push the page sideways on phones */
.grid-cols { grid-template-columns: minmax(0, 1fr); }
.grid-cols > *, .grid > * { min-width: 0; }
@media (min-width: 1000px) { .grid-cols { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); } }
.report td, .report th { white-space: nowrap; }
@media (min-width: 900px) { .fab { display: none; } }
