/* ===========================================================================
   DOAE Workforce Dashboard
   ค่าทั้งหมดในไฟล์นี้ยกมาจาก design handoff จริงที่ docs/design/
   (`DOAE อัตรากำลัง.dc.html` + `README.md`) — ไม่ได้เดาจากสเปกย่ออีกแล้ว
   ที่ต่างจากต้นฉบับมีจดไว้เป็นคอมเมนต์ทุกจุด
   =========================================================================== */
@import url('./vendor/sarabun/sarabun.css');

:root {
  --navy: #123b63;
  --deep: #081b30;
  --deep-2: #0b2540;
  --blue: #2f6fa8;
  --blue-dark: #1d4e7a;
  --blue-soft: #5b87b0;
  --teal: #1fa6a6;
  --teal-light: #7fc9c9;
  --teal-pale: #cffaf2;
  --gold: #c9a227;
  --gold-light: #e4c863;
  --gold-pale: #f0d77a;
  --danger: #c0392b;

  --ink: #152535;
  --muted: #5b6773;
  --muted-2: #41505e;
  --app-bg: #eef2f6;
  --caption-bg: #f4f7fa;
  --hairline: #dbe2ea;

  --container: 1320px;
  --shadow-card: 0 5px 18px rgba(18, 59, 99, 0.07);
  --shadow-kpi: 0 6px 20px rgba(18, 59, 99, 0.08);

  /* ── ระบบ accent (4 ส.ค. 69) ───────────────────────────────────────────
     เดิมใช้อุปกรณ์เดียว — แถบสีหนา 3-6px ริมเดียว — ทำ 7 หน้าที่ที่ต่างกันหมด
     (หัวข้อ · การ์ด KPI · คำอธิบายใต้กราฟ · ป้ายกลุ่ม · แถบเตือน · ชิป · ธง)
     ใช้เหมือนกันทุกที่แปลว่ามันไม่ได้บอกอะไรเลย เป็นแค่ของประดับที่บังเอิญมีสี
     ⇒ แยกเป็น 3 อุปกรณ์ตามบทบาท โดยคงความหมายของสีไว้เท่าเดิม:
       1. คีย์ไลน์ (เส้นสั้นเหนือเนื้อหา) = accent เชิงโครงสร้างของหัวข้อ/การ์ด
       2. กรอบเส้นเดี่ยว + พื้นอ่อน      = โน้ต/คำเตือน — ทั้งผืนสื่อความหมาย
       3. สีที่ตัวหนังสือ                 = ชิปและป้ายกลุ่ม — สีอยู่กับข้อความ */
  --keyline-w: 26px;
  --keyline-h: 2px;
  --tint-teal: rgba(31, 166, 166, 0.07);
  --tint-gold: rgba(201, 162, 39, 0.09);
  --tint-danger: rgba(192, 57, 43, 0.07);
  --ring-teal: rgba(31, 166, 166, 0.28);
  --ring-gold: rgba(201, 162, 39, 0.34);
  --ring-danger: rgba(192, 57, 43, 0.3);
}

/* อุปกรณ์ที่ 1 — คีย์ไลน์ ใช้ร่วมกันทุกที่ที่เคยเป็นแถบหนา */
.section-title::before,
.kpi-card::before {
  content: '';
  display: block;
  width: var(--keyline-w);
  height: var(--keyline-h);
  border-radius: 1px;
  background: var(--accent, var(--gold));
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Sarabun, Tahoma, sans-serif;
  background: var(--app-bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font-family: inherit;
}

a {
  color: var(--teal);
}

a:hover {
  color: var(--navy);
}

:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

/* ── แอนิเมชันร่วม (ยกจากต้นฉบับ) ─────────────────────────────── */
@keyframes gradShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes drift1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, -30px) scale(1.08); }
}
@keyframes drift2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-50px, 35px) scale(1.12); }
}
@keyframes drift3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(30px, 40px) scale(1.06); }
}
@keyframes pulseGlow {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.7; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes floatUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── โลโก้ SVG: keyframes ย้ายออกมาจาก <style> ที่ฝังใน SVG ────
   จำเป็นเพราะ CSP ตั้ง style-src 'self' (ไม่มี unsafe-inline) */
@keyframes N_breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.045); } }
.N_breathe { animation: N_breathe 4s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
@keyframes N_pulse { 0%, 100% { opacity: 0.3; transform: scale(1); } 50% { opacity: 0.75; transform: scale(1.2); } }
.N_glow { animation: N_pulse 2.4s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
@keyframes N_nd { 0%, 100% { opacity: 0.85; } 50% { opacity: 1; } }
.N_node { animation: N_nd 1.8s ease-in-out infinite; }
@keyframes N_tglow {
  0%, 100% { filter: drop-shadow(0 0 1px rgba(127, 224, 208, 0.25)); }
  50% { filter: drop-shadow(0 0 8px rgba(127, 224, 208, 0.7)); }
}
.N_tglow { animation: N_tglow 3s ease-in-out infinite; }
@keyframes N_tw { 0%, 100% { opacity: 0.15; } 50% { opacity: 1; } }
.N_tw { animation: N_tw 1.7s ease-in-out infinite; }
.N_tw2 { animation: N_tw 1.7s ease-in-out 0.5s infinite; }
.N_tw3 { animation: N_tw 1.7s ease-in-out 1s infinite; }
@keyframes N_spin { to { transform: rotate(360deg); } }
.N_ring { animation: N_spin 10s linear infinite; transform-origin: center; transform-box: fill-box; }
.N_ring2 { animation: N_spin 26s linear infinite reverse; transform-origin: center; transform-box: fill-box; }
@keyframes N_halo { 0%, 100% { opacity: 0.08; transform: scale(0.9); } 50% { opacity: 0.22; transform: scale(1.06); } }
.N_halo { animation: N_halo 3.5s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }

@keyframes M_breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.045); } }
.M_breathe { animation: M_breathe 4s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
@keyframes M_pulse { 0%, 100% { opacity: 0.3; transform: scale(1); } 50% { opacity: 0.75; transform: scale(1.2); } }
.M_glow { animation: M_pulse 2.4s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
@keyframes M_nd { 0%, 100% { opacity: 0.85; } 50% { opacity: 1; } }
.M_node { animation: M_nd 1.8s ease-in-out infinite; }
@keyframes M_tglow {
  0%, 100% { filter: drop-shadow(0 0 1px rgba(127, 224, 208, 0.25)); }
  50% { filter: drop-shadow(0 0 8px rgba(127, 224, 208, 0.7)); }
}
.M_tglow { animation: M_tglow 3s ease-in-out infinite; }
@keyframes M_tw { 0%, 100% { opacity: 0.15; } 50% { opacity: 1; } }
.M_tw { animation: M_tw 1.7s ease-in-out infinite; }
.M_tw2 { animation: M_tw 1.7s ease-in-out 0.5s infinite; }
.M_tw3 { animation: M_tw 1.7s ease-in-out 1s infinite; }
@keyframes M_spin { to { transform: rotate(360deg); } }
.M_ring { animation: M_spin 10s linear infinite; transform-origin: center; transform-box: fill-box; }
.M_ring2 { animation: M_spin 26s linear infinite reverse; transform-origin: center; transform-box: fill-box; }
@keyframes M_halo { 0%, 100% { opacity: 0.08; transform: scale(0.9); } 50% { opacity: 0.22; transform: scale(1.06); } }
.M_halo { animation: M_halo 3.5s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }

.logo-svg { width: auto; overflow: visible; display: block; }
.logo-svg-login { height: 118px; }
.logo-svg-header { height: 78px; }

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }
}

/* ═══════════════════════ หน้าเข้าสู่ระบบ ═══════════════════════ */

#login-screen {
  min-height: 100vh;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, var(--deep), var(--navy) 45%, var(--blue-dark) 80%);
  overflow: hidden;
}

.login-blob {
  position: absolute;
  border-radius: 50%;
}

