/* The fee office app. The printed receipt has its own stylesheet (receipt.css). */
:root {
  --ink: #18212b; --muted: #5d6b79; --line: #dfe4ea; --bg: #f4f6f8; --card: #fff;
  --brand: #1d3b5f; --brand-2: #2c5a8c; --gold: #b8892b; --bad: #b42318; --bad-bg: #fdecea; --ok: #1f7a4d;
  --radius: 10px;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
/* `hidden` must win over any display rule (.f and .picker are flex, which otherwise overrides it). */
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); }
a { color: var(--brand-2); }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 12px; }
.muted, .sub { color: var(--muted); }
.sub { font-size: 12.5px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.nowrap { white-space: nowrap; }
.empty { padding: 32px; text-align: center; color: var(--muted); }
.empty.bad { color: var(--bad); }
.pad { padding: 0 18px; }
p.pad { margin: 0 0 12px; }

/* Top bar */
.top { background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 5; }
.top-in { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 20px; padding: 0 16px; height: 58px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 600; white-space: nowrap; }
.brand img { height: 34px; background: #fff; border-radius: 6px; padding: 2px 4px; }
.nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.nav a { color: #d5e1ee; text-decoration: none; padding: 8px 12px; border-radius: 8px; white-space: nowrap; font-size: 14px; }
.nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav a.on { background: rgba(255, 255, 255, .16); color: #fff; font-weight: 600; }
.me { position: relative; }
.me > button { background: none; border: 0; color: #fff; display: flex; align-items: center; gap: 8px; cursor: pointer; font: inherit; }
.av { width: 30px; height: 30px; border-radius: 50%; background: var(--gold); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.menu { position: absolute; right: 0; top: 44px; background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .12); min-width: 230px; padding: 6px; }
.menu .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 9px 10px; border-radius: 6px; font: inherit; cursor: pointer; }
.menu button:hover { background: var(--bg); }

/* Page */
.page { max-width: 1240px; margin: 0 auto; padding: 22px 16px 60px; }
.head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow-x: auto; }
.card.flush > .card-head { padding-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cols > .card { margin-bottom: 16px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--brand); color: #fff; border: 1px solid var(--brand);
  border-radius: 8px; padding: 9px 16px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--brand-2); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn.ghost { background: #fff; color: var(--brand); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--brand-2); }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn.ghost.danger { background: #fff; color: var(--bad); border-color: #f1c4bf; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.big { padding: 12px 24px; font-size: 16px; }
.btn.wide { width: 100%; }
.btn.file { position: relative; }
.link { background: none; border: 0; color: var(--brand-2); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 2px; }
.link.danger { color: var(--bad); }
.x { background: none; border: 0; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; padding: 2px 8px; border-radius: 6px; }
.x:hover { background: var(--bg); color: var(--ink); }

/* Forms */
.f { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; min-width: 0; }
.f > span { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.f small { color: var(--muted); font-size: 12px; }
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid #cbd3dc; border-radius: 8px; padding: 9px 11px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc0e8; outline-offset: 0; border-color: var(--brand-2); }
textarea { resize: vertical; }
.static { padding: 9px 0; font-weight: 600; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid.four { grid-template-columns: repeat(4, 1fr); }
.form-foot { display: flex; justify-content: flex-end; gap: 8px; }
.err { color: var(--bad); min-height: 1.2em; margin: 6px 0; font-size: 14px; }
.warn { background: #fff6e0; border: 1px solid #f2d48a; border-radius: 8px; padding: 10px 12px; font-size: 13.5px; }
.filters { display: flex; flex-wrap: wrap; gap: 0 12px; align-items: flex-end; padding-bottom: 6px; }
.filters .f { width: 150px; }
.filters .f.grow { flex: 1; min-width: 220px; }

/* Tables */
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
.grid th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafbfc; }
.grid td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid tr:last-child td { border-bottom: 0; }
.grid .num { text-align: right; white-space: nowrap; }
.grid.click tbody tr { cursor: pointer; }
.grid.click tbody tr:hover { background: #f3f7fb; }
.grid tr.void td { color: #8a96a3; }
.grid tr.void td b { text-decoration: line-through; }
.grid tr.sum td { border-top: 2px solid var(--line); font-weight: 600; }
.card:not(.flush) .grid th, .card:not(.flush) .grid td { padding-left: 0; }
.clip { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .link { margin-left: 12px; font-size: 13.5px; }
.pill { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: #e8eef5; color: var(--brand); vertical-align: middle; }
.pill.bad { background: var(--bad-bg); color: var(--bad); }

/* Dashboard */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.tile span { color: var(--muted); font-size: 13px; font-weight: 600; }
.tile b { font-size: 26px; letter-spacing: -.01em; }
.tile small { color: var(--muted); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 6px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bar i { display: block; width: 100%; max-width: 30px; background: var(--brand-2); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar span { font-size: 11px; color: var(--muted); }
.summary { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.summary > div { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 16px; display: flex; flex-direction: column; min-width: 120px; }
.summary span { font-size: 12px; color: var(--muted); font-weight: 600; }
.summary b { font-size: 18px; }
.summary small { color: var(--muted); }

/* New receipt */
.issue { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.issue-form section { margin-bottom: 18px; }
.picker { position: relative; display: flex; gap: 8px; }
.results { position: absolute; top: 44px; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .12); z-index: 3; max-height: 360px; overflow-y: auto; }
.results button { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 10px 12px; font: inherit; cursor: pointer; }
.results button:hover, .results button:focus { background: #f3f7fb; }
.results .sub { display: block; }
.results .none { padding: 14px; color: var(--muted); }
.picked { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; background: #f3f7fb; border: 1px solid #d5e2f0; border-radius: var(--radius); padding: 12px 14px; }
table.lines { width: 100%; border-collapse: collapse; }
.lines th { text-align: left; font-size: 12px; color: var(--muted); padding: 0 6px 6px; }
.lines td { padding: 4px 6px; }
.lines .sno { width: 48px; text-align: center; color: var(--muted); }
.lines .amt { width: 170px; }
.lines .amt input { text-align: right; }
.lines .total { text-align: right; font-size: 20px; font-weight: 700; padding-top: 10px; padding-right: 12px; }
.row3 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 14px; }
.side h2 { margin-bottom: 8px; }

/* Students, settings */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
.facts dt { color: var(--muted); font-size: 13.5px; }
.facts dd { margin: 0; font-weight: 600; }
.logo-row { display: flex; gap: 18px; align-items: center; }
.logo-preview { height: 80px; border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: #fff; }
.child .paid { text-align: right; }
.child .paid span { display: block; font-size: 12px; color: var(--muted); }
.child .paid b { font-size: 20px; }

/* Sign in */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, #1d3b5f, #10233a); }
.login-card { width: 100%; max-width: 400px; padding: 28px; text-align: center; }
.login-card .f { text-align: left; }
.login-logo { max-width: 240px; width: 70%; margin-bottom: 8px; }
.login-card h1 { margin-bottom: 4px; }
.login-card .sub { margin: 0 0 20px; }
.login-card .hint { font-size: 12.5px; color: var(--muted); margin: 16px 0 0; }

/* Dialogs */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(480px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
dialog.wide { width: min(720px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(16, 35, 58, .45); }
.dh { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 0; }
.dh h2 { margin: 0; font-size: 17px; }
.db { padding: 14px 18px 4px; }
.df { display: flex; align-items: center; gap: 8px; padding: 10px 18px 16px; }
.df .err { flex: 1; margin: 0; }
.cred { display: grid; gap: 8px; background: var(--bg); border-radius: 10px; padding: 14px; margin-bottom: 10px; }
.cred div { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.cred span { color: var(--muted); font-size: 13px; }
.cred b { font-size: 20px; letter-spacing: .04em; user-select: all; }

/* Toasts */
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: #10233a; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); opacity: 0; transform: translateY(8px); transition: .25s; }
.toast.in { opacity: 1; transform: none; }
.toast.bad { background: var(--bad); }

/* Receipt screen chrome */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .grow { flex: 1; color: var(--muted); }
.toolbar .grow b { color: var(--ink); }
.banner { border-radius: var(--radius); padding: 12px 16px; margin-bottom: 14px; }
.banner.bad { background: var(--bad-bg); color: var(--bad); border: 1px solid #f1c4bf; }

@media (max-width: 900px) {
  .cols, .issue, .form-grid, .form-grid.four, .row3 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .brand span { display: none; }
  .me .nm { display: none; }
  .toolbar .grow { flex-basis: 100%; order: -1; }
}
@media (max-width: 520px) {
  .tiles { grid-template-columns: 1fr; }
  .filters .f { width: 100%; }
}

/* A parent's receipts on a phone: one card per receipt, the amount never off-screen.
   Columns: 1 receipt · 2 date · 3 for · 4 paid by · 5 amount. */
@media (max-width: 640px) {
  .grid.stack thead { display: none; }
  .grid.stack, .grid.stack tbody { display: block; }
  .grid.stack tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .grid.stack tr:last-child { border-bottom: 0; }
  .grid.stack td { padding: 0; border: 0; }
  .grid.stack td:nth-child(1) { grid-area: 1 / 1; }
  .grid.stack td:nth-child(5) { grid-area: 1 / 2; font-size: 16px; }
  .grid.stack td:nth-child(2) { grid-area: 2 / 1; color: var(--muted); font-size: 13px; }
  .grid.stack td:nth-child(4) { grid-area: 2 / 2; color: var(--muted); font-size: 13px; text-align: right; }
  .grid.stack td:nth-child(3) { grid-area: 3 / 1 / 4 / 3; max-width: none; white-space: normal; font-size: 13.5px; }
}
