/* ============================================================
   Harmony Music School — design system
   ============================================================ */
:root {
  --bg: #f4f5f7; --surface: #ffffff; --surface-2: #eef0f3; --surface-hover: #f5f6f8;
  --text: #191b1f; --muted: #5f636b; --faint: #666b73;   /* muted/faint ผ่าน WCAG AA (≥4.5:1) ทุกพื้น รวม --bg/surface-2 */
  --border: #e5e7ec; --border-strong: #d7dae0;
  --brand: #6d5efc; --brand-strong: #5b4bf0; --brand-weak: rgba(109,94,252,.10); --brand-fg: #fff;
  --brand-2: #24b0c4;   /* ปลายไล่เฉดแบรนด์ (teal) — avatar + hero ล็อกอิน */
  --green: #0f9d5c; --green-weak: rgba(15,157,92,.12);
  --red: #dc4a4a; --red-weak: rgba(220,74,74,.12);
  --amber: #bd7d15; --amber-weak: rgba(189,125,21,.14);
  --r-sm: 8px; --r-ctl: 10px; --r: 12px; --r-lg: 16px; --pill: 20px;
  --sh-sm: 0 1px 2px rgba(16,24,40,.05);
  --sh: 0 1px 3px rgba(16,24,40,.07), 0 6px 16px -8px rgba(16,24,40,.10);
  --sh-lg: 0 12px 40px -12px rgba(16,24,40,.22);
  /* สถานะ (มาเรียน/ลา/ขาด/ชดเชย/วางแผน) — โทนตัว · พื้นนุ่ม · ขอบ · มีคู่ dark ด้านล่าง */
  --ok-fg: #14532d; --ok-bg: #dcfce7; --ok-bd: #16a34a;
  --leave-fg: #3730a3; --leave-bg: #ecebfe; --leave-bd: var(--brand);
  --miss-fg: #7f1d1d; --miss-bg: #fee2e2; --miss-bd: #dc2626;
  --mk-fg: #78350f; --mk-bg: #fef3c7; --mk-bd: #d97706;
  --plan-bd: #cbd5e1; --info: #2563eb; --alert-solid: #dc2626;
  /* z-index scale: content < sticky chrome < transient popover < modal < toast < tooltip
     (row-menu/autocomplete are transient overlays → must float ABOVE the mobile sticky top bar) */
  --z-sticky: 60; --z-menu: 70; --z-modal: 100; --z-toast: 120; --z-tooltip: 140;
  /* easing — ชะลอแบบ ease-out (ไม่มี bounce/elastic) */
  --ease-out-quart: cubic-bezier(.25, 1, .5, 1);
  --ease-out-quint: cubic-bezier(.22, 1, .36, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131417; --surface: #1c1e22; --surface-2: #25282d; --surface-hover: #23262b;
    --text: #e9eaed; --muted: #9aa0a8; --faint: #8d949c;   /* faint ≥4.5:1 ทุกพื้นมืด รวม surface-2 (#25282d) */
    --border: #2b2e34; --border-strong: #383c43;
    --brand: #8b7dff; --brand-strong: #7a6bff; --brand-weak: rgba(139,125,255,.16);
    --green: #2bbd7e; --green-weak: rgba(43,189,126,.15);
    --red: #f06a6a; --red-weak: rgba(240,106,106,.15);
    --amber: #d69a35; --amber-weak: rgba(214,154,53,.16);
    --sh-sm: 0 1px 2px rgba(0,0,0,.3);
    --sh: 0 1px 3px rgba(0,0,0,.35), 0 8px 24px -12px rgba(0,0,0,.5);
    --sh-lg: 0 16px 48px -12px rgba(0,0,0,.6);
    /* สถานะโหมดมืด — พื้นโปร่งเข้ม + ตัวอักษรสว่างพอ (WCAG AA บนพื้นดำ) */
    --ok-fg: #7ee0aa; --ok-bg: rgba(43,189,126,.16); --ok-bd: #2bbd7e;
    --leave-fg: #c7c2ff; --leave-bg: rgba(139,125,255,.18); --leave-bd: var(--brand);
    --miss-fg: #f4a6a6; --miss-bg: rgba(240,106,106,.16); --miss-bd: #f06a6a;
    --mk-fg: #e6c07a; --mk-bg: rgba(214,154,53,.18); --mk-bd: #d69a35;
    --plan-bd: #3a4048; --info: #7aa2ff;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Sarabun", "Noto Sans Thai", -apple-system, "Segoe UI", system-ui, sans-serif;
  font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--brand); }
