*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; } /* class ที่ตั้ง display (เช่น .btn, .drag-handle) ต้องไม่ชนะ attribute hidden */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--spms-bg);
  color: var(--spms-text);
  font-family: var(--spms-font);
  font-size: 14px;
  line-height: 1.55;
}
a { color: var(--spms-primary-700); }
:focus-visible { outline: var(--spms-focus); outline-offset: 2px; }
code { background: var(--spms-hover); border-radius: 4px; padding: 1px 5px; font-size: 12.5px; }

.skip-link {
  position: absolute; left: 8px; top: -48px; z-index: 100;
  background: var(--spms-primary-600); color: #fff; padding: 8px 14px; border-radius: var(--spms-radius);
}
.skip-link:focus { top: 8px; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--spms-topbar-h); display: flex; align-items: center; gap: 12px;
  padding: 0 24px; background: var(--spms-surface); border-bottom: 1px solid var(--spms-border);
}
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; font-size: 13px; color: var(--spms-muted); }
.crumbs li + li::before { content: '/'; margin-right: 6px; color: var(--spms-border-strong); }
.crumbs a { color: var(--spms-muted); text-decoration: none; }
.crumbs a:hover { color: var(--spms-primary-700); text-decoration: underline; }
.crumbs [aria-current] { color: var(--spms-text); font-weight: 600; }
.content { padding: 24px; display: flex; flex-direction: column; gap: 16px; max-width: 1440px; width: 100%; }
.content:focus { outline: none; }

.page-head h1 { margin: 0; font-size: 22px; line-height: 1.35; }
.muted { color: var(--spms-muted); margin: 4px 0 0; }

/* ---------- Card / key-value / badge ---------- */
.card {
  background: var(--spms-surface); border: 1px solid var(--spms-border);
  border-radius: var(--spms-radius-xl); padding: 20px 22px;
}
.card-title { margin: 0 0 12px; font-size: 16px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; margin: 0; }
.kv dt { color: var(--spms-muted); }
.kv dd { margin: 0; }
.badge {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px;
  border-radius: var(--spms-radius-sm); font-size: 12px; font-weight: 600;
}
.badge-ok { background: var(--spms-success-bg); color: var(--spms-success); }
.badge-warn { background: var(--spms-warning-bg); color: var(--spms-warning); }
.badge-bad { background: var(--spms-danger-bg); color: var(--spms-danger); }

