/* ==========================================================================
   ระบบของหาย–ของที่เก็บได้ · โรงเรียนเสาไห้ "วิมลวิทยานุกูล"
   โลกภาพ: แผนที่นำเที่ยวโรงเรียน — สีแบน ไม่มีไล่เฉด · พื้นที่เขียวบนพื้นขาวนวล
   ปุ่มแคปซูล · ฟอนต์ Sarabun (ฝังในระบบ ไม่ดึงจากภายนอก)
   ========================================================================== */

@font-face { font-family: 'Sarabun'; font-style: normal; font-weight: 400; font-display: swap; src: url(../fonts/sarabun-400.woff2) format('woff2'); }
@font-face { font-family: 'Sarabun'; font-style: normal; font-weight: 600; font-display: swap; src: url(../fonts/sarabun-600.woff2) format('woff2'); }
@font-face { font-family: 'Sarabun'; font-style: normal; font-weight: 700; font-display: swap; src: url(../fonts/sarabun-700.woff2) format('woff2'); }

:root {
  /* ภูมิประเทศ */
  --ground: #F5F1E4;      /* พื้น = ทางเดิน/ถนน/น้ำ ที่โผล่ระหว่างพื้นที่ */
  --paper: #FFFFFF;
  --land: #8ED462;        /* พื้นที่โรงเรียน */
  --land-soft: #CBEBB3;
  --land-tint: #E4F5D8;
  --land-ink: #2D5A1B;
  --school: #0B6845;      /* เขียวโรงเรียน: ปุ่มยืนยันหลัก */
  --school-ink: #FFFFFF;
  --sun: #FFD23F;         /* เหลืองโรงเรียน: ป้ายแคปซูล */
  --sun-tint: #FFF2BF;
  --sun-ink: #5C4300;
  --coral: #FF6B5A;       /* ใช้ทำป้าย/สัญญาณเท่านั้น */
  --coral-tint: #FFE3DE;
  --coral-ink: #A8261A;
  --pond: #4FA6E3;
  --pond-tint: #DCEEFB;
  --pond-ink: #18598F;
  --lilac: #EBC1FF;
  --lilac-tint: #F5E6FF;
  --lilac-ink: #5E2F7E;
  --ink: #2C2E2A;
  --ink-2: #53564D;
  --ink-3: #6E7166;
  --line: #DCD5C1;
  --line-soft: #ECE7D8;
  --grey-tint: #ECE8DC;

  --r-cap: 999px;
  --r-panel: 28px;
  --r-block: 18px;
  --r-field: 14px;
  --shadow: 0 14px 34px -16px rgba(44, 46, 42, .32), 0 2px 6px -2px rgba(44, 46, 42, .08);
  --shadow-soft: 0 8px 22px -14px rgba(44, 46, 42, .30);
  --spring: cubic-bezier(.34, 1.3, .64, 1); /* โลกแผนที่: ขยับแล้วเกินนิดหนึ่งก่อนหยุด (เบาลงสำหรับงานหลังบ้าน) */
  --out: cubic-bezier(.16, 1, .3, 1);
  --dur: .4s;
  --topbar: 64px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Sarabun', 'Leelawadee UI', 'Tahoma', sans-serif;
  font-size: 17px;
  line-height: 1.7;
  color: var(--ink);
  background: var(--ground);
  caret-color: var(--school);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--sun); color: var(--ink); }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--school); text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