.login-blob-1 {
  width: 520px;
  height: 520px;
  background: radial-gradient(circle, rgba(31, 166, 166, 0.35), transparent 70%);
  top: -140px;
  left: -120px;
  filter: blur(10px);
  animation: drift1 16s ease-in-out infinite;
}

.login-blob-2 {
  width: 460px;
  height: 460px;
  background: radial-gradient(circle, rgba(201, 162, 39, 0.25), transparent 70%);
  bottom: -140px;
  right: -100px;
  filter: blur(10px);
  animation: drift2 20s ease-in-out infinite;
}

.login-blob-3 {
  width: 340px;
  height: 340px;
  background: radial-gradient(circle, rgba(47, 111, 168, 0.3), transparent 70%);
  top: 40%;
  right: 12%;
  filter: blur(8px);
  animation: drift3 18s ease-in-out infinite;
}

/* เดิมเป็นกริดเส้นทับพื้นหลัง login — เอาออก 4 ส.ค. 69
   ขาว 4% คูณ opacity 0.5 = ราว 2% บนพื้นน้ำเงินเข้ม ตาแทบไม่เห็น และ screenshot ต้นฉบับที่
   docs/design/screenshots/01-login.png ก็ไม่มีกริดให้เห็นเลย ⇒ ลบแล้วหน้าตาเท่าเดิมทุกพิกเซลที่คนเห็น
   แต่ตัดลายเซ็นกริดประดับซึ่งเป็นแพตเทิร์นซ้ำของ UI ที่เครื่องสร้างออกไปได้
   (README ของ handoff เขียนว่า "กริดจุด" ส่วนโค้ดเดิมทำเป็นเส้น — ไม่ตรงกันอยู่แล้วตั้งแต่ต้น) */

.login-card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 420px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 24px;
  padding: 34px 32px 28px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.35);
  animation: floatUp 0.7s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.login-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  text-align: center;
}

.login-title {
  color: #fff;
  font-weight: 700;
  font-size: 16px;
}

.login-subtitle {
  color: rgba(255, 255, 255, 0.7);
  font-size: 12.5px;
  margin-top: 2px;
}

.internal-note {
  display: block;
  text-align: center;
  background: rgba(192, 57, 43, 0.22);
  border: 1px solid rgba(192, 57, 43, 0.45);
  color: #ffd4cd;
  font-size: 11.5px;
  padding: 5px 12px;
  border-radius: 20px;
  margin-bottom: 20px;
}

.field {
  position: relative;
  margin-bottom: 22px;
}

.field-tight {
  margin-bottom: 8px;
}

.field input {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 12px;
  padding: 18px 14px 8px;
  color: #fff;
  font-size: 15px;
  outline: none;
}

.field input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(31, 166, 166, 0.28), 0 6px 18px rgba(31, 166, 166, 0.18);
}

.field label {
  position: absolute;
  left: 14px;
  pointer-events: none;
  color: rgba(255, 255, 255, 0.7);
  transition: 0.2s ease;
  font-size: 15px;
  top: 16px;
}

.field input:focus + label,
.field input:not(:placeholder-shown) + label {
  color: rgba(255, 255, 255, 0.55);
  font-size: 11px;
  top: 7px;
}

/* แถบเตือนรหัสทดสอบ — อยู่ในแถบที่ล็อกไว้บนสุด จะได้เลื่อนหนีไม่ได้ */
.weakbar {
  margin: 0;
  padding: 7px 24px;
  background: var(--danger);
  color: #fff;
  font-size: 12.5px;
  text-align: center;
}

.weakbar code {
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 12px;
}

/* ── ปุ่มดวงตา: เปิด/ปิดการมองเห็นรหัสผ่าน ─────────────────────── */
/* เว้นที่ให้ปุ่มก่อน ไม่งั้นรหัสยาว ๆ จะวิ่งไปอยู่ใต้ปุ่ม */
.field-reveal input {
  padding-right: 50px;
}

.reveal {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: rgba(255, 255, 255, 0.62);
  cursor: pointer;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}

.reveal:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.28);
}

.reveal:focus-visible {
  outline: none;
  color: #fff;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(31, 166, 166, 0.32);
}

/* ตอนกำลังเปิดให้เห็นรหัส ปุ่มติดสีไว้ เพื่อไม่ให้ลืมว่ารหัสโชว์อยู่บนจอ */
.reveal[aria-pressed='true'] {
  color: var(--teal-light);
}

/* สลับไอคอนด้วย aria-pressed ตัวเดียว — สถานะที่คนเห็นกับที่ screen reader อ่านจึงหลุดจากกันไม่ได้ */
.reveal .icon-eye-off,
.reveal[aria-pressed='true'] .icon-eye {
  display: none;
}

.reveal[aria-pressed='true'] .icon-eye-off {
  display: block;
}

.login-error {
  color: #ff9d91;
  font-size: 12.5px;
  margin: 6px 0 4px;
}

.login-forgot {
  display: flex;
  justify-content: flex-end;
  margin: 8px 0 20px;
}

.login-forgot button {
  background: none;
  border: 0;
  padding: 0;
  color: #9fd6d6;
  font-size: 12.5px;
  cursor: pointer;
}

.login-forgot button:hover {
  text-decoration: underline;
}

.login-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--teal), var(--blue));
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(31, 166, 166, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.25s, box-shadow 0.25s, filter 0.25s;
}

.login-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 16px 38px rgba(31, 166, 166, 0.55);
  filter: brightness(1.06);
}

.login-btn:active {
  transform: translateY(0);
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

.login-foot {
  text-align: center;
  color: rgba(255, 255, 255, 0.45);
  font-size: 11.5px;
  margin-top: 18px;
}

.login-credit {
  text-align: center;
  color: rgba(255, 255, 255, 0.4);
  font-size: 11px;
  margin-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 10px;
}

/* ═══════════════════════ โครงหน้าแอป ═══════════════════════ */

#app {
  animation: fadeIn 0.5s ease;
}

#stickytop {
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: 0 8px 22px rgba(8, 27, 48, 0.16);
}

.app-header {
  position: relative;
  overflow: hidden;
  color: #fff;
  padding: 22px 0 0;
  background: linear-gradient(120deg, var(--deep), var(--navy) 45%, var(--blue-dark) 75%, var(--blue));
  background-size: 220% 220%;
  animation: gradShift 18s ease infinite;
}

.app-header::before {
  content: '';
  position: absolute;
  right: -90px;
  top: -90px;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(31, 166, 166, 0.3), transparent 70%);
  animation: pulseGlow 6s ease-in-out infinite;
}

.header-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
  position: relative;
  z-index: 2;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: nowrap;
  gap: 14px;
}

.header-brand {
  display: flex;
  gap: 14px;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
}

/* min-width:0 จำเป็นทั้งสองชั้น — ไม่งั้นข้อความในหัวไม่ยอมย่อ
   แล้วโดน overflow:hidden ของ header ตัดหายบนจอแคบ (เห็นเป็นชื่อเรื่องขาด) */
.header-titles {
  min-width: 0;
}

.header-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  max-width: 100%;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 5px 13px;
  border-radius: 20px;
  font-size: 12px;
  margin-bottom: 10px;
  backdrop-filter: blur(4px);
}

.header-chip select {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 12px;
}

.header-chip select option {
  color: var(--ink);
}

.app-header h1 {
  font-size: clamp(18px, 3.2vw, 25px);
  font-weight: 800;
  margin: 0;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.header-subtitle {
  opacity: 0.85;
  margin: 6px 0 0;
  font-size: 14px;
}

.header-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  flex: 0 0 auto;
}

.exportbtn,
.logoutbtn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 11px;
  cursor: pointer;
  font-weight: 600;
}

.exportbtn::before,
.logoutbtn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -130%;
  width: 55%;
  height: 100%;
  background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transform: skewX(-20deg);
  transition: left 0.6s ease;
  pointer-events: none;
}