/* ---------- Sidebar (design/AppSidebar.dc.html) ---------- */
.spsb { width: var(--spms-sidebar-w); flex: 0 0 var(--spms-sidebar-w); display: flex; flex-direction: column; align-self: stretch; transition: width .18s ease-out, flex-basis .18s ease-out; }
.spsb.mini { width: var(--spms-sidebar-mini-w); flex-basis: var(--spms-sidebar-mini-w); }
.spsb-side { flex: 1; display: flex; flex-direction: column; background: var(--spms-surface); border-right: 1px solid var(--spms-border); min-height: 100%; }
.spsb-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 14px; border-bottom: 1px solid var(--spms-border); min-height: 72px; }
.spsb.mini .spsb-head { flex-direction: column; padding: 10px 6px; gap: 6px; }
.spsb-logo { width: 64px; height: auto; flex: 0 0 64px; display: block; }
.spsb.mini .spsb-logo { width: 52px; flex-basis: auto; }
.spsb-bt { flex: 1; min-width: 0; line-height: 1.25; }
.spsb-bt b { display: block; font-size: 15px; color: var(--spms-brand-ink); letter-spacing: .02em; }
.spsb-bt span { font-size: 11.5px; color: var(--spms-muted); }
.spsb.mini .spsb-bt { display: none; }
.spsb-tg { width: 32px; height: 32px; border-radius: var(--spms-radius); border: 1px solid var(--spms-border); background: var(--spms-surface); display: grid; place-items: center; cursor: pointer; color: var(--spms-text-2); flex: 0 0 32px; padding: 0; }
.spsb-tg:hover { background: var(--spms-hover); }
.spsb-nav { padding: 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.spsb-g { font-size: 11.5px; color: var(--spms-muted); padding: 12px 10px 4px; font-weight: 700; }
.spsb.mini .spsb-g { font-size: 0; padding: 8px 0 4px; margin: 0 14px; border-top: 1px solid var(--spms-border-soft); }
.spsb.mini .spsb-g:first-child { border-top: 0; }
.spsb-it { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--spms-radius); color: var(--spms-text-2); text-decoration: none; min-height: 40px; position: relative; }
.spsb-it:hover { background: var(--spms-hover); color: var(--spms-text); }
.spsb-it.on { background: var(--spms-primary-100); color: var(--spms-primary-700); font-weight: 600; }
.spsb-it.on::after { content: ''; position: absolute; right: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 2px; background: var(--spms-primary-600); }
.spsb.mini .spsb-it { justify-content: center; padding: 8px 0; }
.spsb-i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 20px; }
.spsb-i-sm { width: 16px; height: 16px; flex-basis: 16px; }
.spsb.mini .spsb-l { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.spsb-top, .spsb-scrim { display: none; }

@media (max-width: 960px) {
  .app { flex-direction: column; }
  .spsb, .spsb.mini { width: 100%; flex: 0 0 auto; align-self: auto; }
  .spsb-top { display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 10px 0 6px; background: var(--spms-surface); border-bottom: 1px solid var(--spms-border); }
  .spsb-top-logo { height: 36px; width: auto; }
  .spsb-top b { font-size: 15px; color: var(--spms-brand-ink); }
  .spsb-mb { width: 44px; height: 44px; border-radius: var(--spms-radius-lg); border: 0; background: none; display: grid; place-items: center; cursor: pointer; color: var(--spms-text-2); }
  .spsb-side { position: fixed; top: 0; left: 0; bottom: 0; width: 280px; z-index: 80; transform: translateX(-105%); transition: transform .2s ease-out; box-shadow: 0 0 40px rgba(16, 24, 40, .25); overflow-y: auto; }
  .spsb.open .spsb-side { transform: none; }
  .spsb.open .spsb-scrim { display: block; position: fixed; inset: 0; background: rgba(16, 24, 40, .45); z-index: 79; }
  .spsb-tg { display: none; }
  .spsb.mini .spsb-l { position: static; width: auto; height: auto; clip: auto; }
  .spsb.mini .spsb-bt { display: block; }
  .spsb.mini .spsb-g { font-size: 11.5px; padding: 12px 10px 4px; border-top: 0; margin: 0; }
  .spsb.mini .spsb-it { justify-content: flex-start; padding: 8px 10px; }
  .spsb.mini .spsb-head { flex-direction: row; }
  .spsb-it.on::after { display: none; }
  .topbar { padding: 0 16px; height: 48px; }
  .content { padding: 16px; }
}

@media (max-width: 720px) {
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .spsb, .spsb-side { transition: none; }
}

/* ---------- Utilities ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.split { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.req-note { color: var(--spms-danger); font-size: 12.5px; }

/* ---------- Buttons (DesignSystem: primary / secondary / ghost / danger · sm · block) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px; border-radius: var(--spms-radius); border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--spms-primary-600); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--spms-primary-700); }
.btn-primary:active:not(:disabled) { background: var(--spms-primary-800); }
.btn-secondary { background: var(--spms-surface); color: var(--spms-text); border-color: var(--spms-border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--spms-hover); }
.btn-ghost { background: none; color: var(--spms-primary-700); }
.btn-ghost:hover { background: var(--spms-primary-50); }
.btn-danger { background: var(--spms-surface); color: var(--spms-danger); border-color: #F1B8B2; }
.btn-danger:hover:not(:disabled) { background: var(--spms-danger-bg); }
.btn-line { background: #06C755; color: #fff; min-height: 48px; font-size: 15px; }
.btn-line:hover { background: #05B34C; }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 18px; }
.form-inline { flex-direction: row; flex-wrap: wrap; align-items: flex-end; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
/* ช่องที่วางเรียงกันในบล็อกธรรมดา (เช่น wizard) — ใน container ที่มี gap อยู่แล้วไม่ต้องเพิ่ม margin */
:not(.form, .form-card, .stack, .field-row, .field-grid, .filterbar, .check-list, .auth-card, .wiz-body, .row-card, .rv-panel, .split-main, .split-side, .wizard, .content, .input-row, .action-box form) > :is(.field, .field-row, .field-grid, .field-check) + :is(.field, .field-row, .field-grid, .field-check) { margin-top: 18px; }
.req { color: var(--spms-danger); font-weight: 700; margin-left: 2px; }
.field label { font-weight: 600; font-size: 13.5px; color: var(--spms-text-2); }
.field input:not([type="checkbox"]):not([type="radio"]), .field select, .field textarea {
  font: inherit; color: var(--spms-text); background: var(--spms-surface);
  border: 1px solid var(--spms-border-strong); border-radius: var(--spms-radius); padding: 8px 12px; min-height: 40px; width: 100%;
}
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible { outline: var(--spms-focus); outline-offset: 0; border-color: var(--spms-primary-600); }
.field .input-validation-error, .field [aria-invalid="true"] { border-color: var(--spms-danger); background: #FFFBFA; }
.field-error { color: var(--spms-danger); font-size: 12.5px; }
.field-error:empty { display: none; }
.hint { color: var(--spms-muted); font-size: 12.5px; }
.field-check { display: flex; flex-direction: row; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.field-check input { width: 18px; height: 18px; margin-top: 3px; flex: 0 0 18px; accent-color: var(--spms-primary-600); }
.field-check label { font-weight: 400; flex: 1; min-width: 0; }
.field-check .field-error { flex-basis: 100%; }
.check-list { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.input-code { font-size: 20px !important; letter-spacing: .2em; max-width: 260px; }
.filterbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filterbar .field { min-width: 200px; }

/* ---------- Alerts ---------- */
.alert { border-radius: var(--spms-radius); padding: 10px 14px; border: 1px solid transparent; }
.alert-ok { background: var(--spms-success-bg); color: var(--spms-success); border-color: #BFE3CD; }
.alert-warn { background: var(--spms-warning-bg); color: var(--spms-warning); border-color: #F7D4A6; }
.alert-bad { background: var(--spms-danger-bg); color: var(--spms-danger); border-color: #F5C2BC; }
.validation-summary-valid { display: none; }
.validation-summary ul { margin: 0; padding-left: 18px; }
.session-warn { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.session-warn[hidden] { display: none; }
[data-show-when][hidden] { display: none; }

/* ---------- Table (≤720px → การ์ด) ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 12px; color: var(--spms-muted); font-weight: 600; background: var(--spms-surface-2); padding: 10px 12px; border-bottom: 1px solid var(--spms-border); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--spms-border-soft); vertical-align: top; }
.table .actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.pager { display: flex; gap: 16px; align-items: center; justify-content: center; padding-top: 12px; }
.empty { text-align: center; color: var(--spms-muted); }

/* ---------- Sidebar user ---------- */

/* ---------- Auth pages ---------- */
.auth-body { min-height: 100vh; display: flex; }
.auth-main { flex: 1; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 480px; background: var(--spms-surface); border: 1px solid var(--spms-border); border-radius: var(--spms-radius-xl); padding: 28px; display: flex; flex-direction: column; gap: 18px; }
.auth-brand { display: flex; align-items: center; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--spms-border); }
.auth-brand b { display: block; color: var(--spms-brand-ink); font-size: 16px; }
.auth-brand span { color: var(--spms-muted); font-size: 12.5px; }
.auth-logo { width: 56px; height: auto; }
.auth-title { margin: 0; font-size: 20px; }
.auth-foot { margin: 0; font-size: 13px; color: var(--spms-muted); text-align: center; }

/* ---------- MFA ---------- */
.mfa-setup { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.qr { border: 1px solid var(--spms-border); border-radius: var(--spms-radius); background: #fff; }
.key { font-size: 15px; letter-spacing: .08em; }
.card-strong { border-color: var(--spms-warning); }
.code-list { columns: 2; font-size: 16px; }
.code-list li { margin-bottom: 6px; }

/* ---------- หน้าแรก (เข้าสู่ระบบ) แบบแบ่งสองฝั่ง + ประกาศ ---------- */
.landing { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 48%) minmax(0, 1fr); background: var(--spms-bg); }
.landing-hero { background: var(--spms-landing-bg); color: #fff; padding: 48px 52px 40px; display: flex; flex-direction: column; gap: 18px; }
.landing-brand { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--spms-landing-ink-2); }
.landing-logo { width: 36px; height: auto; background: #fff; border-radius: var(--spms-radius); padding: 3px; }
.landing-title { margin: 12px 0 0; font-size: clamp(30px, 3.4vw, 44px); font-weight: 800; line-height: 1.3; color: #fff; }
.landing-lead { margin: 0; max-width: 540px; font-size: 17px; line-height: 1.7; color: var(--spms-landing-ink-2); }
.landing-pdca { list-style: none; margin: auto 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; max-width: 540px; }
.landing-pdca li { background: var(--spms-landing-tile); border-radius: var(--spms-radius-lg); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.landing-pdca b { font-size: 22px; line-height: 1; }
.landing-pdca span { font-size: 13px; color: var(--spms-landing-ink-2); }
.landing-main { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 32px 16px; }
.landing-card { width: 100%; max-width: 440px; background: var(--spms-surface); border: 1px solid var(--spms-border); border-radius: var(--spms-radius-xl); padding: 28px; display: flex; flex-direction: column; gap: 16px; box-shadow: 0 1px 3px rgba(16, 24, 40, .06); }
.landing-card .muted { margin: 0; line-height: 1.6; }
.landing-card-title { margin: 0; font-size: 22px; }
.landing-divider { display: flex; align-items: center; gap: 10px; color: var(--spms-muted); font-size: 13px; }
.landing-divider::before, .landing-divider::after { content: ''; flex: 1; border-top: 1px solid var(--spms-border); }
.landing-steps { margin: 0; padding-left: 20px; color: var(--spms-text-2); font-size: 14px; display: flex; flex-direction: column; gap: 6px; }
.landing-news-btn { width: 100%; max-width: 440px; }
.line-icon { width: 22px; height: 22px; flex: 0 0 22px; }
.ann { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.ann + .ann { border-top: 1px solid var(--spms-border); padding-top: 14px; }
.ann-title { margin: 0; font-size: 17px; }
.ann .rich { width: 100%; }
.ann-video { width: 100%; aspect-ratio: 16 / 9; border-radius: var(--spms-radius); overflow: hidden; background: #000; }
.ann-video iframe, .ann-video video { width: 100%; height: 100%; border: 0; display: block; }
/* ปกวิดีโอ + ปุ่มเล่น (กดแล้วจึงโหลดวิดีโอ) */
.ann-cover { position: relative; display: block; width: 100%; height: 100%; padding: 0; border: 0; cursor: pointer; background: #000; color: #fff; font: inherit; }
.ann-cover img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s ease, opacity .25s ease; }
.ann-cover::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0) 45%, rgba(0,0,0,.45)); pointer-events: none; }
.ann-cover-plain { background: linear-gradient(135deg, var(--spms-primary-800), var(--spms-primary-600)); }
.ann-cover-title { position: absolute; left: 20px; right: 20px; bottom: 18px; z-index: 1; text-align: left; font-size: 18px; font-weight: 700; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ann-play { position: absolute; z-index: 1; left: 50%; top: 50%; width: 68px; height: 68px; margin: -34px 0 0 -34px; border-radius: 50%;
  background: rgba(255,255,255,.94); box-shadow: 0 6px 20px rgba(0,0,0,.35); transition: transform .2s ease, background-color .2s ease; }
.ann-play::before { content: ""; position: absolute; left: 50%; top: 50%; margin: -12px 0 0 -7px; border-style: solid; border-width: 12px 0 12px 20px;
  border-color: transparent transparent transparent var(--spms-primary-600); }
.ann-cover:hover .ann-play, .ann-cover:focus-visible .ann-play { transform: scale(1.08); background: #fff; }
.ann-cover:hover img { transform: scale(1.02); opacity: .92; }
.ann-cover:focus-visible { outline: 3px solid #fff; outline-offset: -5px; box-shadow: inset 0 0 0 5px var(--spms-primary-600); }
@media (prefers-reduced-motion: reduce) { .ann-cover img, .ann-play { transition: none; } }
.ann-link { margin: 0; }
.ann-dlg .dlg-actions { justify-content: space-between; align-items: center; flex-wrap: wrap; }
@media (max-width: 960px) {
  .landing { grid-template-columns: 1fr; }
  .landing-hero { padding: 28px 20px; }
  .landing-pdca { margin-top: 8px; }
}
@media (max-width: 480px) {
  .landing-pdca { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .landing-card { padding: 20px; }
}

/* ---------- Confirm dialog ---------- */
.dlg { border: 0; border-radius: var(--spms-radius-xl); padding: 24px; max-width: 440px; width: calc(100% - 32px); box-shadow: 0 20px 50px rgba(16, 24, 40, .25); }
.dlg::backdrop { background: rgba(16, 24, 40, .45); }
.dlg p { margin: 0 0 18px; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; }
.dlg-wide { max-width: 680px; }
.dlg-title { font-size: 18px; margin: 0 0 4px; }
.dlg .dlg-scroll { max-height: 60vh; overflow-y: auto; margin: 0 0 18px; display: flex; flex-direction: column; gap: 12px; }
.dlg p.kpi-warn { color: var(--spms-danger); font-weight: 700; margin: 0 0 12px; }
.kpi-table .kpi-code { white-space: nowrap; }
.kpi-table .kpi-target { min-width: 110px; }

@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .field-row { grid-template-columns: 1fr; }
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border: 1px solid var(--spms-border); border-radius: var(--spms-radius-lg); margin-bottom: 10px; padding: 6px 0; }
  .table td { border: 0; padding: 6px 12px; }
  .table td[data-label]::before { content: attr(data-label); display: block; font-size: 11.5px; color: var(--spms-muted); }
  .table .actions { justify-content: flex-start; }
  .code-list { columns: 1; }
  .auth-card { padding: 20px; }
  .btn, .field input, .field select { min-height: 44px; }
}
@media print {
  .spsb, .topbar, .btn, form, .session-warn { display: none !important; }
  body { background: #fff; }
  .card { border: 0; }
}

/* หน้า MFA: กล่องอธิบายเหตุผล */
.mfa-why p, .mfa-why ul { margin: 0 0 10px; }
.mfa-why .alert { margin-bottom: 12px; }
.mfa-why ul { padding-left: 20px; }
.mfa-why li { margin-bottom: 4px; }
.mfa-subtitle { margin: 16px 0 8px; font-size: 15px; }

/* ข้อมูลพื้นฐาน (S4) */
.page-head-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; }
.card-flush { padding: 0; overflow: hidden; }
.tabs { display: flex; gap: 4px; padding: 0 10px; border-bottom: 1px solid var(--spms-border); overflow-x: auto; }
.tab { display: inline-block; padding: 12px 14px; color: var(--spms-text-2); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--spms-text); }
.tab.on { color: var(--spms-primary-600); border-bottom-color: var(--spms-primary-600); font-weight: 600; }
.alert-in { margin: 12px 16px 0; }
.tab-intro { margin: 12px 18px 0; font-size: 13px; }
.filterbar-in { padding: 12px 16px; margin: 0; border-bottom: 1px solid var(--spms-border); }
.card-flush .empty { padding: 32px 16px; text-align: center; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; background: #EEF2F8; color: var(--spms-text); font-size: 13px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.badge-off { background: #EEF1F5; color: var(--spms-muted); }
.table-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 12px 16px; margin: 0; font-size: 13px; }
.input-code-text { text-transform: uppercase; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.input-num { text-align: right; font-variant-numeric: tabular-nums; }
.actions form { display: inline; }

/* บทบาทและสิทธิ์ (S11 Permission Matrix) */
.role-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; padding: 16px; border-bottom: 1px solid var(--spms-border); }
.role-head .card-title { margin-bottom: 4px; }
.role-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; }
.matrix th, .matrix td { text-align: center; vertical-align: middle; padding: 6px 4px; }
.matrix th[scope="row"] { text-align: left; padding-left: 16px; font-weight: 600; color: var(--spms-text); background: var(--spms-surface); white-space: nowrap; }
.matrix thead th { white-space: nowrap; }
.matrix .th-sub { font-weight: 400; }
.matrix select { min-width: 92px; padding: 4px 6px; font-size: 12.5px; }
.matrix .cell-on { background: var(--spms-primary-50); }
.matrix .cell-na { color: var(--spms-border-strong); }
.matrix-help { padding: 12px 16px; font-size: 13px; border-top: 1px solid var(--spms-border); }
.matrix-help p { margin: 0 0 6px; }
.form-actions-in { padding: 0 16px 16px; margin: 0; }
.reset-form { border-top: 1px solid var(--spms-border-soft); padding-top: 16px; }
@media (max-width: 720px) {
  .matrix th[scope="row"] { display: block; padding: 10px 12px 4px; font-size: 15px; }
  .matrix .cell-na { display: none; }
  .matrix td { display: flex; justify-content: space-between; align-items: center; gap: 8px; text-align: left; padding: 4px 12px; }
  .matrix td[data-label]::before { display: inline; font-size: 13px; color: var(--spms-text-2); }
  .matrix select { min-width: 140px; }
}

/* ---------- ตารางตั้งค่ารายปี (อัตราค่าใช้จ่าย/วงเงินหน่วยงาน) ---------- */
.table .input {
  font: inherit; color: var(--spms-text); background: var(--spms-surface);
  border: 1px solid var(--spms-border-strong); border-radius: var(--spms-radius); padding: 6px 10px; min-height: 36px; width: 100%; max-width: 180px;
}
.table .input:focus-visible { outline: var(--spms-focus); outline-offset: 0; border-color: var(--spms-primary-600); }
.table .input[aria-invalid="true"] { border-color: var(--spms-danger); background: #FFFBFA; }
.table .input:disabled { background: var(--spms-bg); color: var(--spms-text-2); }
.rate-cell { display: flex; align-items: center; gap: 8px; }
.rate-cell .muted { font-size: 12.5px; white-space: nowrap; }
.table .field-error { display: block; margin-top: 4px; }
.badge-info { background: var(--spms-primary-50); color: var(--spms-primary-800); }

/* ---------- รอบรับแผน ---------- */
.split-main, .split-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.badge-lg { font-size: 13.5px; padding: 6px 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head .card-title { margin: 0; }
.card-head-in { padding: 16px 16px 0; }
.pre { white-space: pre-line; }
.flow { list-style: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 0; margin: 0 0 16px; }
.flow-s { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: var(--spms-radius); border: 1px solid var(--spms-border); background: var(--spms-surface); font-size: 13px; }
.flow-s.done { border-color: #B7DFC8; background: var(--spms-success-bg); }
.flow-s.cur { border-color: var(--spms-primary-600); box-shadow: inset 0 0 0 1px var(--spms-primary-600); }
.check-items { list-style: none; margin: 12px 0 0; padding: 0; }
.check-items li { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--spms-border); }
.check-items .grow { flex: 1; min-width: 0; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--spms-border); display: flex; flex-direction: column; gap: 10px; }
.timeline li { position: relative; }
.timeline li::before { content: ""; position: absolute; left: -20px; top: 7px; width: 10px; height: 10px; border-radius: 50%; background: var(--spms-primary-600); }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; min-width: 0; }
.action-box { border: 1px solid var(--spms-border); border-radius: var(--spms-radius); padding: 10px 12px; }
.action-box summary { cursor: pointer; font-weight: 600; }
.action-box form { display: flex; flex-direction: column; gap: 16px; margin-top: 12px; }
.action-box form .btn { align-self: flex-start; }
@media (max-width: 720px) {
  .flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.link-card { max-width: 720px; display: flex; flex-direction: column; gap: 12px; }

/* ---------- หนังสือเวียน (ตัวอย่าง A4 — ตรงกับ PDF/Word) ---------- */
@font-face { font-family: 'TH Sarabun New'; src: url('../fonts/THSarabunNew.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'TH Sarabun New'; src: url('../fonts/THSarabunNew-Bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }
.split-letter { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
.form-card { display: flex; flex-direction: column; gap: 18px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.card-subtitle { font-size: 14px; margin: 16px 0 8px; }
.plain-list { margin: 0; padding-left: 18px; font-size: 13px; }
.hint code, .plain-list code { font-size: 12px; background: var(--spms-bg); padding: 1px 4px; border-radius: 4px; }
.letter-preview-card { background: var(--spms-bg); }
.doc-sheet {
  background: #fff; color: #000; font-family: 'TH Sarabun New', var(--spms-font); font-size: 16pt; line-height: 1.15;
  aspect-ratio: 210 / 297; padding: 8.4% 6.7% 6.7% 10%; box-shadow: 0 1px 4px rgba(23, 33, 51, .15); overflow: hidden; container-type: inline-size;
}
.doc-sheet { font-size: clamp(9px, 2.85cqi, 16pt); }
.doc-sheet p { margin: 0; }
.doc-head { text-align: center; font-size: 1.8em; font-weight: 700; margin: 0 0 .3em; }
.doc-label { font-size: 1.25em; }
.doc-two { display: grid; grid-template-columns: 1fr 1fr; }
.doc-gap { margin-top: .6em !important; }
.doc-para { text-indent: 2.5cm; margin-top: .5em !important; text-align: justify; }
.doc-sign { margin: 3em 0 0 38%; text-align: center; }
@media (max-width: 1100px) { .split-letter { grid-template-columns: 1fr; } }
.template-version summary { cursor: pointer; } .template-version .kv { margin-top: 12px; }

/* ---------- Wizard ยื่นแผน ---------- */
.small { font-size: 12.5px; }
.wiz-status { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.wizard { display: flex; flex-direction: column; gap: 16px; }
.stepper { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.stepper .st-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; height: 100%; padding: 8px 10px; border: 1px solid var(--spms-border); border-radius: var(--spms-radius); background: var(--spms-surface); font: inherit; font-size: 12.5px; color: var(--spms-text-2); text-align: left; }
.stepper button.st-btn { cursor: pointer; }
.stepper button.st-btn:hover { border-color: var(--spms-primary-600); }
.stepper .st-no { font-weight: 700; font-size: 13px; }
.stepper .done .st-btn { background: var(--spms-success-bg); border-color: #B7DFC8; color: var(--spms-success); }
.stepper .cur .st-btn { border-color: var(--spms-primary-600); box-shadow: inset 0 0 0 1px var(--spms-primary-600); color: var(--spms-primary-800); font-weight: 600; }
.wiz-body { display: flex; flex-direction: column; gap: 18px; }
.wiz-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; position: sticky; bottom: 0; background: var(--spms-bg); padding: 10px 0; border-top: 1px solid var(--spms-border); }
.wiz-actions .grow { flex: 1; }
.row-card { border: 1px solid var(--spms-border); border-radius: var(--spms-radius); padding: 12px 14px; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.row-card legend { font-weight: 600; padding: 0 6px; }
.row-actions { display: flex; justify-content: flex-end; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; }
.table-form td { vertical-align: top; }
.table-form input, .table-form select {
  font: inherit; color: var(--spms-text); background: var(--spms-surface); border: 1px solid var(--spms-border-strong);
  border-radius: var(--spms-radius); padding: 6px 8px; min-height: 36px; width: 100%; min-width: 80px;
}
.table-form .cell-wide { min-width: 260px; }
.table-form .cell-wide > * + * { margin-top: 6px; }
.table-form .field-check input { width: 18px; min-width: 18px; min-height: 18px; }
.budget-sum { margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--spms-border); }
.declare { padding: 12px; border: 1px solid var(--spms-border); border-radius: var(--spms-radius); background: var(--spms-primary-50); }
.missing-list { margin: 8px 0 0; padding-left: 18px; }
.missing-list > li + li { margin-top: 8px; }
.open-round { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; list-style: none; padding: 6px 0; }
.open-rounds .plain-list { padding-left: 0; }
.plan-summary { display: flex; flex-direction: column; gap: 16px; }
.sum-sec h3 { font-size: 15px; margin: 0 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--spms-border); }
.sum-total { font-size: 15px; margin-top: 8px; }
.print-only { display: none; }
@media (max-width: 960px) {
  .stepper { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .stepper { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wiz-status { align-items: flex-start; }
}
@media print {
  .no-print, .crumbs, .alert { display: none !important; }
  .print-only { display: block; }
  .print-doc { font-family: 'TH Sarabun New', var(--spms-font); font-size: 15pt; padding: 0; }
  .print-title { text-align: center; font-size: 18pt; margin: 0 0 12pt; }
  .sum-sec { break-inside: avoid; }
  .table th, .table td { padding: 4px 6px; }
}

/* ---------- ตรวจสอบและอนุมัติแผน (RvQueue / RvDetail / RvStatus / RvHistory) ---------- */
.flow-s.bad { border-color: #F1B8B2; background: var(--spms-danger-bg); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--spms-border); border-radius: var(--spms-radius-lg, 10px); background: var(--spms-surface); }
.kpi b { font-size: 24px; font-variant-numeric: tabular-nums; }
.rv-mark { margin-top: 10px; padding: 10px 12px; border: 1px dashed var(--spms-border); border-radius: var(--spms-radius); background: var(--spms-surface-2); display: flex; flex-direction: column; gap: 8px; }
.rv-verdict { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.rv-verdict legend { float: left; width: 100%; margin: 0 0 2px; padding: 0; font-weight: 600; font-size: 13px; }
.rv-verdict > .field-check + .field-check { margin-top: 0; } /* ระยะห่างใช้ gap ของ fieldset แทน margin-top 18px ของ .field-check */
.rv-panel { position: sticky; top: 12px; display: flex; flex-direction: column; gap: 12px; }
.rv-panel fieldset.field { border: 0; padding: 0; margin: 0; }
.rv-panel legend { font-weight: 600; font-size: 13.5px; margin-bottom: 4px; }
.dec { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--spms-border); border-radius: var(--spms-radius); cursor: pointer; }
.dec:has(input:checked) { border-color: var(--spms-primary-600); box-shadow: inset 0 0 0 1px var(--spms-primary-600); }
.dec input { margin-top: 4px; }
.diff-list { margin: 0; padding-left: 18px; font-size: 13px; }
del { color: var(--spms-danger); }
ins { color: var(--spms-success); text-decoration: none; font-weight: 600; }
.diff-row td { background: #FFFBF2; }
.st-flag { color: var(--spms-danger); }
.revise-note .missing-list { margin-top: 6px; }
@media (max-width: 1100px) {
  .rv-panel { position: static; }
}

/* ---------- โครงการ (PjSubmit / PjPlanHub) ---------- */
.sec-no { display: inline-grid; place-items: center; width: 24px; height: 24px; margin-right: 6px; border-radius: 50%; background: var(--spms-primary-100); color: var(--spms-primary-700); font-size: 12.5px; }
.sec-bad { border-color: var(--spms-danger); }
.sec-bad .sec-no { background: var(--spms-danger-bg); color: var(--spms-danger); }
.flowbar { display: block; width: 100%; height: 22px; border-radius: var(--spms-radius-sm); overflow: hidden; }
.fb-alloc { fill: var(--spms-primary-700); }
.fb-res { fill: var(--spms-primary-300); }
.fb-un { fill: #F5D3A6; }
.legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin: 12px 0; }
.legend > div { border: 1px solid var(--spms-border-soft); border-radius: var(--spms-radius); padding: 8px 10px; background: var(--spms-surface-2); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.lg-alloc { background: var(--spms-primary-700); }
.lg-res { background: var(--spms-primary-300); }
.lg-un { background: #F5D3A6; }
.row-warn { background: #FFFBEB; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.pc { border: 1px solid var(--spms-border); border-radius: var(--spms-radius-lg); padding: 14px; display: flex; flex-direction: column; gap: 6px; background: var(--spms-surface); }
a.kpi { color: inherit; text-decoration: none; }
a.kpi:hover { background: var(--spms-hover); }
.check-list a { color: inherit; }
.check-list .text-bad a { color: var(--spms-danger); font-weight: 600; }

/* ---------- เบิกจ่าย: S-Curve ---------- */
.scurve { display: block; width: 100%; height: 220px; }
.scurve polyline { fill: none; vector-effect: non-scaling-stroke; }
.sc-plan { stroke: #98A2B3; stroke-width: 2; stroke-dasharray: 6 4; }
.sc-paid { stroke: var(--spms-success); stroke-width: 3; }
.sc-ob { stroke: var(--spms-primary-700); stroke-width: 2; }
.sc-grid { stroke: var(--spms-border-soft); vector-effect: non-scaling-stroke; }
.sc-axis { stroke: var(--spms-border-strong); vector-effect: non-scaling-stroke; }
.sc-today { stroke: var(--spms-danger); stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
.sc-months { display: flex; justify-content: space-between; gap: 4px; font-size: 11.5px; color: var(--spms-muted); padding: 4px 16px 0; }
.lg-plan { background: #98A2B3; }
.lg-paid { background: var(--spms-success); }
.lg-ob { background: var(--spms-primary-700); }

/* 4.9 รายงานความก้าวหน้า */
.card-pad { padding-inline: 16px; }
.card-flush > .card-pad:first-child { padding-top: 16px; }
.inline-details > summary { list-style: none; cursor: pointer; }
.inline-details > summary::-webkit-details-marker { display: none; }
.inline-details[open] { flex-basis: 100%; }
.inline-details form { margin-top: 8px; min-width: 240px; text-align: left; }
.text-bad { color: var(--spms-danger); }

/* แดชบอร์ด (4.11) — แถบแนวนอนเป็น SVG เพราะ CSP ไม่อนุญาต style inline */
.bar-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.bar-list li { display: flex; flex-direction: column; gap: 4px; }
.hbar { display: block; width: 100%; height: 12px; border-radius: 3px; overflow: hidden; }
.hb-track { fill: var(--spms-border-soft); }
.hb-bud { fill: var(--spms-primary-300); }
.hb-paid { fill: var(--spms-primary-700); }
.hb-done { fill: var(--spms-success); }
.hb-late { fill: var(--spms-danger); }
.todo-list { list-style: none; margin: 0; padding: 0; }
.todo-list li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--spms-border); flex-wrap: wrap; }
.todo-list li:first-child { border-top: 0; }
.todo-list .grow { flex: 1; min-width: 200px; }
.tabs-wrap { flex-wrap: wrap; overflow-x: visible; }

/* ไทม์ไลน์ (4.11) — แท่ง/เครื่องหมายเป็น SVG · สถานะแสดงเป็นข้อความเสมอ */
.tl { display: flex; flex-direction: column; min-width: 720px; }
.tl-row { display: grid; grid-template-columns: minmax(220px, 30%) minmax(0, 1fr); gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--spms-border-soft); }
.tl-head { border-top: 0; font-weight: 600; font-size: 12.5px; color: var(--spms-muted); }
.tl-plan { background: var(--spms-surface-2); }
.tl-plan .tl-name { padding-left: 6px; }
.tl-row:not(.tl-plan):not(.tl-head) .tl-name { padding-left: 18px; }
.tl-name { min-width: 0; font-size: 13.5px; }
.tl-months { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); text-align: center; }
.tl-track svg { display: block; width: 100%; height: 26px; }
.tl-track rect, .tl-track line { vector-effect: non-scaling-stroke; }
.tl-q { stroke: var(--spms-border-soft); }
.tl-plan-bar { fill: #DCE6F8; }
.tl-done { fill: var(--spms-primary-600); }
.tl-done-ok { fill: var(--spms-success); }
.tl-done-late { fill: var(--spms-danger); }
.tl-rep { fill: #6B4E16; }
.tl-rep-late { fill: var(--spms-danger); }
.tl-rep-soon { fill: #C46A00; }
.tl-rep-done { fill: var(--spms-success); }
.tl-disb { fill: #7A5AF8; }
.tl-ms { fill: #172133; }
.tl-round { fill: #C46A00; }
.tl-today { stroke: var(--spms-danger); stroke-width: 1.5; stroke-dasharray: 3 2; }
.tl-legend { margin-top: 12px; }
.lg-tl-plan { background: #DCE6F8; }
.lg-tl-done { background: var(--spms-primary-600); }
.lg-tl-late { background: var(--spms-danger); }
.lg-tl-rep { background: #6B4E16; }
.lg-tl-disb { background: #7A5AF8; }
.lg-tl-ms { background: #172133; }
.lg-tl-today { background: var(--spms-danger); }
.row-today td { background: var(--spms-primary-50); }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cal { width: 100%; border-collapse: collapse; table-layout: fixed; min-width: 640px; }
.cal th { font-size: 12.5px; color: var(--spms-muted); padding: 6px; }
.cal td { vertical-align: top; height: 92px; border: 1px solid var(--spms-border-soft); padding: 4px 6px; font-size: 12.5px; }
.cal-out { background: var(--spms-surface-2); }
.cal-today { box-shadow: inset 0 0 0 2px var(--spms-primary-600); }
.cal-day { font-weight: 600; }
.cal-ev { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }

/* Wizard ยื่นแผน ขั้นที่ 1: ส่วนย่อย (ความสอดคล้อง → ข้อมูลทั่วไป ที่ล็อกไว้จนกว่าจะเลือกครบ) */
.wiz-part { border: 0; padding: 0; margin: 0 0 20px; min-width: 0; }
.wiz-part-title { display: block; width: 100%; font-size: 15px; font-weight: 600; margin: 0 0 8px; padding: 0 0 4px; border-bottom: 1px solid var(--spms-border); }
fieldset.wiz-part[disabled] .wiz-part-title { color: var(--spms-muted); }

/* ลากจัดลำดับข้อมูลพื้นฐาน (table[data-reorder]) */
.reorder-hint { margin: 0; padding: 10px 16px 0; }
.reorder-status { margin: 0; padding: 4px 16px 0; min-height: 1.5em; color: var(--spms-muted); }
.reorder-status:empty { display: none; }
.table .col-drag { width: 1%; padding-right: 0; white-space: nowrap; }
.drag-handle { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: var(--spms-muted); font-size: 18px; line-height: 1; cursor: grab; touch-action: none; user-select: none; }
.drag-handle:hover { background: var(--spms-hover); color: var(--spms-text); border-color: var(--spms-border); }
.drag-handle:focus-visible { outline: var(--spms-focus); outline-offset: 2px; }
.drag-handle:active { cursor: grabbing; }
.table tr.is-dragging td { background: var(--spms-hover); }
.table tr.is-dragging { box-shadow: 0 2px 8px rgba(23, 33, 51, .16); }
table.is-saving .drag-handle { cursor: progress; opacity: .6; }
.reorder-status.text-bad { color: var(--spms-danger); }
@media (max-width: 720px) {
  .table td.col-drag { width: auto; padding: 4px 12px 0; }
  .drag-handle { width: 44px; height: 44px; }
}
.reorder-ctl { display: flex; align-items: center; gap: 2px; }
.move-btns { display: inline-flex; flex-direction: column; gap: 2px; }
.move-btn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 18px; padding: 0; border: 1px solid var(--spms-border); border-radius: 4px;
  background: var(--spms-surface, #fff); color: var(--spms-text-2); font-size: 10px; line-height: 1; cursor: pointer; }
.move-btn:hover:not(:disabled) { background: var(--spms-hover); color: var(--spms-text); border-color: var(--spms-border-strong); }
.move-btn:focus-visible { outline: var(--spms-focus); outline-offset: 1px; }
.move-btn:disabled { opacity: .35; cursor: default; }
table.is-saving .move-btn { cursor: progress; }
@media (max-width: 720px) {
  .move-btns { flex-direction: row; gap: 6px; }
  .move-btn { width: 44px; height: 44px; font-size: 14px; }
}

/* ---------- การแจ้งเตือน (4.12): กระดิ่งบนแถบบน + รายการ ---------- */
.topbar .crumbs { flex: 1; min-width: 0; }
.bell { position: relative; }
.bell > summary { list-style: none; }
.bell > summary::-webkit-details-marker { display: none; }
.bell-btn { position: relative; width: 40px; height: 40px; display: grid; place-items: center; border-radius: var(--spms-radius); color: var(--spms-text-2); cursor: pointer; }
.bell-btn:hover { background: var(--spms-hover); color: var(--spms-text); }
.bell-btn:focus-visible { outline: var(--spms-focus); outline-offset: 2px; }
.bell-i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bell-dot { position: absolute; top: 3px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--spms-danger); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.bell-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 70; width: 360px; max-width: calc(100vw - 32px); background: var(--spms-surface);
  border: 1px solid var(--spms-border); border-radius: var(--spms-radius-lg); box-shadow: 0 12px 32px rgba(16, 24, 40, .16); overflow: hidden; }
.bell-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--spms-border-soft); }
.bell-empty { margin: 0; padding: 20px 14px; text-align: center; color: var(--spms-muted); font-size: 13.5px; }
.bell-item { display: flex; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--spms-border-soft); color: var(--spms-text); text-decoration: none; }
.bell-item:hover { background: var(--spms-hover); }
.bell-item:focus-visible { outline: var(--spms-focus); outline-offset: -2px; }
.bell-mark { flex: 0 0 8px; height: 8px; margin-top: 7px; border-radius: 50%; background: transparent; }
.bell-item.unread .bell-mark { background: var(--spms-primary-600); }
.bell-item.unread .bell-title { font-weight: 600; }
.bell-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.bell-title { font-size: 13.5px; line-height: 1.45; }
.bell-meta { font-size: 12px; color: var(--spms-muted); }
/* ---------- ผู้ใช้ (มุมขวาของแถบบน) ---------- */
.usermenu { position: relative; }
.usermenu > summary { list-style: none; }
.usermenu > summary::-webkit-details-marker { display: none; }
.um-btn { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 8px 0 4px; border-radius: var(--spms-radius); cursor: pointer; color: var(--spms-text); }
.um-btn:hover { background: var(--spms-hover); }
.um-btn:focus-visible { outline: var(--spms-focus); outline-offset: 2px; }
.um-av { width: 32px; height: 32px; border-radius: 50%; background: #DCE6FB; color: var(--spms-primary-700); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: 0 0 32px; }
.um-mt { min-width: 0; max-width: 220px; line-height: 1.25; display: flex; flex-direction: column; text-align: left; }
.um-mt b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.um-mt span { font-size: 11.5px; color: var(--spms-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.um-caret { width: 16px; height: 16px; fill: none; stroke: var(--spms-muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.um-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 70; width: 260px; max-width: calc(100vw - 32px); background: var(--spms-surface);
  border: 1px solid var(--spms-border); border-radius: var(--spms-radius-lg); box-shadow: 0 12px 32px rgba(16, 24, 40, .16); overflow: hidden; }
.um-head { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-bottom: 1px solid var(--spms-border-soft); }
.um-head span { font-size: 12px; color: var(--spms-muted); }
.um-item { display: block; width: 100%; padding: 10px 14px; border: 0; background: none; text-align: left; font: inherit; font-size: 13.5px; color: var(--spms-text); text-decoration: none; cursor: pointer; }
.um-item:hover { background: var(--spms-hover); }
.um-item:focus-visible { outline: var(--spms-focus); outline-offset: -2px; }
.um-out { color: var(--spms-danger); border-top: 1px solid var(--spms-border-soft); }
@media (max-width: 720px) { .um-mt, .um-caret { display: none; } .um-head { display: flex; } }

.bell-all { display: block; padding: 10px 14px; text-align: center; font-size: 13.5px; font-weight: 600; color: var(--spms-primary-700); text-decoration: none; }
.bell-all:hover { background: var(--spms-primary-50); }
.ntf-list { list-style: none; margin: 0; padding: 0; }
.ntf-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-bottom: 1px solid var(--spms-border-soft); }
.ntf-row.unread { background: var(--spms-primary-50); }
.ntf-row .bell-mark { margin-top: 8px; }
.ntf-row.unread .bell-mark { background: var(--spms-primary-600); }
.ntf-body { flex: 1; min-width: 0; }
.ntf-title { font-weight: 600; color: var(--spms-text); text-decoration: none; }
.ntf-title:hover { text-decoration: underline; color: var(--spms-primary-700); }
.ntf-detail { margin: 2px 0 0; font-size: 13.5px; color: var(--spms-text-2); overflow-wrap: anywhere; }
.ntf-meta { font-size: 12px; color: var(--spms-muted); }
.pref-table td, .pref-table th { text-align: center; }
.pref-table td:first-child, .pref-table th:first-child { text-align: left; }
.pref-table input[type="checkbox"] { width: 20px; height: 20px; }
.chan-status { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.chan-status .card { padding: 16px; }
@media (max-width: 720px) {
  .bell-pop { position: fixed; left: 16px; right: 16px; top: 104px; width: auto; max-width: none; }
}
.form fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }

/* นับถอยหลังก่อนบันทึกผลการพิจารณา (FR-RV-07) — site.js สร้างแทนที่ปุ่มส่งชั่วคราว */
.undo-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; padding: 10px 12px; border-radius: var(--spms-radius);
  background: var(--spms-warning-bg); color: var(--spms-warning); border: 1px solid #F7D4A6; font-weight: 600; }
.undo-bar .undo-actions { display: flex; gap: 8px; }

/* ---------- ข้อความจัดรูปแบบ: editor (Quill snow) + การแสดงผล ---------- */
.rte { border: 1px solid var(--spms-border-strong); border-radius: var(--spms-radius); background: var(--spms-surface); }
.rte:focus-within { outline: var(--spms-focus); outline-offset: 1px; }
.rte .ql-toolbar.ql-snow { border: 0; border-bottom: 1px solid var(--spms-border); font-family: inherit; padding: 6px; }
.rte .ql-container.ql-snow { border: 0; font-family: inherit; font-size: 14px; }
.rte .ql-editor { min-height: 140px; line-height: 1.7; color: var(--spms-text); }
.rte .ql-editor.ql-blank::before { color: var(--spms-muted); font-style: normal; }
.rte.is-disabled { background: var(--spms-bg); opacity: .7; }
.rte.is-disabled .ql-toolbar { pointer-events: none; }
.rich { line-height: 1.7; }
.rich > :first-child { margin-top: 0; }
.rich > :last-child { margin-bottom: 0; }
.rich p { margin: 0 0 8px; }
.rich ul, .rich ol { margin: 0 0 8px; padding-left: 24px; }
.rich .ql-indent-1 { padding-left: 2em; } .rich .ql-indent-2 { padding-left: 4em; } .rich .ql-indent-3 { padding-left: 6em; } .rich .ql-indent-4 { padding-left: 8em; }

/* ผู้รับผิดชอบแผน: แถวลิงก์เชิญใต้รายชื่อ */
.row-sub td { border-top: 0; padding-top: 0; }
.row-sub .input-row { flex-wrap: wrap; }
.row-sub .input-row input { flex: 1 1 280px; min-width: 0; }

/* Wizard ขั้นที่ 4: ตัวเลือกไตรมาส + ใช้งบหรือไม่ (การ์ดคลิกได้ทั้งใบ, checkbox/radio จริงอยู่มุมบน) */
.q-picker, .choice-group { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.q-picker legend, .choice-group legend { font-weight: 600; padding: 0; margin-bottom: 4px; }
.q-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.q-tile, .choice-tile {
  position: relative; display: flex; flex-direction: column; gap: 2px; cursor: pointer;
  padding: 14px 14px 12px; border: 1px solid var(--spms-border-strong); border-radius: var(--spms-radius-lg);
  background: var(--spms-surface); transition: border-color .15s, background-color .15s, box-shadow .15s;
}
.q-tile:hover, .choice-tile:hover { border-color: var(--spms-primary-300); background: var(--spms-hover); }
.q-tile input, .choice-tile input {
  position: absolute; top: 12px; right: 12px; width: 18px; height: 18px; margin: 0; accent-color: var(--spms-primary-600);
}
.q-tile:has(input:focus-visible), .choice-tile:has(input:focus-visible) { outline: var(--spms-focus); outline-offset: 2px; }
.q-tile:has(input:checked), .choice-tile:has(input:checked) {
  border-color: var(--spms-primary-600); background: var(--spms-primary-50); box-shadow: inset 0 0 0 1px var(--spms-primary-600);
}
.q-name { font-weight: 700; font-size: 15px; padding-right: 26px; }
.q-range { color: var(--spms-text-2); font-size: 13px; }
.q-months { display: flex; gap: 4px; margin-top: 10px; }
.q-months span {
  flex: 1; text-align: center; font-size: 12px; padding: 4px 0; border-radius: var(--spms-radius-sm);
  background: var(--spms-surface-2); color: var(--spms-muted); border: 1px solid var(--spms-border-soft);
}
.q-tile:has(input:checked) .q-months span { background: var(--spms-primary-600); border-color: var(--spms-primary-600); color: #fff; font-weight: 600; }
.q-tile:has(input:checked) .q-name { color: var(--spms-primary-800); }
.q-rule { margin-left: 6px; font-size: 12px; font-weight: 600; color: var(--spms-warning); background: var(--spms-warning-bg); padding: 2px 8px; border-radius: 999px; }
.q-summary { margin: 0; color: var(--spms-text-2); font-weight: 600; }
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.choice-title { font-weight: 700; padding-right: 26px; }
.choice-desc { color: var(--spms-text-2); font-size: 13px; }
.choice-tile:has(input:checked) .choice-title { color: var(--spms-primary-800); }
/* แท็กมาตรฐานที่อาจเกี่ยวข้อง (ขั้นที่ 1) — checkbox ในป้ายรูปเม็ดยา · เลือกแล้ว = พื้นฟ้า + เครื่องหมายถูก */
.tag-picker { border: 0; padding: 24px 0 0; margin: 12px 0 0; border-top: 1px solid var(--spms-border-soft); min-width: 0; display: flex; flex-direction: column; gap: 8px; }
/* float = legend ไม่ไปทับเส้นขอบบน แต่อยู่ใน padding เหมือน flex item ปกติ */
.tag-picker legend { float: left; width: 100%; font-weight: 600; padding: 0; margin: 0; }
.tag-picker .hint { margin: 0; }
.tag-picker legend + .hint { margin-top: -6px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; min-height: 36px; padding: 6px 14px 6px 10px;
  border: 1px solid var(--spms-border-strong); border-radius: 999px; background: var(--spms-surface); color: var(--spms-text-2);
  transition: border-color .15s, background-color .15s;
}
.tag-chip input { width: 16px; height: 16px; margin: 0; accent-color: var(--spms-primary-600); }
.tag-chip:hover { border-color: var(--spms-primary-300); background: var(--spms-hover); }
.tag-chip:has(input:focus-visible) { outline: var(--spms-focus); outline-offset: 2px; }
.tag-chip:has(input:checked) { border-color: var(--spms-primary-600); background: var(--spms-primary-50); color: var(--spms-primary-800); font-weight: 600; }
.tag-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-badge { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--spms-primary-50); color: var(--spms-primary-800); border: 1px solid var(--spms-primary-300); font-size: 13px; }
.fund-box { margin-top: 16px; padding: 14px 16px; border: 1px solid var(--spms-border); border-radius: var(--spms-radius-lg); background: var(--spms-surface); display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.fund-box > .table-wrap, .fund-box > .budget-sum { align-self: stretch; }
.fund-box .card-subtitle { margin: 0; }
@media (max-width: 960px) { .q-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .choice-grid { grid-template-columns: 1fr; } }
@media (max-width: 380px) { .q-grid { grid-template-columns: 1fr; } }
.fund-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; align-self: stretch; }
.fund-head .hint { margin: 2px 0 0; }
.fund-table tfoot th, .fund-table tfoot td { border-top: 2px solid var(--spms-border); background: var(--spms-surface-2); }
.fund-table .empty-row { text-align: center; padding: 18px 8px; }
.fund-table .field-error { display: block; }
.dlg-form { max-width: 520px; }
.dlg-form .src-form { border: 0; padding: 0; gap: 14px; }
.dlg-form .src-form legend { font-size: 17px; font-weight: 700; padding: 0; margin-bottom: 4px; }
.src-form { align-self: stretch; }
.choice-tile.choice-sm { padding: 10px 12px; }
.choice-tile.choice-sm input { top: 10px; }
.hint-tight { margin-top: 2px; margin-bottom: 0; }
/* กำลังบันทึก… (site.js) — คลุมทั้งหน้า กันกดซ้ำระหว่างรอ */
.loading-overlay { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; background: rgba(23, 33, 51, .28); backdrop-filter: blur(1.5px); }
.loading-box { display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: 220px; max-width: calc(100% - 32px); padding: 22px 28px; background: var(--spms-surface); border-radius: var(--spms-radius-xl); box-shadow: 0 20px 50px rgba(16, 24, 40, .25); text-align: center; }
.loading-text { font-weight: 600; color: var(--spms-text); }
.loading-slow { font-size: 13px; color: var(--spms-muted); }
.loading-spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--spms-primary-100); border-top-color: var(--spms-primary-600); animation: spms-spin .8s linear infinite; }
@keyframes spms-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .loading-spinner { animation-duration: 2.4s; } }
/* ระยะชิดใต้หัวข้อใน Wizard (.wiz-body เป็น flex column gap 18px — ต้องหักด้วย margin ติดลบ) */
.wiz-body > .hint-tight { margin-top: -12px; }
.wiz-body > .subtitle-tight { margin: -8px 0 -8px; }
.fund-head .card-subtitle { margin: 0; }

/* ---------- ผู้ดูแล: เพิ่ม/แก้ไขประกาศหน้าแรก — การ์ดเป็นหมวด + แผงตัวอย่างติดขอบบน + แถบบันทึกติดขอบล่าง ---------- */
.ann-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr); gap: 20px; align-items: start; }
.ann-main { display: flex; flex-direction: column; gap: 16px; }
.ann-sec { display: flex; flex-direction: column; gap: 18px; padding: 22px 24px 24px; }
/* ระยะห่างในการ์ดใช้ gap แทน margin-top 18px ของกฎ .field + .field ทั่วไป */
.ann-edit .ann-sec > :is(.field, .field-row, .field-grid, .field-check, .choice-group) { margin-top: 0; }
.ann-sec-head { display: flex; flex-direction: column; gap: 4px; padding-bottom: 14px; border-bottom: 1px solid var(--spms-border-soft); }
.ann-sec-head .card-title { margin: 0; font-size: 17px; }
.ann-sec-head .hint { margin: 0; }
.ann-sec .field input:not([type="checkbox"]):not([type="radio"]) { width: 100%; }
.choice-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ann-date-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 130px; }
.ann-side { position: sticky; top: 12px; display: flex; flex-direction: column; gap: 16px; }
.ann-kv { gap: 8px 16px; font-size: 14px; }
.ann-preview { border: 1px solid var(--spms-border); border-radius: var(--spms-radius-xl); padding: 18px; background: var(--spms-surface); box-shadow: 0 10px 28px rgba(16, 24, 40, .10); }
.ann-preview-head { margin: 0 0 12px; padding-bottom: 10px; border-bottom: 1px solid var(--spms-border-soft); font-weight: 700; font-size: 15px; }
.ann-preview-empty { box-shadow: none; border-style: dashed; background: var(--spms-surface-2); text-align: center; padding: 32px 20px; }
.ann-preview-empty .muted { margin: 0; }
.ann-preview-note { display: block; margin-top: 10px; }
.ann-state { height: 26px; padding: 0 10px; font-size: 13px; }
.ann-errors { margin: 6px 0 0; padding-left: 20px; }
.ann-errors a { font-weight: 600; }
.ann-bar { z-index: 2; margin-top: 4px; padding: 12px 0; }
/* กล่องอัปโหลดวิดีโอ (แบ่งชิ้น) */
.vup { display: flex; flex-direction: column; gap: 14px; padding: 16px; border: 1px dashed var(--spms-border-strong); border-radius: var(--spms-radius-lg); background: var(--spms-surface-2); }
.ann-edit .vup > .field { margin-top: 0; }
.ann-cover-field { display: flex; flex-direction: column; gap: 12px; }
.ann-edit .ann-cover-field > .field { margin-top: 0; }
.ann-cover-current { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 10px; border: 1px solid var(--spms-border); border-radius: var(--spms-radius); background: var(--spms-surface-2); }
.ann-cover-current img { width: 160px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; display: block; background: #000; }
.vup-current { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--spms-surface); border: 1px solid var(--spms-border); border-radius: var(--spms-radius); }
.vup-icon { width: 36px; height: 36px; flex: 0 0 36px; border-radius: var(--spms-radius); display: grid; place-items: center; background: var(--spms-primary-50); color: var(--spms-primary-700); font-size: 14px; }
.vup-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.vup-meta b { overflow-wrap: anywhere; }
.vup-meta .muted { margin: 0; }
.vup-progress { display: flex; flex-direction: column; gap: 6px; }
.vup-progress progress { width: 100%; height: 10px; accent-color: var(--spms-primary-600); }
.vup-progress-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.vup-done { margin: 0; color: var(--spms-success); font-weight: 600; }
.vup-done:empty { display: none; }
.vup.is-busy { border-color: var(--spms-primary-300); background: var(--spms-primary-50); }
@media (max-width: 1100px) {
  .ann-layout { grid-template-columns: 1fr; }
  .ann-side { position: static; }
}
@media (max-width: 720px) {
  .ann-sec { padding: 18px 16px 20px; }
  .choice-grid-3, .ann-date-row { grid-template-columns: 1fr; }
}

/* ---------- ปิดบัญชีผู้ใช้ / แผน-โครงการที่ไม่มีผู้รับผิดชอบ ---------- */
.card-danger-zone { border-color: #F3C9C4; }
.card-danger-zone .card-title { color: var(--spms-danger); }
.impact-list { margin: 0 0 16px; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.card-title-in { padding: 16px 20px 0; }
.card-flush > .card-title-in + .empty, .card-flush > .card-title-in + .table-wrap { margin-top: 12px; }
.assign-card { border-color: var(--spms-primary-300); }
.assign-card p { margin: 0 0 14px; }
.alert .btn { margin-left: 8px; }
