/* ============================================
   nswaqs-portal — Modern Minimal Directory
   โทนสีราชการยุคใหม่: ฟ้า / น้ำเงิน / เขียวมรกต
   ============================================ */

:root {
  --gov-50: #eff6ff;
  --gov-100: #dbeafe;
  --gov-500: #3b82f6;
  --gov-600: #2563eb;
  --gov-700: #1d4ed8;
  --gov-800: #1e40af;
  --jade-500: #10b981;
  --jade-600: #059669;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f8fafc;
}

html {
  scroll-behavior: smooth;
}

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- Layout helpers ---------- */
.page-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-shell main {
  flex: 1 0 auto;
}

.container-x {
  width: 100%;
  max-width: 72rem;
  margin-inline: auto;
  padding-inline: 1rem;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.85rem;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  color: #fff;
  background: linear-gradient(135deg, var(--gov-700), var(--jade-600));
  box-shadow: 0 6px 16px -6px rgba(29, 78, 216, 0.55);
  flex-shrink: 0;
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  color: #fff;
  background: linear-gradient(135deg, var(--gov-800) 0%, var(--gov-600) 55%, var(--jade-600) 100%);
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.12;
  background-image: radial-gradient(circle at 20% 25%, #fff 1px, transparent 1px);
  background-size: 26px 26px;
  pointer-events: none;
}

.hero > * {
  position: relative;
  z-index: 1;
}

.hero-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(4px);
}

/* ---------- Directory action cards ---------- */
.dir-grid {
  display: grid;
  /* minmax(0,1fr) กัน track ขยายเกินคอนเทนเนอร์ (ทำให้เกิด overflow แนวนอนบนมือถือ) */
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
}

