:root {
  --red: #a3171f; --red-dark: #7d1017; --red-soft: color-mix(in srgb, var(--red) 10%, white); --red-light: color-mix(in srgb, var(--red) 80%, #ff7a45); --ink: #1c2230; --muted: #667085; --line: #e6e8ee;
  --bg: #f4f6f9; --card: #fff; --ok: #12784a; --ok-bg: #e6f6ee; --warn: #9a6200; --warn-bg: #fff5da;
  --no: #c0281c; --no-bg: #fdecea; --info: #2563eb; --info-bg: #eaf1ff; --gold: #d4a017; --gold-light: color-mix(in srgb, var(--gold) 55%, white);
  --radius: 12px; --radius-sm: 9px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 2px 8px rgba(16,24,40,.05);
  --shadow-lg: 0 10px 30px rgba(16,24,40,.12); --ctl-h: 38px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Sarabun", "Leelawadee UI", Tahoma, sans-serif; font-size: 15px; line-height: 1.5;
  color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--red); }
::selection { background: var(--red-soft); }
.topbar { background: linear-gradient(120deg, var(--red-dark) 0%, var(--red) 55%, var(--red-light) 100%); color: #fff;
  display: flex; align-items: center; gap: 16px; padding: 10px 24px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 50; box-shadow: 0 2px 12px color-mix(in srgb, var(--red-dark) 30%, transparent); }
.topbar .brand { display: inline-flex; align-items: center; gap: 12px; color: #fff; text-decoration: none;
  font-weight: 700; font-size: 18px; letter-spacing: .2px; }
.topbar .brand-logo { width: 42px; height: 42px; border-radius: 50%; background: #fff; padding: 2px; flex: none;
  box-shadow: 0 0 0 2px rgba(255,255,255,.35), 0 2px 6px rgba(0,0,0,.2); }
