/* ==========================================================================
   Suan Prung Strategy & Planning — โทนเขียวกรมสุขภาพจิต + ขาว + ฟ้าอ่อน
   ไม่มี inline style (CSP) — ทุกอย่างอยู่ในไฟล์นี้
   ========================================================================== */
:root {
    --green-900: #06331d;
    --green-800: #0a4a2a;
    --green-700: #0b5e35;
    --green-600: #0f7a43;
    --green-500: #16934f;
    --green-100: #e3f3e8;
    --green-50: #f1f9f3;
    --sky-100: #e6f2fb;
    --sky-50: #f3f9fe;
    --sky-600: #1f6fa8;
    --ink: #17312a;
    --ink-2: #44574f;
    --muted: #6b7c75;
    --line: #dfe9e3;
    --surface: #ffffff;
    --bg: #f4f8f6;
    --good: #18864b;
    --warning: #b7791f;
    --critical: #c0392b;
    --pending: #8a9a93;
    --radius: 14px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(6, 51, 29, .06), 0 6px 18px rgba(6, 51, 29, .06);
    --sidebar-w: 268px;
    --font: "Kanit", "Sarabun", "Tahoma", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-weight: 300; font-size: 15px; line-height: 1.6; color: var(--ink); background: var(--bg); }
img { max-width: 100%; display: block; }
a { color: var(--green-700); text-decoration: none; }
a:hover { color: var(--green-500); }
h1, h2, h3, h4 { font-weight: 500; line-height: 1.3; margin: 0 0 .5em; color: var(--green-900); }
strong, b { font-weight: 500; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .9em; }
hr { border: 0; border-top: 1px solid rgba(255,255,255,.15); margin: 12px 8px; }
:focus-visible { outline: 3px solid #f2c94c; outline-offset: 2px; }
.skip-link { position: absolute; left: -999px; top: 8px; background: #fff; padding: 8px 12px; z-index: 100; border-radius: 6px; }
.skip-link:focus { left: 8px; }

.ic { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.2em; }
.ic-good { color: var(--good); }
.ic-critical { color: var(--critical); }
.ic-muted { color: var(--pending); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.block { display: block; }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.text-danger { color: var(--critical); }
.empty { color: var(--muted); text-align: center; padding: 18px 8px; list-style: none; }
.empty-box { color: var(--muted); text-align: center; padding: 32px 12px; background: var(--green-50); border-radius: var(--radius); }
.empty-box .ic { width: 32px; height: 32px; margin: 0 auto 8px; display: block; }

/* ---------------- Layout ---------------- */
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
    background: linear-gradient(180deg, var(--green-800) 0%, var(--green-900) 100%);
    color: #e8f5ec; overflow-y: auto; padding: 16px 12px 24px;
    transition: transform .25s ease;
}
.brand { display: flex; align-items: center; gap: 12px; color: #fff; padding: 4px 6px 16px; border-bottom: 1px solid rgba(255,255,255,.15); margin-bottom: 10px; }
.brand:hover { color: #fff; }
.brand img { border-radius: 50%; background: #fff; }
.brand strong { display: block; font-size: 1.12rem; font-weight: 500; line-height: 1.25; }
.brand small { display: block; font-size: .72rem; letter-spacing: .06em; opacity: .85; }

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { margin: 14px 10px 4px; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: rgba(232,245,236,.6); }
.nav-link, .nav-group > summary {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
    color: #e8f5ec; cursor: pointer; font-weight: 400; list-style: none;
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-link:hover, .nav-group > summary:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-link.active { background: var(--green-500); color: #fff; box-shadow: 0 4px 12px rgba(0,0,0,.18); }
.nav-group .caret { margin-left: auto; transition: transform .2s; }
.nav-group[open] .caret { transform: rotate(180deg); }
.nav-group ul { list-style: none; margin: 2px 0 8px; padding: 0 0 0 22px; }
.nav-group li a { display: block; padding: 6px 12px 6px 18px; color: rgba(232,245,236,.85); border-radius: 8px; position: relative; font-size: .93rem; }
.nav-group li a::before { content: ""; position: absolute; left: 2px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border: 1.5px solid currentColor; border-radius: 50%; }
.nav-group li a:hover, .nav-group li a.active { color: #fff; background: rgba(255,255,255,.08); }
.nav-group li a.active::before { background: #9be7b4; border-color: #9be7b4; }

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.content { flex: 1; padding: 20px 24px 32px; width: 100%; max-width: 1480px; }

.topbar {
    display: flex; align-items: center; gap: 16px; padding: 12px 24px;
    background: linear-gradient(90deg, #fff 0%, var(--sky-50) 100%);
    border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30;
}
.topbar-title h1 { font-size: 1.45rem; margin: 0; color: var(--green-800); font-weight: 600; }
.tagline { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: .88rem; color: var(--ink-2); }
.tagline span { display: inline-flex; align-items: center; gap: 4px; }
.tagline .ic { color: var(--green-600); }
.search { margin-left: auto; display: flex; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 4px 4px 4px 12px; min-width: 260px; flex: 0 1 380px; }
.search .search-ic { color: var(--muted); }
.search input { border: 0; outline: 0; flex: 1; padding: 6px 8px; font: inherit; background: transparent; min-width: 0; }
.search button { border: 0; background: var(--green-600); color: #fff; border-radius: 9px; width: 38px; height: 34px; cursor: pointer; display: grid; place-items: center; }
.search button:hover { background: var(--green-500); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 12px 6px 6px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--green-100); color: var(--green-700); font-weight: 500; }
.who strong { display: block; font-size: .92rem; line-height: 1.2; }
.who small { display: block; font-size: .75rem; color: var(--muted); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topbar-actions form { margin: 0; }
.icon-btn { border: 1px solid var(--line); background: #fff; border-radius: 10px; width: 40px; height: 40px; display: grid; place-items: center; cursor: pointer; color: var(--green-800); }
.icon-btn:hover { background: var(--green-50); }
.menu-toggle { display: none; }
.sidebar-backdrop { display: none; }

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

/* ---------------- Components ---------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 18px; min-width: 0; }
.card.narrow { max-width: 620px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { font-size: 1.12rem; margin: 0; display: flex; align-items: center; gap: 8px; color: var(--green-900); }
.card-head h2 .ic { color: var(--green-600); width: 1.3em; height: 1.3em; }
.more { font-size: .85rem; color: var(--green-600); }
.sub-head { font-size: 1rem; margin: 18px 0 8px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head h1 { font-size: 1.5rem; margin: 0; display: flex; align-items: center; gap: 10px; }
.page-head h1 .ic { color: var(--green-600); }
.breadcrumb { font-size: .88rem; color: var(--muted); margin-bottom: 12px; }

.grid { display: grid; gap: 18px; }
.grid > .card, .grid > aside > .card { margin-bottom: 0; }
.grid > aside { display: flex; flex-direction: column; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 18px; }
.grid-sidebar { grid-template-columns: 260px minmax(0, 1fr); }
.grid-article { grid-template-columns: minmax(0, 1fr) 320px; }
.grid-form { grid-template-columns: minmax(0, 1fr) 320px; }
/* หน้าแผนยุทธศาสตร์: แบนเนอร์ซ้าย (ติดอยู่ขณะเลื่อน) / แผนขวา */
.grid-plans { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
.plans-banner { position: sticky; top: 88px; /* ใต้ .topbar ที่ sticky */ }
.plans-banner .hero { margin-bottom: 0; }
.plans-main > .card:last-child { margin-bottom: 0; }
/* การ์ดหมวดแผน: แผนแต่ละรายการเป็นแถว คั่นด้วยเส้น */
.plan-list > .plan { padding: 14px 0; border-top: 1px solid var(--line); }
.plan-list > .plan:first-child { border-top: 0; padding-top: 4px; }
.plan-list > .plan:last-child { padding-bottom: 0; }
.plan-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.plan-head h3 { margin: 0; font-size: 1.05rem; font-weight: 600; color: var(--green-900); line-height: 1.45; }
.plan-head .tag { flex: none; }
.plan .file-current { margin: 0; }
/* หมวดหลายปี (คำรับรองการปฏิบัติราชการ): accordion แยกตามปีงบประมาณ */
.year-group { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.year-group + .year-group { margin-top: 10px; }
.year-group > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 11px 16px; cursor: pointer; background: var(--green-50); color: var(--green-900); transition: background .2s; }
.year-group > summary::-webkit-details-marker { display: none; }
.year-group > summary:hover { background: #e3f3e9; }
.year-group > summary:focus-visible { outline: 2px solid var(--green-600); outline-offset: -2px; }
.year-group[open] > summary { border-bottom: 1px solid var(--line); }
.year-label strong { font-size: 1.05rem; font-weight: 600; color: var(--green-800); }
.year-count { margin-left: auto; padding: 2px 10px; border-radius: 999px; background: #fff; border: 1px solid var(--line); font-size: .8rem; color: var(--green-600); }
.year-group .caret { color: var(--green-600); transition: transform .2s; }
.year-group[open] .caret { transform: rotate(180deg); }
.year-files { padding: 2px 16px 6px; }
.year-files li { padding: 10px 0; }
.year-files .doc-title { line-height: 1.45; }
.grid-home { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr) minmax(0, .95fr); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 400; cursor: pointer; line-height: 1.2; text-align: center; }
.btn-sm { padding: 5px 10px; font-size: .84rem; border-radius: 8px; }
.btn-block { width: 100%; margin-top: 8px; }
.btn-primary { background: var(--green-600); color: #fff; }
.btn-primary:hover { background: var(--green-500); color: #fff; }
.btn-success { background: var(--good); color: #fff; }
.btn-success:hover { filter: brightness(1.08); color: #fff; }
.btn-warning { background: #fff7e6; color: #8a5a10; border-color: #f0d49c; }
.btn-danger { background: var(--critical); color: #fff; }
.btn-muted { background: #eef2f0; color: var(--ink-2); }
.btn-outline { background: #fff; color: var(--green-700); border-color: var(--line); }
.btn-outline:hover { background: var(--green-50); }
.btn-soft { background: var(--green-50); color: var(--green-700); border-color: var(--green-100); }
.btn-soft:hover { background: var(--green-100); }
.btn-light { background: rgba(255,255,255,.92); color: var(--green-800); }
.btn-link { background: none; border: 0; color: var(--muted); padding: 8px 0; text-decoration: underline; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { border: 1px solid var(--line); background: #fff; color: var(--ink-2); padding: 4px 14px; border-radius: 999px; font: inherit; font-size: .86rem; cursor: pointer; }
.chip:hover { border-color: var(--green-500); color: var(--green-700); }
.chip.is-active { background: var(--green-600); border-color: var(--green-600); color: #fff; }
.tag { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: .76rem; background: var(--green-100); color: var(--green-700); }
.tag-pr { background: var(--sky-100); color: var(--sky-600); }
.tag-announcement { background: #fff4e0; color: #8a5a10; }
.tag-procurement { background: #f1ecfb; color: #5b3e9b; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 400; }
.badge-draft { background: #eef2f0; color: var(--ink-2); }
.badge-pending_review { background: #fff4e0; color: #8a5a10; }
.badge-approved { background: var(--sky-100); color: var(--sky-600); }
.badge-published { background: var(--green-100); color: var(--green-700); }
.badge-archived { background: #f3e9e7; color: #8c3a2f; }

.status { display: inline-flex; align-items: center; gap: 4px; font-size: .84rem; white-space: nowrap; color: var(--ink-2); }
.status-good .ic { color: var(--good); }
.status-critical .ic { color: var(--critical); }
.status-pending .ic { color: var(--pending); }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; margin: 0 0 16px; border: 1px solid; }
.alert .ic { margin-top: 3px; }
.alert-success { background: var(--green-50); border-color: #bfe3cb; color: var(--green-800); }
.alert-error { background: #fdf0ee; border-color: #f2c4bd; color: #8c2a1f; }
.alert-warning { background: #fff8eb; border-color: #f1d9a6; color: #7a5212; }

.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.pagination a { min-width: 36px; height: 36px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.pagination a.current { background: var(--green-600); color: #fff; border-color: var(--green-600); }
.pagination .gap { min-width: 24px; display: grid; place-items: center; color: var(--muted); }
.list-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.list-head p { margin: 0; }
.per-page { display: flex; align-items: center; gap: 6px; font-size: .86rem; color: var(--ink-2); margin: 0; }
.per-page select { padding: 4px 8px; }
.table .actions { flex-wrap: nowrap; }

/* ---------------- Hero slider ---------------- */
/* สัดส่วนเท่าขนาดภาพที่แนะนำ 1920×640 → แสดงภาพเต็มไม่ถูกตัด */
.hero { position: relative; border-radius: 18px; overflow: hidden; aspect-ratio: 1920 / 640; margin-bottom: 14px; background: linear-gradient(110deg, #e9f6ee 0%, #d6eef7 55%, #c9e8d3 100%); box-shadow: var(--shadow); }
.slide { position: absolute; inset: 0; opacity: 0; visibility: hidden; transition: opacity .6s ease, visibility .6s; }
.slide.is-active { opacity: 1; visibility: visible; }
/* แบนเนอร์ภาพ: ความสูงตามสัดส่วนภาพจริง → ภาพเต็มกรอบพอดี ไม่ถูกตัด ไม่มีขอบว่าง
   (สไลด์ที่แสดงอยู่เป็น relative เพื่อกำหนดความสูง, สไลด์อื่นซ้อนแบบ absolute สำหรับ fade) */
.hero:not(:has(.slide-default)) { aspect-ratio: auto; }
.hero:not(:has(.slide-default)) .slide.is-active { position: relative; }
.slide-img { width: 100%; height: auto; display: block; }
.slide-text { position: absolute; inset: 0 auto 0 0; width: min(60%, 640px); padding: 28px 48px 28px 90px; display: flex; flex-direction: column; justify-content: center; background: linear-gradient(90deg, rgba(255,255,255,.92) 0%, rgba(255,255,255,.75) 70%, rgba(255,255,255,0) 100%); }
.slide-text h2 { font-size: clamp(1.4rem, 2.8vw, 2.5rem); font-weight: 600; color: var(--green-800); font-style: italic; margin: 0 0 10px; }
.slide-text p { margin: 0 0 12px; color: var(--green-900); font-weight: 400; font-size: clamp(.9rem, 1.2vw, 1.05rem); }
.slide-text .btn { align-self: flex-start; }
.quote { color: var(--green-600); }
.slide-default { background:
    radial-gradient(circle at 85% 30%, rgba(22,147,79,.18) 0 120px, transparent 121px),
    radial-gradient(circle at 70% 90%, rgba(31,111,168,.12) 0 160px, transparent 161px),
    linear-gradient(110deg, #f1faf4 0%, #dff0f7 60%, #cfead8 100%); }
.slide-default .slide-text { background: none; }
.slide-motto { position: absolute; right: 48px; top: 26px; margin: 0; text-align: right; font-style: italic; color: var(--green-800); font-weight: 400; font-size: 1.05rem; }
.slider-btn { position: absolute; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255,255,255,.92); box-shadow: var(--shadow); cursor: pointer; display: grid; place-items: center; color: var(--green-800); z-index: 2; }
.slider-btn.prev { left: 14px; }
.slider-btn.next { right: 14px; }
.dots { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; z-index: 2; }
.dots button { width: 10px; height: 10px; border-radius: 50%; border: 0; padding: 0; background: rgba(255,255,255,.7); box-shadow: 0 0 0 1px rgba(6,51,29,.2); cursor: pointer; }
.dots button.is-active { background: var(--green-700); }

/* ---------------- Quick links ---------------- */
/* จำนวนคอลัมน์ = จำนวนลิงก์ใน config/site.php quick_links (6) ให้เต็มความกว้างพอดี */
.quick-links { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.quick-link { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 18px 10px; min-height: 120px; border-radius: var(--radius); background: linear-gradient(180deg, #fff 0%, var(--sky-50) 100%); border: 1px solid var(--line); color: var(--green-900); font-weight: 400; font-size: .92rem; line-height: 1.3; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; }
.quick-link .ic { width: 40px; height: 40px; color: var(--green-600); stroke-width: 1.8; }
.quick-link:hover { transform: translateY(-2px); color: var(--green-700); box-shadow: 0 8px 22px rgba(6,51,29,.12); }

/* ---------------- Home cards ---------------- */
.news-list, .doc-list, .event-list, .link-list, .timeline, .progress-list, .level-bars, .legend, .goal-list, .steps { list-style: none; margin: 0; padding: 0; }
.news-list li + li { border-top: 1px solid var(--line); }
.news-list li.is-extra { display: none; }
.news-item { display: flex; gap: 14px; padding: 10px 0; color: var(--ink); align-items: center; }
.news-item img, .thumb-placeholder { width: 124px; height: 70px; object-fit: cover; border-radius: 8px; flex: none; }
.thumb-placeholder { display: grid; place-items: center; background: var(--green-50); color: var(--green-500); }
.thumb-placeholder.lg { width: 100%; height: 180px; border-radius: 0; }
.news-body strong { display: block; color: var(--green-900); font-weight: 500; line-height: 1.4; }
.news-item:hover strong { color: var(--green-600); }
.meta { font-size: .8rem; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 2px; }

.caption { position: absolute; left: 0; right: 0; bottom: 0; padding: 40px 16px 30px; color: #fff; font-weight: 500; background: linear-gradient(0deg, rgba(0,0,0,.72), transparent); }

.calendar .cal-head { display: flex; align-items: center; justify-content: center; gap: 18px; margin-bottom: 6px; }
.calendar .cal-head strong { font-size: 1.05rem; color: var(--green-900); min-width: 130px; text-align: center; }
.calendar table { width: 100%; border-collapse: collapse; text-align: center; table-layout: fixed; }
.calendar th { font-weight: 400; font-size: .8rem; color: var(--muted); padding: 4px 0; }
.calendar td { padding: 3px 0; font-size: .88rem; }
.calendar td span { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; }
.calendar td.has-event span { background: var(--green-100); color: var(--green-800); font-weight: 500; }
.calendar td.today span { background: var(--green-600); color: #fff; font-weight: 500; }
.calendar:not(.calendar-compact) td span { width: 44px; height: 44px; }
.event-list li { display: grid; grid-template-columns: 12px 92px 1fr; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); font-size: .86rem; align-items: start; }
.event-list li.empty { display: block; }
.event-list .dot-ic { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--green-600); margin-top: 6px; }
.event-list .date { color: var(--green-700); font-weight: 500; }
.event-list strong { display: block; font-weight: 500; }
.event-list small { display: block; color: var(--muted); }

.doc-list li { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); font-size: .9rem; }
.doc-list li:first-child { border-top: 0; }
.doc-list li.empty { display: block; }
.doc-title small { display: block; color: var(--muted); font-size: .8rem; }
.doc-meta { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.file-badge { width: 32px; height: 38px; border-radius: 4px 10px 4px 4px; display: grid; place-items: center; color: #fff; font-size: .62rem; font-weight: 600; letter-spacing: .02em; background: #6b7c75; }
.file-pdf { background: #d64535; }
.file-doc { background: #2f6fc6; }
.file-xls { background: #1f8a4c; }
.file-ppt { background: #d0702a; }
.file-link { background: var(--sky-600); }
.doc-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }

.system-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.system { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--sky-50); color: var(--ink); }
.system .ic { width: 36px; height: 36px; color: var(--green-700); stroke-width: 1.7; }
.system strong { display: block; font-weight: 500; }
.system small { display: block; font-size: .78rem; color: var(--muted); }
.system:hover { border-color: var(--green-500); }

.policy-list { display: flex; flex-direction: column; gap: 10px; }
.policy { display: block; padding: 14px 16px; border-radius: 12px; color: #fff; position: relative; overflow: hidden; }
.policy strong { display: block; font-weight: 500; line-height: 1.35; }
.policy small { opacity: .9; }
.policy:hover { color: #fff; filter: brightness(1.06); }
.policy-0 { background: linear-gradient(110deg, var(--green-800), var(--green-500)); }
.policy-1 { background: linear-gradient(110deg, #165c8a, #3a9bd0); }
.policy-2 { background: linear-gradient(110deg, #2f7a2f, #79b84a); }

/* ---------------- Lists / tables / forms ---------------- */
.link-list li { border-top: 1px solid var(--line); }
.link-list li:first-child { border-top: 0; }
.link-list a, .link-list li:not(:has(a)) { display: block; padding: 9px 4px; color: var(--ink); }
.link-list a.active { color: var(--green-700); font-weight: 500; }
.link-list a:hover { color: var(--green-600); }
.link-list small { display: block; color: var(--muted); font-size: .8rem; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-weight: 500; color: var(--ink-2); background: var(--green-50); padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th.center, .table td.center { text-align: center; }
.table-agreements thead th { vertical-align: middle; }
.table-agreements thead tr:first-child th[colspan] { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th.num, .table td.num { text-align: right; }
.table-sm td, .table-sm th { padding: 7px 8px; font-size: .84rem; }
.table tbody tr:hover { background: #fafdfb; }
.table .group-row th { background: var(--sky-50); color: var(--green-800); }
.table .row-warn { background: #fff8f6; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.actions form { margin: 0; }
.actions-col { width: 1%; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar-title { margin: 0; font-size: 1.15rem; }
/* แท็บแยกหมวดเหนือรายการ (admin/resource/index เมื่อมี group_by) */
/* แสดงทุกหมวดพร้อมกันแบบขึ้นบรรทัดใหม่ (ไม่ใช้แถบเลื่อนแนวนอน) */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.tabs a { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; color: var(--ink-2); border: 1px solid var(--line); border-radius: 999px; background: var(--surface); line-height: 1.4; }
.tabs a:hover { color: var(--green-700); border-color: var(--green-700); background: var(--green-50); }
.tabs a.active { color: #fff; font-weight: 500; background: var(--green-700); border-color: var(--green-700); }
.tab-count { min-width: 22px; padding: 0 7px; border-radius: 999px; font-size: .75rem; line-height: 1.6; text-align: center; background: var(--green-100); color: var(--green-700); }
.tabs a.active .tab-count { background: #fff; color: var(--green-800); }
.tabs a.is-empty:not(.active) { color: var(--muted); border-style: dashed; }
.tabs a.is-empty:not(.active) .tab-count { background: var(--bg); color: var(--muted); }
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filter-bar.inline { margin: 0; }
.filter-bar label { font-size: .88rem; color: var(--ink-2); }
input, select, textarea { font: inherit; font-weight: 300; color: var(--ink); background: #fff; border: 1px solid #cfdcd5; border-radius: 10px; padding: 8px 12px; max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green-500); outline-offset: 0; border-color: var(--green-500); }
textarea { width: 100%; resize: vertical; }
textarea.code { font-family: ui-monospace, Consolas, monospace; font-size: .88rem; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset[disabled] input, fieldset[disabled] textarea, fieldset[disabled] select { background: #f5f7f6; }
legend { font-weight: 500; margin-bottom: 6px; }
.form .field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.form .field > label { font-weight: 400; color: var(--ink-2); }
.form .field input:not([type=checkbox]):not([type=file]), .form .field select { width: 100%; }
.form-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.form-actions { display: flex; gap: 8px; margin-top: 6px; }
.req { color: var(--critical); }
.help { color: var(--muted); font-size: .8rem; }
.field-error { color: var(--critical); font-size: .84rem; margin: 2px 0 0; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--critical); }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 300; cursor: pointer; margin-bottom: 10px; }
.check input { margin-top: 5px; }
.combo { position: relative; flex: 1 1 320px; max-width: 460px; }
.combo input { width: 100%; }
.combo-list { position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; right: 0; margin: 0; padding: 4px; list-style: none; max-height: 320px; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.combo-list li { padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.combo-list li .tag { margin-left: 6px; }
.combo-list li:hover, .combo-list li.is-active { background: var(--green-50); }
.combo-list .combo-empty { color: var(--muted); cursor: default; }
.combo-list .combo-empty:hover { background: none; }
.role-option { padding: 10px; border: 1px solid var(--line); border-radius: 10px; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.preview { max-width: 280px; border-radius: 8px; margin-bottom: 6px; border: 1px solid var(--line); }
.file-current { margin: 0; font-size: .9rem; }
.editor-toolbar { display: flex; gap: 4px; }
.editor-toolbar button { border: 1px solid var(--line); background: #fff; border-radius: 6px; min-width: 32px; height: 30px; cursor: pointer; font: inherit; }
.record-status { margin-bottom: 14px; }
.workflow-steps { list-style: none; padding: 0; margin: 0 0 14px; display: flex; gap: 4px; font-size: .78rem; }
.workflow-steps li { flex: 1; text-align: center; padding: 6px 2px; background: #eef2f0; color: var(--muted); border-radius: 6px; }
.workflow-steps li.current { background: var(--green-600); color: #fff; }
.workflow-form { margin: 0 0 6px; }
.meta-list { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; margin: 12px 0; }
.meta-list dt { color: var(--muted); }
.meta-list dd { margin: 0; }
.timeline li { padding: 6px 0 6px 14px; border-left: 2px solid var(--green-100); }
.danger-zone { border-color: #f2c4bd; }

/* ---------------- Articles ---------------- */
.article h1 { font-size: 1.6rem; }
.article-cover { border-radius: 12px; margin: 10px 0 16px; width: 100%; }
.prose { line-height: 1.8; }
.prose img { border-radius: 8px; margin: 10px 0; height: auto; }
.prose table { border-collapse: collapse; width: 100%; margin: 10px 0; }
.prose td, .prose th { border: 1px solid var(--line); padding: 6px 10px; }
.prose blockquote { border-left: 4px solid var(--green-500); margin: 12px 0; padding: 6px 14px; background: var(--green-50); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.news-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; color: var(--ink); margin: 0; }
.news-card img { width: 100%; height: 180px; object-fit: cover; }
.news-card-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.news-card-body strong { color: var(--green-900); line-height: 1.4; }
.news-card-body small { color: var(--muted); }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.gallery-item { position: relative; border-radius: 12px; overflow: hidden; aspect-ratio: 4 / 3; color: #fff; }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.gallery-item:hover img { transform: scale(1.04); }
.gallery-item span { position: absolute; inset: auto 0 0 0; padding: 30px 12px 10px; background: linear-gradient(0deg, rgba(0,0,0,.7), transparent); }
.gallery-item small { display: block; opacity: .85; }

.plan .vision { margin: 0 0 14px; padding: 14px 16px; border-radius: 12px; background: linear-gradient(110deg, var(--green-50), var(--sky-50)); font-size: 1.05rem; color: var(--green-900); }
.plan .vision span { display: block; font-size: .8rem; color: var(--green-600); }
.goal-list li { display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.goal-code { flex: none; min-width: 44px; height: 28px; padding: 0 8px; border-radius: 8px; display: grid; place-items: center; background: var(--green-600); color: #fff; font-weight: 500; font-size: .85rem; }
.goal-list small { display: block; color: var(--muted); }

.contact-list { display: grid; grid-template-columns: 140px 1fr; gap: 10px 14px; }
.contact-list dt { color: var(--ink-2); display: flex; gap: 6px; align-items: center; }
.contact-list dd { margin: 0; }
.map-card { padding: 0; overflow: hidden; min-height: 340px; }
.map-card iframe { width: 100%; height: 100%; min-height: 340px; border: 0; display: block; }

/* ---------------- Data display (stat tiles, bars) ---------------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-row-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; color: var(--ink); }
.stat-link:hover { border-color: var(--green-500); color: var(--ink); }
.stat-label { color: var(--ink-2); font-size: .88rem; display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 2rem; font-weight: 500; color: var(--green-900); font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat-value.sm { font-size: 1.5rem; }
.stat-sub { color: var(--muted); font-size: .8rem; }
.legend { display: flex; gap: 16px; font-size: .84rem; color: var(--ink-2); margin-bottom: 10px; }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; }
.swatch-good, .seg-good { background: var(--good); }
.swatch-critical, .seg-critical { background: var(--critical); }
.swatch-pending, .seg-pending { background: #c5cfcb; }
.level-bars li { display: grid; grid-template-columns: minmax(140px, 1fr) 2fr 52px; gap: 12px; align-items: center; padding: 8px 0; }
.stack { display: flex; gap: 2px; height: 14px; border-radius: 4px; overflow: hidden; background: #f1f4f3; }
.seg { height: 100%; width: 0; transition: width .4s ease; }
.level-num { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
progress { appearance: none; -webkit-appearance: none; width: 120px; height: 8px; border: 0; border-radius: 4px; background: #e6ece9; vertical-align: middle; overflow: hidden; }
progress::-webkit-progress-bar { background: #e6ece9; border-radius: 4px; }
progress::-webkit-progress-value { background: var(--green-600); border-radius: 4px; }
progress::-moz-progress-bar { background: var(--green-600); border-radius: 4px; }
.progress-lg { width: 100%; height: 12px; }
.progress-list li { display: grid; grid-template-columns: minmax(0, 1fr) 120px 44px; gap: 10px; align-items: center; padding: 6px 0; font-size: .86rem; border-top: 1px solid var(--line); }
.pstatus { font-size: .8rem; padding: 2px 10px; border-radius: 999px; background: #eef2f0; white-space: nowrap; }
.pstatus-in_progress { background: var(--sky-100); color: var(--sky-600); }
.pstatus-completed { background: var(--green-100); color: var(--green-700); }

/* ---------------- Auth / error pages ---------------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background:
    radial-gradient(circle at 10% 10%, rgba(22,147,79,.15) 0 220px, transparent 221px),
    radial-gradient(circle at 90% 90%, rgba(31,111,168,.12) 0 260px, transparent 261px), var(--bg); }
.auth-card { width: 100%; max-width: 440px; background: #fff; border-radius: 18px; padding: 28px; box-shadow: 0 10px 40px rgba(6,51,29,.12); border: 1px solid var(--line); }
.auth-card .card { box-shadow: none; border: 0; padding: 0; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; color: var(--green-900); }
.auth-brand strong { display: block; font-weight: 500; }
.auth-brand small { color: var(--muted); }
.auth-title { font-size: 1.3rem; }
.otp-input { font-size: 1.6rem; letter-spacing: .4em; text-align: center; font-family: ui-monospace, Consolas, monospace; }
.secret-box { background: var(--green-50); border: 1px dashed var(--green-500); border-radius: 12px; padding: 14px; margin: 12px 0 16px; }
.secret { display: block; font-size: 1.15rem; letter-spacing: .08em; color: var(--green-900); margin: 4px 0; word-break: break-all; }
.steps { counter-reset: step; }
.steps li { counter-increment: step; padding: 4px 0 4px 32px; position: relative; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 5px; width: 22px; height: 22px; border-radius: 50%; background: var(--green-600); color: #fff; display: grid; place-items: center; font-size: .78rem; }
.error-card { text-align: center; max-width: 560px; }
.error-card img { margin: 0 auto 10px; }
.error-code { font-size: 4rem; color: var(--green-600); margin: 0; }
.debug { text-align: left; white-space: pre-wrap; font-size: .75rem; background: #1e1e1e; color: #eee; padding: 12px; border-radius: 8px; max-height: 360px; overflow: auto; }

/* ---------------- Reports (หน้าปก) ---------------- */
.year-chips .chip { font-size: .8rem; padding: 2px 12px; }
/* บุคลากร (/about/staff) */
.staff-grid { list-style: none; margin: 20px 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px; }
.staff-card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 18px 14px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.staff-photo { width: 130px; height: 160px; object-fit: cover; border-radius: var(--radius-sm); margin-bottom: 8px; background: var(--bg); }
.staff-photo-empty { display: flex; align-items: center; justify-content: center; color: var(--muted); }
.staff-photo-empty .ic { width: 56px; height: 56px; }
.staff-card strong { font-weight: 500; line-height: 1.35; }
.staff-position { font-size: .9rem; color: var(--green-700); }
.staff-role { font-size: .85rem; color: var(--ink-2); }
.staff-phone { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; font-size: .88rem; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; margin-bottom: 18px; }
.report-grid-sm { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin: 0; }
.report-card { display: flex; flex-direction: column; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; }
.report-card:hover { transform: translateY(-3px); box-shadow: 0 12px 28px rgba(6,51,29,.14); color: var(--ink); }
.report-card:hover strong { color: var(--green-600); }
.report-cover { display: block; width: 100%; aspect-ratio: 210 / 297; object-fit: cover; background: var(--green-50); }
.report-cover-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 18px 14px; text-align: center; color: #fff;
    background: linear-gradient(160deg, var(--green-700) 0%, var(--green-500) 55%, #3a9bd0 130%); }
.report-cover-placeholder img { background: #fff; border-radius: 50%; }
.report-cover-placeholder strong { font-weight: 500; font-size: .98rem; line-height: 1.4; }
.report-cover-placeholder small { font-size: .8rem; opacity: .9; }
.report-cover-placeholder em { font-style: normal; font-size: .72rem; opacity: .8; margin-top: auto; }
.report-card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.report-card-body strong { font-weight: 500; line-height: 1.4; color: var(--green-900); }
.report-card-body small { color: var(--muted); font-size: .8rem; }
.report-grid-sm .report-card-body { padding: 8px 10px 10px; font-size: .86rem; }
.doc-detail { grid-template-columns: 300px minmax(0, 1fr); margin-bottom: 18px; align-items: start; }
.doc-aside .report-cover { border-radius: 10px; margin-bottom: 8px; box-shadow: var(--shadow); }
.lead { font-size: 1.05rem; color: var(--ink-2); }
.pdf-frame { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #525659; }
.pdf-frame iframe { display: block; width: 100%; height: 80vh; min-height: 520px; border: 0; }
.sub-head .ic { color: var(--green-600); }

/* ---------------- Responsive ---------------- */
@media (max-width: 1280px) {
    .grid-home { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .card-news { grid-column: 1 / -1; }
    .quick-links { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); box-shadow: 0 0 40px rgba(0,0,0,.25); }
    body.sidebar-open .sidebar { transform: none; }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 35; }
    .main { margin-left: 0; }
    .menu-toggle { display: grid; }
    .tagline { display: none; }
    .grid-article, .grid-form, .grid-sidebar, .grid-plans, .doc-detail { grid-template-columns: minmax(0, 1fr); }
    .plans-banner { position: static; }
    .doc-aside .report-cover { max-width: 260px; margin-inline: auto; }
    .report-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
    .pdf-frame iframe { height: 70vh; min-height: 420px; }
    .slide-text { width: 80%; padding-left: 70px; }
    .slide-motto { display: none; }
}
@media (max-width: 760px) {
    body { font-size: 14px; }
    .content { padding: 14px 16px 24px; }
    .topbar { padding: 10px 16px; flex-wrap: wrap; gap: 10px; }
    .topbar-title h1 { font-size: 1.1rem; }
    .search { order: 3; flex: 1 1 100%; min-width: 0; }
    .login-btn, .user-chip .who { display: none; }
    .grid-home, .grid-2, .system-grid, .form-row, .stat-row-2 { grid-template-columns: minmax(0, 1fr); }
    .quick-links { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    /* มือถือ: แบนเนอร์ภาพคงสัดส่วนภาพ, สไลด์ข้อความเริ่มต้นต้องสูงพอให้ข้อความไม่ล้น */
    .hero:has(.slide-default) { aspect-ratio: auto; min-height: 260px; }
    .slide-text { width: 100%; padding: 24px 56px; background: rgba(255,255,255,.85); }
    .doc-list li { grid-template-columns: 34px minmax(0, 1fr); }
    .doc-list .doc-meta { grid-column: 2; }
    .doc-list .btn, .doc-list .doc-actions { grid-column: 2; justify-self: start; }
    .news-item img, .news-item .thumb-placeholder { width: 96px; height: 60px; }
    .level-bars li { grid-template-columns: 1fr 52px; }
    .level-bars .stack { grid-column: 1 / -1; grid-row: 2; }
    .progress-list li { grid-template-columns: 1fr 44px; }
    .progress-list progress { grid-column: 1 / -1; width: 100%; }
    .meta-list, .contact-list { grid-template-columns: 1fr; }
    .footer { padding: 14px 16px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media print {
    .sidebar, .topbar, .footer, .slider-btn, .dots, .chips, .filter-bar, .pagination { display: none !important; }
    .main { margin: 0; }
    .card { box-shadow: none; break-inside: avoid; }
}

/* รูปย่อในตารางรายการ admin (เช่น แบนเนอร์) */
.list-thumb { width: 120px; height: 40px; object-fit: cover; border-radius: 6px; display: block; }
