/* ────────────────────────────────────────────────────────────────
   Village Atlas — ระบบดีไซน์ตาม DESIGN-apple.md
   สีเน้นเดียว (Action Blue) · ไทล์เต็มความกว้างสลับสว่าง/มืด
   เงาเดียวในระบบสงวนไว้ให้ภาพ/แผนที่ที่ "วางอยู่บนพื้นผิว"
   ──────────────────────────────────────────────────────────────── */

:root {
  /* colors */
  --primary: #0066cc;
  --primary-focus: #0071e3;
  --primary-on-dark: #2997ff;
  --ink: #1d1d1f;
  --body-on-dark: #ffffff;
  --body-muted: #cccccc;
  --ink-muted-80: #333333;
  --ink-muted-48: #7a7a7a;
  --divider-soft: #f0f0f0;
  --hairline: #e0e0e0;
  --canvas: #ffffff;
  --canvas-parchment: #f5f5f7;
  --surface-pearl: #fafafc;
  --surface-tile-1: #272729;
  --surface-tile-3: #252527;
  --surface-black: #000000;
  --on-primary: #ffffff;

  /* radius */
  --r-sm: 8px;
  --r-md: 11px;
  --r-lg: 18px;
  --r-pill: 9999px;

  /* spacing */
  --s-xxs: 4px;
  --s-xs: 8px;
  --s-sm: 12px;
  --s-md: 17px;
  --s-lg: 24px;
  --s-xl: 32px;
  --s-xxl: 48px;
  --s-section: 80px;

  --font-display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Noto Sans Thai', system-ui,
    sans-serif;
  --font-text: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Noto Sans Thai', system-ui,
    sans-serif;

  /* เงาเดียวของระบบ — ใช้กับสิ่งที่เป็น "ภาพวางบนพื้นผิว" เท่านั้น */
  --product-shadow: rgba(0, 0, 0, 0.22) 3px 5px 30px 0;

  --subnav-h: 52px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--subnav-h) + 16px);
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 17px;
  font-weight: 400;
  line-height: 1.47;
  letter-spacing: -0.374px;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--canvas);
  padding: var(--s-sm) var(--s-md);
}
.skip-link:focus {
  left: var(--s-sm);
  top: var(--s-sm);
}

/* ── Sub nav (frosted) ──────────────────────────────────────── */
.sub-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--subnav-h);
  background: rgba(245, 245, 247, 0.8);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.sub-nav__inner {
  max-width: 1440px;
  height: 100%;
  margin: 0 auto;
  padding: 0 var(--s-lg);
  display: flex;
  align-items: center;
  gap: var(--s-md);
}
.sub-nav__title {
  /* เดิม .sub-nav__stat เป็นตัว flex:1 ที่ดันปุ่มทางขวาไปชิดขอบ พอเอา stat ออกจึงย้ายหน้าที่นั้นมาที่หัวข้อ
     (ใส่ไว้ที่หัวข้อเพราะปุ่ม "ผู้ดูแลระบบ" ถูกซ่อนสำหรับผู้ใช้ทั่วไป จะพึ่ง margin-left:auto ที่ปุ่มแรกไม่ได้) */
  flex: 1;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  line-height: 1.19;
  letter-spacing: 0.231px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sub-nav__user {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.29;
  letter-spacing: -0.224px;
  color: var(--ink-muted-80);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--r-pill);
  background: transparent;
  font-family: inherit;
  cursor: pointer;
}
.sub-nav__user:hover {
  background: rgba(0, 0, 0, 0.04);
}
.sub-nav__user::after {
  content: '';
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 0.15s ease;
}
.sub-nav__user[aria-expanded='true']::after {
  transform: translateY(1px) rotate(-135deg);
}

/* ── เมนูผู้ใช้ (คลิกชื่อเพื่อกาง) ────────────────────────────── */
.user-menu {
  position: relative;
}
.user-menu__panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  width: 280px;
  padding: var(--s-md);
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.14);
}
.user-menu__panel[hidden] {
  display: none;
}
.user-menu__list {
  margin: 0 0 var(--s-md);
  display: grid;
  gap: 8px;
}
.user-menu__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-sm);
  font-size: 13px;
  line-height: 1.4;
}
.user-menu__row dt {
  color: var(--ink-muted-48);
  white-space: nowrap;
}
.user-menu__row dd {
  margin: 0;
  font-weight: 600;
  color: var(--ink);
  text-align: right;
  overflow-wrap: anywhere;
}
.user-menu__row dd.is-warning {
  color: #b3261e;
}
.user-menu__logout {
  width: 100%;
}
.user-menu__renew {
  width: 100%;
  margin-bottom: var(--s-xs);
}