.muted { color: var(--muted); }
.center { min-height: 60vh; display: grid; place-items: center; }
.hidden { display: none !important; }
.page-actions { display: flex; justify-content: flex-end; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
/* ตัวกรองตารางเรียน: เดสก์ท็อป select อยู่ในแถวตามเดิม · ปุ่ม "ตัวกรอง" ซ่อน */
.sched-filters { display: contents; }
.sched-filters select { width: auto; min-width: 130px; max-width: 190px; }
.page-actions > .sched-ftoggle { display: none; }   /* ชนะ specificity ของ button.ghost */
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.num { font-variant-numeric: tabular-nums; }
.ic { width: 18px; height: 18px; flex: none; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex: none; background: var(--surface); border-right: 1px solid var(--border);
  padding: 16px 14px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 4px; }
.brand .brand-logo { width: 38px; height: 38px; border-radius: var(--r); background: #fff; padding: 4px; box-shadow: var(--sh-sm); flex: none; }
.brand .brand-logo img { width: 100%; height: 100%; object-fit: contain; }
.brand .brand-name { font-weight: 700; font-size: 15.5px; letter-spacing: -.01em; line-height: 1.15; }
.brand .brand-name small { display: block; font-weight: 500; font-size: 11px; color: var(--faint); letter-spacing: .02em; }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: 14px 10px 6px; }
.nav-group { padding-top: 12px; }   /* ป้ายหัวกลุ่มเมนู (แอดมิน) — เว้นเหนือกลุ่มถัดไป */
/* เมนูตรงกลางเลื่อนเองได้เมื่อยาวเกินจอ (brand ค้างบน / โปรไฟล์ค้างล่าง) — min-height:0 ให้ flex ย่อได้ */
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; padding-left: 14px; margin-left: -14px; }
.nav::-webkit-scrollbar { width: 7px; }
.nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
/* วิธีใช้งาน (Help) + ปุ่ม ? ประจำหน้า */
.help-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: var(--r-ctl); background: var(--brand-weak); color: var(--brand); font-size: 13.5px; font-weight: 600; text-decoration: none; flex: none; white-space: nowrap; }
.help-btn:hover { background: var(--brand); color: #fff; }
.help-btn .ic { width: 18px; height: 18px; }
/* หน้าวิธีใช้งาน — เลย์เอาต์แบบเอกสาร (สารบัญซ้าย + เนื้อหาขวา) โทนเรียบ */
.help-note { display: flex; align-items: flex-start; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 12px 15px; font-size: 13px; color: var(--muted); line-height: 1.55; margin-bottom: 20px; }
.help-note .ic { width: 17px; height: 17px; color: var(--brand); flex: none; margin-top: 1px; }
.help-note b { color: var(--text); font-weight: 600; }

.help-layout { display: grid; grid-template-columns: 216px minmax(0, 1fr); gap: 30px; align-items: start; }

/* สารบัญ (sticky) */
.help-toc { position: sticky; top: 12px; display: flex; flex-direction: column; gap: 1px; }
/* !important เพื่อชนะ base rule button:not(.ghost)... (แพตเทิร์นเดียวกับ .seg button) */
.help-toc-i { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 8px 11px; border: none; border-left: 2px solid transparent; background: none !important; border-radius: var(--r-ctl); color: var(--muted) !important; font-size: 13px; font-weight: 500 !important; font-family: inherit; cursor: pointer; box-shadow: none !important; transition: background .12s, color .12s; }
.help-toc-i:hover { background: var(--surface-hover) !important; color: var(--text) !important; }
.help-toc-i.on { background: var(--brand-weak) !important; color: var(--brand) !important; font-weight: 600 !important; }
.help-toc-i .ic { width: 16px; height: 16px; flex: none; opacity: .85; }

/* เนื้อหา */
.help-doc { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.help-topic { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 20px 24px 22px; animation: help-fade .18s var(--ease-out-quart); }
@keyframes help-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.help-topic-h { display: flex; align-items: center; gap: 10px; padding-bottom: 12px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.help-topic-h h2 { font-size: 15px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.help-topic-ic { width: 28px; height: 28px; border-radius: var(--r-sm); background: var(--surface-2); color: var(--muted); display: grid; place-items: center; flex: none; }
.help-topic-ic .ic { width: 16px; height: 16px; }
.help-steps { margin: 0; padding: 0; list-style: none; counter-reset: hstep; display: flex; flex-direction: column; gap: 11px; }
.help-steps li { position: relative; padding-left: 30px; font-size: 13.5px; line-height: 1.62; color: var(--text); counter-increment: hstep; }
.help-steps li::before { content: counter(hstep); position: absolute; left: 0; top: 1px; width: 20px; height: 20px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); color: var(--faint); font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.help-steps b { font-weight: 600; color: var(--text); }
.help-flash { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-weak); }

@media (max-width: 760px) {
  .help-layout { grid-template-columns: 1fr; gap: 14px; }
  .help-toc { position: static; flex-direction: row; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
  .help-toc-i { width: auto; border: 1px solid var(--border); padding: 6px 11px; }
  .help-toc-i.on { border-color: var(--brand); }
}
@media (max-width: 560px) { .help-btn span { display: none; } .help-btn { padding: 8px; } }
/* ทัวร์สอนใช้งาน (spotlight overlay) */
.tour { position: fixed; inset: 0; z-index: 4000; }
.tour-dim { position: fixed; inset: 0; background: rgba(20,10,40,.6); }
.tour-hole { position: fixed; border-radius: 10px; box-shadow: 0 0 0 9999px rgba(20,10,40,.6); outline: 3px solid var(--brand); pointer-events: none; }
.tour-card { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); width: min(560px, calc(100% - 28px)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: 0 14px 44px rgba(0,0,0,.28); padding: 18px 20px; }
.tour-step-n { font-size: 12px; color: var(--brand); font-weight: 700; letter-spacing: .02em; }
.tour-card h3 { margin: 5px 0 8px; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.tour-card h3 .ic { color: var(--brand); width: 20px; height: 20px; }
.tour-card p { font-size: 14.5px; color: var(--text); line-height: 1.6; margin: 0 0 14px; max-height: 34vh; overflow: auto; }
.tour-card p b { color: var(--brand); font-weight: 700; }
.tour-foot { display: flex; align-items: center; gap: 8px; }
.tour-foot .spacer { flex: 1; }
.tour-skip { background: transparent; border: 0; color: var(--muted); cursor: pointer; font-size: 13px; padding: 6px; }
.tour-skip:hover { color: var(--text); text-decoration: underline; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: var(--r-ctl);
  color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500;
  position: relative; transition: background .12s, color .12s;
}
.nav a .ic { color: var(--faint); transition: color .12s; }
.nav a:hover { background: var(--surface-hover); color: var(--text); }
.nav a:hover .ic { color: var(--muted); }
.nav a.active { background: var(--brand-weak); color: var(--brand); font-weight: 600; }
.nav a.active .ic { color: var(--brand); }
.nav a.active::before { content: ""; position: absolute; left: -14px; top: 50%; transform: translateY(-50%); width: 3px; height: 20px; background: var(--brand); border-radius: 0 3px 3px 0; }
.side-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-2)); }
.avatar .ic { width: 18px; height: 18px; }
.side-foot .who { flex: 1; min-width: 0; }
.side-foot .who b { font-size: 13px; font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-foot .who span { font-size: 11.5px; color: var(--faint); }
.icon-btn { width: 34px; height: 34px; padding: 0; display: grid; place-items: center; background: transparent; border: 1px solid var(--border); border-radius: var(--r-ctl); color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.nav-toggle { display: none; }   /* ปุ่มแฮมเบอร์เกอร์ — โผล่เฉพาะจอ ≤900px */

.main { flex: 1; min-width: 0; padding: 26px 30px 60px; max-width: 1140px; width: 100%; margin: 0 auto; }
.topbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; }
.topbar-id { display: flex; align-items: center; gap: 13px; }
.topbar-ic { width: 44px; height: 44px; border-radius: var(--r); background: var(--brand-weak); color: var(--brand); display: grid; place-items: center; flex: none; }
.topbar-ic .ic { width: 23px; height: 23px; }
/* แถบสรุปตัวเลข: hero เด่น + ตัวรอง (ใช้แทนการ์ด 3 ใบเท่ากัน) */
.figures { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 30px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-sm); padding: 18px 22px; margin-bottom: 22px; }
.fig-hero { display: flex; flex-direction: column; }
.fig-hero .fig-num { font-size: 34px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.fig-sub { font-size: 12.5px; color: var(--faint); margin-top: 4px; }
.fig-rest { display: flex; flex-wrap: wrap; gap: 14px 28px; align-items: center; margin-left: auto; padding-left: 30px; border-left: 1px solid var(--border); }
.fig { display: flex; flex-direction: column; gap: 2px; }
.fig .fig-val { font-size: 20px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.fig-label { font-size: 12.5px; color: var(--muted); }
.figures .green { color: var(--green); } .figures .amber { color: var(--amber); } .figures .red { color: var(--red); }

/* ช่องเลือกวันที่/เวลา (DateField/TimeField) — คลิกเลือกผ่าน popover */
.dtf-input { cursor: pointer; padding-right: 34px !important; background-repeat: no-repeat; background-position: right 10px center; background-size: 16px 16px; }
.dtf-date { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round'%3E%3Crect x='3' y='4' width='18' height='17' rx='2'/%3E%3Cpath d='M3 9h18M8 2v4M16 2v4'/%3E%3C/svg%3E"); }
.dtf-time { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2'/%3E%3C/svg%3E"); }
.dtf-pop { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--sh-lg); padding: 10px; }
.dtf-cal { width: 252px; }
.dtf-cal-head { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.dtf-cal-head select { flex: 1; min-width: 0; padding: 5px 6px; font-size: 13px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--text); }
/* NB: กฎ button:not(...) รวมของแอปบังคับ background:var(--brand) ทุกปุ่ม → ต้อง !important */
.dtf-nav { width: 28px; height: 28px; min-height: 28px !important; flex: none; padding: 0 !important; border: 1px solid var(--border); border-radius: 7px; background: var(--surface) !important; cursor: pointer; color: var(--text) !important; font-size: 17px; line-height: 1; display: grid; place-items: center; box-shadow: none !important; }
.dtf-nav:hover { background: var(--surface-hover) !important; border-color: var(--brand); }
.dtf-cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.dtf-dow { text-align: center; font-size: 11px; color: var(--muted); padding: 3px 0; min-width: 0; }
.dtf-day { height: 30px; min-height: 30px !important; min-width: 0; border: 0; background: none !important; border-radius: 7px; cursor: pointer; color: var(--text) !important; font-size: 13px; font-family: inherit; box-shadow: none; padding: 0 !important; }
.dtf-day:hover { background: var(--brand-weak) !important; }
.dtf-day.today { box-shadow: inset 0 0 0 1.5px var(--brand); }
.dtf-day.sel { background: var(--brand) !important; color: #fff !important; font-weight: 600; }
.dtf-time-pop { display: flex; gap: 8px; }
.dtf-col { position: relative; width: 70px; max-height: 216px; overflow-y: auto; border: 1px solid var(--border); border-radius: 9px; padding: 4px; }
.dtf-col-h { position: sticky; top: 0; z-index: 1; background: var(--surface); text-align: center; font-size: 11px; color: var(--muted); padding: 2px 0 5px; }
.dtf-t { display: block; width: 100%; min-height: 0 !important; text-align: center; border: 0; background: none !important; border-radius: 6px; padding: 6px 0 !important; cursor: pointer; color: var(--text) !important; font-size: 13px; font-family: inherit; box-shadow: none !important; }
.dtf-t:hover { background: var(--brand-weak) !important; }
.dtf-t.sel { background: var(--brand) !important; color: #fff !important; font-weight: 600; }

/* กราฟแดชบอร์ด: จัดคู่ 2 คอลัมน์ (รายได้|จ่ายเงิน, นักเรียน|วิชา) — จอเล็กเรียงเดี่ยว */
.dash-charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 22px; }
.dash-charts-grid > .card { min-width: 0; }
@media (max-width: 760px) { .dash-charts-grid { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .fig-rest { margin-left: 0; padding-left: 0; border-left: 0; width: 100%; } .fig-hero .fig-num { font-size: 29px; } }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.topbar .sub { color: var(--muted); font-size: 14px; margin-top: 3px; }
h2 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; margin: 26px 0 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: var(--pill); background: var(--surface); border: 1px solid var(--border); font-size: 12.5px; font-weight: 600; color: var(--muted); }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px; box-shadow: var(--sh-sm); }
.link { color: var(--brand); font-weight: 600; text-decoration: none; cursor: pointer; }
.link:hover { text-decoration: underline; }
.link.back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 14px; font-size: 13.5px; }
.link.back .ic { width: 16px; height: 16px; }
.profile-head { display: block; }
.ph-top { display: flex; align-items: center; gap: 16px; }
.ph-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.profile-info { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 20px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.pi { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.pi-k { font-size: 12px; color: var(--muted); }
.pi-v { font-size: 14.5px; color: var(--text); font-weight: 500; word-break: break-word; }
.seg.seg-sm button { padding: 5px 12px; font-size: 13px; }
.seg.seg-sm .ic { width: 15px; height: 15px; }
.avatar.lg { width: 54px; height: 54px; }
.avatar.lg .ic { width: 28px; height: 28px; }
img.avatar { object-fit: cover; background: none; padding: 0; }

/* ---------- รูปนักเรียน ---------- */
.photo-pick { display: flex; align-items: center; gap: 14px; }
.photo-prev { width: 64px; height: 64px; border-radius: 50%; flex: none; overflow: hidden; display: grid; place-items: center; background: var(--surface-2); color: var(--faint); border: 1px solid var(--border); }
.photo-prev img { width: 100%; height: 100%; object-fit: cover; }
.photo-prev .ic { width: 28px; height: 28px; }
.name-cell { display: inline-flex; align-items: center; gap: 9px; }
.row-avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; flex: none; }
.row-avatar.ph { display: grid; place-items: center; background: var(--surface-2); color: var(--faint); border: 1px solid var(--border); }
.row-avatar.ph .ic { width: 16px; height: 16px; }

/* ---------- PDPA consent + policy ---------- */
.consent-row { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; padding: 12px; border: 1px solid var(--border); border-radius: var(--r-ctl); background: var(--surface-2); font-size: 13.5px; line-height: 1.5; cursor: pointer; }
.consent-row input[type=checkbox] { margin-top: 2px; flex: none; width: 18px; height: 18px; }
.consent-row.consent-err { border-color: var(--red); background: rgba(220, 74, 74, .08); }
.consent-row .btn-link { font-size: inherit; }
.policy h4 { margin: 16px 0 6px; font-size: 15px; }
.policy p, .policy li { font-size: 14px; line-height: 1.65; color: var(--text); }
.policy ul { margin: 4px 0; padding-left: 20px; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--sh-sm); }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
thead th { background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; text-align: left; padding: 11px 15px; white-space: nowrap; border-bottom: 1px solid var(--border); }
tbody td { padding: 12px 15px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .1s; }
tbody tr:hover td { background: var(--surface-hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
/* หัวคอลัมน์ที่เรียงได้ — คลิกเพื่อ sort · ลูกศรบอกทิศ */
th.th-sort { cursor: pointer; user-select: none; }
th.th-sort:hover { color: var(--text); }
.sort-ind { display: inline-block; margin-left: 5px; font-size: 9px; opacity: .3; vertical-align: middle; }
.sort-ind.on { opacity: 1; color: var(--brand-strong); }
/* หัวคอลัมน์ปุ่ม (.actions) ต้องคงเป็นเซลล์ตาราง — ไม่งั้น display:flex ทำให้หลุด layout เป็นกล่องลอย */
thead th.actions { display: table-cell; }
/* คอลัมน์ปุ่มในตาราง (เดสก์ท็อป) — เป็น table-cell จริง (ไม่ใช่ flex) เพื่อให้สี hover เต็มช่อง +
   หดพอดีปุ่ม (width:1%) + ปุ่มเรียงแนวนอนบรรทัดเดียว (nowrap) · มือถือ (โหมดการ์ด ≤560) ปล่อย flex ตามเดิม */
@media (min-width: 561px) {
  td.actions { display: table-cell; width: 1%; white-space: nowrap; text-align: right; }
  td.actions > * { vertical-align: middle; }
  td.actions > * + * { margin-left: 7px; }
}
/* คอลัมน์ลูกศร "คลิกดูรายละเอียด" — แคบ ชิดขวา แนบขอบแถว (ไม่ใช้ flex เลยไม่เป็นกล่องลอย) */
td.chev, th.chev { width: 1%; white-space: nowrap; text-align: right; }
/* คอลัมน์ checkbox เลือกบิล — กว้างคงที่ให้ checkbox อยู่ในเซลล์ (ไม่ใช้ 1% ที่หดจนหลุด)
   สำคัญ: ต้อง display:table-cell ทับ .chk เดิม (label ฟอร์ม) ที่เป็น display:flex — ไม่งั้น td.chk เลิกเป็นเซลล์ตาราง
   จะไม่ยืดเต็มความสูงแถว → พื้นหลัง/ขอบแถวบิลรวมเต็มแค่ครึ่งบน เหลือขาวครึ่งล่าง + หัวคอลัมน์หลุดออกนอกการ์ด */
td.chk, th.chk { display: table-cell; margin: 0; vertical-align: middle; width: 44px; min-width: 44px; text-align: center; padding-left: 12px; padding-right: 4px; }
th.chk { background: var(--surface-2); }   /* กันหัวคอลัมน์ติ๊กไม่ได้พื้นเทา ดูเหมือนหลุดออกนอกการ์ด */
td.chk input { width: 17px; height: 17px; margin: 0; cursor: pointer; accent-color: var(--brand); vertical-align: middle; }
/* ซ่อนคอลัมน์ checkbox จนถึง 768px — ช่วงนี้ตาราง (min-width:560) เลื่อนแนวนอน คอลัมน์ติ๊ก 44px จะดูลอยหลุดขอบการ์ด
   ต้องซ่อนทั้ง th+td พร้อมกันในโหมดตาราง (561–768) ไม่งั้นหัว-ค่าเหลื่อมคอลัมน์ · รวมบิลใช้บนจอกว้าง (≥769) ที่ตารางพอดีจอ */
@media (max-width: 768px) { .table-wrap th.chk, .table-wrap td.chk { display: none; } }
/* แถบรวมบิล */
.merge-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; padding: 10px 14px; background: var(--brand-weak); border: 1px solid var(--brand); border-radius: var(--radius, 12px); }
.merge-count { font-weight: 700; color: var(--brand-strong); }
/* ตัวนับ "นักเรียนทั้งหมด N คน" (ทะเบียนนักเรียน) */
.roster-count { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; background: var(--brand-weak); color: var(--brand-strong); border-radius: var(--pill); font-size: 14px; font-weight: 600; white-space: nowrap; }
.roster-count .ic { width: 16px; height: 16px; }
.roster-count b { font-size: 16px; }
/* ชื่อผู้ปกครองในตารางนักเรียน — กดเพื่อดูรายละเอียด */
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); font-weight: 600; cursor: pointer; text-align: left; }
.link-btn:hover { text-decoration: underline; }
/* โมดัลรายละเอียดผู้ปกครอง */
.gd-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); padding: 14px 16px; margin-bottom: 18px; }
.gd-name { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 17px; font-weight: 700; margin-bottom: 10px; }
.gd-rows { display: flex; flex-direction: column; gap: 7px; font-size: 14px; }
.gd-rows > div { display: flex; align-items: center; gap: 8px; }
.gd-rows .ic { width: 16px; height: 16px; flex: 0 0 auto; color: var(--muted); }
.gd-kids-h { display: flex; align-items: center; gap: 7px; font-weight: 700; font-size: 14px; margin-bottom: 10px; }
.gd-kids-h .ic { width: 16px; height: 16px; }
.gd-kids-h .cnt { color: var(--brand-strong); }
.gd-kid { display: flex; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: var(--r-ctl); padding: 10px 12px; text-decoration: none; color: inherit; transition: background .12s, border-color .12s; }
.gd-kid:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.gd-kid-info { flex: 1; min-width: 0; }
.gd-kid-name { font-weight: 600; }
.gd-kid > .ic { width: 18px; height: 18px; flex: 0 0 auto; color: var(--muted); }
.merge-warn { color: var(--amber); font-size: 13px; font-weight: 600; }

/* ---------- forms ---------- */
.form-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px 20px; box-shadow: var(--sh-sm); margin-bottom: 22px; }
.form-card .form-title { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 14.5px; margin-bottom: 14px; }
.form-card .form-title .ic { color: var(--brand); }
label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin: 0 0 5px; }
input, select, textarea {
  font: inherit; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--r-ctl);
  background: var(--surface); color: var(--text); width: 100%; transition: border-color .12s, box-shadow .12s;
}
input::placeholder { color: var(--faint); }
/* checkbox/radio ต้องล้าง padding+border ที่ input ทั่วไปตั้งไว้ ไม่งั้น box-sizing:border-box บีบตัว control จนหายไป (มองไม่เห็นติ๊ก) */
input[type=checkbox], input[type=radio] { width: auto; height: auto; flex: none; padding: 0; border: 0; background: none; accent-color: var(--brand); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-weak); }
select { cursor: pointer; }
/* keyboard focus ring — สม่ำเสมอทุกอิลิเมนต์ที่โฟกัสได้ (เมาส์ไม่เห็น คีย์บอร์ดเห็น) */
a:focus-visible, button:focus-visible, [tabindex]:focus-visible, summary:focus-visible,
.subj-card:focus-visible, .cal-ev:focus-visible, .ac-item:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}
a:focus:not(:focus-visible), button:focus:not(:focus-visible) { outline: none; }
/* skip-link — โผล่เมื่อ Tab ครั้งแรก ข้ามเมนูข้างไปเนื้อหา */
.skip-link {
  position: fixed; top: 8px; left: 8px; z-index: var(--z-tooltip);
  background: var(--brand); color: var(--brand-fg); font-weight: 600; font-size: 14px;
  padding: 10px 16px; border-radius: var(--r-ctl); text-decoration: none;
  transform: translateY(-150%); transition: transform .15s ease;
}
.skip-link:focus { transform: translateY(0); outline: 2px solid var(--brand-fg); outline-offset: 2px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1; min-width: 150px; }
.row > .grow0 { flex: 0; }

