/* ==========================================================================
   SchoolPro — Design System 3.0 "Prestige"
   ภาษาการออกแบบ: สถาบันการศึกษาระดับพรีเมียม
   - Typography: Anuphan (UI) · Trirong (display serif ฝั่งเว็บไซต์)
   - Surface: กระดาษนวล + การ์ดขาว + เส้น hairline (ไม่พึ่งเงาหนา/gradient ฉูดฉาด)
   - Accent: สีแบรนด์ (ปรับได้ตามธีม) + ทองสถาบัน (--gold) สำหรับรายละเอียดพรีเมียม
   - คงชื่อคลาสเดิมทั้งหมดของระบบ
   ========================================================================== */

:root {
  /* แบรนด์ (ถูก override ด้วยธีมที่แอดมินเลือก) */
  --brand: #1D4E89;
  --brand-2: #3E77B6;
  --brand-3: #7FA8D9;
  --brand-dark: #163C6B;
  --brand-darker: #0E2A4C;
  --brand-light: #EBF1F8;
  --brand-tint: #F6F9FC;
  --brand-rgb: 29, 78, 137;

  /* ทองสถาบัน — คงที่ทุกธีม ใช้เป็นรายละเอียดพรีเมียม */
  --gold: #B08C46;
  --gold-deep: #8F6F33;
  --gold-soft: #E8DDC4;
  --gold-tint: #FAF6EC;

  /* พื้นผิว */
  --bg: #F4F5F7;
  --bg-2: #FAFAFB;
  --card: #FFFFFF;
  --line: #E4E7EC;
  --line-soft: #EEF0F4;
  --line-strong: #D5DAE1;

  /* หมึก */
  --ink: #1A2332;
  --ink-soft: #5C6778;
  --ink-faint: #9AA3B2;

  /* สีความหมาย (โทนขรึม ไม่แสบตา) */
  --green: #217A4B; --green-bg: #EAF4EE; --green-ink: #1B5E3B;
  --red: #B3413A;   --red-bg: #F9ECEB;   --red-ink: #8F332E;
  --yellow: #9A6B15; --yellow-bg: #F9F1E0; --yellow-ink: #7A5510;
  --blue: #2A5DA8;  --blue-bg: #EBF1F9;  --blue-ink: #1F4A88;
  --purple: #6B4FA1; --purple-bg: #F1EDF8; --purple-ink: #543E82;
  --gray: #66707E;  --gray-bg: #F1F3F5;  --gray-ink: #454E5B;

  /* Sidebar — หมึกน้ำเงินเกือบดำ */
  --sidebar-bg: #0D1524;
  --sidebar-bg2: #111B2E;
  --sidebar-line: rgba(255, 255, 255, .06);
  --sidebar-text: #9AA7BA;
  --sidebar-text-dim: #5E6B80;

  /* aliases เข้ากันย้อนหลังกับโมดูลเดิม */
  --danger: var(--red);
  --success: var(--green);
  --shadow-brand: 0 1px 3px rgba(var(--brand-rgb), .25);

  --radius: 12px;
  --radius-sm: 9px;
  --radius-lg: 16px;

  /* เงา: แผ่วมาก — ความพรีเมียมมาจากเส้นและระยะ ไม่ใช่เงา */
  --shadow-xs: 0 1px 2px rgba(23, 30, 43, .04);
  --shadow: 0 1px 2px rgba(23, 30, 43, .05), 0 4px 12px -6px rgba(23, 30, 43, .06);
  --shadow-md: 0 2px 6px rgba(23, 30, 43, .06), 0 12px 28px -12px rgba(23, 30, 43, .12);
  --shadow-lg: 0 8px 20px -8px rgba(23, 30, 43, .14), 0 24px 56px -20px rgba(23, 30, 43, .18);
  --shadow-pop: 0 12px 36px -10px rgba(13, 21, 36, .28);

  --font: 'Anuphan', 'Sarabun', 'Noto Sans Thai', system-ui, -apple-system, sans-serif;
  --font-head: 'Anuphan', 'Sarabun', system-ui, sans-serif;
  --font-display: 'Trirong', 'Anuphan', Georgia, serif;

  --ease: cubic-bezier(.25, .6, .3, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  --header-h: 76px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font); font-size: 15px; color: var(--ink);
  background: var(--bg); line-height: 1.65;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  font-feature-settings: 'tnum' 0;
}
img { max-width: 100%; }
a { color: var(--brand); text-decoration: none; transition: color .15s var(--ease); }
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 600; line-height: 1.3; letter-spacing: -.008em; color: var(--ink); }
::selection { background: rgba(var(--brand-rgb), .16); }
:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; border-radius: 4px; }

