/* BPY E-Saraban — โทนสีโรงเรียน ส้ม + น้ำเงิน */

/* ฟอนต์หนังสือราชการ (ฟอนต์แห่งชาติ SIPA ใช้และแจกจ่ายได้ฟรี) ใช้ในตรารับและกรอบเกษียนบน PDF */
@font-face { font-family: "THSarabunIT9"; src: url("../assets/fonts/THSarabunIT9.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "THSarabunIT9"; src: url("../assets/fonts/THSarabunIT9-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
:root {
  --navy-950: #060f2b;
  --navy-900: #0a1b47;
  --navy-800: #0f2766;
  --blue-700: #1d4ed8;
  --blue-600: #2563eb;
  --blue-500: #3b82f6;
  --blue-100: #dbeafe;
  --blue-50: #eef4ff;
  --orange-700: #c2410c;
  --orange-600: #ea580c;
  --orange-500: #f97316;
  --orange-400: #fb923c;
  --orange-100: #ffedd5;
  --orange-50: #fff7ed;
  --sky-400: #38bdf8;
  --amber-300: #fcd34d;

  --grad-brand: linear-gradient(135deg, var(--blue-600) 0%, var(--navy-800) 100%);
  --grad-orange: linear-gradient(135deg, #fb923c 0%, #f97316 45%, #ea580c 100%);
  --grad-mix: linear-gradient(120deg, var(--orange-500), #f59e0b 30%, var(--blue-500) 70%, var(--blue-700));

  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f7f9fd;
  --border: #e3e8f2;
  --border-strong: #cdd5e3;
  --text: #0e1630;
  --text-2: #4a5470;
  --text-3: #7b85a0;

  --success: #12804b;
  --success-bg: #e5f6ec;
  --warning: #b45309;
  --warning-bg: #fff3e0;
  --danger: #c62832;
  --danger-bg: #fdecec;
  --info: var(--blue-700);
  --info-bg: var(--blue-50);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(14, 22, 48, .05);
  --shadow: 0 1px 2px rgba(14, 22, 48, .04), 0 10px 28px -14px rgba(15, 39, 102, .25);
  --shadow-hover: 0 2px 4px rgba(14, 22, 48, .05), 0 22px 40px -18px rgba(15, 39, 102, .35);
  --shadow-lg: 0 28px 64px -22px rgba(6, 15, 43, .45);
  --ring: 0 0 0 4px rgba(37, 99, 235, .18);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);

  --font: "IBM Plex Sans Thai", "Sarabun", system-ui, sans-serif;
  --font-head: "Prompt", "IBM Plex Sans Thai", system-ui, sans-serif;
  --sidebar-w: 272px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #070d1f;
    --surface: #0f1830;
    --surface-2: #0c1428;
    --border: #1d2947;
    --border-strong: #2b3a60;
    --text: #e9eefb;
    --text-2: #b2bcd6;
    --text-3: #8490ae;
    --blue-50: #11214a;
    --blue-100: #1a3070;
    --orange-50: #2a1708;
    --orange-100: #3a1f0a;
    --success-bg: #0d2a1b;
    --warning-bg: #2d1c08;
    --danger-bg: #301215;
    --success: #4ad48a;
    --warning: #fbbf6a;
    --danger: #ff7c82;
    --info: #93b4ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 28px -14px rgba(0, 0, 0, .7);
    --shadow-hover: 0 2px 4px rgba(0, 0, 0, .3), 0 22px 40px -18px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background:
    radial-gradient(900px 500px at 100% -10%, rgba(249, 115, 22, .07), transparent 60%),
    radial-gradient(800px 500px at -10% 110%, rgba(37, 99, 235, .07), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 600; line-height: 1.3; margin: 0; color: var(--text); }
h1 { font-size: 26px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0; }
a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
::selection { background: rgba(249, 115, 22, .25); }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- boot ---------- */
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot img { width: 92px; height: 92px; border-radius: 50%; animation: boot 1.4s var(--ease) infinite; box-shadow: 0 0 0 0 rgba(249, 115, 22, .5); }
@keyframes boot { 0% { box-shadow: 0 0 0 0 rgba(249, 115, 22, .45); transform: scale(.96); } 70% { box-shadow: 0 0 0 22px rgba(249, 115, 22, 0); transform: scale(1); } 100% { transform: scale(.96); } }

/* ---------- buttons ---------- */
.btn {
  position: relative; overflow: hidden; isolation: isolate;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px; border-radius: 11px; border: 1px solid transparent;
  font-weight: 500; font-size: 15px; cursor: pointer; white-space: nowrap;
  transition: transform .2s var(--ease), box-shadow .25s var(--ease), background-color .2s, border-color .2s, filter .2s;
  text-decoration: none !important;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px) scale(.98); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn i { font-size: 18px; transition: transform .3s var(--spring); }
.btn:hover i { transform: translateX(2px) scale(1.08); }
.btn-primary { background: var(--grad-brand); color: #fff; box-shadow: 0 8px 18px -10px rgba(37, 99, 235, .9); }
.btn-primary:hover { box-shadow: 0 14px 26px -12px rgba(37, 99, 235, .95); filter: brightness(1.08); }
.btn-gold, .btn-accent { background: var(--grad-orange); color: #fff; box-shadow: 0 8px 18px -10px rgba(234, 88, 12, .9); }
.btn-gold:hover, .btn-accent:hover { box-shadow: 0 14px 26px -12px rgba(234, 88, 12, .95); filter: brightness(1.05); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover { border-color: var(--blue-500); color: var(--blue-700); box-shadow: 0 6px 16px -10px rgba(37, 99, 235, .5); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); transform: none; }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-sm { height: 34px; padding: 0 12px; font-size: 14px; border-radius: 9px; }
.btn-sm i { font-size: 16px; }
.btn-block { width: 100%; }
.btn-icon { width: 40px; padding: 0; }
.btn-icon:hover i { transform: rotate(-8deg) scale(1.1); }
.btn[disabled], .btn.loading { opacity: .65; pointer-events: none; }
.btn.loading::before {
  content: ""; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
.btn.loading i { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ripple (สร้างด้วย motion.js) */
.ripple {
  position: absolute; border-radius: 50%; pointer-events: none; z-index: -1;
  background: currentColor; opacity: .22; transform: scale(0); animation: ripple .6s var(--ease) forwards;
}
.btn-primary .ripple, .btn-gold .ripple, .btn-accent .ripple { background: #fff; opacity: .35; }
@keyframes ripple { to { transform: scale(1); opacity: 0; } }

/* ---------- forms ---------- */
.form { display: grid; gap: 16px; }
.form-row { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.form-row.three { grid-template-columns: 120px 1fr 1fr; }
.field { display: grid; gap: 6px; align-content: start; }
.field label { font-size: 14px; font-weight: 500; color: var(--text); }
.field .hint { font-size: 13px; color: var(--text-3); }
.input-wrap { position: relative; }
.input-wrap > i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 18px; pointer-events: none; transition: color .2s, transform .3s var(--spring); }
.input-wrap:focus-within > i { color: var(--orange-500); transform: translateY(-50%) scale(1.12); }
.input, select.input {
  width: 100%; height: 44px; padding: 0 14px; border-radius: 11px;
  border: 1px solid var(--border-strong); background: var(--surface);
  transition: border-color .2s, box-shadow .2s, background-color .2s;
}
.input-wrap > i + .input { padding-left: 40px; }
textarea.input { height: auto; min-height: 76px; padding: 10px 14px; line-height: 1.55; resize: vertical; }
.input:hover { border-color: #aeb9cf; }
.input:focus { outline: none; border-color: var(--blue-500); box-shadow: var(--ring); }
.input.invalid { border-color: var(--danger); }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237b85a0' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; cursor: pointer; }
.toggle-pw { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--text-3); width: 34px; height: 34px; border-radius: 8px; cursor: pointer; transition: background .2s, color .2s; }
.toggle-pw:hover { background: var(--surface-2); color: var(--orange-500); }
.field-error { color: var(--danger); font-size: 13px; }
input[type=checkbox] { accent-color: var(--orange-500); width: 16px; height: 16px; }

.pw-meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 2px; }
.pw-meter span { height: 4px; border-radius: 2px; background: var(--border); transition: background .3s, transform .3s var(--spring); }
.pw-meter[data-score="1"] span:nth-child(-n+1) { background: var(--danger); }
.pw-meter[data-score="2"] span:nth-child(-n+2) { background: var(--orange-500); }
.pw-meter[data-score="3"] span:nth-child(-n+3) { background: #3b9b5a; }
.pw-meter[data-score="4"] span { background: var(--success); }

/* ---------- alerts / badges ---------- */
.alert { display: flex; gap: 12px; padding: 12px 14px; border-radius: var(--radius); font-size: 14px; line-height: 1.55; border: 1px solid transparent; }
.alert i { font-size: 20px; flex: none; margin-top: 1px; }
.alert-info { background: var(--info-bg); color: var(--info); border-color: rgba(37, 99, 235, .15); }
.alert-success { background: var(--success-bg); color: var(--success); border-color: rgba(18, 128, 75, .15); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: rgba(249, 115, 22, .2); }
.alert-danger { background: var(--danger-bg); color: var(--danger); border-color: rgba(198, 40, 50, .15); }
.alert b { font-weight: 600; }
.alert-warning i { animation: nudge 2.4s ease-in-out infinite; }
@keyframes nudge { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-12deg); } 90% { transform: rotate(10deg); } 95% { transform: rotate(-6deg); } }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.badge i { font-size: 14px; }
.role-admin { background: #efe9ff; color: #5b3cc4; }
.role-director { background: var(--orange-100); color: var(--orange-700); }
.role-deputy { background: var(--blue-50); color: var(--blue-700); }
.role-clerk { background: #e0f5f3; color: #0f766e; }
.role-teacher { background: #eef1f6; color: #4a5470; }
.role-none { background: var(--warning-bg); color: var(--warning); }
.st-active, .st-registered { background: var(--success-bg); color: var(--success); }
.st-pending_approval, .st-sent { background: var(--orange-100); color: var(--orange-700); }
.st-pending_email, .st-new { background: #eef1f6; color: #5b6476; }
.st-disabled { background: var(--danger-bg); color: var(--danger); }
.st-pending_approval::before, .st-sent::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: blink 1.6s ease-in-out infinite;
}
@keyframes blink { 50% { opacity: .25; } }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .role-admin { background: #241a45; color: #b9a5ff; }
  :root:not([data-theme="light"]) .role-director, :root:not([data-theme="light"]) .st-pending_approval, :root:not([data-theme="light"]) .st-sent { color: var(--orange-400); }
  :root:not([data-theme="light"]) .role-clerk { background: #0d2a29; color: #5fd4c6; }
  :root:not([data-theme="light"]) .role-teacher, :root:not([data-theme="light"]) .st-pending_email, :root:not([data-theme="light"]) .st-new { background: #1a2442; color: #b2bcd6; }
}

/* ---------- auth layout ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-brand {
  position: relative; overflow: hidden; color: #fff;
  background: linear-gradient(155deg, var(--navy-800) 0%, var(--navy-950) 100%);
  padding: 48px 56px; display: flex; flex-direction: column;
}
.auth-brand::before {
  content: ""; position: absolute; inset: 0; z-index: 1; opacity: .55;
  background-image: radial-gradient(rgba(255, 255, 255, .1) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(180deg, #000 0%, transparent 85%);
}
.blob { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .75; z-index: 0; will-change: transform; }
.blob.b1 { width: 420px; height: 420px; background: radial-gradient(circle, rgba(249, 115, 22, .75), transparent 65%); top: -120px; right: -100px; animation: drift1 16s ease-in-out infinite; }
.blob.b2 { width: 480px; height: 480px; background: radial-gradient(circle, rgba(37, 99, 235, .8), transparent 65%); bottom: -180px; left: -140px; animation: drift2 19s ease-in-out infinite; }
.blob.b3 { width: 260px; height: 260px; background: radial-gradient(circle, rgba(56, 189, 248, .55), transparent 65%); top: 45%; left: 55%; animation: drift3 22s ease-in-out infinite; }
@keyframes drift1 { 50% { transform: translate(-80px, 90px) scale(1.12); } }
@keyframes drift2 { 50% { transform: translate(110px, -70px) scale(1.08); } }
@keyframes drift3 { 33% { transform: translate(-90px, -60px); } 66% { transform: translate(40px, 70px) scale(.9); } }
.auth-brand > :not(.blob) { position: relative; z-index: 2; }
.brand-top { display: flex; align-items: center; gap: 12px; font-family: var(--font-head); font-weight: 600; font-size: 18px; letter-spacing: .2px; }
.brand-top img { width: 40px; height: 40px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(251, 146, 60, .7); }
.brand-hero { margin: auto 0; padding: 40px 0; max-width: 520px; }
.emblem-ring {
  position: relative; width: 172px; height: 172px; border-radius: 50%; padding: 6px; margin-bottom: 30px;
  background: conic-gradient(from 0deg, #fb923c, #fcd34d, #f97316, #3b82f6, #1d4ed8, #fb923c);
  box-shadow: 0 24px 60px -18px rgba(0, 0, 0, .75), 0 0 50px -6px rgba(249, 115, 22, .55);
  transition: transform .4s var(--ease);
  animation: float 6s ease-in-out infinite;
}
.emblem-ring::after { content: ""; position: absolute; inset: -10px; border-radius: 50%; border: 1px dashed rgba(255, 255, 255, .25); animation: spin 30s linear infinite; }
.emblem-ring img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
@keyframes float { 50% { translate: 0 -10px; } }
.brand-hero h1 { color: #fff; font-size: 42px; font-weight: 600; letter-spacing: .3px; }
.brand-hero h1 span {
  background: linear-gradient(90deg, #fdba74, #f97316, #fcd34d, #fb923c); background-size: 200% auto;
  -webkit-background-clip: text; background-clip: text; color: transparent; animation: shine 5s linear infinite;
}
@keyframes shine { to { background-position: 200% center; } }
.brand-hero .lead { color: rgba(255, 255, 255, .8); font-size: 16px; margin-top: 10px; }
.brand-features { list-style: none; padding: 0; margin: 32px 0 0; display: grid; gap: 12px; }
.brand-features li {
  display: flex; gap: 14px; align-items: center; color: rgba(255, 255, 255, .92);
  padding: 8px 12px 8px 8px; border-radius: 14px; transition: background .3s, transform .3s var(--ease);
}
.brand-features li:hover { background: rgba(255, 255, 255, .06); transform: translateX(6px); }
.brand-features i {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; flex: none;
  background: linear-gradient(135deg, rgba(249, 115, 22, .3), rgba(37, 99, 235, .3));
  border: 1px solid rgba(255, 255, 255, .15); color: #fdba74;
  transition: transform .4s var(--spring);
}
.brand-features li:hover i { transform: rotate(-10deg) scale(1.12); }
.brand-foot { font-size: 13px; color: rgba(255, 255, 255, .55); }

.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--surface); position: relative; }
.auth-main::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--grad-mix); background-size: 200% 100%; animation: shine 6s linear infinite; }
.auth-card { width: 100%; max-width: 440px; }
.auth-card.wide { max-width: 560px; }
.auth-card .head { margin-bottom: 26px; }
.auth-card .head h2 { font-size: 28px; }
.auth-card .head p { color: var(--text-2); margin-top: 6px; }
.auth-icon {
  width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; font-size: 32px; margin-bottom: 20px;
  background: var(--blue-50); color: var(--blue-600); animation: pop .6s var(--spring) both;
}
.auth-icon.success { background: var(--success-bg); color: var(--success); }
.auth-icon.warning { background: var(--orange-100); color: var(--orange-600); }
.auth-icon.danger { background: var(--danger-bg); color: var(--danger); }
@keyframes pop { from { transform: scale(.5) rotate(-12deg); opacity: 0; } }
.auth-alt { text-align: center; margin-top: 22px; color: var(--text-2); font-size: 14px; }
.auth-alt a, .row-between a { color: var(--orange-600); font-weight: 500; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.invite-banner {
  display: flex; gap: 14px; align-items: center; padding: 14px 16px; border-radius: var(--radius); margin-bottom: 22px;
  background: linear-gradient(120deg, var(--orange-50), var(--blue-50)); border: 1px solid var(--border);
}
.invite-banner i { font-size: 26px; color: var(--orange-500); animation: nudge 2.4s ease-in-out infinite; }

/* ---------- app shell ---------- */
.shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40; overflow: hidden;
  background: linear-gradient(180deg, var(--navy-900) 0%, var(--navy-950) 100%);
  color: #d6def3; display: flex; flex-direction: column; padding: 18px 14px;
  transition: transform .35s var(--ease);
}
.sidebar::before {
  content: ""; position: absolute; width: 320px; height: 320px; left: -120px; bottom: -160px; border-radius: 50%;
  background: radial-gradient(circle, rgba(249, 115, 22, .35), transparent 65%); filter: blur(30px);
  animation: drift2 18s ease-in-out infinite; pointer-events: none;
}
.sidebar::after {
  content: ""; position: absolute; width: 260px; height: 260px; right: -140px; top: -80px; border-radius: 50%;
  background: radial-gradient(circle, rgba(59, 130, 246, .4), transparent 65%); filter: blur(30px); pointer-events: none;
}
.sidebar > * { position: relative; z-index: 1; }
.side-brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.side-brand img { width: 46px; height: 46px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(251, 146, 60, .75), 0 6px 18px -6px rgba(249, 115, 22, .6); transition: transform .6s var(--spring); }
.side-brand:hover img { transform: rotate(-12deg) scale(1.06); }
.side-brand b { font-family: var(--font-head); font-weight: 600; color: #fff; font-size: 17px; display: block; line-height: 1.2; }
.side-brand small { color: #fdba74; font-size: 12px; }
.nav { margin-top: 12px; display: grid; gap: 3px; overflow-y: auto; overflow-x: hidden; padding-right: 6px; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .15) transparent; }
.nav-label { font-size: 11.5px; letter-spacing: .6px; color: rgba(214, 222, 243, .45); padding: 14px 12px 6px; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px;
  color: #c3cde6; text-decoration: none; font-size: 14.5px; isolation: isolate; overflow: hidden;
  transition: color .25s, transform .3s var(--ease);
}
.nav a::after {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit;
  background: linear-gradient(90deg, rgba(255, 255, 255, .1), rgba(255, 255, 255, .03));
  opacity: 0; transform: scaleX(.6); transform-origin: left; transition: opacity .3s, transform .35s var(--ease);
}
.nav a:hover { color: #fff; transform: translateX(4px); }
.nav a:hover::after { opacity: 1; transform: scaleX(1); }
.nav a i { font-size: 20px; opacity: .9; transition: transform .4s var(--spring), color .25s; }
.nav a:hover i { transform: scale(1.18) rotate(-8deg); color: #fdba74; }
.nav a.active { color: #fff; font-weight: 500; }
.nav a.active::after { opacity: 1; transform: none; background: linear-gradient(90deg, rgba(249, 115, 22, .32), rgba(37, 99, 235, .18)); }
.nav a.active i { color: #fdba74; }
.nav a.active::before {
  content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0;
  background: var(--grad-orange); box-shadow: 0 0 12px rgba(249, 115, 22, .9); animation: grow .4s var(--ease);
}
@keyframes grow { from { transform: scaleY(0); } }
.nav a .soon { margin-left: auto; font-size: 11px; padding: 1px 8px; border-radius: 999px; background: rgba(56, 189, 248, .14); color: #7dd3fc; }
.nav a .count {
  margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--grad-orange); color: #fff; font-size: 12px; font-weight: 600; display: grid; place-items: center;
  box-shadow: 0 0 0 0 rgba(249, 115, 22, .7); animation: ping 2s infinite;
}
@keyframes ping { 70% { box-shadow: 0 0 0 8px rgba(249, 115, 22, 0); } 100% { box-shadow: 0 0 0 0 rgba(249, 115, 22, 0); } }
.side-user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid rgba(255, 255, 255, .08); }
.side-user .who { min-width: 0; flex: 1; }
.side-user .who b { display: block; color: #fff; font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user .who span { font-size: 12px; color: rgba(214, 222, 243, .6); }
.side-user .btn-ghost { color: #c3cde6; }
.side-user .btn-ghost:hover { background: rgba(249, 115, 22, .18); color: #fdba74; }

.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-family: "IBM Plex Sans Thai Looped", var(--font); font-weight: 500; font-size: 16px; color: #fff;
  background: var(--grad-brand); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .15);
}
.avatar.alt { background: var(--grad-orange); }
.avatar.lg { width: 72px; height: 72px; font-size: 28px; box-shadow: 0 0 0 4px var(--surface), 0 0 0 6px var(--orange-400); }

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: 66px; display: flex; align-items: center; gap: 12px;
  padding: 0 28px; background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(1.5) blur(14px); border-bottom: 1px solid transparent;
  transition: border-color .3s, box-shadow .3s;
}
.topbar.scrolled { border-bottom-color: var(--border); box-shadow: 0 8px 24px -18px rgba(15, 39, 102, .45); }
.topbar h1 { font-size: 20px; }
.topbar .spacer { flex: 1; }
.topbar .date { font-size: 13px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.menu-btn { display: none; }
.content { padding: 28px; width: 100%; max-width: 1200px; display: grid; gap: 22px; align-content: start; }
.content > *, .grid > * { min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h2 { position: relative; padding-bottom: 6px; }
.page-head h2::after { content: ""; position: absolute; left: 0; bottom: 0; width: 36px; height: 3px; border-radius: 3px; background: var(--grad-orange); }
.page-head p { color: var(--text-2); margin-top: 6px; }
.scrim { display: none; }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  transition: transform .35s var(--ease), box-shadow .35s var(--ease), border-color .3s;
}
.card-pad { padding: 22px; }
.card-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-head h3 { display: flex; align-items: center; gap: 10px; }
.card-head h3 i {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; font-size: 18px;
  background: var(--orange-100); color: var(--orange-600);
}
a.card:hover, .card.lift:hover, .feature:hover, .stat:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); border-color: color-mix(in srgb, var(--orange-500) 35%, var(--border)); }

.hero {
  position: relative; overflow: hidden; isolation: isolate; border-radius: 22px; color: #fff; padding: 30px 32px;
  background: linear-gradient(120deg, var(--navy-800) 0%, var(--blue-700) 55%, #2f6bf0 100%);
  display: flex; align-items: center; gap: 24px; box-shadow: 0 24px 50px -28px rgba(15, 39, 102, .8);
}
.hero::before {
  content: ""; position: absolute; z-index: -1; width: 380px; height: 380px; right: -90px; top: -170px; border-radius: 50%;
  background: radial-gradient(circle, rgba(249, 115, 22, .85), rgba(249, 115, 22, 0) 65%); animation: drift1 14s ease-in-out infinite;
}
.hero::after {
  content: ""; position: absolute; z-index: -1; inset: 0; opacity: .35;
  background-image: radial-gradient(rgba(255, 255, 255, .25) 1px, transparent 1px); background-size: 18px 18px;
  mask-image: linear-gradient(90deg, transparent 30%, #000 100%);
}
.hero .shape { position: absolute; z-index: -1; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .14); }
.hero .shape.s1 { width: 140px; height: 140px; right: 12%; bottom: -60px; animation: spin 24s linear infinite; border-style: dashed; }
.hero .shape.s2 { width: 18px; height: 18px; right: 30%; top: 22px; background: rgba(253, 186, 116, .9); border: 0; animation: float 4s ease-in-out infinite; }
.hero .shape.s3 { width: 10px; height: 10px; right: 8%; top: 40%; background: rgba(125, 211, 252, .9); border: 0; animation: float 5s ease-in-out infinite .6s; }
.hero h2 { color: #fff; font-size: 26px; }
.hero p { color: rgba(255, 255, 255, .85); margin-top: 4px; }
.hero .emblem {
  width: 92px; height: 92px; border-radius: 50%; flex: none;
  box-shadow: 0 0 0 3px #fb923c, 0 0 0 8px rgba(255, 255, 255, .12), 0 14px 30px -10px rgba(0, 0, 0, .6);
  animation: float 6s ease-in-out infinite;
}
.hero .badge { background: rgba(255, 255, 255, .16); color: #fff; margin-top: 10px; backdrop-filter: blur(4px); }
.wave { display: inline-block; transform-origin: 70% 70%; animation: wave 2.4s ease-in-out 1s 2; }
@keyframes wave { 10%, 30% { transform: rotate(14deg); } 20% { transform: rotate(-8deg); } 40% { transform: rotate(-4deg); } 50% { transform: rotate(10deg); } 60%, 100% { transform: rotate(0); } }

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

.stat { padding: 18px 20px; display: flex; gap: 14px; align-items: center; position: relative; overflow: hidden; }
.stat::after { content: ""; position: absolute; right: -30px; bottom: -30px; width: 90px; height: 90px; border-radius: 50%; background: currentColor; opacity: .04; transition: transform .5s var(--ease); }
.stat:hover::after { transform: scale(1.6); }
.stat .ic, .feature .ic { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 23px; flex: none; transition: transform .45s var(--spring); }
.stat:hover .ic, .feature:hover .ic { transform: rotate(-10deg) scale(1.1); }
.stat .num { font-family: var(--font-head); font-size: 28px; font-weight: 600; line-height: 1.1; }
.stat .lbl { color: var(--text-2); font-size: 13.5px; }
.ic-blue { background: var(--blue-50); color: var(--blue-600); }
.ic-gold, .ic-orange { background: var(--orange-100); color: var(--orange-600); }
.ic-green { background: var(--success-bg); color: var(--success); }
.ic-sky { background: #e0f4fe; color: #0284c7; }

.feature { padding: 22px; display: grid; gap: 10px; position: relative; overflow: hidden; }
.feature::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--grad-mix); transform: scaleX(0); transform-origin: left; transition: transform .5s var(--ease); }
.feature:hover::before { transform: scaleX(1); }
.feature .tag { position: absolute; right: 16px; top: 16px; }
.feature p { color: var(--text-2); font-size: 14px; }

.checklist { display: grid; }
.check-item { display: flex; gap: 14px; align-items: center; padding: 14px 22px; border-top: 1px solid var(--border); transition: background .25s, padding .3s var(--ease); }
.check-item:first-child { border-top: 0; }
.check-item:hover { background: var(--surface-2); padding-left: 28px; }
.check-item .dot { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: 18px; }
.check-item .txt { flex: 1; min-width: 0; }
.check-item .txt b { font-weight: 500; display: block; }
.check-item .txt span { font-size: 13.5px; color: var(--text-2); }
.check-item .go { color: var(--text-3); transition: transform .3s var(--ease), color .2s; }
.check-item:hover .go { transform: translateX(4px); color: var(--orange-500); }

/* ---------- tables ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 9px; font-size: 14px; color: var(--text-2); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; transition: background .25s, color .2s, box-shadow .25s; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 2px 8px -2px rgba(15, 39, 102, .2); font-weight: 500; }
.seg button .n { font-size: 12px; background: var(--border); border-radius: 999px; padding: 0 7px; transition: background .25s, color .25s; }
.seg button.on .n { background: var(--grad-orange); color: #fff; }
.search { position: relative; }
.search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); transition: color .2s; }
.search:focus-within i { color: var(--orange-500); }
.search .input { height: 38px; padding-left: 36px; width: 240px; transition: width .35s var(--ease), border-color .2s, box-shadow .2s; }
.search .input:focus { width: 280px; }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th { text-align: left; font-weight: 500; color: var(--text-3); font-size: 13px; padding: 12px 22px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 14px 22px; border-bottom: 1px solid var(--border); vertical-align: middle; transition: background .2s; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { position: relative; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--orange-500) 4%, var(--surface)); }
.table tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--orange-500); }
.person { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.person .avatar { width: 36px; height: 36px; font-size: 14px; transition: transform .35s var(--spring); }
tr:hover .person .avatar { transform: scale(1.1); }
.person b { font-weight: 500; display: block; }
.person span { font-size: 13px; color: var(--text-3); }
.actions { display: flex; gap: 6px; justify-content: flex-end; }
.tg-ok { color: var(--success); display: inline-flex; align-items: center; gap: 4px; font-size: 13.5px; white-space: nowrap; }
.tg-no { color: var(--text-3); display: inline-flex; align-items: center; gap: 4px; font-size: 13.5px; white-space: nowrap; }
.table .pos { min-width: 120px; }
@media (max-width: 1280px) { .table .hide-md { display: none; } }

.empty { text-align: center; padding: 48px 20px; color: var(--text-2); }
.empty i { font-size: 46px; color: var(--text-3); display: block; margin-bottom: 8px; animation: float 4s ease-in-out infinite; }

.skeleton { border-radius: 10px; background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- dialog / toast ---------- */
dialog.modal { border: 0; padding: 0; border-radius: 20px; width: min(480px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); overflow: hidden; }
dialog.modal[open] { animation: modal-in .35s var(--spring); }
dialog.modal::before { content: ""; display: block; height: 4px; background: var(--grad-mix); }
dialog.modal::backdrop { background: rgba(6, 15, 43, .5); backdrop-filter: blur(4px); animation: fade .25s ease; }
@keyframes modal-in { from { opacity: 0; transform: translateY(16px) scale(.94); } }
@keyframes fade { from { opacity: 0; } }
.modal-body { padding: 24px; display: grid; gap: 16px; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; background: var(--surface-2); }

.toasts { position: fixed; z-index: 100; right: 20px; bottom: 20px; display: grid; gap: 10px; width: min(380px, calc(100vw - 40px)); }
.toast {
  position: relative; overflow: hidden; display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: toast-in .45s var(--spring); font-size: 14.5px;
}
.toast::after { content: ""; position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: currentColor; transform-origin: left; animation: toast-bar var(--toast-ms, 4200ms) linear forwards; opacity: .5; }
.toast.success { color: var(--success); }
.toast.error { color: var(--danger); }
.toast.info { color: var(--blue-600); }
.toast > div { color: var(--text); }
.toast i { font-size: 20px; flex: none; }
.toast.hide { opacity: 0; transform: translateX(30px); transition: .3s var(--ease); }
@keyframes toast-in { from { opacity: 0; transform: translateX(40px) scale(.95); } }
@keyframes toast-bar { to { transform: scaleX(0); } }

.dev-note { border: 1px dashed var(--orange-500); background: var(--orange-50); color: #7c2d12; border-radius: 10px; padding: 10px 12px; font-size: 13.5px; word-break: break-all; }
.dev-note a { color: #9a3412; font-weight: 600; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .dev-note, :root:not([data-theme="light"]) .dev-note a { color: var(--orange-400); }
}
.mock-flag { position: fixed; right: 12px; bottom: 12px; z-index: 90; font-size: 12px; white-space: nowrap; background: #431407; color: #fdba74; padding: 4px 12px; border-radius: 999px; opacity: .88; pointer-events: none; }

.profile-head { display: flex; gap: 18px; align-items: center; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; font-size: 14.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; }
.tg-card { display: flex; gap: 16px; align-items: center; }
.tg-logo { width: 52px; height: 52px; border-radius: 14px; background: linear-gradient(135deg, #37aee2, #1e96c8); color: #fff; display: grid; place-items: center; font-size: 28px; flex: none; box-shadow: 0 10px 20px -10px rgba(30, 150, 200, .8); }
.tg-logo i { animation: fly 3s ease-in-out infinite; }
@keyframes fly { 50% { transform: translate(2px, -3px) rotate(-6deg); } }

/* ---------- เข้าฉาก (motion.js ใส่ --i ให้แต่ละชิ้น) ---------- */
.rise { animation: rise .6s var(--ease) both; animation-delay: calc(var(--i, 0) * 60ms); }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }
.nav a.slide { animation: slide .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 35ms + 80ms); }
@keyframes slide { from { opacity: 0; transform: translateX(-16px); } }
.auth-card > * { animation: rise .6s var(--ease) both; }
.auth-card > :nth-child(2) { animation-delay: .08s; }
.auth-card > :nth-child(3) { animation-delay: .16s; }
.auth-card > :nth-child(4) { animation-delay: .24s; }
.auth-card > :nth-child(5) { animation-delay: .32s; }
.brand-features li { animation: slide .6s var(--ease) both; }
.brand-features li:nth-child(1) { animation-delay: .3s; }
.brand-features li:nth-child(2) { animation-delay: .42s; }
.brand-features li:nth-child(3) { animation-delay: .54s; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { padding: 22px 20px; }
  .brand-hero { padding: 18px 0 4px; display: flex; gap: 16px; align-items: center; }
  .emblem-ring { width: 78px; height: 78px; padding: 3px; margin: 0; flex: none; }
  .emblem-ring::after { inset: -6px; }
  .brand-hero h1 { font-size: 28px; }
  .brand-hero .lead { font-size: 14px; margin-top: 2px; }
  .brand-features, .brand-foot, .brand-top { display: none; }
  .auth-main { align-items: flex-start; padding: 28px 16px 48px; }

  .sidebar { transform: translateX(-100%); }
  .shell.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(6, 15, 43, .5); backdrop-filter: blur(2px); animation: fade .3s ease; }
  .main { margin-left: 0; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .topbar .date { display: none; }
  .content { padding: 18px 16px 40px; }
}
@media (max-width: 640px) {
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .stat { flex-direction: column; align-items: flex-start; gap: 10px; padding: 16px; }
  .form-row, .form-row.three { grid-template-columns: 1fr; }
  .hero { flex-direction: column; align-items: flex-start; padding: 22px; }
  .hero .emblem { width: 62px; height: 62px; }
  .search .input, .search .input:focus { width: 100%; }
  .search { flex: 1; }
  .table th, .table td { padding: 12px 14px; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .card-pad { padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