/* ── กรอบข้อความสีเหลืองแสดงวันหมดอายุหลัง user-menu ── */
.user-expire-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  background: #fffbeb;
  color: #92400e;
  border: 1.5px solid #f59e0b;
  box-shadow: 0 1px 3px rgba(245, 158, 11, 0.2);
  transition: all 0.2s ease;
}
.user-expire-chip svg {
  flex-shrink: 0;
  color: #d97706;
}
.user-expire-chip[hidden] {
  display: none;
}
.user-expire-chip:hover {
  background: #fef3c7;
  border-color: #d97706;
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.3);
}
.user-expire-chip--trial {
  background: #fffbeb;
  color: #92400e;
  border-color: #f59e0b;
}
.user-expire-chip--expired {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #ef4444;
  box-shadow: 0 1px 3px rgba(239, 68, 68, 0.2);
}
.user-expire-chip--expired svg {
  color: #b91c1c;
}
.user-expire-chip--admin {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #3b82f6;
  box-shadow: 0 1px 3px rgba(59, 130, 246, 0.15);
}
.user-expire-chip--admin svg {
  color: #2563eb;
}

/* ── สิทธิ์การใช้งานหมดอายุ ──────────────────────────────────── */
.expired-gate {
  text-align: center;
}
.expired-gate__title {
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 1.2;
  color: #b3261e;
}
.expired-gate__lead {
  margin: var(--s-md) auto var(--s-lg);
  max-width: 52ch;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink-muted-80);
}

/* ── popup ต่ออายุ ───────────────────────────────────────────── */
.renew-dialog {
  width: min(520px, calc(100vw - 32px));
}
.renew-dialog__lead {
  margin: 0 0 var(--s-md);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-muted-80);
}
.renew-qr {
  margin: 0 0 var(--s-lg);
  text-align: center;
}
.renew-qr img {
  width: min(320px, 100%);
  height: auto;
  border-radius: var(--r-lg);
  border: 1px solid var(--hairline);
}
.renew-qr__cap {
  margin-top: var(--s-xs);
  font-size: 12px;
  color: var(--ink-muted-48);
}
.renew-dialog__sub {
  margin: 0 0 var(--s-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted-80);
}
.renew-admins {
  display: flex;
  flex-direction: column;
  gap: var(--s-sm);
}
.renew-admin {
  padding: var(--s-md);
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
}
.renew-admin__name {
  font-weight: 600;
}
.renew-admin__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-xs) var(--s-md);
  margin-top: var(--s-xs);
  font-size: 14px;
}
.renew-admin__links a {
  color: var(--primary);
}

/* ── popup ผู้ดูแลระบบ ───────────────────────────────────────── */
.admin-dialog {
  width: min(1200px, calc(100vw - 32px));
  max-width: 1200px;
  max-height: calc(100vh - 48px);
  padding: var(--s-lg);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  background: var(--canvas);
  color: var(--ink);
  overflow: auto;
  overscroll-behavior: contain;
}
.renew-dialog {
  width: min(520px, calc(100vw - 32px));
  max-width: 520px;
}
.admin-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}
.admin-dialog__head {
  position: relative;
  margin-bottom: var(--s-sm);
}
.admin-dialog__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
}
.admin-dialog__close {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink-muted-80);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.admin-dialog__close:hover {
  background: rgba(0, 0, 0, 0.06);
}
.admin-dialog__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-md);
  margin-bottom: var(--s-md);
}
.admin-dialog__status {
  margin: 0;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-muted-48);
}
.admin-stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--r-pill, 9999px);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.25;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}
.admin-stat-chip__num {
  font-weight: 700;
}
.admin-stat-chip--total {
  background: var(--canvas-parchment);
  border-color: var(--hairline);
  color: var(--ink);
}
.admin-stat-chip--pending {
  background: rgba(255, 149, 0, 0.12);
  border-color: rgba(255, 149, 0, 0.35);
  color: #b35900;
}
.admin-stat-chip--reject {
  background: rgba(255, 59, 48, 0.08);
  border-color: rgba(255, 59, 48, 0.28);
  color: #d70015;
}
.admin-stat-chip--renew {
  background: rgba(255, 59, 48, 0.09);
  border-color: rgba(255, 59, 48, 0.28);
  color: #d70015;
}
.admin-stat-chip--none {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.06);
  color: var(--ink-muted-48);
}
.admin-stat-chip__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ff9500;
  display: inline-block;
  animation: pulse-dot 1.8s infinite ease-in-out;
}
.admin-stat-chip__dot--orange {
  background: #ff9500;
}
.admin-stat-chip__dot--red {
  background: #ff3b30;
}