.exportbtn:hover::before,
.logoutbtn:hover::before {
  left: 155%;
}

.exportbtn {
  background: rgba(255, 255, 255, 0.1);
  color: var(--gold-pale);
  border: 1px solid rgba(228, 200, 99, 0.45);
  padding: 7px 13px;
  font-size: 12px;
  transition: transform 0.22s cubic-bezier(0.2, 0.7, 0.3, 1), background 0.22s, border-color 0.22s, box-shadow 0.22s;
  box-shadow: 0 2px 8px rgba(8, 27, 48, 0.16);
}

.exportbtn:hover {
  transform: translateY(-1px);
  background: rgba(228, 200, 99, 0.2);
  border-color: rgba(240, 215, 122, 0.75);
}

.exportbtn:active {
  transform: translateY(0) scale(0.97);
}

.exportbtn svg {
  transition: transform 0.3s;
}

.exportbtn:hover svg {
  transform: scale(1.1);
}

.logoutbtn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  padding: 8px 15px;
  gap: 8px;
  font-size: 12.5px;
  transition: transform 0.25s cubic-bezier(0.2, 0.7, 0.3, 1), background 0.25s, border-color 0.25s, box-shadow 0.25s;
  box-shadow: 0 4px 12px rgba(8, 27, 48, 0.2);
}

.logoutbtn:hover {
  transform: translateY(-2px);
  background: linear-gradient(135deg, rgba(192, 57, 43, 0.55), rgba(192, 57, 43, 0.32));
  border-color: rgba(255, 150, 140, 0.7);
  box-shadow: 0 9px 22px rgba(192, 57, 43, 0.4);
}

.logoutbtn:active {
  transform: translateY(0) scale(0.95);
}

.logoutbtn svg {
  transition: transform 0.3s;
}

.logoutbtn:hover svg {
  transform: translateX(3px);
}

/* แท็บสลับมุมมอง */
/* ปุ่มกว้างตามข้อความของตัวเอง ไม่หารเท่ากัน — ป้ายยาวไม่เท่ากันมาก (33 ตัวอักษร ถึง 6)
   ของเดิม `flex: 1` หารช่องเท่ากัน พอ admin เห็นครบ 5 แท็บจึงเหลือปุ่มละ 248px
   ⇒ ป้ายไทยพับบรรทัดแล้วทุกปุ่มถูกยืดสูงตาม รวมถึงปุ่ม "ผู้ใช้" ที่มี 6 ตัวอักษร
   ไทยไม่มีช่องว่างระหว่างคำ จุดตัดบรรทัดจึงคุมไม่ได้ ("...ระดับ" / "สูง")
   เนื้อจริงรวมกัน 908px ใน 1,272px ที่มี ⇒ แถวเดียวถึง 1024px แล้วค่อยตกแถวสอง */
.view-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.view-tab {
  flex: 0 1 auto;
  padding: 11px 18px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.25s;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.view-tab.active {
  background: #fff;
  color: var(--navy);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}

.view-tab:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* แถบ quick-nav */
.quicknav {
  background: rgba(238, 242, 246, 0.97);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hairline);
}

.quicknav-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 9px 24px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.navchip {
  flex: 0 0 auto;
  white-space: nowrap;
  background: #fff;
  border: 1px solid var(--hairline);
  color: var(--navy);
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 15px;
  border-radius: 20px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.22s cubic-bezier(0.2, 0.7, 0.3, 1), background 0.22s, color 0.22s, border-color 0.22s,
    box-shadow 0.22s;
  box-shadow: 0 2px 7px rgba(18, 59, 99, 0.07);
}

.navchip::before {
  content: '';
  position: absolute;
  top: 0;
  left: -120%;
  width: 55%;
  height: 100%;
  background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: skewX(-20deg);
  transition: left 0.55s ease;
  pointer-events: none;
}

.navchip:hover::before {
  left: 150%;
}

.navchip:hover {
  background: linear-gradient(135deg, var(--teal), var(--blue));
  color: #fff;
  border-color: transparent;
  transform: translateY(-2px);
  box-shadow: 0 9px 22px rgba(31, 166, 166, 0.42);
}

.navchip:active {
  transform: translateY(0) scale(0.96);
}

/* ── เนื้อหา ─────────────────────────────────────────────────── */

main {
  max-width: var(--container);
  margin: 0 auto;
  padding: 26px 24px 50px;
}

.section {
  scroll-margin-top: 70px;
  animation: floatUp 0.5s ease backwards;
}

.section + .section {
  margin-top: 32px;
}

.section-title {
  font-size: 19px;
  font-weight: 800;
  color: var(--navy);
  margin-bottom: 16px;
}

.section-title::before {
  margin-bottom: 9px;
}

.section-title.tight {
  margin-bottom: 5px;
}

.section-lead {
  font-size: 12.5px;
  color: var(--muted);
  margin: 0 0 16px 19px;
}

/* ขอบเขตของหมวดที่ครอบไม่ถึงทั้งกรม — ต้องอ่านได้จากหัวข้อโดยไม่ต้องลงไปอ่านคำอธิบาย
   (การ์ดกรอบตำแหน่งนับข้าราชการอย่างเดียว คนกวาดตาผ่านจะเข้าใจว่าเป็นยอดรวมทั้งกรม)
   เกาะไปกับหัวข้อแต่ไม่แย่งน้ำหนัก จึงเบากว่าหนึ่งขั้นและตัวเล็กลงชัดเจน */
.section-title .scope-note {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  margin-inline-start: 6px;
  white-space: nowrap;
}

/* หัวข้อย่อยในหมวดที่มีของสองชั้นซึ่ง**มาคนละที่มา** (เช่น โครงกรอบ vs การครองตำแหน่ง)
   อยู่ระหว่าง .section-title 19px กับ .card h3 15px — ต้องอ่านออกว่าเป็นคนละก้อน
   ไม่ใช่รายการต่อกัน แต่ต้องไม่แย่งน้ำหนักกับหัวหมวด */
.subhead {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
  margin: 18px 0 8px;
}

.subhead:first-of-type {
  margin-top: 4px;
}

.grid {
  display: grid;
  gap: 18px;
}

/* min(…,100%) กันคอลัมน์กว้างเกินจอมือถือแล้วหน้าเลื่อนซ้ายขวา */
.grid-kpi {
  grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(min(430px, 100%), 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
}

.grid-3-narrow {
  grid-template-columns: repeat(auto-fit, minmax(min(290px, 100%), 1fr));
}

/* การ์ด */
.card {
  background: #fff;
  border-radius: 16px;
  padding: 19px 19px 15px;
  box-shadow: var(--shadow-card);
  transition: transform 0.3s, box-shadow 0.3s;
}

.card-hover:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 32px rgba(18, 59, 99, 0.16);
}

.card h3 {
  margin: 0 0 3px;
  font-size: 15px;
  font-weight: 700;
}

.card-note {
  font-size: 12.5px;
  color: var(--muted);
  margin: 0 0 10px;
}

.card-note b {
  color: var(--teal);
}

/* กล่องสรุปใต้กราฟ — ต้นฉบับใส่ข้อความตีความ ที่นี่ใส่ได้แต่ "ข้อเท็จจริงจากตัวเลข"
   เพราะกฎเหล็กข้อ 3 ของสเปกห้ามระบบให้ความเห็นแทนคน */
/* อุปกรณ์ที่ 2 — กรอบเส้นเดี่ยว + พื้นอ่อน: ทั้งผืนสื่อความหมาย ไม่ต้องมีแถบหนาริมเดียว */
.chart-caption {
  margin-top: 11px;
  font-size: 12px;
  color: var(--muted-2);
  background: var(--tint-teal);
  border: 1px solid var(--ring-teal);
  border-radius: 10px;
  padding: 8px 11px;
  line-height: 1.45;
}

