/* =====================================================================
   รอบ 70: หน้าเว็บผู้ปกครอง (/parent) — มือถือเป็นหลัก แบบเดียวกับหน้าร้านออนไลน์ (สว่างเสมอ)
   ไฟล์นี้โหลดทุกหน้า: ทุกกฎขึ้นต้น .pp เพื่อไม่กระทบหน้าอื่น · สีจากตัวแปรใน :root (app.css) + สีของโรงเรียน (--brand*)
   โครง: หัวสีโรงเรียน (ติดบน) → เนื้อหากว้างไม่เกิน 720px → ท้ายหน้า
   ===================================================================== */

.pp {
  --pp-radius: 18px;
  --pp-shadow: 0 2px 10px rgba(120,60,20,.07);
  --pp-present: #1C6B3A;
  --pp-present-bg: #E3F4E8;
  --pp-late: #8A5A00;
  --pp-late-bg: #FDF0D8;
  --pp-leave: #2459A8;
  --pp-leave-bg: #E5EEFB;
  --pp-absent: var(--danger);
  --pp-absent-bg: var(--danger-soft);
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink); overflow-x: clip;
}

/* ---------- หัวโรงเรียน ---------- */
.pp .pp-bar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  min-height: calc(56px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0 14px;
  background: var(--brand-strong); color: #fff;
  box-shadow: 0 2px 10px rgba(var(--brand-rgb), .25);
}
.pp .pp-brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; color: #fff; text-decoration: none; }
.pp .pp-logo {
  flex: none; width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
  background: #fff; color: var(--brand-strong); font-weight: 800; font-size: 1.05rem; line-height: 1;
}
.pp .pp-logo-img { object-fit: contain; padding: 3px; }
.pp .pp-brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.pp .pp-brand-name { font-weight: 700; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp .pp-brand-sub { font-size: .75rem; opacity: .85; }
.pp .pp-bar .lang-switch a { min-height: 30px; padding: 0 10px; }

.pp .pp-main { flex: 1; width: 100%; max-width: 720px; margin: 0 auto; padding: 14px 16px 28px; min-width: 0; }
.pp .pp-footer {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 16px;
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom)); color: var(--muted); font-size: .85rem; text-align: center;
}
.pp .pp-footer strong { color: var(--ink); }
.pp .pp-footer a { color: inherit; }
.pp .pp-logout { margin: 0; }

/* ---------- ทั่วไป ---------- */
.pp h1 { font-size: 1.35rem; }
.pp h2 { font-size: 1.05rem; margin: 0 0 10px; }
.pp .pp-section {
  margin-top: 14px; padding: 16px; border-radius: var(--pp-radius);
  background: var(--surface); box-shadow: var(--pp-shadow);
}
.pp .pp-empty { margin-top: 14px; padding: 24px 16px; border-radius: var(--pp-radius); background: var(--surface); text-align: center; }
.pp .pp-red { color: var(--danger); }
.pp .pp-green { color: var(--ok); }
.pp .pp-tag {
  display: inline-flex; align-items: center; gap: 4px; width: fit-content; padding: 1px 8px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand-strong); font-size: .75rem; font-weight: 600;
}
.pp .pp-tag.red { background: var(--danger-soft); color: var(--danger); }
.pp .pp-back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-size: .9rem; min-height: 36px; }
.pp .pp-back:hover { color: var(--ink); }

/* ---------- หน้าเข้าสู่ระบบ / ตั้ง PIN ---------- */
.pp .pp-auth { max-width: 420px; margin: 18px auto 0; padding: 22px 18px; border-radius: var(--pp-radius); background: var(--surface); box-shadow: var(--pp-shadow); }
.pp .pp-auth h1 { margin-bottom: 6px; }
.pp .pp-form { margin-top: 14px; }
.pp .pp-pin { letter-spacing: .45em; font-size: 1.3rem; text-align: center; font-variant-numeric: tabular-nums; }
.pp .pp-check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: .92rem; }
.pp .pp-check input { width: 20px; height: 20px; accent-color: var(--brand); }
.pp .pp-auth-help { margin-top: 14px; }