/* ── ฟอร์มสมัครสมาชิก (ในกล่องผู้ดูแลระบบ) ───────────────────── */
.admin-create {
  margin-bottom: var(--s-lg);
  padding: var(--s-md);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  background: rgba(0, 0, 0, 0.02);
}
.admin-create__title {
  margin: 0 0 var(--s-md);
  font-size: 16px;
  font-weight: 600;
}
.admin-create__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: var(--s-md);
}
.admin-create__actions {
  display: flex;
  align-items: center;
  gap: var(--s-sm);
  margin-top: var(--s-md);
}
.admin-create__note {
  font-size: 12px;
  color: var(--ink-muted-48);
}
.admin-create .login-input {
  height: 40px;
  padding: 0 14px;
}
.admin-create .login-input input,
.admin-create .login-input select {
  font-size: 14px;
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.admin-create .login-form__error {
  margin-top: var(--s-sm);
  text-align: left;
}
.admin-dialog__status.is-error {
  color: #b3261e;
}
.admin-table__wrap {
  overflow-x: auto;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.admin-table th,
.admin-table td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}
.admin-table th {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted-48);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.admin-table tbody tr.is-pending {
  background: rgba(255, 193, 7, 0.09);
}
.admin-table tbody tr.is-rejected {
  background: rgba(255, 59, 48, 0.06);
}
.admin-table tbody tr.is-expired {
  background: rgba(179, 38, 30, 0.07);
}
.admin-select-status {
  padding: 4px 26px 4px 10px;
  border-radius: var(--r-pill);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #ffffff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") no-repeat right 8px center;
  appearance: none;
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
}
.admin-select-status.is-approved {
  background-color: rgba(52, 199, 89, 0.12);
  color: #1b7f4b;
  border-color: rgba(52, 199, 89, 0.35);
}
.admin-select-status.is-pending {
  background-color: rgba(255, 149, 0, 0.12);
  color: #c95100;
  border-color: rgba(255, 149, 0, 0.35);
}
.admin-select-status.is-rejected {
  background-color: rgba(255, 59, 48, 0.1);
  color: #d70015;
  border-color: rgba(255, 59, 48, 0.3);
}
.admin-reject-reason-tag {
  display: block;
  font-size: 11px;
  color: #d70015;
  margin-top: 3px;
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.admin-reject-reason-tag:hover {
  text-decoration: underline;
}
.admin-user-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  padding: 4px 8px;
  margin: -4px -8px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  text-align: left;
  transition: all 0.15s ease;
}
.admin-user-btn:hover {
  background: rgba(0, 102, 204, 0.09);
  color: #0066cc;
}
.admin-user-btn__name {
  line-height: 1.35;
}
.admin-user-btn__icon {
  color: var(--ink-muted-48);
  flex-shrink: 0;
  transition: color 0.15s ease, transform 0.15s ease;
}
.admin-user-btn:hover .admin-user-btn__icon {
  color: #0066cc;
  transform: scale(1.15);
}
.admin-user__name {
  font-weight: 600;
}
.admin-user__sub,
.admin-cell__sub {
  font-size: 12px;
  color: var(--ink-muted-48);
}
.admin-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.06);
  color: var(--ink-muted-80);
}
.admin-badge--admin {
  background: rgba(0, 102, 204, 0.12);
  color: #0066cc;
}
.admin-delete {
  padding: 5px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: #d70015;
  background: rgba(255, 59, 48, 0.08);
  border: 1px solid rgba(255, 59, 48, 0.22);
  border-radius: var(--r-pill);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}
.admin-delete:hover {
  background: #ff3b30;
  color: #ffffff;
  border-color: #ff3b30;
  box-shadow: 0 2px 6px rgba(255, 59, 48, 0.25);
}
.admin-delete:active {
  transform: scale(0.96);
}

/* ── แจ้งเตือนยืนยันลบบัญชีตาม DESIGN-apple.md (Cupertino Alert Modal) ── */
.apple-alert-dialog {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: 420px;
  width: calc(100vw - 32px);
  margin: auto;
  position: fixed;
  inset: 0;
  overflow: visible;
  display: flex;
  align-items: center;
  justify-content: center;
}
.apple-alert-dialog:not([open]) {
  display: none;
}
.apple-alert-dialog#userDetailDialog {
  max-width: min(860px, calc(100vw - 32px));
  width: min(860px, calc(100vw - 32px));
}
.apple-alert-dialog#renewHistoryDialog {
  max-width: min(480px, calc(100vw - 32px));
  width: min(480px, calc(100vw - 32px));
}
.apple-alert-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: appleFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.apple-alert-dialog[open] {
  animation: appleScaleIn 0.26s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes appleFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes appleScaleIn {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(6px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}
.apple-alert {
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(30px) saturate(190%);
  -webkit-backdrop-filter: blur(30px) saturate(190%);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 22px;
  padding: 24px 22px;
  box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.32), 0 0 1px rgba(0, 0, 0, 0.15);
  text-align: center;
  color: var(--ink);
}
.apple-alert__icon-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
}
.apple-alert__icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.apple-alert__icon--danger {
  background: rgba(255, 59, 48, 0.12);
  color: #ff3b30;
}
.apple-alert__icon--warning {
  background: rgba(255, 149, 0, 0.12);
  color: #ff9500;
}
.apple-alert__input-wrap {
  margin-bottom: 18px;
}
.apple-alert__textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--hairline);
  background: var(--canvas);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  outline: none;
  resize: vertical;
  min-height: 72px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}
