/* Parent app (app.php, parent.php, parent-login.php). Uses the colours of css/site.css. */
:root {
  --ap-bar: #155a9c;
  --ap-bar-ink: #ffffff;
  --ap-gold: #ffbf3a;
  --ap-ok: #1f7a35; --ap-ok-bg: #e3f3e3;
  --ap-bad: #b3261e; --ap-bad-bg: #fbe7e5;
  --ap-warn: #8a5a00; --ap-warn-bg: #fdf0d2;
  --ap-off: #eceae4; --ap-off-ink: #8a8f9c;
  --ap-tabs-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ap-bar: #061526;
    --ap-ok: #8fd19e; --ap-ok-bg: #173a22;
    --ap-bad: #f2a29b; --ap-bad-bg: #4a1c19;
    --ap-warn: #e6b85a; --ap-warn-bg: #3a2e0c;
    --ap-off: #1b2a48; --ap-off-ink: #7f8aa3;
  }
}
:root[data-theme="dark"] {
  --ap-bar: #061526;
  --ap-ok: #8fd19e; --ap-ok-bg: #173a22;
  --ap-bad: #f2a29b; --ap-bad-bg: #4a1c19;
  --ap-warn: #e6b85a; --ap-warn-bg: #3a2e0c;
  --ap-off: #1b2a48; --ap-off-ink: #7f8aa3;
}

.ap-body { margin: 0; background: var(--bg); color: var(--text); min-height: 100vh; padding-bottom: calc(var(--ap-tabs-h) + env(safe-area-inset-bottom)); -webkit-tap-highlight-color: transparent; }
.ap-body svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Top bar ---------- */
.ap-top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  background: var(--ap-bar); color: var(--ap-bar-ink);
  padding: calc(10px + env(safe-area-inset-top)) 10px 10px 14px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}
.ap-logo { width: 36px; height: 36px; border-radius: 50%; background: #fff; object-fit: contain; padding: 2px; flex: none; }
.ap-title { min-width: 0; flex: 1; }
.ap-title b { display: block; font: 700 1.02rem/1.2 "Newsreader", Georgia, serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-title span { display: block; font-size: 0.76rem; opacity: 0.8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-iconbtn { position: relative; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; color: inherit; text-decoration: none; flex: none; }
.ap-iconbtn:hover, .ap-iconbtn:focus-visible { background: rgba(255, 255, 255, 0.12); }
.ap-iconbtn.sm { width: 36px; height: 36px; color: var(--brand); background: var(--surface-2); }
.ap-iconbtn.off { visibility: hidden; }
.ap-dot { position: absolute; top: 8px; right: 9px; width: 9px; height: 9px; border-radius: 50%; background: var(--ap-gold); border: 2px solid var(--ap-bar); }
.ap-dot[hidden] { display: none; }

/* ---------- Bottom tabs ---------- */
.ap-tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.06);
}
.ap-tabs a { display: grid; justify-items: center; gap: 2px; padding: 4px 0; color: var(--text-muted); text-decoration: none; font-size: 0.68rem; font-weight: 600; border-radius: 10px; }
.ap-tabs a[aria-current="page"] { color: var(--brand); }
.ap-tabs a[aria-current="page"] svg { stroke-width: 2.3; }

/* ---------- Content ---------- */
.ap-main { max-width: 640px; margin: 0 auto; padding: 14px 14px 22px; }
.ap-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 14px; margin-bottom: 12px; }
.ap-h { display: flex; align-items: baseline; gap: 8px; margin: 0 0 8px; font: 700 1rem "Newsreader", Georgia, serif; }
.ap-h a { margin-left: auto; font: 600 0.8rem "Public Sans", system-ui, sans-serif; color: var(--brand); }
.ap-h small { font: 500 0.75rem "Public Sans", system-ui, sans-serif; color: var(--text-muted); }
.ap-muted { color: var(--text-muted); font-size: 0.84rem; margin: 6px 0; }
.ap-muted.bad, b.bad { color: var(--ap-bad); }
b.good { color: var(--ap-ok); }
.ap-center { text-align: center; }
.ap-mono { font-family: "IBM Plex Mono", monospace; }
.ap-wide { display: block; width: 100%; text-align: center; box-sizing: border-box; margin: 0 0 6px; }
.ap-flash { border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; font-size: 0.9rem; font-weight: 600; }
.ap-flash.ok { background: var(--ap-ok-bg); color: var(--ap-ok); }
.ap-flash.err { background: var(--ap-bad-bg); color: var(--ap-bad); }
.ap-alert { border-radius: 14px; padding: 11px 13px; margin-bottom: 12px; font-size: 0.9rem; font-weight: 600; }
.ap-alert.urgent { background: var(--ap-bad-bg); color: var(--ap-bad); }
.ap-alert.important { background: var(--ap-warn-bg); color: var(--ap-warn); }

