/* app.css - page layouts (public ledger + admin)
 * Card rhythm: every content card is a .card (glass.css, 18px padding, 18px radius).
 * Vertical rhythm: 22px between top-level blocks, 16px between repeated cards. */

/* ---------- public ledger ---------- */

.hero { margin-top: 22px; padding: 26px; }
.hero .class-name { font-size: 15px; color: var(--muted); font-weight: 600; }
.hero h1 { font-size: 26px; margin: 6px 0 2px; }
.hero .balance-label { font-size: 13px; color: var(--muted); margin-top: 16px; }
.hero .balance {
  font-size: 52px;
  font-weight: 800;
  letter-spacing: -1.5px;
  line-height: 1.15;
  word-break: break-all;
}
.hero .balance.pos { color: var(--ok); }
.hero .balance.neg { color: var(--danger); }
.hero .meta { font-size: 13px; color: var(--muted); margin-top: 8px; }

.section { margin-top: 22px; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.section-head h2 { font-size: 18px; margin: 0; }
.section-head .sub { font-size: 13px; color: var(--muted); }

.charge-list { display: grid; gap: 16px; }
/* a card that follows the charge list (income ledger) keeps the same 16px rhythm */
.charge-list + .card { margin-top: 16px; }
.charge-item .top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.charge-item .name { font-weight: 700; font-size: 15px; }
.charge-item .nums { font-size: 14px; font-variant-numeric: tabular-nums; }
.charge-item .nums b { font-size: 16px; }
.charge-item .progress { margin-top: 10px; }
.charge-item .foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

/* ---------- admin ---------- */

.login-wrap {
  display: flex;
  justify-content: center;
  padding: 44px 0 20px;
}
.login-card { width: 100%; max-width: 400px; padding: 26px; }
.login-card h1 { font-size: 21px; }
.login-card .hint { font-size: 13px; color: var(--muted); margin-bottom: 18px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card .btn { width: 100%; padding: 11px; font-size: 15px; }
.login-card .foot-link { text-align: center; font-size: 13px; margin-top: 14px; }

.dash-cards { margin-top: 22px; }

/* only the selected panel renders; without this rule every panel shows at once */
.panel { display: none; }
.panel.active { display: block; }

.list { display: grid; gap: 16px; }
.row-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
}
.row-item .grow { flex: 1 1 auto; min-width: 0; }
.row-item .title { font-weight: 600; font-size: 15px; word-break: break-all; }
.row-item .meta { font-size: 12px; color: var(--muted); }
.row-item .acts { display: flex; gap: 6px; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; }

.badge-count {
  display: inline-block;
  min-width: 22px;
  text-align: center;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 12px;
  font-weight: 700;
}

/* charge card with payment registration grid (padding comes from .card: 18px) */
.charge-admin .head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.charge-admin .head .grow { flex: 1 1 auto; min-width: 0; }
.charge-admin .head .title { font-weight: 700; font-size: 16px; }
.charge-admin .head .nums { font-size: 13px; color: var(--muted); margin-top: 2px; }
.charge-admin .head .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.charge-admin .progress { margin-top: 12px; }

/* payment registration: narrow name cells with a paid/unpaid corner mark */
.pay-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.pay-tools .pay-all {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.pay-tools .pay-all input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.pay-tools .pay-search { flex: 1 1 150px; max-width: 220px; height: 34px; font-size: 14px; }

.pay-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.pay-toggle {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 24px 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--fg);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.pay-toggle .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pay-toggle .mark {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 15px;
  height: 15px;
  border-radius: 999px;
  font-size: 10px;
  line-height: 14px;
  text-align: center;
  border: 1px solid var(--border);
  color: transparent;
}
.pay-toggle .mark.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.pay-toggle.paid {
  border-color: color-mix(in srgb, var(--ok) 55%, transparent);
  background: color-mix(in srgb, var(--ok) 12%, transparent);
}
.pay-toggle:hover { border-color: var(--accent); }

.settings-form { display: grid; gap: 14px; max-width: 520px; }

/* attachment chips (receipts on an expense) */
.file-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--input-bg);
  font-size: 12px;
  color: var(--fg);
  text-decoration: none;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
a.file-chip:hover { border-color: var(--accent); }
.file-chip .chip-x {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  padding: 0;
}
.file-chip .chip-x:hover { color: var(--danger); }

/* inline editing: edits happen on the row/card itself, not the top form */
.inline-edit {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
}
.inline-edit .ie-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.inline-edit label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  min-width: 0;
  flex: 1 1 110px;
}
.inline-edit input { height: 36px; font-size: 14px; }
.inline-edit .acts { display: flex; gap: 6px; }