/* ---------- ยังไม่เปิดให้ใช้ ---------- */
.pp .pp-closed { max-width: 460px; margin: 40px auto 0; padding: 28px 20px; text-align: center; border-radius: var(--pp-radius); background: var(--surface); box-shadow: var(--pp-shadow); }
.pp .pp-closed-ico { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 20px; background: var(--brand-soft); color: var(--brand-strong); margin-bottom: 10px; }

/* ---------- หน้าแรก ---------- */
.pp .pp-hello h1 { margin-bottom: 6px; }
.pp .pp-welcome { margin: 6px 0 0; padding: 10px 14px; border-radius: 14px; background: var(--brand-soft); font-size: .92rem; }
.pp .pp-dayoff { margin: 8px 0 0; padding: 8px 14px; border-radius: 12px; background: var(--chip); font-size: .9rem; font-weight: 600; }
.pp .pp-kids { display: grid; gap: 12px; margin-top: 14px; }
.pp .pp-kid { border-radius: var(--pp-radius); background: var(--surface); box-shadow: var(--pp-shadow); overflow: hidden; }
.pp .pp-kid-top { display: flex; align-items: center; gap: 12px; padding: 14px; color: var(--ink); text-decoration: none; }
.pp .pp-kid-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pp .pp-kid-text strong { font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp .pp-chev { flex: none; color: var(--muted); }
.pp .pp-avatar {
  flex: none; width: 48px; height: 48px; border-radius: 50%; object-fit: cover; background: var(--chip);
}
.pp .pp-avatar.big { width: 58px; height: 58px; }
.pp .pp-avatar-txt { display: grid; place-items: center; color: var(--brand-strong); background: var(--brand-soft); font-weight: 800; font-size: 1.2rem; }
.pp .pp-kid-stats { display: flex; flex-wrap: wrap; gap: 1px; background: var(--line); border-top: 1px solid var(--line); }
/* รอบ 98: flex แทน grid — จำนวนช่องเป็นเลขคี่ (3) บนมือถือ ช่องสุดท้ายขยายเต็มแถว ไม่เหลือช่องว่างสีเส้น */
.pp .pp-stat { flex: 1 1 140px; display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; background: var(--surface); color: var(--ink); text-decoration: none; min-width: 0; }
.pp .pp-stat:hover { background: var(--brand-tint); }
.pp .pp-stat-lbl { color: var(--muted); font-size: .78rem; }
.pp .pp-stat strong { font-size: 1rem; }
.pp .pp-stat small { font-size: .75rem; }
.pp .pp-kid-links { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px 14px; border-top: 1px solid var(--line); }
.pp .pp-kid-links a {
  display: inline-flex; align-items: center; min-height: 34px; padding: 0 12px; border-radius: 999px;
  background: var(--chip); color: var(--ink); text-decoration: none; font-size: .85rem; font-weight: 600;
}
.pp .pp-kid-links a:hover { background: var(--brand-soft); color: var(--brand-strong); }

.pp .pp-att { font-weight: 700; }
.pp .pp-att-present { color: var(--pp-present); }
.pp .pp-att-late { color: var(--pp-late); }
.pp .pp-att-leave { color: var(--pp-leave); }
.pp .pp-att-absent { color: var(--pp-absent); }

.pp .pp-events { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pp .pp-event { display: flex; flex-direction: column; gap: 1px; padding: 10px 12px; border-radius: 12px; background: var(--bg); border-left: 4px solid var(--brand); }
.pp .pp-event.off { border-left-color: var(--danger); }
.pp .pp-event-date { color: var(--muted); font-size: .8rem; }

/* ---------- หัวหน้าลูก + แท็บ ---------- */
.pp .pp-child-head { display: flex; flex-direction: column; gap: 8px; }
.pp .pp-child-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--pp-radius); background: var(--surface); box-shadow: var(--pp-shadow); }
.pp .pp-child-text { display: flex; flex-direction: column; min-width: 0; }
.pp .pp-child-text strong { font-size: 1.05rem; }
.pp .pp-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.pp .pp-tab {
  display: inline-flex; align-items: center; min-height: 38px; padding: 0 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: .9rem; font-weight: 600;
}
.pp .pp-tab.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