@media (min-width: 640px) {
  .dir-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .dir-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.dir-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  padding: 1.35rem 1.25rem 1.2rem;
  text-decoration: none;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.dir-card:hover,
.dir-card:focus-visible {
  transform: translateY(-4px);
  border-color: var(--gov-500);
  box-shadow: 0 14px 30px -14px rgba(29, 78, 216, 0.35);
  outline: none;
}

.dir-card:active {
  transform: translateY(-1px);
}

.dir-icon {
  width: 3rem;
  height: 3rem;
  border-radius: 0.95rem;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  line-height: 1;
}

.dir-icon--rose { background: #fff1f2; color: #e11d48; }
.dir-icon--jade { background: #ecfdf5; color: #059669; }
.dir-icon--sky  { background: #f0f9ff; color: #0284c7; }
.dir-icon--amber{ background: #fffbeb; color: #d97706; }

.dir-card h3 {
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.4;
}

.dir-card p {
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.6;
  flex: 1;
}

.dir-cta {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--gov-700);
}

.dir-badge {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  background: var(--gov-50);
  color: var(--gov-700);
  border: 1px solid var(--gov-100);
}

.dir-badge--external {
  background: #fffbeb;
  color: #b45309;
  border-color: #fde68a;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.7rem 1.4rem;
  border-radius: 0.85rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--gov-700);
  color: #fff;
  box-shadow: 0 8px 18px -10px rgba(29, 78, 216, 0.8);
}

.btn-primary:hover:not(:disabled) {
  background: var(--gov-800);
}

.btn-light {
  background: #fff;
  color: var(--gov-800);
}

.btn-light:hover {
  background: var(--gov-50);
}

.btn-ghost {
  background: transparent;
  color: var(--gov-700);
  border-color: var(--gov-100);
}

.btn-ghost:hover {
  background: var(--gov-50);
}

/* ---------- Forms ---------- */
.form-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 1.15rem;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

@media (min-width: 768px) {
  .form-card {
    padding: 2rem;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
}

.field label .req {
  color: #e11d48;
  margin-left: 0.15rem;
}

.input,
.select,
.textarea {
  width: 100%;
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 0.7rem;
  padding: 0.62rem 0.85rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.textarea {
  min-height: 5.5rem;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--gov-500);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

.input.invalid,
.select.invalid,
.textarea.invalid {
  border-color: #e11d48;
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.12);
}

.field-error {
  font-size: 0.78rem;
  color: #e11d48;
  min-height: 1rem;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
}

@media (min-width: 640px) {
  .form-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

fieldset.form-section {
  border: 0;
  padding: 0;
  margin: 0;
}

fieldset.form-section + fieldset.form-section {
  margin-top: 1.6rem;
  padding-top: 1.4rem;
  border-top: 1px dashed var(--line);
}

legend.form-legend {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gov-700);
  margin-bottom: 0.9rem;
}

/* radio / checkbox pills */
.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pill {
  position: relative;
}

.pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pill span {
  display: inline-block;
  padding: 0.5rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: #475569;
  background: #f1f5f9;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.pill input:checked + span {
  background: var(--gov-700);
  color: #fff;
  box-shadow: 0 6px 14px -8px rgba(29, 78, 216, 0.9);
}

.pill input:focus-visible + span {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.35);
}

/* honeypot */
.hp-field {
  position: absolute !important;
  left: -9999px !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ---------- Alerts / result ---------- */
.alert {
  border-radius: 0.85rem;
  padding: 0.9rem 1.1rem;
  font-size: 0.9rem;
  line-height: 1.6;
}

.alert-error {
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: #9f1239;
}

.alert-success {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.alert-info {
  background: var(--gov-50);
  border: 1px solid var(--gov-100);
  color: var(--gov-800);
}

/* ---------- Spinner ---------- */
.spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner--dark {
  border-color: rgba(29, 78, 216, 0.25);
  border-top-color: var(--gov-700);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Report / list cards ---------- */
.link-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
}

.link-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0.95rem;
  padding: 0.95rem 1.1rem;
  text-decoration: none;
  color: var(--ink);
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.link-row:hover {
  border-color: var(--gov-500);
  transform: translateX(3px);
  box-shadow: 0 8px 20px -14px rgba(29, 78, 216, 0.5);
}

.link-row .link-ico {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.7rem;
  background: var(--gov-50);
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.link-row .link-title {
  font-weight: 700;
  font-size: 0.95rem;
}

.link-row .link-desc {
  font-size: 0.8rem;
  color: var(--muted);
}

/* stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

@media (min-width: 768px) {
  .stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1.1rem;
  text-align: center;
}

.stat-card .stat-num {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--gov-700);
  line-height: 1.2;
}

.stat-card .stat-label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

/* ---------- Embed wrapper ---------- */
.embed-frame {
  width: 100%;
  flex: 1;
  min-height: 70vh;
  border: 0;
  display: block;
  background: #fff;
}

/* ---------- Footer ---------- */
.site-footer {
  background: var(--ink);
  color: #cbd5e1;
  margin-top: 3rem;
}

.site-footer a {
  color: #94a3b8;
  text-decoration: none;
}

.site-footer a:hover {
  color: #fff;
}

/* ---------- Misc ---------- */
.text-muted { color: var(--muted); }
.mt-0_5 { margin-top: 0.25rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2ee8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 0.7rem;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

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

/* ============================================
   THEME TOGGLE
   ============================================ */
.theme-toggle {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.7rem;
  display: grid;
  place-items: center;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  background: #f1f5f9;
  border: 1px solid var(--line);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--gov-50); border-color: var(--gov-200); }
.theme-toggle:active { transform: scale(0.94); }

/* ============================================
   DARK THEME
   แนวทาง: override ค่าของ utility class ที่ใช้บ่อย
   (Tailwind CDN สร้าง class ตอน runtime — override ด้วย html.dark)
   ============================================ */
html[data-theme="dark"] {
  --gov-50: #0f2747;
  --gov-100: #17395f;
  --gov-700: #60a5fa;
  --gov-800: #93c5fd;
  --jade-500: #34d399;
  --jade-600: #10b981;
  --ink: #e2e8f0;
  --muted: #94a3b8;
  --line: #1e293b;
  --bg: #0b1220;
}

html.dark body { background-color: #0b1220; color: #e2e8f0; }
html.dark .site-header { background: rgba(11, 18, 32, 0.9); border-bottom-color: #1e293b; }

html.dark .bg-white { background-color: #111a2e !important; }
html.dark .bg-slate-50 { background-color: #0b1220 !important; }
html.dark .bg-slate-100 { background-color: #16223b !important; }
html.dark .bg-gov-50, html.dark .bg-gov-100 { background-color: #0f2747 !important; }
html.dark .bg-jade-50 { background-color: #06281f !important; }
html.dark .bg-sky-50 { background-color: #082f49 !important; }
html.dark .bg-rose-50 { background-color: #3b0d1a !important; }
html.dark .bg-amber-50, html.dark .bg-red-50 { background-color: #3a2508 !important; }
html.dark .bg-slate-800, html.dark .bg-slate-900 { background-color: #0b1220 !important; }

html.dark .text-slate-800, html.dark .text-slate-700, html.dark .text-slate-900 { color: #e2e8f0 !important; }
html.dark .text-slate-600 { color: #cbd5e1 !important; }
html.dark .text-slate-500, html.dark .text-slate-400 { color: #94a3b8 !important; }
html.dark .text-gov-800, html.dark .text-gov-700 { color: #7dd3fc !important; }
html.dark .text-jade-700, html.dark .text-jade-600 { color: #6ee7b7 !important; }

html.dark .border-slate-100, html.dark .border-slate-200, html.dark .border-gov-100 {
  border-color: #1e293b !important;
}

html.dark .dir-card,
html.dark .form-card,
html.dark .link-row,
html.dark .stat-card {
  background: #111a2e;
  border-color: #1e293b;
  color: #e2e8f0;
}
html.dark .dir-card:hover { border-color: #3b82f6; }

html.dark .input,
html.dark .select,
html.dark .textarea {
  background: #0f1a2e;
  border-color: #24334d;
  color: #e2e8f0;
}
html.dark .input::placeholder,
html.dark .textarea::placeholder { color: #64748b; }
html.dark .input[readonly] { background: #0b1526; color: #cbd5e1; }

html.dark .field label { color: #cbd5e1; }
html.dark .pill span { background: #16223b; color: #cbd5e1; }
html.dark .pill input:checked + span { background: #2563eb; color: #fff; }

html.dark .alert-info { background: #0f2747; border-color: #17395f; color: #bae6fd; }
html.dark .alert-error { background: #3b0d1a; border-color: #6b1b2e; color: #fecdd3; }
html.dark .alert-success { background: #06281f; border-color: #0f5132; color: #a7f3d0; }

/* nav links */
.nav-link {
  padding: 0.45rem 0.75rem;
  border-radius: 0.6rem;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-link:hover { background: var(--gov-50); color: var(--gov-700); }
.nav-link[aria-current="page"] { background: var(--gov-50); color: var(--gov-700); }
html.dark .nav-link:hover, html.dark .nav-link[aria-current="page"] { background: #16223b; color: #93c5fd; }

html.dark .btn-ghost { color: #93c5fd; border-color: #1e293b; }
html.dark .btn-ghost:hover { background: #16223b; }
html.dark .btn-light { background: #16223b; color: #93c5fd; }

html.dark .site-footer { background: #060c17; }
html.dark .skeleton { background: linear-gradient(90deg, #16223b 25%, #1e2b45 50%, #16223b 75%); background-size: 200% 100%; }
html.dark .link-row .link-ico { background: #16223b; }
html.dark { color-scheme: dark; }

/* ============================================
   UNDER DEVELOPMENT PANEL (feature flag ปิด)
   ============================================ */
.dev-panel {
  background: #fff;
  border: 1px dashed #fbbf24;
  border-radius: 1.15rem;
  padding: 2.2rem 1.5rem;
  text-align: center;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}
.dev-panel .dev-ico {
  width: 4rem;
  height: 4rem;
  margin: 0 auto 1rem;
  border-radius: 1.2rem;
  display: grid;
  place-items: center;
  font-size: 2rem;
  background: #fffbeb;
  border: 1px solid #fde68a;
}
.dev-panel h2 { font-size: 1.35rem; font-weight: 800; color: #92400e; }
.dev-panel p { color: #64748b; margin-top: 0.5rem; line-height: 1.7; }
.dev-panel .dev-tag {
  display: inline-block;
  margin-top: 1rem;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}
html.dark .dev-panel { background: #111a2e; border-color: #b45309; }
html.dark .dev-panel h2 { color: #fcd34d; }
html.dark .dev-panel .dev-ico { background: #3a2508; border-color: #b45309; }
html.dark .dev-panel .dev-tag { background: #3a2508; color: #fcd34d; border-color: #b45309; }

/* badge บนการ์ดไดเรกทอรีเมื่อโมดูลปิด */
.dir-badge--dev {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}
.dir-card[data-under-dev="true"] { opacity: 0.92; }

/* ============================================
   DIRECTION GATE (FMD SAT 1)
   ============================================ */
.gate {
  background: linear-gradient(160deg, #ffffff, #f0f7ff);
  border: 1px solid var(--line);
  border-radius: 1.15rem;
  padding: 1.8rem 1.4rem;
  text-align: center;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}
.gate h2 { font-size: 1.25rem; font-weight: 800; color: var(--gov-800); }
.gate p { color: var(--muted); font-size: 0.9rem; margin-top: 0.4rem; }
.gate-options {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.9rem;
  margin-top: 1.4rem;
}
@media (min-width: 640px) { .gate-options { grid-template-columns: 1fr 1fr; } }
.dir-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 1.4rem 1rem;
  border-radius: 1rem;
  border: 2px solid var(--line);
  background: #fff;
  cursor: pointer;
  transition: all 0.15s ease;
  font: inherit;
}
.dir-btn .dir-arrow { font-size: 1.9rem; line-height: 1; }
.dir-btn .dir-name { font-size: 1.05rem; font-weight: 800; color: var(--ink); }
.dir-btn .dir-sub { font-size: 0.78rem; color: var(--muted); }
.dir-btn:hover { border-color: var(--gov-500); transform: translateY(-2px); }
.dir-btn.active {
  border-color: var(--gov-700);
  background: var(--gov-50);
  box-shadow: 0 10px 24px -14px rgba(29, 78, 216, 0.7);
}
.dir-btn.active .dir-name { color: var(--gov-800); }
html.dark .gate { background: linear-gradient(160deg, #111a2e, #0f2747); }
html.dark .gate h2 { color: #7dd3fc; }
html.dark .dir-btn { background: #0f1a2e; border-color: #24334d; }
html.dark .dir-btn .dir-name { color: #e2e8f0; }
html.dark .dir-btn.active { background: #0f2747; border-color: #3b82f6; }

/* แสดงทิศทางที่เลือกไว้ในหัวฟอร์ม */
.direction-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  background: var(--gov-50);
  color: var(--gov-700);
  border: 1px solid var(--gov-100);
}
.direction-chip[data-direction="เที่ยวลง"] {
  background: #fff7ed;
  color: #c2410c;
  border-color: #fed7aa;
}
html.dark .direction-chip[data-direction="เที่ยวลง"] { background: #3a1f08; color: #fdba74; border-color: #b45309; }

/* ============================================
   LOOKUP BAR + AUTOFILL
   ============================================ */
.lookup-bar {
  background: var(--gov-50);
  border: 1px solid var(--gov-100);
  border-radius: 1rem;
  padding: 1.1rem 1.15rem;
}
.lookup-bar .lookup-row {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.6rem;
}
@media (min-width: 640px) { .lookup-bar .lookup-row { flex-direction: row; } }
.lookup-status { font-size: 0.82rem; margin-top: 0.6rem; }
.autofill-note { font-size: 0.78rem; color: var(--muted); }
.autofill-tag {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--jade-50, #ecfdf5);
  color: #047857;
  border: 1px solid #a7f3d0;
  margin-left: 0.35rem;
}
.field label .auto-dot { color: #059669; font-size: 0.7rem; margin-left: 0.3rem; }
html.dark .lookup-bar { background: #0f2747; border-color: #17395f; }
html.dark .autofill-tag { background: #06281f; color: #6ee7b7; border-color: #0f5132; }

/* items table */
.items-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.items-table th, .items-table td { padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); text-align: left; }
.items-table th { font-weight: 700; color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; }
html.dark .items-table th, html.dark .items-table td { border-color: #1e293b; }

/* ============================================
   TOAST
   ============================================ */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  left: 1rem;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  pointer-events: none;
}
@media (min-width: 640px) { .toast-container { left: auto; width: 22rem; } }
.toast {
  pointer-events: auto;
  width: 100%;
  border-radius: 0.85rem;
  padding: 0.8rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 14px 30px -14px rgba(15, 23, 42, 0.5);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast--in { opacity: 1; transform: translateY(0); }
.toast--info { background: var(--gov-700); color: #fff; }
.toast--success { background: #059669; color: #fff; }
.toast--error { background: #e11d48; color: #fff; }
.toast--warn { background: #d97706; color: #fff; }

/* ============================================
   BRANDING (โลโก้จาก admin) + POPUP ประกาศหน้าแรก
   ============================================ */
.brand-mark img.brand-logo {
  width: 2.2rem;
  height: 2.2rem;
  object-fit: contain;
  display: block;
  border-radius: 0.4rem;
}

.announce-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
}
.announce-box {
  position: relative;
  width: min(34rem, 100%);
  background: #fff;
  border-radius: 1.2rem;
  padding: 1.6rem 1.6rem 1.3rem;
  box-shadow: 0 24px 60px rgba(2, 6, 23, 0.35);
  animation: announce-in 0.22s ease-out;
}
@keyframes announce-in {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
.announce-headline {
  font-size: 1.15rem;
  font-weight: 800;
  color: #1e40af;
  padding-right: 2rem;
}
.announce-body {
  margin-top: 0.75rem;
  white-space: pre-wrap;
  color: #374151;
  font-size: 0.95rem;
  line-height: 1.7;
}
.announce-actions {
  margin-top: 1.1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.announce-close {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  border: 0;
  background: #f1f5f9;
  color: #475569;
  font-size: 0.9rem;
  cursor: pointer;
}
.announce-close:hover { background: #e2e8f0; }
html.dark .announce-box { background: #101a2e; }
html.dark .announce-headline { color: #93c5fd; }
html.dark .announce-body { color: #cbd5e1; }
html.dark .announce-close { background: #1e293b; color: #94a3b8; }

/* ============================================
   ADMIN
   ============================================ */
.admin-card { display: block; }
.admin-shell { max-width: 56rem; margin-inline: auto; }
/* ช่องกรอกรหัสผู้ดูแล (รองรับตัวอักษรและสัญลักษณ์ เช่น DLDAQS@2569) */
.pass-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 26rem;
  margin: 1.2rem auto 0;
  text-align: left;
}
.pass-box .input {
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 0.95rem;
  background: #fff;
}
.toggle-row + .toggle-row { margin-top: 0.6rem; }
.toggle-row .tr-title { font-weight: 700; }
.toggle-row .tr-desc { font-size: 0.8rem; color: var(--muted); }
html.dark .toggle-row { background: #111a2e; border-color: #1e293b; }

/* switch */
.switch { position: relative; display: inline-block; width: 3.2rem; height: 1.8rem; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; cursor: pointer; border-radius: 999px;
  background: #cbd5e1; transition: background 0.2s ease;
}
.switch .slider::before {
  content: ""; position: absolute; height: 1.4rem; width: 1.4rem; left: 0.2rem; top: 0.2rem;
  border-radius: 50%; background: #fff; transition: transform 0.2s ease;
}
.switch input:checked + .slider { background: #059669; }
.switch input:checked + .slider::before { transform: translateX(1.4rem); }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 3px rgba(59,130,246,0.35); }

.officer-row {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 0.9rem; border: 1px solid var(--line); border-radius: 0.85rem; background: #fff;
}
.officer-row + .officer-row { margin-top: 0.5rem; }
.officer-row.is-inactive { opacity: 0.55; }
html.dark .officer-row { background: #111a2e; border-color: #1e293b; }

.btn-sm { padding: 0.45rem 0.85rem; font-size: 0.82rem; border-radius: 0.7rem; }
.btn-danger { background: #e11d48; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #be123c; }
.btn-success { background: #059669; color: #fff; }
.btn-success:hover:not(:disabled) { background: #047857; }

.admin-badge {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.75rem; font-weight: 700; padding: 0.25rem 0.7rem;
  border-radius: 999px; background: #111827; color: #f8fafc;
}
.status-pill { font-size: 0.72rem; font-weight: 700; padding: 0.15rem 0.6rem; border-radius: 999px; }
.status-pill.ok { background: #ecfdf5; color: #047857; }
.status-pill.off { background: #f1f5f9; color: #64748b; }
.status-pill.warn { background: #fffbeb; color: #b45309; }
html.dark .status-pill.off { background: #16223b; color: #94a3b8; }
html.dark .status-pill.ok { background: #06281f; color: #6ee7b7; }
html.dark .status-pill.warn { background: #3a2508; color: #fcd34d; }