/* ป้ายบอกว่าตัวเลขของชุดนี้มีของจากชั้นแก้มือปนอยู่ (M8.5)
   ตั้งใจให้เป็น "หมายเหตุที่อ่านเจอ" ไม่ใช่คำเตือนสีแดง — ของแก้มือไม่ใช่ความผิดพลาด
   แต่เป็นของที่มีที่มาต่างจากตัวเลขรอบตัว จึงใช้โทนเดียวกับแถบเตือนอ่อนของระบบ */
.correction-bar {
  margin: 0 0 14px;
  padding: 9px 13px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted-2);
  background: var(--tint-gold);
  border: 1px solid var(--ring-gold);
  border-radius: 10px;
}

/* ปุ่มที่อ่านเป็นลิงก์ในประโยค — ยังเป็น <button> จริงเพื่อให้คีย์บอร์ด/เครื่องอ่านหน้าจอใช้ได้ */
.linklike {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--teal);
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

.linklike:hover {
  color: var(--navy);
}

.linklike:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ข้อความที่เป็นรายการหลายบรรทัด (ช่วงเวลาละบรรทัด · ตัวอย่างแถวก่อนนำเข้า)
   เดิมคั่นด้วย "|" ยาวติดกันจนหาไม่เจอว่าตัวเลขไหนของอะไร
   ใช้ `pre-line` ไม่ใช่ `pre` เพราะยังต้องให้ห่อบรรทัดเองได้เมื่อจอแคบ */
.lines {
  white-space: pre-line;
}

.chart-caption.danger {
  background: var(--tint-danger);
  border-color: var(--ring-danger);
}

.chart-caption.warn {
  background: var(--tint-gold);
  border-color: var(--ring-gold);
}

.card-foot {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 9px;
  border-top: 1px dashed var(--hairline);
  padding-top: 8px;
}

/* ปุ่มสลับชุดข้อมูลในการ์ด */
.toggle-group {
  display: flex;
  gap: 6px;
  margin: 0 0 10px;
  flex-wrap: wrap;
}

.toggle-btn {
  padding: 4px 12px;
  border-radius: 16px;
  border: 1px solid var(--hairline);
  background: #fff;
  color: var(--navy);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
}

.toggle-btn:hover:not(.active) {
  background: var(--caption-bg);
  border-color: var(--teal);
}

.toggle-btn.active {
  background: linear-gradient(135deg, var(--teal), var(--blue));
  border-color: transparent;
  color: #fff;
}

/* แถวปุ่มรอง (ตัวกรอง) — ให้ดูเบากว่าแถวเลือกรูปแบบด้านบน */
.toggle-group-sub {
  margin-top: -4px;
}

.toggle-group-sub .toggle-btn {
  font-size: 11.5px;
  padding: 3px 10px;
  background: var(--caption-bg);
}

.toggle-group-sub .toggle-btn.active {
  background: var(--navy);
  color: #fff;
}

/* KPI */
.kpi-card {
  --accent: var(--teal);
  background: #fff;
  border-radius: 16px;
  padding: 18px 16px;
  box-shadow: var(--shadow-kpi);
  animation: floatUp 0.5s ease backwards;
  transition: transform 0.3s cubic-bezier(0.2, 0.7, 0.3, 1), box-shadow 0.3s;
}

.kpi-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 16px 34px rgba(18, 59, 99, 0.18);
}

/* การ์ดที่กดดูรายละเอียดได้ — เป็น <button> จริง ต้องล้างสไตล์ปุ่มของเบราว์เซอร์ให้หมด
   ไม่งั้นได้ขอบ/ฟอนต์/การจัดชิดกลางของปุ่มมาทับการ์ด */
.kpi-drillable {
  border: none;
  font: inherit;
  text-align: inherit;
  width: 100%;
  cursor: pointer;
}
.kpi-drillable:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

.kpi-value {
  font-size: clamp(21px, 4.4vw, 28px);
  font-weight: 800;
  color: var(--navy);
  line-height: 1.15;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.kpi-label {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 4px;
}

/* view 2 ใช้ KPI สีต่างกันต่อใบตามภาพ 03-view2-hr.png (navy / teal / แดง / ทอง)
   ตัวเลขในการ์ดใช้สีเดียวกับขอบบน — ต้นฉบับทำแบบนี้เพื่อให้แยกใบได้จากหางตา */
.kpi-card::before { margin-bottom: 12px; }
.kpi-card.tone-navy { --accent: var(--navy); }
.kpi-card.tone-blue { --accent: var(--blue); }
.kpi-card.tone-teal { --accent: var(--teal); }
.kpi-card.tone-danger { --accent: var(--danger); }
.kpi-card.tone-gold { --accent: var(--gold); }
.kpi-card.tone-navy .kpi-value { color: var(--navy); }
.kpi-card.tone-blue .kpi-value { color: var(--blue); }
.kpi-card.tone-teal .kpi-value { color: var(--teal); }
.kpi-card.tone-danger .kpi-value { color: var(--danger); }
/* ทองบนพื้นขาวคอนทราสต์ไม่ถึงเกณฑ์อ่าน — ใช้โทนเข้มกว่าเฉพาะตัวเลข ขอบบนยังทองตามแบบ */
.kpi-card.tone-gold .kpi-value { color: #7a6114; }

/* ── แถบตัวกรอง view 2 ─────────────────────────────────────────── */
.filterbar {
  background: #fff;
  border-radius: 16px;
  padding: 13px 18px;
  margin-bottom: 22px;
  box-shadow: 0 4px 16px rgba(18, 59, 99, 0.07);
}

.filterbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.filterbar-row-basis {
  margin-top: 11px;
  padding-top: 11px;
  border-top: 1px solid var(--hairline);
}

.filterbar-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.filter-field {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
}

.filter-field select {
  max-width: 260px;
  padding: 6px 10px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}

.filter-field select:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
}

/* ── ช่องเลือกที่ค้นหาได้ (combobox.js) ─────────────────────────── */
.combo {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.combo-input {
  width: 260px;
  max-width: 100%;
  padding: 6px 26px 6px 10px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  cursor: text;
}

.combo-input:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
}

.combo-caret {
  position: absolute;
  right: 7px;
  padding: 0;
  border: 0;
  background: none;
  font-size: 11px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

.combo-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 60;
  min-width: 100%;
  max-width: 380px;
  max-height: 320px;
  overflow-y: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(18, 59, 99, 0.16);
}

/* หัวข้อกลุ่มต้องอ่านออกทันทีว่าเป็น "หัวข้อ" ไม่ใช่ตัวเลือก (Jack สั่ง 2 ส.ค.) */
/* อุปกรณ์ที่ 3 — สีอยู่ที่ตัวหนังสือ: ป้ายกลุ่มไม่ต้องเป็นกล่อง แค่ต้องอ่านออกว่าเป็นหัวข้อ */
.combo-group {
  margin: 10px 0 2px;
  padding: 4px 10px 5px;
  border-bottom: 1px solid var(--hairline);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--navy);
}

.combo-group:first-child {
  margin-top: 0;
}

/* ตัวเลือกที่อยู่ใต้หัวข้อ — ย่อหน้าเข้าไปให้เห็นชั้นความสัมพันธ์ */
.combo-option {
  margin-left: 6px;
}

.combo-option {
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}

.combo-option.is-active {
  background: var(--caption-bg);
}

.combo-option.is-selected {
  font-weight: 700;
  color: var(--navy);
}

.combo-empty {
  padding: 8px 10px;
  font-size: 12.5px;
  color: var(--muted);
}

.filter-clear {
  margin-left: auto;
  padding: 6px 14px;
  border: 1px solid var(--hairline);
  border-radius: 16px;
  background: #fff;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--navy);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.filter-clear:hover {
  background: var(--caption-bg);
  border-color: var(--blue-soft);
}