* { scrollbar-width: thin; scrollbar-color: #C9CFD8 transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: #C9CFD8; border-radius: 99px; }
*::-webkit-scrollbar-thumb:hover { background: #AEB6C2; }

.icon { vertical-align: -3px; flex: none; }
.inline { display: inline; }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }

/* ============ Motion — สงบ แม่นยำ ============ */

@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes kenburns { from { transform: scale(1.04); } to { transform: scale(1.11); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes ripple { to { transform: scale(3); opacity: 0; } }
@keyframes pulseSoft { 0%,100% { opacity: 1; } 50% { opacity: .5; } }
@keyframes shimmer { 100% { transform: translateX(100%); } }

html.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity .55s var(--ease-out), transform .55s var(--ease-out); }
html.js .reveal.in, html.reveal-all .reveal { opacity: 1; transform: none; }
html.js .reveal.rv-scale { transform: scale(.97); }
html.js .reveal.rv-left { transform: translateX(-16px); }
html.js .reveal.rv-right { transform: translateX(16px); }
.stagger > * { transition-delay: calc(var(--i, 0) * 55ms); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  html.js .reveal { opacity: 1 !important; transform: none !important; }
}

/* ============ โครงหลังบ้าน ============ */

.app-wrap { display: flex; min-height: 100vh; }

.sidebar {
  width: 262px; flex: none; color: var(--sidebar-text);
  position: sticky; top: 0; height: 100vh; overflow-y: auto; overflow-x: hidden; z-index: 60;
  background: linear-gradient(180deg, var(--sidebar-bg2) 0%, var(--sidebar-bg) 100%);
  border-right: 1px solid rgba(255, 255, 255, .04);
}
.sb-brand {
  display: flex; gap: 12px; align-items: center; padding: 20px 18px 18px;
  border-bottom: 1px solid var(--sidebar-line);
  position: sticky; top: 0; background: var(--sidebar-bg2); z-index: 2;
}
.sb-brand img { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; background: #fff; }
.sb-logo-ph {
  width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .07); color: var(--gold-soft); border: 1px solid rgba(255, 255, 255, .1);
}
.sb-brand-name strong { display: block; color: #F3F5F8; font-family: var(--font-head); font-weight: 600; font-size: 14.5px; line-height: 1.3; letter-spacing: .01em; }
.sb-brand-name span { font-size: 11px; color: var(--sidebar-text-dim); letter-spacing: .02em; }
.sb-nav { flex: 1; padding: 10px 12px 26px; }
.sb-group {
  font-size: 10px; text-transform: uppercase; letter-spacing: .14em; font-weight: 600;
  color: var(--sidebar-text-dim); padding: 18px 10px 7px;
}
.sb-item {
  display: flex; align-items: center; gap: 11px; color: var(--sidebar-text);
  padding: 8px 10px; border-radius: 8px; font-size: 13.5px; margin-bottom: 1px;
  position: relative; transition: background .16s var(--ease), color .16s var(--ease);
}
.sb-item .icon { opacity: .75; transition: opacity .16s; }
.sb-item:hover { background: rgba(255, 255, 255, .05); color: #E8ECF2; }
.sb-item:hover .icon { opacity: 1; }
.sb-item.active { background: rgba(255, 255, 255, .07); color: #FFFFFF; font-weight: 500; }
.sb-item.active .icon { opacity: 1; color: var(--gold-soft); }
.sb-item.active::before {
  content: ''; position: absolute; left: -12px; top: 7px; bottom: 7px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--gold);
}
.sb-item span { flex: 1; }
.sb-badge {
  background: var(--red); color: #fff; font-size: 10.5px; padding: 1px 7px;
  border-radius: 99px; font-weight: 600; letter-spacing: .02em;
}
.sb-foot {
  padding: 14px 18px; font-size: 11px; color: var(--sidebar-text-dim);
  border-top: 1px solid var(--sidebar-line); letter-spacing: .02em;
}
.lic-valid { color: #7FBF9B; } .lic-demo { color: var(--gold-soft); } .lic-expired, .lic-invalid { color: #D98880; }

.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  background: rgba(255, 255, 255, .92); backdrop-filter: saturate(160%) blur(10px); -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line); padding: 0 26px;
  display: flex; align-items: center; gap: 14px; height: 60px; position: sticky; top: 0; z-index: 50;
}
.tb-burger { display: none; background: none; border: 0; cursor: pointer; color: var(--ink); padding: 6px; border-radius: 8px; }
.tb-burger:hover { background: var(--gray-bg); }
.tb-title { font-family: var(--font-head); font-weight: 600; font-size: 16px; letter-spacing: -.005em; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-right { display: flex; align-items: center; gap: 2px; }
.tb-icon-btn { position: relative; background: none; border: 0; cursor: pointer; color: var(--ink-soft); padding: 9px; border-radius: 9px; transition: background .14s, color .14s; }
.tb-icon-btn:hover { background: var(--gray-bg); color: var(--ink); }
.tb-badge {
  position: absolute; top: 4px; right: 3px; background: var(--red); color: #fff;
  font-size: 9.5px; min-width: 15px; text-align: center; padding: 0 4px; border-radius: 99px;
  font-weight: 700; box-shadow: 0 0 0 2px #fff;
}
.tb-user {
  display: flex; align-items: center; gap: 10px; background: none; border: 0; cursor: pointer;
  padding: 5px 10px 5px 6px; border-radius: 10px; font-family: var(--font); transition: background .14s;
}
.tb-user:hover { background: var(--gray-bg); }
.tb-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.tb-avatar-ph {
  background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px;
}
.tb-uname { text-align: left; font-size: 13px; line-height: 1.3; color: var(--ink); font-weight: 500; }
.tb-uname small { display: block; color: var(--ink-faint); font-size: 11px; font-weight: 400; }

.dropdown { position: relative; }
.dd-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 8px); background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-pop);
  min-width: 236px; z-index: 70; overflow: hidden;
}
.dd-menu.open { display: block; animation: slideDown .18s var(--ease-out); }
.dd-notif { width: 344px; max-width: 92vw; }
.dd-head { padding: 11px 16px; font-weight: 600; font-size: 13px; border-bottom: 1px solid var(--line-soft); color: var(--ink); }
.dd-item { display: flex; gap: 11px; padding: 11px 16px; color: var(--ink); font-size: 13px; align-items: flex-start; transition: background .12s; }
.dd-item:hover { background: var(--bg-2); }
.dd-item.unread { background: var(--brand-tint); }
.dd-item .icon { margin-top: 2px; color: var(--brand); }
.dd-t { line-height: 1.45; }
.dd-d { font-size: 11px; color: var(--ink-faint); margin-top: 1px; }
.dd-empty { padding: 28px; text-align: center; color: var(--ink-faint); font-size: 13px; }
.dd-all { display: block; text-align: center; padding: 10px; font-size: 12.5px; border-top: 1px solid var(--line-soft); font-weight: 600; color: var(--brand); }
.dd-all:hover { background: var(--bg-2); }

.content { flex: 1; padding: 26px 28px 40px; max-width: 1440px; width: 100%; }
.app-foot { padding: 16px 28px; color: var(--ink-faint); font-size: 12px; border-top: 1px solid var(--line); letter-spacing: .01em; }

.license-bar { padding: 8px 20px; font-size: 13px; text-align: center; font-weight: 500; animation: slideDown .4s var(--ease-out); }
.lb-demo { background: var(--gold-tint); color: var(--gold-deep); border-bottom: 1px solid var(--gold-soft); }
.lb-warn { background: var(--yellow-bg); color: var(--yellow-ink); border-bottom: 1px solid #EBDBBB; }
.lb-error { background: var(--red-bg); color: var(--red-ink); border-bottom: 1px solid #EFD2D0; }

/* ============ ส่วนประกอบ ============ */

.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; animation: fadeUp .45s var(--ease-out); }
.page-head h1 { font-size: 21px; font-weight: 650; display: flex; align-items: center; gap: 10px; letter-spacing: -.012em; }
.page-head h1 .icon { color: var(--brand); opacity: .9; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.card {
  background: var(--card); border-radius: var(--radius); border: 1px solid var(--line);
  box-shadow: var(--shadow-xs); margin-bottom: 18px; transition: box-shadow .2s var(--ease);
}
.card-head { display: flex; align-items: center; gap: 10px; padding: 15px 20px 13px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.card-head h2 { font-size: 14.5px; font-weight: 600; letter-spacing: -.005em; display: flex; align-items: center; gap: 8px; }
.card-head h2 .icon { color: var(--ink-faint); }
.card-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card-body { padding: 20px; }
.card-body.p0 { padding: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat {
  background: var(--card); border-radius: var(--radius); border: 1px solid var(--line);
  box-shadow: var(--shadow-xs); padding: 18px 18px 16px; display: flex; gap: 14px; align-items: flex-start;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease), transform .2s var(--ease);
}
a.stat:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex: none; margin-top: 2px; }
.si-blue { background: var(--blue-bg); color: var(--blue); }
.si-green { background: var(--green-bg); color: var(--green); }
.si-red { background: var(--red-bg); color: var(--red); }
.si-yellow { background: var(--yellow-bg); color: var(--yellow); }
.si-purple { background: var(--purple-bg); color: var(--purple); }
.si-gray { background: var(--gray-bg); color: var(--gray); }
.stat-num {
  font-size: 25px; font-weight: 650; font-family: var(--font-head); line-height: 1.15;
  letter-spacing: -.02em; color: var(--ink); font-variant-numeric: tabular-nums;
}
.stat-label { font-size: 12px; color: var(--ink-soft); margin-top: 2px; letter-spacing: .01em; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; padding: 10px 16px; background: var(--bg-2); color: var(--ink-soft);
  font-weight: 600; font-size: 11.5px; letter-spacing: .05em; text-transform: none;
  border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; font-variant-numeric: tabular-nums; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--bg-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .empty { text-align: center; color: var(--ink-faint); padding: 44px 20px; font-size: 13.5px; }
.table input.input, .table select.input { padding: 6px 9px; font-size: 13px; margin-top: 0; }

.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 16px; border-radius: 9px;
  border: 1px solid var(--line-strong); background: var(--card); color: var(--ink);
  font-family: var(--font); font-size: 13.5px; font-weight: 500; letter-spacing: .005em;
  cursor: pointer; text-decoration: none; position: relative; overflow: hidden;
  transition: background .15s var(--ease), border-color .15s var(--ease), box-shadow .15s var(--ease), transform .1s var(--ease);
  box-shadow: var(--shadow-xs);
}
.btn:hover { background: var(--bg-2); border-color: #C4CBD5; }
.btn:active { transform: scale(.985); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(var(--brand-rgb), .3), inset 0 1px 0 rgba(255,255,255,.08); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: var(--red-ink); border-color: var(--red-ink); color: #fff; }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { background: var(--green-ink); border-color: var(--green-ink); color: #fff; }
.btn-outline { border-color: var(--brand); color: var(--brand); background: transparent; box-shadow: none; }
.btn-outline:hover { background: var(--brand-light); }
.btn-sm { padding: 4.5px 11px; font-size: 12.5px; border-radius: 8px; gap: 5px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.btn .rp { display: none; }

.badge {
  display: inline-block; padding: 2.5px 10px; border-radius: 99px; font-size: 11.5px;
  font-weight: 600; white-space: nowrap; letter-spacing: .015em; border: 1px solid transparent;
}
.b-green { background: var(--green-bg); color: var(--green-ink); border-color: #D2E7DA; }
.b-red { background: var(--red-bg); color: var(--red-ink); border-color: #EFD6D4; }
.b-yellow { background: var(--yellow-bg); color: var(--yellow-ink); border-color: #EDDFC2; }
.b-blue { background: var(--blue-bg); color: var(--blue-ink); border-color: #D3E0F0; }
.b-purple { background: var(--purple-bg); color: var(--purple-ink); border-color: #E0D8EF; }
.b-gray { background: var(--gray-bg); color: var(--gray-ink); border-color: #E0E4E9; }

.alert {
  padding: 12px 16px; border-radius: 10px; margin-bottom: 14px; font-size: 13.5px;
  border: 1px solid transparent; display: flex; align-items: flex-start; gap: 9px; line-height: 1.6;
}
.a-info { background: var(--blue-bg); color: var(--blue-ink); border-color: #D3E0F0; }
.a-success { background: var(--green-bg); color: var(--green-ink); border-color: #D2E7DA; }
.a-warn { background: var(--yellow-bg); color: var(--yellow-ink); border-color: #EDDFC2; }
.a-error { background: var(--red-bg); color: var(--red-ink); border-color: #EFD6D4; }

.form-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px 18px; }
.form-grid label { display: block; font-size: 12.5px; font-weight: 550; color: var(--ink-soft); letter-spacing: .01em; }
.span-1 { grid-column: span 1; } .span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; } .span-8 { grid-column: span 8; } .span-9 { grid-column: span 9; }
.span-12 { grid-column: span 12; }
.input {
  width: 100%; padding: 9px 13px; border: 1px solid var(--line-strong); border-radius: 9px;
  font-family: var(--font); font-size: 14px; background: #fff; color: var(--ink); margin-top: 6px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
  box-shadow: inset 0 1px 2px rgba(23, 30, 43, .03);
}
.input:hover { border-color: #B7BFCB; }
.input:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(var(--brand-rgb), .12); }
textarea.input { resize: vertical; line-height: 1.6; }
.form-actions { margin-top: 22px; display: flex; gap: 10px; flex-wrap: wrap; }
.req { color: var(--red); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tab {
  padding: 9px 15px; font-size: 13.5px; font-weight: 500; color: var(--ink-soft); white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

.pagination { display: flex; gap: 4px; margin-top: 18px; flex-wrap: wrap; align-items: center; }
.pg-btn {
  padding: 5px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px;
  background: var(--card); color: var(--ink-soft); transition: all .14s; font-variant-numeric: tabular-nums;
}
.pg-btn:hover { border-color: var(--line-strong); color: var(--ink); }
.pg-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.pg-btn.disabled { opacity: .4; pointer-events: none; }
.pg-dots { color: var(--ink-faint); padding: 0 3px; }

.avatar-sm { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }
.avatar-ph {
  width: 34px; height: 34px; border-radius: 50%; background: var(--brand-light); color: var(--brand);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 600;
}

.progress { height: 7px; border-radius: 99px; background: var(--line-soft); overflow: hidden; min-width: 80px; }
.progress > div { height: 100%; background: var(--brand); border-radius: 99px; transition: width .9s var(--ease-out); }

.filter-bar {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 18px;
  padding: 14px 16px; background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--line); box-shadow: var(--shadow-xs);
}
.filter-bar label { font-size: 12px; color: var(--ink-soft); display: block; font-weight: 550; }
.filter-bar .input { margin-top: 4px; width: auto; min-width: 140px; }

.att-opts { display: flex; gap: 4px; flex-wrap: wrap; }
.att-opt { cursor: pointer; }
.att-opt input { display: none; }
.att-opt span {
  display: inline-block; padding: 4px 11px; border-radius: 99px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--line); background: #fff; color: var(--ink-soft); transition: all .14s var(--ease);
}
.att-opt span:hover { border-color: var(--line-strong); }
.att-opt input:checked + span.o-present { background: var(--green-bg); border-color: var(--green); color: var(--green-ink); font-weight: 600; }
.att-opt input:checked + span.o-late { background: var(--yellow-bg); border-color: var(--yellow); color: var(--yellow-ink); font-weight: 600; }
.att-opt input:checked + span.o-absent { background: var(--red-bg); border-color: var(--red); color: var(--red-ink); font-weight: 600; }
.att-opt input:checked + span.o-leave { background: var(--blue-bg); border-color: var(--blue); color: var(--blue-ink); font-weight: 600; }
.att-opt input:checked + span.o-sick { background: var(--purple-bg); border-color: var(--purple); color: var(--purple-ink); font-weight: 600; }
.att-opt input:checked + span.o-activity { background: var(--gray-bg); border-color: var(--gray); color: var(--gray-ink); font-weight: 600; }

.grade-4 { color: var(--green-ink); font-weight: 650; }
.grade-0, .grade-r, .grade-ms { color: var(--red-ink); font-weight: 650; }

/* ============ เว็บไซต์สาธารณะ — Prestige ============ */

.pub-body { background: #fff; }
.pub-container { max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.pub-announce {
  background: var(--sidebar-bg); color: #D8DEE7; text-align: center; padding: 8px 16px;
  font-size: 12.5px; letter-spacing: .02em;
}
.pub-announce .icon { color: var(--gold-soft); animation: pulseSoft 2.6s infinite; }

.pub-header {
  background: rgba(255, 255, 255, .94); backdrop-filter: saturate(160%) blur(12px); -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 60;
  transition: box-shadow .25s;
}
.pub-header.shrink { box-shadow: 0 4px 20px -12px rgba(23, 30, 43, .18); }
.pub-header-in { display: flex; align-items: center; gap: 18px; min-height: var(--header-h); flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; transition: min-height .25s var(--ease); }
.pub-header.shrink .pub-header-in { min-height: 62px; }
.pub-brand { display: flex; align-items: center; gap: 13px; color: var(--ink); }
.pub-brand img { width: 48px; height: 48px; object-fit: contain; transition: transform .25s var(--ease); }
.pub-header.shrink .pub-brand img { transform: scale(.88); }
.pub-logo-ph {
  width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  background: var(--brand-darker); color: var(--gold-soft); border: 1px solid rgba(255,255,255,.1);
}
.pub-brand-name { font-family: var(--font-display); font-weight: 600; font-size: 19px; line-height: 1.2; letter-spacing: .005em; }
.pub-brand-sub { font-size: 11.5px; color: var(--ink-faint); letter-spacing: .06em; margin-top: 1px; }
.pub-burger { display: none; margin-left: auto; background: none; border: 0; cursor: pointer; color: var(--ink); padding: 6px; border-radius: 8px; }
.pub-nav { margin-left: auto; display: flex; align-items: center; gap: 0; flex-wrap: wrap; }
.pub-nav a {
  color: var(--ink-soft); font-size: 13.5px; font-weight: 500; padding: 9px 13px; border-radius: 8px;
  position: relative; letter-spacing: .01em; transition: color .15s;
}
.pub-nav a::after {
  content: ''; position: absolute; left: 13px; right: 13px; bottom: 5px; height: 2px;
  background: var(--gold); border-radius: 2px; transform: scaleX(0); transform-origin: left;
  transition: transform .22s var(--ease);
}
.pub-nav a:hover { color: var(--ink); }
.pub-nav a:hover::after { transform: scaleX(1); }
.pub-nav a.active { color: var(--ink); font-weight: 600; }
.pub-nav a.active::after { transform: scaleX(1); }
.pub-nav .pub-login {
  background: var(--brand); color: #fff; margin-left: 12px; display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: 9px; font-weight: 500;
  box-shadow: 0 1px 2px rgba(var(--brand-rgb), .3);
  transition: background .15s, transform .15s;
}
.pub-nav .pub-login::after { display: none; }
.pub-nav .pub-login:hover { background: var(--brand-dark); color: #fff; transform: translateY(-1px); }

.pub-main { min-height: 60vh; }
.section { padding: 64px 0; }
.section.alt { background: var(--bg-2); border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.section-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 30px; }
.section-head h2 {
  font-family: var(--font-display); font-size: clamp(22px, 3vw, 30px); font-weight: 600;
  letter-spacing: .005em; color: var(--ink); padding-left: 0; position: relative;
}
.section-head h2::before {
  content: ''; display: block; width: 36px; height: 3px; border-radius: 2px;
  background: var(--gold); margin-bottom: 12px;
}
.section-head .more {
  margin-left: auto; font-size: 13.5px; font-weight: 600; color: var(--brand);
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; padding-bottom: 4px;
}
.section-head .more .icon { transition: transform .18s var(--ease); }
.section-head .more:hover .icon { transform: translateX(3px); }

/* Hero */
.hero { position: relative; overflow: hidden; background: var(--brand-darker); }
.hero-slide { position: relative; height: clamp(380px, 52vw, 600px); }
.hero-slide img { width: 100%; height: 100%; object-fit: cover; display: block; animation: kenburns 14s var(--ease-out) forwards; }
.hero-slide::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(10, 18, 32, .38) 0%, rgba(10, 18, 32, .18) 42%, rgba(10, 18, 32, .82) 100%);
}
.hero-caption {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 44px 24px 30px; color: rgba(255,255,255,.92);
  font-size: 15px; letter-spacing: .02em; z-index: 3; max-width: 1180px; margin: 0 auto;
}
.hero-dots { position: absolute; bottom: 22px; right: 26px; display: flex; gap: 7px; z-index: 6; }
.hero-dots button { width: 8px; height: 8px; border-radius: 99px; border: 0; background: rgba(255,255,255,.4); cursor: pointer; transition: all .2s; }
.hero-dots button.active { background: var(--gold-soft); width: 26px; }
.hero-overlay {
  position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 24px; pointer-events: none;
}
.hero-overlay > * { pointer-events: auto; }
.hero-overlay h1 {
  color: #fff; font-family: var(--font-display); font-size: clamp(30px, 5vw, 56px); font-weight: 600;
  letter-spacing: .01em; text-shadow: 0 2px 28px rgba(0, 0, 0, .45); margin-bottom: 14px;
  animation: fadeUp .8s var(--ease-out) both;
}
.hero-overlay h1::after {
  content: ''; display: block; width: 64px; height: 3px; background: var(--gold);
  margin: 20px auto 0; border-radius: 2px;
}
.hero-overlay p {
  color: rgba(255, 255, 255, .88); font-size: clamp(14px, 2vw, 18px); letter-spacing: .06em;
  text-shadow: 0 1px 12px rgba(0, 0, 0, .4); margin-bottom: 30px; max-width: 640px;
  animation: fadeUp .8s .1s var(--ease-out) both;
}
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; animation: fadeUp .8s .2s var(--ease-out) both; }
.hero-cta .btn { padding: 11px 26px; font-size: 14px; border-radius: 10px; }
.hero-cta .btn-primary { background: #fff; border-color: #fff; color: var(--brand-darker); font-weight: 600; box-shadow: 0 6px 24px -6px rgba(0,0,0,.35); }
.hero-cta .btn-primary:hover { background: var(--gold-tint); border-color: var(--gold-tint); color: var(--brand-darker); }
.hero-cta .btn-glass {
  background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .55); color: #fff;
  backdrop-filter: blur(6px); box-shadow: none; font-weight: 500;
}
.hero-cta .btn-glass:hover { background: rgba(255, 255, 255, .2); color: #fff; }
.hero-static { padding: clamp(70px, 12vw, 120px) 0; text-align: center; position: relative; z-index: 3; }
.hero-static h1 {
  font-family: var(--font-display); font-size: clamp(32px, 6vw, 54px); font-weight: 600; margin-bottom: 14px;
  color: #fff; text-shadow: 0 2px 24px rgba(0, 0, 0, .35);
}
.hero-static p { font-size: clamp(14px, 2.2vw, 19px); color: rgba(255, 255, 255, .85); letter-spacing: .06em; }
.hero-wave { display: block; width: 100%; height: auto; position: relative; z-index: 2; margin-bottom: -6px; }

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }

.news-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  transition: box-shadow .25s var(--ease), transform .25s var(--ease), border-color .25s;
  display: flex; flex-direction: column;
}
.news-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-4px); border-color: var(--line-strong); }
.news-card .thumb {
  height: 185px; background: linear-gradient(160deg, var(--brand-tint), var(--brand-light));
  display: flex; align-items: center; justify-content: center; color: var(--brand-3); overflow: hidden; position: relative;
}
.news-card .thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .55s var(--ease-out); }
.news-card:hover .thumb img { transform: scale(1.05); }
.news-card .nc-body { padding: 18px; flex: 1; display: flex; flex-direction: column; gap: 9px; }
.news-card h3 {
  font-size: 15.5px; font-weight: 600; line-height: 1.5; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  transition: color .18s;
}
.news-card:hover h3 { color: var(--brand); }
.news-card .nc-meta { font-size: 12px; color: var(--ink-faint); margin-top: auto; display: flex; gap: 14px; letter-spacing: .01em; }

.quick-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 16px; }
.quick-link {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px 16px 22px; text-align: center; color: var(--ink);
  transition: border-color .22s var(--ease), box-shadow .22s var(--ease), transform .22s var(--ease);
  position: relative;
}
.quick-link::before {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%) scaleX(0);
  width: 44px; height: 3px; background: var(--gold); border-radius: 0 0 3px 3px;
  transition: transform .25s var(--ease);
}
.quick-link .icon, .quick-link .icon-duo { color: var(--brand); transition: transform .25s var(--ease); display: block; margin: 0 auto; }
.quick-link div { margin-top: 13px; font-weight: 600; font-size: 13.5px; letter-spacing: .01em; }
.quick-link:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); transform: translateY(-3px); color: var(--ink); }
.quick-link:hover::before { transform: translateX(-50%) scaleX(1); }
.quick-link:hover .icon, .quick-link:hover .icon-duo { transform: translateY(-2px); color: var(--brand); }

.person-card {
  text-align: center; background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px 18px 22px; transition: box-shadow .22s var(--ease), transform .22s var(--ease);
}
.person-card:hover { box-shadow: var(--shadow-md); transform: translateY(-3px); }
.person-card img, .person-card .pc-ph {
  width: 108px; height: 108px; border-radius: 50%; object-fit: cover; margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-tint); color: var(--brand); font-size: 32px; font-weight: 600;
  border: 3px solid #fff; outline: 1px solid var(--line);
}
.person-card h3 { font-size: 14.5px; font-weight: 600; }
.person-card p { font-size: 12.5px; color: var(--ink-faint); margin-top: 3px; }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(235px, 1fr)); gap: 20px; }
.feature {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 24px;
  transition: box-shadow .22s var(--ease), transform .22s var(--ease);
}
.feature:hover { box-shadow: var(--shadow-md); transform: translateY(-3px); }
.feature .icon-duo { color: var(--brand); display: block; margin-bottom: 16px; }
.feature-ic {
  width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px; background: var(--brand-darker); color: var(--gold-soft);
}
.feature h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; letter-spacing: -.005em; }
.feature p { font-size: 13px; color: var(--ink-soft); line-height: 1.75; }

.pub-footer { background: var(--sidebar-bg); color: #96A2B4; margin-top: 0; position: relative; }
.pub-footer::before { content: ''; display: block; height: 3px; background: linear-gradient(90deg, var(--gold-deep), var(--gold), var(--gold-deep)); }
.pub-footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 36px; padding: 56px 24px 38px; }
.pub-footer h3 {
  color: #E9EDF2; font-family: var(--font-head); font-size: 14px; font-weight: 600;
  letter-spacing: .06em; margin-bottom: 16px;
}
.pub-footer p { font-size: 13px; margin-bottom: 9px; line-height: 1.7; }
.pub-footer a { color: #96A2B4; transition: color .15s; }
.pub-footer a:hover { color: var(--gold-soft); }
.pub-copy { border-top: 1px solid rgba(255, 255, 255, .07); text-align: center; padding: 18px; font-size: 12px; color: #5E6B80; letter-spacing: .02em; }

.prose { max-width: 800px; }
.prose p { margin-bottom: 14px; line-height: 1.85; }
.prose img { border-radius: 10px; }
.prose h2, .prose h3 { margin: 24px 0 12px; font-family: var(--font-display); }
.prose ul, .prose ol { padding-left: 26px; margin-bottom: 14px; }

/* Login — สง่างาม สงบ */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  position: relative; overflow: hidden; background: var(--sidebar-bg);
}
.login-wrap::before {
  content: ''; position: absolute; inset: 0;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(var(--brand-rgb), .35), transparent 60%),
    radial-gradient(700px 500px at 95% 110%, rgba(176, 140, 70, .16), transparent 60%);
}
.login-wrap::after {
  content: ''; position: absolute; inset: 0; opacity: .05; pointer-events: none;
  background-image: repeating-linear-gradient(45deg, #fff 0 1px, transparent 1px 14px);
}
.login-card {
  background: #fff; border-radius: 16px; width: 100%; max-width: 420px; padding: 42px 40px 36px;
  position: relative; z-index: 2; box-shadow: 0 32px 80px -24px rgba(0, 0, 0, .55);
  border-top: 3px solid var(--gold); animation: scaleIn .5s var(--ease-out) both;
}
.login-card .login-logo { text-align: center; margin-bottom: 18px; }
.login-card .login-logo img { width: 72px; height: 72px; object-fit: contain; }
.login-card h1 { text-align: center; font-family: var(--font-display); font-size: 21px; font-weight: 600; margin-bottom: 5px; }
.login-card .sub { text-align: center; color: var(--ink-faint); font-size: 12.5px; margin-bottom: 26px; letter-spacing: .01em; }

.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ''; position: absolute; top: 50%; left: 50%; width: 15px; height: 15px; margin: -7.5px 0 0 -7.5px;
  border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; border-radius: 50%;
  animation: spin .55s linear infinite;
}


/* หัวการ์ดทักทาย (แดชบอร์ด) */
.welcome-title { font-size: 20px; font-weight: 650; letter-spacing: -.012em; }

/* ตัวเลขเด่นพิเศษ (การ์ดสรุปฝั่งนักเรียน/ผู้ปกครอง) */
.stat-num-xl { font-size: 38px; font-weight: 650; font-family: var(--font-head); line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

/* ปุ่มลบแบบ ghost สำหรับแถวตาราง — สงวน btn-danger ทึบไว้กับการยืนยันจริง */
.btn-ghost-danger { background: transparent; border-color: transparent; color: var(--red); box-shadow: none; }
.btn-ghost-danger:hover { background: var(--red-bg); border-color: #EFD6D4; color: var(--red-ink); }

/* ============ พิมพ์ ============ */
@media print {
  body { background: #fff; font-size: 13px; }
  .sidebar, .topbar, .app-foot, .license-bar, .page-head .actions, .no-print,
  .pub-header, .pub-footer, .pub-announce, .filter-bar, .pagination, .tabs, .hero-dots { display: none !important; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; margin: 0; }
  .card-body { padding: 0; }
  .table th, .table td { padding: 5px 8px; border: 1px solid #999; }
  .table th { background: #eee !important; color: #000; position: static; }
  .print-area { display: block !important; }
  html.js .reveal { opacity: 1 !important; transform: none !important; }
}

/* ============ Responsive ============ */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: -280px; transition: left .26s var(--ease); height: 100vh; box-shadow: var(--shadow-pop); }
  .sidebar.open { left: 0; }
  .tb-burger { display: block; }
  .tb-uname { display: none; }
  .content { padding: 16px; }
  .span-1, .span-2, .span-3, .span-4, .span-5, .span-6, .span-8, .span-9 { grid-column: span 12; }
  .pub-burger { display: block; }
  .pub-nav { display: none; width: 100%; flex-direction: column; align-items: stretch; padding-bottom: 12px; gap: 2px; animation: slideDown .22s var(--ease-out); }
  .pub-nav.open { display: flex; }
  .pub-nav a { padding: 12px 12px; border-radius: 8px; }
  .pub-nav a::after { display: none; }
  .pub-nav a.active { background: var(--brand-tint); }
  .pub-nav .pub-login { margin-left: 0; justify-content: center; margin-top: 8px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .pub-footer-grid { grid-template-columns: 1fr; gap: 26px; }
  .section { padding: 44px 0; }
}
@media (max-width: 520px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 11px; }
  .stat { padding: 14px; gap: 11px; flex-direction: column; }
  .stat-icon { width: 36px; height: 36px; }
  .stat-num { font-size: 21px; }
  .quick-links { grid-template-columns: 1fr 1fr; }
  .pub-brand-name { font-size: 16px; }
  .pub-brand img, .pub-logo-ph { width: 42px; height: 42px; }
  .content { padding: 13px; }
  .login-card { padding: 32px 24px 28px; }
}

.sidebar-overlay { display: none; }
@media (max-width: 860px) {
  .sidebar-overlay.show {
    display: block; position: fixed; inset: 0; background: rgba(10, 16, 28, .55);
    backdrop-filter: blur(2px); z-index: 55; animation: fadeIn .18s;
  }
}

/* หัวตารางจัดตำแหน่งตามคลาส (ชนะ .table th ที่ตั้ง text-align:left ไว้) */
.table th.text-right { text-align: right; }
.table th.text-center { text-align: center; }

/* ---------- เช็คชื่อ: แถบเครื่องมือเช็คเร็ว + ตัวนับสด ---------- */
.att-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; padding: 10px 14px; margin: 0 0 14px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}
.att-quick { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.att-live { display: flex; gap: 6px; flex-wrap: wrap; }
.att-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 11px;
  border-radius: 999px; border: 1px solid var(--line); background: #fff;
  font-size: 12.5px; color: var(--ink-soft);
}
.att-chip b { font-weight: 650; font-variant-numeric: tabular-nums; }
.att-chip.c-present b { color: var(--green-ink); }
.att-chip.c-late b    { color: var(--yellow-ink); }
.att-chip.c-absent b  { color: var(--red-ink); }
.att-chip.c-leave b   { color: var(--blue-ink); }