/* ---------- buttons ---------- */
button { font: inherit; cursor: pointer; border: none; border-radius: var(--r-ctl); font-weight: 600; }
button:not(.icon-btn):not(.toggle):not(.ghost):not(.danger):not(.link-btn) {
  background: var(--brand); color: var(--brand-fg); padding: 9px 16px; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; transition: filter .12s, transform .05s, background .12s;
}
button:not(.icon-btn):not(.toggle):not(.ghost):not(.danger):not(.link-btn):hover { background: var(--brand-strong); }
button:not(.icon-btn):not(.toggle):not(.ghost):not(.danger):not(.link-btn):active { transform: translateY(1px); }
button.ghost, button.danger { padding: 9px 16px; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; transition: background .12s, filter .12s, transform .05s; }
/* กดแล้วยุบเล็กน้อย — feedback สัมผัสทุกปุ่ม (คีย์บอร์ด/ทัช/เมาส์) */
button.ghost:active, button.danger:active { transform: translateY(1px); }
.icon-btn { transition: background .12s, color .12s, transform .05s; }
.icon-btn:active { transform: scale(.92); }
button:disabled { opacity: .55; cursor: default; }
button:disabled:active { transform: none; }
button.ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); }
button.ghost:hover { background: var(--surface-hover); }
button.danger { background: var(--red); }
button.danger:hover { background: var(--red); filter: brightness(1.06); }
button.ghost.danger { background: var(--surface); color: var(--red); border-color: var(--red-weak); }
button.ghost.danger:hover { background: var(--red-weak); }
button.sm { padding: 6px 11px !important; font-size: 12.5px !important; border-radius: var(--r-sm); }
.actions { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
/* เมนู ⋯ ต่อแถว (portal ไป body, position:fixed หนี overflow ของ .table-wrap) */
.row-menu { position: fixed; z-index: var(--z-menu); min-width: 168px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-ctl); box-shadow: var(--sh-lg); padding: 5px; display: flex; flex-direction: column; gap: 2px; animation: menu-in .12s var(--ease-out-quart); }
/* !important เพื่อชนะ base rule button:not(.ghost)... ตามแบบเดียวกับ .seg/.btn-link ในโปรเจกต์ */
.row-menu-item { display: flex; align-items: center; gap: 9px; width: 100%; justify-content: flex-start; text-align: left; padding: 9px 11px; border: 0; background: transparent !important; border-radius: var(--r-sm); color: var(--text) !important; font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.row-menu-item:hover, .row-menu-item:focus-visible { background: var(--surface-hover) !important; }
.row-menu-item .ic { width: 16px; height: 16px; color: var(--muted); flex: none; }
.row-menu-item.danger { color: var(--red) !important; }
.row-menu-item.danger .ic { color: var(--red); }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
/* กล่องยืนยัน (confirmDialog) */
.confirm-msg { font-size: 14.5px; line-height: 1.55; color: var(--text); margin: 2px 0 12px; }
.confirm-detail { display: flex; gap: 9px; align-items: flex-start; background: var(--mk-bg); border: 1px solid var(--mk-bd); color: var(--mk-fg); border-radius: var(--r-ctl); padding: 10px 12px; font-size: 13px; line-height: 1.5; margin: 0 0 4px; }
.confirm-detail.danger { background: var(--miss-bg); border-color: var(--miss-bd); color: var(--miss-fg); }
.confirm-detail .ic { width: 17px; height: 17px; flex: none; margin-top: 1px; }
/* validation ตรงช่อง (fieldError) */
input.invalid, select.invalid, textarea.invalid { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-weak); }
.field-err { color: var(--red); font-size: 12.5px; font-weight: 500; margin-top: 5px; }
/* แจ้งผลค้างในโมดัล (ไม่หายเองเหมือน toast) — ผลลัพธ์เรื่องเงิน/ตาราง */
.m-alert { position: relative; border-radius: var(--r-ctl); padding: 11px 36px 11px 13px; margin-bottom: 15px; font-size: 13.5px; line-height: 1.5; border: 1px solid; animation: menu-in .15s var(--ease-out-quart); }
.m-alert.err { background: var(--miss-bg); border-color: var(--miss-bd); color: var(--miss-fg); }
.m-alert.warn { background: var(--mk-bg); border-color: var(--mk-bd); color: var(--mk-fg); }
.m-alert.ok { background: var(--ok-bg); border-color: var(--ok-bd); color: var(--ok-fg); }
.m-alert-title { font-weight: 700; }
.m-alert-list { margin: 6px 0 0; padding-left: 18px; }
.m-alert-list li { margin: 2px 0; }
.m-alert-x { position: absolute; top: 8px; right: 8px; background: transparent !important; border: none !important; box-shadow: none !important; color: inherit !important; cursor: pointer; padding: 3px; border-radius: var(--r-sm); opacity: .7; line-height: 0; }
.m-alert-x:hover { opacity: 1; background: rgba(0,0,0,.08) !important; }
.m-alert-x .ic { width: 15px; height: 15px; }
/* wizard ฟอร์มหลายขั้น (ลงเรียน) */
.wz-steps { display: flex; gap: 4px; margin-bottom: 18px; }
.wz-dot { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: var(--faint); text-align: center; }
.wz-dot span { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); font-weight: 700; font-size: 13px; border: 1.5px solid var(--border); transition: background .15s, color .15s, border-color .15s; }
.wz-dot.on { color: var(--brand); font-weight: 700; }
.wz-dot.on span { background: var(--brand); color: #fff; border-color: var(--brand); }
.wz-dot.done span { background: var(--brand-weak); color: var(--brand); border-color: var(--brand); }
.wz-more { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 8px; }
.wz-more summary { list-style: none; cursor: pointer; color: var(--brand); font-weight: 600; font-size: 13.5px; display: inline-flex; align-items: center; gap: 6px; padding: 8px 0; border-radius: var(--r-sm); }
.wz-more summary::-webkit-details-marker { display: none; }
.wz-more summary .ic { width: 15px; height: 15px; transition: transform .15s var(--ease-out-quart); }
.wz-more[open] summary { margin-bottom: 8px; }
.wz-more[open] summary .ic { transform: rotate(45deg); }

/* ---------- badges / misc ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: var(--pill); font-size: 12.5px; font-weight: 600; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.active, .badge.present { background: var(--green-weak); color: var(--green); }
.badge.paused, .badge.makeup { background: var(--amber-weak); color: var(--amber); }
.badge.ended, .badge.absent, .badge.cancelled { background: var(--red-weak); color: var(--red); }
.badge.leave { background: var(--brand-weak); color: var(--brand-strong); }
/* บทบาทในหน้าบัญชีผู้ใช้ */
.badge.role-admin { background: var(--brand-weak); color: var(--brand-strong); }
.badge.role-manager { background: var(--amber-weak); color: var(--amber); }
.badge.role-teacher { background: var(--green-weak); color: var(--green); }
.badge.role-parent { background: var(--bg); color: var(--muted); }
/* รายละเอียดเจ้าของบัญชี (ชื่อครู / ลูกที่ผูก) */
.u-detail-name { font-weight: 600; color: var(--text); }
.u-detail-sub { font-size: 12.5px; color: var(--muted); }
.u-detail-sub b { color: var(--text); font-weight: 600; }
.roster-head { margin: 2px 0 10px; font-size: 13px; }
.muted.sm { font-size: 12.5px; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: var(--pill); vertical-align: middle; }
.tag.sub { background: var(--brand-weak); color: var(--brand-strong); }
.tag.move { background: var(--amber-weak); color: var(--amber); }
tr.row-off td { opacity: .6; }
.sub-h { font-size: 13px; margin: 16px 0 8px; color: var(--muted); }
.lrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--border); }
.lrow-info { flex: 1 1 200px; }
.lrow-ctl { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.lrow-ctl select, .lrow-ctl input { width: auto; padding: 5px 8px; }
.la-move { display: inline-flex; gap: 6px; }
/* autocomplete (พิมพ์เพื่อค้นหา) */
.ac { position: relative; }
.ac-menu { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: var(--z-menu);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-ctl);
  box-shadow: var(--sh-lg); max-height: 260px; overflow-y: auto; padding: 4px; }
.ac-item { padding: 9px 11px; border-radius: 7px; cursor: pointer; font-size: 14px; }
.ac-item:hover, .ac-item.active { background: var(--brand-weak); color: var(--brand); }
.ac-empty { padding: 12px; text-align: center; color: var(--faint); font-size: 13px; }
.ac-item.ac-create { display: flex; align-items: center; gap: 7px; color: var(--brand); font-weight: 600; border-top: 1px solid var(--border); border-radius: 0 0 7px 7px; }
.ac-item.ac-create .ic { width: 15px; height: 15px; }

/* modal */
.modal-ov { position: fixed; inset: 0; background: rgba(17, 20, 32, .5); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: var(--z-modal); overflow-y: auto; animation: ov-in .15s ease; }
@keyframes ov-in { from { opacity: 0 } to { opacity: 1 } }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-lg); width: 100%; max-width: 480px; animation: modal-in .2s var(--ease-out-quint);
  display: flex; flex-direction: column; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); }
.modal-head { flex: 0 0 auto; }
.modal-body { flex: 1 1 auto; overflow-y: auto; }
/* ปิด modal แบบนุ่ม (JS ใส่ .closing ก่อนถอดออก ~120ms) */
@keyframes ov-out { to { opacity: 0 } }
@keyframes modal-out { to { opacity: 0; transform: translateY(6px) scale(.98) } }
.modal-ov.closing { animation: ov-out .12s ease forwards; }
.modal-ov.closing .modal { animation: modal-out .12s var(--ease-out-quart) forwards; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98) } to { opacity: 1; transform: none } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px; }
.modal-body .field { margin-bottom: 14px; }
.modal-body .field:last-child { margin-bottom: 0; }
.modal-body label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.modal-body .row2 { display: flex; gap: 12px; flex-wrap: wrap; }
.modal-body .row2 > * { flex: 1; }
/* .field-err ที่ fieldError() แทรกใน row2 = ขึ้นบรรทัดใหม่เต็มความกว้าง (ไม่บีบเป็นคอลัมน์ที่ 3) */
.modal-body .row2 > .field-err { flex-basis: 100%; margin-top: 0; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; align-items: center; }
/* ตัวดูสลิป/ใบเสร็จ — ปรับรูปพอดีจอ */
.modal.modal-wide { max-width: 760px; }
.receipt-view { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r); padding: 10px; text-align: center; }
.receipt-view img { max-width: 100%; max-height: 74vh; border-radius: var(--r-sm); }
.btn-link { display: inline-flex; align-items: center; gap: 6px; margin-right: auto; font-size: 13px; font-weight: 600; color: var(--brand) !important; text-decoration: none;
  background: none !important; border: none !important; box-shadow: none !important; padding: 0 !important; cursor: pointer; font-family: inherit; }
.btn-link:hover { text-decoration: underline; }
.btn-link .ic { width: 16px; height: 16px; }
/* ศูนย์แจ้งเตือน */
.notif-list { display: flex; flex-direction: column; gap: 10px; }
.notif { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 14px 16px; }
.notif.unread { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand) inset; }
.notif-ic { flex: 0 0 auto; width: 38px; height: 38px; border-radius: var(--r-ctl); display: flex; align-items: center; justify-content: center; }
.notif-ic .ic { width: 19px; height: 19px; }
.notif-ic.green { background: var(--ok-bg); color: var(--ok-bd); }
.notif-ic.amber { background: var(--mk-bg); color: var(--mk-bd); }
.notif-ic.red { background: var(--miss-bg); color: var(--miss-bd); }
.notif-ic.brand { background: var(--leave-bg); color: var(--brand); }
.notif-main { flex: 1; min-width: 0; }
.notif-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.notif-tag { font-size: 11px; color: var(--muted); background: var(--bg); border: 1px solid var(--border); border-radius: var(--pill); padding: 1px 8px; }
.notif-body { font-size: 13.5px; color: var(--text); margin-top: 3px; }
.notif-time { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.notif-act { flex: 0 0 auto; display: flex; flex-direction: column; gap: 6px; }
.nav-badge { margin-left: auto; background: var(--alert-solid); color: #fff; font-size: 11px; font-weight: 700; min-width: 18px; height: 18px; border-radius: var(--r-ctl); display: inline-flex; align-items: center; justify-content: center; padding: 0 5px; }
/* ปฏิทินการเรียน */
.cal { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; }
.cal-head { display: flex; align-items: center; justify-content: center; gap: 18px; margin-bottom: 12px; }
.cal-head b { font-size: 16px; min-width: 150px; text-align: center; }
.cal-scroll { overflow-x: auto; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(84px, 1fr)); gap: 6px; min-width: 620px; }
.cal-dh { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); padding: 4px 0; }
.cal-cell { min-height: 78px; border: 1px solid var(--border); border-radius: var(--r-ctl); padding: 5px; display: flex; flex-direction: column; gap: 3px; background: var(--bg); }
.cal-cell.blank { border: 0; background: transparent; }
.cal-cell.today { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand) inset; }
.cal-cell.has-ev { cursor: pointer; transition: background .12s, border-color .12s; }
.cal-cell.has-ev:hover { background: var(--surface-hover); border-color: var(--brand); }
.cal-day { font-size: 12px; font-weight: 700; color: var(--muted); }
.cal-cell.today .cal-day { color: var(--brand); }
.cal-ev { font-size: 11.5px; line-height: 1.25; padding: 2px 5px; border-radius: 6px; border-left: 3px solid var(--border); background: var(--surface); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev .ic { width: 10px; height: 10px; vertical-align: -1px; margin-right: 2px; }
.cal-ev.st-present { background: var(--ok-bg); border-color: var(--ok-bd); color: var(--ok-fg); }
.cal-ev.st-leave { background: var(--leave-bg); border-color: var(--leave-bd); color: var(--leave-fg); }
.cal-ev.st-absent { background: var(--miss-bg); border-color: var(--miss-bd); color: var(--miss-fg); }
.cal-ev.st-makeup { background: var(--mk-bg); border-color: var(--mk-bd); color: var(--mk-fg); }
.cal-ev.st-cancelled { background: var(--bg); border-color: var(--border); color: var(--muted); text-decoration: line-through; }
.cal-ev.st-plan { background: var(--surface); border-color: var(--plan-bd); color: var(--muted); border-left-style: dashed; }
.cal-tag { font-size: 11px; background: var(--brand); color: #fff; border-radius: 4px; padding: 0 4px; }
.cal-tag.sub { background: var(--info); }
.cal-tag.move { background: var(--mk-bd); }
.cal-tag.off { background: var(--muted); }
.cal-tag.makeup { background: var(--mk-bd); }
.cal-tag.warn { background: var(--amber-weak); color: var(--amber); }

/* ---------- QR พร้อมเพย์ ---------- */
.pay-qr { display: flex; justify-content: center; margin-bottom: 14px; }
.qr-wrap { text-align: center; }
.qr-wrap img { display: block; margin: 0 auto 6px; border-radius: 8px; background: #fff; padding: 8px; }

/* ---------- วงแหวนโควตา (donut) ---------- */
.quota-cell { display: inline-flex; flex-direction: column; align-items: center; gap: 3px; }
.quota { position: relative; width: 42px; height: 42px; }
.quota-ring { width: 42px; height: 42px; display: block; }
.qr-bg { fill: none; stroke: var(--surface-2); stroke-width: 4.5; }
.qr-fg { fill: none; stroke-width: 4.5; stroke-linecap: round; transition: stroke-dashoffset .6s var(--ease-out-quint); }
.quota-ctr { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; }
.quota-cap { font-size: 11px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.q-ok .qr-fg { stroke: var(--green); } .q-ok .quota-ctr { color: var(--green); }
.q-low .qr-fg { stroke: var(--amber); } .q-low .quota-ctr { color: var(--amber); }
.q-empty .qr-fg { stroke: var(--red); } .q-empty .quota-ctr { color: var(--red); }
.q-month .qr-fg { stroke: var(--brand); } .q-month .quota-ctr { color: var(--brand); }
.q-done .qr-fg { stroke: var(--green); } .q-done .quota-ctr { color: var(--green); }
@media (prefers-reduced-motion: reduce) { .qr-fg { transition: none; } }

/* ---------- ตารางสอนรายสัปดาห์ (week grid) ---------- */
.wk-scroll { overflow-x: auto; }
.wk-grid { display: grid; grid-template-columns: repeat(7, minmax(116px, 1fr)); gap: 8px; min-width: 812px; }
.wk-col { min-width: 0; }
.wk-day { display: flex; align-items: center; justify-content: center; gap: 6px; font-weight: 700; padding: 8px 4px; background: var(--surface-2); border-radius: var(--r-sm); margin-bottom: 8px; }
.wk-day .wk-n { font-size: 11px; font-weight: 700; color: var(--brand); background: var(--brand-weak); border-radius: var(--pill); padding: 0 6px; min-width: 8px; }
.wk-cell { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-ctl); padding: 8px 10px; margin-bottom: 8px; box-shadow: var(--sh-sm); }
.wk-cell.clk { cursor: pointer; transition: border-color .12s; }
.wk-cell.clk:hover { border-color: var(--brand); }
.wk-time { font-size: 12.5px; color: var(--brand); font-weight: 700; }
.wk-subj { font-weight: 600; font-size: 14px; margin-top: 2px; }
.wk-meta { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.wk-empty { text-align: center; color: var(--faint); padding: 10px 0; }
/* checkbox + field hint + count badge (คาบค้าง) */
.chk { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; margin: 0 0 12px; cursor: pointer; line-height: 1.5; }
.chk input { width: auto; margin-top: 2px; }
.fhint { display: block; font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.fsec { display: block; font-size: 12.5px; font-weight: 600; color: var(--text); margin: 12px 0 2px; padding-top: 8px; border-top: 1px solid var(--border); }
.req { color: var(--miss-bd); font-weight: 700; }
.cnt { font-weight: 700; color: var(--brand); }
.cnt.on { background: var(--alert-solid); color: #fff; border-radius: var(--r-ctl); padding: 0 6px; margin-left: 2px; }
/* คำอธิบายในโมดัลจัดการคาบ/ครูลา */
.hint { font-size: 13px; color: var(--muted); margin: 0 0 12px; line-height: 1.55; }
.hint-scope { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 8px 10px; }
.hint-scope .ic { width: 15px; height: 15px; vertical-align: -3px; margin-right: 3px; }
.adot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.adot.blue { background: var(--info); }
.adot.amber { background: var(--mk-bd); }
.adot.red { background: var(--miss-bd); }
.adj-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 11.5px; color: var(--muted); margin: 0 0 10px; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 0 0 12px; font-size: 12px; color: var(--muted); }
.cal-legend span { display: inline-flex; align-items: center; gap: 5px; }
.cal-legend .ic { width: 13px; height: 13px; }
.cal-legend .dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; border-left: 3px solid; }
.dot.st-present { background: var(--ok-bg); border-color: var(--ok-bd); }
.dot.st-leave { background: var(--leave-bg); border-color: var(--leave-bd); }
.dot.st-absent { background: var(--miss-bg); border-color: var(--miss-bd); }
.dot.st-makeup { background: var(--mk-bg); border-color: var(--mk-bd); }
.dot.st-plan { background: var(--surface); border-color: var(--plan-bd); }
/* modal รายละเอียดคาบของวัน */
.cal-day-list { display: flex; flex-direction: column; gap: 10px; }
.cal-day-row { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: var(--r-ctl); padding: 10px 12px; }
.cal-day-row.st-present { border-left-color: var(--ok-bd); }
.cal-day-row.st-leave { border-left-color: var(--leave-bd); }
.cal-day-row.st-absent { border-left-color: var(--miss-bd); }
.cal-day-row.st-makeup { border-left-color: var(--mk-bd); }
.cal-day-row.st-plan { border-left-color: var(--plan-bd); border-left-style: dashed; }
.cal-day-time { flex: 0 0 auto; font-weight: 700; font-size: 13px; min-width: 92px; }
.cal-day-info { flex: 1; min-width: 0; }
.cal-day-subj { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.cal-day-info .sm .ic { width: 14px; height: 14px; vertical-align: -2px; }
.badge.plan { background: var(--bg); color: var(--muted); border: 1px dashed var(--plan-bd); }
.cal-day-side { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.cal-day-acts { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; }
/* ป้ายวิชาแบบยังมีค้าง (เหลือง) ในช่องปฏิทิน */
.cal-ev.st-todo { background: var(--mk-bg); border-color: var(--mk-bd); color: var(--mk-fg); }
.dot.st-todo { background: var(--mk-bd); }
.cal-ev.cal-more { background: transparent; border-color: transparent; color: var(--muted); font-weight: 600; }
/* ---------- มุมมองรายการ (agenda) ---------- */
.cal-day-row.st-todo { border-left-color: var(--mk-bd); }
.cal-day-row[role="button"] { cursor: pointer; transition: background .12s, border-color .12s; }
.cal-day-row[role="button"]:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.badge.todo { background: var(--mk-bg); color: var(--mk-fg); }
.badge.st-ic::before { display: none; }        /* ใช้ไอคอนแทนจุด */
.badge .ic { width: 13px; height: 13px; }
.ag-date { font-size: 13px; font-weight: 700; color: var(--muted); margin: 18px 2px 8px; }
.ag-date:first-child { margin-top: 2px; }
/* การ์ดเลือกวิชา (ชั้น 1 ของ modal) */
.subj-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 12px 14px; margin-bottom: 8px; cursor: pointer; font: inherit; color: inherit; transition: background .12s, border-color .12s; }
.subj-card:hover { background: var(--surface-hover); border-color: var(--brand); }
.subj-main { display: flex; flex-direction: column; gap: 2px; }
.subj-main b { font-size: 15px; }
.subj-main .ic { width: 14px; height: 14px; vertical-align: -2px; margin-right: 3px; }
.subj-side { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.subj-side .ic { width: 18px; height: 18px; }
.cd-back { margin-bottom: 10px; }
.cd-subj-h { margin-bottom: 10px; font-size: 15px; }
/* segmented toggle */
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-ctl); padding: 3px; margin-bottom: 16px; width: 100%; }
.seg button { flex: 1; border: none !important; background: none !important; padding: 7px 12px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--muted) !important; cursor: pointer; box-shadow: none !important; }
.seg button.on { background: var(--surface) !important; color: var(--brand) !important; box-shadow: var(--sh) !important; }
.static-field { padding: 10px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-ctl); font-weight: 600; }

/* batch billing list */
.bill-list { display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow-y: auto; margin-bottom: 4px; }
.bill-row { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--r-ctl); }
.bill-row .grow { flex: 1; }
.bill-row.paid { opacity: .6; }
.bill-amt { width: 90px !important; text-align: right; padding: 6px 8px; }
.bill-row select { width: auto !important; flex: 0 0 auto; min-width: 118px; padding: 6px 8px; }
.bill-head { display: flex; align-items: center; gap: 10px; padding: 7px 11px; margin-bottom: 9px; font-weight: 600; font-size: 13.5px; border-bottom: 1px solid var(--border); cursor: pointer; }
.bill-head .grow { flex: 1; }
/* จอแคบ: แถวเก็บเงินขึ้นบรรทัดใหม่ — ติ๊ก+ชื่อบรรทัดแรก · ช่องยอดเต็มกว้างบรรทัดล่าง (ไม่ล้นโมดัล + แตะง่าย) */
@media (max-width: 480px) {
  .bill-row { flex-wrap: wrap; }
  .bill-row .bill-amt { flex: 1 0 100%; width: auto !important; text-align: left; }
}

/* weekly schedule */
.week { display: flex; flex-direction: column; gap: 14px; }
.day-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 6px 8px 8px; box-shadow: var(--sh); }
.day-card.today { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand) inset, var(--sh); }
.day-head { font-weight: 700; font-size: 14px; padding: 10px 8px 8px; display: flex; align-items: center; gap: 8px; }
.tag-today { font-size: 11px; font-weight: 600; color: var(--brand); background: var(--brand-weak); padding: 2px 8px; border-radius: var(--pill); }
.slot { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--r-ctl); }
.slot:hover { background: var(--surface-hover); }
.slot + .slot { border-top: 1px solid var(--border); }
.slot-time { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--brand); min-width: 96px; }
.slot-main { flex: 1; }
.slot-teacher { color: var(--muted); font-size: 13px; }
.slot-act { display: inline-flex; gap: 6px; align-items: center; }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn.sm .ic { width: 15px; height: 15px; }
.ac-hint { font-size: 11.5px; color: var(--faint); margin-top: 3px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip-x { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 11px; border-radius: var(--pill);
  background: var(--brand-weak); color: var(--brand); font-size: 13px; font-weight: 600; }
.chip-x button { background: none; border: none; color: inherit; cursor: pointer; padding: 0 2px; font-size: 15px; line-height: 1; opacity: .7; }
.chip-x button:hover { opacity: 1; }

/* toolbar (search + filters) + pager */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .toolbar-right { margin-left: auto; }
.toolbar .search { position: relative; flex: 1; min-width: 200px; max-width: 340px; }
.toolbar .search .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); width: 16px; height: 16px; }
.toolbar .search input { padding-left: 34px; }
.toolbar select { width: auto; min-width: 140px; }
.toolbar .tb-date { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.toolbar .tb-date input { width: auto; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 4px 2px; flex-wrap: wrap; font-size: 13px; }
.pager .actions { align-items: center; }
.pager .actions .muted { padding: 0 4px; }

.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty .ic { width: 30px; height: 30px; color: var(--faint); margin-bottom: 8px; }
/* ไอคอนในปุ่ม CTA ของ empty-state — ตามสีปุ่ม (ขาวบนพื้นม่วง) ไม่ใช่สีจางของ empty */
.empty button .ic { width: 16px; height: 16px; color: inherit; margin-bottom: 0; }
/* โหลดไม่สำเร็จ (ต่างจาก "ไม่มีข้อมูล") — ไอคอนสีเตือน + ปุ่มลองใหม่ */
.err-state { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.err-state .ic { color: var(--red); }
.err-state button { margin-top: 12px; }
/* โครงร่างระหว่างโหลด (skeleton shimmer) — ลดการกระพริบ/เลื่อนของเลย์เอาต์ */
@keyframes sk-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.sk { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-hover) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: sk-shimmer 1.3s ease-in-out infinite; border-radius: var(--r-sm); }
.sk-line { display: block; height: 13px; }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } }

