/* css/board.css — แดชบอร์ดสำนักพัฒนาสังคม ; โครงเดียวกับหน้าศูนย์เด็ก/หอพัก/Bangkok Brand */
:root {
    --bg: #f4f6f3; --surface: #fff; --line: #e2e8e0;
    --ink: #1c2420; --ink-2: #4a5550; --ink-3: #66716b;
    --focus: #1d4ed8; --radius: 14px;
    --hero-1: #123f24; --hero-2: #17552f; --accent: #f2c14e;
    --primary: #2e7d32; --primary-ink: #1b5e20; --primary-soft: #e8f3e9;
    /* แผนที่: น้ำเงินไล่ระดับสีเดียว 5 ขั้น (ตรวจแล้ว: ไล่ความสว่างชัด ขั้นอ่อนสุดตัดพื้นขาว ≥ 2:1) + ศูนย์ (เทา) */
    --q0: #eceee9; --q1: #86b6ef; --q2: #3987e5; --q3: #256abf; --q4: #184f95; --q5: #0d366b;
    --sz-s: #86b6ef; --sz-m: #256abf; --sz-l: #0d366b;
    --d-r: #2a78d6; --d-n: #eb6834;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: "Sarabun", "Noto Sans Thai", "Leelawadee UI", "Leelawadee", Tahoma, sans-serif; font-size: 16px; line-height: 1.55; }
a { color: var(--primary-ink); }
a:focus, button:focus, input:focus, select:focus, [tabindex]:focus { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.bp { max-width: 1280px; margin: 0 auto; padding: 16px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; padding: 10px 16px; background: #0f172a; color: #fff; font-weight: 700; border-radius: 0 0 8px 8px; text-decoration: none; }
.skip-link:focus { top: 0; }
.muted { color: var(--ink-3); }
.js .nojs-only { display: none; }

/* ---------- หัว ---------- */
.hero {
    position: relative; overflow: hidden; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px;
    padding: 24px 28px; border-radius: var(--radius); color: #fff; background: linear-gradient(120deg, var(--hero-1), var(--hero-2));
}
.hero::after { content: ""; position: absolute; right: -60px; top: -80px; width: 280px; height: 280px; border-radius: 50%; border: 36px solid rgba(255, 255, 255, .06); pointer-events: none; }
.eyebrow { margin: 0 0 4px; font-size: 14px; font-weight: 600; color: var(--accent); }
.hero h1 { margin: 0; font-size: 30px; line-height: 1.2; }
.lead { margin: 6px 0 0; color: rgba(255, 255, 255, .88); }
.lead a { color: #fff; font-weight: 700; }
.lead a:focus { outline-color: #fff; }
.pick { position: relative; z-index: 1; min-width: 260px; }
.pick label { display: block; font-size: 14px; font-weight: 600; color: rgba(255, 255, 255, .9); margin-bottom: 4px; }
.pick-row { display: flex; gap: 8px; }
.pick select { flex: 1; height: 44px; padding: 0 12px; font: inherit; font-size: 16px; border-radius: 10px; border: 0; color: var(--ink); background: #fff; }
.pick select:focus { outline: 3px solid var(--accent); outline-offset: 2px; }

.btn { display: inline-flex; align-items: center; justify-content: center; height: 42px; padding: 0 16px; font: inherit; font-weight: 700; border-radius: 10px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn-light { background: var(--accent); color: #1c2420; border: 0; height: 44px; }
.btn-ghost { background: #fff; color: var(--ink-2); border: 1px solid #7d8a82; }
.btn-ghost:hover { background: #f1f4f1; }

/* ---------- การ์ด ---------- */
.cards { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.card { display: flex; flex-direction: column; padding: 16px 18px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); border-top: 5px solid var(--primary); }
.c-child { border-top-color: #256abf; }
.c-bb { border-top-color: #b8860b; }
.c-mib { border-top-color: #0f766e; }
.c-dorm { border-top-color: #b4471b; }
.card h3 { margin: 0; font-size: 16px; }
.big { margin: 6px 0 0; font-size: 34px; font-weight: 800; line-height: 1.1; }
.big small { font-size: 15px; font-weight: 600; color: var(--ink-2); }
.sub { margin: 4px 0 10px; font-size: 13px; color: var(--ink-3); }
.na { margin: 10px 0; color: #7f1d1d; font-weight: 600; }
.more { margin-top: auto; padding-top: 10px; font-size: 14px; font-weight: 700; }
.more::after { content: " \2192"; }
.asof { margin: 6px 0 0; font-size: 12px; color: var(--ink-3); }
.kv { margin: 0 0 8px; font-size: 14px; display: grid; gap: 2px; }
.kv div { display: flex; flex-wrap: wrap; gap: 0 6px; }
.kv dt { color: var(--ink-3); }
.kv dt::after { content: ":"; }
.kv dd { margin: 0; font-weight: 600; }

.mb { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.mb li { display: grid; grid-template-columns: minmax(70px, 44%) 1fr auto; gap: 8px; align-items: center; padding: 2px 0; }
.mb-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.mb-b { height: 10px; }
.mb-b span { display: block; height: 100%; min-width: 2px; border-radius: 0 3px 3px 0; }
.mb-v { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.f-g { background: var(--primary); }
.c-bb .f-g { background: #9a6b00; }
.c-mib .f-g { background: #0f766e; }
.c-chum .f-g { background: var(--primary); }

.stack { display: flex; gap: 2px; height: 14px; margin: 2px 0 4px; }
.stack span { display: block; height: 100%; min-width: 3px; }
.stack span:first-child { border-radius: 4px 0 0 4px; }
.stack span:last-child { border-radius: 0 4px 4px 0; }
.stack span:only-child { border-radius: 4px; }
.sz-s { background: var(--sz-s); } .sz-m { background: var(--sz-m); } .sz-l { background: var(--sz-l); }
.d-r { background: var(--d-r); } .d-n { background: var(--d-n); }
.stack-l { margin: 0 0 6px; font-size: 13px; color: var(--ink-2); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: 0; }
.ranks { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.rank { padding: 1px 8px; border-radius: 999px; font-size: 12px; border: 1px solid; }
.rank-premium  { background: #f1eafc; color: #4b2a86; border-color: #b9a0e6; }
.rank-platinum { background: #e5f2f4; color: #1d5360; border-color: #8fbfc8; }
.rank-gold     { background: #fdf3d2; color: #6e5000; border-color: #e0b84a; }
.rank-silver   { background: #eef1f4; color: #3c4753; border-color: #a9b3bd; }
.rank-bronze   { background: #f8e7da; color: #7a3a10; border-color: #d39a6c; }
.rank-other    { background: #f1f3f1; color: #3c4540; border-color: #c4ccc6; }

/* ---------- แผง ---------- */
.panel { margin-top: 14px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 10px 16px; }
.panel-head h2 { margin: 0; font-size: 20px; }
.panel-head h2:focus { outline: none; }
.count { margin: 2px 0 0; color: var(--ink-2); }
.hint { margin: 8px 0 0; font-size: 13px; color: var(--ink-3); }

/* แผนที่ */
.metric fieldset { margin: 0; padding: 0; border: 0; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.metric legend { float: left; margin-right: 8px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.metric label { display: inline-flex; align-items: center; gap: 4px; padding: 5px 12px; border: 1px solid #b7c2bb; border-radius: 999px; font-size: 14px; cursor: pointer; background: #fff; }
.metric label:has(input:checked) { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-ink); font-weight: 700; }
.metric input { margin: 0; accent-color: var(--primary); }
.metric input:focus { outline: 3px solid var(--focus); outline-offset: 2px; }
.metric { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.map-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 18px; margin-top: 12px; }
.map-box { position: relative; }
.bkkmap { display: block; width: 100%; height: auto; }
.bkkmap path { stroke: #fff; stroke-width: .9; stroke-linejoin: round; transition: opacity .12s; }
.bkkmap a { cursor: pointer; }
.bkkmap a:hover path, .bkkmap a:focus path { stroke: #111; stroke-width: 1.8; }
.bkkmap a:focus { outline: none; }
.bkkmap a:focus path { stroke: var(--focus); stroke-width: 3; }
.bkkmap .sel-outline { fill: none; stroke: #111; stroke-width: 3; pointer-events: none; }
.q0 { fill: var(--q0); background: var(--q0); } .q1 { fill: var(--q1); background: var(--q1); } .q2 { fill: var(--q2); background: var(--q2); }
.q3 { fill: var(--q3); background: var(--q3); } .q4 { fill: var(--q4); background: var(--q4); } .q5 { fill: var(--q5); background: var(--q5); }
.tip { position: absolute; z-index: 3; pointer-events: none; padding: 6px 10px; border-radius: 8px; background: rgba(15, 23, 42, .92); color: #fff; font-size: 13px; line-height: 1.4; white-space: nowrap; }
.tip b { display: block; }
.map-side h3 { margin: 0 0 6px; font-size: 15px; }
.map-side h3 + .legend, .map-side .legend + h3 { margin-top: 0; }
.legend { list-style: none; margin: 0 0 14px; padding: 0; font-size: 14px; display: grid; gap: 4px; }
.legend li { display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.sw { display: inline-block; width: 22px; height: 14px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.top5 { margin: 0 0 12px; padding-left: 22px; font-size: 14px; line-height: 1.9; }
.top5 b { font-variant-numeric: tabular-nums; }
.map-note { margin: 0; font-size: 13px; color: var(--ink-3); }

/* ตาราง */
.tools { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.fld label { display: block; margin-bottom: 4px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.fld input { width: 240px; height: 42px; padding: 0 12px; font: inherit; font-size: 15px; border: 1px solid #7d8a82; border-radius: 10px; }
.table-wrap { position: relative; margin-top: 10px; overflow: auto; max-height: 640px; border: 1px solid var(--line); border-radius: 12px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl thead th { position: sticky; top: 0; z-index: 1; background: var(--primary); color: #fff; }
.tbl thead th button { font: inherit; font-weight: 700; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.tbl thead th button::after { content: "\2195"; opacity: .55; font-size: 12px; }
.tbl thead th[aria-sort="ascending"] button::after { content: "\25B2"; opacity: 1; }
.tbl thead th[aria-sort="descending"] button::after { content: "\25BC"; opacity: 1; }
.tbl thead th button:focus { outline: 3px solid #fff; outline-offset: 2px; }
.tbl thead th.num button { justify-content: flex-end; }
.tbl tbody tr:nth-child(even) { background: #f8faf8; }
.tbl tbody tr.is-sel { background: #fff4c7; }
.tbl tbody tr.is-sel th a { font-weight: 800; }
.tbl tbody th a { color: var(--primary-ink); font-weight: 600; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl td .z { color: var(--ink-3); }
.tbl tfoot th, .tbl tfoot td { position: sticky; bottom: 0; background: var(--primary-soft); font-weight: 800; border-top: 2px solid var(--primary); }

/* iframe สวัสดิการ */
.wf { display: block; width: 100%; height: 640px; margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }

.foot { margin: 14px 0 4px; text-align: center; font-size: 13px; color: var(--ink-3); }

@media (max-width: 900px) {
    .map-wrap { grid-template-columns: 1fr; }
    .map-side { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
    .map-side .map-note { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
    .bp { padding: 10px; }
    .hero { padding: 20px; }
    .hero h1 { font-size: 24px; }
    .pick { min-width: 0; width: 100%; }
    .panel { padding: 14px; }
    .fld, .fld input { width: 100%; }
    .tools, .tools .btn { width: 100%; }
    .map-side { grid-template-columns: 1fr; }
}
@media (forced-colors: active) {
    .bkkmap path { forced-color-adjust: none; }
    .stack span, .mb-b span { border: 1px solid CanvasText; }
}
@media print {
    .pick, .metric, .tools, .wf, .skip-link { display: none !important; }
    .hero { color: #000; background: none; border: 1px solid #000; }
    .lead, .eyebrow { color: #000; }
    .table-wrap { max-height: none; overflow: visible; }
}
/* ขอบเขตชุมชน (include/boardbnd.php) */
.bnd-box { margin-top: 10px; padding: 8px 10px; background: #f2f6ff; border: 1px solid #c7d2fe; border-radius: 10px; }
.bnd-line { margin: 0 0 6px; font-size: 14px; }
.bnd-bar { display: block; height: 8px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.bnd-bar span { display: block; height: 100%; background: #312e81; }
.bnd-link { display: inline-block; margin-top: 6px; font-size: 14px; font-weight: 700; }
.bnd-link::after { content: " \2192"; }