.filterbar-note {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

/* ป้ายกำกับขอบเขตข้างหัวข้อ section (Jack 2 ส.ค.) — เนื้อหาไม่ได้ตามตัวกรอง ต้องบอกก่อนอ่าน */
.scope-badge {
  display: inline-block;
  vertical-align: 2px;
  margin-left: 8px;
  padding: 2px 10px;
  border: 1px solid var(--gold);
  border-radius: 12px;
  background: #fdf8e7;
  font-size: 11.5px;
  font-weight: 600;
  color: #7a6114;
  white-space: nowrap;
}

.filterbar-count {
  margin: 0 0 0 auto;
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

/* แถบข้อเท็จจริงใต้ section — ข้อความมาจากตัวเลขเท่านั้น ไม่ใช่ข้อสรุปของระบบ */
.factbar {
  margin: 16px 0 0;
  padding: 12px 16px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 3px 12px rgba(18, 59, 99, 0.06);
  font-size: 12.5px;
  color: var(--muted-2);
}

.factbar-danger {
  background: var(--tint-danger);
  border: 1px solid var(--ring-danger);
  color: var(--muted-2);
}

.factbar b {
  color: var(--navy);
}

/* กราฟที่กดเข้าไปดูรายชื่อได้ — บอกด้วยเคอร์เซอร์ว่ากดได้ */
.chart-wrap.drillable canvas {
  cursor: pointer;
}

/* ── ลิ้นชักรายชื่อ (drill) ────────────────────────────────────── */
.drill[hidden] {
  display: none;
}

.drill {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  justify-content: flex-end;
}

.drill-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 27, 48, 0.45);
  animation: fadeIn 0.2s ease;
}

.drill-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(980px, 96vw);
  height: 100%;
  background: #fff;
  box-shadow: -18px 0 42px rgba(8, 27, 48, 0.28);
  animation: slideIn 0.25s cubic-bezier(0.2, 0.7, 0.3, 1);
}

@keyframes fadeIn {
  from { opacity: 0; }
}

@keyframes slideIn {
  from { transform: translateX(40px); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .drill-backdrop,
  .drill-panel {
    animation: none;
  }
}

.drill-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 22px 12px;
  border-bottom: 1px solid var(--hairline);
}

.drill-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  color: var(--navy);
}

.drill-cond {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.drill-close {
  margin-left: auto;
  width: 34px;
  height: 34px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: #fff;
  font-size: 15px;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.drill-close:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.drill-meta {
  margin: 0;
  padding: 9px 22px;
  background: var(--caption-bg);
  font-size: 12.5px;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}

/* ─── แถบ "อะไรเปลี่ยนไป" (M7) ─────────────────────────────────── */

.diff-head {
  align-items: flex-end;
  gap: 14px;
  margin-bottom: 12px;
}

.diff-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.diff-chip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 150px;
  padding: 10px 14px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow-card);
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.diff-chip:hover:not(:disabled):not(.diff-chip-static) {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(8, 27, 48, 0.12);
}

.diff-chip:disabled,
.diff-chip-static {
  cursor: default;
}

.diff-chip:disabled {
  opacity: 0.55;
}

/* สีของชิปย้ายไปอยู่ที่ตัวเลข ซึ่งเป็นสิ่งที่คนอ่านจริง ไม่ใช่ที่ขอบกล่อง */
.diff-chip.tone-teal .diff-chip-value { color: var(--teal); }
.diff-chip.tone-danger .diff-chip-value { color: var(--danger); }
.diff-chip.tone-navy .diff-chip-value { color: var(--navy); }
.diff-chip.tone-gold .diff-chip-value { color: #7a6114; }

.diff-chip-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

.diff-chip-label {
  font-size: 12px;
  color: var(--muted);
}

/* ─── ค้นหา / เลือกดู ในลิ้นชัก (Jack 31 ก.ค.) ─────────────────── */

.drill-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 10px 22px;
  border-bottom: 1px solid var(--hairline);
}

.drill-search {
  flex: 1 1 210px;
  min-width: 180px;
}

.drill-search input {
  width: 100%;
  padding: 7px 12px;
  border: 1px solid var(--hairline);
  border-radius: 18px;
  background: #fff;
  font: inherit;
  font-size: 13px;
  color: var(--navy);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.drill-search input:focus {
  outline: none;
  border-color: var(--blue-soft);
  box-shadow: 0 0 0 3px rgba(47, 111, 168, 0.12);
}

.drill-facets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.drill-facet {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.drill-facet select {
  max-width: 210px;
  padding: 6px 8px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: #fff;
  font: inherit;
  font-size: 12.5px;
  color: var(--navy);
}

.drill-reset {
  margin-left: auto;
  font-size: 12.5px;
}

/* หัวตารางกดเรียงได้ — ปุ่มกินเต็มช่อง คนกดไม่ต้องเล็งตัวอักษร */
table.data th .th-sort {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 700;
  color: inherit;
  text-align: inherit;
  cursor: pointer;
}

table.data th.num .th-sort {
  justify-content: flex-end;
}

table.data th .th-sort:hover {
  color: var(--blue);
}

.th-arrow {
  font-size: 10px;
  opacity: 0.4;
}

.th-sort.is-active .th-arrow {
  opacity: 1;
  color: var(--blue);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.drill-body {
  flex: 1;
  overflow: auto;
  padding: 0 22px;
}

.drill-body table.data td:first-child {
  font-weight: 600;
  color: var(--navy);
}

/**
 * virtual scroll คิดจากความสูงแถวเดียวทั้งตาราง ⇒ ช่องในลิ้นชักห้ามหักบรรทัด
 * ชื่อหน่วยงานยาว ๆ จึงไม่ถูกตัดทิ้ง แต่ทำให้ตารางกว้างขึ้นและเลื่อนซ้ายขวาแทน
 * (ตัดข้อความทิ้งจนอ่านไม่ครบ อันตรายกว่าการเลื่อนซ้ายขวา)
 */
.drill-body table.data {
  width: max-content;
  min-width: 100%;
}

.drill-body table.data td {
  white-space: nowrap;
}

/* แถวว่างแทนแถวที่ยังไม่ได้วาด — ห้ามมีเส้นคั่น/ระยะห่างไปบวกกับความสูงที่คำนวณไว้ */
.drill-body tr.drill-spacer td {
  padding: 0;
  border: 0;
}

.drill-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 12px 22px 16px;
  border-top: 1px solid var(--hairline);
}

.drill-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
}

.drill-pagesize,
.drill-pages {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.drill-pager select {
  padding: 6px 8px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: #fff;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--navy);
}

.drill-pager .btn-ghost {
  padding: 6px 14px;
  border-radius: 18px;
  font-size: 12.5px;
}

.drill-pager .btn-ghost:disabled {
  color: var(--muted);
  cursor: default;
  opacity: 0.55;
}

.drill-pager .btn-ghost:disabled:hover {
  background: #fff;
  border-color: var(--hairline);
}

.drill-pagecount {
  font-variant-numeric: tabular-nums;
}

.drill-warn {
  margin: 0 0 0 auto;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--danger);
}

/* ระหว่างรอผลหน้าถัดไป — บอกว่ากำลังทำงานอยู่โดยไม่กระพริบทั้งลิ้นชัก */
.drill-panel.is-busy .drill-body {
  opacity: 0.55;
  transition: opacity 0.15s;
}

@media (max-width: 720px) {
  .filter-field {
    flex: 1 1 100%;
  }
  .filter-field select {
    flex: 1;
    max-width: none;
  }
  .filterbar-count,
  .filter-clear {
    margin-left: 0;
  }
}

/* กล่อง bullet สรุปผู้บริหาร */
.summary-box {
  background: #fff;
  border-radius: 18px;
  padding: 20px 22px;
  box-shadow: 0 6px 22px rgba(18, 59, 99, 0.08);
}

.summary-box ul {
  margin: 0;
  padding-left: 20px;
  font-size: 14.5px;
  color: var(--ink);
}

.summary-box li + li {
  margin-top: 8px;
}

.summary-box b.teal { color: var(--teal); }
.summary-box b.danger { color: var(--danger); }

/* กราฟ */
.chart-wrap {
  position: relative;
  height: 270px;
}

.chart-wrap.h330 { height: 330px; }
.chart-wrap.h290 { height: 290px; }
.chart-wrap.h260 { height: 260px; }
.chart-wrap.h420 { height: 420px; }

/* การ์ดกว้างเต็ม section (อยู่นอก grid) — ใช้กับกราฟที่ป้ายชื่อยาว เช่น รายหน่วยงาน */
.card-wide { margin-top: 18px; }

/**
 * การ์ดในกริดที่ขอกินความกว้างทั้งแถว — เปิดเมื่อเนื้อในเป็นชื่อหน่วยงานย่อยที่ยาวมาก
 * (ยาวได้ถึง 66 ตัวอักษร) ถ้าปล่อยอยู่ในคอลัมน์แคบ ชื่อจะต้องตัด 3 บรรทัดจนการ์ดสูง 700px+
 * แล้วดันความสูงของทั้งแถว ทำให้การ์ดข้าง ๆ เหลือที่ว่างเปล่าครึ่งใบ
 * `order` ดันไปท้ายแถว เพื่อไม่ให้ไปแทรกกลางจนการ์ดอื่นตกไปคนละบรรทัด
 */
.grid > .card.card-span-all {
  grid-column: 1 / -1;
  order: 1;
}

/* ป้ายข้อสมมติของ projection — บังคับให้เห็น */
.assumption {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 14px;
  padding: 7px 13px;
  border-radius: 20px;
  border: 1px solid rgba(201, 162, 39, 0.55);
  background: rgba(201, 162, 39, 0.14);
  font-size: 12.5px;
  font-weight: 700;
  color: #7a6114;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data th,
table.data td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--hairline);
  text-align: left;
}

table.data th {
  font-weight: 700;
  color: var(--navy);
  background: var(--caption-bg);
  position: sticky;
  top: 0;
}

/* หัวตารางต้องชิดข้างเดียวกับตัวเลขในคอลัมน์นั้น ไม่งั้นอ่านแล้วเยื้องกันจนสับสน */
table.data th.num,
table.data td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

table.data td:first-child {
  white-space: nowrap;
}

/* ค่าที่เป็นก้อนเดียวจบ (ประเภท · เหตุการณ์ · วันที่) — หักบรรทัดแล้วอ่านผิดความหมาย */
table.data td.nowrap {
  white-space: nowrap;
}

/* ─── หน้านำเข้า (M5 · admin) ─────────────────────────────────── */

.dropzone {
  margin: 0 0 16px;
  padding: 40px 24px;
  border: 2px dashed rgba(18, 59, 99, 0.28);
  border-radius: 16px;
  background: #fff;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.09s ease;
}

.dropzone:hover,
.dropzone:focus-visible {
  border-color: var(--teal);
  background: rgba(31, 166, 166, 0.05);
  outline: none;
}

.dropzone.over {
  border-color: var(--teal);
  background: rgba(31, 166, 166, 0.1);
  transform: scale(1.005);
}

.dropzone.busy {
  opacity: 0.6;
  pointer-events: none;
}

.dropzone-title {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 800;
  color: var(--navy);
}

.dropzone-hint {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}

.upload-card {
  margin-bottom: 16px;
}

.upload-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.upload-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 2px;
  border-bottom: 1px solid var(--hairline);
  font-size: 13.5px;
}