/* ---------- ค่าเรียน ---------- */
.pp .pp-total { display: flex; flex-direction: column; gap: 2px; padding: 14px; border-radius: 14px; background: var(--brand-tint); }
.pp .pp-total span { color: var(--muted); font-size: .85rem; }
.pp .pp-total strong { font-size: 1.6rem; line-height: 1.2; }
.pp .pp-total.late { background: var(--danger-soft); }
.pp .pp-total.late strong, .pp .pp-total.late small { color: var(--danger); }
.pp .pp-fee-sum p { margin: 8px 0 0; }
.pp .pp-payinfo { margin-top: 12px; padding: 12px 14px; border-radius: 14px; border: 1px dashed var(--line); }
.pp .pp-payinfo p { margin: 4px 0 0; }
.pp .pp-lines, .pp .pp-receipts, .pp .pp-scores, .pp .pp-subj-att, .pp .pp-glist, .pp .pp-requests { list-style: none; margin: 0; padding: 0; }
.pp .pp-line { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.pp .pp-line:last-child { border-bottom: 0; }
.pp .pp-line.late .pp-line-amt { color: var(--danger); }
.pp .pp-line.future { opacity: .75; }
.pp .pp-line-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.pp .pp-line-amt { flex: none; white-space: nowrap; }
.pp .pp-receipt { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.pp .pp-receipts li:last-child .pp-receipt { border-bottom: 0; }
.pp .pp-receipt.void { opacity: .6; }
.pp .pp-receipt-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.pp .pp-receipt-items { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp .pp-receipt-amt { flex: none; }
.pp .pp-rcpt-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.pp .pp-partial { background: var(--warn-soft); margin: 0 0 10px; }
.pp .pp-rcpt { display: flex; justify-content: center; }
.pp .pp-rcpt .receipt-paper { max-width: 100%; }

/* ---------- การมาเรียน ---------- */
.pp .pp-month-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.pp .pp-month-nav h2 { margin: 0; text-align: center; flex: 1; }
.pp .pp-month-nav .btn { min-width: 42px; font-size: 1.2rem; text-decoration: none; }
.pp .pp-month-nav .disabled { opacity: .35; pointer-events: none; }
.pp .pp-att-sum { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; margin-bottom: 12px; }
.pp .pp-att-rate { display: flex; flex-direction: column; }
.pp .pp-att-rate strong { font-size: 1.6rem; line-height: 1.1; }
.pp .pp-att-counts { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .88rem; }
.pp .pp-att-counts li { display: inline-flex; align-items: center; gap: 5px; }
.pp .pp-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.pp .pp-dot.present { background: var(--pp-present); }
.pp .pp-dot.late { background: #E0A100; }
.pp .pp-dot.leave { background: var(--pp-leave); }
.pp .pp-dot.absent { background: var(--pp-absent); }
.pp .pp-cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.pp .pp-cal-h { text-align: center; font-size: .72rem; color: var(--muted); padding: 2px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp .pp-cal-d {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  min-height: 44px; border-radius: 10px; background: var(--bg); font-size: .85rem; line-height: 1.15;
}
.pp .pp-cal-d small { font-size: .68rem; font-weight: 700; }
.pp .pp-cal-d.blank { background: transparent; }
.pp .pp-cal-d.future { color: var(--muted); opacity: .6; }
.pp .pp-cal-d.off { background: var(--chip); color: var(--muted); }
.pp .pp-cal-d.present { background: var(--pp-present-bg); color: var(--pp-present); }
.pp .pp-cal-d.late { background: var(--pp-late-bg); color: var(--pp-late); }
.pp .pp-cal-d.leave { background: var(--pp-leave-bg); color: var(--pp-leave); }
.pp .pp-cal-d.absent { background: var(--pp-absent-bg); color: var(--pp-absent); }
.pp .pp-cal-d.today { outline: 2px solid var(--brand); outline-offset: -2px; }
.pp .pp-cal-legend { margin: 10px 0 0; }
.pp .pp-subj-att li, .pp .pp-glist li { display: flex; flex-direction: column; padding: 8px 0; border-bottom: 1px solid var(--line); }
.pp .pp-subj-att li:last-child, .pp .pp-glist li:last-child { border-bottom: 0; }

/* ---------- คะแนน ---------- */
.pp .pp-periods { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.pp .pp-chip {
  display: inline-flex; align-items: center; min-height: 34px; padding: 0 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: .85rem;
}
.pp .pp-chip.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.pp .pp-score-sum { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; margin-bottom: 12px; }
.pp .pp-score-sum > div { display: flex; flex-direction: column; padding: 10px 12px; border-radius: 12px; background: var(--brand-tint); }
.pp .pp-score-sum strong { font-size: 1.3rem; }
.pp .pp-scores li { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.pp .pp-scores li:last-child { border-bottom: 0; }
.pp .pp-scores li > span:first-child { min-width: 0; }
.pp .pp-scores strong { white-space: nowrap; }
.pp .pp-note { margin-top: 12px; padding: 10px 14px; border-radius: 12px; background: var(--chip); }
.pp .pp-note p { margin: 4px 0 0; }

/* ---------- ตารางเรียน ---------- */
.pp .pp-tt { display: grid; gap: 8px; }
.pp .pp-tt-day { border-radius: 14px; background: var(--bg); }
.pp .pp-tt-day summary { display: flex; align-items: center; gap: 8px; padding: 10px 14px; cursor: pointer; min-height: 44px; }
.pp .pp-tt-list { list-style: none; margin: 0; padding: 0 14px 10px; }
.pp .pp-tt-list li { display: flex; gap: 12px; padding: 7px 0; border-top: 1px solid var(--line); }
.pp .pp-tt-list li.brk { color: var(--muted); font-size: .85rem; }
.pp .pp-tt-time { flex: none; width: 92px; color: var(--muted); font-size: .82rem; }
.pp .pp-tt-subj { display: flex; flex-direction: column; min-width: 0; }

/* ---------- ข้อมูลนักเรียน ---------- */
.pp .pp-dl { margin: 0; display: grid; gap: 0; }
.pp .pp-dl > div { display: grid; grid-template-columns: minmax(96px, 38%) 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.pp .pp-dl > div:last-child { border-bottom: 0; }
.pp .pp-dl dt { color: var(--muted); font-size: .88rem; }
.pp .pp-dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.pp .pp-requests li { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; margin-bottom: 8px; border-radius: 12px; background: var(--warn-soft); }
.pp .pp-requests p { margin: 2px 0 0; }
.pp textarea { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); width: 100%; }

@media (min-width: 720px) {
  .pp .pp-main { padding-top: 22px; }
  .pp .pp-kids { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pp .pp-cal-d { min-height: 54px; }
}

/* ---------- พิมพ์ใบเสร็จ ---------- */
@media print {
  .pp { min-height: 0; background: #fff; }
  .pp .pp-main { max-width: none; padding: 0; }
}

/* รอบ 70 (แก้ตามรีวิว): วันหยุดของสาขาลูกแต่ละคน */
.pp .pp-kid-off { margin: 0 14px 10px; }

/* =====================================================================
   รอบ 71: ระยะ 2 — ขอลา / จ่ายผ่าน QR + แนบสลิป / ประกาศ / คะแนนปีก่อน
   ===================================================================== */
.pp .pp-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.pp .pp-form input[type="date"], .pp .pp-form input[type="datetime-local"], .pp .pp-form input[type="text"],
.pp .pp-form input[type="file"], .pp .pp-form select { width: 100%; min-width: 0; max-width: 100%; }
.pp .pp-inline-form { margin: 4px 0 0; }
.pp .pp-top-alert { margin-top: 12px; }
.pp .pp-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.pp .pp-sec-head h2 { margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* คำขอลา / สลิป */
.pp .pp-leaves { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.pp .pp-leave { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; border-radius: 12px; background: var(--bg); border-left: 4px solid var(--line); min-width: 0; }
.pp .pp-leave.pending { border-left-color: #E0A100; }
.pp .pp-leave.approved, .pp .pp-leave.accepted { border-left-color: var(--pp-present); }
.pp .pp-leave.rejected { border-left-color: var(--danger); }
.pp .pp-leave.cancelled { opacity: .65; }
.pp .pp-leave p { margin: 2px 0 0; overflow-wrap: anywhere; }
.pp .pp-leave-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.pp .pp-leave-note { padding: 6px 10px; border-radius: 10px; background: var(--surface); }
.pp .pp-st { display: inline-flex; align-items: center; padding: 1px 9px; border-radius: 999px; font-size: .75rem; font-weight: 700; background: var(--chip); color: var(--ink); }
.pp .pp-st-pending { background: var(--pp-late-bg); color: var(--pp-late); }
.pp .pp-st-approved, .pp .pp-st-accepted { background: var(--pp-present-bg); color: var(--pp-present); }
.pp .pp-st-rejected { background: var(--danger-soft); color: var(--danger); }
.pp .pp-cal-d.leave.planned { outline: 2px dashed var(--pp-leave); outline-offset: -3px; }
.pp .pp-cal-d.leave.pending { background: var(--surface); outline: 2px dashed #E0A100; outline-offset: -3px; color: var(--pp-late); }

/* จ่ายผ่าน QR */
.pp .pp-pay-cta { margin-top: 12px; }
.pp .pp-accounts { display: grid; gap: 12px; }
.pp .pp-account { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 14px; background: var(--bg); min-width: 0; }
.pp .pp-qr { flex: none; width: 140px; max-width: 42vw; height: auto; border-radius: 10px; background: #fff; padding: 6px; }
.pp .pp-account-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.pp .pp-accno { font-size: 1.15rem; font-weight: 700; letter-spacing: .03em; }
.pp .pp-picks { border: 1px solid var(--line); border-radius: 14px; padding: 6px 10px; margin: 0; min-width: 0; }
.pp .pp-picks legend { padding: 0 4px; color: var(--muted); }
.pp .pp-pick { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.pp .pp-pick:last-child { border-bottom: 0; }
.pp .pp-pick input { width: 20px; height: 20px; flex: none; accent-color: var(--brand); }
.pp .pp-pick.busy { opacity: .55; cursor: default; }
.pp .pp-pick-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.pp .pp-pick > strong { flex: none; white-space: nowrap; }

/* ประกาศ */
.pp .pp-news-h { font-size: 1.15rem; margin: 0 0 10px; }
.pp .pp-news { list-style: none; margin: 0; padding: 0; }
.pp .pp-news-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.pp .pp-news li:last-child .pp-news-item { border-bottom: 0; }
.pp .pp-news-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.pp .pp-news-main strong { font-weight: 500; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pp .pp-news-item.unread .pp-news-main strong { font-weight: 800; }
.pp .pp-news-snip { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp .pp-unread-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.pp .pp-news-read h1 { font-size: 1.25rem; margin: 6px 0 2px; overflow-wrap: anywhere; }
.pp .pp-news-body { margin-top: 10px; line-height: 1.6; overflow-wrap: anywhere; }
.pp .pp-years { margin-top: 12px; }