.apple-alert__textarea:focus {
  border-color: var(--primary-focus, #0066cc);
  box-shadow: 0 0 0 1px var(--primary-focus, #0066cc);
}
.apple-alert__title {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.4px;
  margin: 0 0 8px;
  color: #1d1d1f;
}
.apple-alert__desc {
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--ink-muted-48);
  margin: 0 0 16px;
}
.apple-alert__target {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: var(--canvas-parchment);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 10px 14px;
  margin-bottom: 20px;
}
.apple-alert__avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #e8e8ed;
  color: #1d1d1f;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 15px;
  flex-shrink: 0;
}
.apple-alert__target-info {
  min-width: 0;
  flex: 1;
}
.apple-alert__target-name {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.apple-alert__target-meta {
  font-size: 12.5px;
  color: var(--ink-muted-48);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.apple-alert__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.apple-alert__btn {
  height: 42px;
  font-size: 14.5px;
  font-weight: 500;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s ease, background-color 0.15s ease;
}
.apple-alert__btn:active {
  transform: scale(0.97);
}
.btn--secondary {
  background: #f0f0f2;
  color: #1d1d1f;
  border: 0;
}
.btn--secondary:hover {
  background: #e5e5ea;
}
.btn--destructive {
  background: #ff3b30;
  color: #ffffff;
  border: 0;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(255, 59, 48, 0.28);
}
.btn--destructive:hover {
  background: #e02d23;
}
.btn--destructive:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
/* ซ่อนจากสายตาแต่ยังอ่านได้ด้วยโปรแกรมอ่านหน้าจอ */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.admin-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
}
.admin-toggle input {
  width: 18px;
  height: 18px;
  cursor: pointer;
}
.admin-date {
  height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: var(--r-sm, 8px);
  background: var(--canvas);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
}
.admin-date:focus {
  outline: 0;
  border-color: var(--primary-focus);
  box-shadow: 0 0 0 1px var(--primary-focus);
}
.btn--xs {
  height: 22px;
  padding: 0 6px;
  font-size: 11px;
  border-radius: 6px;
}
.admin-renew-cell {
  font-size: 11px;
  line-height: 1.3;
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 170px;
}
.admin-renew-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: var(--r-pill, 9999px);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.admin-renew-badge.is-pending {
  background: rgba(255, 149, 0, 0.15);
  color: #c95100;
  border: 1px solid rgba(255, 149, 0, 0.3);
}
.admin-renew-badge.is-approved {
  background: rgba(52, 199, 89, 0.12);
  color: #1b7f4b;
  border: 1px solid rgba(52, 199, 89, 0.25);
}
.admin-renew-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ff9500;
  display: inline-block;
  animation: pulse-dot 1.8s infinite ease-in-out;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}
.admin-card-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  color: var(--ink-muted-80);
  word-break: break-all;
  line-height: 1.2;
}
.admin-renew-quick {
  all: unset;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 3px;
  height: 21px;
  padding: 0 7px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: -0.1px;
  line-height: 1;
  border-radius: 5px;
  background: rgba(0, 102, 204, 0.08);
  color: #0066cc;
  border: 1px solid rgba(0, 102, 204, 0.25);
  transition: all 0.15s ease;
  white-space: nowrap;
  align-self: flex-start;
  cursor: pointer;
}
.admin-renew-quick:hover {
  background: #0066cc;
  color: #ffffff;
  border-color: #0066cc;
}
.admin-renew-quick:active {
  transform: scale(0.96);
}
.admin-renew-status-wrap {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.admin-history-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: var(--ink-muted-80);
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
}
.admin-history-btn:hover {
  background: rgba(0, 102, 204, 0.15);
  color: #0066cc;
  border-color: rgba(0, 102, 204, 0.3);
  transform: scale(1.08);
}
.admin-history-btn svg {
  width: 13px;
  height: 13px;
}

/* Modal History Dialog Styling */
.renew-history-dialog {
  max-width: 440px;
}
.renew-history-card {
  padding: 20px;
}
.renew-history__head {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  text-align: left;
  margin-bottom: 12px;
}
.apple-alert__icon--history {
  background: rgba(0, 102, 204, 0.1);
  color: #0066cc;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.renew-history__head-text {
  flex: 1;
  min-width: 0;
}
.renew-history__head-text .apple-alert__title {
  font-size: 17px;
  margin: 0;
}
.renew-history__head-text .apple-alert__desc {
  font-size: 12.5px;
  margin: 2px 0 0;
}
.renew-history__close {
  position: absolute;
  top: -4px;
  right: -4px;
}
.renew-history__summary {
  display: flex;
  margin-bottom: 10px;
}
.renew-history__count-badge {
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 9999px;
  background: rgba(0, 102, 204, 0.08);
  color: #0066cc;
}
.renew-history__list {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: var(--canvas-parchment);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  text-align: left;
}
.renew-history__item {
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
}
.renew-history__item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
}
.renew-history__item-badges {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.renew-history__tx-badge {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 10.5px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.05);
  color: var(--ink-muted-80);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--hairline);
}
.renew-history__item-action {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--hairline);
  display: flex;
  justify-content: flex-end;
}
.renew-history__item-date {
  font-size: 11px;
  color: var(--ink-muted-48);
}
.renew-history__item-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 600;
  color: var(--ink);
  font-size: 11.5px;
}
.renew-history__item-ref {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--primary);
  background: rgba(0, 102, 204, 0.08);
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 500;
}
.renew-history__item-ref strong {
  font-weight: 600;
  color: var(--primary);
}
.renew-history__empty {
  padding: 20px 10px;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-muted-48);
}
.admin-row__saving {
  opacity: 0.5;
  pointer-events: none;
}