a:hover { color: var(--ink); }
h1, h2, h3, h4 { line-height: 1.3; margin: 0; font-weight: 700; letter-spacing: 0; text-wrap: balance; }
p { margin: 0; }
.nw { white-space: nowrap; }            /* กันชื่อ/คำประสมขาดกลางบรรทัด */
.num, .money, td.n { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.small { font-size: 15px; }
.tiny { font-size: 13.5px; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; border-radius: 10px; }

* { scrollbar-width: thin; scrollbar-color: #C9C2AC transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #C9C2AC; border-radius: 99px; border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

svg.ic { display: inline-block; vertical-align: -4px; }
.ic { width: 22px; height: 22px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic-sm { width: 18px; height: 18px; }
.ic-lg { width: 28px; height: 28px; }

/* ---------- ปุ่มแคปซูล ---------- */
.btn {
  --bg: var(--paper); --fg: var(--ink); --bd: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 0 22px; border-radius: var(--r-cap);
  background: var(--bg); color: var(--fg); border: 2px solid var(--bd);
  font-weight: 600; font-size: 16.5px; line-height: 1.2; text-decoration: none; cursor: pointer;
  transition: transform .18s var(--out), background-color .18s, box-shadow .18s;
  -webkit-tap-highlight-color: transparent; user-select: none; white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-soft); }
.btn:active { transform: translateY(1px) scale(.98); box-shadow: none; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn .chip {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: var(--ink); color: var(--paper); margin-right: -14px; transition: transform var(--dur) var(--spring);
}
.btn:hover .chip { transform: translateX(3px); }
.btn .chip .ic { width: 18px; height: 18px; }
.btn-go { --bg: var(--land); --bd: var(--land); }
.btn-school { --bg: var(--school); --fg: var(--school-ink); --bd: var(--school); }
.btn-school .chip { background: var(--paper); color: var(--school); }
.btn-sun { --bg: var(--sun); --bd: var(--sun); }
.btn-line { --bg: transparent; }
.btn-danger { --bg: var(--paper); --fg: var(--coral-ink); --bd: var(--coral); }
.btn-ink { --bg: var(--ink); --fg: var(--paper); --bd: var(--ink); }
.btn-ghost { --bg: transparent; --bd: transparent; padding: 0 14px; }
.btn-ghost:hover { background: rgba(44, 46, 42, .06); box-shadow: none; }
.btn-sm { min-height: 44px; padding: 0 16px; font-size: 15.5px; gap: 8px; }
.btn-block { width: 100%; }
.btn-icon { width: 48px; padding: 0; }
.btn-icon.btn-sm { width: 44px; }
.btn.is-loading { pointer-events: none; opacity: .75; }
.btn.is-loading::after { content: ''; width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ชิปกรองแบบแคปซูล */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; margin: 0 -20px; padding: 0 20px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.fchip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: var(--r-cap);
  border: 1.5px solid var(--line); background: var(--paper); color: var(--ink); font-weight: 600; font-size: 15.5px;
  cursor: pointer; white-space: nowrap; scroll-snap-align: start; transition: background-color .2s, border-color .2s, color .2s;
}
.fchip:hover { border-color: var(--ink); }
.fchip .cnt { min-width: 24px; height: 24px; padding: 0 7px; border-radius: 99px; background: var(--grey-tint); font-size: 13px; display: inline-grid; place-items: center; font-variant-numeric: tabular-nums; order: 2; }
.fchip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.fchip[aria-pressed="true"] .cnt { background: var(--sun); color: var(--ink); order: -1; }

/* ป้ายสถานะ */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 12px; min-height: 28px; border-radius: 99px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.plain::before { display: none; }
.st-ST-01, .cl-Approved, .lr-Open, .ok { background: var(--land-tint); color: var(--land-ink); }
.st-ST-02, .cl-Pending, .lr-Matched, .warn, .adj-Pending { background: var(--sun-tint); color: var(--sun-ink); }
.st-ST-03, .cl-Completed, .info { background: var(--pond-tint); color: var(--pond-ink); }
.st-ST-04, .adj-Approved { background: var(--lilac-tint); color: var(--lilac-ink); }
.st-ST-05, .cl-Cancelled, .lr-Closed, .lr-Cancelled, .grey { background: var(--grey-tint); color: var(--ink-2); }
.cl-Rejected, .bad, .adj-Rejected { background: var(--coral-tint); color: var(--coral-ink); }
.tag-money { display: inline-flex; align-items: center; gap: 6px; background: var(--coral); color: var(--ink); font-weight: 700; font-size: 13.5px; padding: 2px 12px; border-radius: 99px; }

/* ---------- ช่องกรอก ---------- */
.field { display: grid; gap: 6px; }
.field > label, .field > .lbl { font-weight: 600; font-size: 15.5px; }
.field .hint { font-size: 14px; color: var(--ink-2); line-height: 1.5; }
.field .req { color: var(--coral-ink); }
.input, select.input, textarea.input {
  width: 100%; min-height: 48px; padding: 10px 16px; border-radius: var(--r-field);
  border: 1.5px solid #BDB5A0; background: var(--paper); color: var(--ink); line-height: 1.5;
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { min-height: 96px; resize: vertical; }
select.input { appearance: none; -webkit-appearance: none; padding-right: 44px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232C2E2A' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; background-size: 20px; }
.input::placeholder { color: #6B6E63; } /* 5.1:1 บนพื้นขาว */
.input:hover { border-color: var(--ink-3); }
.input:focus { outline: none; border-color: var(--school); box-shadow: 0 0 0 4px rgba(142, 212, 98, .45); }
.input[aria-invalid="true"] { border-color: var(--coral-ink); box-shadow: 0 0 0 4px var(--coral-tint); }
.field .err { color: var(--coral-ink); font-size: 14.5px; font-weight: 600; }
.search {
  position: relative; display: flex; align-items: center;
}
.search .input { border-radius: var(--r-cap); padding-left: 50px; padding-right: 48px; min-height: 52px; border-width: 2px; border-color: var(--ink); }
.search > .ic { position: absolute; left: 18px; pointer-events: none; }
.search .clear { position: absolute; right: 4px; }
.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; line-height: 1.55; }
.check input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--school); flex: none; }
.grid-2 { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.stack { display: grid; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

/* ---------- แถบบน ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar);
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: var(--ground); border-bottom: 1.5px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand-mark { width: 44px; height: 44px; flex: none; }
.brand-txt { min-width: 0; line-height: 1.25; }
.brand-txt b { display: block; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-txt span { display: block; font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.who { display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 8px 0 6px; border-radius: 99px; background: var(--paper); border: 1.5px solid var(--line); cursor: pointer; max-width: 260px; }
.who .av { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--land); font-weight: 700; flex: none; font-size: 15px; }
.who .nm { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ==========================================================================
   หน้าสาธารณะ: แผงรายการ + แผนที่
   ========================================================================== */
.explore { position: relative; height: calc(100dvh - var(--topbar)); min-height: 520px; overflow: hidden; } /* กันแผ่นรายการที่ซ่อนอยู่ทำให้ทั้งหน้าเลื่อนได้ */
.mapwrap { position: absolute; inset: 0; overflow: hidden; background: #EEEDE5; }
.mapscroll { z-index: 1; }
.mapscroll { position: absolute; inset: 0; display: flex; overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.mapcanvas { margin: auto; flex: none; }
.mapcanvas svg { width: 100%; height: auto; }
.mapctl { position: absolute; right: 14px; top: 14px; display: grid; gap: 8px; z-index: 5; }
.mapctl .btn { background: var(--paper); box-shadow: var(--shadow-soft); }
.maphint {
  position: absolute; left: 14px; top: 14px; z-index: 5; max-width: 280px;
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px 12px 16px; border-radius: 20px;
  background: var(--sun); box-shadow: var(--shadow-soft); font-weight: 600; font-size: 15px; line-height: 1.45;
  animation: hintIn .6s var(--spring) both .3s;
}
.maphint .x { margin: -6px -8px -6px 0; }
@keyframes hintIn { from { opacity: 0; transform: translateY(-10px) scale(.96); } }

/* แผงรายการ (คอม = แผงซ้าย · มือถือ = แผ่นเลื่อนจากล่าง) */
.panel {
  position: absolute; z-index: 20; background: var(--paper); display: flex; flex-direction: column;
}
.panel-head { padding: 18px 20px 12px; display: grid; gap: 14px; border-bottom: 1.5px solid var(--line-soft); }
.panel-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 14px 20px 28px; }
.handle { display: none; }
.lead { font-size: 26px; line-height: 1.3; font-weight: 700; }
.lead em { font-style: normal; background: var(--sun); padding: 0 8px; border-radius: 10px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }

@media (min-width: 900px) {
  .panel { top: 16px; bottom: 16px; left: 16px; width: 440px; border-radius: var(--r-panel); box-shadow: var(--shadow); }
  .mapwrap { left: 470px; }
  .maphint { left: 14px; }
}
@media (min-width: 1280px) { .panel { width: 480px; } .mapwrap { left: 510px; } }

@media (max-width: 899.98px) {
  .panel {
    left: 0; right: 0; bottom: 0; height: calc(100dvh - var(--topbar) - 8px);
    border-radius: 26px 26px 0 0; box-shadow: 0 -10px 30px -16px rgba(44, 46, 42, .4);
    transform: translateY(calc(100% - var(--peek, 168px)));
    transition: transform var(--dur) var(--spring);
    will-change: transform;
  }
  .panel[data-state="half"] { transform: translateY(46%); }
  .panel[data-state="full"] { transform: translateY(0); }
  .panel.dragging { transition: none; }
  .handle { display: grid; place-items: center; height: 26px; margin: -10px -20px -6px; cursor: grab; touch-action: none; background: transparent; border: 0; width: calc(100% + 40px); }
  .handle::before { content: ''; width: 48px; height: 5px; border-radius: 9px; background: #C9C2AC; }
  .panel-head { padding-top: 14px; }
  .lead { font-size: 21px; }
  .mapscroll { padding-bottom: 190px; }
  .maphint { right: 14px; max-width: none; }
  .mapctl { top: auto; bottom: calc(var(--peek, 168px) + 14px); }
  .panel[data-state="peek"] .lead { display: none; }
  .panel { --peek: 176px; }
  .mapctl { --peek: 176px; }
  .hide-sm { display: none; }
}
@media (max-width: 479.98px) { .who { max-width: 150px; } .topbar { gap: 8px; padding: 0 12px; } }
@media (prefers-reduced-motion: reduce) {
  .panel, .btn .chip, .maphint, .modal-card, .toast { transition: none !important; animation: none !important; }
}

/* ขั้นตอนนำทาง 1-2-3 */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; counter-reset: s; list-style: none; margin: 0; padding: 0; }
.step { position: relative; padding: 10px 10px 10px 12px; border-radius: 16px; background: var(--ground); font-size: 14px; line-height: 1.4; }
.step b { display: block; font-size: 15px; }
.step::before { counter-increment: s; content: counter(s); position: absolute; top: -9px; right: 8px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; background: var(--ink); color: var(--paper); }
.step:nth-child(2) { background: var(--sun-tint); }
.step:nth-child(3) { background: var(--land-tint); }

.zonebar { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; border-radius: 16px; background: var(--ink); color: var(--paper); }
.zonebar .ic { color: var(--sun); }
.zonebar b { flex: 1; font-size: 15.5px; line-height: 1.35; }
.zonebar .btn { --bg: transparent; --fg: var(--paper); --bd: rgba(255,255,255,.4); }

.resultmeta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 0 10px; font-size: 15px; color: var(--ink-2); }

/* การ์ดรายการ (รูปตัดเป็นก้อนแบบเกาะบนแผนที่) */
.items { display: grid; gap: 12px; }
.itemcard {
  display: grid; grid-template-columns: 92px 1fr; gap: 14px; align-items: start; padding: 12px; border-radius: 22px;
  border: 1.5px solid var(--line-soft); background: var(--paper); cursor: pointer; text-align: left; width: 100%;
  transition: border-color .2s, transform .25s var(--out), box-shadow .25s;
}
.itemcard:hover { border-color: var(--ink); box-shadow: var(--shadow-soft); transform: translateY(-2px); }
.itemcard .thumb { width: 92px; height: 92px; border-radius: 40% 60% 55% 45% / 50% 45% 55% 50%; overflow: hidden; background: var(--land-tint); display: grid; place-items: center; color: var(--land-ink); }
.itemcard .thumb.money { background: var(--coral-tint); color: var(--coral-ink); border-radius: 55% 45% 40% 60% / 45% 55% 45% 55%; }
.itemcard .thumb img { width: 100%; height: 100%; object-fit: cover; }
.itemcard .thumb .ic { width: 38px; height: 38px; stroke-width: 1.6; }
.itemcard .ttl { display: block; font-weight: 700; font-size: 17.5px; line-height: 1.4; margin: 2px 0 4px; overflow-wrap: anywhere; }
.itemcard > span:last-child { min-width: 0; display: block; }
.itemcard .meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 14px; color: var(--ink-2); line-height: 1.5; }
.itemcard .meta span { display: inline-flex; align-items: center; gap: 4px; }
.itemcard .meta .ic { width: 16px; height: 16px; }
.code { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 13.5px; letter-spacing: .02em; color: var(--ink-2); white-space: nowrap; }

.empty { text-align: center; padding: 28px 18px; display: grid; gap: 10px; justify-items: center; color: var(--ink-2); }
.empty .blob { width: 88px; height: 88px; border-radius: 45% 55% 60% 40% / 55% 45% 55% 45%; background: var(--land-tint); display: grid; place-items: center; color: var(--land-ink); }
.empty .blob .ic { width: 40px; height: 40px; stroke-width: 1.6; }
.empty h4 { color: var(--ink); font-size: 18px; }

.skel { height: 116px; border-radius: 22px; background: var(--line-soft); animation: sk 1.1s ease-in-out infinite alternate; }
.skel + .skel { margin-top: 12px; }
@keyframes sk { from { opacity: 1; } to { opacity: .45; } }

.pager { display: flex; justify-content: center; gap: 8px; margin-top: 16px; }
.officecard { margin-top: 22px; padding: 18px; border-radius: 22px; background: var(--ground); display: grid; gap: 10px; }
.officecard h4 { font-size: 17px; display: flex; gap: 8px; align-items: center; }
.footer-credit { margin-top: 18px; font-size: 13px; line-height: 1.6; color: var(--ink-2); }
.footer-credit b { color: var(--ink); }

/* ---------- แผนที่ 3 มิติ (SVG) ---------- */
.campus3d { font-family: 'Sarabun', sans-serif; user-select: none; -webkit-user-select: none; display: block; }
.campus3d .g-bg { fill: #EEEDE5; }
.campus3d .g-north { fill: #DCEFD3; }
.campus3d .g-major { fill: #FFE2A0; stroke: #E9B864; stroke-width: 1.5; }
.campus3d .g-minor { fill: #FFFFFF; stroke: #DDD7C8; stroke-width: 1.2; }
.campus3d .g-canal { fill: #9FD3F2; }
.campus3d .g-campus { fill: #D9EFCF; stroke: #2E9A4E; stroke-width: 2.4; stroke-dasharray: 9 7; stroke-linejoin: round; }
.campus3d .g-inner { fill: #FBFAF4; }
.campus3d .g-dash { fill: none; stroke: #FFFFFF; stroke-width: 1.6; stroke-dasharray: 10 10; }
.campus3d .g-pond { fill: #9FD3F2; stroke: #6FB8E3; stroke-width: 1.2; }
.campus3d .g-track { fill: #E8866A; }
.campus3d .g-infield { fill: #9AD483; }
.campus3d .g-pitch { fill: #86CB70; stroke: #FFFFFF; stroke-width: 1.6; }
.campus3d .g-line { fill: none; stroke: #FFFFFF; stroke-width: 1.4; }
.campus3d .g-rows { fill: none; stroke: #8FC46A; stroke-width: 1.2; }
.campus3d .shadows { fill: #24402C; opacity: .17; filter: url(#lfBlur); }
.campus3d .face, .campus3d .roof { stroke: rgba(44, 46, 42, .22); stroke-width: .8; stroke-linejoin: round; }
.campus3d .b { transition: opacity .25s; }
.campus3d .zb, .campus3d .zone-ground, .campus3d .hits polygon, .campus3d .lab { cursor: pointer; }
.campus3d .hits polygon { fill: transparent; }
.campus3d .tree .t-sh { fill: #24402C; opacity: .14; }
.campus3d .tree .t1 { fill: #6DBE68; }
.campus3d .tree .t2 { fill: #9FDB8C; }
.campus3d.has-sel .b:not(.sel), .campus3d.has-sel .tree { opacity: .5; }
.campus3d.has-sel .zone-ground:not(.sel) { opacity: .6; }
.campus3d .zone-ground.sel .g-track { fill: #FFD23F; }
.campus3d .zone-ground.sel .g-pond { fill: #FFD23F; stroke: #2C2E2A; }
.campus3d .b.sel .roof, .campus3d .b.sel .face { stroke: #2C2E2A; stroke-width: 1.6; }
.campus3d .lab .pill { fill: #FFFFFF; stroke: rgba(44, 46, 42, .18); stroke-width: 1; filter: drop-shadow(0 3px 5px rgba(36, 64, 44, .22)); }
.campus3d .lab .lab-t { font-weight: 700; fill: #2C2E2A; }
.campus3d .lab .lead { stroke: #2C2E2A; stroke-width: 1.2; opacity: .55; }
.campus3d .lab .lead-dot { fill: #2C2E2A; }
.campus3d .lab .cnt { fill: #FFD23F; stroke: #2C2E2A; stroke-width: 1.2; }
.campus3d .lab .cnt-t { font-weight: 700; fill: #2C2E2A; font-variant-numeric: tabular-nums; }
.campus3d .lab.gate .pill { fill: #FFD23F; stroke: #2C2E2A; }
.campus3d .lab .pin { fill: #0B6845; stroke: #FFFFFF; stroke-width: 1.6; filter: drop-shadow(0 3px 4px rgba(5, 46, 22, .35)); }
.campus3d .lab .pin-dot { fill: #FFFFFF; }
.campus3d .lab.sel .pill { fill: #2C2E2A; stroke: #2C2E2A; }
.campus3d .lab.sel .lab-t { fill: #FFFFFF; }
.campus3d .lab:focus-visible { outline: none; }
.campus3d .nb { pointer-events: none; }
.campus3d .nb circle { fill: #FFFFFF; stroke: #2C2E2A; stroke-width: 1; opacity: .92; }
.campus3d .nb text { font-weight: 700; fill: #2C2E2A; font-variant-numeric: tabular-nums; }
.campus3d .nb.sel circle { fill: #2C2E2A; }
.campus3d .nb.sel text { fill: #FFFFFF; }
.campus3d.has-sel .nb:not(.sel) { opacity: .45; }
/* ดัชนีสถานที่ตามแผนผัง */
.placeidx { margin-top: 18px; border-radius: 20px; background: var(--ground); }
.placeidx > summary { cursor: pointer; min-height: 52px; display: flex; align-items: center; gap: 10px; padding: 0 16px; font-weight: 700; list-style: none; }
.placeidx > summary::-webkit-details-marker { display: none; }
.placeidx > summary .ic:last-child { margin-left: auto; transition: transform .2s; }
.placeidx[open] > summary .ic:last-child { transform: rotate(180deg); }
.placeidx ol { list-style: none; margin: 0; padding: 0 10px 12px; display: grid; gap: 4px; }
.placeidx .pl { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 10px; align-items: center; width: 100%; min-height: 44px; padding: 6px 8px; border-radius: 14px; border: 0; background: transparent; text-align: left; font: inherit; color: var(--ink); }
.placeidx button.pl { cursor: pointer; }
.placeidx button.pl:hover { background: var(--paper); }
.placeidx .pl .no { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--ink); background: var(--paper); font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.placeidx .pl .zn { display: block; font-size: 13px; color: var(--ink-2); }
.placeidx .pl.nozone { color: var(--ink-2); }
.campus3d .lab:focus-visible .pill { stroke: #0B6845; stroke-width: 3; }
.campus3d .decor { pointer-events: none; }
.campus3d .roadname { font-weight: 600; fill: #8A6A2E; letter-spacing: .02em; }
.campus3d .canalname { font-weight: 600; fill: #1F6FA8; }
.campus3d .credit { fill: #6E7166; }
.campus3d .compass circle { fill: #FFFFFF; stroke: #2C2E2A; stroke-width: 1.5; }
.campus3d .compass path { fill: #E5484D; }
.campus3d .compass text { font-weight: 700; fill: #2C2E2A; }
@media (prefers-reduced-motion: reduce) { .campus3d .b { transition: none; } }

/* ---------- หน้าต่างซ้อน ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal-bg { position: absolute; inset: 0; background: rgba(44, 46, 42, .52); animation: fadeIn .25s both; }
.modal-card {
  position: relative; width: 100%; max-width: 640px; max-height: calc(100dvh - 40px); overflow: auto; overscroll-behavior: contain;
  background: var(--paper); border-radius: var(--r-panel); box-shadow: var(--shadow); animation: popIn var(--dur) var(--spring) both;
}
.modal-card.wide { max-width: 980px; }
.modal-card.narrow { max-width: 460px; }
.modal-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 12px; padding: 16px 16px 12px 24px; background: var(--paper); border-bottom: 1.5px solid var(--line-soft); }
.modal-head h2 { font-size: 21px; flex: 1; line-height: 1.35; }
.modal-body { padding: 20px 24px 24px; display: grid; gap: 18px; }
.modal-foot { position: sticky; bottom: 0; display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; padding: 14px 24px; background: var(--paper); border-top: 1.5px solid var(--line-soft); }
.modal-foot .left { margin-right: auto; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: translateY(24px) scale(.97); } }
@media (max-width: 639.98px) {
  .modal { padding: 0; place-items: end stretch; }
  .modal-card, .modal-card.narrow, .modal-card.wide { max-width: none; max-height: 94dvh; border-radius: 26px 26px 0 0; animation-name: sheetIn; }
  .modal-body { padding: 18px 18px 22px; }
  .modal-head { padding-left: 18px; }
  .modal-foot { padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; }
}
@keyframes sheetIn { from { transform: translateY(100%); } }
body.modal-open { overflow: hidden; }

/* รายละเอียดสิ่งของ */
.gallery { display: grid; grid-auto-flow: column; grid-auto-columns: 82%; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; border-radius: 22px; }
.gallery img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 22px; scroll-snap-align: start; background: var(--ground); }
.gallery.one { grid-auto-columns: 100%; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.fact { padding: 12px 14px; border-radius: 16px; background: var(--ground); line-height: 1.45; }
.fact .k { display: block; font-size: 13.5px; color: var(--ink-2); font-weight: 600; }
.fact .v { font-weight: 600; overflow-wrap: anywhere; }
.fact.full { grid-column: 1 / -1; }
.secret { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 18px; background: var(--coral-tint); color: var(--coral-ink); font-weight: 600; line-height: 1.5; }
.note { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 18px; background: var(--sun-tint); color: var(--sun-ink); line-height: 1.55; }
.note.green { background: var(--land-tint); color: var(--land-ink); }
.note.blue { background: var(--pond-tint); color: var(--pond-ink); }
.note b { color: inherit; }
.bigcode { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.minimap { border-radius: 20px; overflow: hidden; background: #EEEDE5; }
.minimap svg { width: 100%; height: auto; }

/* ไทม์ไลน์สถานะคำร้อง */
.timeline { display: grid; gap: 0; margin: 4px 0; }
.tl { display: grid; grid-template-columns: 28px 1fr; gap: 12px; position: relative; padding-bottom: 14px; }
.tl::before { content: ''; position: absolute; left: 13px; top: 26px; bottom: 0; width: 2px; background: var(--line); }
.tl:last-child::before { display: none; }
.tl .dot { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); background: var(--paper); display: grid; place-items: center; }
.tl.done .dot { background: var(--land); border-color: var(--land); }
.tl.now .dot { background: var(--sun); border-color: var(--ink); }
.tl.fail .dot { background: var(--coral); border-color: var(--coral); }
.tl .dot .ic { width: 16px; height: 16px; stroke-width: 3; }
.tl b { display: block; line-height: 1.4; }
.tl span { font-size: 14px; color: var(--ink-2); }

/* ---------- แจ้งเตือนลอย ---------- */
.toasts { position: fixed; z-index: 200; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 10px; width: min(560px, calc(100% - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 20px; background: var(--ink); color: var(--paper); box-shadow: var(--shadow); font-weight: 600; line-height: 1.5; animation: popIn var(--dur) var(--spring) both; }
.toast.ok .ic { color: var(--land); }
.toast.err { background: var(--coral-ink); }
.toast.err .ic { color: var(--sun); }
.toast .x { margin-left: auto; color: inherit; }

.updatebar { position: fixed; z-index: 300; left: 50%; top: 10px; transform: translateX(-50%); display: flex; gap: 12px; align-items: center; padding: 8px 8px 8px 18px; border-radius: 99px; background: var(--sun); box-shadow: var(--shadow); font-weight: 700; border: 2px solid var(--ink); max-width: calc(100% - 20px); }
.netbar { position: fixed; z-index: 290; left: 0; right: 0; bottom: 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--coral-ink); color: var(--paper); font-weight: 600; text-align: center; }

/* ==========================================================================
   หลังบ้าน (เจ้าหน้าที่ / ผู้ดูแล)
   ========================================================================== */
.bo { min-height: 100dvh; }
.nav { position: sticky; top: var(--topbar); z-index: 30; background: var(--ground); border-bottom: 1.5px solid var(--line-soft); }
.nav-in { display: flex; gap: 6px; overflow-x: auto; padding: 8px 16px; max-width: 1360px; margin: 0 auto; scrollbar-width: none; }
.nav-in::-webkit-scrollbar { display: none; }
.navbtn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 99px; border: 0; background: transparent; font-weight: 600; font-size: 15.5px; white-space: nowrap; cursor: pointer; color: var(--ink-2); }
.navbtn:hover { background: rgba(44, 46, 42, .06); color: var(--ink); }
.navbtn[aria-current="page"] { background: var(--ink); color: var(--paper); }
.navbtn .cnt { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px; background: var(--sun); color: var(--ink); font-size: 12.5px; display: inline-grid; place-items: center; }
.page { max-width: 1360px; margin: 0 auto; padding: 22px 16px 60px; display: grid; gap: 20px; }
.page-head { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.page-head h1 { font-size: 28px; }
.page-head p { color: var(--ink-2); }
.page-head .actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }
.card { background: var(--paper); border-radius: var(--r-panel); padding: 20px; box-shadow: var(--shadow-soft); }
.card h2 { font-size: 20px; margin-bottom: 12px; }
.card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2 { margin: 0; flex: 1; }

/* แดชบอร์ด: ก้อนพื้นที่ความเร่งด่วน (ขนาดเป็นขั้นตายตัว) */
.dash { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 1000px) { .dash { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); } }
.lobes { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.lobe {
  position: relative; display: grid; align-content: space-between; gap: 6px; min-height: 132px; padding: 18px 20px; text-align: left;
  border: 0; cursor: pointer; color: var(--ink); background: var(--paper); border-radius: 46% 54% 40% 60% / 18% 22% 20% 24%;
  box-shadow: var(--shadow-soft); transition: transform .3s var(--spring);
}
.lobe:hover { transform: translateY(-3px) rotate(-.4deg); }
.lobe .n { font-size: 44px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.lobe .t { font-weight: 600; line-height: 1.35; }
.lobe .s { font-size: 14px; color: inherit; opacity: .85; }
.lobe.l1 { grid-column: 1 / -1; min-height: 168px; background: var(--sun); }
.lobe.l1 .n { font-size: 64px; }
.lobe.green { background: var(--land); }
.lobe.coral { background: var(--coral); }
.lobe.pond { background: var(--pond); }
.lobe.lilac { background: var(--lilac); }
.lobe.ink { background: var(--ink); color: var(--paper); }
.queue { display: grid; gap: 8px; }
.qrow { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 16px; background: var(--ground); cursor: pointer; border: 0; text-align: left; width: 100%; }
.qrow:hover { background: var(--sun-tint); }

/* ตาราง */
.tablewrap { overflow-x: auto; border-radius: 18px; border: 1.5px solid var(--line-soft); background: var(--paper); }
table.t { width: 100%; border-collapse: collapse; font-size: 15.5px; line-height: 1.5; }
.t th { text-align: left; font-weight: 700; font-size: 14px; color: var(--ink-2); background: var(--ground); padding: 10px 12px; white-space: nowrap; position: sticky; top: 0; }
.t td { padding: 11px 12px; border-top: 1.5px solid var(--line-soft); vertical-align: top; }
.t tr.click { cursor: pointer; }
.t tr.click:hover td { background: #FBF9F2; }
.t td.n, .t th.n { text-align: right; white-space: nowrap; }
.t .pos { color: var(--land-ink); font-weight: 700; }
.t .neg { color: var(--coral-ink); font-weight: 700; }
.t tfoot td { font-weight: 700; background: var(--ground); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.toolbar .field { min-width: 160px; }
.toolbar .grow { flex: 1; min-width: 220px; }
@media (max-width: 719.98px) {
  table.t.cards thead { display: none; }
  table.t.cards, .t.cards tbody, .t.cards tr, .t.cards td { display: block; width: 100%; }
  .t.cards tr { padding: 10px 14px; border-top: 1.5px solid var(--line-soft); }
  .t.cards td { border: 0; padding: 3px 0; }
  .t.cards td[data-k]::before { content: attr(data-k) ' · '; color: var(--ink-2); font-size: 13.5px; font-weight: 600; }
  .t.cards td.n { text-align: left; }
}

/* เทียบหลักฐาน 2 ฝั่ง */
.compare { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .compare { grid-template-columns: 1fr 1fr; } }
.side { padding: 16px 18px; border-radius: 22px; display: grid; gap: 10px; align-content: start; }
.side.claimant { background: var(--pond-tint); }
.side.record { background: var(--ground); border: 2px dashed var(--coral); }
.side h3 { font-size: 17px; display: flex; gap: 8px; align-items: center; }
.side dl { margin: 0; display: grid; gap: 8px; }
.side dt { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.side dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; white-space: pre-line; }
.match { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-radius: 18px; font-weight: 700; }
.match.yes { background: var(--land-tint); color: var(--land-ink); }
.match.no { background: var(--coral); color: var(--ink); }
.danger-zone { margin-top: 8px; padding-top: 18px; border-top: 1.5px dashed var(--line); }

/* ช่องเซ็นชื่อ */
.sigpad { position: relative; border-radius: 18px; border: 2px dashed #BDB5A0; background: #FFFEF9; touch-action: none; }
.sigpad canvas { display: block; width: 100%; height: 180px; border-radius: 16px; }
.sigpad .ph { position: absolute; inset: 0; display: grid; place-items: center; color: #8F8A78; pointer-events: none; font-weight: 600; }
.sigpad .base { position: absolute; left: 24px; right: 24px; bottom: 42px; border-bottom: 1.5px solid #CFC8B2; pointer-events: none; }

/* อัปโหลดรูป + ปิดทับข้อมูลส่วนตัว */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.thumbs .t1 { position: relative; aspect-ratio: 1; border-radius: 18px; overflow: hidden; background: var(--ground); }
.thumbs .t1 img { width: 100%; height: 100%; object-fit: cover; }
.thumbs .t1 .btn { position: absolute; top: 6px; right: 6px; background: var(--paper); }
.redact { position: relative; border-radius: 18px; overflow: hidden; background: #222; touch-action: none; }
.redact canvas { display: block; width: 100%; height: auto; cursor: crosshair; }

/* ใบรายงาน */
.sumgrid { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 900px) { .sumgrid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.sum { padding: 14px 16px; border-radius: 20px; background: var(--ground); display: grid; gap: 2px; }
.sum .k { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.sum .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sum.big { background: var(--ink); color: var(--paper); }
.sum.big .k { color: #D9D6CC; }
.sum.green { background: var(--land-tint); }
.sum.coral { background: var(--coral-tint); }
.formula { font-size: 14.5px; color: var(--ink-2); }
.print-only { display: none; }

/* หน้าเข้าสู่ระบบ */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; position: relative; overflow: hidden; }
.login .blob { position: absolute; z-index: 0; }
.login .card { position: relative; z-index: 1; width: 100%; max-width: 440px; padding: 28px; display: grid; gap: 18px; box-shadow: var(--shadow); }
.login h1 { font-size: 28px; }

/* พิมพ์ (A4) */
@media print {
  @page { size: A4; margin: 14mm 12mm; }
  body { background: #fff; font-size: 12.5pt; }
  .topbar, .nav, .no-print, .toasts, .updatebar, .netbar, .modal { display: none !important; }
  .page { padding: 0; max-width: none; }
  .card { box-shadow: none; padding: 0; }
  .tablewrap { border: 0; overflow: visible; }
  .t th { position: static; background: #f1f1f1; }
  .t td, .t th { padding: 5px 6px; }
  .t tr { break-inside: avoid; }
  .print-only { display: block; }
  .sum { border: 1px solid #ccc; }
  .sum.big { background: #fff; color: #000; }
  .sum.big .k { color: #333; }
  a { color: #000; text-decoration: none; }
  .poster { break-after: page; border: 2px solid #000; }
  body:not(.print-poster) #printArea { display: none !important; }
  body.print-poster > *:not(#printArea) { display: none !important; }
  body.print-poster #printArea { display: block !important; }
  body.print-report .page > :not(#repOut) { display: none !important; }
  .lobe, .sum { box-shadow: none; }
}

/* ใบประกาศพิมพ์ติดบอร์ด */
.poster { max-width: 720px; margin: 0 auto; padding: 28px; border-radius: 28px; background: var(--paper); display: grid; gap: 16px; }
.poster .ph1 { font-size: 34px; font-weight: 700; line-height: 1.25; }
.poster .qr { width: 220px; height: 220px; }
.poster .bar { display: flex; gap: 18px; align-items: center; }

/* ===== กันแอบอ้าง (รุ่น 2.1) ===== */
.secretbox { padding: 16px; border-radius: 20px; border: 2px dashed var(--coral); background: var(--paper); }
.qedit { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; }
@media (max-width: 639.98px) { .qedit { grid-template-columns: minmax(0, 1fr) auto; } .qedit [data-a] { grid-column: 1; } .qedit [data-qdel] { grid-row: 1 / span 2; grid-column: 2; } }
.qlist { margin: 0; padding-left: 22px; display: grid; gap: 4px; }
.thumbs .t1 .vis { position: absolute; left: 6px; bottom: 6px; display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 12.5px; font-weight: 700; background: var(--ink); color: var(--paper); }
.thumbs .t1 .vis.pub { background: var(--sun); color: var(--ink); }
.thumbs .t1 .vis-t { right: auto; left: 6px; }
.visset { border: 0; padding: 0; margin: 0; display: grid; gap: 10px; }
.visset legend { margin-bottom: 4px; }
.risk { display: grid; gap: 8px; padding: 14px 16px; border-radius: 20px; border: 2px solid var(--line); background: var(--paper); }
.risk.high { border-color: var(--coral); }
.risk.medium { border-color: var(--sun); }
.risk ul { margin: 0; padding-left: 22px; display: grid; gap: 2px; }
.risk ul.good { color: var(--land-ink); }
.qa { display: grid; gap: 8px; padding: 12px 14px; border-radius: 18px; background: var(--ground); }
.qa-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.qa-grid .k { display: block; font-size: 13px; color: var(--ink-2); }
.qa-grid b { word-break: break-word; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.segopt { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 99px; border: 1.5px solid var(--line); background: var(--paper); font-weight: 600; cursor: pointer; }
.segopt input { width: 20px; height: 20px; margin: 0; accent-color: var(--ink); }
.segopt.match:has(input:checked) { background: var(--land-tint); border-color: var(--land-ink); color: var(--land-ink); }
.segopt.partial:has(input:checked) { background: var(--pond-tint); border-color: var(--pond-ink); color: var(--pond-ink); }
.segopt.nomatch:has(input:checked) { background: var(--coral-tint); border-color: var(--coral-ink); color: var(--coral-ink); }
.checks { border: 0; padding: 0; margin: 0; display: grid; gap: 10px; }
.pill.plain { display: inline-block; margin-left: 4px; padding: 0 8px; border-radius: 99px; font-size: 12.5px; font-weight: 700; }
.declare { padding: 14px 16px; border-radius: 18px; background: var(--coral-tint); color: var(--coral-ink); font-weight: 600; }
.incident .inc { width: 100%; border-collapse: collapse; }
.incident .inc th, .incident .inc td { border: 1px solid #999; padding: 8px 10px; text-align: left; vertical-align: top; }
.incident .inc th { width: 160px; background: #f3f3f3; }
.incident .signs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 28px; text-align: center; line-height: 2; }