/* ---------- คำแนะนำเริ่มต้นใช้งาน (แสดงครั้งแรกต่อ role แล้วจำไว้) ---------- */
.welcome { position: relative; background: var(--brand-weak); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px 46px 18px 20px; margin-bottom: 22px; }
.welcome h2 { margin: 0 0 5px; font-size: 18px; display: flex; align-items: center; gap: 9px; }
.welcome h2 .ic { width: 21px; height: 21px; color: var(--brand); flex: none; }
.welcome .welcome-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 14px; line-height: 1.55; }
.welcome ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 11px; }
.welcome li { display: flex; gap: 11px; align-items: flex-start; font-size: 14.5px; line-height: 1.55; }
.welcome li .ic { width: 19px; height: 19px; color: var(--brand); flex: none; margin-top: 2px; }
.welcome-foot { margin-top: 16px; }
.welcome-x { position: absolute; top: 10px; right: 10px; }
.toast { position: fixed; bottom: max(22px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 11px 20px; border-radius: var(--r); box-shadow: var(--sh-lg); z-index: var(--z-toast); font-size: 14px; font-weight: 500; animation: rise .2s ease; }
.toast.err { background: var(--red); color: #fff; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }
.toast.leaving { animation: toast-out .2s var(--ease-out-quart) forwards; }
@keyframes toast-out { to { opacity: 0; transform: translate(-50%, 8px); } }

/* logo chip (พื้นขาวเสมอ) */
.logo-chip { display: inline-flex; align-items: center; justify-content: center; background: #fff; border-radius: var(--r-sm); padding: 3px; overflow: hidden; }
.logo-chip img { width: 26px; height: 26px; object-fit: contain; display: block; }

/* ============ Login (split-screen) ============ */
.auth { display: flex; min-height: 100vh; }
.auth-brand { flex: 1.1; position: relative; overflow: hidden; color: #fff; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 48px 40px; background: linear-gradient(150deg, #8b6dff 0%, #5b7cfa 42%, var(--brand-2) 100%); }
.auth-brand::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 130px; background: radial-gradient(120% 100% at 50% 100%, rgba(255,255,255,.18), transparent 70%); }
.auth-brand-logo { width: 128px; height: 128px; border-radius: 32px; background: #fff; padding: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.22); margin-bottom: 22px; position: relative; z-index: 2; }
.auth-brand-logo img { width: 100%; height: 100%; object-fit: contain; }
.auth-brand h1 { font-size: 30px; margin: 0 0 6px; position: relative; z-index: 2; color: #fff; }
.auth-brand .en { font-size: 16px; opacity: .92; position: relative; z-index: 2; }
.auth-brand .tag { font-size: 14px; opacity: .8; margin-top: 2px; position: relative; z-index: 2; }
.auth-contact { margin-top: 30px; font-size: 13.5px; line-height: 2; position: relative; z-index: 2; }
.auth-contact a { color: #fff; text-decoration: none; opacity: .9; }
.auth-contact a:hover { opacity: 1; text-decoration: underline; }
.auth-contact .sep { opacity: .5; margin: 0 6px; }
.note { position: absolute; color: rgba(255,255,255,.22); font-size: 34px; z-index: 1; animation: float 6s ease-in-out infinite; }
.note.n1 { top: 14%; left: 16%; } .note.n2 { top: 24%; right: 18%; font-size: 26px; animation-delay: 1.5s; }
.note.n3 { bottom: 20%; left: 22%; font-size: 44px; animation-delay: .8s; } .note.n4 { bottom: 28%; right: 14%; animation-delay: 2.2s; }
@keyframes float { 0%,100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-16px) rotate(4deg); } }
.auth-form { flex: 1; display: grid; place-items: center; padding: 40px 28px; background: var(--bg); }
.auth-form-inner { width: 100%; max-width: 360px; }
.auth-form h2 { font-size: 24px; margin: 0 0 4px; }
.auth-form .sub { color: var(--muted); margin: 0 0 26px; }
.auth-form label { margin-top: 16px; }
.auth-form .field { position: relative; }
.auth-form .field .toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: auto; background: transparent; border: none; color: var(--muted); padding: 6px 8px; font-size: 13px; cursor: pointer; }
.auth-form button[type=submit] { width: 100%; margin-top: 24px; padding: 12px; font-size: 15px; }
.auth-hint { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 18px; }

/* ---------- responsive ---------- */
@media (max-width: 820px) {
  .auth { flex-direction: column; }
  .auth-brand { flex: none; padding: 40px 24px 48px; }
  .auth-brand-logo { width: 96px; height: 96px; border-radius: 24px; margin-bottom: 16px; }
  .auth-brand h1 { font-size: 24px; }
  .note { display: none; }
  .auth-form { padding: 32px 24px 48px; }
}
/* ---------- แท็บเล็ต+มือถือ: ยุบ sidebar เป็นแถบบน + ปุ่มแฮมเบอร์เกอร์ ---------- */
/* เนื้อหาได้ความกว้างเต็ม (ตารางไม่ถูกบีบ) · เมนูพับไว้ กดเปิด → หน้าจอแรกเห็นเนื้อหาทันที */
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  /* คง flex-direction: column ของ base ไว้ → brand (มีแฮมเบอร์เกอร์อยู่ข้างใน) เป็นแถวบน, nav/foot อยู่ล่าง */
  .sidebar {
    width: 100%; height: auto; gap: 0;
    position: sticky; top: 0; z-index: var(--z-sticky);
    border-right: 0; border-bottom: 1px solid var(--border); padding: 10px 16px;
  }
  .brand { padding: 4px 0; }
  .nav-toggle { display: grid; margin-left: auto; }   /* ดันแฮมเบอร์เกอร์ไปขวาสุดของแถวแบรนด์ */
  .nav-label:not(.nav-group) { display: none; }   /* ซ่อน "เมนู" บนมือถือ แต่คงป้ายหัวกลุ่มไว้ (ช่วยจัดกลุ่ม) */
  /* พับเมนูไว้ก่อน — เปิดด้วยปุ่มแฮมเบอร์เกอร์ */
  .nav, .side-foot { display: none; }
  /* เมนูมือถือ = ลิสต์คอลัมน์เดียว (drawer มาตรฐาน) แถวสูงพอ กดง่าย เลื่อนได้ถ้ายาว */
  .sidebar.nav-open .nav { display: flex; flex-direction: column; gap: 3px; margin-top: 10px; max-height: 66vh; overflow-y: auto; }
  .sidebar.nav-open .nav a { padding: 13px 14px; border-radius: var(--r-ctl); font-size: 15px; }
  .sidebar.nav-open .nav-group { padding: 12px 4px 4px; }   /* ป้ายหัวกลุ่มเต็มกว้าง */
  .sidebar.nav-open .side-foot { display: flex; margin-top: 12px; }
  .nav a { flex: none; }
  .nav a.active::before { display: none; }
  .main { padding: 22px 24px 52px; }
}
@media (max-width: 720px) {
  .main { padding: 18px 14px 48px; }
  /* ฟอร์มในแถว + toolbar + การ์ดคาบ ให้ขึ้นบรรทัดใหม่บนจอเล็ก */
  .row, .modal-body .row2 { flex-wrap: wrap; }
  .row > *, .modal-body .row2 > * { flex: 1 1 100%; }
  .toolbar { flex-wrap: wrap; }
  .toolbar .search { flex: 1 1 100%; }
  .toolbar select, .toolbar .tb-date { flex: 1 1 auto; }
  .toolbar > button { flex: 1 1 100%; justify-content: center; }
  .slot { flex-wrap: wrap; }
  .slot-main { flex: 1 1 100%; order: 3; }
  .slot-teacher { order: 2; margin-left: auto; }
  .slot-act { order: 4; flex: 1 1 100%; }
  .modal-ov { padding: 16px 10px; }
  /* ตารางเลื่อนแนวนอนได้ ไม่ดันจอ */
  .table-wrap { overflow-x: auto; }
  table { min-width: 560px; }
  /* ปุ่มบนหัวเพจ วางแนวตั้งเต็มความกว้าง ไม่ล้นจอ */
  .page-actions { flex-direction: column; align-items: stretch; }
  .page-actions > button { width: 100%; justify-content: center; }
  /* มือถือ: พับตัวกรอง 4 ช่องไว้หลังปุ่ม "ตัวกรอง" — ปฏิทิน/รายการขึ้นในจอแรก */
  .page-actions > .sched-ftoggle { display: inline-flex; }
  .sched-filters { display: none; }
  .sched-filters.open { display: flex; flex-direction: column; gap: 10px; width: 100%; }
  .sched-filters.open select { width: 100%; min-width: 0; max-width: none; }
}

/* ป้ายในเซลล์ (.td-label) โผล่เฉพาะโหมดการ์ดบนมือถือ — เดสก์ท็อปใช้หัวตาราง (thead) แทน */
.td-label { display: none; }

/* ---------- มือถือแคบ: ตาราง → การ์ด (แต่ละแถว = การ์ด, แต่ละช่อง = "ป้าย: ค่า") ---------- */
/* แทน scroll แนวนอนที่มองไม่เห็น + ปุ่ม ⋯ ที่หลุดขวาจอ → ทุกช่อง+ปุ่มอยู่ในการ์ด เห็นครบ */
@media (max-width: 560px) {
  .table-wrap { overflow-x: visible; border: 0; background: transparent; box-shadow: none; border-radius: 0; }
  .table-wrap table { min-width: 0; width: 100%; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; }
  /* หัวตารางไม่จำเป็นแล้ว — ป้ายย้ายเข้าแต่ละเซลล์เป็น DOM จริง (.td-label) ที่ screen reader อ่านได้ */
  .table-wrap thead { display: none; }
  .table-wrap tbody tr {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
    box-shadow: var(--sh-sm); padding: 4px 14px; margin-bottom: 12px;
  }
  .table-wrap tbody td {
    display: flex; justify-content: space-between; align-items: center; gap: 16px;
    padding: 9px 0; border: 0; border-bottom: 1px solid var(--border);
    text-align: right; white-space: normal; min-height: 0;
  }
  .table-wrap tbody tr td:last-child { border-bottom: 0; }
  .table-wrap tbody td .td-label {
    display: block; text-align: left; flex: 0 0 auto;
    color: var(--muted); font-size: 12.5px; font-weight: 600; white-space: nowrap;
  }
  /* ช่องไม่มีป้าย (คอลัมน์ปุ่ม/⋯) = ปุ่มเต็มบรรทัด ชิดขวา */
  .table-wrap tbody td[data-label=""], .table-wrap tbody td:not([data-label]) { justify-content: flex-end; }
  /* ปฏิทิน: ซ่อนปุ่มสลับ "เดือน/รายการ" — มุมมองเดือน (กริด 7 คอลัมน์) ถูกตัดบนจอแคบ จึงบังคับ "รายการ" (renderCal คุม view เอง) */
  #calview { display: none; }
}

/* ---------- reduced motion (เคารพการตั้งค่าผู้ใช้) ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .note { animation: none !important; }   /* โน้ตดนตรีลอยวนที่หน้าล็อกอิน — หยุดสนิท */
}

/* ---------- อุปกรณ์สัมผัส: เป้าแตะใหญ่ขึ้น + กัน iOS ซูม (เดสก์ท็อปยังแน่นเหมือนเดิม) ---------- */
@media (pointer: coarse) {
  input, select, textarea { font-size: 16px; }   /* ≥16px กัน Safari iOS ซูมตอนโฟกัส */
  button.ghost, button.danger,
  button:not(.icon-btn):not(.toggle):not(.sm) { min-height: 44px; }
  .chip-x button { min-height: 0; }               /* ยกเว้นปุ่ม × เล็กในชิป */
  button.sm { min-height: 44px; padding: 11px 15px !important; font-size: 13.5px !important; }
  .seg button { min-height: 44px; padding: 13px 12px; }
  .icon-btn { width: 44px; height: 44px; }
  .icon-btn.sm { width: 44px; height: 44px; }
  .icon-btn.sm .ic { width: 18px; height: 18px; }
  .nav a, .ac-item { padding: 12px; }
  .actions, .slot-act, .cal-day-acts, .lrow-ctl { gap: 8px; }
}

/* ============================================================
   Landing page — โรงเรียนดนตรีฮาร์โมนี (น่าเชื่อถือ · มืออาชีพ · โมเดิร์น · เหลี่ยมคม)
   ฟอนต์ Anuphan (โมเดิร์นไทย) self-host เพื่อไม่ให้ติด CSP
   ============================================================ */
@font-face { font-family: 'Anuphan'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/anuphan-regular.woff2') format('woff2'); }
@font-face { font-family: 'Anuphan'; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/anuphan-500.woff2') format('woff2'); }
@font-face { font-family: 'Anuphan'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/anuphan-600.woff2') format('woff2'); }
@font-face { font-family: 'Anuphan'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/anuphan-700.woff2') format('woff2'); }

.lp, .lp-ov {
  --ink: #221a36; --mut: #5f5878;
  --p: #6d4bf5; --p-strong: #5836e8; --line: #e6e2f2; --r: 3px;
  font-family: 'Anuphan', 'Sarabun', 'Noto Sans Thai', system-ui, sans-serif;
}
.lp {
  position: relative; min-height: 100dvh; max-width: 100vw; overflow-x: hidden;
  color: var(--ink); background: #ffffff; display: flex; flex-direction: column;
}

/* ---------- HERO (ภาพจริงนำ) ---------- */
.lp-hero { position: relative; min-height: min(86vh, 740px); display: flex; align-items: flex-end; overflow: hidden; isolation: isolate; }
.lp-hero::before { content: ""; position: absolute; inset: 0; z-index: -2; background: var(--hero, linear-gradient(140deg, #6a4ff0 0%, #8f66ff 50%, #c3a0ff 100%)); background-size: cover; background-position: center; }
.lp-hero.has-photo::before { background-position: center 28%; }
/* ฉาก 3D ลอยในhero (โน้ต/ทรงมันวาว) — อยู่เหนือรูป/scrim (z -1) แต่ใต้ข้อความ (inner z2) และ nav (z5) */
.lp-hero-3d { position: absolute; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.lp-hero-3d canvas { display: block; width: 100%; height: 100%; }
@media (max-width: 899px) { .lp-hero-3d { display: none; } }

/* ===== Minimal-luxe hero (redesign 2026-07-06: โน้ต 3D ชิ้นเดียวเป็นชิ้นเอก) ===== */
.lp-mhero { position: relative; background: #fff; overflow: hidden;
  background-image: radial-gradient(1200px 620px at 50% -12%, rgba(109,75,245,.10), transparent 60%),
                    radial-gradient(760px 520px at 86% 14%, rgba(255,111,92,.06), transparent 60%); }
.lp-mnav { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 24px clamp(16px,4vw,48px); position: relative; z-index: 5; }
.lp-mlogo { display: flex; align-items: center; gap: 11px; font-weight: 700; font-size: 16px; min-width: 0; }
.lp-mlogo img { border-radius: var(--r); }
.lp-mlogo b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lp-mlinks { display: flex; align-items: center; gap: 28px; flex-shrink: 0; }
.lp-mlinks > a { color: var(--mut); text-decoration: none; font-weight: 500; font-size: 15px; }
.lp-mlinks > a:hover { color: var(--ink); }
.lp-mhero-in { max-width: 960px; margin: 0 auto; padding: clamp(28px,5vh,58px) clamp(16px,4vw,48px) 0; text-align: center; position: relative; z-index: 2; }
.lp-eyebrow2 { font-size: 12.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--p); font-weight: 600; margin-bottom: 20px; }
.lp-mh1 { font-size: clamp(44px,7vw,86px); line-height: 1.04; letter-spacing: -.035em; font-weight: 700; margin: 0 0 20px; text-wrap: balance; color: var(--ink); }
.lp-mlead { font-size: clamp(16px,1.9vw,20px); line-height: 1.6; color: var(--mut); max-width: 50ch; margin: 0 auto 28px; font-weight: 400; }
.lp-mcta { display: flex; gap: 13px; justify-content: center; flex-wrap: wrap; }
.lp-mstage { position: relative; height: clamp(300px,42vh,460px); margin-top: 24px; display: grid; place-items: center; }
.lp-ring { position: absolute; border-radius: 50%; pointer-events: none; }
.lp-ring1 { width: min(370px,74vw); height: min(370px,74vw); border: 1.5px solid rgba(109,75,245,.16); }
.lp-ring2 { width: min(510px,92vw); height: min(510px,92vw); border: 1px solid rgba(109,75,245,.09); }
.lp-stage { position: absolute; inset: 0; display: grid; place-items: center; }
.lp-stage canvas { width: 100% !important; height: 100% !important; display: block; }
.lp-stage-fallback { font-size: clamp(96px,17vw,168px); line-height: 1; filter: drop-shadow(0 24px 40px rgba(109,75,245,.35)); }
.lp-stage[data-d3="on"] .lp-stage-fallback { display: none; }
/* แถบรูปเด็กจริง ใต้ hero (คงความอบอุ่น/หลักฐานจริง) */
.lp-photoband { max-width: 1180px; margin: 8px auto 0; padding: 0 clamp(16px,4vw,48px); }
.lp-photoframe { border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); aspect-ratio: 16/7; }
.lp-photoframe img { width: 100%; height: 100%; object-fit: cover; object-position: center 28%; display: block; }
@media (max-width: 620px) { .lp-photoframe { aspect-ratio: 4/3; } }
.lp-hero::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, rgba(18,12,38,.6) 0%, rgba(18,12,38,.24) 40%, rgba(18,12,38,0) 72%), linear-gradient(180deg, rgba(18,12,38,.42) 0%, rgba(18,12,38,.06) 28%, rgba(18,12,38,.18) 56%, rgba(18,12,38,.84) 100%); }

.lp-nav { position: absolute; top: 0; left: 0; right: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px clamp(16px,4vw,52px); }
.lp-logo { display: flex; align-items: center; gap: 10px; min-width: 0; }
.lp-logo img { border-radius: var(--r); background: #fff; padding: 3px; box-shadow: 0 4px 14px rgba(0,0,0,.22); }
.lp-logo b { font-weight: 700; font-size: 16px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; text-shadow: 0 1px 8px rgba(0,0,0,.35); }
.lp-links { display: flex; align-items: center; gap: 26px; flex-shrink: 0; }
.lp-links > a { color: rgba(255,255,255,.92); text-decoration: none; font-weight: 600; font-size: 15px; text-shadow: 0 1px 8px rgba(0,0,0,.3); }
.lp-links > a:hover { color: #fff; }

/* หมายเหตุ: ใช้ !important เพราะปุ่ม global (button:not(.ghost)...) specificity สูงกว่า class เดียว */
.lp-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; border: 0; cursor: pointer; font-weight: 700; font-size: 16px; border-radius: var(--r); padding: 12px 26px; color: #fff !important; background: var(--p) !important; box-shadow: 0 6px 16px rgba(109,75,245,.28); transition: transform .16s ease, box-shadow .16s ease, background .16s ease; text-decoration: none; white-space: nowrap; }
.lp-btn .ic { width: 19px; height: 19px; }
.lp-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(109,75,245,.38); background: var(--p-strong) !important; }
.lp-btn:active { transform: translateY(0); }
.lp-btn-sm { min-height: 44px; padding: 10px 18px; font-size: 14.5px; }
.lp-btn-lg { min-height: 54px; padding: 15px 32px; font-size: 17px; }
.lp-btn-ghost { background: #fff !important; color: var(--p) !important; border: 1.5px solid var(--line); box-shadow: none; }
.lp-btn-ghost:hover { background: #faf9ff !important; border-color: var(--p); box-shadow: none; }
.lp-btn-glass { background: rgba(255,255,255,.14) !important; color: #fff !important; border: 1.5px solid rgba(255,255,255,.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); box-shadow: none; }
.lp-btn-glass:hover { background: rgba(255,255,255,.26) !important; }

.lp-hero-inner { position: relative; z-index: 2; width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 clamp(16px,4vw,52px) clamp(34px,6vh,66px); color: #fff; }
.lp-eyebrow { font-weight: 600; letter-spacing: .12em; text-transform: uppercase; font-size: 13px; color: #e7ddff; margin-bottom: 16px; text-shadow: 0 1px 8px rgba(0,0,0,.4); }
.lp-hero h1 { font-size: clamp(38px, 6.4vw, 70px); line-height: 1.06; letter-spacing: -0.02em; margin: 0 0 18px; font-weight: 700; text-wrap: balance; color: #fff; text-shadow: 0 2px 26px rgba(0,0,0,.4); }
.lp-lead { font-size: clamp(16px, 1.9vw, 20px); line-height: 1.6; color: rgba(255,255,255,.95); max-width: 46ch; margin: 0 0 26px; font-weight: 400; text-shadow: 0 1px 14px rgba(0,0,0,.4); }
.lp-cta { display: flex; gap: 14px; flex-wrap: wrap; }

/* ---------- แถบสถิติ ---------- */
.lp-stats { display: flex; justify-content: center; gap: clamp(24px,6vw,80px); flex-wrap: wrap; padding: 28px clamp(16px,4vw,48px); background: #faf9ff; border-bottom: 1px solid var(--line); }
.lp-stat { text-align: center; }
.lp-stat b { display: block; font-size: clamp(24px,3vw,32px); font-weight: 700; color: var(--p); letter-spacing: -.01em; }
.lp-stat span { color: var(--mut); font-size: 14px; font-weight: 500; }

.lp-sec { position: relative; z-index: 2; padding: clamp(28px,5vh,60px) clamp(16px,4vw,48px); max-width: 1080px; margin: 0 auto; width: 100%; }
.lp-h2 { text-align: center; font-size: clamp(24px,3.4vw,38px); font-weight: 700; margin: 0 0 8px; letter-spacing: -0.02em; text-wrap: balance; color: var(--ink); }
.lp-sub { text-align: center; color: var(--mut); font-size: clamp(14.5px,1.6vw,17px); margin: 0 auto 30px; max-width: 52ch; font-weight: 400; }

.lp-course-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.lp-course { background: #fff; border-radius: var(--r); padding: 26px 16px; text-align: center; border: 1px solid var(--line); transition: border-color .16s ease, transform .16s ease; }
.lp-course:hover { transform: translateY(-3px); border-color: var(--p); }
.lp-course-ic { font-size: 38px; display: block; margin-bottom: 10px; }
.lp-course b { font-size: 16px; font-weight: 600; }

.lp-why-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.lp-why { background: #fff; border-radius: var(--r); padding: 28px 24px; border: 1px solid var(--line); transition: border-color .16s ease, transform .16s ease; }
.lp-why:hover { transform: translateY(-3px); border-color: var(--p); }
.lp-why-ic { display: inline-grid; place-items: center; width: 50px; height: 50px; border-radius: var(--r); margin-bottom: 16px; background: #efe9ff; color: var(--p); }
.lp-why-ic .ic { width: 26px; height: 26px; stroke-width: 1.9; }
.lp-why b { font-size: 18px; font-weight: 600; display: block; margin-bottom: 6px; }
.lp-why p { font-size: 14.5px; line-height: 1.6; color: var(--mut); margin: 0; font-weight: 400; }

.lp-contact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.lp-cc { display: flex; flex-direction: column; gap: 3px; background: #fff; border-radius: var(--r); padding: 22px; text-decoration: none; color: var(--ink); border: 1px solid var(--line); transition: border-color .16s ease, transform .16s ease; }
.lp-cc:hover { transform: translateY(-3px); border-color: var(--p); }
.lp-cc-ic { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r); margin-bottom: 10px; background: #efe9ff; color: var(--p); }
.lp-cc-ic .ic { width: 23px; height: 23px; }
.lp-cc b { font-size: 16px; font-weight: 600; }
.lp-cc small { color: var(--mut); font-size: 13.5px; }
.lp-cc.cc-fb .lp-cc-ic { background: #e8f0ff; color: #1877f2; }
.lp-cc.cc-ig .lp-cc-ic { background: #fdeaf3; color: #c73a74; }
.lp-contact-note { text-align: center; margin-top: 24px; color: var(--mut); font-weight: 500; }
.lp-linkbtn { display: inline-block; min-height: 44px; padding: 10px 4px; background: none; border: 0; color: var(--p); font-weight: 600; cursor: pointer; font-size: inherit; text-decoration: underline; }

/* แผนที่ฝัง (พร้อมหมุด) + ฟีดโพสต์ล่าสุดจากเฟซบุ๊ก */
.lp-map { max-width: 900px; margin: 0 auto 24px; text-align: center; }
.lp-map-frame { width: 100%; height: 360px; border: 1px solid var(--line); border-radius: var(--r); background: #eef0f3; display: block; }
.lp-map-open { margin-top: 14px; }
.lp-fb { display: flex; flex-direction: column; align-items: center; }
.lp-fb-frame { width: 100%; max-width: 400px; height: 560px; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: #fff; }
/* 3 โพสต์ล่าสุดเรียงแนวนอน (แอดมินตั้งลิงก์เอง) */
.lp-posts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: start; }
.lp-post { display: flex; justify-content: center; }
.lp-post-frame { width: 100%; max-width: 360px; height: 500px; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: #fff; }
.lp-social-cta { text-align: center; margin-top: 18px; }
@media (max-width: 780px) { .lp-posts { grid-template-columns: 1fr; justify-items: center; } }

.lp-foot { position: relative; z-index: 2; text-align: center; padding: 26px 16px 34px; font-size: 13.5px; color: var(--mut); margin-top: auto; }
.lp-foot-links { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.lp-foot-links a, .lp-foot-links .btn-link { color: var(--p); text-decoration: none; font-weight: 700; font-size: 13.5px; cursor: pointer; }

/* .lp-ov เป็น sibling ของ .lp — ตัวแปรสี (--p ฯลฯ) มาจาก selector รวม ".lp, .lp-ov" ด้านบน */
.lp-ov { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(18,12,38,.5); backdrop-filter: blur(5px); opacity: 0; transition: opacity .2s ease; }
.lp-ov.show { opacity: 1; }
.lp-login { width: 100%; max-width: 400px; background: #fff; color: var(--ink); border-radius: 6px; padding: 28px 26px 22px; box-shadow: 0 30px 70px rgba(18,12,38,.35); position: relative; transform: translateY(16px) scale(.98); transition: transform .22s cubic-bezier(.22,1,.36,1); }
.lp-ov.show .lp-login { transform: translateY(0) scale(1); }
.lp-x { position: absolute; top: 12px; right: 12px; width: 44px; height: 44px; border-radius: var(--r); border: 1px solid var(--line); background: #faf9ff; color: var(--p); cursor: pointer; font-size: 17px; font-weight: 700; }
.lp-x:hover { background: #efe9ff; }
.lp-login-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.lp-login-head img { border-radius: var(--r); }
.lp-login-head b { font-size: 20px; font-weight: 700; display: block; }
.lp-login-head small { color: var(--mut); font-size: 13px; }
.lp-login label { display: block; font-size: 13.5px; font-weight: 700; margin: 10px 0 5px; }
.lp-login input { width: 100%; border-radius: var(--r); }
.lp-login .field { position: relative; }
.lp-login .field .toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); min-height: 40px; display: inline-flex; align-items: center; background: none; border: 0; color: var(--p); font-size: 13px; font-weight: 700; cursor: pointer; padding: 6px 12px; }
.lp-login-hint { margin-top: 14px; font-size: 12.5px; color: var(--mut); text-align: center; line-height: 1.5; }

@media (max-width: 620px) {
  .lp-links > a { display: none; }
  .lp-hero { min-height: min(78vh, 620px); }
  .lp-hero-inner { padding-bottom: 32px; }
  .lp-cta { flex-direction: column; align-items: stretch; }
  .lp-cta .lp-btn { width: 100%; }
  .lp-stats { gap: 20px 36px; }
  .lp-map-frame { height: 280px; }
  .lp-fb-frame { height: 500px; }
}

@media (prefers-reduced-motion: reduce) {
  .lp-btn, .lp-course, .lp-why, .lp-cc, .lp-login, .lp-ov { transition: none !important; }
}

/* =================================================================== */
/* ===== Landing 2.0 — warm editorial (ดีไซน์จาก D:\pencil) ========== */
/* โทนครีม-ม่วงเข้ม มุมโค้ง รูปในกรอบโค้ง · scoped ใต้ .hm ไม่ชนธีมแอป */
/* =================================================================== */
.hm {
  --bg: #FFFFFF; --alt: #F6F3EE; --surface: #FFFFFF;
  --ink: #1B1620; --soft: #736D78;
  --ac: #5E2E9E; --ac-deep: #4A2280; --ac-soft: #F1EAF9;
  --line: #E9E3DB;
  --r-sm: 14px; --r-md: 22px; --r-lg: 34px; --pill: 999px;
  font-family: 'Anuphan', system-ui, -apple-system, sans-serif;
  color: var(--ink); background: var(--bg); line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  /* หมายเหตุ: ไม่ใส่ overflow-x ที่นี่ เพราะจะทำให้ position:sticky ของ nav พัง — คลิป ghost wordmark ที่ระดับ section แทน */
}
.hm *, .hm *::before, .hm *::after { box-sizing: border-box; }
.hm img { max-width: 100%; display: block; }
.hm-wrap { max-width: 1180px; margin: 0 auto; padding: 0 clamp(20px, 5vw, 48px); }

/* buttons */
.hm-btn { border: 0; border-radius: var(--pill); padding: 14px 26px; font-family: inherit; font-weight: 700; font-size: 15.5px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform .15s, box-shadow .15s, background .15s; }
.hm-btn .ic { width: 18px; height: 18px; }
.hm-btn-p { background: var(--ac); color: #fff; box-shadow: 0 12px 26px -10px rgba(94, 46, 158, .6); }
.hm-btn-p:hover { background: var(--ac-deep); transform: translateY(-1px); }
.hm-btn-g { background: var(--surface); color: var(--ink); border: 1.5px solid var(--line); }
.hm-btn-g:hover { border-color: var(--ac); color: var(--ac); }
.hm-btn-glass { background: rgba(255, 255, 255, .14); color: #fff; border: 1.5px solid rgba(255, 255, 255, .3); }
.hm-btn-glass:hover { background: rgba(255, 255, 255, .24); }
.hm-btn-sm { padding: 10px 20px; font-size: 14.5px; }
.hm-btn-block { width: 100%; }

/* nav */
.hm-nav { position: sticky; top: 0; z-index: 40; background: rgba(255, 255, 255, .82); backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid transparent; transition: background .2s, border-color .2s, box-shadow .2s; }
.hm-nav.is-scrolled { background: rgba(255, 255, 255, .94); border-bottom-color: var(--line); box-shadow: 0 6px 24px -16px rgba(27, 22, 32, .4); }
.hm-nav-in { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 15px; padding-bottom: 15px; }
.hm-logo { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--ink); }
.hm-logo-mark { width: 40px; height: 40px; border-radius: 12px; background: var(--ac); color: #fff; display: grid; place-items: center; flex-shrink: 0; overflow: hidden; }
.hm-logo-mark .ic { width: 20px; height: 20px; }
.hm-logo-mark img { width: 100%; height: 100%; object-fit: cover; }
.hm-logo-txt { display: flex; flex-direction: column; line-height: 1.1; }
.hm-logo-txt b { font-size: 18px; font-weight: 700; }
.hm-logo-txt small { font-size: 9.5px; font-weight: 600; letter-spacing: .14em; color: var(--soft); }
.hm-links { display: flex; align-items: center; gap: 26px; }
.hm-links a { color: var(--soft); text-decoration: none; font-size: 14.5px; font-weight: 500; transition: color .15s; }
.hm-links a:hover { color: var(--ac); }
.hm-links-login { display: none !important; }   /* ปุ่มล็อกอินในเมนู = โชว์เฉพาะมือถือ · !important กันโดน global button:not() ทับ */
/* แฮมเบอร์เกอร์ (มือถือ) — ซ่อนบนเดสก์ท็อป · !important เพราะ global `button:not()` (specificity สูง) บังคับ display */
/* บังคับทับ global `button:not()` (พื้นม่วง+padding) ให้แฮมเบอร์เกอร์เป็นไอคอนโปร่งเส้นเข้ม */
.hm-burger { display: none !important; flex-direction: column; justify-content: center; align-items: stretch !important; gap: 5px !important; width: 44px; height: 44px; padding: 10px !important; background: none !important; border: 0; cursor: pointer; flex-shrink: 0; }
.hm-burger span { display: block; height: 2px; width: 100%; background: var(--ink); border-radius: 2px; transition: transform .25s ease, opacity .2s ease; }
.hm-burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hm-burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.hm-burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* eyebrow / headings */
.hm-eyebrow { display: inline-flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; color: var(--ac); letter-spacing: .04em; margin-bottom: 16px; }
.hm-eyebrow-line { width: 26px; height: 2px; border-radius: 2px; background: currentColor; }
.hm-eyebrow.is-light { color: #C7A6ED; }
.hm-h1 { font-size: clamp(38px, 5vw, 52px); line-height: 1.12; letter-spacing: -.02em; font-weight: 700; margin: 0 0 20px; }
.hm-accent { color: var(--ac); }
.hm-lead { font-size: 16.5px; line-height: 1.65; color: var(--soft); max-width: 30em; margin: 0 0 28px; }
.hm-h2 { font-size: clamp(28px, 3.6vw, 38px); line-height: 1.2; letter-spacing: -.02em; font-weight: 700; margin: 0 0 14px; }
.hm-h2-sm { font-size: clamp(24px, 3vw, 32px); }
.hm-sub { font-size: 16px; line-height: 1.6; color: var(--soft); max-width: 40em; margin: 0 auto; }
.hm-head { text-align: center; max-width: 720px; margin: 0 auto 48px; }
.hm-head .hm-eyebrow { justify-content: center; }

/* sections */
.hm-sec { padding: clamp(64px, 8vw, 104px) 0; position: relative; overflow: hidden; }
.hm-sec-alt { background: var(--alt); }
.hm-sec-tight { padding: 0 0 clamp(64px, 8vw, 104px); }
.hm-card { background: var(--surface); border-radius: var(--r-md); box-shadow: 0 1px 2px rgba(27, 22, 32, .05), 0 18px 40px -24px rgba(27, 22, 32, .16); }

/* ghost wordmark */
.hm-ghost { position: absolute; font-weight: 700; color: var(--ac-soft); pointer-events: none; z-index: 0; user-select: none; white-space: nowrap; }
.hm-ghost-hero { top: -.18em; left: 50%; transform: translateX(-50%); font-size: clamp(140px, 22vw, 240px); opacity: .55; }
.hm-ghost-ploy { top: -.2em; left: -.1em; font-size: clamp(110px, 15vw, 200px); color: #EDE7F4; }
.hm-ghost-quote { top: -.05em; left: 50%; transform: translateX(-50%); font-size: clamp(200px, 30vw, 340px); color: rgba(27, 22, 32, .06); line-height: 1; }
.hm-sparkle { position: absolute; color: var(--ac); }
.hm-sparkle .ic { width: 24px; height: 24px; }

/* hero */
.hm-hero { position: relative; overflow: hidden;
  background-image: radial-gradient(900px 460px at 80% 0%, var(--ac-soft), transparent 70%); }
.hm-hero-in { position: relative; z-index: 1; display: grid; grid-template-columns: 1.05fr .95fr; gap: 56px; align-items: center; padding: clamp(40px, 6vw, 72px) 0 clamp(56px, 7vw, 88px); }
.hm-hero-btns { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 32px; }
.hm-trust { display: flex; align-items: center; gap: clamp(18px, 3vw, 34px); flex-wrap: wrap; }
.hm-trust-item b { display: block; font-size: 22px; font-weight: 700; }
.hm-trust-item span { font-size: 13px; color: var(--soft); }
.hm-hero-right { position: relative; min-height: 560px; }
.hm-arch { border-radius: 210px 210px var(--r-md) var(--r-md); overflow: hidden; background: var(--alt); }
.hm-arch img { width: 100%; height: 100%; object-fit: cover; }
.hm-hero-photo { position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 400px; height: 560px; box-shadow: 0 40px 80px -30px rgba(27, 22, 32, .38); }
.hm-float-stat { position: absolute; left: 0; bottom: 60px; z-index: 2; display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: 16px; padding: 12px 16px; box-shadow: 0 20px 44px -20px rgba(27, 22, 32, .28); }
.hm-float-ic { width: 40px; height: 40px; border-radius: 12px; background: var(--ac-soft); color: var(--ac); display: grid; place-items: center; flex-shrink: 0; }
.hm-float-stat b { display: block; font-size: 15px; font-weight: 700; }
.hm-float-stat small { font-size: 12.5px; color: var(--soft); }
.hm-photo-accent { position: absolute; right: 0; bottom: 20px; width: 130px; height: 130px; border-radius: var(--pill); overflow: hidden; border: 5px solid var(--surface); box-shadow: 0 18px 36px -16px rgba(27, 22, 32, .3); z-index: 2; }
.hm-photo-accent img { width: 100%; height: 100%; object-fit: cover; }
.hm-sparkle-hero { top: 30px; right: 8px; }

/* courses */
.hm-course-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.hm-course { padding: 26px; display: flex; flex-direction: column; }
.hm-course-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.hm-course-ic { font-size: 30px; line-height: 1; }
.hm-course-name { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.hm-course-name b { font-size: 20px; font-weight: 700; }
.hm-course-name small { font-size: 13px; color: var(--soft); }
.hm-course-desc { font-size: 14px; line-height: 1.55; color: var(--soft); margin: 0 0 16px; flex: 1; }
.hm-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 16px; }
.hm-tag { font-size: 11.5px; font-weight: 500; color: var(--soft); background: #EFEBE3; border-radius: 8px; padding: 4px 10px; }
.hm-tag-ac { color: var(--ac); background: var(--ac-soft); font-weight: 600; }
.hm-link { background: none; border: 0; padding: 0; font-family: inherit; color: var(--ac); font-weight: 600; font-size: 13.5px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; }
.hm-link .ic { width: 15px; height: 15px; transition: transform .15s; }
.hm-link:hover .ic { transform: translateX(3px); }

/* benefits */
.hm-benefits { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px 40px; }
.hm-benefit { padding-top: 18px; }
.hm-benefit-rule { display: block; width: 40px; height: 2px; border-radius: 2px; background: var(--ac); margin-bottom: 18px; }
.hm-benefit-ic { color: var(--ink); }
.hm-benefit-ic .ic { width: 26px; height: 26px; }
.hm-benefit b { display: block; font-size: 18px; font-weight: 700; margin: 12px 0 6px; }
.hm-benefit p { font-size: 14.5px; line-height: 1.55; color: var(--soft); margin: 0; }

/* parallax band */
.hm-band { position: relative; margin-top: clamp(56px, 7vw, 88px); min-height: 380px; display: flex; align-items: center; background-image: var(--bandimg); background-size: cover; background-position: center; }
.hm-band-scrim { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(13, 10, 20, .8), rgba(13, 10, 20, .5)); }
.hm-band-scrim.is-dark { background: rgba(13, 10, 20, .66); }
.hm-band-in { position: relative; z-index: 1; padding: 56px 0; }
.hm-band-kicker { font-size: 13px; font-weight: 600; color: rgba(255, 255, 255, .72); margin-bottom: 12px; }
.hm-band-quote { font-size: clamp(22px, 3vw, 30px); font-weight: 600; color: #fff; max-width: 18em; line-height: 1.35; margin: 0; }

/* about */
.hm-about { display: grid; grid-template-columns: 460px 1fr; gap: 64px; align-items: center; margin-top: clamp(56px, 7vw, 96px); }
.hm-about-portrait { position: relative; }
.hm-about-photo { position: relative; z-index: 1; width: 400px; max-width: 100%; height: 500px; margin: 0 auto; box-shadow: 0 40px 80px -34px rgba(27, 22, 32, .4); }
.hm-caption-card { position: absolute; right: 0; bottom: 30px; z-index: 2; display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: 16px; padding: 14px 18px; box-shadow: 0 20px 44px -20px rgba(27, 22, 32, .28); }
.hm-caption-rule { width: 26px; height: 3px; border-radius: 2px; background: var(--ac); flex-shrink: 0; }
.hm-caption-card b { display: block; font-size: 16px; font-weight: 700; }
.hm-caption-card small { font-size: 12.5px; color: var(--soft); }
.hm-para { font-size: 16px; line-height: 1.7; color: var(--soft); margin: 0 0 22px; }
.hm-creds { list-style: none; margin: 0 0 24px; padding: 0; display: grid; gap: 12px; }
.hm-creds li { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 500; }
.hm-cred-ic { color: var(--ac); flex-shrink: 0; display: inline-grid; }
.hm-cred-ic .ic { width: 18px; height: 18px; }
.hm-quote { position: relative; margin: 0; padding-left: 20px; border-left: 3px solid var(--ac); font-size: 16.5px; font-weight: 500; line-height: 1.55; }
.hm-quote cite { display: block; margin-top: 8px; font-size: 14px; font-weight: 600; font-style: normal; color: var(--soft); }

/* teachers */
.hm-teachers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 22px; }
.hm-teacher { overflow: hidden; }
.hm-teacher-photo { aspect-ratio: 3 / 3.1; background: var(--alt); }
.hm-teacher-photo img { width: 100%; height: 100%; object-fit: cover; }
.hm-teacher-info { padding: 18px; }
.hm-teacher-info b { font-size: 17px; font-weight: 700; }
.hm-teacher-inst { display: block; font-size: 13px; font-weight: 600; color: var(--ac); margin: 3px 0 8px; }
.hm-teacher-info p { font-size: 13px; line-height: 1.5; color: var(--soft); margin: 0; }

/* gallery */
.hm-head-gallery { margin-top: clamp(64px, 8vw, 100px); }
.hm-gallery { position: relative; display: grid; grid-template-columns: 356px 1fr 1fr; grid-template-rows: auto auto; gap: 22px; align-items: start; }
.hm-g-arch { grid-row: span 2; height: 496px; position: relative; box-shadow: 0 30px 60px -30px rgba(27, 22, 32, .34); }
.hm-g-caption { position: absolute; left: 16px; bottom: 16px; display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border-radius: var(--pill); padding: 7px 14px; font-size: 12.5px; font-weight: 600; box-shadow: 0 10px 24px -12px rgba(27, 22, 32, .3); }
.hm-g-caption .ic { width: 15px; height: 15px; color: var(--ac); }
.hm-g-circle { grid-column: 2 / 4; height: 292px; border-radius: var(--r-md); overflow: hidden; }
.hm-g-crop { height: 236px; border-radius: var(--r-md); overflow: hidden; }
.hm-gallery img { width: 100%; height: 100%; object-fit: cover; }
.hm-sparkle-g { top: -14px; right: -6px; }
.hm-sparkle-g .ic { width: 30px; height: 30px; }

/* pricing */
.hm-plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; align-items: start; }
.hm-plan { padding: 30px; }
.hm-plan.is-hot { box-shadow: 0 0 0 2px var(--ac), 0 30px 60px -28px rgba(94, 46, 158, .5); transform: translateY(-8px); }
.hm-plan-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.hm-plan-name { font-size: 19px; font-weight: 700; }
.hm-plan-head small { display: block; font-size: 13px; color: var(--soft); margin-top: 3px; }
.hm-plan-price { display: flex; align-items: baseline; gap: 8px; margin-bottom: 18px; }
.hm-plan-price b { font-size: 42px; font-weight: 700; letter-spacing: -.02em; }
.hm-plan-price span { font-size: 14px; color: var(--soft); }
.hm-plan-div { height: 1px; background: var(--line); margin-bottom: 18px; }
.hm-plan-feats { list-style: none; margin: 0 0 24px; padding: 0; display: grid; gap: 12px; }
.hm-plan-feats li { display: flex; align-items: flex-start; gap: 10px; font-size: 14.5px; line-height: 1.4; }

/* stats band */
.hm-band-stats { margin-top: clamp(56px, 7vw, 88px); min-height: 340px; }
.hm-band-stats-in { width: 100%; text-align: center; }
.hm-band-stats-in .hm-band-kicker { text-align: center; }
.hm-statsrow { display: flex; align-items: center; justify-content: center; gap: clamp(24px, 5vw, 64px); flex-wrap: wrap; }
.hm-statsrow-item b { display: block; font-size: clamp(38px, 5vw, 52px); font-weight: 700; color: #fff; }
.hm-star { color: #FFC93C; }
.hm-statsrow-item span { font-size: 15px; color: rgba(255, 255, 255, .8); }

/* testimonials */
.hm-reviews { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; position: relative; z-index: 1; }
.hm-review { padding: 26px; }
.hm-stars { display: flex; gap: 3px; color: var(--ac); margin-bottom: 14px; }
.hm-stars .ic { width: 16px; height: 16px; }
.hm-review-q { font-size: 15px; line-height: 1.6; margin: 0 0 20px; }
.hm-review-who { display: flex; align-items: center; gap: 12px; }
.hm-avatar { width: 44px; height: 44px; border-radius: var(--pill); object-fit: cover; background: var(--ac-soft); }
.hm-review-who b { display: block; font-size: 14.5px; font-weight: 600; }
.hm-review-who small { font-size: 12.5px; color: var(--soft); }

/* cta band */
.hm-cta-band { position: relative; overflow: hidden; border-radius: var(--r-lg); background-image: var(--bandimg); background-size: cover; background-position: center; padding: clamp(48px, 6vw, 80px) clamp(24px, 4vw, 64px); }
.hm-cta-in { position: relative; z-index: 2; max-width: 720px; }
.hm-cta-h { font-size: clamp(28px, 3.6vw, 40px); line-height: 1.2; font-weight: 700; color: #fff; margin: 0 0 16px; }
.hm-cta-sub { font-size: 16.5px; line-height: 1.6; color: rgba(255, 255, 255, .82); max-width: 40em; margin: 0 0 28px; }
.hm-cta-btns { margin-bottom: 0; }
.hm-ghost-cta { top: -.1em; right: -.02em; left: auto; font-size: clamp(120px, 17vw, 190px); color: rgba(255, 255, 255, .08); }

/* contact */
.hm-contact { display: grid; grid-template-columns: 440px 1fr; gap: 28px; align-items: stretch; }
.hm-contact-card { background: var(--surface); border-radius: var(--r-lg); border: 1px solid var(--line); padding: 28px; display: flex; flex-direction: column; gap: 20px; box-shadow: 0 24px 50px -30px rgba(27, 22, 32, .2); }
.hm-info { display: flex; align-items: flex-start; gap: 14px; }
.hm-info-chip { width: 42px; height: 42px; border-radius: 12px; background: var(--ac-soft); color: var(--ac); display: grid; place-items: center; flex-shrink: 0; }
.hm-info-chip .ic { width: 20px; height: 20px; }
.hm-info-t small { display: block; font-size: 12.5px; font-weight: 600; color: var(--soft); margin-bottom: 3px; }
.hm-info-t b { font-size: 14.5px; font-weight: 500; white-space: pre-line; line-height: 1.45; }
.hm-contact-social { display: flex; flex-wrap: wrap; gap: 10px; margin-top: auto; padding-top: 4px; }
.hm-social-pill { display: inline-flex; align-items: center; gap: 8px; background: var(--alt); border-radius: 10px; padding: 9px 14px; font-size: 12.5px; font-weight: 500; color: var(--ink); text-decoration: none; }
.hm-social-pill .ic { width: 16px; height: 16px; }
.hm-social-pill:hover { color: var(--ac); }
.hm-map { position: relative; border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--line); min-height: 420px; }
.hm-map-frame { width: 100%; height: 100%; min-height: 420px; border: 0; display: block; filter: grayscale(.15); }
.hm-map-btn { position: absolute; left: 16px; bottom: 16px; display: inline-flex; align-items: center; gap: 7px; background: var(--surface); border-radius: var(--pill); padding: 9px 16px; font-size: 13px; font-weight: 600; color: var(--ink); text-decoration: none; box-shadow: 0 10px 24px -12px rgba(27, 22, 32, .3); }
.hm-map-btn .ic { width: 16px; height: 16px; color: var(--ac); }

/* footer */
.hm-footer { background: var(--alt); padding: clamp(48px, 6vw, 72px) 0 32px; }
.hm-footer-top { display: grid; grid-template-columns: 340px 1fr; gap: 48px; }
.hm-footer-brand p { font-size: 13.5px; line-height: 1.6; color: var(--soft); margin: 16px 0; max-width: 34em; }
.hm-footer-social { display: flex; gap: 10px; }
.hm-footer-social a { width: 38px; height: 38px; border-radius: var(--pill); background: var(--bg); display: grid; place-items: center; color: var(--ink); }
.hm-footer-social a:hover { color: var(--ac); }
.hm-footer-social .ic { width: 17px; height: 17px; }
.hm-footer-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px; }
.hm-footer-col { display: flex; flex-direction: column; gap: 9px; }
.hm-footer-col b { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.hm-footer-col a, .hm-footer-col span { font-size: 13.5px; color: var(--soft); text-decoration: none; }
.hm-footer-col a:hover { color: var(--ac); }
.hm-footer-div { height: 1px; background: var(--line); margin: 36px 0 20px; }
.hm-footer-bottom { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--soft); }
.hm-footer-policy { display: flex; gap: 20px; }
.hm-linkbtn { background: none; border: 0; padding: 0; font-family: inherit; font-size: 12.5px; color: var(--soft); cursor: pointer; }
.hm-linkbtn:hover { color: var(--ac); }

/* responsive */
@media (max-width: 980px) {
  .hm-hero-in { grid-template-columns: 1fr; gap: 32px; }
  .hm-hero-right { min-height: 520px; }
  .hm-about { grid-template-columns: 1fr; gap: 40px; }
  .hm-about-portrait { max-width: 460px; margin: 0 auto; }
  .hm-contact, .hm-footer-top { grid-template-columns: 1fr; }
  .hm-course-grid, .hm-benefits, .hm-plans, .hm-reviews { grid-template-columns: repeat(2, 1fr); }
  .hm-teachers { grid-template-columns: repeat(2, 1fr); }
  .hm-gallery { grid-template-columns: 1fr 1fr; }
  .hm-g-arch { grid-row: auto; grid-column: span 2; height: 360px; }
  .hm-g-circle { grid-column: span 2; }
  .hm-plan.is-hot { transform: none; }
}
/* แท็บเล็ต/มือถือ: สลับเมนูเป็นแฮมเบอร์เกอร์ + ดรอปดาวน์ */
@media (max-width: 760px) {
  .hm-nav-login { display: none !important; }
  .hm-burger { display: inline-flex !important; }
  .hm-links {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: rgba(255, 255, 255, .98); backdrop-filter: saturate(1.4) blur(12px);
    border-bottom: 1px solid var(--line); box-shadow: 0 22px 44px -26px rgba(27, 22, 32, .45);
    padding: 6px 0 16px;
    max-height: 0; overflow: hidden; opacity: 0; visibility: hidden;
    transition: max-height .3s ease, opacity .2s ease, visibility .3s;
  }
  .hm-links.is-open { max-height: 440px; opacity: 1; visibility: visible; }
  .hm-links a { padding: 13px clamp(20px, 5vw, 48px); font-size: 15.5px; border-bottom: 1px solid var(--line); }
  .hm-links a:last-of-type { border-bottom: 0; }
  .hm-links-login { display: inline-flex !important; margin: 14px clamp(20px, 5vw, 48px) 0; }
}
@media (max-width: 640px) {
  .hm-course-grid, .hm-benefits, .hm-plans, .hm-reviews, .hm-teachers, .hm-gallery { grid-template-columns: 1fr; }
  .hm-g-arch, .hm-g-circle { grid-column: auto; }
  .hm-hero-photo { width: 88%; height: 460px; }
  .hm-trust { gap: 20px; }
  .hm-footer-cols { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 460px) {
  .hm-sec { padding: 56px 0; }
  .hm-hero-right { min-height: 452px; }
  .hm-hero-photo { width: 92%; height: 400px; }
  .hm-float-stat { bottom: 40px; padding: 10px 13px; }
  .hm-float-stat b { font-size: 14px; }
  .hm-photo-accent { width: 104px; height: 104px; }
  .hm-plan-price b { font-size: 38px; }
  .hm-footer-cols { grid-template-columns: 1fr; }
  .hm-footer-bottom { flex-direction: column; align-items: flex-start; gap: 10px; }
}
/* reveal-on-scroll (เปิดใช้เมื่อ JS พร้อม → .hm-anim · ไม่มี JS เนื้อหายังเห็นปกติ) */
.hm-anim .hm-rev { opacity: 0; transform: translateY(26px); transition: opacity .6s ease, transform .6s cubic-bezier(.2, .7, .2, 1); will-change: opacity, transform; }
.hm-anim .hm-rev.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .hm-btn, .hm-link .ic { transition: none !important; }
  .hm-anim .hm-rev { opacity: 1 !important; transform: none !important; transition: none !important; }
}

/* ===== หน้าตั้งค่า — แผงเดียว แถวสองคอลัมน์ (หัวข้อซ้าย / ฟอร์มขวา) ให้ดูเป็นระบบ ===== */
.set { max-width: 900px; margin: 0 auto; }
.set-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-sm); overflow: hidden; }
.set-row { display: grid; grid-template-columns: 240px 1fr; gap: 40px; padding: 26px 28px; }
.set-row + .set-row { border-top: 1px solid var(--border); }
.set-row-h h3 { font-size: 15px; font-weight: 700; margin: 0 0 5px; }
.set-row-h p { margin: 0; line-height: 1.5; }
.set-row-b { min-width: 0; max-width: 480px; }
.set-row-b .field { margin-bottom: 14px; }
.set-row-b .field:last-child { margin-bottom: 0; }
.set-row-b .pay-qr { margin: 4px 0 0; }
.set-actions { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; }
.set-id { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.set-id-av { width: 46px; height: 46px; font-size: 18px; font-weight: 700; }
.set-id-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.set-id-txt b { font-size: 15px; font-weight: 700; word-break: break-all; }
.set-defs { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.set-def { display: flex; flex-direction: column; gap: 3px; }
.set-def b { font-size: 14px; font-weight: 600; }
.set-def-wide { grid-column: 1 / -1; }
@media (max-width: 720px) {
  .set-row { grid-template-columns: 1fr; gap: 14px; padding: 22px 18px; }
  .set-row-b { max-width: none; }
  .set-defs { grid-template-columns: 1fr; }
}

/* ===== ใบเสร็จรับเงิน (พิมพ์ได้) ===== */
.rcpt-doc { background: #fff; color: #1b1620; max-width: 640px; margin: 0 auto; }
.rcpt-head { display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: 14px; border-bottom: 2px solid #1b1620; padding-bottom: 14px; }
.rcpt-logo { width: 58px; height: 58px; object-fit: contain; }
.rcpt-org { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: #666; }
.rcpt-org b { font-size: 16px; color: #1b1620; }
.rcpt-title { text-align: right; font-size: 20px; font-weight: 700; line-height: 1.1; white-space: nowrap; }
.rcpt-title span { display: block; font-size: 10.5px; font-weight: 600; letter-spacing: .18em; color: #999; }
.rcpt-meta { display: flex; justify-content: space-between; gap: 16px; margin: 14px 0; font-size: 13.5px; }
.rcpt-meta span { color: #777; margin-right: 8px; }
.rcpt-party { margin: 14px 0; font-size: 14px; }
.rcpt-party span { display: block; color: #777; font-size: 12px; margin-bottom: 3px; }
.rcpt-party b { display: block; font-size: 22px; font-weight: 800; color: #111; line-height: 1.25; }  /* ชื่อผู้จ่าย = เด่นสุด */
.rcpt-party small { display: block; color: #2a2a2a; font-weight: 600; font-size: 14px; margin-top: 5px; }
/* ใบวางบิล — เน้นชื่อนักเรียน (ใหญ่/เข้ม/ชื่อเล่น) · ชื่อผู้ปกครองจาง */
.rcpt-party.for-bill small { color: #9a9a9a; font-weight: 400; }
.rcpt-table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 14px; }
.rcpt-table th { text-align: left; background: #f3f0f8; padding: 9px 12px; font-size: 12.5px; color: #555; border-bottom: 1px solid #ddd; }
.rcpt-table th.num, .rcpt-table td.num { text-align: right; white-space: nowrap; }
.rcpt-table td { padding: 12px; border-bottom: 1px solid #eee; vertical-align: top; }
.rcpt-table tfoot td { font-weight: 700; border-top: 2px solid #1b1620; border-bottom: 0; font-size: 15px; }
.rcpt-inwords { display: block; font-weight: 400; font-size: 12px; color: #777; margin-top: 3px; }
.rcpt-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-top: 26px; }
.rcpt-method { font-size: 13.5px; }
.rcpt-sign { text-align: center; font-size: 12.5px; color: #555; }
.rcpt-sign-line { width: 190px; border-bottom: 1px dotted #999; margin-bottom: 6px; height: 34px; }
.rcpt-note { text-align: center; font-size: 11px; color: #b3b3b3; margin-top: 22px; }

/* โหมด 2 ฉบับ (ต้นฉบับ + สำเนา) บน A4 แผ่นเดียว */
.rcpt-copytag { display: inline-block; border: 1px solid #5e2e9e; background: #f1eaf9; color: #5e2e9e; font-size: 11px; font-weight: 700; padding: 3px 12px; border-radius: 999px; margin-bottom: 10px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.rcpt-cut { text-align: center; color: #bbb; font-size: 11px; letter-spacing: .1em; margin: 18px 0; }
.rcpt-dup .rcpt-copy { max-width: 640px; margin: 0 auto; }
.rcpt-hint { flex: 1; font-size: 12px; color: var(--muted); min-width: 0; }
/* ปุ่มพิมพ์ใบเสร็จ/ใบวางบิล — สีเข้มขึ้น ให้เด่นเป็นปุ่มหลัก */
button.btn-print { background: #3a1d6b !important; color: #fff !important; font-weight: 700; }
button.btn-print:hover { background: #2c1552 !important; }

/* หน้าชำระเงิน — แยก "บิลรวม" / "บิลเดี่ยว" ให้บัญชีอ่านง่าย */
tr.row-bundle td { background: var(--brand-weak); }
tr.row-bundle td:first-child { border-left: 3px solid var(--brand); }
.badge.badge-bundle { background: var(--brand); color: var(--brand-fg); font-weight: 700; }
.badge.badge-single { background: transparent; color: var(--muted); border: 1px solid var(--border); font-weight: 500; }
@media (max-width: 560px) { tr.row-bundle td:first-child { border-left: 3px solid var(--brand); } }

/* ตารางแบบ "ออเดอร์" — คลิกทั้งแถวเพื่อดูรายละเอียด */
tr.row-click { cursor: pointer; transition: background .12s; }
tr.row-click:hover td { background: var(--surface-2); }
tr.row-bundle.row-click:hover td { background: var(--brand-weak); filter: brightness(.98); }
.ord-cell { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ord-cell-name { font-weight: 600; }
.ord-amt { font-weight: 700; font-size: 15px; }
.ord-chevron { color: var(--muted); font-size: 22px; line-height: 1; font-weight: 700; }
tr.row-click:hover .ord-chevron { color: var(--brand); }

/* กล่องรายละเอียดออเดอร์ */
.ord-h-title b { font-weight: 800; }
.ord-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.ord-stu { font-size: 18px; font-weight: 800; color: var(--text); }
.ord-guardian { font-size: 13px; color: var(--muted); margin-top: 2px; }
.ord-meta { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.ord-date { font-size: 13px; color: var(--muted); }
.ord-lines { margin: 14px 0; }
.ord-empty { padding: 24px; text-align: center; color: var(--muted); }
.ord-table { width: 100%; border-collapse: collapse; }
.ord-table th { text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 6px 10px; border-bottom: 1px solid var(--border); }
.ord-table th.num, .ord-table td.num { text-align: right; }
.ord-table td { padding: 10px; border-bottom: 1px solid var(--border-weak, var(--border)); }
.ord-table tfoot td { border-bottom: none; border-top: 2px solid var(--border); font-weight: 700; padding-top: 12px; }
.ord-cnt { font-weight: 500; color: var(--muted); font-size: 12.5px; }
.ord-total { font-size: 17px; color: var(--brand-strong); }
.ord-info { display: flex; gap: 28px; padding: 12px 10px; background: var(--surface-2); border-radius: var(--radius, 10px); }
.ord-info > div { display: flex; flex-direction: column; gap: 2px; }
.ord-info span { font-size: 12px; color: var(--muted); }
.ord-info b { font-size: 14px; color: var(--text); }
.ord-foot { flex-wrap: wrap; }
.ord-lines-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.ord-lines-head > span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.ord-price-input { width: 110px; text-align: right; padding: 5px 8px; }
.ord-edit-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px; padding: 10px 12px; background: var(--amber-weak); border-radius: var(--radius, 10px); }
.ord-edit-hint { font-size: 12.5px; color: var(--amber); font-weight: 600; }
.ord-edit-btns { display: flex; gap: 8px; }

/* โปรไฟล์ครู */
.tp-card { background: var(--surface-2); border-radius: var(--radius, 12px); padding: 16px; margin: 12px 0 4px; }
.tp-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.tp-name { font-size: 18px; font-weight: 800; color: var(--text); }
.tp-sub { font-size: 13px; color: var(--muted); margin-top: 3px; }
.tp-notes { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 13.5px; color: var(--text); white-space: pre-wrap; }
.tp-sec { margin: 22px 0 8px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.tp-count { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 7px; border-radius: var(--pill); background: var(--brand-weak); color: var(--brand-strong); font-size: 12.5px; font-weight: 700; }

/* แบนเนอร์เตือน "คาบค้างชดเชย" บนหน้าตารางเรียน — เห็นชัด กดแล้วเปิดตัวจัดวัน */
.makeup-banner { display: flex !important; align-items: center; gap: 10px; width: 100%; margin-bottom: 14px; text-align: left;
  background: rgba(240, 170, 60, 0.14) !important; color: var(--text) !important; font-weight: 600;
  border: 1px solid rgba(220, 150, 40, 0.55); border-radius: 12px; padding: 12px 16px !important; cursor: pointer; }
.makeup-banner:hover { background: rgba(240, 170, 60, 0.24) !important; }
.makeup-banner b { font-weight: 800; }
.makeup-banner svg { flex: none; }
.makeup-banner .makeup-banner-cta { margin-left: auto; display: inline-flex; align-items: center; gap: 2px; color: var(--brand); font-weight: 700; white-space: nowrap; }
/* ใบวางบิล — ช่องทางชำระ + QR พร้อมเพย์ */
.rcpt-pay { display: flex; gap: 16px; align-items: center; margin-top: 18px; padding-top: 14px; border-top: 1px dashed #ddd; }
.rcpt-qr { text-align: center; flex: none; }
.rcpt-qr img { display: block; }
.rcpt-qr-cap { font-size: 11px; color: #666; margin-top: 5px; line-height: 1.5; }
.rcpt-qr-head { font-weight: 600; color: #333; }
.rcpt-qr-acct { color: #111; }
.rcpt-qr-acct b { font-size: 13px; font-weight: 800; }
.rcpt-qr-num { color: #444; }
.rcpt-payinfo { font-size: 12.5px; color: #555; }
.rcpt-payline b { color: #1b1620; }
.rcpt-paynote { margin-top: 6px; color: #777; }
.rcpt-dup .rcpt-pay { margin-top: 12px; padding-top: 10px; }
.rcpt-dup .rcpt-qr img { width: 84px !important; height: 84px !important; }
/* ใบวางบิล — ประวัติการเข้าเรียนรอบก่อน + วันเริ่มรอบใหม่ */
.rcpt-att { margin: 12px 0; }
.rcpt-att-h { font-size: 12px; color: #5e2e9e; font-weight: 700; margin-bottom: 6px; }
.rcpt-att-tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.rcpt-att-tbl th { text-align: left; color: #888; font-weight: 600; padding: 4px 8px; border-bottom: 1px solid #eee; }
.rcpt-att-tbl td { padding: 4px 8px; border-bottom: 1px solid #f2f2f2; color: #444; }
.rcpt-att-tbl th:first-child, .rcpt-att-tbl td:first-child { width: 26px; color: #aaa; }
.rcpt-next { margin: 12px 0; font-size: 13.5px; background: #f1eaf9; border-radius: 10px; padding: 10px 14px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.rcpt-next span { color: #777; font-size: 12px; }
/* พรีวิวบนจอ + ประหยัดพื้นที่ให้ครบ 2 ฉบับ */
.rcpt-dup .rcpt-head { padding-bottom: 10px; }
.rcpt-dup .rcpt-logo { width: 46px; height: 46px; }
.rcpt-dup .rcpt-title { font-size: 17px; }
.rcpt-dup .rcpt-meta { margin: 10px 0; }
.rcpt-dup .rcpt-foot { margin-top: 16px; }
.rcpt-dup .rcpt-sign-line { height: 26px; }
.rcpt-dup .rcpt-note { margin-top: 12px; }

/* ── รายงานสรุปสถิติ (หน้า Reports + พรีวิวพิมพ์ A4) ── */
.report-controls { display: flex; justify-content: space-between; align-items: center; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 18px; }
.report-period { display: flex; gap: 28px; margin: 2px 0 18px; font-size: 13.5px; }
.report-period span { color: var(--muted); margin-right: 8px; }
.report-period b { color: var(--text); }
.report-sec { margin-top: 26px; }
.report-sec > h3 { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; color: var(--text); margin: 0 0 10px; }
.report-sec > h3 .ic { color: var(--brand); flex: none; }
.report-hint { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.report-note { margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.report-empty { padding: 18px 0; text-align: center; font-size: 13px; }
.report-total { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; padding: 12px 14px; background: var(--brand-weak); border-radius: var(--r-ctl); font-weight: 700; color: var(--text); }
.report-total b { font-size: 17px; color: var(--brand-strong); }
.report-charts .dash-charts-grid { margin-top: 0; }

/* หัวจดหมาย + ท้ายเอกสาร (เฉพาะพรีวิวพิมพ์) */
.report-head { display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: 14px; border-bottom: 2px solid #1b1620; padding-bottom: 14px; margin-bottom: 8px; }
.report-logo { width: 56px; height: 56px; object-fit: contain; }
.report-org { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: #666; }
.report-org b { font-size: 16px; color: #1b1620; }
.report-title { text-align: right; font-size: 19px; font-weight: 700; line-height: 1.1; white-space: nowrap; }
.report-title span { display: block; font-size: 10px; font-weight: 600; letter-spacing: .16em; color: #999; }
.report-foot { text-align: center; font-size: 11px; color: #b3b3b3; margin-top: 24px; }

/* พรีวิวพิมพ์ = เอกสารสีอ่อนเสมอ (override token ให้เป็นธีมสว่าง แม้แอปอยู่โหมดมืด) */
.report-print {
  --text: #1b1620; --muted: #6b6f77; --faint: #9aa0a8;
  --border: #e5e7ec; --border-strong: #d7dae0; --surface: #fff; --surface-2: #f6f4fb;
  --brand: #6d5efc; --brand-strong: #5b4bf0; --brand-weak: #efeafc;
  --green: #0f9d5c; --red: #dc4a4a; --amber: #bd7d15; --amber-weak: #fbf1dc;
  background: #fff; color: #1b1620; max-width: 720px; margin: 0 auto;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}

@media print {
  .no-print { display: none !important; }
  body > *:not(.modal-ov) { display: none !important; }
  .modal-ov { position: static !important; background: none !important; padding: 0 !important; display: block !important; }
  .modal-ov.closing { display: none !important; }
  .modal { box-shadow: none !important; border: 0 !important; max-width: none !important; width: auto !important; max-height: none !important; overflow: visible !important; border-radius: 0 !important; }
  .modal-head, .modal-foot { display: none !important; }
  .modal-body { padding: 0 !important; max-height: none !important; overflow: visible !important; }
  .rcpt-doc { max-width: none; }
  .rcpt-table th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  @page { size: A4; margin: 14mm; }
  /* 2 ฉบับ: แต่ละฉบับสูง ~ครึ่งหน้า + ห้ามฉีกกลางฉบับ → ลง A4 แผ่นเดียว */
  .rcpt-dup .rcpt-copy { min-height: 122mm; break-inside: avoid; page-break-inside: avoid; }
  .rcpt-dup .rcpt-cut { break-inside: avoid; margin: 4mm 0; }
}