/* ── Modal ข้อมูลผู้ใช้ (User Detail Card) ─────────────────────── */
.user-detail-card {
  width: min(860px, calc(100vw - 32px));
  max-width: 860px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  overscroll-behavior: contain;
  text-align: left;
  padding: 24px 28px;
}
.user-detail__head {
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--hairline);
}
.user-detail__avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #0066cc;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
}
.user-detail__head-info {
  min-width: 0;
  flex: 1;
}
.user-detail__title {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: #1d1d1f;
}
.user-detail__badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.user-detail__close {
  position: absolute;
  top: -4px;
  right: -4px;
}
.user-detail__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px 14px;
  margin-bottom: 20px;
}
.user-detail__item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--canvas-parchment);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 10px 14px;
}
.user-detail__item--col-2 {
  grid-column: span 2;
}
.user-detail__item--full {
  grid-column: 1 / -1;
}
.user-detail__val-inline {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}
.user-detail__subval {
  font-size: 12.5px;
  color: var(--ink-muted-48);
  font-weight: normal;
}
.user-detail__label {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-muted-48);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.user-detail__label--danger {
  color: #d70015;
}
.user-detail__val {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  word-break: break-word;
}
.user-detail__val--danger {
  color: #d70015;
  font-weight: 600;
}
.user-detail__card-image-wrap {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.03);
  padding: 12px;
  border-radius: 10px;
  border: 1px dashed var(--hairline);
}
.user-detail__card-image {
  max-width: 100%;
  max-height: 240px;
  border-radius: 8px;
  border: 1px solid var(--hairline);
  object-fit: contain;
  background: #fff;
  cursor: zoom-in;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.user-detail__card-image:hover {
  transform: scale(1.02);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}
.user-detail__card-hint {
  font-size: 12px;
  color: var(--primary);
  font-weight: 500;
  text-decoration: underline;
}
.user-detail__actions {
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 768px) {
  .user-detail-card {
    padding: 16px;
  }
  .user-detail__grid {
    grid-template-columns: 1fr;
  }
  .user-detail__item--col-2 {
    grid-column: 1;
  }
  .user-menu__panel {
    width: min(280px, calc(100vw - 24px));
  }
}

/* ── ชั้นข้อมูลบนแผนที่ (ปุ่มติ๊กใต้ช่องค้นหา) ─────────────────── */
.layers {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-sm) var(--s-lg);
  margin: var(--s-md) 0 0;
  padding: var(--s-sm) var(--s-md);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
}
.layers__legend {
  padding: 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted-80);
}
.layers__item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  line-height: 1.3;
  cursor: pointer;
  white-space: nowrap;
}
.layers__item input {
  width: 17px;
  height: 17px;
  cursor: pointer;
}
.layers__item--off {
  color: var(--ink-muted-48);
  cursor: not-allowed;
}
.layers__item--off input {
  cursor: not-allowed;
}
.layers__note {
  flex: 1 1 100%;
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink-muted-48);
}
.layers__note.is-error {
  color: #b3261e;
}

/* ── ตัวเลือกประเภทจุดสำคัญ ─────────────────────────────────── */
.poi {
  flex: 1 1 100%;
  margin-top: 4px;
  padding-top: var(--s-sm);
  border-top: 1px solid var(--hairline);
}
.poi__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-sm);
  margin-bottom: var(--s-sm);
}
.poi__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted-80);
  margin-right: auto;
}
/* ขอบเขตการแสดงจุด — จำกัดเฉพาะรอบที่อยู่ที่ค้นหา */
.poi__scope {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: var(--s-sm);
  font-size: 13px;
  cursor: pointer;
}
.poi__scope input {
  width: 15px;
  height: 15px;
  cursor: pointer;
  flex: 0 0 auto;
}
.poi__scope-radius {
  font: inherit;
  font-size: 12px;
  padding: 1px 4px;
  cursor: pointer;
}
.poi__scope.is-off {
  opacity: 0.55;
}
.poi__groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: var(--s-sm) var(--s-lg);
}
.poi__group {
  min-width: 0;
}
.poi__group-name {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted-80);
}
.poi__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.poi__item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 0 2px 17px;
  font-size: 13px;
  line-height: 1.35;
  cursor: pointer;
}
.poi__item input {
  width: 15px;
  height: 15px;
  cursor: pointer;
  flex: 0 0 auto;
}
/* สัญลักษณ์ประจำประเภท — วงกลมสีตามหมวด ใช้ให้ตรงกับหมุดบนแผนที่ */
.poi__mark {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  line-height: 1;
  color: #fff;
}
.poi__item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.poi__count {
  margin-left: auto;
  padding-left: 8px;
  font-size: 11px;
  color: var(--ink-muted-48);
  font-variant-numeric: tabular-nums;
}
.poi__note {
  margin: var(--s-sm) 0 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink-muted-48);
}

/* คำอธิบายชั้นระบบระบายน้ำ */
.drain-legend {
  padding: 8px 10px;
  background: rgb(255 255 255 / 0.92);
  border-radius: var(--r-sm, 6px);
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.25);
  font-size: 11px;
  line-height: 1.35;
  color: var(--ink);
  max-width: 220px;
}
.drain-legend__title {
  font-weight: 600;
  margin-bottom: 5px;
}
.drain-legend__scale {
  display: flex;
  height: 9px;
  border-radius: 2px;
  overflow: hidden;
}
.drain-legend__sw {
  flex: 1;
}
.drain-legend__ends {
  display: flex;
  justify-content: space-between;
  margin-top: 3px;
  color: var(--ink-muted-48);
}
.drain-legend__foot {
  margin-top: 5px;
  color: var(--ink-muted-48);
}
.drain-legend__vill {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c62828;
  border: 1px solid #fff;
  vertical-align: -1px;
}