.upload-list li:last-child {
  border-bottom: none;
}

.kind-badge {
  flex: none;
  padding: 2px 10px;
  border-radius: 20px;
  background: rgba(31, 166, 166, 0.13);
  color: #0c6b6b;
  font-size: 12px;
  font-weight: 700;
}

.kind-badge.unknown {
  background: rgba(192, 57, 43, 0.12);
  color: var(--danger);
}

.upload-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.upload-size {
  color: var(--muted);
  font-size: 12px;
}

.check-list {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  font-size: 13px;
}

.check-list li {
  padding: 4px 2px;
}

.check-list li.pass { color: #1e7a4f; }
.check-list li.fail { color: var(--danger); font-weight: 700; }
.check-list li.info { color: var(--muted); }

.confirm-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--hairline);
}

.confirm-row input[type='text'] {
  padding: 8px 12px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  font-size: 14px;
  min-width: 220px;
}

/* ช่อง "ที่มาของข้อมูล" ของชั้นแก้มือ — เป็นประโยคอธิบาย ไม่ใช่วันที่/ชื่อสั้น จึงต้องกว้างกว่าเพื่อน
   และขึ้นบรรทัดของตัวเองเมื่อแถวแคบ (ป้ายยาวกว่าช่องอื่นมาก) */
.filter-field.wide {
  flex: 1 1 100%;
  align-items: flex-start;
  flex-direction: column;
  gap: 5px;
}

.filter-field.wide input[type='text'] {
  width: 100%;
}

.confirm-row input[type='text']:focus {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
  border-color: transparent;
}

.confirm-btn {
  padding: 10px 26px;
  border: none;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--navy), var(--blue-dark));
  color: #fff;
  font-size: 14.5px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.09s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  box-shadow: var(--shadow-card);
}

.confirm-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(18, 59, 99, 0.18);
}

.confirm-btn:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}

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

#import-result {
  min-height: 1.4em;
  font-weight: 700;
  color: #1e7a4f;
}

#import-result.error {
  color: var(--danger);
}

.drive-help {
  padding: 10px 4px 4px;
  font-size: 13px;
  color: var(--muted-2);
}

.drive-help code {
  background: var(--caption-bg);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 12px;
}

/* ─── view 3 — ความเคลื่อนไหวกำลังคน (M5.5) ───────────────────── */

/* ชื่อการ์ดอยู่บรรทัดของตัวเองเต็มความกว้าง — ปุ่ม 2 ชุดยาวเกินกว่าจะเบียดแถวเดียวกับชื่อ
   (เบียดแล้วชื่อไทยหักบรรทัดกลางคำ — Jack ทัก 30 ก.ค.) */
.card-head-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  margin-bottom: 4px;
}

.card-head-row h3 {
  margin: 0;
}

/* ปุ่มประจำการ์ด (Jack ขอ 30 ก.ค.): ชุดกรองประเภทบุคลากร + ชุด รวม/แยกเพศ */
.mv-toggles {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 6px;
}

.mv-toggle-pills {
  display: inline-flex;
  border: 1px solid var(--hairline);
  border-radius: 18px;
  overflow: hidden;
  background: var(--caption-bg);
}

.mv-toggle-pills button {
  border: none;
  background: transparent;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.mv-toggle-pills button.active {
  background: var(--navy);
  color: #fff;
}

.mv-toggle-pills button:not(.active):hover {
  color: var(--navy);
}

#mv-empty {
  margin: 26px 0;
  padding: 22px;
  border: 1px dashed var(--hairline);
  border-radius: 14px;
  background: #fff;
  color: var(--muted-2);
  text-align: center;
  font-size: 14.5px;
}

.table-scroll {
  max-height: 300px;
  overflow: auto;
  border: 1px solid var(--hairline);
  border-radius: 10px;
}

/* การ์ดนโยบาย */
/* การ์ดนโยบายมีป้าย tag สีอยู่แล้วบนหัว — แถบหนาริมซ้ายเป็นการพูดเรื่องเดิมซ้ำ เอาออก
   เหลือกรอบเส้นเดี่ยวไว้ให้ขอบการ์ดชัดบนพื้นเทาของหน้า */
.policy-card {
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: 16px;
  padding: 20px 22px;
  box-shadow: 0 4px 16px rgba(18, 59, 99, 0.07);
}

.policy-card h3 {
  margin: 0 0 8px;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--navy);
}

.policy-body {
  font-size: 14px;
  line-height: 1.65;
}

.policy-body p {
  margin: 0 0 8px;
}

.tag {
  display: inline-block;
  margin-bottom: 8px;
  padding: 2px 10px;
  border-radius: 16px;
  background: var(--caption-bg);
  border: 1px solid var(--hairline);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--navy);
}

