/* =====================================================================
   EZAI - Theme
   โทน: กรมท่าเข้ม + ทอง, พื้นสะอาด, ตัวอักษรอ่านง่าย
   แก้สีหลักได้ที่ตัวแปรใน :root
   ===================================================================== */
:root {
  --navy-950: #061528;
  --navy-900: #0b2140;
  --navy-800: #102c52;
  --navy-700: #173a69;
  --navy-600: #1f4a82;
  --gold: #c5a059;
  --gold-soft: #e6d3a8;

  --ink: #14213a;
  --ink-2: #33415a;
  --muted: #64708a;
  --line: #e2e6ee;
  --line-strong: #cbd2de;
  --bg: #f4f6f9;
  --card: #ffffff;

  --danger: #b42318;
  --danger-bg: #fef3f2;
  --danger-line: #fecdca;
  --success: #067647;
  --success-bg: #ecfdf3;
  --success-line: #abefc6;
  --info: #175cd3;
  --info-bg: #eff8ff;
  --info-line: #b2ddff;

  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(11, 33, 64, .06);
  --shadow-md: 0 12px 32px -12px rgba(11, 33, 64, .18), 0 2px 6px rgba(11, 33, 64, .05);

  --font: "IBM Plex Sans Thai", "Noto Sans Thai", "Leelawadee UI", "Segoe UI", Tahoma, sans-serif;
  --font-display: "Noto Serif Thai", "IBM Plex Sans Thai", "Leelawadee UI", serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.65 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, p { margin: 0; }
a { color: var(--navy-600); }
svg { flex: none; }

/* ---------- Logo ---------- */
.logo { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.logo-mark { width: 34px; height: 34px; color: var(--gold); }
.logo-text { font-weight: 600; font-size: 20px; letter-spacing: .14em; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 20px;
  border: 1px solid transparent; border-radius: var(--radius);
  font: 500 16px/1 var(--font); text-decoration: none; cursor: pointer;
  transition: background-color .15s, border-color .15s, box-shadow .15s, color .15s;
}
.btn:focus-visible { outline: 3px solid rgba(197, 160, 89, .55); outline-offset: 2px; }
.btn-primary { background: var(--navy-900); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--navy-700); }
.btn-outline { background: #fff; border-color: var(--line-strong); color: var(--ink); }
.btn-outline:hover { border-color: var(--navy-700); color: var(--navy-700); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: rgba(11, 33, 64, .06); }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: 14px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .65; cursor: progress; }
.btn.is-loading::after {
  content: ""; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
.form { display: grid; gap: 18px; margin-top: 24px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 14px; font-weight: 500; color: var(--ink-2); }
.field input {
  width: 100%; height: 48px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: #fff; color: var(--ink); font: 400 16px/1 var(--font);
  transition: border-color .15s, box-shadow .15s;
}
.field input::placeholder { color: #9aa4b6; }
.field input:hover { border-color: #aab4c6; }
.field input:focus { outline: none; border-color: var(--navy-700); box-shadow: 0 0 0 4px rgba(23, 58, 105, .12); }
.input-group { position: relative; }
.input-group input { padding-right: 68px; }
.input-action {
  position: absolute; top: 4px; right: 4px; height: 40px; padding: 0 12px;
  border: 0; border-radius: 7px; background: transparent;
  color: var(--navy-600); font: 500 14px/1 var(--font); cursor: pointer;
}
.input-action:hover { background: rgba(11, 33, 64, .06); }
.input-action:focus-visible { outline: 2px solid var(--gold); }
.hint { font-size: 13px; color: var(--muted); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }

/* ---------- Alerts ---------- */
.alert {
  display: flex; gap: 10px; align-items: flex-start;
  margin-top: 20px; padding: 12px 14px;
  border: 1px solid; border-radius: var(--radius);
  font-size: 15px; line-height: 1.55;
}
.alert svg { width: 20px; height: 20px; margin-top: 2px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.alert-error { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger); }
.alert-success { background: var(--success-bg); border-color: var(--success-line); color: var(--success); }
.alert-info { background: var(--info-bg); border-color: var(--info-line); color: var(--info); }

.muted { color: var(--muted); }
.eyebrow { font-size: 13px; font-weight: 500; letter-spacing: .16em; text-transform: uppercase; color: var(--gold); }

/* =====================================================================
   หน้า Login
   ===================================================================== */
.auth-shell { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }

.auth-brand {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
  padding: 48px 56px;
  color: #fff;
  background:
    radial-gradient(900px 520px at 110% -10%, rgba(197, 160, 89, .20), transparent 60%),
    radial-gradient(700px 480px at -15% 110%, rgba(47, 107, 184, .35), transparent 60%),
    linear-gradient(160deg, var(--navy-900) 0%, var(--navy-950) 100%);
}
/* ลายเส้นตารางจางๆ */
.auth-brand::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(ellipse at 30% 40%, #000 0%, transparent 72%);
  mask-image: radial-gradient(ellipse at 30% 40%, #000 0%, transparent 72%);
}
.auth-brand > * { position: relative; }
.auth-brand-body { max-width: 520px; }
.brand-headline {
  margin-top: 14px;
  font: 600 clamp(34px, 3.6vw, 48px)/1.3 var(--font-display);
  letter-spacing: -.005em;
}
.brand-lead { margin-top: 18px; font-size: 17px; line-height: 1.75; color: rgba(255, 255, 255, .78); }
.brand-points { list-style: none; margin: 36px 0 0; padding: 28px 0 0; display: grid; gap: 20px; border-top: 1px solid rgba(255, 255, 255, .14); }
.brand-points li { display: flex; gap: 14px; align-items: flex-start; font-size: 15px; line-height: 1.6; color: rgba(255, 255, 255, .74); }
.brand-points svg {
  width: 38px; height: 38px; padding: 8px; border-radius: 10px;
  background: rgba(197, 160, 89, .14); border: 1px solid rgba(197, 160, 89, .32);
  fill: none; stroke: var(--gold-soft); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
.brand-points strong { display: block; font-weight: 500; font-size: 16px; color: #fff; }
.auth-brand-foot { font-size: 13px; color: rgba(255, 255, 255, .5); }

.auth-main {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  padding: 40px 24px;
}
.auth-card {
  width: 100%; max-width: 440px; padding: 40px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.auth-card-logo { display: none; margin-bottom: 22px; color: var(--navy-900); }
.auth-card h1 { margin-top: 16px; font: 600 28px/1.3 var(--font); letter-spacing: -.01em; }
.auth-sub { margin-top: 6px; color: var(--muted); font-size: 15px; }

.org-badge {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  padding: 5px 12px 5px 10px; border-radius: 999px;
  background: #f1f4f9; border: 1px solid var(--line);
  font-size: 14px; font-weight: 500; color: var(--ink-2);
}
.org-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); flex: none; }
.org-badge-admin { background: #fbf6ea; border-color: #ecdcb6; color: #7a5a17; }

.auth-help { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.auth-secure { display: flex; align-items: center; gap: 8px; max-width: 440px; font-size: 13px; color: var(--muted); text-align: left; }
.auth-secure svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

@media (max-width: 960px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-card-logo { display: block; }
  .auth-main { justify-content: flex-start; padding: 32px 16px; background: linear-gradient(180deg, #e9eef6 0, var(--bg) 320px); }
  .auth-card { padding: 28px 22px; }
}

/* =====================================================================
   หน้าในระบบ
   ===================================================================== */
.topbar { background: var(--navy-900); color: #fff; border-bottom: 2px solid var(--gold); }
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 16px; }
.topbar-brand { color: #fff; text-decoration: none; display: inline-flex; }
.topbar .logo-mark { width: 28px; height: 28px; }
.topbar .logo-text { font-size: 17px; }
.topbar-org {
  padding-left: 16px; border-left: 1px solid rgba(255, 255, 255, .2);
  font-size: 14px; color: rgba(255, 255, 255, .78);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.topbar-user-text { display: grid; line-height: 1.3; }
.topbar-user-text strong { font-weight: 500; font-size: 14px; }
.topbar-user-text small { font-size: 12px; color: rgba(255, 255, 255, .62); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(197, 160, 89, .2); border: 1px solid rgba(197, 160, 89, .5); color: var(--gold-soft);
  font-weight: 600; font-size: 14px;
}
.topbar .btn-ghost { color: #fff; border-color: rgba(255, 255, 255, .25); margin-left: 6px; }
.topbar .btn-ghost:hover { background: rgba(255, 255, 255, .1); }

.page { max-width: 1120px; margin: 0 auto; padding: 28px 20px 56px; display: grid; gap: 20px; }
.page-narrow { max-width: 520px; }
.hero h1 { font: 600 30px/1.3 var(--font); letter-spacing: -.01em; }
.hero .muted { margin-top: 4px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow-sm); }
.card h1 { font: 600 24px/1.3 var(--font); }
.card h2 { font: 600 17px/1.4 var(--font); margin-bottom: 12px; }
.card h1 + .muted { margin-top: 6px; }
.card-muted { background: transparent; border-style: dashed; box-shadow: none; }
.card .btn { margin-top: 16px; }
.card .form .btn { margin-top: 0; }
.grid-2 { display: grid; gap: 20px; grid-template-columns: repeat(2, minmax(0, 1fr)); }

.dl { margin: 0; display: grid; }
.dl > div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.dl > div:last-child { border-bottom: 0; }
.dl dt { color: var(--muted); font-size: 14px; flex: none; }
.dl dd { margin: 0; font-size: 15px; text-align: right; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; background: #fbf6ea; border: 1px solid #ecdcb6; color: #7a5a17; font-size: 13px; font-weight: 500; }

.session-list { list-style: none; margin: 0; padding: 0; display: grid; }
.session-list li { display: grid; gap: 2px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.session-list li:last-child { border-bottom: 0; }
.session-list strong { font-weight: 500; font-size: 15px; font-variant-numeric: tabular-nums; }
.session-list small { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }

@media (max-width: 720px) {
  .grid-2 { grid-template-columns: 1fr; }
  .topbar-org, .topbar-user-text { display: none; }
  .hero h1 { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* =====================================================================
   หน้าจอผู้ดูแล
   ===================================================================== */
.subnav { background: var(--navy-800); border-top: 1px solid rgba(255, 255, 255, .08); }
.subnav-inner { max-width: 1120px; margin: 0 auto; padding: 0 20px; display: flex; gap: 4px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.subnav-inner::-webkit-scrollbar { display: none; }
.subnav a {
  padding: 11px 14px; color: rgba(255, 255, 255, .72); text-decoration: none; font-size: 15px; white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.subnav a:hover { color: #fff; }
.subnav a.is-active { color: #fff; font-weight: 500; border-bottom-color: var(--gold); }
.subnav a:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }

.page-medium { max-width: 680px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font: 600 28px/1.3 var(--font); letter-spacing: -.01em; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page > .alert { margin-top: 0; }
.back-link { justify-self: start; color: var(--muted); text-decoration: none; font-size: 14px; }
.back-link:hover { color: var(--navy-700); }

.card-flush { padding: 0; overflow: hidden; }
.card-head { padding: 18px 24px 14px; }
.card-head h2 { margin: 0; }
.count { display: inline-block; margin-left: 6px; padding: 0 8px; border-radius: 999px; background: #eef1f6; color: var(--muted); font-size: 13px; font-weight: 500; }

.toolbar { display: flex; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.toolbar input {
  flex: 1 1 260px; height: 38px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: #fff; color: var(--ink); font: 400 15px/1 var(--font);
}
.toolbar input:focus { outline: none; border-color: var(--navy-700); box-shadow: 0 0 0 4px rgba(23, 58, 105, .12); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th {
  padding: 10px 16px; text-align: left; white-space: nowrap;
  background: #f8f9fb; border-bottom: 1px solid var(--line);
  color: var(--muted); font-size: 13px; font-weight: 500;
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfd; }
.table td small { display: block; font-size: 13px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table code, .dl code { font: 14px/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--ink-2); overflow-wrap: anywhere; }
.row-link { color: var(--navy-700); font-weight: 500; text-decoration: none; }
.row-link:hover { text-decoration: underline; }
.actions-col { text-align: right; white-space: nowrap; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.card .row-actions .btn, .card .toolbar .btn, .page-head .btn { margin-top: 0; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; border: 1px solid; font-size: 13px; font-weight: 500; white-space: nowrap; }
.badge-success { background: var(--success-bg); border-color: var(--success-line); color: var(--success); }
.badge-info { background: var(--info-bg); border-color: var(--info-line); color: var(--info); }
.badge-danger { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger); }
.badge-warning { background: #fffaeb; border-color: #fedf89; color: #93370d; }
.badge-muted { background: #f2f4f7; border-color: var(--line); color: var(--muted); }
.alert-warning { background: #fffaeb; border-color: #fedf89; color: #7a2e0e; }
.alert svg path, .alert svg circle { fill: none; }

.btn-danger-outline { background: #fff; border-color: var(--danger-line); color: var(--danger); }
.btn-danger-outline:hover { background: var(--danger-bg); border-color: var(--danger); }

.empty { padding: 44px 24px; text-align: center; display: grid; gap: 8px; justify-items: center; }
.empty h2 { margin: 0; }
.empty-code { font: 600 44px/1 var(--font-display); color: var(--gold); }

.fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 18px; }
.fieldset + .fieldset { padding-top: 22px; border-top: 1px solid var(--line); }
.fieldset legend { padding: 0; margin-bottom: 14px; font-weight: 600; font-size: 16px; }
.field-row { display: grid; gap: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.optional { color: var(--muted); font-weight: 400; }
.field select {
  width: 100%; height: 48px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: #fff; color: var(--ink); font: 400 16px/1 var(--font);
}
.field select:focus { outline: none; border-color: var(--navy-700); box-shadow: 0 0 0 4px rgba(23, 58, 105, .12); }
.input-affix { display: flex; align-items: stretch; }
.input-affix input { border-top-right-radius: 0; border-bottom-right-radius: 0; min-width: 0; }
.affix {
  display: flex; align-items: center; padding: 0 12px; white-space: nowrap;
  border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 var(--radius) var(--radius) 0;
  background: #f4f6f9; color: var(--muted); font-size: 15px;
}
.form-inline { grid-template-columns: repeat(3, minmax(0, 1fr)) auto; align-items: end; margin-top: 8px; }

.success-head { display: flex; gap: 14px; align-items: flex-start; }
.success-head svg { width: 40px; height: 40px; fill: none; stroke: var(--success); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.cred { margin-top: 22px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cred-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.cred-row:last-child { border-bottom: 0; }
.cred-row-key { background: #fbf6ea; }
.cred-label { color: var(--muted); font-size: 14px; }
.cred-value { font: 15px/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace; overflow-wrap: anywhere; }
.cred-secret { font-size: 19px; font-weight: 600; letter-spacing: .06em; color: var(--navy-900); }
.card .cred .btn { margin-top: 0; min-width: 84px; }
.card > .hint { margin-top: 14px; }
.card > .form-actions { margin-top: 22px; }
.card > .form-actions .btn { margin-top: 0; }

@media (max-width: 720px) {
  .field-row, .form-inline { grid-template-columns: 1fr; }
  .cred-row { grid-template-columns: 1fr auto; }
  .cred-label { grid-column: 1 / -1; }
  .page-head h1 { font-size: 23px; }
}
.sr-only { position: absolute; left: -9999px; top: 0; }

/* ---------- เครดิต / โมเดล ---------- */
.stat-row { display: flex; gap: 40px; flex-wrap: wrap; }
.stat { display: grid; gap: 2px; }
.stat-label { color: var(--muted); font-size: 14px; }
.stat-value { font: 600 28px/1.25 var(--font); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.form-credit { grid-template-columns: 180px 180px minmax(0, 1fr) auto; align-items: end; padding-top: 20px; margin-top: 20px; border-top: 1px solid var(--line); }
.table-inset { margin: 22px -24px -24px; border-top: 1px solid var(--line); }
.field-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.table th br + * , .table th { line-height: 1.45; }
.fieldset legend .optional { font-size: 14px; margin-left: 6px; }
.card > h2 + .muted { margin-top: -6px; }
@media (max-width: 720px) {
  .form-credit, .field-row-3 { grid-template-columns: 1fr; }
}

/* จัดช่องกรอกในแถวเดียวกันให้อยู่ระนาบเดียวกัน แม้บางช่องมีคำอธิบายใต้ช่อง */
.field { align-content: start; }
.field-row { align-items: start; }
/* หัวข้อกลุ่มอยู่ใต้เส้นคั่น ไม่ทับเส้น */
.fieldset legend { float: left; width: 100%; margin-bottom: -4px; }
.field input[readonly] { background: #f4f6f9; color: var(--muted); cursor: not-allowed; }
.card > .form-actions .btn, .card .form .form-actions .btn { margin-top: 0; }
.row-actions .btn { text-decoration: none; }

/* ---------- จัดการองค์กร ---------- */
.quota-cell { min-width: 170px; font-variant-numeric: tabular-nums; }
.quota-cell progress { display: block; width: 100%; max-width: 180px; height: 6px; margin-top: 6px; border: 0; border-radius: 999px; overflow: hidden; background: #e9edf3; appearance: none; -webkit-appearance: none; }
.quota-cell progress::-webkit-progress-bar { background: #e9edf3; }
.quota-cell progress::-webkit-progress-value { background: var(--navy-600); border-radius: 999px; }
.quota-cell progress::-moz-progress-bar { background: var(--navy-600); border-radius: 999px; }
.quota-cell progress.is-over::-webkit-progress-value { background: var(--danger); }
.quota-cell progress.is-over::-moz-progress-bar { background: var(--danger); }
.text-danger { color: var(--danger); font-weight: 500; }
.nowrap { white-space: nowrap; }
.action-list { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.action-list .btn { margin-top: 0; }
.card h2 .badge { margin-left: 8px; vertical-align: 2px; }
.form-dept { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); align-items: start; margin-top: 8px; }
.form-dept .form-actions { grid-column: 1 / -1; }
.stat-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.stat-grid .stat { padding: 18px 22px; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form select, .filters select, .filters input[type="date"] {
  height: 38px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; color: var(--ink); font: 400 15px/1 var(--font);
}
.filters { align-items: end; gap: 12px; }
.filters label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.filters input[type="date"] { flex: none; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; padding: 14px; border-top: 1px solid var(--line); }
.pager .btn { margin-top: 0; text-decoration: none; }
.page-head .btn { text-decoration: none; }
@media (max-width: 720px) { .form-dept { grid-template-columns: 1fr; } }
.card .table .btn { margin-top: 0; text-decoration: none; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 3px; flex: none; accent-color: var(--navy-700); }
.check small { display: block; font-size: 13px; }

/* ---- โมเดล AI: sync ---- */
.sync-form .btn { display: inline-flex; align-items: center; gap: 8px; }
.sync-form svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sync-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.sync-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.sync-list li:first-child { border-top: 0; }
.sync-list small { flex-basis: 100%; overflow-wrap: anywhere; }
.model-filter .btn { margin-top: 0; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.model-filter .count { font-size: 12px; opacity: .75; }

/* ---- SweetAlert2 (ธีม EZAI) ---- */
.btn-danger { background: var(--danger); color: #fff; box-shadow: var(--shadow-sm); }
.btn-danger:hover { background: #912018; }
.ez-swal-container { padding: 16px; }
.ez-swal-container.swal2-backdrop-show { background: rgba(6, 21, 40, .55); }
.swal2-popup.ez-swal {
  width: min(440px, 100%); padding: 28px 24px 24px;
  border-radius: var(--radius-lg); border: 1px solid var(--line);
  box-shadow: var(--shadow-md); font-family: var(--font); color: var(--ink);
}
.ez-swal .swal2-icon { margin: 4px auto 14px; transform: scale(.8); }
.ez-swal .swal2-icon.swal2-question { border-color: var(--navy-600); color: var(--navy-700); }
.ez-swal .swal2-icon.swal2-warning { border-color: #f79009; color: #dc6803; }
.ez-swal-title { padding: 0; font: 600 21px/1.4 var(--font); color: var(--ink); }
.ez-swal-text { margin: 10px 0 0; padding: 0; font: 400 16px/1.65 var(--font); color: var(--ink-2); }
.ez-swal-actions { width: 100%; margin: 24px 0 0; gap: 10px; flex-wrap: nowrap; }
.ez-swal-actions .btn { flex: 1; margin: 0; }
.swal2-popup.ez-toast {
  padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--line);
  box-shadow: var(--shadow-md); font-family: var(--font);
}
.ez-toast-title { font: 500 15px/1.5 var(--font); color: var(--ink); }
.ez-toast .swal2-timer-progress-bar { background: var(--gold); }
@media (max-width: 480px) {
  .ez-swal-actions { flex-direction: column-reverse; }
  .ez-swal-actions .btn { width: 100%; }
}

/* ---- โมเดล AI: ค้นหา / เรียง / แบ่งหน้า ---- */
.model-toolbar { justify-content: space-between; align-items: center; gap: 12px; }
.model-filter { display: flex; gap: 8px; flex-wrap: wrap; }
.model-search { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0; }
.model-search input[type="search"], .model-search select {
  min-height: 38px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  font: 400 14px/1 var(--font); color: var(--ink); background: #fff;
}
.model-search input[type="search"] { width: 220px; }
.model-search input:focus, .model-search select:focus { outline: none; border-color: var(--navy-700); box-shadow: 0 0 0 4px rgba(23, 58, 105, .12); }
.model-search .btn { margin-top: 0; text-decoration: none; }
.sort-link { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
th.num .sort-link { justify-content: flex-end; }
.sort-link:hover, .sort-link.is-active { color: var(--navy-700); }
.sort-arrow { font-size: 11px; opacity: .45; }
.sort-link.is-active .sort-arrow { opacity: 1; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 16px; border-top: 1px solid var(--line); }
.pagination-pages { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pagination-pages .btn { margin-top: 0; min-width: 38px; padding: 0 10px; text-decoration: none; }
.pagination-gap { color: var(--muted); padding: 0 2px; }
@media (max-width: 640px) {
  .model-search input[type="search"] { width: 100%; flex-basis: 100%; }
}
