/* ==========================================================================
   mcems_portal.css — Parent Portal (Phase 8). Mobile first; builds on the
   tokens, buttons, chips and fields of mcems_theme.css (light and dark).
   ========================================================================== */

body.portal { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 var(--font-body); -webkit-font-smoothing: antialiased; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
body.portal--auth { padding-bottom: 0; }
.portal h1 { font-size: 22px; }
.portal h2 { font-size: 17px; }
.pt-small { font-size: 12.5px; }
.pt-mono { font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace; letter-spacing: .03em; }
.pt-block { width: 100%; }
.pt-big { min-height: 50px; font-size: 16px; }
.pt-due { color: var(--danger-fg); }
.pt-clear { color: var(--ok-fg); }

/* ── Top bar ─────────────────────────────────────────────────────────────── */
.pt-top { position: sticky; top: 0; z-index: 20; background: var(--topbar-bg); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); }
.pt-top__in { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 10px; padding: 10px 16px; }
.pt-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); margin-right: auto; min-width: 0; }
.pt-brand img { width: 34px; height: 34px; border-radius: 10px; object-fit: contain; background: #fff; }
.pt-brand span { display: grid; line-height: 1.15; }
.pt-brand b { font-family: var(--font-head); font-size: 15px; color: var(--mc-royal); }
:root[data-theme="dark"] .pt-brand b { color: var(--mc-gold); }
.pt-brand small { font-size: 11.5px; color: var(--muted); }
.pt-topnav { display: none; gap: 4px; }
.pt-topnav a { display: inline-flex; gap: 7px; align-items: center; padding: 8px 12px; border-radius: 10px; text-decoration: none; color: var(--text-2); font-weight: 600; font-size: 14px; }
.pt-topnav a:hover { background: var(--surface-2); }
.pt-topnav a[aria-current="page"] { background: var(--info-bg); color: var(--mc-royal); }
:root[data-theme="dark"] .pt-topnav a[aria-current="page"] { color: var(--info-fg); }
.pt-out { margin: 0; }
.pt-theme { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; }
.pt-hide-sm { display: none; }

/* ── Bottom tab bar (phones) ─────────────────────────────────────────────── */
.pt-tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
.pt-tabbar a { display: grid; justify-items: center; gap: 2px; padding: 9px 4px 10px; text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 600; }
.pt-tabbar a i { font-size: 19px; }
.pt-tabbar a[aria-current="page"] { color: var(--mc-royal); }
:root[data-theme="dark"] .pt-tabbar a[aria-current="page"] { color: var(--mc-gold); }

@media (min-width: 720px) {
  body.portal { padding-bottom: 32px; }
  .pt-topnav { display: flex; }
  .pt-tabbar { display: none; }
  .pt-hide-sm { display: inline; }
}

/* ── Page ────────────────────────────────────────────────────────────────── */
.pt-main { max-width: 760px; margin: 0 auto; padding: 16px; display: grid; gap: 14px; }
.pt-head { display: grid; gap: 2px; }
.pt-head p { margin: 0; }
.pt-back { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; text-decoration: none; font-size: 14px; justify-self: start; padding: 6px 0; }
.pt-card { padding: 16px; border-radius: 18px; }
.pt-card__title { margin: 0 0 10px; }
.pt-section { display: grid; gap: 10px; }
.pt-section__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pt-section__head a { font-weight: 600; font-size: 14px; }
.pt-empty { text-align: center; display: grid; gap: 6px; justify-items: center; padding: 28px 18px; }
.pt-empty > i { font-size: 34px; color: var(--mc-royal); opacity: .7; }
.pt-empty p { margin: 0; }

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.pt-alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; font-size: 14px; background: var(--info-bg); color: var(--info-fg); }
.pt-alert--error { background: var(--danger-bg); color: var(--danger-fg); }
.pt-alert--ok { background: var(--ok-bg); color: var(--ok-fg); }
.pt-alert--warn { background: var(--warn-bg); color: var(--warn-fg); }
.pt-alert i { margin-top: 3px; }