.empty {
  padding: 26px 18px;
  border: 1px dashed var(--hairline);
  border-radius: 16px;
  text-align: center;
  font-size: 13.5px;
  color: var(--muted);
  background: #fff;
}

/* ที่มาของตัวเลข */
.provenance {
  margin-top: 32px;
  font-size: 12.5px;
  color: var(--muted);
  background: #fff;
  border-radius: 14px;
  padding: 14px 18px;
  box-shadow: var(--shadow-card);
}

.provenance summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--navy);
}

.provenance p {
  margin: 12px 0 4px;
  font-weight: 600;
  color: var(--navy);
}

.provenance ul {
  margin: 0;
  padding-left: 20px;
  line-height: 1.8;
}

.provenance code {
  font-size: 11.5px;
  color: var(--muted);
}

.loading {
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 60;
  max-width: min(560px, 92vw);
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--danger);
  color: #fff;
  font-size: 13.5px;
  box-shadow: 0 14px 32px rgba(18, 59, 99, 0.28);
}

@media (max-width: 900px) {
  .app-header h1 {
    white-space: normal;
  }
  .header-top {
    flex-wrap: wrap;
  }
  .header-actions {
    flex-direction: row;
    align-items: center;
  }
}

@media (max-width: 560px) {
  .header-brand {
    flex-wrap: wrap;
    gap: 10px;
  }
  .logo-svg-header {
    height: 54px;
  }
  .header-chip {
    font-size: 11.5px;
  }
}

@media (max-width: 720px) {
  .header-inner,
  .quicknav-inner {
    padding-left: 14px;
    padding-right: 14px;
  }
  main {
    padding: 18px 14px 40px;
  }
  .view-tabs {
    flex-direction: column;
  }
  .chart-wrap,
  .chart-wrap.h330,
  .chart-wrap.h290,
  .chart-wrap.h260 {
    height: 260px;
  }
}

/* หัวกระดาษเฉพาะตอนพิมพ์ (M9) — บนจอไม่มีตัวตน */
#print-header { display: none; }

@media print {
  #print-header {
    display: block;
    border-bottom: 2px solid var(--navy);
    padding-bottom: 8px;
    margin-bottom: 14px;
  }
  #print-header strong { display: block; font-size: 15px; color: var(--navy); }
  #print-header span { font-size: 11px; color: #4a5b6b; }
  /* กราฟ/การ์ดไม่ขาดครึ่งหน้า */
  .chart-wrap, .card canvas { break-inside: avoid; }
  #stickytop,
  .quicknav,
  .header-actions,
  .view-tabs,
  .provenance,
  .filter-clear,
  .drill,
  .edit-pencil,
  .policy-add,
  #btn-flag-rules,
  #btn-flag-rules-v3 {
    display: none !important;
  }
  /* แถบตัวกรองยังต้องพิมพ์ออกมาด้วย เพราะเป็นตัวบอกว่ากระดาษแผ่นนี้กรองอะไรไว้ */
  .filterbar .toggle-btn:not(.active) {
    display: none;
  }
  body {
    background: #fff;
  }
  .card,
  .kpi-card,
  .summary-box {
    box-shadow: none;
    border: 1px solid var(--hairline);
    break-inside: avoid;
  }
  .section + .section {
    margin-top: 18px;
  }
}

