/* คลังเอกสาร วจก. — โทนสี modern-academic */
:root {
  --navy: #1E3A8A;
  --navy-700: #172E6E;
  --pink: #EC4899;
  --pink-btn: #DB2777;      /* ใช้เมื่อมีตัวอักษรขาวบนชมพู (contrast ≥ 4.5:1) */
  --pink-ink: #BE185D;
  --pink-bg: #FCE7F3;
  --sky: #60A5FA;
  --sky-bg: #EFF6FF;
  --sky-200: #BFDBFE;
  --blue-100: #DBEAFE;
  --bg: #F3F4F6;
  --ink: #111827;
  --ink-2: #374151;
  --muted: #4B5563;
  --line: #E5E7EB;
  --line-2: #D1D5DB;
  --white: #FFFFFF;
  --radius: 14px;
  --font: 'IBM Plex Sans Thai', Tahoma, 'Leelawadee UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.6; }
a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.3; margin: 0; }
img, svg { max-width: 100%; }
.ico { flex-shrink: 0; vertical-align: middle; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; border-radius: 6px; }
.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; }
.sr-only-focusable:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip { position: absolute; left: -9999px; top: 8px; background: var(--white); padding: 8px 14px; border-radius: 8px; z-index: 50; }
.skip:focus { left: 8px; }
.wrap { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 24px; }
.narrow { max-width: 720px; padding-top: 48px; padding-bottom: 48px; }
.meta { color: var(--muted); font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.empty { color: var(--muted); font-size: 15px; padding: 12px 0; }
.nowrap { white-space: nowrap; }
.small { font-size: 12px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- ปุ่ม ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; font-size: 15px; cursor: pointer; background: transparent; color: var(--ink); text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--navy); color: var(--white); }
.btn-primary:hover { background: var(--navy-700); color: var(--white); }
.btn-accent { background: var(--pink-btn); color: var(--white); }
.btn-accent:hover { background: var(--pink-ink); }
.btn-outline { background: var(--white); border-color: var(--line-2); color: var(--navy); }
.btn-outline:hover { border-color: var(--navy); }
.btn-ghost { color: var(--muted); }
.btn-ghost:hover { background: var(--bg); color: var(--ink); }
.btn-danger { background: var(--white); border-color: #FBCFE8; color: var(--pink-ink); }
.btn-danger:hover { background: #FDF2F8; }
.btn-google { background: var(--white); border-color: var(--line-2); color: var(--ink); }
.btn-google:hover { border-color: var(--muted); }
.btn-icon { width: 44px; padding: 0; background: var(--white); border-color: var(--line-2); color: var(--navy); }
.btn-lg { min-height: 54px; padding: 0 26px; font-size: 16px; border-radius: 12px; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-xs { min-height: 28px; width: auto; padding: 0 8px; font-size: 12px; border-radius: 6px; }
.btn-icon.btn-xs { width: 28px; padding: 0; }
.btn-block { width: 100%; }

.chip { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--white); color: var(--ink-2); font-size: 14px; font-weight: 500; }
.chip:hover { text-decoration: none; border-color: var(--navy); }
.chip.is-on { background: var(--navy); color: var(--white); border-color: var(--navy); }
.chip-light { background: transparent; color: var(--white); border-color: rgba(255,255,255,.4); }
.chip-light:hover { background: rgba(255,255,255,.12); border-color: var(--white); }

.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 1px 9px; border-radius: 999px; line-height: 1.7; vertical-align: middle; }
.tag-new { background: var(--pink-bg); color: var(--pink-ink); }
.tag-upd { background: var(--blue-100); color: var(--navy); }
.tag-lock { background: var(--navy); color: var(--white); }
.tag-pdpa { background: #FEF3C7; color: #92400E; }

/* ---------- ไอคอนไฟล์ ---------- */
.ficon { position: relative; display: inline-flex; align-items: flex-end; justify-content: center; flex-shrink: 0; border-radius: 7px; font-weight: 700; letter-spacing: .02em; }
.ficon::after { content: ""; position: absolute; top: 0; right: 0; width: 30%; height: 25%; background: rgba(255,255,255,.7); border-bottom-left-radius: 5px; }
.ficon-sm { width: 32px; height: 38px; font-size: 8.5px; padding-bottom: 5px; border-radius: 5px; }
.ficon-md { width: 40px; height: 48px; font-size: 10px; padding-bottom: 7px; }
.ficon-lg { width: 44px; height: 52px; font-size: 11px; padding-bottom: 8px; }
.ficon-xl { width: 88px; height: 108px; font-size: 20px; padding-bottom: 16px; border-radius: 12px; }
.ft-pdf { background: #FEE2E2; color: #B91C1C; }
.ft-doc { background: #DBEAFE; color: #1D4ED8; }
.ft-xls { background: #DCFCE7; color: #15803D; }
.ft-ppt { background: #FFEDD5; color: #C2410C; }
.ft-zip, .ft-txt { background: #E5E7EB; color: #374151; }

/* ---------- ประกาศ ---------- */
.notice { padding: 12px 16px; border-radius: 10px; margin: 0 0 16px; font-size: 15px; border: 1px solid; }
.notice-ok { background: #F0FDF4; border-color: #BBF7D0; color: #166534; }
.notice-warn { background: #FFFBEB; border-color: #FDE68A; color: #92400E; }
.notice-error { background: #FDF2F8; border-color: #FBCFE8; color: #9D174D; }
.flash-wrap { padding-top: 16px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: var(--white); padding: 10px 18px; border-radius: 10px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60; }
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }

/* ================= หน้าบ้าน ================= */
.topbar { background: var(--white); border-bottom: 1px solid var(--line); }
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 72px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 40px; height: 40px; border-radius: 10px; background: var(--navy); color: var(--white); display: grid; place-items: center; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.brand-text strong { font-size: 18px; }
.brand-text small { font-size: 13px; color: var(--muted); }
.topnav { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; }
.topnav > a { padding: 10px 16px; border-radius: 8px; font-size: 15px; font-weight: 500; color: var(--ink-2); }
.topnav > a:hover { background: var(--bg); text-decoration: none; }
.topnav > a.is-active { background: var(--sky-bg); color: var(--navy); font-weight: 600; }
.userchip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 4px 4px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; color: var(--ink-2); }
.userchip form { margin: 0; }
.userchip button { white-space: nowrap; border: 0; background: var(--bg); border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; }

.hero { background: var(--navy); color: var(--white); padding: 56px 0 48px; }
.hero-kicker { margin: 0 0 10px; color: var(--sky-200); font-weight: 600; font-size: 15px; }
.hero h1 { font-size: clamp(28px, 4vw, 44px); font-weight: 700; max-width: 820px; }
.hero-search { margin-top: 28px; display: flex; align-items: center; gap: 10px; background: var(--white); border-radius: 14px; padding: 6px 6px 6px 18px; max-width: 860px; box-shadow: 0 10px 30px rgba(17,24,39,.2); }
.hero-search-ico { color: #6B7280; display: flex; }
.hero-search input, .field-search input { flex: 1; min-width: 0; border: 0 !important; outline: 0; box-shadow: none !important; padding: 0; background: transparent; }
.hero-search input { font-size: 17px; height: 48px; color: var(--ink); }
.hero-search input::placeholder { color: #6B7280; }
.hero-search .btn { min-height: 50px; padding: 0 28px; }
.hero-types { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; color: var(--blue-100); font-size: 14px; }
.hero-types > span { margin-right: 4px; }
.hero-stats { margin: 24px 0 0; color: var(--blue-100); font-size: 15px; }
.hero-stats strong { color: var(--white); font-size: 22px; margin: 0 4px 0 0; }
.hero-stats strong:nth-of-type(2) { margin-left: 24px; }

.home { padding-top: 44px; padding-bottom: 56px; display: flex; flex-direction: column; gap: 40px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 18px; }
.block-head h2, .panel h2 { font-size: 21px; }
.catgrid { display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); gap: 18px; }
.catcard { display: flex; gap: 16px; align-items: flex-start; background: var(--white); border: 1px solid var(--line); border-radius: 16px; padding: 22px; color: var(--ink); transition: border-color .15s; }
.catcard:hover { border-color: var(--sky); text-decoration: none; }
.catcard-ico { width: 48px; height: 48px; border-radius: 12px; background: var(--sky-bg); color: var(--navy); display: grid; place-items: center; flex-shrink: 0; }
.catcard-body { display: flex; flex-direction: column; gap: 4px; }
.catcard-body strong { font-size: 18px; }
.catcard-body small { color: var(--muted); font-size: 14px; }
.catcard-body em { font-style: normal; color: var(--navy); font-weight: 600; font-size: 14px; }
.home-split { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; align-items: start; }

.panel { background: var(--white); border: 1px solid var(--line); border-radius: 16px; padding: 24px; }
.panel > h2 { margin-bottom: 12px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

.dmini { display: flex; align-items: center; gap: 14px; padding: 12px 10px; border-radius: 12px; color: var(--ink); }
.dmini:hover { background: var(--bg); text-decoration: none; }
.dmini-body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.dmini-title { font-weight: 600; font-size: 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.dmini-sm .dmini-title { font-size: 14px; }
.dmini-count { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 14px; flex-shrink: 0; }

.rank { list-style: none; margin: 0; padding: 0; }
.rank a { display: flex; gap: 14px; align-items: flex-start; padding: 10px 6px; border-radius: 10px; color: var(--ink); }
.rank a:hover { background: var(--bg); text-decoration: none; }
.rank span:last-child { display: flex; flex-direction: column; }
.rank small { color: var(--muted); font-size: 13px; }
.rank-no { width: 28px; height: 28px; border-radius: 8px; background: var(--bg); color: var(--navy); font-weight: 700; font-size: 14px; display: grid; place-items: center; flex-shrink: 0; }
.rank-no.is-first { background: var(--pink-btn); color: var(--white); }

/* หน้าหมวด */
.catpage { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 28px; padding-top: 28px; padding-bottom: 56px; align-items: start; }
.cattree-box { background: var(--white); border: 1px solid var(--line); border-radius: 16px; padding: 12px; position: sticky; top: 16px; }
.cattree-box summary { list-style: none; font-size: 13px; font-weight: 600; color: var(--muted); padding: 6px 10px; cursor: default; }
.cattree-box summary::-webkit-details-marker { display: none; }
.tnode { display: flex; align-items: center; gap: 6px; padding: 9px 10px 9px calc(10px + (var(--d) - 1) * 20px); border-radius: 10px; color: var(--ink); font-size: 15px; }
.tnode:hover { background: var(--bg); text-decoration: none; }
.tnode.is-active { background: var(--navy); color: var(--white); font-weight: 600; }
.tnode.is-active .tnode-count, .tnode.is-active .tnode-caret { color: var(--blue-100); }
.tnode-caret { display: flex; color: #9CA3AF; width: 14px; }
.tnode-caret.is-leaf { visibility: hidden; }
.tnode-caret.is-open svg { transform: rotate(90deg); }
.tnode-name { flex: 1; }
.tnode-count { font-size: 13px; color: var(--muted); }
.crumbs { display: flex; flex-wrap: wrap; gap: 8px; font-size: 14px; color: var(--muted); margin-bottom: 12px; }
.catmain h1 { font-size: 30px; }
.lead { color: var(--muted); font-size: 16px; margin: 6px 0 0; }
.toolbar, .filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin: 20px 0 12px; }
.field-search { flex: 1 1 240px; display: flex; align-items: center; gap: 8px; min-height: 44px; border: 1px solid var(--line-2); border-radius: 10px; padding: 0 12px; background: var(--white); color: #6B7280; }
.field-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); }
.field-search:focus-within { border-color: var(--sky); box-shadow: 0 0 0 3px rgba(96,165,250,.3); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.toolbar-label { font-size: 14px; color: var(--muted); }
select, input[type="text"], input[type="email"], input[type="search"], textarea {
  min-height: 44px; border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 12px; background: var(--white); max-width: 100%; }
textarea { resize: vertical; }
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 3px rgba(96,165,250,.3); }
.count-line { color: var(--muted); font-size: 14px; margin: 0 0 10px; min-height: 1em; }
.dlist { background: var(--white); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.drow { display: flex; align-items: center; gap: 18px; padding: 18px 22px; border-bottom: 1px solid var(--bg); }
.drow:last-child { border-bottom: 0; }
.drow-body { flex: 1; min-width: 0; }
.drow-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.drow-title a { font-size: 17px; font-weight: 600; color: var(--ink); }
.drow-desc { margin: 2px 0 0; color: var(--ink-2); font-size: 14px; }
.drow .meta { margin: 4px 0 0; font-size: 13px; }
.drow-count { display: flex; flex-direction: column; align-items: flex-end; width: 84px; flex-shrink: 0; }
.drow-count strong { font-size: 18px; }
.drow-count small { font-size: 12px; color: var(--muted); }
.drow-act { display: flex; gap: 8px; flex-shrink: 0; }
.emptybox { background: var(--white); border: 1px dashed var(--line-2); border-radius: 16px; padding: 36px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.emptybox strong { font-size: 18px; }
.emptybox p { margin: 0; color: var(--muted); max-width: 520px; }
.pager { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 20px; }
.pager a { min-width: 44px; min-height: 44px; padding: 0 12px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line-2); background: var(--white); color: var(--ink-2); font-weight: 600; }
.pager a:hover { border-color: var(--navy); text-decoration: none; }
.pager a.is-current { background: var(--navy); border-color: var(--navy); color: var(--white); }

/* หน้าเอกสาร */
.docpage { padding-top: 28px; padding-bottom: 56px; }
.docgrid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.doccard { background: var(--white); border: 1px solid var(--line); border-radius: 20px; padding: 36px; display: flex; flex-direction: column; gap: 26px; }
.dochead { display: flex; gap: 26px; align-items: flex-start; }
.dochead h1 { font-size: clamp(24px, 3vw, 32px); margin-top: 6px; }
.tags { display: flex; gap: 8px; flex-wrap: wrap; }
.docdesc { color: var(--ink-2); font-size: 17px; line-height: 1.75; margin: 10px 0 0; max-width: 68ch; }
.metagrid { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.metagrid > div { padding: 16px 20px; border-right: 1px solid var(--bg); border-bottom: 1px solid var(--bg); }
.metagrid dt { font-size: 13px; color: var(--muted); }
.metagrid dd { margin: 2px 0 0; font-size: 17px; font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.gate { display: flex; align-items: center; gap: 20px; border: 1.5px solid var(--sky-200); background: var(--sky-bg); border-radius: 16px; padding: 24px; }
.gate p { margin: 4px 0 0; color: var(--ink-2); }
.gate strong { color: var(--navy); font-size: 17px; }
.gate-ico { width: 54px; height: 54px; border-radius: 14px; background: var(--navy); color: var(--white); display: grid; place-items: center; flex-shrink: 0; }
.gate > div { flex: 1; }
.gate-denied { border-color: #FBCFE8; background: #FDF2F8; flex-wrap: wrap; }
.gate-denied strong { color: #9D174D; }
.history h2 { font-size: 20px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; }
.history h2 small { font-size: 14px; color: var(--muted); font-weight: 400; }
.timeline { list-style: none; margin: 14px 0 0; padding: 0 0 0 22px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 18px 6px; }
.timeline li::before { content: ""; position: absolute; left: -29px; top: 7px; width: 12px; height: 12px; border-radius: 50%; background: #9CA3AF; }
.timeline li.is-current::before { background: var(--navy); }
.timeline li > div { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.timeline p { margin: 2px 0 0; color: var(--ink-2); }
.docside { display: flex; flex-direction: column; gap: 20px; }
.docside h2 { font-size: 16px; }
.qrbox { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.qrbox h2 { align-self: flex-start; }
.qr { width: 196px; height: 196px; padding: 0; overflow: hidden; border-radius: 12px; background: var(--white); border: 1px solid var(--line); display: grid; place-items: center; }
.qr canvas { width: 194px; height: 194px; display: block; }

.foot { background: var(--white); border-top: 1px solid var(--line); }
.foot-in { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 24px; color: var(--muted); font-size: 14px; }

/* ================= หลังบ้าน ================= */
.admin-shell { display: flex; min-height: 100vh; flex: 1; }
@media (min-width: 961px) { .admin-shell { background: linear-gradient(to right, var(--navy) 248px, transparent 248px); } }
body.front > main { flex: 1; }
.side { width: 248px; flex-shrink: 0; background: var(--navy); color: var(--white); padding: 24px 16px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side-brand { display: flex; flex-direction: column; padding: 0 12px 20px; }
.side-brand strong { font-size: 18px; }
.side-brand small { color: var(--sky-200); font-size: 13px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a { display: flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 10px; color: var(--white); font-size: 15px; }
.side-nav a:hover { background: rgba(255,255,255,.1); text-decoration: none; }
.side-nav a.is-active { background: var(--white); color: var(--navy); font-weight: 600; }
.side-out { margin-top: auto; display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; color: var(--sky-200); font-size: 14px; }
.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-top { min-height: 72px; background: var(--white); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 16px; padding: 0 32px; }
.admin-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.admin-title h1 { font-size: 21px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb { color: var(--muted); font-size: 15px; }
.crumb::after { content: "›"; margin-left: 10px; color: #9CA3AF; }
.admin-user { display: flex; align-items: center; gap: 12px; }
.admin-user > span { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.35; }
.admin-user strong { font-size: 14px; }
.admin-user small { font-size: 12px; color: var(--muted); }
.admin-user form { margin: 0; }
.side-toggle { display: none; border: 1px solid var(--line); background: var(--white); border-radius: 10px; width: 44px; height: 44px; align-items: center; justify-content: center; cursor: pointer; color: var(--navy); }
.admin-body { padding: 28px 32px 48px; display: flex; flex-direction: column; gap: 20px; }
.admin-body > .notice { margin: 0; }
.page-actions { display: flex; justify-content: flex-end; gap: 10px; margin-bottom: -8px; }
.lead-admin { margin: 0; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.stat { background: var(--white); border: 1px solid var(--line); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 4px; }
.stat span { color: var(--muted); font-size: 14px; }
.stat strong { font-size: 30px; line-height: 1.2; }
.stat small { color: var(--muted); font-size: 13px; }
.storage { padding: 16px 22px; }
.storage-head { display: flex; justify-content: space-between; font-size: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.span-2 { grid-column: span 2; }
.bars { height: 260px; display: flex; align-items: stretch; gap: 10px; padding-top: 8px; }
.bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; min-width: 0; }
.bar-v { font-size: 11px; color: var(--muted); }
.bar-fill { width: 100%; min-height: 2px; max-height: calc(100% - 44px); background: var(--sky); border-radius: 6px 6px 0 0; }
.bar.is-current .bar-fill { background: var(--pink); }
.bar-m { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); width: 100%; text-align: center; padding-top: 4px; }
.toplist { list-style: none; margin: 0; padding: 0; counter-reset: t; }
.toplist li { counter-increment: t; display: flex; gap: 10px; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--bg); font-size: 14px; }
.toplist li::before { content: counter(t); color: var(--navy); font-weight: 700; width: 18px; }
.toplist a { flex: 1; color: var(--ink); }
.missrow { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--bg); flex-wrap: wrap; }
.missrow > strong, .missrow-main { flex: 1; min-width: 160px; }
.missrow-main { display: flex; flex-direction: column; }
.missrow-main a { color: var(--ink); font-weight: 600; font-size: 14px; }
.missrow-main small { color: var(--muted); font-size: 12px; }
.minis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 8px; }
.minis > div { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; }
.minis strong { font-size: 26px; }
.minis span { color: var(--muted); font-size: 13px; }
.logrow { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--bg); font-size: 14px; }

.table-wrap { background: var(--white); border: 1px solid var(--line); border-radius: 14px; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); background: #F9FAFB; padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--bg); vertical-align: middle; }
.table tr.is-off td { opacity: .6; }
.table tr.is-off td:has(.switch) { opacity: 1; }
.col-check { width: 40px; }
.col-check input { width: 18px; height: 18px; }
.col-act { white-space: nowrap; text-align: right; }
.col-act .btn-icon { width: 36px; min-height: 36px; border: 0; }
.tdoc { display: flex; align-items: center; gap: 12px; }
.tdoc > div { display: flex; flex-direction: column; min-width: 0; }
.tdoc-title { font-weight: 600; color: var(--ink); }
.tdoc small { color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.table-foot { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.table-foot .pager { margin: 0; }
.bulkbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; background: var(--sky-bg); border: 1px solid var(--sky-200); border-radius: 10px; padding: 8px 14px; margin-bottom: 12px; }
.bulkbar strong { color: var(--navy); font-size: 14px; }
.bulkbar select { min-height: 36px; font-size: 14px; }
form.inline { display: inline; margin: 0; }

.switch { width: 44px; height: 26px; border-radius: 999px; border: 0; background: var(--line-2); padding: 3px; display: inline-flex; cursor: pointer; transition: background .15s; vertical-align: middle; }
.switch span { width: 20px; height: 20px; border-radius: 50%; background: var(--white); box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--navy); }
.switch[aria-checked="true"] span { transform: translateX(18px); }
.switch[aria-busy="true"] { opacity: .6; }
.switch-input { appearance: none; -webkit-appearance: none; width: 44px; height: 26px; border-radius: 999px; background: var(--line-2); position: relative; cursor: pointer; flex-shrink: 0; margin: 0; transition: background .15s; }
.switch-input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--white); box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch-input:checked { background: var(--navy); }
.switch-input:checked::after { transform: translateX(18px); }

/* ฟอร์มเอกสาร */
.docform { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.docform-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.docform-side .panel { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 16px; }
.docform-side .panel > h2 { margin: 0; }
.docform-extra { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label, .radios legend { font-size: 14px; font-weight: 600; }
.req { color: var(--pink-ink); }
.field-error { margin: 0; color: var(--pink-ink); font-size: 13px; font-weight: 600; }
[aria-invalid="true"] { border-color: var(--pink-ink) !important; }
.filecard { display: flex; align-items: center; gap: 14px; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--white); margin-bottom: 14px; }
.filecard > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.filecard strong { font-size: 15px; overflow-wrap: anywhere; }
.filecard small { color: var(--muted); font-size: 13px; }
.filecard.is-pending { border-color: var(--sky); }
.replacebox { border: 1.5px solid var(--sky); background: #F8FAFF; border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.replacebox.is-new { border: 0; background: transparent; padding: 0; }
.replacebox h3 { display: flex; align-items: center; gap: 8px; font-size: 16px; color: var(--navy); }
.replacebox .field { margin: 0; }
.dropzone { position: relative; border: 2px dashed var(--sky); background: var(--sky-bg); border-radius: 14px; padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; color: var(--navy); cursor: pointer; }
.dropzone span { color: var(--muted); font-size: 13px; }
.dropzone.is-over { background: var(--blue-100); }
.dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone:focus-within { box-shadow: 0 0 0 3px rgba(96,165,250,.45); }
.dropzone-name { color: var(--navy) !important; font-weight: 600; font-size: 14px !important; }
.warnbox { border-radius: 12px; padding: 14px 16px; border: 1px solid; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.warnbox p { margin: 0; color: var(--ink-2); line-height: 1.65; }
.warnbox-info { background: var(--sky-bg); border-color: var(--sky-200); }
.warnbox-info strong { color: var(--navy); font-size: 15px; }
.warnbox-pink { background: #FDF2F8; border-color: #FBCFE8; color: #9D174D; }
.warnbox-pink strong { font-size: 15px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row form { margin: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--navy); flex-shrink: 0; }
.check-block span { display: flex; flex-direction: column; }
.check-block small { color: var(--muted); font-size: 12px; }
.switchrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
.switchrow span { display: flex; flex-direction: column; }
.switchrow small { color: var(--muted); font-size: 13px; }
.radios { border: 0; border-top: 1px solid var(--bg); margin: 0; padding: 14px 0 0; display: flex; flex-direction: column; gap: 8px; }
.radios legend { float: left; width: 100%; margin-bottom: 8px; padding: 0; }
.radiocard { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.radiocard:has(input:checked) { border-color: var(--sky); background: var(--sky-bg); }
.radiocard input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--navy); flex-shrink: 0; }
.radiocard span { display: flex; flex-direction: column; }
.radiocard strong { font-size: 14px; display: flex; align-items: center; gap: 6px; }
.radiocard small { color: var(--muted); font-size: 12px; line-height: 1.5; }
.side-links { margin: 0; font-size: 13px; color: var(--muted); }
.vcard { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 6px; }
.vcard.is-current { background: var(--sky-bg); border-color: var(--sky-200); }
.vcard-head { display: flex; justify-content: space-between; gap: 10px; }
.vcard p { margin: 0; color: var(--ink-2); font-size: 14px; }
.danger h2 { color: var(--pink-ink); }

/* หมวดหมู่ / รายชื่อ */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.side-form { position: sticky; top: 16px; }
.side-stack { display: flex; flex-direction: column; gap: 20px; }
.crow { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px calc(10px + (var(--d) - 1) * 30px); border-radius: 10px; border: 1px solid transparent; }
.crow:hover { background: #F9FAFB; }
.crow.is-selected { background: var(--sky-bg); border-color: var(--sky); }
.crow.is-off .crow-name { color: var(--muted); }
.crow-order { display: flex; gap: 2px; }
.crow-order form { margin: 0; }
.crow-ico { color: var(--navy); display: flex; }
.crow-name { flex: 1; color: var(--ink); font-weight: 600; }
.crow-count { width: 44px; text-align: right; color: var(--muted); font-size: 14px; }
.delete-form { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--bg); }
.kv { margin: 0 0 12px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.kv > div { display: flex; justify-content: space-between; gap: 10px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 700; }
.kv .ok { color: #15803D; }
.kv .bad { color: var(--pink-ink); }

/* หน้าเข้าสู่ระบบหลังบ้าน */
body.login { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.loginbox { background: var(--white); border: 1px solid var(--line); border-radius: 20px; padding: 40px; width: 100%; max-width: 460px; display: flex; flex-direction: column; gap: 16px; }
.loginbox-brand { display: flex; align-items: center; gap: 12px; }
.loginbox-brand div { display: flex; flex-direction: column; }
.loginbox-brand small { color: var(--muted); }
.loginbox h1 { font-size: 24px; margin-top: 8px; }
.loginbox p { margin: 0; color: var(--muted); }
.loginbox .notice { margin: 0; }
.loginbox-back { font-size: 14px; text-align: center; }

/* ---------- จอเล็ก ---------- */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .docform, .docform-extra, .split { grid-template-columns: 1fr; }
  .docform-side .panel, .side-form { position: static; }
}
@media (max-width: 960px) {
  .catgrid { grid-template-columns: repeat(min(var(--cols, 3), 2), minmax(0, 1fr)); }
  .home-split, .docgrid, .grid-2 { grid-template-columns: 1fr; }
  .catpage { grid-template-columns: 1fr; }
  .cattree-box { position: static; }
  .cattree-box summary { cursor: pointer; font-size: 15px; color: var(--navy); padding: 10px; }
  .cattree-box summary::after { content: ' ▾'; }
  .side { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .side.is-open { transform: none; box-shadow: 0 0 0 100vmax rgba(17,24,39,.4); }
  .side-toggle { display: inline-flex; }
  .admin-top { padding: 0 16px; }
  .admin-body { padding: 20px 16px 40px; }
  .admin-user > span { display: none; }
}
@media (max-width: 640px) {
  .wrap { padding-left: 16px; padding-right: 16px; }
  .home { padding-top: 28px; }
  .topbar-in { min-height: 60px; gap: 8px; }
  .brand-mark { width: 36px; height: 36px; }
  .brand-text strong { font-size: 16px; white-space: nowrap; }
  .brand-text small { display: none; }
  .topnav { gap: 2px; }
  .topnav > a { padding: 8px; font-size: 14px; white-space: nowrap; }
  .userchip span { display: none; }
  .topnav:has(.userchip) > a:first-child { display: none; } /* ล็อกอินแล้วพื้นที่ไม่พอ: โลโก้ก็พากลับหน้าแรกอยู่แล้ว */
  .userchip { padding: 3px; }
  .userchip button { padding: 6px 8px; font-size: 12px; }
  .hero { padding: 32px 0; }
  .hero-search { padding-left: 12px; }
  .hero-search .btn { padding: 0 16px; }
  .hero-stats strong:nth-of-type(2) { margin-left: 12px; }
  .catgrid { grid-template-columns: 1fr; }
  .drow { flex-wrap: wrap; padding: 16px; gap: 12px; }
  .drow-body { flex-basis: calc(100% - 60px); }
  .drow-count { flex-direction: row; gap: 4px; width: auto; align-items: baseline; }
  .drow-count strong { font-size: 15px; }
  .drow-act { width: 100%; }
  .drow-act .btn:first-child { flex: 1; }
  .doccard { padding: 22px; }
  .dochead { flex-direction: column; gap: 16px; }
  .ficon-xl { width: 64px; height: 78px; font-size: 15px; padding-bottom: 10px; }
  .metagrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gate { flex-direction: column; align-items: flex-start; }
  .actions .btn { flex: 1; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat strong { font-size: 24px; }
  .bars { gap: 4px; }
  .bar-v { display: none; }
}
.hint-inline { font-weight: 400; color: var(--muted); font-size: 13px; }
.warnbox b { font-weight: 700; }

/* ---------- ค้นหาแนะนำ ---------- */
.sg-host { position: relative; }
.suggest { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30; margin: 0; padding: 6px; list-style: none; background: var(--white); color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(17,24,39,.16); max-height: 440px; overflow-y: auto; text-align: left; }
.sg-group { font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 10px 4px; }
.sg-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 8px; cursor: pointer; min-height: 44px; }
.sg-item[aria-selected="true"], .sg-item:hover { background: var(--sky-bg); }
.sg-body { display: flex; flex-direction: column; min-width: 0; }
.sg-title { font-size: 15px; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.sg-title mark { background: var(--pink-bg); color: var(--pink-ink); border-radius: 3px; padding: 0 1px; }
.sg-meta { font-size: 12.5px; color: var(--muted); }
.sg-cat .sg-title { font-weight: 500; }
.sg-all { border-top: 1px solid var(--bg); margin-top: 4px; color: var(--navy); font-weight: 600; font-size: 14px; }

/* ---------- รายงาน ---------- */
.rp-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.rp-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 24px; }
.rp-kpis > div { border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 2px; }
.rp-kpis span { color: var(--muted); font-size: 13px; }
.rp-kpis strong { font-size: 28px; line-height: 1.2; color: var(--navy); }
.rp-kpis small { color: var(--muted); font-size: 12.5px; }
.rp-sec { margin-bottom: 28px; break-inside: avoid; }
.rp-sec h2 { font-size: 18px; margin-bottom: 10px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; }
.rp-sec h2 small { font-size: 13px; font-weight: 400; color: var(--muted); }
.rp-bars { height: 200px; display: flex; align-items: stretch; gap: 8px; }
.rp-bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; min-width: 0; }
.rp-bar-v { font-size: 11px; color: var(--muted); }
.rp-bar-fill { width: 100%; min-height: 2px; max-height: calc(100% - 40px); background: var(--sky); border-radius: 5px 5px 0 0; }
.rp-bar-m { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); width: 100%; text-align: center; padding-top: 3px; }
.rp-table { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.rp-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rp-share { width: 170px; white-space: nowrap; font-size: 13px; }
.rp-meter { display: inline-block; width: 90px; height: 8px; border-radius: 4px; background: var(--bg); margin-right: 8px; vertical-align: middle; overflow: hidden; }
.rp-meter span { display: block; height: 100%; background: var(--navy); }
.rp-two { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.rp-note { color: var(--muted); font-size: 12.5px; margin: 0; }
body.report-print { background: var(--white); display: block; }
.rp-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 24px; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 5; }
.rp-page { max-width: 900px; margin: 0 auto; padding: 32px 24px 48px; }
.rp-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; border-bottom: 3px solid var(--navy); padding-bottom: 16px; margin-bottom: 24px; }
.rp-head h1 { font-size: 24px; color: var(--navy); margin: 4px 0 6px; }
.rp-org { margin: 0; font-weight: 600; color: var(--ink-2); }
.rp-by { text-align: right; margin: 0; }
@media (max-width: 760px) { .rp-kpis { grid-template-columns: 1fr 1fr; } .rp-two { grid-template-columns: 1fr; } .rp-head { flex-direction: column; } .rp-by { text-align: left; } }
@media print {
  @page { size: A4; margin: 14mm 12mm; }
  body.report-print { font-size: 12px; }
  .rp-toolbar { display: none; }
  .rp-page { max-width: none; padding: 0; }
  .rp-kpis { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .rp-kpis strong { font-size: 20px; }
  .rp-two { grid-template-columns: 1fr 1fr; }
  .table th, .table td { padding: 6px 8px; }
  .rp-table tr { break-inside: avoid; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- ตรวจสุขภาพระบบ ---------- */
.hl-summary { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; align-items: center; padding: 16px 20px; border-radius: 14px; border: 1px solid; }
.hl-summary strong { font-size: 17px; }
.hl-summary span { font-size: 13px; color: var(--muted); }
.hl-summary.hl-ok { background: #F0FDF4; border-color: #BBF7D0; color: #166534; }
.hl-summary.hl-warn { background: #FFFBEB; border-color: #FDE68A; color: #92400E; }
.hl-summary.hl-fail { background: #FDF2F8; border-color: #FBCFE8; color: #9D174D; }
.hl-group { margin-bottom: 20px; }
.hl-row { display: flex; gap: 14px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--bg); }
.hl-row:last-child { border-bottom: 0; }
.hl-row p { margin: 2px 0 0; font-size: 14px; color: var(--ink-2); overflow-wrap: anywhere; }
.hl-row .hl-fix { color: var(--navy); font-size: 13px; }
.hl-badge { flex-shrink: 0; width: 64px; text-align: center; font-size: 12px; font-weight: 700; padding: 2px 0; border-radius: 999px; margin-top: 2px; }
.hl-badge.hl-ok { background: #DCFCE7; color: #166534; }
.hl-badge.hl-warn { background: #FEF3C7; color: #92400E; }
.hl-badge.hl-fail { background: var(--pink-bg); color: var(--pink-ink); }
.hl-action { margin-bottom: 14px; }
.hl-action .hint { margin-top: 4px; }
.hl-kv { margin: 0; font-size: 13px; }
.hl-kv dt { color: var(--muted); margin-top: 12px; }
.hl-kv dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.hl-kv code { font-size: 12.5px; background: var(--bg); padding: 2px 6px; border-radius: 6px; }
.hl-kv summary { cursor: pointer; color: var(--navy); }
.hl-alert a { margin-left: 6px; font-weight: 600; }

/* ---------- ตัวติดตั้ง ---------- */
body.setup { display: block; padding: 32px 16px; }
.su-box { background: var(--white); border: 1px solid var(--line); border-radius: 20px; padding: 36px; max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.su-box h1 { font-size: 24px; }
.su-box h2 { font-size: 17px; margin-top: 12px; display: flex; gap: 8px; align-items: baseline; }
.su-box h2 small { font-size: 13px; font-weight: 400; color: var(--muted); }
.su-box > p, .su-box .notice { margin: 0; }
.su-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--bg); padding-bottom: 14px; }
.su-steps li { display: flex; align-items: center; gap: 6px; }
.su-steps span { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--bg); font-weight: 700; font-size: 12px; }
.su-steps .is-current { color: var(--navy); font-weight: 600; }
.su-steps .is-current span { background: var(--navy); color: var(--white); }
.su-steps .is-done span { background: #DCFCE7; color: #166534; }
.su-form { display: flex; flex-direction: column; }
.su-form input { width: 100%; }
.su-grid { display: grid; grid-template-columns: 1fr 120px; gap: 12px; }
.su-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.su-howto, .su-todo { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 10px; }
.su-copy { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 6px; font-size: 13px; }
.su-copy span { color: var(--muted); min-width: 140px; }
.su-copy code, .su-box code { background: var(--bg); padding: 2px 6px; border-radius: 6px; font-size: 12.5px; overflow-wrap: anywhere; }
.su-config { width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.su-checks .hl-row:last-child { border-bottom: 0; }
@media (max-width: 640px) { .su-box { padding: 22px; } .su-grid { grid-template-columns: 1fr 90px; } }
.prose h1 { font-size: 28px; margin-bottom: 12px; }
.prose h2 { font-size: 19px; margin: 24px 0 8px; }
.prose p, .prose li { color: var(--ink-2); line-height: 1.75; }
.prose ul { padding-left: 22px; }

/* ---------- รูปแบบหน้าแรก (hm-) ---------- */
.hm-n { color: var(--muted); font-weight: 400; margin-left: 4px; font-size: 13px; }
.chip.is-on .hm-n { color: var(--blue-100); }
/* แถบหัวแบบกะทัดรัด ใช้ใน สารบัญ / อัปเดตล่าสุด / ตาราง */
.hm-band { background: var(--navy); color: var(--white); padding: 32px 0; }
.hm-band-slim { padding: 24px 0; }
.hm-band-in { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.hm-band-text h1 { font-size: clamp(22px, 3vw, 30px); }
.hm-band-text p { margin: 4px 0 0; color: var(--blue-100); font-size: 15px; }
.hero-search-band { margin-top: 0; flex: 0 1 560px; box-shadow: none; }
.hero-search-band input { height: 44px; font-size: 16px; }
.hero-search-band .btn { min-height: 44px; padding: 0 22px; }

/* สารบัญหมวดหมู่ */
.hm-dir { padding-top: 32px; padding-bottom: 56px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.hm-dir-sec { background: var(--white); border: 1px solid var(--line); border-radius: 16px; padding: 22px; }
.hm-dir-head { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: start; }
.hm-dir-head h2 { font-size: 19px; }
.hm-dir-head h2 a { color: var(--ink); }
.hm-dir-head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.hm-dir-all { font-size: 14px; font-weight: 600; white-space: nowrap; padding-top: 2px; }
.hm-dir-subs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.hm-dir-subs .chip { min-height: 32px; font-size: 13px; padding: 0 12px; }
.hm-dir-docs { margin-top: 12px; border-top: 1px solid var(--bg); padding-top: 4px; }
.hm-dir-docs .dmini .meta { font-size: 12px; }

/* อัปเดตล่าสุด */
.hm-feed { padding-top: 32px; padding-bottom: 56px; display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }
.hm-month { font-size: 17px; color: var(--navy); margin: 8px 0 12px; padding-left: 74px; }
.hm-month:not(:first-child) { margin-top: 28px; }
.hm-events { list-style: none; margin: 0 0 8px; padding: 0; position: relative; }
.hm-events::before { content: ''; position: absolute; left: 29px; top: 8px; bottom: 8px; width: 2px; background: var(--line-2); }
.hm-event { display: grid; grid-template-columns: 60px minmax(0, 1fr); gap: 14px; margin-bottom: 12px; position: relative; }
.hm-day { width: 60px; height: 60px; border-radius: 14px; background: var(--white); border: 2px solid var(--sky); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; position: relative; z-index: 1; }
.hm-day strong { font-size: 20px; color: var(--navy); }
.hm-day span { font-size: 12px; color: var(--muted); }
.hm-event.is-update .hm-day { border-color: var(--pink); }
.hm-event-card { background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 14px 18px; }
.hm-event-head { display: flex; gap: 12px; align-items: flex-start; }
.hm-event-title { font-weight: 600; font-size: 16px; color: var(--ink); }
.hm-event-head .meta { margin: 4px 0 0; font-size: 13px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.hm-note { margin: 10px 0 0; padding: 8px 12px; background: var(--bg); border-radius: 10px; font-size: 14px; color: var(--ink-2); }
.hm-event.is-update .hm-note { background: var(--pink-bg); }
.hm-timeline > .btn { margin: 12px 0 0 74px; }
.hm-side { display: flex; flex-direction: column; gap: 20px; position: sticky; top: 16px; }
.hm-catlist { list-style: none; margin: 0; padding: 0; }
.hm-catlist a { display: flex; justify-content: space-between; gap: 12px; padding: 9px 6px; border-radius: 8px; color: var(--ink); }
.hm-catlist a:hover { background: var(--bg); text-decoration: none; }

/* ตารางเอกสาร */
.hm-list { padding-top: 24px; padding-bottom: 56px; display: flex; flex-direction: column; gap: 16px; }
.hm-table td { vertical-align: middle; }
.hm-table .tdoc small { display: flex; flex-wrap: wrap; gap: 4px; }
.hm-table .col-act .btn { white-space: nowrap; }

/* เรียบง่าย */
#main:has(> .hm-min) { display: flex; flex-direction: column; }
.hm-min { flex: 1; background: var(--white); display: flex; align-items: center; padding: 64px 0 72px; }
.hm-min-in { max-width: 760px; text-align: center; display: flex; flex-direction: column; align-items: center; }
.hm-min-mark { width: 64px; height: 64px; border-radius: 18px; background: var(--navy); color: var(--white); display: grid; place-items: center; }
.hm-min h1 { font-size: clamp(26px, 4vw, 36px); margin-top: 18px; color: var(--navy); }
.hm-min-sub { margin: 6px 0 0; color: var(--muted); }
.hero-search-min { width: 100%; margin-top: 28px; border: 2px solid var(--navy); box-shadow: 0 8px 24px rgba(30,58,138,.12); text-align: left; }
.hm-min-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 14px; }
.hm-min-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 20px; margin-top: 28px; font-weight: 600; }
.hm-min-pop { margin-top: 36px; width: 100%; border-top: 1px solid var(--line); padding-top: 20px; }
.hm-min-pop h2 { font-size: 14px; color: var(--muted); font-weight: 600; }
.hm-min-pop ul { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 20px; font-size: 15px; }
.hm-min-pop a { color: var(--ink-2); }

/* แถบตัวอย่างสำหรับผู้ดูแล */
.hm-preview { background: var(--pink-bg); border-bottom: 1px solid #F9A8D4; color: var(--ink); font-size: 14px; }
.hm-preview-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; }
.hm-preview-act { display: flex; gap: 8px; align-items: center; }
.hm-preview-act form { margin: 0; }
.hm-preview-back { background: var(--white); border: 1px solid var(--line-2); color: var(--ink); }

/* หลังบ้าน: เลือกรูปแบบ */
.hm-intro { max-width: 860px; margin: 0 0 20px; }
.hm-pick fieldset { border: 0; margin: 0; padding: 0; }
.hm-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.hm-opt { position: relative; background: var(--white); border: 2px solid var(--line); border-radius: 16px; transition: border-color .15s, box-shadow .15s; }
.hm-opt:hover { border-color: var(--sky); }
.hm-opt:has(.hm-radio:checked) { border-color: var(--navy); box-shadow: 0 0 0 4px var(--blue-100); }
.hm-radio { position: absolute; top: 14px; right: 14px; width: 20px; height: 20px; accent-color: var(--navy); z-index: 2; margin: 0; }
.hm-radio:focus-visible + label .hm-thumb { outline: 3px solid var(--sky); outline-offset: 2px; }
.hm-opt label { display: block; cursor: pointer; padding: 14px 14px 0; }
.hm-opt-body { display: flex; flex-direction: column; gap: 4px; padding: 14px 4px 4px; }
.hm-opt-body strong { font-size: 17px; display: flex; align-items: center; gap: 8px; }
.hm-opt-body > span { font-size: 14px; color: var(--ink-2); }
.hm-opt-body small { font-size: 13px; color: var(--muted); }
.hm-opt-preview { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 600; margin: 6px 18px 16px; }
.hm-save { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 24px; }

/* โครงร่างย่อ */
.hm-thumb { display: flex; flex-direction: column; gap: 5px; height: 168px; overflow: hidden; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); padding: 0 0 8px; }
.hm-thumb i { display: block; border-radius: 3px; background: var(--line-2); }
.hm-thumb .t-bar { height: 7px; }
.hm-thumb .t-ink { background: var(--navy); opacity: .7; }
.hm-thumb .t-line { height: 5px; }
.hm-thumb .t-input { height: 12px; background: var(--white); border-radius: 4px; }
.hm-thumb .t-ring { border: 2px solid var(--navy); height: 14px; }
.hm-thumb .t-pill { width: 22px; height: 7px; border-radius: 9px; }
.hm-thumb .t-light { background: rgba(255,255,255,.4); }
.hm-thumb .t-w20 { width: 20%; } .hm-thumb .t-w30 { width: 30%; } .hm-thumb .t-w40 { width: 40%; } .hm-thumb .t-w50 { width: 50%; } .hm-thumb .t-w70 { width: 70%; }
.hm-thumb .t-row { display: flex; gap: 4px; padding: 0 10px; }
.hm-thumb .t-center { justify-content: center; }
.hm-thumb .t-hero { background: var(--navy); padding: 12px 10px; display: flex; flex-direction: column; gap: 6px; }
.hm-thumb .t-hero .t-bar { background: rgba(255,255,255,.75); }
.hm-thumb .t-hero .t-row { padding: 0; }
.hm-thumb .t-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 2px 10px; }
.hm-thumb .t-tile { height: 22px; background: var(--white); border: 1px solid var(--line-2); }
.hm-thumb .t-split2 { display: grid; grid-template-columns: 2fr 1fr; gap: 4px; padding: 0 10px; flex: 1; }
.hm-thumb .t-box { background: var(--white); border: 1px solid var(--line-2); min-height: 26px; }
.hm-thumb .t-band { background: var(--navy); padding: 9px 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.hm-thumb .t-band .t-bar { background: rgba(255,255,255,.75); }
.hm-thumb .t-slim { padding: 7px 10px; }
.hm-thumb-directory { display: grid; grid-template-columns: 1fr 1fr; align-content: start; }
.hm-thumb-directory .t-band { grid-column: 1 / -1; }
.hm-thumb .t-sec { background: var(--white); border: 1px solid var(--line-2); border-radius: 5px; margin: 0 0 0 10px; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.hm-thumb .t-sec:nth-of-type(odd) { margin: 0 10px 0 0; }
.hm-thumb .t-sec .t-row { padding: 0; }
.hm-thumb .t-cols2 { display: flex; flex-direction: column; gap: 3px; }
.hm-thumb .t-split { display: grid; grid-template-columns: 2fr 1fr; gap: 6px; padding: 2px 10px; }
.hm-thumb .t-tl { display: flex; flex-direction: column; gap: 5px; }
.hm-thumb .t-ev { display: flex; gap: 5px; align-items: center; }
.hm-thumb .t-dot { width: 14px; height: 14px; border-radius: 4px; background: var(--white); border: 2px solid var(--sky); flex-shrink: 0; }
.hm-thumb .t-ev:nth-child(2) .t-dot { border-color: var(--pink); }
.hm-thumb .t-card { flex: 1; height: 18px; background: var(--white); border: 1px solid var(--line-2); }
.hm-thumb .t-aside { display: flex; flex-direction: column; gap: 5px; }
.hm-thumb .t-aside .t-box { min-height: 40px; }
.hm-thumb .t-table { margin: 0 10px; background: var(--white); border: 1px solid var(--line-2); border-radius: 5px; }
.hm-thumb .t-tr { display: flex; gap: 8px; align-items: center; padding: 5px 6px; border-bottom: 1px solid var(--line); }
.hm-thumb .t-tr:last-child { border-bottom: 0; }
.hm-thumb .t-tr .t-w50 { flex: 1; }
.hm-thumb .t-btn { width: 24px; height: 9px; background: var(--pink-btn); border-radius: 3px; }
.hm-thumb-minimal { background: var(--white); }
.hm-thumb .t-min { display: flex; flex-direction: column; align-items: center; gap: 7px; padding-top: 20px; }
.hm-thumb .t-min .t-line { width: 50%; }
.hm-thumb .t-mark { width: 18px; height: 18px; border-radius: 5px; background: var(--navy); }

@media (max-width: 960px) {
  .hm-band-in { flex-direction: column; align-items: stretch; gap: 14px; }
  .hero-search-band { flex: none; }
  .hm-dir { grid-template-columns: 1fr; }
  .hm-feed { grid-template-columns: 1fr; }
  .hm-side { position: static; }
}
@media (max-width: 640px) {
  .hm-dir-head { grid-template-columns: auto 1fr; }
  .hm-dir-all { grid-column: 1 / -1; }
  .hm-month { padding-left: 0; }
  .hm-events::before { left: 23px; }
  .hm-event { grid-template-columns: 48px minmax(0, 1fr); gap: 10px; }
  .hm-day { width: 48px; height: 52px; }
  .hm-timeline > .btn { margin-left: 0; }
  .hm-table thead { display: none; }
  .hm-table tr { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .hm-table td { display: block; padding: 0 !important; border: 0 !important; }
  .hm-table td:first-child { grid-column: 1 / -1; }
  .hm-table td:nth-child(2), .hm-table td:nth-child(3), .hm-table td:nth-child(5) { display: none; }
  .hm-table td:nth-child(4)::before { content: 'อัปเดต '; }
  .hm-min { padding: 40px 0 48px; }
  .hm-preview-in { flex-direction: column; align-items: stretch; }
}
@media print { .hm-preview { display: none; } }