/* ลูกศรความลาดชัน — ชี้ไปทางที่พื้นลาดลง (สีเขียวตามชุดข้อมูลต้นทาง) */
.slope-arrow-wrap {
  background: none;
  border: 0;
}
.slope-arrow {
  width: 24px;
  height: 24px;
  overflow: visible;
  fill: none;
  stroke: #35ff35;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  paint-order: stroke;
  filter: drop-shadow(0 0 1.5px rgb(0 0 0 / 0.75));
}

/* หมุดจุดสำคัญบนแผนที่ */
.poi-pin-wrap {
  background: none;
  border: 0;
}
.poi-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.4);
  font-size: 12px;
  line-height: 1;
}
.poi-popup__name {
  font-weight: 600;
  margin-bottom: 2px;
}
.poi-popup__kind {
  font-size: 12px;
  color: var(--ink-muted-48);
}

/* ── คำอธิบายสีของชั้นพื้นที่ลุ่มต่ำ (มุมแผนที่) ───────────────── */
.flood-legend {
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.94);
  border-radius: var(--r-lg);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink);
  max-width: 220px;
}
.flood-legend__title {
  font-weight: 600;
  margin-bottom: 6px;
}
.flood-legend__scale {
  display: flex;
  gap: 8px;
}
.flood-legend__bar {
  width: 16px;
  border-radius: 3px;
  /* ไล่สีเดียวกับภาพ overlay: แดง = ลุ่มต่ำมาก → น้ำเงิน = ลุ่มต่ำน้อย */
  background: linear-gradient(
    to bottom,
    #ff0000,
    #ff8c00,
    #ffff00,
    #00d000,
    #00c8c8,
    #0000ff
  );
}
.flood-legend__ends {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.flood-legend__hi {
  font-weight: 600;
}
.flood-legend__lo {
  font-weight: 600;
}
.flood-legend__sub {
  color: var(--ink-muted-48);
}
.flood-legend__foot {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--hairline);
  color: var(--ink-muted-48);
}

/* ── Tiles ──────────────────────────────────────────────────── */
.tile {
  padding: var(--s-section) var(--s-lg);
}
.tile--light {
  background: var(--canvas);
  color: var(--ink);
}
.tile--parchment {
  background: var(--canvas-parchment);
  color: var(--ink);
}
.tile--dark {
  background: var(--surface-tile-1);
  color: var(--body-on-dark);
}
.tile--dark a {
  color: var(--primary-on-dark);
}
.tile__headline {
  font-size: 40px;
  line-height: 1.1;
  text-align: center;
}
.tile__lead {
  max-width: 720px;
  margin: var(--s-lg) auto 0;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
  line-height: 1.14;
  letter-spacing: 0.196px;
  text-align: center;
}
.tile--dark .tile__lead {
  color: var(--body-muted);
}
.tile__note {
  max-width: 720px;
  margin: var(--s-xxl) auto 0;
  font-size: 14px;
  line-height: 1.43;
  letter-spacing: -0.224px;
  color: var(--body-muted);
  text-align: center;
}
.tile__note--muted {
  margin-top: var(--s-md);
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: -0.12px;
  color: var(--ink-muted-48);
}

/* ── Hero + search ──────────────────────────────────────────── */
.hero {
  /* ไม่มีหัวข้อใหญ่แล้ว จึงลดอากาศบน-ล่างให้การ์ดค้นหาชิดกับผลลัพธ์มากขึ้น */
  padding-top: var(--s-xl);
  padding-bottom: var(--s-xl);
  text-align: center;
}
.hero__lead {
  max-width: 760px;
  margin: 0 auto;
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 400;
  line-height: 1.18;
  letter-spacing: -0.374px;
}

.search {
  max-width: 1440px;
  margin: var(--s-lg) auto 0;
  padding: var(--s-sm) var(--s-md);
  background: var(--canvas-parchment);
  border-radius: var(--r-lg);
  text-align: left;
}
/* ทุกช่องอยู่แถวเดียว ยืดออกทางกว้างแทนการซ้อนหลายแถว */
.search__row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--s-xs);
}
.field {
  flex: 1 1 130px;
  min-width: 0;
  display: block;
}
.field--grow {
  flex: 2 1 220px;
}
.field--moo {
  flex: 0 1 82px;
}
.field__label {
  display: block;
  margin: 0 0 2px var(--s-sm);
  font-size: 11px;
  line-height: 1.3;
  letter-spacing: -0.12px;
  color: var(--ink-muted-48);
}
.field__hint {
  font-size: 12px;
  line-height: 1.4;
  letter-spacing: -0.12px;
  color: var(--ink-muted-48);
}
.field__control {
  display: flex;
  align-items: center;
  gap: var(--s-xs);
  height: 36px;
  padding: 0 14px;
  background: var(--canvas);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--r-pill);
}
.field__control:focus-within {
  border-color: var(--primary-focus);
  box-shadow: 0 0 0 1px var(--primary-focus);
}
.field__icon {
  flex: none;
  width: 14px;
  height: 14px;
  fill: var(--ink-muted-48);
}
.field__control input,
.field__control select {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 14px;
  letter-spacing: -0.224px;
}
.field__control select {
  appearance: none;
  cursor: pointer;
}
.field__control select:disabled {
  color: var(--ink-muted-48);
  cursor: not-allowed;
}
.field__control--select {
  position: relative;
  padding-right: 30px;
}
.field__control--select::after {
  content: '';
  position: absolute;
  right: 13px;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--ink-muted-48);
  border-bottom: 1.5px solid var(--ink-muted-48);
  transform: translateY(-2px) rotate(45deg);
  pointer-events: none;
}
.field__control input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