/* ── M6: แก้ narrative inline + editor ── */
.policy-card { position: relative; }
.edit-pencil {
  position: absolute; top: 10px; right: 10px; border: 1px solid rgba(18,59,99,.25);
  background: #fff; color: var(--navy); border-radius: 8px; width: 30px; height: 30px;
  cursor: pointer; font-size: 14px; line-height: 1;
}
.edit-pencil:hover { background: var(--navy); color: #fff; }
/* กันปุ่มดินสอ (30px + right:10px = 40px) ทับหัวเรื่อง/ป้าย — เฉพาะการ์ดที่แก้ไขได้เท่านั้น */
.policy-card.has-edit h3,
.policy-card.has-edit .tag {
  padding-right: 40px;
}
.tag-carried { display: block; margin-left: 0; background: rgba(201,162,39,.15); color: #8a6d3b; border-color: rgba(201,162,39,.35); }
/* ตัวเลขในการ์ดไม่ตรงข้อมูลของชุดที่กำลังดูอยู่ — แดงกว่า tag-carried เพราะเป็นเรื่องความถูกต้อง ไม่ใช่แค่ความเก่า */
.tag-drift {
  display: block; margin-left: 0; background: rgba(176,42,42,.12);
  color: #8c2020; border-color: rgba(176,42,42,.35); cursor: help;
}

/* คำเตือนว่าส่วนนี้ AI เขียน — กินเต็มความกว้างของ grid 2 คอลัมน์ เพราะต้องอ่านก่อนการ์ดทุกใบ */
.ai-notice {
  grid-column: 1 / -1;
  border: 1px solid var(--ring-gold);
  border-radius: 12px;
  background: var(--tint-gold);
  padding: 14px 18px;
}
.ai-notice strong { display: block; color: var(--navy); font-size: 14px; margin-bottom: 6px; }
.ai-notice p { margin: 4px 0 0; font-size: 13px; line-height: 1.65; color: #4a5b6b; }
@media print { .ai-notice { break-inside: avoid; } }

.btn-primary {
  padding: 10px 22px; border: none; border-radius: 11px;
  background: linear-gradient(135deg, var(--navy), var(--blue-dark));
  color: #fff; font-size: 14px; font-weight: 700; cursor: pointer;
  transition: transform 0.09s ease, box-shadow 0.15s ease;
  box-shadow: var(--shadow-card);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(18, 59, 99, 0.18); }
.btn-primary:active:not(:disabled) { transform: translateY(0) scale(0.98); }

.btn-ghost {
  padding: 9px 20px; border: 1px solid var(--hairline); border-radius: 11px;
  background: #fff; color: var(--navy); font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.btn-ghost:hover:not(:disabled) { background: var(--caption-bg); border-color: var(--blue-soft); }

.btn-danger {
  padding: 9px 20px; border: 1px solid rgba(192,57,43,.4); border-radius: 11px;
  background: #fff; color: var(--danger); font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.btn-danger:hover:not(:disabled) { background: rgba(192,57,43,.08); border-color: var(--danger); }

/**
 * ปุ่มที่ถูกปิดไว้ต้อง**ดูปิด** — ไม่งั้นหน้าจอบอกว่ากดได้ทั้งที่กดไม่ได้
 *
 * `background`/`color`/`cursor` ที่เราเขียนเอง **ชนะการทำเทาของเบราว์เซอร์** ⇒ ปุ่มที่
 * `disabled = true` หน้าตาเหมือนปุ่มปกติทุกประการ · และ `:hover` ที่ไม่มี `:not(:disabled)`
 * กำกับ ยังสว่างขึ้นตอนเอาเมาส์ชี้ = สัญญาณว่า "กดได้" ทั้งสามอย่างครบ
 * (Jack เจอ 17 ส.ค. 69 กับปุ่ม "ปิดบัญชี" บนแถวของตัวเองในหน้าจัดการผู้ใช้ —
 *  ตัวปุ่มปิดจริงและเซิร์ฟเวอร์บังคับซ้ำอยู่แล้ว ที่ผิดคือหน้าจอบอกคนละเรื่องกับความจริง)
 * ท่านี้มีอยู่ในไฟล์นี้แล้วสองที่ (`.drill-pager .btn-ghost:disabled` · `.diff-chip:hover:not(:disabled)`)
 * — ตรงนี้ยกขึ้นเป็นกฎกลางของปุ่มทุกตัว เพื่อไม่ต้องจำเป็นราย ๆ ไปอีก
 */
.btn-ghost:disabled,
.btn-danger:disabled,
.btn-primary:disabled {
  cursor: default;
  opacity: 0.45;
  box-shadow: none;
  transform: none;
}

.policy-add {
  align-self: start; justify-self: start; width: fit-content;
}

.edit-dialog { border: none; border-radius: 14px; padding: 22px; width: min(560px, 92vw); }
.edit-dialog::backdrop { background: rgba(8,27,48,.55); }
.edit-dialog label { display: block; margin: 10px 0 4px; font-weight: 600; font-size: 14px; color: var(--navy); }
.edit-dialog input, .edit-dialog textarea {
  width: 100%; border: 1px solid #c9d4e0; border-radius: 8px; padding: 8px 10px; font: inherit;
  box-sizing: border-box;
}
/* ช่องติ๊ก — กฎ `.edit-dialog input { width: 100% }` ข้างบนกินมันด้วย ทำให้ checkbox ยืดเต็มบรรทัด
   จนกลายเป็นแถบสีเทาที่ไม่เหลือเค้าว่าเป็นช่องติ๊ก (และคลิกที่ไหนก็โดน) ⇒ ต้องคืนขนาดจริงให้มัน */
.edit-dialog .check-row { display: flex; align-items: center; gap: 8px; margin: 14px 0 2px; }
.edit-dialog .check-row input[type="checkbox"] {
  width: 16px; height: 16px; flex: none; margin: 0; accent-color: var(--navy);
}
.edit-actions { display: flex; gap: 8px; margin-top: 16px; align-items: center; }
.edit-actions .spacer { flex: 1; }
.edit-error { color: var(--danger); font-size: 14px; margin: 8px 0 0; }

/* ── M6: กล่องธงตามเกณฑ์ (view 2) ── */
.flag-box-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.flag-box-head h3 { margin: 0; }
/* เพดานความสูง + scroll เอง — ไม่งั้นติดธง 20 หน่วยแล้วการ์ดยืดดันทุกอย่างใต้มันลง ตอนที่กล่องนี้สำคัญที่สุด */
.flag-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; max-height: 280px; overflow-y: auto; }
.flag {
  padding: 8px 12px; border-radius: 10px; font-size: 13.5px; line-height: 1.5;
  border: 1px solid var(--hairline); background: var(--caption-bg);
}
.flag-danger { border-color: var(--ring-danger); background: var(--tint-danger); }
.flag-warn { border-color: var(--ring-gold); background: var(--tint-gold); }
.flag-drill { cursor: pointer; }
.flag-drill:hover, .flag-drill:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }

/* ── M6: หน้าตั้งเกณฑ์ธง (rules-dialog) ── */
.rules-dialog { width: min(680px, 94vw); max-height: 88vh; overflow-y: auto; }
.rules-list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; max-height: 220px; overflow-y: auto; }
.rules-list li { display: flex; gap: 8px; align-items: center; font-size: 13.5px; padding: 6px 2px; border-bottom: 1px dashed var(--hairline); }
.rules-list li span { flex: 1; }
.rules-list li.empty { display: block; border-bottom: none; padding: 26px 18px; }
.rule-cond { display: flex; gap: 10px; flex-wrap: wrap; }
.rule-cond label { flex: 1; min-width: 100px; }
/* กล่องผลพรีวิว — ตั้งใจให้เด่นเหมือนกล่อง caption ใต้กราฟ ผู้ใช้ต้องเห็นก่อนกดบันทึกได้โดยไม่ต้องเดา */
.rule-preview {
  font-size: 13.5px; color: var(--navy); min-height: 1.2em; margin: 10px 0 0;
  background: var(--tint-teal); border: 1px solid var(--ring-teal); border-radius: 10px;
  padding: 8px 11px;
}
/* ผลเก่าค้างจากก่อนแก้ฟอร์ม — จางลง+ตัวเอียงกันคนอ่านแล้วเข้าใจผิดว่าเป็นผลของเกณฑ์ปัจจุบัน */
.rule-preview.stale { opacity: 0.6; font-style: italic; border-color: var(--ring-gold); background: var(--tint-gold); }
.btn-preview { border-color: var(--teal); color: var(--teal); }
.btn-preview:hover { background: var(--teal-pale); border-color: var(--teal); }

/* ── กล่องแก้ไขการ์ด: คำอธิบาย token + พรีวิวของจริง ─────────────────
   ต้นฉบับที่มี {{fact:...}} อ่านยากโดยธรรมชาติ แต่ทิ้งไม่ได้ (ดู narrativeFacts.js)
   ⇒ ชดเชยด้วยการบอกว่ามันคืออะไร แล้วโชว์ผลลัพธ์จริงไว้ข้าง ๆ */
.edit-hint { font-size: 12.5px; color: var(--muted); margin: -4px 0 0; line-height: 1.5; }
.edit-hint code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 11.5px;
  background: var(--tint-teal); border: 1px solid var(--ring-teal); border-radius: 5px; padding: 1px 5px;
}
.card-preview {
  margin: 12px 0 0; padding: 11px 13px; border-radius: 10px;
  background: var(--tint-teal); border: 1px solid var(--ring-teal);
}
.card-preview h4 {
  margin: 0 0 7px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.03em;
  text-transform: uppercase; color: var(--teal);
}
.card-preview-title { margin: 0 0 5px; font-weight: 700; color: var(--navy); font-size: 14.5px; }
.card-preview-body { font-size: 13.5px; color: var(--navy); line-height: 1.65; }
.card-preview-body p { margin: 0 0 6px; }
.card-preview-body ul { margin: 0; padding-left: 19px; }
.card-preview-body li { margin-bottom: 3px; }
.card-preview-body > :last-child { margin-bottom: 0; }
/* พิมพ์ต่อหลังกดดูผล = ผลที่เห็นไม่ใช่ของร่างปัจจุบันอีกแล้ว — เตือนด้วยตาแบบเดียวกับ .rule-preview */
.card-preview.stale { opacity: 0.55; border-color: var(--ring-gold); background: var(--tint-gold); }

/* ── M12: กรอบอัตรากำลัง แยกตามประเภทบุคลากร ──────────────────────────────────
   แถวละประเภท **ไม่มีแถวรวม** โดยเจตนา (สเปก D3) — กรอบสองชนิดบวกกันไม่ได้
   ตัวเลขใหญ่คือ "ว่างที่จ้างได้จริง" ส่วนเลขที่เป็นเพดานเชิงนโยบายอยู่บรรทัดรอง
   จงใจไม่ใช้ .kpi-card: การ์ด KPI สื่อว่า "ใบหนึ่ง = ตัวชี้วัดหนึ่งของภาพรวมเดียวกัน"
   ซึ่งตรงข้ามกับสิ่งที่การ์ดนี้ต้องบอก คือสองแถวนี้เป็นคนละฐานที่เอามาเทียบกันตรง ๆ ไม่ได้ */
.frame-types {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.frame-type-row {
  background: #fff;
  border: 1px solid var(--hairline);
  border-inline-start: 3px solid var(--teal);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
  text-align: start;
  font: inherit;
  color: inherit;
  transition: transform 0.15s, box-shadow 0.15s;
}

.frame-type-row.is-drillable { cursor: pointer; }
.frame-type-row.is-drillable:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(8, 27, 48, 0.12);
}
.frame-type-row.is-drillable:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

.frame-type-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  margin-bottom: 8px;
}

.frame-type-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
}

/* ป้ายที่มาของกรอบ — บังคับตาม D3 ห้ามโชว์เลขกรอบโดยไม่บอกว่ากรอบ ณ เมื่อไหร่
   เบากว่าชื่อประเภทหนึ่งขั้นเพื่อไม่แย่งสายตา แต่ยังอยู่บรรทัดเดียวกันให้อ่านคู่กันเสมอ */
.frame-type-basis {
  font-size: 11.5px;
  color: var(--muted);
  background: var(--tint-teal);
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
}

.frame-type-value {
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 800;
  color: var(--navy);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.frame-type-value-label {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}

.frame-type-detail {
  font-size: 12.5px;
  color: var(--ink);
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px dashed var(--hairline);
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
  .frame-type-row.is-drillable:hover { transform: none; }
}