/* student roster: responsive columns + bulk selection */
#studentList { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.student-item { flex-wrap: wrap; cursor: pointer; min-height: 54px; box-sizing: border-box; }
.student-item .pick {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  cursor: pointer;
  accent-color: var(--accent);
}
.student-item .acts { width: 100%; justify-content: flex-start; }
.roster-tools { margin: 0 0 12px; }
.roster-tools .roster-search { width: 100%; max-width: 280px; height: 34px; font-size: 14px; }
/* the student-card editor is a single inline row: the card keeps its size */
.student-item .inline-edit {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
}
.student-item .inline-edit .ie-row {
  display: flex;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: nowrap;
}
.student-item .inline-edit input {
  height: 30px;
  min-width: 0;
  flex: 1 1 0;
  font-size: 14px;
  padding: 0 8px;
}
.student-item .inline-edit .acts { flex: 0 0 auto; width: auto; }
.student-item .inline-edit .acts .btn { height: 30px; padding: 0 10px; }
.bulk-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 12px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
}
.bulk-bar .grow { flex: 1 1 auto; min-width: 0; font-size: 13px; color: var(--muted); }
.bulk-bar .bulk-amount { width: 118px; height: 32px; font-size: 13px; }

@media (max-width: 640px) {
  /* compact cards: more detail rows per screen on phones */
  .card { padding: 12px; border-radius: 12px; }
  .card + .card { margin-top: 10px; }
  .hero { padding: 14px; margin-top: 14px; }
  .hero .balance { font-size: 30px; letter-spacing: -1px; }
  .hero h1 { font-size: 18px; }
  .hero .balance-label { margin-top: 10px; }
  .hero .meta { font-size: 12px; margin-top: 6px; }
  .section { margin-top: 14px; }
  .section-head { margin-bottom: 6px; }
  .section-head h2 { font-size: 16px; }
  .cards { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat { padding: 10px 8px; }
  .stat .label { font-size: 11px; }
  .stat .value { font-size: 18px; margin-top: 2px; }
  .stat.featured .value { font-size: 22px; }
  .stat .hint { font-size: 10px; }
  .tabs { margin: 14px 0 10px; gap: 6px; }
  .tab { padding: 6px 12px; font-size: 13px; }
  .topbar { top: 8px; margin-top: 8px; }
  .topbar-inner { padding: 8px 12px; gap: 8px; }
  table { font-size: 13px; }
  th, td { padding: 7px 6px; }
  .charge-list, .list { gap: 10px; }
  .charge-list + .card { margin-top: 10px; }
  .row-item { flex-wrap: wrap; padding: 8px 10px; gap: 8px; }
  .row-item .title { font-size: 14px; }
  .row-item .acts { width: 100%; justify-content: flex-start; }
  #studentList { grid-template-columns: 1fr; }
  .roster-tools .roster-search { max-width: none; }
  .charge-item .nums { font-size: 13px; }
  .charge-item .foot { font-size: 11px; margin-top: 4px; }
  .charge-item .progress { margin-top: 8px; }
  .unpaid-line { margin-top: 6px; font-size: 12px; line-height: 1.6; }
  .pay-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; margin-top: 10px; }
  .pay-tools .pay-search { max-width: none; }
  .export-row { margin-top: 10px; }
  .login-wrap { padding: 20px 0 8px; }
  .login-card { padding: 16px; }
  .login-card form { gap: 10px; }
  .gate-card { padding: 16px; }
  .gate-card h1 { font-size: 19px; }
  .settings-form { gap: 10px; }

  /* iOS zooms the page when focusing an input under 16px: keep every
     field at exactly 16px on phones so the viewport never jumps */
  input, select, textarea { font-size: 16px; }
}

/* ---------- batch import / export rows ---------- */
.export-row { display: flex; justify-content: flex-end; margin-top: 16px; }

/* ---------- unpaid roster line on a charge card ---------- */
.unpaid-line {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.8;
  word-break: break-all;
}
.unpaid-line strong { color: var(--fg); }

/* ---------- parent query code ---------- */
.code {
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  letter-spacing: 1.5px;
  background: var(--card-strong);
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 12px;
  color: var(--accent);
}
.parent-head { font-size: 15px; margin-bottom: 10px; }
.parent-sum { margin-top: 10px; font-size: 14px; }
.warn-text { color: var(--warn); }

.nowrap { white-space: nowrap; }

textarea { min-height: 96px; resize: vertical; }

/* ---------- print: only the card the user chose ---------- */
@media print {
  body { background: #fff; }
  body.printing * { visibility: hidden; }
  body.printing .print-target,
  body.printing .print-target * { visibility: visible; }
  body.printing .print-target {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    margin: 0;
    padding: 0;
    border: none;
    box-shadow: none;
    background: #fff;
    color: #000;
  }
  body.printing .print-target .unpaid-line,
  body.printing .print-target .nums { color: #333; }
  body.printing .print-target .head .acts { display: none; }
}

/* ---------- name gate: blocks the ledger until a student name verifies ---------- */
body.gated { overflow: hidden; }
.gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.gate-card { width: 100%; max-width: 380px; padding: 26px; }
.gate-class { font-size: 13px; font-weight: 600; color: var(--muted); }
.gate-card h1 { font-size: 21px; margin: 6px 0 4px; }
.gate-card .hint { font-size: 13px; color: var(--muted); margin: 0 0 16px; }
.gate-card form { display: flex; flex-direction: column; gap: 14px; }
.gate-card .btn { width: 100%; padding: 11px; font-size: 15px; }
.gate-err { margin: 0; font-size: 13px; color: var(--danger); }

/* ---------- refunded students: visible but out of every count ---------- */
.row-item.refunded { opacity: 0.6; }