/* Child */
.ap-child { display: flex; align-items: center; gap: 12px; }
.ap-avatar { width: 58px; height: 58px; border-radius: 16px; object-fit: cover; flex: none; background: var(--surface-2); }
.ap-avatar.sm { width: 42px; height: 42px; border-radius: 12px; }
.ap-initial { display: grid; place-items: center; background: var(--brand); color: var(--brand-ink); font: 700 1.5rem "Newsreader", Georgia, serif; }
.ap-avatar.sm.ap-initial { font-size: 1.1rem; }
.ap-child-who { min-width: 0; flex: 1; }
.ap-child-who b { display: block; font: 700 1.12rem/1.2 "Newsreader", Georgia, serif; color: var(--brand); }
.ap-child-who span { display: block; font-size: 0.8rem; color: var(--text-muted); }
.ap-chip { flex: none; font: 700 0.76rem "Public Sans", system-ui, sans-serif; color: var(--brand); background: var(--surface-2); border: 0; border-radius: 999px; padding: 7px 12px; text-decoration: none; cursor: pointer; }
.ap-chip.ghost { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }

/* Fee due strip */
.ap-due { display: flex; align-items: center; gap: 10px; background: var(--ap-warn-bg); border: 1px solid rgba(200, 143, 17, 0.4); border-radius: 14px; padding: 11px 12px; margin-bottom: 12px; color: var(--ap-warn); text-decoration: none; }
.ap-due b { display: block; font-size: 0.92rem; }
.ap-due small { display: block; font-size: 0.75rem; opacity: 0.85; }
.ap-due-go { margin-left: auto; background: var(--ap-gold); color: #1a1300; border-radius: 999px; padding: 6px 13px; font-weight: 700; font-size: 0.8rem; }

/* Stats and tiles */
.ap-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.ap-stats > * { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 10px 6px; text-align: center; text-decoration: none; color: inherit; min-width: 0; }
.ap-stats b { display: block; font: 700 1.08rem "Newsreader", Georgia, serif; color: var(--brand); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-stats span { font-size: 0.7rem; color: var(--text-muted); }
.ap-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.ap-tiles a { display: grid; justify-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 13px 4px 11px; font-size: 0.78rem; font-weight: 600; color: var(--text); text-decoration: none; }
.ap-tiles svg { width: 26px; height: 26px; color: var(--brand); stroke-width: 1.7; }

/* Notices and messages */
.ap-notice { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); }
.ap-notice:first-of-type { border-top: 0; padding-top: 2px; }
.ap-notice strong { font-size: 0.9rem; }
.ap-notice small { display: block; font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.ap-date { flex: none; width: 44px; text-align: center; background: var(--surface-2); border-radius: 10px; padding: 4px 0; font-size: 0.68rem; color: var(--text-muted); align-self: flex-start; }
.ap-date b { display: block; font-size: 1.05rem; color: var(--brand); }
.ap-note { display: block; padding: 10px 0; border-top: 1px solid var(--border); color: inherit; text-decoration: none; }
.ap-note:first-of-type { border-top: 0; padding-top: 2px; }
.ap-note b { display: block; font-size: 0.92rem; }
.ap-note span { display: block; font-size: 0.84rem; color: var(--text-muted); margin-top: 2px; }
.ap-note small { display: block; font-size: 0.72rem; color: var(--text-muted); margin-top: 4px; }
.ap-note.new b::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ap-gold); margin-right: 6px; vertical-align: 1px; }
.ap-pill { display: inline-block; font-style: normal; font-size: 0.68rem; font-weight: 700; border-radius: 999px; padding: 2px 8px; text-decoration: none; vertical-align: 1px; }
.ap-pill.ok { background: var(--ap-ok-bg); color: var(--ap-ok); }
.ap-pill.bad { background: var(--ap-bad-bg); color: var(--ap-bad); }
.ap-pill.warn { background: var(--ap-warn-bg); color: var(--ap-warn); }
.ap-pill.tag { background: var(--surface-2); color: var(--text-muted); }