/* ปุ่มอยู่ท้ายแถวเดียวกับช่องกรอก จึงชิดล่างให้ตรงแนวกับกล่องช่อง */
.search__actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--s-xs);
}
.search__actions .btn {
  height: 36px;
}
/* บรรทัดคำอธิบาย + สถานะ อยู่ใต้แถวช่องกรอก */
.search__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s-xs) var(--s-sm);
  margin: var(--s-xs) 0 0 var(--s-sm);
}
.search__status {
  font-size: 12px;
  letter-spacing: -0.12px;
  color: var(--ink-muted-48);
}
.search__status--error {
  color: #b3261e;
}

/* ── Buttons ────────────────────────────────────────────────── */
/* .btn ตั้ง display จึงทับ [hidden] ของ UA — ต้องประกาศทับกลับ ไม่งั้นปุ่มที่ซ่อนไว้จะยังโผล่ */
[hidden] {
  display: none !important;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 22px;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  font-family: var(--font-text);
  font-size: 17px;
  line-height: 1.24;
  letter-spacing: -0.374px;
  cursor: pointer;
}
.btn:hover {
  text-decoration: none;
}
.btn:active {
  transform: scale(0.95);
}
.btn--primary {
  background: var(--primary);
  color: var(--on-primary);
}
.btn--ghost {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
#btnAdmin.btn--ghost {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
#btnAdmin.btn--ghost:hover {
  background: #0052a3;
  border-color: #0052a3;
}
#btnAisFibre.btn--ghost {
  background: #28a745;
  color: #fff;
  border-color: #28a745;
}
#btnAisFibre.btn--ghost:hover {
  background: #218838;
  border-color: #218838;
}
#btnAisFibre.btn--ghost:disabled {
  opacity: 0.65;
}
.btn--sm {
  padding: 6px 16px;
  font-size: 14px;
  letter-spacing: -0.224px;
}

/* ── Results ────────────────────────────────────────────────── */
/* ผลลัพธ์ต่อจากการ์ดค้นหาโดยตรง จึงตัดอากาศด้านบนให้เหลือน้อยที่สุด */
.results {
  padding-top: var(--s-lg);
}
/* สถานะว่าง (ยังไม่ได้ค้นหา) ไม่มีเนื้อหาแล้ว เหลือไว้เป็นแถบพักสายตาบาง ๆ */
.empty {
  padding: var(--s-lg);
}
.results__header {
  max-width: 1440px;
  margin: 0 auto var(--s-lg);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 0 var(--s-md);
}
.results__title,
.results__meta {
  grid-column: 1;
}
.results__title {
  font-family: var(--font-text);
  font-size: 34px;
  line-height: 1.47;
  letter-spacing: -0.374px;
}
.results__meta {
  margin: 0;
  font-size: 14px;
  line-height: 1.43;
  letter-spacing: -0.224px;
  color: var(--ink-muted-48);
}
.results__grid {
  display: grid;
  /* คอลัมน์รายการล็อกความกว้างไว้ ที่เหลือยกให้แผนที่ทั้งหมด */
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
  gap: var(--s-lg);
  max-width: 1440px;
  margin: 0 auto;
  align-items: start;
}
.results__list-wrap {
  max-height: 720px;
  overflow-y: auto;
  padding-right: var(--s-xxs);
}
.results__actions {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: start;
  display: flex;
  gap: var(--s-xs);
}
/* ซ่อนรายการไปด้านข้าง — แผนที่กินพื้นที่เต็มความกว้าง */
.results__grid.is-collapsed {
  grid-template-columns: minmax(0, 1fr);
}
.results__grid.is-collapsed .results__list-wrap {
  display: none;
}