/* ── Child cards (home) ──────────────────────────────────────────────────── */
.pt-kids { display: grid; gap: 14px; }
.pt-kid { padding: 0; overflow: hidden; border-top: 4px solid var(--c, var(--mc-royal)); }
.pt-kid__head { display: flex; align-items: center; gap: 14px; padding: 16px; text-decoration: none; color: var(--text); }
.pt-kid__head:hover { background: var(--surface-2); }
.pt-kid__who { display: grid; gap: 3px; min-width: 0; flex: 1; }
.pt-kid__who b { font-family: var(--font-head); font-size: 17px; }
.pt-kid__who > span:not(.chip) { color: var(--muted); font-size: 13.5px; }
.pt-kid__who .chip { justify-self: start; --c: inherit; }
.pt-kid__go { color: var(--muted); }
.pt-kid__stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); border-top: 1px solid var(--border); }
.pt-stat { display: grid; gap: 4px; padding: 12px 16px; border-right: 1px solid var(--border); text-decoration: none; color: var(--text); }
.pt-stat:last-child { border-right: 0; }
.pt-stat--link:hover { background: var(--surface-2); }
.pt-stat__label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; color: var(--muted); }
.pt-stat__value { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.pt-kid__actions { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pt-kid__actions .btn { flex: 1; min-height: 42px; }
.pt-alerts { list-style: none; margin: 0; padding: 0 16px 12px; display: grid; gap: 6px; }
.pt-alerts__item { display: flex; gap: 9px; align-items: center; padding: 9px 12px; border-radius: 12px; font-size: 13.5px; font-weight: 600; background: var(--info-bg); color: var(--info-fg); }
.pt-alerts__item--danger { background: var(--danger-bg); color: var(--danger-fg); }
.pt-alerts__item--warn { background: var(--warn-bg); color: var(--warn-fg); }

.pt-avatar { width: 58px; height: 58px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; background: var(--surface-3); }
.pt-avatar--ini { display: inline-grid; place-items: center; font-family: var(--font-head); font-weight: 700; font-size: 20px; color: #fff; background: var(--c, var(--mc-royal)); }
.pt-avatar--lg { width: 92px; height: 92px; font-size: 30px; }

/* ── Child page ──────────────────────────────────────────────────────────── */
.pt-profile { display: grid; gap: 16px; justify-items: center; border-top: 4px solid var(--c, var(--mc-royal)); }
.pt-dl { margin: 0; display: grid; gap: 0; width: 100%; }
.pt-dl > div { display: grid; grid-template-columns: 42% 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.pt-dl > div:last-child { border-bottom: 0; }
.pt-dl dt { color: var(--muted); font-size: 13.5px; }
.pt-dl dd { margin: 0; font-weight: 600; word-break: break-word; }
@media (min-width: 560px) { .pt-profile { grid-template-columns: auto 1fr; justify-items: start; align-items: start; } }
.pt-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.pt-tile { display: grid; gap: 5px; align-content: start; text-decoration: none; color: var(--text); }
.pt-tile > i { font-size: 20px; color: var(--mc-royal); }
:root[data-theme="dark"] .pt-tile > i { color: var(--mc-gold); }
.pt-tile__label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; color: var(--muted); }
.pt-tile__value { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pt-tile__more { font-size: 13px; font-weight: 600; color: var(--link); }
.pt-tile--link:hover { border-color: var(--mc-royal); }
.pt-soon h2 { display: flex; gap: 8px; align-items: center; }
.pt-soon p { margin: 6px 0 0; }

/* ── Fees ────────────────────────────────────────────────────────────────── */
.pt-balance { display: grid; gap: 4px; text-align: center; padding: 22px 16px; }
.pt-balance__label { font-weight: 700; color: var(--text-2); }
.pt-balance__amt { font-family: var(--font-head); font-size: 32px; font-variant-numeric: tabular-nums; }
.pt-balance--due .pt-balance__amt { color: var(--danger-fg); }
.pt-balance--clear .pt-balance__amt { color: var(--ok-fg); }
.pt-table-wrap { overflow-x: auto; margin: 0 -4px; }
.pt-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.pt-table th, .pt-table td { padding: 9px 6px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.pt-table thead th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.pt-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pt-table tfoot th, .pt-table tfoot td, .pt-table .pt-sub th, .pt-table .pt-sub td { border-bottom: 0; border-top: 2px solid var(--border-strong); }
.pt-table tbody tr:last-child td, .pt-table tbody tr:last-child th { border-bottom: 0; }
.pt-table--compact td, .pt-table--compact th { padding: 7px 6px; }
.pt-void td { color: var(--muted); }
.pt-term { display: grid; gap: 8px; }
.pt-term__head { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
.pt-paycode { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); border: 1px dashed var(--border-strong); }
.pt-paycode span { font-size: 13px; color: var(--muted); width: 100%; }
.pt-paycode strong { font-size: 24px; }
.pt-list { margin: 10px 0; padding-left: 18px; display: grid; gap: 8px; }
.pt-list--plain { list-style: none; padding: 0; }
.pt-list--plain li { padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.pt-list--plain li:last-child { border-bottom: 0; }

/* ── Notices ─────────────────────────────────────────────────────────────── */
.pt-notice { display: grid; gap: 4px; text-decoration: none; color: var(--text); }
a.pt-notice:hover { border-color: var(--mc-royal); }
.pt-notice__meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pt-notice__snip { color: var(--text-2); font-size: 14px; }
.pt-notice--full h2 { margin: 2px 0 4px; }
.pt-notice__body { color: var(--text-2); }
.pt-notice--open { box-shadow: 0 0 0 3px var(--focus); }

/* ── Forms, sign-in and activation ───────────────────────────────────────── */
.pt-form { display: grid; gap: 14px; }
.pt-form .input { min-height: 48px; font-size: 16px; }   /* 16px: no zoom on iPhone */
.pt-pin { position: relative; }
.pt-pin__input { letter-spacing: .4em; font-variant-numeric: tabular-nums; padding-right: 48px; }
.pt-pin__eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 10px; }
.pt-code { text-transform: uppercase; letter-spacing: .2em; font-family: ui-monospace, Menlo, Consolas, monospace; }
.pt-auth { min-height: 100vh; min-height: 100dvh; display: grid; place-content: center; gap: 14px; padding: 20px 16px; background:
  radial-gradient(1200px 500px at 50% -10%, rgba(38,37,140,.16), transparent 60%), var(--bg); }
.pt-auth__card { width: min(420px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow-md); padding: 24px 20px; display: grid; gap: 14px; }
.pt-auth__card h1 { font-size: 24px; }
.pt-auth__card > p { margin: 0; }
.pt-auth__logo { width: 56px; height: 56px; border-radius: 14px; background: #fff; object-fit: contain; }
.pt-auth__eyebrow { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--mc-royal); margin: 0; }
:root[data-theme="dark"] .pt-auth__eyebrow { color: var(--mc-gold); }
.pt-auth__links { display: grid; gap: 8px; border-top: 1px solid var(--border); padding-top: 14px; }
.pt-auth__links p { margin: 0; }
.pt-auth__foot { text-align: center; font-size: 12.5px; color: var(--muted); max-width: 420px; margin: 0 auto; }

@media print {
  .pt-top, .pt-tabbar, .pt-back, .pt-noprint, .pt-kid__actions { display: none !important; }
  body.portal { background: #fff; padding: 0; }
  .pt-card { box-shadow: none; break-inside: avoid; }
}

/* ── Phase 8B: section pages ─────────────────────────────────────────────── */
.pt-row { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--text); }
a.pt-row:hover { border-color: var(--mc-royal); }
.pt-row__icon { font-size: 20px; width: 28px; text-align: center; color: var(--mc-royal); flex: 0 0 auto; }
:root[data-theme="dark"] .pt-row__icon { color: var(--mc-gold); }
.pt-row__main { display: grid; gap: 2px; flex: 1; min-width: 0; }
.pt-row > .chip { flex: 0 0 auto; }
.pt-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--c, var(--mc-royal)); flex: 0 0 auto; }
.pt-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.pt-chips .chip { font-size: 13px; padding: 7px 12px; text-decoration: none; border: 0; cursor: pointer; font-family: inherit; }
.pt-date { display: grid; justify-items: center; width: 46px; flex: 0 0 auto; font-size: 11px; text-transform: uppercase; font-weight: 700; color: var(--muted); line-height: 1.1; }
.pt-date b { font-size: 20px; color: var(--text); font-family: var(--font-head); }

.pt-menu { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 560px) { .pt-menu { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.pt-menu__item { display: flex; gap: 12px; align-items: flex-start; padding: 16px 14px; text-decoration: none; color: var(--text); min-height: 76px; }
.pt-menu__item:hover { border-color: var(--mc-royal); }
.pt-menu__item i { font-size: 22px; color: var(--mc-royal); width: 26px; text-align: center; margin-top: 2px; }
:root[data-theme="dark"] .pt-menu__item i { color: var(--mc-gold); }
.pt-menu__item span { display: grid; gap: 2px; min-width: 0; }
.pt-menu__item b { font-size: 15px; }
.pt-menu__item small { color: var(--muted); font-size: 12.5px; line-height: 1.3; }

/* attendance */
.pt-att-sum { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 560px) { .pt-att-sum { grid-template-columns: repeat(4, 1fr); } }
.pt-att-sum div { display: grid; gap: 2px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.pt-att-sum b { font: 700 22px/1.1 var(--font-head); }
.pt-att-sum span { font-size: 12.5px; color: var(--muted); }
.pt-cal__nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.pt-cal__row, .pt-cal__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.pt-cal__dn { text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; padding: 4px 0; }
.pt-cal__d { aspect-ratio: 1 / 1; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; align-content: center; gap: 0; position: relative; border: 1px solid var(--border); }
.pt-cal__d--pad { background: transparent; border: 0; }
.pt-cal__n { font-size: 11px; color: var(--muted); line-height: 1; }
.pt-cal__c { font-weight: 800; font-size: 14px; line-height: 1.2; min-height: 1.2em; }
.pt-cal__d--ok { background: var(--ok-bg); color: var(--ok-fg); border-color: transparent; }
.pt-cal__d--warn { background: var(--warn-bg); color: var(--warn-fg); border-color: transparent; }
.pt-cal__d--danger { background: var(--danger-bg); color: var(--danger-fg); border-color: transparent; }
.pt-cal__d--info { background: var(--info-bg); color: var(--info-fg); border-color: transparent; }
.pt-cal__d--off { background: repeating-linear-gradient(135deg, var(--surface-3), var(--surface-3) 4px, transparent 4px, transparent 8px); border-color: transparent; }
.pt-cal__d--future { opacity: .45; }
.pt-cal__d--today { box-shadow: 0 0 0 2px var(--mc-royal); }
.pt-cal__d > span { color: inherit; }
.pt-legend { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 13px; }
.pt-legend li { display: flex; align-items: center; gap: 6px; }
.pt-cal__key { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; font-weight: 800; font-size: 11px; border: 1px solid var(--border); }

/* timetable */
.pt-tt { display: grid; gap: 12px; }
.pt-tt__day[data-off] { display: none; }
@media (min-width: 900px) { .pt-tt { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); } .pt-tt__day[data-off] { display: block; } .pt-tt-days { display: none; } }
.pt-tt__list { list-style: none; margin: 0; padding: 0; }
.pt-tt__item { display: grid; grid-template-columns: 52px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.pt-tt__item:last-child { border-bottom: 0; }
.pt-tt__item--break { background: var(--surface-2); margin: 0 -8px; padding: 6px 8px; border-radius: 8px; }
.pt-tt__time { font-size: 12.5px; font-variant-numeric: tabular-nums; font-weight: 600; }
.pt-tt__what { display: grid; gap: 1px; }

/* assignments */
.pt-asg summary { display: flex; align-items: center; gap: 12px; cursor: pointer; list-style: none; }
.pt-asg summary::-webkit-details-marker { display: none; }
.pt-asg[open] summary { margin-bottom: 10px; }
.pt-asg__body { display: grid; gap: 8px; justify-items: start; border-top: 1px solid var(--border); padding-top: 10px; }
.pt-asg__body p { margin: 0; }
.pt-alerts__item--ok { background: var(--ok-bg); color: var(--ok-fg); }

/* ── Balance on every screen size (update 14a, 14 Nov 2026) ─────────────────
   1. The "Parent Portal · Master Cares Schools" name never shrinks under the menu (it overlapped the Home button).
   2. The top menu shows from 1000px; tablets (720–999px) keep the bottom tab bar, where all five items fit.
   3. Laptops use a wider page (1040px): children side by side, section tiles four across.
   4. Tiles and children cards fill rows evenly; an odd last row is centred instead of hanging on the left.
   5. Nothing in a page can make it wider than the phone screen (the account page was 20px too wide). */
.pt-brand { flex: 0 0 auto; }
.pt-brand span { white-space: nowrap; }
.pt-topnav { min-width: 0; }
.pt-topnav a { white-space: nowrap; }
.pt-main { grid-template-columns: minmax(0, 1fr); }
.pt-main > * { min-width: 0; }

@media (min-width: 720px) and (max-width: 999.98px) {
  body.portal { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .pt-topnav { display: none; }
  .pt-tabbar { display: grid; }
}

.pt-menu { display: flex; flex-wrap: wrap; justify-content: center; }
.pt-menu > * { flex: 0 0 calc((100% - 12px) / 2); min-width: 0; }
@media (min-width: 560px) { .pt-menu > * { flex-basis: calc((100% - 24px) / 3); } }

.pt-kids { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; }
.pt-kids > * { flex: 1 1 100%; min-width: 0; }

.pt-card .pt-form { max-width: 620px; }

@media (min-width: 1000px) {
  .pt-top__in, .pt-main { max-width: 1040px; }
  .pt-menu > * { flex-basis: calc((100% - 36px) / 4); }
  .pt-kids > * { flex: 0 0 calc((100% - 14px) / 2); }
  .pt-kids > :only-child { flex-basis: 100%; }
}
.pt-main > form.pt-form { width: 100%; max-width: 720px; justify-self: center; }
/* a lone stat box (learner portal: "Today" only) is a slim one-line bar instead of a wide empty box */
.pt-tiles > :only-child { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.pt-tiles > :only-child > * { margin: 0; }
