/* ระบบแผนที่สถานการณ์ จังหวัดนราธิวาส
   Palette: the source briefing sheet's own codes — ระดับ 1 ส้ม / 2 เหลือง / 3 เขียว
   on a slate command-room ground. */
:root {
  --bg: #eef1f6;
  --surface: #ffffff;
  --surface-alt: #f7f9fc;
  --surface-strong: #eef2f8;
  --border: #d9e0ea;
  --border-strong: #bcc7d6;
  --ink: #16202e;
  --ink-2: #3a4a5f;
  --muted: #6b7c92;
  --light: #97a4b5;
  --navy: #143a63;
  --navy-600: #1b4e85;
  --navy-300: #6b93c0;
  --accent: #0f6fc4;
  --danger: #c0392b;
  --ok: #1f8a4c;
  --lv1: #f08a2e;   /* หมู่บ้านระดับ 1 */
  --lv2: #f2d024;   /* หมู่บ้านระดับ 2 */
  --lv3: #29a355;   /* หมู่บ้านระดับ 3 */
  --shadow-sm: 0 1px 2px rgba(16,32,46,.07);
  --shadow: 0 2px 6px rgba(16,32,46,.10), 0 10px 30px -18px rgba(16,32,46,.4);
  --radius: 10px;
  --font: "IBM Plex Sans Thai","IBM Plex Sans",-apple-system,"Segoe UI",sans-serif;
  --mono: "IBM Plex Mono",ui-monospace,Menlo,monospace;
  --header-h: 54px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
#root { height: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }

/* ------------------------------------------------------------ login
   The page's subject IS a map, so the province's own outline carries the
   design instead of a stock gradient + white card. Palette: night command
   room (ink) + brass chart ink (amber). */
.login-wrap {
  min-height: 100%;
  background:
    radial-gradient(900px 620px at 22% 38%, #12314f 0%, transparent 70%),
    radial-gradient(1100px 700px at 78% 12%, #10324f 0%, transparent 62%),
    linear-gradient(160deg, #0a1b2c 0%, #071320 55%, #050e18 100%);
  /* fixed + safe centring: the app's light --bg used to show below the card on
     short screens, and plain `center` clips the top once content overflows */
  position: fixed; inset: 0; overflow-y: auto; overscroll-behavior: contain;
  display: grid; place-items: safe center; padding: 32px 24px;
}
.login-grid {
  width: min(1120px, 100%);
  display: grid; grid-template-columns: 1fr 400px; gap: 64px; align-items: center;
}

/* ---- left: the province as the hero ---- */
.login-hero { min-width: 0; color: #dce9f7; }
.eyebrow {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  letter-spacing: 2.6px; color: #e8b04b; margin-bottom: 14px;
}
.login-hero h1 {
  margin: 0 0 14px; font-size: clamp(30px, 4.4vw, 46px); font-weight: 700;
  line-height: 1.12; letter-spacing: -.6px; color: #f2f7fd; text-wrap: balance;
}
.hero-sub {
  margin: 0 0 30px; max-width: 46ch; font-size: 14.5px; line-height: 1.75; color: #8ba6c4;
}
.login-art { position: relative; }
.art-frame {
  position: relative; width: min(430px, 96%); aspect-ratio: 1; padding: 16px;
}
.art-map {
  width: 100%; height: 100%; display: block; color: #e8b04b;
  filter: drop-shadow(0 0 22px rgba(232, 176, 75, .22));
  animation: art-in .9s cubic-bezier(.2, .7, .3, 1) both;
}
/* corner ticks — chart furniture, not decoration for its own sake */
.tick { position: absolute; width: 13px; height: 13px; border: 1px solid rgba(232,176,75,.55); }
.tick.tl { top: 0; left: 0; border-right: 0; border-bottom: 0; }
.tick.tr { top: 0; right: 0; border-left: 0; border-bottom: 0; }
.tick.bl { bottom: 0; left: 0; border-right: 0; border-top: 0; }
.tick.br { bottom: 0; right: 0; border-left: 0; border-top: 0; }
.art-caption {
  display: flex; align-items: center; gap: 9px; margin-top: 10px;
  font-size: 12px; color: #6f8bab;
}
.art-caption .coord { font-family: var(--mono); letter-spacing: .4px; color: #8ba6c4; }
.dot-sep { opacity: .5; }
@keyframes art-in { from { opacity: 0; transform: scale(.97) translateY(6px); } to { opacity: 1; } }

/* ---- right: the sign-in panel (glass, not a white slab) ---- */
.login-panel { min-width: 0; }
.panel-inner {
  background: rgba(9, 22, 37, .78);
  border: 1px solid rgba(255, 255, 255, .10);
  border-radius: 18px; padding: 32px 30px 26px;
  box-shadow: 0 30px 70px -28px rgba(0, 0, 0, .85), inset 0 1px 0 rgba(255,255,255,.06);
  backdrop-filter: blur(8px);
}
.panel-mark {
  width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center;
  font-size: 21px; margin-bottom: 16px;
  background: linear-gradient(145deg, #1d4b77, #0f2c48);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .13);
}
.panel-inner h2 { margin: 0 0 4px; font-size: 21px; color: #f2f7fd; letter-spacing: -.2px; }
.panel-sub { margin: 0 0 22px; font-size: 13px; color: #7d99b8; }
.login-form { display: flex; flex-direction: column; gap: 13px; }
.lf { display: flex; flex-direction: column; gap: 6px; }
.lf > span { font-size: 12.5px; font-weight: 600; color: #9db6d1; }
.lf input {
  width: 100%; padding: 12px 14px; font-size: 14.5px;
  color: #eef5fc; background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .13); border-radius: 11px; outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.lf input::placeholder { color: #5e7896; }
.lf input:focus {
  border-color: #e8b04b; background: rgba(255, 255, 255, .08);
  box-shadow: 0 0 0 3px rgba(232, 176, 75, .16);
}
.login-btn {
  margin-top: 6px; display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 13px 18px; border: 0; border-radius: 11px; cursor: pointer;
  font-size: 15px; font-weight: 700; color: #15202c;
  background: linear-gradient(180deg, #f0be62, #dfa53c);
  box-shadow: 0 10px 26px -12px rgba(232, 176, 75, .8);
  transition: transform .12s, box-shadow .15s, filter .15s;
}
.login-btn:hover:not(:disabled) { filter: brightness(1.05); transform: translateY(-1px); }
.login-btn:active:not(:disabled) { transform: translateY(0); }
.login-btn:disabled { opacity: .65; cursor: progress; }
.login-btn .arr { transition: transform .15s; }
.login-btn:hover:not(:disabled) .arr { transform: translateX(3px); }
.login-btn.busy .arr { animation: arr-pulse .9s ease-in-out infinite; }
@keyframes arr-pulse { 50% { opacity: .35; } }
.login-err {
  color: #ff9b8f; font-size: 13px; min-height: 18px; line-height: 1.4;
}
.panel-foot {
  margin-top: 20px; padding-top: 15px; border-top: 1px solid rgba(255, 255, 255, .08);
  font-size: 11.5px; color: #5e7896; letter-spacing: .3px; text-align: center;
}

@media (max-width: 900px) {
  .login-wrap { padding: 26px 18px; align-items: start; }
  .login-grid { grid-template-columns: 1fr; gap: 26px; }
  /* the map stops being a column and becomes a watermark behind the copy */
  .login-grid { justify-items: center; }
  /* one column must not mean one very wide form — a 780px-wide password field
     reads as broken, not spacious */
  .login-hero, .login-panel { width: min(430px, 100%); }
  .login-hero { position: relative; text-align: center; }
  .login-art { position: absolute; inset: -14% -10% auto; z-index: 0; pointer-events: none; }
  .art-frame { width: 78%; margin: 0 auto; opacity: .16; }
  .art-caption, .tick { display: none; }
  .eyebrow, .login-hero h1, .hero-sub { position: relative; z-index: 1; }
  .hero-sub { margin: 0 auto; }
  .panel-inner { padding: 26px 22px 22px; }
}
@media (max-width: 480px) {
  .login-hero h1 { font-size: 27px; }
  .hero-sub { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  .art-map { animation: none; }
  .login-btn, .login-btn .arr { transition: none; }
}

/* ------------------------------------------------------------ shell */
.app { height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.app-header {
  height: var(--header-h); flex: 0 0 auto; display: flex; align-items: center;
  gap: 14px; padding: 0 16px; background: var(--navy); color: #fff;
  position: relative; z-index: 1400; box-shadow: 0 2px 10px rgba(0,0,0,.22);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; }
.brand .mark {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(140deg,#2f6ea8,#12395f); font-size: 16px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.22);
}
.header-nav { display: flex; gap: 2px; margin-left: 10px; }
.header-nav a {
  color: #cfe0f2; text-decoration: none; padding: 7px 12px; border-radius: 7px;
  font-size: 13.5px; font-weight: 500;
}
.header-nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.header-nav a.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.user-chip {
  display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px;
  background: rgba(255,255,255,.12); border-radius: 20px; font-size: 13px;
}
.user-chip .av {
  width: 26px; height: 26px; border-radius: 50%; background: #e0a53c; color: #22160a;
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
}
.nav-burger {
  display: none; width: 38px; height: 34px; border: 1px solid rgba(255,255,255,.3);
  background: rgba(255,255,255,.1); color: #fff; border-radius: 8px; cursor: pointer;
}
.mobile-menu {
  display: none; position: absolute; top: var(--header-h); left: 0; right: 0;
  background: var(--navy-600); padding: 8px; flex-direction: column; gap: 2px;
  box-shadow: 0 10px 26px rgba(0,0,0,.35);
}
.mobile-menu.open { display: flex; }
.mobile-menu a, .mobile-menu button {
  color: #e8f0f9; text-decoration: none; padding: 11px 14px; border-radius: 8px;
  background: none; border: 0; text-align: left; cursor: pointer; font-size: 14.5px;
}
.mobile-menu a.active, .mobile-menu a:hover, .mobile-menu button:hover { background: rgba(255,255,255,.14); }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px;
  border-radius: 8px; border: 1px solid var(--border-strong); background: #fff;
  cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--ink-2);
  box-shadow: var(--shadow-sm); white-space: nowrap;
}
.btn:hover { background: var(--surface-strong); }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-600); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; box-shadow: none; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ------------------------------------------------------------ map page */
.map-page { flex: 1 1 auto; display: grid; grid-template-columns: 1fr 380px; min-height: 0; }
.map-wrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: #aac8e0; }
.side {
  background: var(--surface); border-left: 1px solid var(--border);
  overflow-y: auto; min-height: 0; -webkit-overflow-scrolling: touch;
}
.side-head { padding: 14px 16px 10px; border-bottom: 1px solid var(--border); }
.side-head h1 { margin: 0; font-size: 17px; letter-spacing: -.2px; }
.side-head .meta { color: var(--muted); font-size: 12.5px; margin-top: 3px; }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--border); }
.stat { padding: 12px 14px; border-right: 1px solid var(--border); }
.stat:last-child { border-right: 0; }
.stat .v { font-family: var(--mono); font-size: 22px; font-weight: 600; color: var(--navy); line-height: 1.1; }
.stat .k { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.side-section { padding: 13px 16px; border-bottom: 1px solid var(--border); }
.side-section h2 {
  margin: 0 0 9px; font-size: 12px; font-weight: 700; letter-spacing: .3px;
  color: var(--muted); text-transform: uppercase;
}

/* summary tables — mirror the printed briefing sheet */
table.sheet { width: 100%; border-collapse: collapse; font-size: 12px; }
table.sheet th, table.sheet td {
  border: 1px solid var(--border); padding: 4px 6px; text-align: center;
}
table.sheet th { background: var(--surface-strong); font-weight: 600; color: var(--ink-2); }
table.sheet td.name { text-align: left; white-space: nowrap; font-weight: 500; }
table.sheet td.num, table.sheet th.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
table.sheet tfoot td { background: #fff7d6; font-weight: 700; }
table.sheet td.zero { color: var(--light); }
table.sheet .lv1 { background: rgba(240,138,46,.20); }
table.sheet .lv2 { background: rgba(242,208,36,.28); }
table.sheet .lv3 { background: rgba(41,163,85,.18); }
.table-scroll { overflow-x: auto; }

/* incident list */
.inc-list { display: flex; flex-direction: column; }
.inc-item {
  display: grid; grid-template-columns: 26px 1fr auto; gap: 9px; align-items: center;
  padding: 7px 16px; border-bottom: 1px solid var(--surface-strong); cursor: pointer;
  background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; width: 100%;
}
.inc-item:hover { background: var(--surface-alt); }
.inc-item.active { background: #e8f1fb; box-shadow: inset 3px 0 0 var(--accent); }
.inc-seq {
  font-family: var(--mono); font-size: 11.5px; font-weight: 600; color: #fff;
  background: var(--navy-300); border-radius: 5px; text-align: center; padding: 2px 0;
}
.inc-main { min-width: 0; }
.inc-title { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inc-sub { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.lv-dot { width: 11px; height: 11px; border-radius: 50%; flex: 0 0 auto; border: 1px solid rgba(0,0,0,.2); }
.lv-1 { background: var(--lv1); } .lv-2 { background: var(--lv2); } .lv-3 { background: var(--lv3); }
.lv-0 { background: #cfd8e3; }

.type-chip img { object-fit: contain; }
.sheet th img, .inc-sub img { vertical-align: middle; object-fit: contain; }
.type-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 20px;
  font-size: 11px; font-weight: 600; background: var(--surface-strong); color: var(--ink-2);
  border: 1px solid var(--border);
}

.empty { padding: 22px 16px; text-align: center; color: var(--muted); font-size: 13px; }

/* ------------------------------------------------------------ map controls */
.map-panel {
  background: rgba(255,255,255,.96); border: 1px solid var(--border-strong);
  border-radius: 9px; box-shadow: var(--shadow); overflow: hidden; max-width: 250px;
}
.mp-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; border: 0; background: transparent; cursor: pointer; padding: 7px 10px;
  font: 700 11.5px var(--font); color: var(--ink); text-align: left;
}
.mp-head:hover { background: var(--surface-strong); }
.mp-chev { color: var(--light); font-size: 10px; }
.mp-body { padding: 2px 10px 9px; }
.mp-row {
  display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-2);
  padding: 3px 0; cursor: pointer;
}
.mp-row input { margin: 0; accent-color: var(--accent); }
.mp-row .sw { width: 16px; height: 3px; border-radius: 2px; flex: 0 0 auto; }
.mp-count { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.mp-note { font-size: 11px; color: var(--muted); padding-top: 6px; border-top: 1px solid var(--border); margin-top: 6px; }

.base-switch { display: flex; flex-direction: column; gap: 3px; }
.base-opt {
  display: flex; align-items: center; gap: 7px; padding: 5px 7px; border-radius: 6px;
  cursor: pointer; font-size: 12.5px; border: 1px solid transparent; background: none; text-align: left; width: 100%;
}
.base-opt:hover { background: var(--surface-strong); }
.base-opt.active { background: #e8f1fb; border-color: #b9d5f0; font-weight: 600; color: var(--navy); }
.base-opt .ic { font-size: 14px; }

/* markers — the symbol is the sheet's own artwork; the ring encodes village level */
.inc-marker { background: none; border: 0; }
.inc-pin {
  position: relative; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; line-height: 1;
  background: rgba(255,255,255,.94);
  border: 3px solid #b9c4d2; box-shadow: 0 2px 7px rgba(0,0,0,.45);
}
.pin-sym { width: 22px; height: 22px; display: block; object-fit: contain; }
.pin-sym-none { font-size: 16px; }

/* pin palette — choose the symbol before dropping it */
.pal-grid { display: grid; grid-template-columns: 1fr; gap: 4px; }
.pal-opt {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px;
  border: 1.5px solid var(--border); border-radius: 8px; background: #fff;
  cursor: pointer; font-size: 12.5px; text-align: left; color: var(--ink-2);
}
.pal-opt:hover { background: var(--surface-strong); }
.pal-opt.armed { border-color: var(--navy); background: #e8f1fb; font-weight: 600; color: var(--navy); }
.pal-opt img { flex: 0 0 auto; }
.pal-lv-row { display: flex; gap: 5px; }
.pal-lv {
  flex: 1 1 0; display: flex; align-items: center; justify-content: center; gap: 4px;
  padding: 5px 0; border: 1.5px solid var(--border); border-radius: 8px;
  background: #fff; cursor: pointer; font-size: 12px; font-family: var(--mono);
}
.pal-lv.armed { border-color: var(--navy); background: #e8f1fb; font-weight: 700; }
.inc-pin .num {
  position: absolute; top: -7px; right: -8px; min-width: 17px; height: 17px; padding: 0 3px;
  background: #16202e; color: #fff; border: 1.5px solid #fff; border-radius: 9px;
  font: 600 10.5px var(--mono); display: grid; place-items: center;
}
.inc-marker.sel .inc-pin { outline: 3px solid var(--accent); outline-offset: 2px; }
.amp-label {
  background: none; border: 0; font: 700 12px var(--font); color: #11202f;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 5px #fff, 1px 1px 0 #fff, -1px -1px 0 #fff;
  white-space: nowrap; pointer-events: none;
}
.amp-label.on-sat { color: #fff; text-shadow: 0 0 3px #000, 0 0 4px #000, 1px 1px 2px #000; }
.new-pin-tip { font-weight: 600; }

.leaflet-container { font-family: var(--font); }
.map-tip { font-size: 12.5px; }
.leaflet-popup-content { margin: 10px 12px; font-size: 13px; }
.pop-title { font-weight: 700; margin-bottom: 4px; }
.pop-row { color: var(--ink-2); font-size: 12.5px; }
.pop-actions { display: flex; gap: 6px; margin-top: 8px; }

.crosshair { cursor: crosshair !important; }
.hint-bar {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 14px; z-index: 600;
  background: rgba(22,32,46,.9); color: #fff; padding: 7px 14px; border-radius: 20px;
  font-size: 12.5px; box-shadow: var(--shadow); pointer-events: none;
}

/* ------------------------------------------------------------ admin */
.admin-page { flex: 1 1 auto; overflow-y: auto; padding: 18px 22px 40px; min-height: 0; }
.admin-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.admin-head h1 { margin: 0; font-size: 20px; }
.admin-head .spacer { margin-left: auto; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters select, .filters input {
  padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff;
}
.filters input[type=search] { min-width: 220px; flex: 1 1 220px; }
.admin-list { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 820px; }
table.grid th, table.grid td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
table.grid th { background: var(--surface-alt); font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tr:hover td { background: var(--surface-alt); }
table.grid td.num { font-family: var(--mono); text-align: right; }
.row-actions { display: flex; gap: 6px; }

/* ------------------------------------------------------------ modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(12,22,34,.55); z-index: 2000;
  display: grid; place-items: center; padding: 20px;
}
.modal {
  background: var(--surface); border-radius: 14px; width: min(620px, 100%);
  max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 30px 70px -20px rgba(0,0,0,.6);
}
.modal.wide { width: min(880px, 100%); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 16.5px; }
.modal-close { margin-left: auto; width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: #fff; cursor: pointer; }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--border); }
/* Form fields. These live here rather than in the login block — the login
   redesign owned `.field` and deleting that block silently un-styled every
   modal in the app (labels collapsed back inline). */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 0; }
.field > label, .field-label {
  font-size: 12.5px; font-weight: 600; color: var(--ink-2); letter-spacing: .1px;
}
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; font-size: 14px;
  border: 1px solid var(--border-strong); border-radius: 9px;
  background: #fff; outline: none; color: var(--ink);
  transition: border-color .12s, box-shadow .12s;
}
.field textarea { resize: vertical; min-height: 64px; line-height: 1.55; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15, 111, 196, .14);
}
.field input::placeholder, .field textarea::placeholder { color: var(--light); }
.field .hint { font-size: 11.5px; color: var(--muted); }

/* the incident form, grouped into labelled sections */
.fset { border: 0; margin: 0 0 18px; padding: 0; }
.fset > legend, .fset-head {
  display: flex; align-items: center; gap: 8px; width: 100%;
  font-size: 11.5px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
  color: var(--muted); margin-bottom: 9px; padding: 0;
}
.fset-head::after {
  content: ''; flex: 1 1 auto; height: 1px; background: var(--border);
}
.fset-body { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fset-body .full { grid-column: 1 / -1; }
.inj-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.inj-grid .field > label { font-size: 11.5px; font-weight: 600; text-align: center; }
.inj-grid input { text-align: center; font-family: var(--mono); padding: 8px 4px; }
.coord-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; }
.coord-row input { font-family: var(--mono); font-size: 13px; }
.locnote {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--muted); background: var(--surface-alt);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
}
.locnote b { color: var(--ink-2); font-weight: 600; }
@media (max-width: 620px) {
  .fset-body { grid-template-columns: 1fr; }
  .inj-grid { grid-template-columns: repeat(3, 1fr); }
  .coord-row { grid-template-columns: 1fr 1fr; }
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.hintline { font-size: 12px; color: var(--muted); margin-top: 4px; }
.err { color: var(--danger); font-size: 13px; }

.type-picker { display: flex; flex-wrap: wrap; gap: 7px; }
.type-opt {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 9px;
  border: 1.5px solid var(--border-strong); background: #fff; cursor: pointer; font-size: 13px;
}
.type-opt.active { border-color: var(--navy); background: #e8f1fb; font-weight: 600; }
.level-picker { display: flex; gap: 7px; }
.level-opt {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 9px;
  border: 1.5px solid var(--border-strong); background: #fff; cursor: pointer; font-size: 13px;
}
.level-opt.active { border-color: var(--navy); background: #e8f1fb; font-weight: 600; }

.toast-wrap { position: fixed; right: 16px; bottom: 16px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #16202e; color: #fff; padding: 10px 15px; border-radius: 9px;
  box-shadow: var(--shadow); font-size: 13px; max-width: 340px;
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }

.spinner {
  width: 26px; height: 26px; border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay { display: grid; place-items: center; padding: 40px; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1100px) { .map-page { grid-template-columns: 1fr 330px; } }
@media (max-width: 900px) {
  .header-nav, .header-right .btn, .header-right .user-chip { display: none; }
  .nav-burger { display: block; margin-left: auto; }
  .map-page { grid-template-columns: 1fr; grid-template-rows: 56vh auto; overflow-y: auto; }
  .map-wrap { min-height: 56vh; }
  .side { border-left: 0; border-top: 1px solid var(--border); overflow: visible; }
  .app { overflow: auto; }
}
@media (max-width: 760px) {
  .modal-backdrop { padding: 0; }
  .modal { width: 100%; height: 100%; max-height: 100%; border-radius: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .admin-page { padding: 14px; }
  .stat .v { font-size: 19px; }
}

/* Clicking an อำเภอ polygon focuses the SVG path, and Chrome then draws a focus
   ring around its whole bounding box — a stray blue rectangle across the map.
   Suppress it for pointer focus only; keyboard focus still shows a ring. */
.leaflet-container path:focus:not(:focus-visible) { outline: none; }
.leaflet-container path:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