/* โลโก้ทุกที่ล็อกขนาดกรอบไว้ ภาพที่อัปโหลดไม่บิดสัดส่วน */
.topbar .brand-logo, .login-logo, .closed-logo, .pv-logo, .logo-thumb { object-fit: contain; }
.logo-thumb { border-radius: 50%; background: #fff; border: 1px solid var(--line); padding: 2px; }
.topbar .brand-text { line-height: 1.25; }
.topbar .brand small { display: block; font-weight: 500; font-size: 12.5px; letter-spacing: 1px; opacity: .85; color: var(--gold-light); }
.login-logo { display: block; margin: 0 auto 10px; width: 88px; height: 88px; }
.login .login-en { text-align: center; margin: -2px 0 4px; font-weight: 600; letter-spacing: 1.5px; color: var(--red); font-size: 14px; }
.topbar nav { margin-left: auto; display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
/* เมนู: ปุ่มทรงแคปซูล ชี้แล้วพื้นสว่างขึ้นและมีเส้นทองใต้ตัวอักษร หน้าปัจจุบันพื้นขาวตัวแดง */
.topbar nav a, .topbar nav button { position: relative; color: #fff; text-decoration: none; background: transparent;
  border: 0; font: inherit; font-size: 15px; cursor: pointer; padding: 7px 14px; border-radius: 999px;
  transition: background .2s ease, color .2s ease, transform .15s ease, box-shadow .2s ease; }
.topbar nav a::after { content: ""; position: absolute; left: 50%; bottom: 3px; width: 0; height: 2px;
  background: var(--gold-light); border-radius: 2px; transition: width .25s ease, left .25s ease; }
.topbar nav a:hover { background: rgba(255,255,255,.16); transform: translateY(-1px); }
.topbar nav a:hover::after { width: 50%; left: 25%; }
.topbar nav a:focus-visible, .topbar nav button:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 2px; }
.topbar nav a.active { background: #fff; color: var(--red); font-weight: 600; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.topbar nav a.active::after { display: none; }
.topbar nav .who { display: inline-flex; align-items: center; gap: 7px; margin-left: 10px; padding: 4px 12px 4px 4px;
  border-radius: 999px; background: rgba(255,255,255,.12); font-size: 14px; }
.topbar nav .who .avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--gold-light); color: var(--red-dark);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.topbar nav .who-text { display: flex; flex-direction: column; line-height: 1.2; }
.topbar nav .who-text small { font-size: 11.5px; opacity: .85; color: var(--gold-light); max-width: 220px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar nav form { margin: 0; }
/* ปุ่มดาวน์โหลด Excel (ไอคอนสีเขียว Excel) */
.btn.xlsx-btn { display: inline-flex; align-items: center; gap: 6px; border-color: #1D6F42; color: #1D6F42; }
.btn.xlsx-btn:hover { background: #e8f3ec; }
/* ปุ่มขนาดตัวอักษร ก- ก ก+ */
.topbar nav .font-size-ctl { display: inline-flex; margin-left: 8px; border: 1px solid rgba(255,255,255,.45); border-radius: 999px; overflow: hidden; }
.topbar nav .font-size-ctl button { padding: 4px 10px; border-radius: 0; font-weight: 700; line-height: 1.2; }
.topbar nav .font-size-ctl button[data-font="-1"] { font-size: 13px; }
.topbar nav .font-size-ctl button[data-font="0"] { font-size: 15px; border-left: 1px solid rgba(255,255,255,.3); border-right: 1px solid rgba(255,255,255,.3); }
.topbar nav .font-size-ctl button[data-font="1"] { font-size: 18px; }
.topbar nav .font-size-ctl button sup { font-size: .6em; margin-left: 1px; }
.topbar nav .font-size-ctl button:hover:not(:disabled) { background: rgba(255,255,255,.18); }
.topbar nav .font-size-ctl button:disabled { opacity: .4; cursor: default; }
.topbar nav .font-size-ctl button.on { background: var(--gold-light); color: var(--red-dark); }
.topbar nav button.logout { border: 1px solid rgba(255,255,255,.55); padding: 6px 14px; font-size: 14px; }
.topbar nav button.logout:hover { background: #fff; color: var(--red); border-color: #fff; }
main { max-width: 1320px; margin: 0 auto; padding: 24px 20px 56px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
h1 { font-size: 24px; font-weight: 700; margin: 0 0 4px; letter-spacing: -.2px; }
h2 { font-size: 18px; font-weight: 700; margin: 26px 0 10px; }
.sub { color: var(--muted); margin: 0 0 18px; }
/* ข้อความแจ้งผล: แถบมีขอบสีด้านซ้าย */
.msgs { list-style: none; padding: 0; margin: 0 0 16px; }
.msgs li { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 8px; background: var(--ok-bg); color: var(--ok);
  border-left: 4px solid currentColor; box-shadow: var(--shadow); animation: slide-in .25s ease; }
.msgs li.error { background: var(--no-bg); color: var(--no); }
.msgs li.warning { background: var(--warn-bg); color: var(--warn); }
.msgs li.info { background: var(--info-bg); color: var(--info); }
@keyframes slide-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
/* กล่องตัวเลขสรุป: แถบสีด้านบนตามความหมาย ชี้แล้วลอยขึ้น */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 16px 0; }
.tile { position: relative; display: block; text-decoration: none; color: inherit; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 18px 12px; box-shadow: var(--shadow); overflow: hidden;
  transition: transform .15s ease, box-shadow .2s ease, border-color .2s ease; }
.tile::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: #c9ced8; }
.tile:nth-child(1)::before { background: var(--red); }
.tile:nth-child(2)::before { background: #98a2b3; }
.tile:nth-child(3)::before { background: var(--ok); }
.tile:nth-child(4)::before { background: var(--no); }
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.tile.active { border-color: var(--red); box-shadow: 0 0 0 2px var(--red-soft), var(--shadow); }
.tile b { display: block; font-size: 30px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: 14px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar .right { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
/* ช่องกรอกและปุ่มสูงเท่ากัน มีกรอบโฟกัส */
input[type=text], input[type=password], input[type=search], select, textarea { font: inherit; padding: 7px 12px; min-height: var(--ctl-h);
  border: 1px solid #d0d5dd; border-radius: var(--radius-sm); background: #fff; color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.btn { font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--ctl-h);
  padding: 7px 16px; border-radius: var(--radius-sm); border: 1px solid #d0d5dd; background: #fff; color: var(--ink); cursor: pointer;
  text-decoration: none; white-space: nowrap; box-shadow: 0 1px 2px rgba(16,24,40,.05);
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .1s ease, box-shadow .15s ease; }
.btn:hover { background: #f5f6f8; border-color: #b8bfca; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ok:hover { background: #0d5f3a; }
.btn.info { background: var(--info); border-color: var(--info); color: #fff; }
.btn.info:hover { background: #1d4ed8; border-color: #1d4ed8; }
.btn.no { color: var(--no); border-color: #f3b9b3; background: #fff; }
.btn.no:hover { background: var(--no-bg); }
.btn.info { background: var(--info); border-color: var(--info); color: #fff; }
.btn.info:hover { background: #1d4fd0; border-color: #1d4fd0; }
.btn.danger { background: var(--no); border-color: var(--no); color: #fff; }
.btn.danger:hover { background: #9b1f15; }
.btn.small { min-height: 30px; padding: 3px 11px; font-size: 14px; }
/* ตัดชื่อต้องระบุเหตุผล: ข้อความเตือนสีแดงจนกว่าจะพิมพ์เหตุผล */
form.need-reason .reason-hint { flex-basis: 100%; color: var(--no); font-size: 13px; }
form.need-reason.has-reason .reason-hint { display: none; }
form.need-reason button:disabled { opacity: .5; cursor: not-allowed; }
/* กล่องส่งข้อมูลระบบ RDEN ในหน้าสรุป */
.rden-box { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 14px; border-left: 4px solid var(--red); }
.rden-box form { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.rden-box.locked { border-left-color: var(--ok); background: var(--ok-bg); }
/* หน้าเพิ่ม/แก้ไขผู้ใช้ */
.user-page { max-width: 820px; margin: 0 auto; }
.back-link { display: inline-block; margin-bottom: 8px; color: var(--muted); text-decoration: none; font-size: 14px; }
.back-link:hover { color: var(--red); }
.search-bar { display: flex; gap: 8px; margin-bottom: 14px; }
.search-bar input { flex: 1; min-width: 0; }
.person-card { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.avatar-lg { flex: none; width: 52px; height: 52px; border-radius: 50%; background: var(--red); color: #fff; font-size: 22px;
  font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.person-info { min-width: 0; }
.person-name { font-size: 19px; font-weight: 700; margin-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: #eef2f7; color: var(--ink); border-radius: 999px; padding: 2px 10px; font-size: 13px; }
.chip.muted { color: var(--muted); }
.user-form section { padding: 4px 0 14px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.user-form section:last-of-type { border-bottom: 0; margin-bottom: 0; }
.user-form h2 { font-size: 15px; color: var(--muted); font-weight: 600; margin: 0 0 10px; text-transform: none; }
.user-form .field { margin-bottom: 10px; }
.user-form .field > label { display: block; font-weight: 600; margin-bottom: 4px; }
.user-form .field select, .user-form .field input[type=text], .user-form .field input[type=number] { width: 100%; }
.user-form .field-row { display: flex; gap: 20px; align-items: flex-end; flex-wrap: wrap; }
.user-form .toggle-field { display: flex; gap: 10px; align-items: flex-start; }
.user-form .toggle-field > label:not(.switch), .user-form .toggle-field label[for] { font-weight: 600; margin: 0; cursor: pointer; }
.user-form .field-row .toggle-field { padding-bottom: 8px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); margin-top: 6px; }
/* ผู้ลงนามท้ายบัญชีของส่วนงาน (หน้ารายชื่อ) */
.signer-box { margin-bottom: 14px; padding: 12px 16px; border-left: 4px solid var(--gold); }
.signer-box summary { cursor: pointer; list-style: none; }
.signer-box summary::-webkit-details-marker { display: none; }
.signer-box .link-btn { margin-left: 8px; }
.signer-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.signer-form input[type=text] { flex: 1 1 240px; min-width: 0; }
/* หน้าตั้งค่าเว็บ */
.color-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.color-pick { display: flex; align-items: center; gap: 8px; }
.color-pick input[type=color] { width: 52px; height: 38px; padding: 3px; cursor: pointer; }
.color-pick code { font-size: 13px; color: var(--muted); }
.config-preview { padding: 0; overflow: hidden; margin-bottom: 14px; --pv-primary: var(--red); --pv-dark: var(--red-dark); --pv-accent: var(--gold); }
.pv-bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; color: #fff;
  background: linear-gradient(120deg, var(--pv-dark), var(--pv-primary)); }
.pv-bar img { border-radius: 50%; background: #fff; padding: 2px; }
.pv-bar b { display: block; font-size: 15px; }
.pv-bar small { display: block; font-size: 12px; letter-spacing: 1px; color: color-mix(in srgb, var(--pv-accent) 55%, white); }
.pv-menu { margin-left: auto; background: #fff; color: var(--pv-primary); border-radius: 999px; padding: 3px 12px; font-weight: 600; font-size: 14px; }
.pv-body { padding: 14px 16px; display: flex; gap: 14px; align-items: center; }
.pv-btn { font: inherit; font-weight: 600; background: var(--pv-primary); color: #fff; border: 0; border-radius: 9px; padding: 7px 16px; }
.pv-link { color: var(--pv-primary); text-decoration: underline; }
.pv-foot { border-top: 1px solid var(--line); padding: 10px 16px; font-size: 13px; color: var(--muted); text-align: center; }
.pv-foot b { color: var(--pv-primary); }
@media (max-width: 760px) { .color-row { grid-template-columns: 1fr; } }
/* ปุ่มไอคอนในตาราง */
.row-actions { display: flex; gap: 6px; align-items: center; }
.row-actions form { margin: 0; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 7px;
  border: 1px solid #cbd0d6; background: #fff; color: var(--muted); cursor: pointer; transition: all .15s ease; }
.icon-btn.danger:hover { background: var(--no); border-color: var(--no); color: #fff; }
/* สวิตช์เลื่อนเปิด/ปิด (หน้าจัดการผู้ใช้) */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; cursor: pointer; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .slider { position: absolute; inset: 0; background: #cbd0d6; border-radius: 999px; transition: background .2s ease; }
.switch .slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff;
  border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s ease; }
.switch input:checked + .slider { background: var(--ok); }
.switch input:checked + .slider::before { transform: translateX(20px); }
.switch input:focus-visible + .slider { outline: 2px solid #0d6efd; outline-offset: 2px; }
/* หน้าต่างยืนยัน (แทน confirm() ของเบราว์เซอร์) */
dialog.modal { border: none; border-radius: 12px; padding: 0; width: min(440px, calc(100vw - 32px));
  box-shadow: 0 20px 50px rgba(0,0,0,.25); color: var(--ink); font-family: inherit; }
dialog.modal::backdrop { background: rgba(17,24,39,.45); }
dialog.modal form { padding: 22px 24px 18px; }
dialog.modal .modal-title { margin: 0 0 8px; font-size: 20px; }
dialog.modal .modal-body { margin: 0 0 20px; white-space: pre-line; color: #374151; line-height: 1.6; }
dialog.modal .modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
/* pop up ข้อตกลงการใช้ข้อมูล (PDPA) */
dialog.terms-modal { width: min(620px, calc(100vw - 24px)); border-top: 5px solid var(--gold); }
dialog.terms-modal::backdrop { background: rgba(17,24,39,.6); backdrop-filter: blur(3px); }
.terms-head { display: flex; gap: 14px; align-items: center; padding: 20px 24px 12px; border-bottom: 1px solid var(--line); }
.terms-head h2 { margin: 0; font-size: 20px; }
.terms-head p { margin: 2px 0 0; }
.terms-icon { flex: none; width: 46px; height: 46px; border-radius: 50%; background: var(--red-soft); display: inline-flex;
  align-items: center; justify-content: center; font-size: 22px; }
.terms-body { padding: 14px 24px 20px !important; max-height: min(70vh, 640px); overflow-y: auto; overflow-x: hidden; }
dialog.terms-modal { overflow: hidden; }
.terms-body > p { margin: 0 0 8px; }
.terms-list { margin: 0 0 12px; padding-left: 22px; line-height: 1.7; }
.terms-list li { margin-bottom: 4px; }
.terms-agree { display: flex; gap: 10px; align-items: center; padding: 10px 12px; margin: 6px 0 16px; border-radius: var(--radius-sm);
  background: #f8f9fb; border: 1px solid var(--line); font-weight: 600; cursor: pointer; }
.terms-agree input { width: 18px; height: 18px; accent-color: var(--red); }
.accepted-list { margin-top: 6px; }
.accepted-list summary { cursor: pointer; color: var(--red); font-weight: 600; margin-bottom: 8px; }
.user-form textarea { width: 100%; }
/* ตาราง: อยู่ในการ์ดมุมโค้ง หัวตารางติดด้านบน ชี้แถวแล้วไฮไลต์ */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
.table-wrap.card { padding: 0 !important; overflow: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card); }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f8f9fb; font-weight: 600; font-size: 13.5px; color: #475467; position: sticky; top: 0; z-index: 1;
  white-space: nowrap; border-bottom: 1px solid #dfe3ea; }
tbody tr { transition: background .12s ease; }
tbody tr:hover td { background: #fafbfd; }
tbody tr:last-child td { border-bottom: 0; }
td.num { font-variant-numeric: tabular-nums; color: var(--muted); }
.name { font-weight: 600; }
.meta { color: var(--muted); font-size: 13px; }
tr.child-dept td:first-child { padding-left: 28px; }
.remark-add { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; }
.remark-add input[type=text] { min-width: 240px; flex: 1; }
.be-date select { margin-right: 2px; }
tr.row-focus td { background: #fff3bf !important; transition: background .4s; }  /* แถวที่เพิ่งบันทึก */
.ks2-icon {display: inline-block; margin-left: 6px; padding: 0 6px; border: 1px solid var(--line, #ccc); border-radius: 6px; text-decoration: none; white-space: nowrap; }
.ks2-icon:hover { background: #2563eb; border-color: #2563eb; color: #fff; }
.cls { white-space: nowrap; }
.cls .to { font-weight: 700; color: var(--red); }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: #f2f4f7; color: #344054; margin-top: 4px; }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.rjp { background: #fff3d6; color: #8a5a00; border: 1px solid #f0d58c; }
/* ผลการตรวจ: ป้ายทรงแคปซูลมีจุดสี */
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13.5px; white-space: nowrap;
  padding: 3px 11px; border-radius: 999px; background: #f2f4f7; color: #475467; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.C { color: var(--ok); background: var(--ok-bg); }
.status.R { color: var(--no); background: var(--no-bg); }
.status.P { color: #667085; background: #f2f4f7; font-weight: 500; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: flex-start; }
.actions form { margin: 0; }
details.remove summary { list-style: none; }
details.remove summary::-webkit-details-marker { display: none; }
details.remove[open] summary { display: none; }
details.remove form { display: flex; gap: 6px; flex-wrap: wrap; }
details.remove input[type=text] { width: 220px; }
tr.R td { background: #fff8f7; }
.empty { text-align: center; color: var(--muted); padding: 36px; }
/* แถบแจ้งสถานะในหน้า */
.readonly { display: inline-block; background: var(--warn-bg); color: var(--warn); padding: 8px 14px; border-radius: var(--radius-sm);
  margin: 0 0 14px; border-left: 4px solid currentColor; }
.toolbar .readonly { margin: 0; padding: 6px 12px; }
.prename-form { margin-top: 6px; display: flex; gap: 4px; flex-wrap: wrap; }
.submitted { background: var(--ok-bg); color: var(--ok); padding: 10px 14px; border-radius: var(--radius-sm); margin: 0 0 14px;
  font-weight: 600; border-left: 4px solid currentColor; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.sub-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.sub-row form { margin: 0; }
.status-icon { position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; margin-left: 6px; border-radius: 50%; background: #f3e8ff; color: #7e22ce;
  font-size: 13px; font-weight: 700; cursor: help; vertical-align: middle; }
.status-icon:hover::after, .status-icon:focus::after { content: attr(data-tip); position: absolute; left: 50%; bottom: 125%;
  transform: translateX(-50%); white-space: nowrap; background: #1f2328; color: #fff; font-size: 13px; font-weight: 400;
  padding: 5px 9px; border-radius: 6px; z-index: 10; box-shadow: 0 4px 12px rgba(0,0,0,.2); }
.alert-red { display: inline-block; background: var(--no-bg); color: var(--no); padding: 8px 14px; border-radius: var(--radius-sm);
  margin: 0 0 14px; font-weight: 600; border-left: 4px solid currentColor; }
.badge.missing { background: var(--no-bg); color: var(--no); }
.criteria { color: var(--ink); font-weight: 600; margin-bottom: 3px; }
.pdf-remark { margin-top: 4px; color: #1d4ed8; }
.link-btn { color: var(--red); cursor: pointer; font-size: 13px; margin-top: 4px; display: inline-block; }
.prename-form select { padding: 2px 8px; min-height: 28px; font-size: 13px; border-radius: 7px; }
details.remove input[type=text], .actions select, .actions input[type=text] { min-height: 30px; padding: 3px 10px; font-size: 14px; }
.prename-form.missing select { border-color: var(--no); background: var(--no-bg); color: var(--no); font-weight: 600; }
.badge.added { background: #e0ecff; color: #1d4ed8; }
.badge.changed { background: #f3e8ff; color: #7e22ce; }
.changed-reason { color: #7e22ce; margin-bottom: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label { display: block; font-weight: 600; margin-bottom: 4px; }
.form-grid input, .form-grid select, .form-grid textarea { width: 100%; }
.errorlist { color: var(--no); margin: 4px 0 0; padding-left: 18px; font-size: 14px; }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.pager .pages { display: flex; gap: 4px; flex-wrap: wrap; }
.pager .current { background: var(--red); border-color: var(--red); color: #fff; cursor: default; }
.pager .btn { min-width: 36px; }
.reason { font-size: 13px; color: var(--muted); max-width: 340px; }
/* login */
/* ท้ายหน้า */
body { min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; width: 100%; }
.site-footer { text-align: center; padding: 16px 12px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line);
  background: #fff; }
.site-footer .sep { margin: 0 6px; color: #c4c9d2; }
.site-footer .powered { margin-left: 10px; }
.site-footer .powered b { color: var(--red); font-weight: 600; }
@media (max-width: 760px) { .site-footer .powered { display: block; margin: 4px 0 0; } }
.login-wrap { flex: 1; min-height: 0; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 10% -10%, var(--red-light) 0%, transparent 60%),
              linear-gradient(150deg, color-mix(in srgb, var(--red-dark) 75%, black) 0%, var(--red-dark) 35%, var(--red) 60%, #f4f6f9 60.2%); }
.login { width: 100%; max-width: 420px; background: #fff; border-radius: 18px; padding: 34px 32px 30px; box-shadow: 0 24px 60px rgba(16,24,40,.25);
  border-top: 5px solid var(--gold); }
.login h1 { text-align: center; font-size: 21px; line-height: 1.4; }
.login p.sub { text-align: center; }
.login label { display: block; margin: 14px 0 6px; font-weight: 600; }
.login input { width: 100%; min-height: 44px; }
.login .btn { width: 100%; margin-top: 22px; min-height: 46px; font-size: 16px; }
.login .err { background: var(--no-bg); color: var(--no); padding: 9px 14px; border-radius: var(--radius-sm); border-left: 4px solid currentColor; }
@media (max-width: 760px) {
  main { padding: 16px 12px 40px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile b { font-size: 26px; }
  .toolbar .right { margin-left: 0; }
  .topbar { padding: 10px 14px; position: static; }
  .topbar .brand { font-size: 16px; }
}
.req { color: #d32f2f; font-weight: 700; }
.btn.dl:hover { background: #2563eb; border-color: #2563eb; color: #fff; } /* ปุ่มดาวน์โหลดไฟล์ */
/* pop up แบบประเมินความพึงพอใจ: มุมซ้ายล่าง */
.survey-pop { position: fixed; left: 20px; bottom: 24px; width: 270px; z-index: 40; background: var(--card); border-radius: 16px;
  box-shadow: 0 18px 40px rgba(16,24,40,.18), 0 2px 6px rgba(16,24,40,.06); overflow: hidden; animation: survey-in .45s ease-out both; }
.survey-pop[hidden] { display: none; }
.survey-head { position: relative; padding: 20px 20px 16px; color: #fff; text-align: center;
  background: linear-gradient(135deg, var(--red) 0%, var(--red-dark) 100%); }
.survey-head::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: linear-gradient(90deg, var(--gold), var(--gold-light), var(--gold)); }
.survey-badge { width: 54px; height: 54px; margin: 0 auto 10px; border-radius: 50%; display: grid; place-items: center; font-size: 26px;
  background: rgba(255,255,255,.16); box-shadow: inset 0 0 0 2px rgba(255,255,255,.35); }
.survey-head b { display: block; font-size: 17px; letter-spacing: .2px; }
.survey-stars { margin-top: 6px; color: var(--gold-light); font-size: 15px; letter-spacing: 3px; }
.survey-body { padding: 16px 20px 20px; text-align: center; }
.survey-body p { margin: 0 0 16px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.survey-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 42px; border-radius: 10px;
  background: var(--red); color: #fff; font-weight: 600; text-decoration: none; box-shadow: 0 6px 14px color-mix(in srgb, var(--red) 30%, transparent);
  transition: background .2s, transform .2s, box-shadow .2s; }
.survey-btn:hover { background: var(--red-dark); transform: translateY(-1px); box-shadow: 0 8px 18px color-mix(in srgb, var(--red) 38%, transparent); color: #fff; }
.survey-later { margin-top: 10px; border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }
.survey-later:hover { color: var(--ink); text-decoration: underline; }
.survey-close { position: absolute; top: 8px; right: 8px; z-index: 1; width: 30px; height: 30px; border: 0; border-radius: 50%;
  background: rgba(255,255,255,.18); color: #fff; font-size: 18px; line-height: 1; cursor: pointer; transition: background .2s; }
.survey-close:hover { background: rgba(255,255,255,.32); }
@keyframes survey-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@media (max-width: 600px) { .survey-pop { left: 12px; right: 12px; width: auto; } }/* ระบบทดสอบ (ฐานข้อมูลชื่อมี TEST): แถบเตือนบนสุด และป้ายข้างชื่อระบบ ไม่แสดงบนเซิร์ฟเวอร์จริง */
.test-strip { background: repeating-linear-gradient(45deg, #f59e0b, #f59e0b 14px, #fbbf24 14px, #fbbf24 28px); color: #3b2300;
  text-align: center; font-weight: 700; font-size: 14px; padding: 5px 12px; letter-spacing: .2px; }
.test-badge { display: inline-block; vertical-align: middle; margin-left: 6px; padding: 1px 10px; border-radius: 999px;
  background: #fbbf24; color: #3b2300; font-size: 12px; font-weight: 700; }
/* ตั้งค่าเว็บ: ภาพพื้นหลังที่ใช้อยู่ และปุ่มคืนธีมตั้งต้น */
.bg-thumb { width: 100%; max-width: 320px; height: 120px; border-radius: 10px; border: 1px solid var(--line);
  background-size: cover; background-position: center; margin-bottom: 8px; }
.theme-reset { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }

/* ผลประเมินย้อนหลัง 5 ปี (หน้ารายชื่อ) ต่ำกว่า "ดี" = แดง */
.perf[title] { cursor: help; }
.perf.perf-low { color: #c62828; font-weight: 600; }
.perf .perf-pass { color: #2e7d32; font-weight: 600; }
.perf .perf-miss { color: #b26a00; font-weight: 400; }
.doc-table td { vertical-align: middle; }
.doc-table .doc-up { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ปิดระบบชั่วคราว: หน้าแจ้งผู้ใช้ และแถบเตือนแอดมินสูงสุด */
.lock-strip { background: #fff3cd; color: #7a4b00; border-bottom: 1px solid #f0c36d; padding: 8px 16px; text-align: center; font-weight: 600; }
.lock-strip a { color: inherit; text-decoration: underline; }
.closed-page { min-height: 70vh; display: flex; align-items: center; justify-content: center; padding: 32px 16px; }
.closed-card { background: #fff; border-radius: 16px; box-shadow: 0 8px 30px rgba(0,0,0,.08); max-width: 560px; width: 100%;
  padding: 36px 28px; text-align: center; border-top: 6px solid var(--red); }
.closed-card h1 { margin: 12px 0 4px; color: var(--red-dark); font-size: 1.6rem; }
.closed-icon { font-size: 2.6rem; margin-top: 8px; }
.closed-system { color: #666; margin: 0 0 18px; }
.closed-msg { background: #fbf6ec; border: 1px solid #ecdcb8; border-radius: 10px; padding: 14px 18px; margin-bottom: 16px; font-size: 1.05rem; }
.closed-msg p { margin: 4px 0; }