.result-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-sm);
}
.result-item {
  width: 100%;
  display: block;
  padding: var(--s-md);
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  text-align: left;
  font-family: var(--font-text);
  cursor: pointer;
}
.result-item:active {
  transform: scale(0.99);
}
.result-item[aria-current='true'] {
  border: 2px solid var(--primary-focus);
  padding: calc(var(--s-md) - 1px);
}
.result-item__top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 var(--s-xs);
}
.result-item__name {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.24;
  letter-spacing: -0.374px;
}
.result-item__moo {
  font-size: 14px;
  letter-spacing: -0.224px;
  color: var(--ink-muted-48);
}
.result-item__where {
  margin: var(--s-xxs) 0 0;
  font-size: 14px;
  line-height: 1.43;
  letter-spacing: -0.224px;
  color: var(--ink-muted-80);
}
.result-item__facts {
  margin-top: var(--s-sm);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-xs);
}
.chip {
  padding: 5px 12px;
  background: var(--surface-pearl);
  border: 1px solid var(--divider-soft);
  border-radius: var(--r-md);
  font-size: 12px;
  line-height: 1.4;
  letter-spacing: -0.12px;
  color: var(--ink-muted-80);
}
.chip--near {
  color: var(--primary);
  background: var(--canvas);
  border-color: var(--primary);
}
.chip--warn {
  color: #8a6100;
  background: #fff8e6;
  border-color: #f2e2b8;
}
.result-list__more {
  margin: var(--s-sm) 0 0;
  font-size: 14px;
  letter-spacing: -0.224px;
  color: var(--ink-muted-48);
  text-align: center;
}
.result-empty {
  padding: var(--s-xxl) var(--s-lg);
  text-align: center;
  color: var(--ink-muted-48);
}

/* ── Map ────────────────────────────────────────────────────── */
.results__map-wrap {
  position: sticky;
  top: calc(var(--subnav-h) + var(--s-lg));
}
.map-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-lg);
  /* แผนที่คือ "ภาพที่วางอยู่บนพื้นผิว" — จุดเดียวที่ใช้เงาของระบบ */
  box-shadow: var(--product-shadow);
}
#map {
  height: 620px;
  background: var(--canvas-parchment);
}

/* เต็มจอ: ทั้งแบบ Fullscreen API และแบบสำรอง (เบราว์เซอร์ที่ไม่รองรับ) */
.map-card:fullscreen #map,
.map-card.is-fullscreen #map {
  height: 100%;
}
.map-card:fullscreen {
  border-radius: 0;
}
.map-card.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 3000;
  border-radius: 0;
}
.leaflet-container {
  font-family: var(--font-text);
  font-size: 14px;
}
.leaflet-popup-content-wrapper {
  border-radius: var(--r-md);
}
.leaflet-popup-content {
  margin: 12px 16px;
  line-height: 1.43;
}
.popup__name {
  font-weight: 600;
}
.popup__where {
  color: var(--ink-muted-80);
}
.leaflet-control-zoom a {
  color: var(--ink) !important;
}

.detail {
  margin-top: var(--s-lg);
  padding: var(--s-lg);
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
}
.detail__name {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  line-height: 1.19;
}
.detail__where {
  margin: var(--s-xxs) 0 var(--s-md);
  font-size: 14px;
  letter-spacing: -0.224px;
  color: var(--ink-muted-48);
}
.detail__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--s-md);
  padding-top: var(--s-md);
  border-top: 1px solid var(--divider-soft);
}
.detail__k {
  display: block;
  font-size: 12px;
  letter-spacing: -0.12px;
  color: var(--ink-muted-48);
}
.detail__v {
  display: block;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.374px;
}
.detail__links {
  margin-top: var(--s-md);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-md);
  font-size: 14px;
  letter-spacing: -0.224px;
}

/* ── About ──────────────────────────────────────────────────── */
.about__grid {
  max-width: 980px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--s-lg);
  text-align: center;
}
.about__num {
  display: block;
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 600;
  line-height: 1.1;
}
.about__cap {
  display: block;
  margin-top: var(--s-xs);
  font-size: 14px;
  letter-spacing: -0.224px;
  color: var(--body-muted);
}

/* ── Footer ─────────────────────────────────────────────────── */
.footer {
  background: var(--canvas-parchment);
  color: var(--ink-muted-80);
  padding: 64px var(--s-lg);
}
.footer__inner {
  max-width: 980px;
  margin: 0 auto;
}
.footer__lead {
  margin: 0 0 var(--s-sm);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.29;
  letter-spacing: -0.224px;
}
.footer__fine {
  margin: 0 0 var(--s-xs);
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: -0.12px;
}
.footer__fine--muted {
  color: var(--ink-muted-48);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1068px) {
  .results__grid {
    grid-template-columns: 1fr;
  }
  .results__map-wrap {
    position: static;
    order: -1;
  }
  .results__list-wrap {
    max-height: none;
  }
  #map {
    height: 420px;
  }
}

@media (max-width: 833px) {
  .tile {
    padding: var(--s-xxl) var(--s-md);
  }
  .hero {
    padding-top: var(--s-lg);
    padding-bottom: var(--s-lg);
  }
  .results,
  .empty {
    padding-top: var(--s-md);
  }
}

@media (max-width: 640px) {
  .tile__lead {
    font-size: 21px;
    line-height: 1.3;
  }
  .hero__lead {
    font-size: 24px;
    line-height: 1.3;
  }
  .tile__headline {
    font-size: 28px;
  }
  .results__title {
    font-size: 24px;
  }
  /* จอเล็กเรียงลงเป็นแถวละช่อง ยกเว้นหมู่ที่ที่จับคู่กับชื่อได้ */
  .field--grow,
  .field {
    flex: 1 1 100%;
  }
  .field--moo {
    flex: 0 1 96px;
  }
  .search {
    padding: var(--s-sm);
  }
  .search__actions {
    flex: 1 1 100%;
    margin-top: var(--s-xxs);
  }
  .search__actions .btn {
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .btn:active,
  .result-item:active {
    transform: none;
  }
}
