/* IESSystem — ทะเบียนศูนย์การเรียนตามมาตรา 12
   โทนสี: กระดาษเย็น + หมึกเขียวเข้ม + ตราประทับหยก; แดงชาดใช้กับกำหนดเวลาเท่านั้น */
:root {
  --paper: #f3f4f0;
  --surface: #ffffff;
  --ink: #1c2b33;
  --muted: #55646c;
  --line: #d3d9d4;
  --seal: #0e6655;
  --seal-deep: #0a4a3e;
  --seal-wash: #e3efeb;
  --brass: #946a12;
  --stamp: #b3361f;
  --stamp-wash: #f8e6e1;
  --focus: #1f6feb;
  --radius: 6px;

  --bs-body-font-family: "IBM Plex Sans Thai", system-ui, sans-serif;
  --bs-body-color: var(--ink);
  --bs-body-bg: var(--paper);
  --bs-link-color: var(--seal);
  --bs-link-hover-color: var(--seal-deep);
}

html { font-size: 16px; }
body {
  font-family: var(--bs-body-font-family);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
h1, h2, h3, h4 { font-weight: 600; line-height: 1.35; letter-spacing: 0; }
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- แถบบน ---------- */
.site-bar { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-bar .inner { display: flex; align-items: center; gap: 2rem; min-height: 64px; }
.brand { display: flex; align-items: center; gap: .65rem; color: var(--ink); text-decoration: none; font-weight: 600; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid var(--seal); color: var(--seal);
  display: grid; place-items: center; font-size: .8rem; font-weight: 700;
}
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: .75rem; line-height: 1.2; }
.site-nav { display: flex; gap: .25rem; margin: 0; padding: 0; list-style: none; }
.site-nav a, .nav-drop { white-space: nowrap; }
.site-nav a {
  display: block; padding: .5rem .85rem; border-radius: var(--radius);
  color: var(--ink); text-decoration: none; font-size: .95rem;
}
.site-nav a:hover { background: var(--seal-wash); }
.site-nav a[aria-current="page"] { background: var(--seal-wash); color: var(--seal-deep); font-weight: 600; }
.account { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.account .who { font-size: .9rem; line-height: 1.25; text-align: right; }
.account .who small { display: block; color: var(--muted); font-size: .75rem; }
.nav-toggle { display: none; }
@media (max-width: 991.98px) {
  .site-bar .inner { flex-wrap: wrap; gap: .5rem 1rem; padding: .5rem 0; }
  .nav-toggle { display: inline-block; margin-left: auto; }
  .site-nav { display: none; width: 100%; flex-direction: column; }
  .site-nav.open { display: flex; }
}

/* ---------- หัวหน้า ---------- */
.page-head { padding: 3rem 0 1.5rem; }
.page-head h1 { font-size: clamp(1.9rem, 4.5vw, 3rem); max-width: 22ch; }
.page-head p.lede { color: var(--muted); max-width: 60ch; font-size: 1.1rem; margin-top: .75rem; }

/* ---------- ตัวสร้างรหัสสถานศึกษา (จุดเด่นของหน้าแรก) ---------- */
.code-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 1.75rem; margin-bottom: 2.5rem;
}
.code-plates { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.25rem; }
.plate { text-align: left; }
.plate .digits {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: clamp(2rem, 7vw, 4rem); font-weight: 500; line-height: 1.1;
  padding: .25rem .6rem; border-radius: var(--radius);
  border-bottom: 4px solid currentColor; letter-spacing: .06em;
  background: var(--paper);
}
.plate .cap { font-size: .85rem; color: var(--muted); margin-top: .35rem; min-height: 2.6em; }
.plate-dept { color: var(--ink); }
.plate-prov { color: var(--brass); }
.plate-type { color: var(--seal); }
.plate-run  { color: var(--muted); }
.code-controls { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.code-controls label { font-size: .9rem; font-weight: 500; display: block; margin-bottom: .25rem; }
.code-controls .form-select, .code-controls .form-control { border-color: #9aa7a1; }
.code-note { font-size: .875rem; color: var(--muted); margin: 1rem 0 0; }

/* แบบฟอร์มข้อมูลแบ่งเป็นกลุ่ม: การ์ดต่อกลุ่ม + แถบลิงก์ข้ามกลุ่ม */
.form-groups { border: 0; padding: 0; margin: 0; min-width: 0; display: grid; gap: 1.25rem; }
.form-card { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 1.25rem 1.25rem 1.5rem; scroll-margin-top: 5rem; }
.form-card > h2.part { margin-top: 0; }
.form-jump { display: flex; flex-wrap: wrap; gap: .25rem .5rem; margin: 0 0 1rem; font-size: .9rem; }
.form-jump a { padding: .2rem .65rem; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; background: var(--surface); }
.form-jump a:hover, .form-jump a:focus-visible { border-color: var(--seal); }

/* ตารางที่คลิกทั้งแถวเพื่อเปิดรายการ */
table.row-links tbody tr[data-href] { cursor: pointer; }
table.row-links tbody tr[data-href]:hover > td { background: color-mix(in srgb, var(--brass) 10%, transparent); }

/* ---------- ตัวเลขสรุป ---------- */
.tally { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; margin-bottom: 2.5rem; }
.tally > div { padding: 1.25rem 1.5rem; border-right: 1px solid var(--line); }
.tally > div:last-child { border-right: 0; }
.tally .n { font-size: 2.25rem; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tally .l { color: var(--muted); font-size: .9rem; }
@media (max-width: 575.98px) {
  .tally > div { border-right: 0; border-bottom: 1px solid var(--line); }
  .tally > div:last-child { border-bottom: 0; }
}

/* ---------- ตารางประเภทผู้จัด ---------- */
.type-list { list-style: none; margin: 0 0 3rem; padding: 0; border-top: 1px solid var(--line); }
.type-list li {
  display: grid; grid-template-columns: 3.5rem 1fr auto; gap: .5rem 1.25rem;
  align-items: baseline; padding: 1rem 0; border-bottom: 1px solid var(--line);
}
.type-list .code { font-family: "IBM Plex Mono", monospace; color: var(--seal); font-weight: 500; font-size: 1.25rem; }
.type-list .name { font-weight: 600; }
.type-list .desc { color: var(--muted); font-size: .95rem; grid-column: 2; }
.type-list .count { font-variant-numeric: tabular-nums; color: var(--muted); grid-row: 1; grid-column: 3; }

/* ---------- เลือกประเภทก่อนยื่นคำขอ ---------- */
.radio-cards { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin-bottom: 1.5rem; }
.radio-card input { position: absolute; opacity: 0; }
.radio-card label {
  display: block; height: 100%; padding: 1rem 1.15rem; cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 8px;
}
.radio-card label:hover { border-color: var(--seal); }
.radio-card input:checked + label { border-color: var(--seal); background: var(--seal-wash); box-shadow: inset 0 0 0 1px var(--seal); }
.radio-card input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 2px; }
.radio-card .code { font-family: "IBM Plex Mono", monospace; color: var(--seal); font-weight: 500; }
.radio-card .name { font-weight: 600; font-size: 1.1rem; }
.radio-card .desc { color: var(--muted); font-size: .9rem; margin-top: .15rem; }

.rule-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1.5rem; }
.rule-panel dl { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1.5rem; margin: 0; }
.rule-panel dt { font-weight: 400; color: var(--muted); }
.rule-panel dd { margin: 0; font-weight: 600; }
.facts { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: .35rem; font-size: .95rem; }
.facts li::before { content: "•"; color: var(--seal); margin-right: .6rem; }

/* ---------- คิวคำขอ ---------- */
.queue-table { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.queue-table table { margin: 0; }
.queue-table th { font-weight: 600; background: var(--paper); font-size: .9rem; white-space: nowrap; }
.queue-table td { vertical-align: middle; }
.sla { font-variant-numeric: tabular-nums; font-weight: 600; }
.sla.late { color: var(--stamp); }
.sla.soon { color: var(--stamp); }
.chip { display: inline-block; padding: .1rem .6rem; border-radius: 99px; font-size: .85rem; border: 1px solid var(--line); background: var(--paper); }
.chip.ok { background: var(--seal-wash); border-color: #b5d3ca; color: var(--seal-deep); }
.chip.bad { background: var(--stamp-wash); border-color: #e7bdb3; color: var(--stamp); }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.filters a { padding: .3rem .85rem; border: 1px solid var(--line); border-radius: 99px; text-decoration: none; color: var(--ink); background: var(--surface); font-size: .9rem; }
.filters a[aria-current="true"] { background: var(--seal); color: #fff; border-color: var(--seal); }

.empty { padding: 3rem 1.5rem; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 1.15rem; margin-bottom: .25rem; }
.notice { border-left: 4px solid var(--brass); background: #f7f0dd; padding: .75rem 1rem; border-radius: 0 var(--radius) var(--radius) 0; margin-bottom: 1.5rem; font-size: .95rem; }

.btn-seal { background: var(--seal); color: #fff; border: 0; padding: .6rem 1.25rem; border-radius: var(--radius); font-weight: 500; text-decoration: none; display: inline-block; }
.btn-seal:hover { background: var(--seal-deep); color: #fff; }
.btn-seal[aria-disabled="true"] { background: #9aa7a1; pointer-events: none; }

/* ---------- wizard ยื่นคำขอ ---------- */
.stepper { list-style: none; margin: 0 0 1.5rem; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; counter-reset: s; }
.stepper li { counter-increment: s; flex: 1 1 150px; }
.stepper button {
  width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .55rem .8rem; font-size: .9rem; color: var(--muted); display: flex; gap: .55rem; align-items: baseline;
}
.stepper button::before { content: counter(s); font-weight: 600; color: var(--muted); }
.stepper button[aria-current="step"] { border-color: var(--seal); background: var(--seal-wash); color: var(--seal-deep); font-weight: 600; }
.stepper button[aria-current="step"]::before { color: var(--seal); }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1.5rem; margin: 0 0 1rem; min-width: 0; }
.step[hidden] { display: none; }
.step legend { float: none; width: auto; font-size: 1.35rem; font-weight: 600; margin-bottom: 1rem; padding: 0; }
.step legend:focus { outline: none; }
.fields { display: grid; gap: .9rem 1.1rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.fields.one { grid-template-columns: minmax(0, 46rem); }
.field label { display: block; font-size: .9rem; font-weight: 500; margin-bottom: .25rem; }
.field .opt { font-weight: 400; color: var(--muted); font-size: .8rem; margin-left: .4rem; }
.form-control, .form-select { border-color: #9aa7a1; background-color: #fff; }
.form-control:disabled, .form-select:disabled { background-color: var(--paper); }
.part { font-size: 1.15rem; margin: 2rem 0 .5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.part .count-note { font-size: .85rem; font-weight: 400; color: var(--muted); margin-left: .5rem; }
.sub { font-size: 1rem; margin: 1.5rem 0 .6rem; color: var(--seal-deep); }
.hint { color: var(--muted); font-size: .9rem; max-width: 60ch; margin: .75rem 0; }
.check { display: flex; align-items: center; gap: .5rem; margin: .25rem 0 .75rem; }
.radio-row { display: flex; flex-wrap: wrap; gap: .25rem 1.5rem; }
.nav-row { display: flex; justify-content: space-between; margin-top: 1.75rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.form-errors { background: var(--stamp-wash); border: 1px solid #e7bdb3; border-radius: 8px; padding: 1rem 1.25rem; margin-bottom: 1rem; }
.form-errors ul { margin: .5rem 0; padding-left: 1.25rem; }
.member { border: 1px solid var(--line); border-radius: 8px; padding: .5rem 1rem 1rem; margin-bottom: .6rem; }
.member summary { font-weight: 600; cursor: pointer; padding: .4rem 0; }
.plan { display: grid; gap: 1.1rem; }
.plan-item { display: grid; grid-template-columns: 2rem minmax(0, 46rem); gap: .75rem; }
.plan-item .no { font-weight: 600; color: var(--seal); padding-top: .1rem; }
.docs { display: grid; gap: 1rem; max-width: 40rem; }
.ok-notice { border-left-color: var(--seal); background: var(--seal-wash); }

.tracker { list-style: none; margin: 0 0 1.5rem; padding: 0; display: flex; gap: 0; }
.tracker li { flex: 1; padding: .6rem .9rem; border-top: 4px solid var(--line); color: var(--muted); font-size: .95rem; }
.tracker li small { display: block; font-size: .8rem; }
.tracker li.done { border-top-color: var(--seal); color: var(--ink); font-weight: 600; }
.tracker li.bad { border-top-color: var(--stamp); color: var(--stamp); font-weight: 600; }
@media (max-width: 575.98px) { .tracker { flex-direction: column; } .tracker li { border-top: 0; border-left: 4px solid var(--line); } .tracker li.done { border-left-color: var(--seal); } .tracker li.bad { border-left-color: var(--stamp); } }

.site-foot { border-top: 1px solid var(--line); color: var(--muted); font-size: .875rem; padding: 1.25rem 0; margin-top: 3rem; background: var(--surface); }

@media (prefers-reduced-motion: no-preference) {
  .plate .digits { transition: color .15s; }
}

/* ---------- หน้าจอข้อมูลหลัก ---------- */
.ctx-bar { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: end; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.25rem; margin-bottom: 1rem; }
.ctx-bar .field { min-width: 12rem; }
.ctx-bar .field.grow { flex: 1 1 18rem; }
.ctx-bar .status .lbl { display: block; font-size: .9rem; font-weight: 500; margin-bottom: .25rem; }
.data-form { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1.5rem; }
.data-form fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.data-form .part.first { margin-top: 0; padding-top: 0; border-top: 0; }
.field.span2 { grid-column: span 2; }
@media (max-width: 575.98px) { .field.span2 { grid-column: span 1; } }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.btn-ghost { border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: .5rem 1rem; border-radius: var(--radius); text-decoration: none; display: inline-block; }
.btn-ghost:hover { border-color: var(--seal); color: var(--seal-deep); }
.select2-container--bootstrap-5 .select2-selection { border-color: #9aa7a1; }
.conf-list { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr)); }
.conf-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; }
.report-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); margin-top: 1rem; }

/* เมนูย่อยบนแถบบน */
.site-nav .dropdown { position: relative; }
.nav-drop { background: none; border: 0; padding: .5rem .85rem; border-radius: var(--radius); color: var(--ink); font-size: .95rem; }
.nav-drop:hover, .nav-drop[data-current="page"] { background: var(--seal-wash); color: var(--seal-deep); }
.nav-drop::after { content: ""; display: inline-block; margin-left: .4rem; border: .3em solid transparent; border-top-color: currentColor; border-bottom: 0; vertical-align: .15em; }
.site-nav .dropdown-menu { border-color: var(--line); border-radius: 8px; padding: .35rem; min-width: 16rem; }
.site-nav .dropdown-item { border-radius: 6px; padding: .45rem .75rem; font-size: .95rem; }
.site-nav .dropdown-item:hover { background: var(--seal-wash); }
@media (max-width: 991.98px) { .site-nav .dropdown-menu { position: static !important; transform: none !important; border: 0; box-shadow: none; padding-left: 1rem; } }

/* กราฟ */
.chart-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr)); }
.chart-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.25rem; margin: 0; }
.chart-card figcaption { font-weight: 600; margin-bottom: .5rem; }
.chart-box { position: relative; height: 260px; }
.chart-empty { color: var(--muted); text-align: center; padding-top: 6rem; }
.id-check { background: var(--paper); border: 1px dashed var(--line); border-radius: 8px; padding: 1rem; margin-top: 1rem; }

/* Status Dot และ Overflow Menu (NameThatUI) */
.status-dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; margin-right: .5rem; background: #9aa7a1; vertical-align: .05em; }
.status-dot.on { background: #1f8f5f; }
.status-dot.off { background: var(--stamp); }
.status-dot.wait { background: var(--brass); }
.row-menu { position: relative; display: inline-block; text-align: left; }
.row-menu > summary { list-style: none; cursor: pointer; width: 2rem; height: 2rem; display: grid; place-items: center; border-radius: 50%; font-size: 1.25rem; line-height: 1; color: var(--muted); }
.row-menu > summary::-webkit-details-marker { display: none; }
.row-menu > summary:hover, .row-menu[open] > summary { background: var(--seal-wash); color: var(--seal-deep); }
.row-menu-list { position: absolute; right: 0; top: 2.2rem; z-index: 20; min-width: 15rem; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .4rem; box-shadow: 0 6px 20px rgba(28,43,51,.14); display: grid; gap: .25rem; }
.row-menu-list form { margin: 0; display: grid; gap: .25rem; }
.row-menu-list button { width: 100%; text-align: left; background: none; border: 0; padding: .45rem .65rem; border-radius: 6px; font-size: .95rem; }
.row-menu-list button:hover { background: var(--seal-wash); }
.row-menu-list button.danger { color: var(--stamp); }
.row-menu-list button.danger:hover { background: var(--stamp-wash); }

/* Bento Grid + แถบสัดส่วน (NameThatUI) */
.bento { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); margin-bottom: 1rem; }
.bento > .rule-panel:first-child { grid-row: span 2; }
.bento-tally { grid-template-columns: 1fr 1fr; margin-bottom: 0; }
.bar-row { display: grid; grid-template-columns: 9rem 1fr 3rem; gap: .75rem; align-items: center; margin: .4rem 0; font-size: .95rem; }
.bar { height: .7rem; background: var(--paper); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--seal); border-radius: 99px; }
.bar-row b { text-align: right; font-variant-numeric: tabular-nums; }

/* Bottom Navigation — แสดงเฉพาะจอมือถือ/แท็บเล็ตแนวตั้ง */
.bottom-nav { display: none; }
@media (max-width: 991.98px) {
  body { padding-bottom: 4.25rem; }
  .bottom-nav {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
    background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav a { display: grid; justify-items: center; gap: .15rem; padding: .5rem .25rem; font-size: .8rem; color: var(--muted); text-decoration: none; }
  .bottom-nav svg { width: 1.4rem; height: 1.4rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .bottom-nav a[aria-current="page"] { color: var(--seal-deep); font-weight: 600; }
  .bottom-nav a:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
}
.row-menu-list .menu-link { display: block; padding: .45rem .65rem; border-radius: 6px; font-size: .95rem; color: var(--ink); text-decoration: none; }
.row-menu-list .menu-link:hover { background: var(--seal-wash); }
tr.row-off td { color: var(--muted); }

/* เข้าสู่ระบบ / บัญชีของฉัน */
.login-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 28rem)); align-items: start; }
.ext-list { display: grid; gap: .6rem; margin-bottom: 1rem; }
.ext-btn { display: grid; padding: .7rem 1rem; border: 1.5px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); text-decoration: none; }
.ext-btn:hover { border-color: var(--seal); background: var(--seal-wash); }
.ext-btn .ext-name { font-weight: 600; }
.ext-btn small { color: var(--muted); }
.ext-linked { list-style: none; margin: 0 0 .5rem; padding: 0; }
.ext-linked li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .65rem 0; border-bottom: 1px solid var(--line); }
.ext-linked li:last-child { border-bottom: 0; }
.ext-linked form { margin: 0; }

/* ---------- แผนที่หน้าแรก ---------- */
.home-map { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.map-stage { position: relative; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; }
#mapCanvas { height: 560px; background: #f7f8f5; }
#mapCanvas .leaflet-container { background: #f7f8f5; font-family: inherit; }
.map-legend { position: absolute; left: .75rem; bottom: .75rem; z-index: 500; display: flex; flex-wrap: wrap; gap: .25rem .75rem; align-items: center;
  background: rgb(255 255 255 / .92); border: 1px solid var(--line); border-radius: var(--radius); padding: .35rem .65rem; font-size: .8rem; max-width: calc(100% - 1.5rem); }
.map-legend .lg-title { font-weight: 600; }
.map-legend .lg-item { display: inline-flex; align-items: center; gap: .3rem; }
.map-legend i { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgb(0 0 0 / .15); display: inline-block; }
.map-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1.25rem 1.25rem 1.5rem; }
.fig-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin: 0; border-top: 1px solid var(--line); }
.fig-list > div { padding: .85rem .25rem; border-bottom: 1px solid var(--line); }
.fig-list > div:nth-child(odd) { padding-right: 1rem; border-right: 1px solid var(--line); }
.fig-list > div:nth-child(even) { padding-left: 1rem; }
.fig-list dt { font-weight: 400; color: var(--muted); font-size: .875rem; }
.fig-list dd { margin: 0; font-size: 2rem; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; color: var(--seal-deep); }
.office-table { font-size: .875rem; }
.office-table td:first-child { min-width: 9rem; }
@media (max-width: 991.98px) {
  .home-map { grid-template-columns: 1fr; }
  #mapCanvas { height: 380px; }
}

/* ---------- ข่าวสาร ---------- */
.news-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.25rem; }
.news-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.news-card.pinned { border-color: var(--seal); }
.news-media { display: block; aspect-ratio: 16 / 9; background: var(--seal-wash); }
.news-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.news-ph { height: 100%; display: grid; place-items: center; font-weight: 600; font-size: 1.15rem; color: var(--seal-deep); }
.news-ph.cat-activity { background: #f3ead2; color: var(--brass); }
.news-ph.cat-pr { background: #e1ebf1; color: #2f6580; }
.news-body { padding: 1rem 1.1rem 1.25rem; display: flex; flex-direction: column; gap: .35rem; }
.news-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .6rem; font-size: .8rem; color: var(--muted); margin: 0; }
.news-meta .chip.cat-activity { color: var(--brass); }
.news-meta .chip.cat-pr { color: #2f6580; }
.news-title { font-size: 1.05rem; margin: 0; }
.news-title a { color: var(--ink); text-decoration: none; }
.news-title a:hover, .news-title a:focus-visible { color: var(--seal); text-decoration: underline; }
.news-sum { margin: 0; color: var(--muted); font-size: .9rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.news-article { max-width: 46rem; padding-bottom: 2rem; }
.news-article h1 { font-size: 1.75rem; margin: .5rem 0 1rem; }
.news-hero { width: 100%; border-radius: 10px; margin-bottom: 1.25rem; }
.news-text { white-space: pre-line; overflow-wrap: anywhere; }
.code-explain > summary { cursor: pointer; font-weight: 600; padding: .5rem 0; }
.cred { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 1.25rem; letter-spacing: .04em; color: var(--ink); background: var(--seal-wash); padding: .15rem .5rem; border-radius: var(--radius); }
@media print { .site-bar, .bottom-nav, .site-foot, .no-print { display: none !important; } }

/* แถบเมนูมีหลายรายการ: ไม่ให้ปุ่มออกจากระบบถูกบีบจนตัดบรรทัด */
.account { flex-shrink: 0; }
.account .btn, .account .who { white-space: nowrap; }
@media (max-width: 1399.98px) { .site-bar .inner { gap: 1rem; } .site-nav a { padding: .5rem .6rem; } }

/* ---------- Bento grid (ตัวเลขสรุป) ---------- */
.bento { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: minmax(110px, auto); gap: .9rem; margin-bottom: 1.75rem; }
.bento-tile { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1rem 1.15rem; display: flex; flex-direction: column; justify-content: space-between; }
.bento-tile .l { color: var(--muted); font-size: .9rem; }
.bento-tile .n { font-size: 2.1rem; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.bento-tile .s { color: var(--muted); font-size: .8rem; }
.bento-main { grid-column: span 2; grid-row: span 2; background: var(--seal-deep); border-color: var(--seal-deep); color: #fff; }
.bento-main .l, .bento-main .s { color: rgb(255 255 255 / .75); }
.bento-main .n { font-size: 3.5rem; }
.bento-accent { background: var(--seal-wash); border-color: transparent; }
@media (max-width: 767.98px) { .bento { grid-template-columns: repeat(2, minmax(0, 1fr)); } .bento-main { grid-column: span 2; grid-row: auto; } .bento-main .n { font-size: 2.75rem; } }

/* ---------- Carousel ข่าวเด่น ---------- */
.news-carousel { border-radius: 14px; overflow: hidden; background: var(--seal-deep); }
.news-carousel .slide { display: block; position: relative; aspect-ratio: 21 / 8; color: #fff; text-decoration: none; }
.news-carousel .slide img, .news-carousel .slide-ph { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.news-carousel .slide-ph { background: linear-gradient(135deg, var(--seal) 0%, var(--seal-deep) 100%); }
.news-carousel .slide-ph.cat-activity { background: linear-gradient(135deg, #b88a2a, var(--brass)); }
.news-carousel .slide-ph.cat-pr { background: linear-gradient(135deg, #3f7f9b, #2f6580); }
.news-carousel .slide-cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 2.5rem 3.5rem 2.25rem 2rem; display: flex; flex-direction: column; gap: .35rem; align-items: flex-start;
  background: linear-gradient(to top, rgb(10 30 28 / .88), transparent); }
.news-carousel .slide-cap strong { font-size: 1.5rem; line-height: 1.35; }
.news-carousel .slide-cap .chip { background: rgb(255 255 255 / .92); color: var(--seal-deep); }
.news-carousel .carousel-indicators { margin-bottom: .4rem; }
@media (max-width: 767.98px) { .news-carousel .slide { aspect-ratio: 4 / 3; } .news-carousel .slide-cap { padding: 1.5rem 1rem 2rem; } .news-carousel .slide-cap strong { font-size: 1.1rem; } }

/* ---------- Steps ---------- */
.steps { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; list-style: none; padding: 0; margin: 0 0 1.5rem; }
.steps li { display: flex; align-items: center; gap: .55rem; color: var(--muted); font-size: .95rem; }
.steps .dot { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: .85rem; font-weight: 600; background: var(--surface); }
.steps .done { color: var(--ink); } .steps .done .dot { background: var(--seal); border-color: var(--seal); color: #fff; }
.steps .now { color: var(--ink); font-weight: 600; } .steps .now .dot { border-color: var(--seal); color: var(--seal); }

/* ---------- Pagination / Switch / Spinner ---------- */
.pagination { --bs-pagination-color: var(--seal); --bs-pagination-active-bg: var(--seal); --bs-pagination-active-border-color: var(--seal); --bs-pagination-hover-color: var(--seal-deep); --bs-pagination-focus-color: var(--seal-deep); }
.form-switch .form-check-input:checked { background-color: var(--seal); border-color: var(--seal); }
.map-loading { position: absolute; inset: 0; z-index: 600; display: grid; place-items: center; align-content: center; background: rgb(247 248 245 / .85); color: var(--muted); }
.btn-busy { pointer-events: none; opacity: .85; }

/* ส่งออกข้อมูลตามโครงสร้างมาตรฐาน */
.export-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1.25rem 1.5rem 1.5rem; margin-bottom: 1rem; }
.scope-choice { border: 0; padding: 0; margin: 1rem 0 0; }
.scope-choice legend { font-size: .95rem; font-weight: 600; margin-bottom: .35rem; }
.scope-pick { max-width: 34rem; margin: .25rem 0 .6rem 1.75rem; }

/* กลุ่มข้อมูลของแบบฟอร์มผู้เรียน: ข้อมูลส่วนบุคคล / ข้อมูลครอบครัว */
.form-group-block { display: grid; gap: 1.25rem; }
.form-groups { gap: 2.25rem; }
.group-title { font-size: 1.35rem; margin: 0; padding-bottom: .5rem; border-bottom: 3px solid var(--seal); }
.form-jump .jump-label { font-weight: 600; color: var(--seal-deep); align-self: center; margin-left: .5rem; }
.form-jump .jump-label:first-child { margin-left: 0; }
.guardian-switches { display: flex; flex-wrap: wrap; gap: .5rem 2rem; margin-bottom: .5rem; }

/* กลุ่มย่อยในการ์ดฟอร์ม: เรียงช่องเป็นหมวดตามลำดับที่ผู้ใช้กรอก */
.sub-group { border: 0; border-top: 1px solid var(--line); padding: .9rem 0 .25rem; margin: 0 0 .5rem; min-width: 0; }
.sub-group:first-of-type { border-top: 0; padding-top: 0; }
.sub-group > legend { float: none; width: auto; font-size: .95rem; font-weight: 600; color: var(--seal-deep); margin: 0 0 .5rem; padding: 0; }
.sub-group > legend .opt { font-weight: 400; }

/* ปรับระยะกลุ่มย่อยให้อ่านง่ายขึ้น */
.sub-group, .sub-group:first-of-type { border-top: 0; padding: 0; margin: 0 0 1.5rem; }
.sub-group + .sub-group { border-top: 1px dashed var(--line); padding-top: 1.1rem; }
.sub-group:last-of-type { margin-bottom: .25rem; }
.sub-group > legend { margin-bottom: .75rem; }
.form-card .sub-group { margin: 0; padding: 1.25rem 0 1.5rem; border-top: 1px dashed var(--line); }
.form-card .sub-group:first-of-type { border-top: 0; padding-top: .25rem; }
.form-card .sub-group:last-of-type { padding-bottom: .25rem; }

/* ประวัติการใช้งาน (audit) */
.audit-dl { display: grid; grid-template-columns: 9rem 1fr; gap: .35rem 1rem; margin: 0; }
.audit-dl dt { color: var(--muted); font-weight: 400; }
.audit-dl dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 575.98px) { .audit-dl { grid-template-columns: 1fr; } .audit-dl dt { margin-top: .4rem; } }

/* ตัวสร้าง API: รายการฟิลด์/ตัวเลือก และตัวอย่างโค้ด */
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: .15rem 1rem; max-height: 22rem; overflow: auto; padding: .25rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.field-opt { display: flex; align-items: center; gap: .45rem; padding: .2rem .25rem; font-size: .9rem; cursor: pointer; overflow-wrap: anywhere; }
.field-opt .pii { color: var(--stamp); }
.code-sample { background: #1c2b33; color: #e8f1ee; padding: 1rem 1.1rem; border-radius: var(--radius); overflow-x: auto; white-space: pre-wrap; word-break: break-all; font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: .85rem; }

/* สวิตช์เปิด/ปิดในตาราง (js-switch) */
.row-switch { display: flex; align-items: center; gap: .6rem; min-height: 1.6rem; }
.row-switch .form-check-input { margin: 0; float: none; cursor: pointer; width: 2.4em; height: 1.3em; flex: none; }
.row-switch .form-check-input:disabled { cursor: not-allowed; }
.row-switch .form-check-label { min-width: 5.2rem; }