/* Install / notification prompts */
.ap-install, .ap-push-box { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px dashed var(--border); border-radius: 14px; padding: 11px 12px; margin-bottom: 12px; }
.ap-install[hidden], .ap-push-box[hidden] { display: none; }
.ap-install > span, .ap-push-box > span { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; flex: 1; min-width: 0; }
.ap-install svg, .ap-push-box svg { grid-row: span 2; color: var(--brand); }
.ap-install b, .ap-push-box b { font-size: 0.9rem; }
.ap-install small, .ap-push-box small { font-size: 0.76rem; color: var(--text-muted); }
.ap-install .btn, .ap-push-box .btn { padding: 8px 14px; font-size: 0.82rem; flex: none; }

/* Sheet: choose a child */
.ap-sheet { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.45); display: flex; align-items: flex-end; justify-content: center; }
.ap-sheet[hidden] { display: none; }
.ap-sheet-box { width: 100%; max-width: 520px; background: var(--surface); border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 80vh; overflow-y: auto; }
.ap-sheet-box h2 { margin: 0 0 10px; font: 700 1.1rem "Newsreader", Georgia, serif; }
.ap-kid-row { margin: 0; }
.ap-kid-row button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); margin-bottom: 8px; text-align: left; font: inherit; cursor: pointer; }
.ap-kid-row button[aria-current="true"] { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(21, 90, 156, 0.15); }
.ap-kid-row b, .ap-kid b { display: block; font-size: 0.95rem; }
.ap-kid-row small, .ap-kid small { display: block; font-size: 0.76rem; color: var(--text-muted); }
.ap-add { display: flex; align-items: center; gap: 8px; padding: 10px 2px; color: var(--brand); font-weight: 700; font-size: 0.9rem; text-decoration: none; }
.ap-close { width: 100%; margin-top: 6px; justify-content: center; text-align: center; }
.ap-kid { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.ap-kid:first-of-type { border-top: 0; }
.ap-kid > span:not(.ap-avatar) { flex: 1; min-width: 0; }
.ap-kid form { margin: 0; }

/* Attendance */
.ap-month { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.ap-month h2 { margin: 0; font: 700 1.1rem "Newsreader", Georgia, serif; }
.ap-cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; text-align: center; font-size: 0.84rem; }
.ap-cal .h { font-size: 0.66rem; color: var(--text-muted); font-weight: 600; padding-bottom: 2px; }
.ap-cal span:not(.h) { border-radius: 9px; padding: 7px 0 5px; font-weight: 600; min-height: 34px; display: grid; align-content: center; line-height: 1.1; }
.ap-cal small { font-size: 0.56rem; font-weight: 700; }
.ap-cal .P { background: var(--ap-ok-bg); color: var(--ap-ok); }
.ap-cal .A { background: var(--ap-bad-bg); color: var(--ap-bad); }
.ap-cal .L, .ap-cal .H { background: var(--ap-warn-bg); color: var(--ap-warn); }
.ap-cal .V { background: #e6ecf8; color: #3a5a99; }
.ap-cal .off { background: var(--ap-off); color: var(--ap-off-ink); }
.ap-cal .fut { color: var(--text-muted); opacity: 0.55; }
.ap-cal .today { outline: 2px solid var(--brand); outline-offset: -2px; }
.ap-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 10px; font-size: 0.72rem; color: var(--text-muted); }
.ap-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.ap-legend .P { background: var(--ap-ok); } .ap-legend .A { background: var(--ap-bad); } .ap-legend .L, .ap-legend .H { background: var(--ap-gold); }
.ap-legend .V { background: #3a5a99; } .ap-legend .off { background: var(--ap-off-ink); }
.ap-row { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-top: 1px solid var(--border); font-size: 0.88rem; }
.ap-row:first-of-type { border-top: 0; }
.ap-row.tot { font-weight: 700; border-top: 2px solid var(--border); }
.ap-bigpct { display: flex; align-items: baseline; gap: 10px; }
.ap-bigpct b { font: 700 2rem "Newsreader", Georgia, serif; color: var(--brand); }
.ap-bigpct.low b { color: var(--ap-bad); }
.ap-bigpct span { font-size: 0.84rem; color: var(--text-muted); }
.ap-bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.ap-bar i { display: block; height: 100%; background: var(--brand); border-radius: 4px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ap-cal .V { background: #1d2c4f; color: #a9c0ef; } }

/* Fees */
.ap-total { display: grid; gap: 2px; background: var(--ap-bar); color: #fff; border-radius: 16px; padding: 14px 16px; margin-bottom: 10px; }
.ap-total.ok { background: #1f6a35; }
.ap-total span { font-size: 0.8rem; opacity: 0.85; }
.ap-total b { font: 700 1.9rem "Newsreader", Georgia, serif; }
.ap-total small { font-size: 0.78rem; opacity: 0.85; }
.ap-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); color: inherit; text-decoration: none; }
.ap-item:first-of-type { border-top: 0; }
.ap-item > span:first-child { flex: 1; min-width: 0; }
.ap-item b { display: block; font-size: 0.9rem; }
.ap-item small { display: block; font-size: 0.74rem; color: var(--text-muted); }
.ap-item.ap-link > span:first-child { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; }
.ap-item.ap-link svg { grid-row: span 2; color: var(--brand); align-self: center; }
.ap-item.cancelled { opacity: 0.6; }
.ap-item.cancelled .ap-amt { text-decoration: line-through; }
.ap-amt { flex: none; text-align: right; font-weight: 700; font-size: 0.9rem; white-space: nowrap; display: grid; justify-items: end; gap: 3px; }
.ap-details summary { cursor: pointer; font-weight: 700; display: flex; align-items: center; gap: 8px; list-style: none; }
.ap-details summary::-webkit-details-marker { display: none; }
.ap-details summary::after { content: "+"; margin-left: auto; font-size: 1.2rem; color: var(--text-muted); }
.ap-details[open] summary::after { content: "−"; }
.ap-details[open] summary { margin-bottom: 8px; }
.ap-details summary small { font-weight: 500; color: var(--text-muted); }

/* Empty */
.ap-empty { text-align: center; padding: 36px 16px; color: var(--text-muted); }
.ap-empty svg { width: 48px; height: 48px; color: var(--brand); stroke-width: 1.4; }
.ap-empty h2 { color: var(--text); font: 700 1.2rem "Newsreader", Georgia, serif; margin: 10px 0 6px; }
.ap-empty p { margin: 0 auto; max-width: 340px; font-size: 0.9rem; }

/* ID card */
.ap-idc { width: 100%; max-width: 300px; margin: 6px auto 12px; background: #fff; color: #15213a; border-radius: 16px; overflow: hidden; box-shadow: 0 10px 28px rgba(21, 90, 156, 0.22); text-align: center; }
.ap-idc-head { display: flex; gap: 10px; align-items: center; background: #155a9c; color: #fff; padding: 11px 12px; text-align: left; }
.ap-idc-head img { width: 40px; height: 40px; border-radius: 50%; background: #fff; object-fit: contain; flex: none; }
.ap-idc-head b { display: block; font: 700 0.86rem/1.2 "Newsreader", Georgia, serif; }
.ap-idc-head small { display: block; font-size: 0.62rem; opacity: 0.8; line-height: 1.25; }
.ap-idc-band { background: #ffbf3a; color: #1a1300; font: 700 0.62rem "IBM Plex Mono", monospace; letter-spacing: 0.12em; padding: 4px; }
.ap-idc-photo { width: 96px; height: 118px; margin: 12px auto 6px; border-radius: 10px; object-fit: cover; display: block; background: #c9d6ea; }
.ap-idc-photo.ap-initial { display: grid; font-size: 2.4rem; }
.ap-idc h2 { margin: 0 12px; font: 700 1.1rem "Newsreader", Georgia, serif; color: #155a9c; }
.ap-idc dl { display: grid; gap: 3px; margin: 10px 16px 8px; font-size: 0.8rem; text-align: left; }
.ap-idc dl div { display: grid; grid-template-columns: 92px 1fr; gap: 8px; }
.ap-idc dt { color: #5d6680; font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.04em; align-self: center; }
.ap-idc dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.ap-idc-foot { display: flex; align-items: center; gap: 12px; border-top: 1px solid #e6dfcb; margin: 4px 0 0; padding: 10px 14px 12px; text-align: left; font-size: 0.78rem; }
.ap-idc-foot small { display: block; color: #5d6680; }
.ap-qr { width: 64px; height: 64px; flex: none; }
.ap-qr svg { width: 64px; height: 64px; display: block; stroke: none; }
.ap-qr svg path, .ap-qr svg rect { stroke: none; }

/* More */
.ap-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.ap-btns [hidden] { display: none; }
.ap-how p { font-size: 0.86rem; margin: 8px 0; }
#ap-install-btn { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 6px; }
#ap-install-btn[hidden] { display: none; }
.ap-form { display: grid; gap: 10px; }
.ap-form label { display: grid; gap: 4px; font-size: 0.82rem; font-weight: 600; color: var(--text-muted); }
.ap-form input { font: 500 1rem "Public Sans", system-ui, sans-serif; padding: 11px 12px; border: 1px solid var(--border); border-radius: 11px; background: var(--bg); color: var(--text); }
.ap-links { padding: 4px 14px; }
.ap-links a, .ap-links button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 0; border: 0; border-top: 1px solid var(--border); background: none; color: var(--text); font: 600 0.92rem "Public Sans", system-ui, sans-serif; text-decoration: none; text-align: left; cursor: pointer; }
.ap-links > :first-child { border-top: 0; }
.ap-links svg { color: var(--brand); }
.ap-links form { margin: 0; }
.ap-links form button { color: var(--ap-bad); }
.ap-links form button svg { color: var(--ap-bad); }

/* ---------- Results page inside the app (parent.php) ---------- */
.ap-body .pp-main { background: none; padding: 14px 14px 22px; min-height: 0; }
.ap-body .pp-student { box-shadow: none; padding: 14px; border-radius: 16px; gap: 12px; }
.ap-body .pp-photo { width: 58px; height: 58px; }
.ap-body .pp-who h1 { font-size: 1.25rem; }
.ap-body .pp-actions .btn { padding: 8px 12px; font-size: 0.8rem; }
.ap-body .login-footer { display: none; }
@media (max-width: 560px) {
  .ap-body .pp-student { grid-template-columns: auto 1fr; }
  .ap-body .pp-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

/* ---------- Login inside the app ---------- */
.ap-login .login-stage { padding-top: calc(28px + env(safe-area-inset-top)); }
.pl-remember { display: flex; align-items: flex-start; gap: 10px; margin: 14px 0 0; font-size: 0.88rem; font-weight: 600; color: var(--text); cursor: pointer; }
.pl-remember input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--brand); flex: none; }
.pl-remember small { display: block; font-weight: 500; color: var(--text-muted); font-size: 0.78rem; }

@media print {
  .ap-top, .ap-tabs, .ap-install, .ap-push-box { display: none !important; }
  .ap-body { padding: 0; }
}
