:root {
  --bg-dark: #0f172a;
  --bg-panel: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-custom-map: #eef3f8;
  --border: #e2e8f0;
  --border-dark: #1e293b;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --accent: #0ea5e9;
  --success: #10b981;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.14);
  --radius: 10px;
  --topbar-height: 56px;
  --sidebar-width: 348px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Sarabun', 'Prompt', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-main);
  background: var(--bg-dark);
}

h1, h2, h3, .brand-text h1, .basemap-title, .stat-value {
  font-family: 'Prompt', 'Sarabun', sans-serif;
}

/* Topbar */
.topbar {
  height: var(--topbar-height);
  background: linear-gradient(90deg, #0f172a 0%, #1e293b 100%);
  color: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 1000;
  position: relative;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: #f8fafc;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: linear-gradient(135deg, #2563eb 0%, #0ea5e9 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.45);
}

.brand-text h1 {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.2px;
}

.brand-sub {
  display: block;
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.2;
}

.crs-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(14, 165, 233, 0.16);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.3);
  margin-left: 4px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  font-family: 'Prompt', sans-serif;
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.topbar-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.topbar-btn.active {
  background: rgba(37, 99, 235, 0.28);
  border-color: rgba(96, 165, 250, 0.55);
  color: #ffffff;
}

/* Workspace Layout */
.workspace {
  display: flex;
  height: calc(100vh - var(--topbar-height));
  width: 100%;
  position: relative;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100%;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 500;
  transition: margin-left 0.25s ease;
  box-shadow: 2px 0 12px rgba(15, 23, 42, 0.06);
}

.sidebar.collapsed {
  margin-left: calc(var(--sidebar-width) * -1);
}

/* Module Navigation (Main Layer Headers — Vertical Reorderable List) */
.module-nav {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px 12px;
  background: #e2e8f0;
  border-bottom: 2px solid #cbd5e1;
}

.module-nav-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: 'Prompt', sans-serif;
  font-size: 10.5px;
  font-weight: 600;
  color: #475569;
  padding: 0 2px 2px;
  letter-spacing: 0.2px;
}

.module-tab {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 8px 9px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  border-left: 4px solid #64748b;
  background: #ffffff;
  color: #1e293b;
  font-family: 'Prompt', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
  user-select: none;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.module-tab.is-live-module {
  border-left-color: #2563eb;
}

.module-tab.is-muted-layer {
  background: #f1f5f9;
  border-color: #e2e8f0;
  border-left-color: #cbd5e1;
  color: #94a3b8;
  box-shadow: none;
}

.module-tab.is-muted-layer svg {
  opacity: 0.5;
}

.module-tab.is-muted-layer .dot-live {
  background: #cbd5e1;
}

.layer-lock-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 500;
  color: #64748b;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  padding: 2px 6px;
  flex-shrink: 0;
}

.module-tab.active .layer-lock-badge {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.28);
  color: #e0f2fe;
}

.module-tab:hover {
  border-color: #93c5fd;
  border-left-color: #2563eb;
  background: #f8fbff;
}

.module-tab.active {
  background: linear-gradient(90deg, #1e3a8a 0%, #2563eb 100%);
  border-color: #1e3a8a;
  border-left-color: #38bdf8;
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.28);
}

.module-tab .module-tab-label {
  flex: 1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.module-tab .dot-live {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.module-tab.active .dot-live {
  background: #86efac;
}

.module-tab-chk {
  width: 15px;
  height: 15px;
  accent-color: #2563eb;
  cursor: pointer;
  flex-shrink: 0;
  margin: 0;
}

.module-tab.active .module-tab-chk {
  accent-color: #38bdf8;
}

.module-tab-chk-spacer {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.layer-order-btns {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.order-btn {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  background: #f1f5f9;
  color: #475569;
  font-size: 9px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: all 0.12s ease;
}

.order-btn:hover:not(:disabled) {
  background: #dbeafe;
  border-color: #60a5fa;
  color: #1d4ed8;
}

.order-btn:disabled {
  opacity: 0.28;
  cursor: default;
}

.module-tab.active .order-btn {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.26);
  color: #ffffff;
}

.module-tab.active .order-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.3);
}

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

.module-panel {
  display: none;
}

.module-panel.active {
  display: block;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.panel-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
}

.panel-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.panel-sub code {
  background: #f1f5f9;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
  color: #334155;
}

.status-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.status-active {
  background: #dcfce7;
  color: #15803d;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.stat-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.stat-label {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
}

.stat-value {
  display: block;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
  margin-top: 2px;
}

/* Control Card */
.control-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}

.opacity-row {
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
}

.opacity-row label {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--text-muted);
}

.opacity-row input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
  cursor: pointer;
}

.toggle-switch {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Search Box */
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  height: 36px;
  margin-bottom: 12px;
  color: var(--text-muted);
}

.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.search-box input {
  border: none;
  outline: none;
  width: 100%;
  font-family: 'Sarabun', sans-serif;
  font-size: 13.5px;
  color: var(--text-main);
}

/* Area List */
.area-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}

.link-btn:hover {
  text-decoration: underline;
}

.area-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.area-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #ffffff;
  cursor: pointer;
  transition: all 0.15s ease;
}

.area-item:hover {
  border-color: #93c5fd;
  background: #f8fbff;
}

.area-item.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.area-swatch {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.area-info {
  flex: 1;
  min-width: 0;
}

.area-name {
  display: block;
  font-family: 'Prompt', sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.area-meta {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
}

.area-km2 {
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  white-space: nowrap;
}

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

/* Planned Module Card */
.planned-card {
  background: var(--bg-subtle);
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  padding: 18px 16px;
}

.planned-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: #b45309;
  background: #fef3c7;
  padding: 3px 9px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.planned-card h2 {
  font-size: 16px;
  margin-bottom: 6px;
}

.planned-card p {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 14px;
}

.planned-info {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: 12.5px;
  color: #334155;
}

.planned-info ul {
  margin-top: 6px;
  padding-left: 18px;
  line-height: 1.7;
}

/* Map Stage */
.map-stage {
  flex: 1;
  position: relative;
  height: 100%;
  overflow: hidden;
}

.map-container {
  width: 100%;
  height: 100%;
  background: #1e293b;
  transition: background-color 0.25s ease;
}

.map-container.custom-basemap-mode {
  background: #ffffff;
}

/* Top-Right Floating Control Cluster */
.map-top-right-controls {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 820;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

/* Other Polling Units Alert Dropdown (! หน่วยเลือกตั้งอื่นๆ) */
.other-units-widget {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.other-units-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px 7px 8px;
  background: rgba(255, 251, 235, 0.97);
  backdrop-filter: blur(8px);
  border: 1.5px solid #f59e0b;
  border-radius: 11px;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  color: #78350f;
  transition: all 0.15s ease;
}

.other-units-trigger:hover {
  background: #fef3c7;
  border-color: #d97706;
}

.other-units-trigger[aria-expanded="true"] .basemap-chevron {
  transform: rotate(180deg);
  color: #b45309;
}

.alert-exclaim {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ef4444 0%, #f59e0b 100%);
  color: #ffffff;
  font-family: 'Prompt', sans-serif;
  font-size: 16px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

.other-units-trigger-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  line-height: 1.15;
}

.other-units-trigger-text strong {
  font-family: 'Prompt', sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  color: #78350f;
}

.other-units-sub {
  font-size: 10px;
  color: #b45309;
}

.other-units-count {
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #dc2626;
  color: #ffffff;
  font-family: 'Prompt', sans-serif;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.other-units-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 360px;
  max-height: calc(100vh - 130px);
  background: rgba(255, 255, 255, 0.99);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(217, 119, 6, 0.35);
  border-radius: 13px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.24);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 900;
}

.other-units-head {
  padding: 10px 13px;
  background: linear-gradient(90deg, #78350f 0%, #b45309 100%);
  color: #fffbeb;
}

.other-units-head strong {
  display: block;
  font-family: 'Prompt', sans-serif;
  font-size: 13.5px;
  font-weight: 600;
}

.other-units-head span {
  display: block;
  font-size: 11px;
  color: #fde68a;
  margin-top: 1px;
}

.other-units-tabs {
  display: flex;
  gap: 5px;
  padding: 8px 10px;
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
}

.ou-tab {
  flex: 1;
  border: 1px solid #fcd34d;
  background: #ffffff;
  color: #92400e;
  font-family: 'Prompt', sans-serif;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 6px;
  border-radius: 7px;
  cursor: pointer;
}

.ou-tab.active {
  background: #d97706;
  border-color: #d97706;
  color: #ffffff;
  font-weight: 600;
}

.ou-search-wrap {
  padding: 8px 10px 6px;
  border-bottom: 1px solid #f1f5f9;
}

.ou-search-wrap input {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  font-family: 'Sarabun', sans-serif;
  font-size: 13px;
  outline: none;
}

.ou-search-wrap input:focus {
  border-color: #d97706;
}

.other-units-list {
  list-style: none;
  max-height: 360px;
  overflow-y: auto;
  padding: 6px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ou-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 9px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.14s ease;
}

.ou-item:hover {
  border-color: #f59e0b;
  background: #fffbeb;
}

.ou-item-main {
  flex: 1;
  min-width: 0;
}

.ou-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.ou-item-name {
  font-family: 'Prompt', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ou-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

.ou-badge-outside {
  background: #fee2e2;
  color: #b91c1c;
}

.ou-badge-missing {
  background: #fef3c7;
  color: #b45309;
}

.ou-item-meta {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.ou-detail-view {
  max-height: 430px;
  overflow-y: auto;
  background: #ffffff;
}

.ou-back-btn {
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: none;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  color: var(--primary);
  font-family: 'Prompt', sans-serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.ou-back-btn:hover {
  background: #eff6ff;
}

/* Floating Basemap Switcher (Dropdown) */
.basemap-switcher {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.basemap-trigger {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 11px 7px 8px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 11px;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  color: var(--text-main);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.basemap-trigger:hover {
  border-color: #93c5fd;
  background: #ffffff;
}

.basemap-trigger[aria-expanded="true"] {
  border-color: var(--primary);
}

.basemap-trigger-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  line-height: 1.15;
}

.basemap-trigger-sub {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
}

.basemap-trigger-text strong {
  font-family: 'Prompt', sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
}

.basemap-chevron {
  color: var(--text-muted);
  margin-left: 2px;
  transition: transform 0.18s ease;
}

.basemap-trigger[aria-expanded="true"] .basemap-chevron {
  transform: rotate(180deg);
  color: var(--primary);
}

.basemap-dropdown {
  margin-top: 6px;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 12px;
  padding: 8px;
  box-shadow: var(--shadow-md);
  min-width: 245px;
}

.basemap-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.basemap-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: #ffffff;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
}

.basemap-btn:hover {
  border-color: #93c5fd;
  background: #f8fbff;
}

.basemap-btn.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.basemap-thumb {
  width: 34px;
  height: 28px;
  border-radius: 6px;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
}

.thumb-satellite {
  background: linear-gradient(135deg, #064e3b 0%, #1e3a5f 55%, #0f172a 100%);
  color: #a7f3d0;
}

.thumb-streets {
  background: linear-gradient(135deg, #fef9c3 0%, #e0f2fe 50%, #dcfce7 100%);
  color: #1e40af;
}

.thumb-custom {
  background: linear-gradient(135deg, #eef3f8 0%, #dbeafe 60%, #bfdbfe 100%);
  color: #1d4ed8;
}

.basemap-label {
  display: block;
  font-family: 'Prompt', sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.2;
}

.basemap-desc {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* Detail Card */
.detail-card {
  position: absolute;
  bottom: 48px;
  right: 14px;
  z-index: 800;
  width: 348px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 12px;
  padding: 14px;
  box-shadow: var(--shadow-md);
}

.detail-election-box {
  margin-bottom: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.detail-election-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: 'Prompt', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 8px;
}

.detail-election-title span {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}

.detail-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.detail-swatch {
  width: 14px;
  height: 32px;
  border-radius: 4px;
  flex-shrink: 0;
}

.detail-header h3 {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
}

.detail-type {
  font-size: 12px;
  color: var(--text-muted);
}

.icon-btn-sm {
  border: none;
  background: #f1f5f9;
  color: #475569;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.icon-btn-sm:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.detail-item {
  background: var(--bg-subtle);
  border-radius: 7px;
  padding: 7px 9px;
}

.detail-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

.detail-item strong {
  display: block;
  font-size: 12.5px;
  color: var(--text-main);
  margin-top: 2px;
  word-break: break-word;
}

.detail-actions {
  display: flex;
  gap: 8px;
}

.btn-primary-sm,
.btn-secondary-sm {
  flex: 1;
  height: 32px;
  border-radius: 7px;
  font-family: 'Prompt', sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: none;
}

.btn-primary-sm {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary-sm:hover {
  background: var(--primary-hover);
}

.btn-secondary-sm {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid var(--border);
}

.btn-secondary-sm:hover {
  background: #e2e8f0;
}

/* Coordinate Bar */
.coord-bar {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 750;
  background: rgba(15, 23, 42, 0.84);
  color: #e2e8f0;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  backdrop-filter: blur(6px);
  box-shadow: var(--shadow-sm);
}

.coord-sep {
  color: #475569;
}

.coord-hint {
  color: #94a3b8;
  font-size: 11px;
}

/* Polygon Map Labels */
.area-map-label {
  background: transparent;
  border: none;
  box-shadow: none;
}

.area-map-label span {
  display: inline-block;
  font-family: 'Prompt', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: #0f172a;
  background: rgba(255, 255, 255, 0.88);
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid rgba(15, 23, 42, 0.16);
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.14);
  transform: translate(-50%, -50%);
}

.satellite-mode .area-map-label span {
  background: rgba(15, 23, 42, 0.82);
  color: #f8fafc;
  border-color: rgba(255, 255, 255, 0.25);
}

/* Graticule Labels */
.graticule-label {
  background: transparent;
  border: none;
}

.graticule-label span {
  font-size: 10px;
  font-weight: 600;
  color: #64748b;
  background: rgba(238, 243, 248, 0.85);
  padding: 1px 4px;
  border-radius: 3px;
  white-space: nowrap;
}

/* Toast */
.toast {
  position: absolute;
  bottom: 54px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  background: #0f172a;
  color: #f8fafc;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow-md);
}

.hidden {
  display: none !important;
}

/* Leaflet overrides */
.leaflet-control-scale-line {
  background: rgba(255, 255, 255, 0.85) !important;
  border-color: #475569 !important;
  color: #0f172a !important;
  font-size: 11px !important;
}

/* =========================================================
   QGIS-Style Layer Tree & Sub-layers
   ========================================================= */
.tree-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.layer-tree {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.layer-parent-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 10px;
  background: linear-gradient(180deg, #eff6ff 0%, #e0edff 100%);
  border-bottom: 1px solid #bfdbfe;
  user-select: none;
}

.tree-caret {
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  color: #334155;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 4px;
  transition: transform 0.18s ease, background 0.15s ease;
  flex-shrink: 0;
}

.tree-caret:hover {
  background: rgba(37, 99, 235, 0.12);
}

.tree-caret.collapsed {
  transform: rotate(-90deg);
}

.tree-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.layer-type-icon {
  color: #2563eb;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.layer-parent-name {
  flex: 1;
  font-family: 'Prompt', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #1e3a8a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.style-trigger-btn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: #475569;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.style-trigger-btn:hover {
  background: #ffffff;
  border-color: #cbd5e1;
  color: var(--primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.sublayer-list {
  list-style: none;
  padding: 6px 6px 6px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: #ffffff;
}

.sublayer-list.collapsed {
  display: none;
}

.sublayer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 7px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.14s ease;
  position: relative;
}

.sublayer-item::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: #e2e8f0;
}

.sublayer-item:hover {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.sublayer-item.selected {
  background: var(--primary-soft);
  border-color: #93c5fd;
}

.sublayer-item.is-hidden-layer {
  background: #f1f5f9;
  color: #94a3b8;
  opacity: 0.65;
  filter: grayscale(0.9);
}

.sublayer-item.is-hidden-layer .sublayer-name {
  color: #94a3b8;
}

/* QGIS-style Symbol Swatch (shows live Fill + Stroke Border!) */
.symbol-swatch-btn {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  background-image:
    linear-gradient(45deg, #e2e8f0 25%, transparent 25%),
    linear-gradient(-45deg, #e2e8f0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e2e8f0 75%),
    linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0;
  border: none;
  overflow: hidden;
  transition: transform 0.12s ease;
}

.symbol-swatch-btn:hover {
  transform: scale(1.12);
}

.symbol-swatch-inner {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 4px;
  box-sizing: border-box;
}

.sublayer-info {
  flex: 1;
  min-width: 0;
}

.sublayer-name {
  display: block;
  font-family: 'Prompt', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

.sublayer-meta {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

.layer-tip {
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.45;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}

/* =========================================================
   Floating Draggable Style Editor Pop-up Modal
   ========================================================= */
.style-popup {
  position: absolute;
  top: 64px;
  left: 24px;
  z-index: 950;
  width: 340px;
  max-height: calc(100vh - 110px);
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 14px;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.24);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.style-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: linear-gradient(90deg, #0f172a 0%, #1e293b 100%);
  color: #f8fafc;
  cursor: move;
  user-select: none;
}

.style-popup-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.style-popup-badge {
  font-size: 10px;
  font-weight: 600;
  color: #7dd3fc;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.style-popup-header h3 {
  font-size: 14.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.style-popup-header .icon-btn-sm {
  background: rgba(255, 255, 255, 0.12);
  color: #f8fafc;
}

.style-popup-header .icon-btn-sm:hover {
  background: rgba(255, 255, 255, 0.24);
}

.style-popup-body {
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.symbol-preview-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}

.symbol-preview-checker {
  width: 120px;
  height: 58px;
  border-radius: 7px;
  border: 1px solid #cbd5e1;
  background-color: #ffffff;
  background-image:
    linear-gradient(45deg, #e2e8f0 25%, transparent 25%),
    linear-gradient(-45deg, #e2e8f0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e2e8f0 75%),
    linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
  flex-shrink: 0;
}

.symbol-preview-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.symbol-preview-meta strong {
  font-family: 'Prompt', sans-serif;
  font-size: 13.5px;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.symbol-preview-meta span {
  font-size: 11px;
  color: var(--text-muted);
}

.style-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid #f1f5f9;
}

.style-section:first-of-type {
  padding-top: 0;
  border-top: none;
}

.style-section-title {
  font-family: 'Prompt', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
}

.style-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-main);
}

.style-row.slider-row {
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}

.style-row.slider-row label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

.style-row.slider-row label strong {
  color: var(--text-main);
}

.style-row input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
  cursor: pointer;
}

.color-picker-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-picker-wrap input[type="color"] {
  width: 34px;
  height: 26px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 1px;
  background: #ffffff;
  cursor: pointer;
}

.color-picker-wrap code {
  font-size: 11.5px;
  color: #475569;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.preset-colors {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-chip {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: 1.5px solid rgba(15, 23, 42, 0.18);
  cursor: pointer;
  transition: transform 0.12s ease;
}

.preset-chip:hover {
  transform: scale(1.15);
}

.style-select {
  height: 30px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  font-family: 'Sarabun', sans-serif;
  font-size: 12.5px;
  color: var(--text-main);
  cursor: pointer;
}

.style-popup-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-subtle);
  border-top: 1px solid var(--border);
}

.style-footer-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.style-popup-footer .btn-primary-sm,
.style-popup-footer .btn-secondary-sm {
  flex: none;
  padding: 0 11px;
  font-size: 11.5px;
}

/* =========================================================
   Election 2569 Points, Candidate Photo Pins & Pop-up
   ========================================================= */
.election-filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.election-filters .style-select {
  width: 100%;
  height: 34px;
}

.muted-count {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.candidate-scoreboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cand-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #ffffff;
}

.cand-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top center;
  flex-shrink: 0;
  border: 2px solid #cbd5e1;
  background: #f1f5f9;
}

.cand-info {
  flex: 1;
  min-width: 0;
}

.cand-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}

.cand-name {
  font-family: 'Prompt', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cand-votes {
  font-family: 'Prompt', sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
}

.cand-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 1px;
}

.cand-bar-track {
  height: 5px;
  border-radius: 999px;
  background: #f1f5f9;
  overflow: hidden;
  margin-top: 4px;
}

.cand-bar-fill {
  height: 100%;
  border-radius: 999px;
}

.station-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 2px;
}

.station-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #ffffff;
  cursor: pointer;
  transition: all 0.14s ease;
}

.station-item:hover {
  border-color: #93c5fd;
  background: #f8fbff;
}

.station-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top center;
  flex-shrink: 0;
  border: 2.5px solid #f97316;
}

.station-info {
  flex: 1;
  min-width: 0;
}

.station-name {
  display: block;
  font-family: 'Prompt', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.station-meta {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

/* Map Candidate Photo Marker Pin */
.election-marker-wrapper {
  background: transparent;
  border: none;
}

.election-pin {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--pin-color, #f97316);
  background: #ffffff;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
}

.election-pin:hover {
  transform: scale(1.18);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.45);
  z-index: 1000;
}

.election-pin img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  object-position: top center;
  display: block;
}

.election-pin-num {
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  height: 16px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--pin-color, #f97316);
  color: #ffffff;
  font-family: 'Prompt', sans-serif;
  font-size: 9.5px;
  font-weight: 700;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid #ffffff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.3);
  line-height: 1;
}

.election-pin-units {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  height: 16px;
  padding: 0 5px;
  border-radius: 999px;
  background: #0f172a;
  color: #ffffff;
  font-family: 'Prompt', sans-serif;
  font-size: 9.5px;
  font-weight: 600;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid #ffffff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.3);
  line-height: 1;
}

.election-dot-pin {
  position: relative;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--pin-color, #f97316);
  border: 2px solid #ffffff;
  color: #ffffff;
  font-family: 'Prompt', sans-serif;
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.35);
  transition: transform 0.14s ease;
}

.election-dot-pin:hover {
  transform: scale(1.2);
}

/* Out-of-District (เลือกตั้งนอกเขต) Exclamation Pin & Tooltip */
.election-pin-outofdistrict {
  border-color: #dc2626 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.3), 0 4px 12px rgba(15, 23, 42, 0.4) !important;
}

.election-pin-exclaim {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #dc2626 0%, #f59e0b 100%);
  color: #ffffff;
  font-family: 'Prompt', sans-serif;
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.5);
  line-height: 1;
}

.outofdistrict-tooltip {
  background: #78350f !important;
  color: #fffbeb !important;
  border: 1.5px solid #f59e0b !important;
  border-radius: 8px !important;
  font-family: 'Prompt', sans-serif !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  padding: 5px 10px !important;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.25) !important;
}

.outofdistrict-tooltip::before {
  border-top-color: #f59e0b !important;
}

/* Rich Leaflet Election Popup (Clean 8-Row Layout, No Clipping) */
.election-leaflet-popup .leaflet-popup-content-wrapper {
  border-radius: 13px;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.25);
}

.election-leaflet-popup .leaflet-popup-content {
  margin: 0;
  width: 348px !important;
  font-family: 'Sarabun', 'Prompt', sans-serif;
}

.ep-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #f8fafc;
  padding: 11px 14px;
}

.ep-local {
  font-size: 11px;
  color: #7dd3fc;
  font-weight: 600;
}

.ep-title {
  font-family: 'Prompt', sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
  margin-top: 2px;
}

.ep-sub {
  font-size: 11px;
  color: #cbd5e1;
  margin-top: 3px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ep-gmap-link {
  color: #93c5fd;
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}

.ep-gmap-link:hover {
  text-decoration: underline;
}

.ep-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 12px 6px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.ep-tab {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  font-family: 'Prompt', sans-serif;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  cursor: pointer;
}

.ep-tab.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
  font-weight: 600;
}

.ep-body {
  padding: 10px 12px 12px;
  background: #ffffff;
}

.ep-winner-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  margin-bottom: 9px;
}

.ep-winner-photo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top center;
  border: 3px solid #f97316;
  flex-shrink: 0;
}

.ep-winner-info {
  flex: 1;
  min-width: 0;
}

.ep-winner-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: #ffffff;
  padding: 1px 7px;
  border-radius: 999px;
  margin-bottom: 2px;
}

.ep-winner-name {
  display: block;
  font-family: 'Prompt', sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ep-winner-party {
  display: block;
  font-size: 11px;
  color: #64748b;
}

.ep-winner-score {
  text-align: right;
  flex-shrink: 0;
}

.ep-winner-score strong {
  display: block;
  font-family: 'Prompt', sans-serif;
  font-size: 16px;
  line-height: 1.1;
}

.ep-winner-score span {
  font-size: 11px;
  color: #64748b;
}

.ep-scores-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ep-score-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.ep-mini-photo {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top center;
  border: 1.5px solid #cbd5e1;
  flex-shrink: 0;
}

.ep-score-main {
  flex: 1;
  min-width: 0;
}

.ep-score-top {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  line-height: 1.2;
}

.ep-score-label {
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ep-score-num {
  font-family: 'Prompt', sans-serif;
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
  margin-left: 6px;
}

.ep-bar-bg {
  height: 5px;
  border-radius: 999px;
  background: #f1f5f9;
  overflow: hidden;
  margin-top: 2px;
}

.ep-bar-fill {
  height: 100%;
  border-radius: 999px;
}

.ep-footer {
  margin-top: 9px;
  padding-top: 7px;
  border-top: 1px solid #f1f5f9;
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #64748b;
}

/* =========================================================
   Key POIs (พิกัดสำคัญ — Multi-Tab Google Sheet)
   ========================================================= */
.poi-category-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
  padding-left: 12px;
  border-left: 2px dashed #cbd5e1;
  margin-left: 6px;
}

.poi-cat-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px;
  border-radius: 7px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  font-size: 12px;
  transition: all 0.14s ease;
}

.poi-cat-item.is-hidden-layer {
  background: #f1f5f9;
  border-color: #e2e8f0;
  opacity: 0.62;
  filter: grayscale(0.95);
}

.poi-cat-item.is-hidden-layer .poi-cat-name {
  color: #94a3b8;
}

.poi-cat-icon {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  flex-shrink: 0;
  border: none;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.poi-cat-icon:hover {
  transform: scale(1.1);
}

.poi-cat-icon svg {
  width: 15px;
  height: 15px;
}

.poi-cat-name {
  flex: 1;
  font-family: 'Prompt', sans-serif;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.poi-cat-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: #f1f5f9;
  padding: 1px 7px;
  border-radius: 999px;
}

.poi-filter-row {
  margin-bottom: 8px;
}

.poi-filter-row .style-select {
  width: 100%;
  height: 34px;
}

/* POI Map Pin Shapes (Teardrop, Circle, Square, Diamond) */
.poi-marker-wrapper {
  background: transparent;
  border: none;
}

.poi-pin {
  width: var(--poi-size, 30px);
  height: var(--poi-size, 30px);
  background: var(--poi-color, #2563eb);
  border: 2px solid #ffffff;
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.14s ease;
}

.poi-pin svg {
  width: calc(var(--poi-size, 30px) * 0.54);
  height: calc(var(--poi-size, 30px) * 0.54);
  display: block;
}

.poi-pin.poi-shape-teardrop {
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
}

.poi-pin.poi-shape-teardrop svg {
  transform: rotate(45deg);
}

.poi-pin.poi-shape-teardrop:hover {
  transform: rotate(-45deg) scale(1.16);
}

.poi-pin.poi-shape-circle {
  border-radius: 50%;
}

.poi-pin.poi-shape-circle:hover {
  transform: scale(1.16);
}

.poi-pin.poi-shape-square {
  border-radius: 8px;
}

.poi-pin.poi-shape-square:hover {
  transform: scale(1.16);
}

.poi-pin.poi-shape-diamond {
  border-radius: 5px;
  transform: rotate(45deg) scale(0.86);
}

.poi-pin.poi-shape-diamond svg {
  transform: rotate(-45deg);
}

.poi-pin.poi-shape-diamond:hover {
  transform: rotate(45deg) scale(1.0);
}

/* POI Style Pop-up Preview & Icon Picker Grid */
.poi-preview-stage {
  width: 66px;
  height: 58px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.poi-icon-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.poi-icon-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 2px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: #ffffff;
  color: #334155;
  cursor: pointer;
  transition: all 0.12s ease;
}

.poi-icon-option:hover {
  border-color: #93c5fd;
  background: #f8fbff;
}

.poi-icon-option.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.poi-icon-option svg {
  width: 18px;
  height: 18px;
}

.poi-icon-option span {
  font-family: 'Prompt', sans-serif;
  font-size: 9px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* POI Leaflet Popup (ชื่อสถานที่ 16px, หมวดหมู่ 8px = ครึ่งนึงของชื่อสถานที่) */
.poi-leaflet-popup .leaflet-popup-content-wrapper {
  border-radius: 12px;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.22);
}

.poi-leaflet-popup .leaflet-popup-content {
  margin: 0;
  width: 290px !important;
  font-family: 'Sarabun', 'Prompt', sans-serif;
}

.poi-popup-head {
  padding: 11px 14px 10px;
  color: #ffffff;
  background: var(--poi-color, #2563eb);
}

.poi-popup-title {
  font-family: 'Prompt', sans-serif;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  color: #ffffff;
}

.poi-popup-category {
  font-family: 'Prompt', sans-serif;
  font-size: 8px; /* Exact half (50%) of 16px place name */
  font-weight: 500;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.92);
  margin-top: 3px;
  letter-spacing: 0.2px;
}

.poi-popup-body {
  padding: 10px 14px 12px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.poi-popup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  color: #334155;
}

.poi-importance-badge {
  font-family: 'Prompt', sans-serif;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #0f172a;
}

.poi-popup-note {
  font-size: 12.5px;
  color: #475569;
  line-height: 1.45;
  background: #f8fafc;
  border-radius: 7px;
  padding: 6px 9px;
  border: 1px solid #e2e8f0;
}

.poi-popup-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 6px;
  border-top: 1px solid #f1f5f9;
  font-size: 11px;
  color: #64748b;
}

.poi-popup-foot a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.poi-popup-foot a:hover {
  text-decoration: underline;
}

/* POI Sidebar Item */
.poi-list-name {
  display: block;
  font-family: 'Prompt', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.poi-list-cat {
  display: block;
  font-family: 'Prompt', sans-serif;
  font-size: 7px; /* ~Half of place name */
  color: var(--text-muted);
  margin-top: 1px;
}

.poi-list-meta {
  display: block;
  font-size: 11px;
  color: #475569;
  margin-top: 2px;
}

/* POI Per-Category Label Toggle Button */
.poi-label-btn.active {
  background: var(--primary-soft);
  border-color: #93c5fd;
  color: var(--primary);
}

/* POI Permanent Map Label Tooltip */
.poi-map-label {
  background: rgba(255, 255, 255, 0.94) !important;
  color: #0f172a !important;
  border: 1px solid rgba(15, 23, 42, 0.2) !important;
  border-radius: 6px !important;
  padding: 2px 6px !important;
  font-family: 'Prompt', sans-serif !important;
  font-size: 10.5px !important;
  font-weight: 600 !important;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.16) !important;
  white-space: nowrap !important;
  pointer-events: none !important;
}

.poi-map-label::before {
  display: none !important;
}

.satellite-mode .poi-map-label {
  background: rgba(15, 23, 42, 0.86) !important;
  color: #f8fafc !important;
  border-color: rgba(255, 255, 255, 0.28) !important;
}

@media (max-width: 768px) {
  .crs-badge, .brand-sub, .coord-hint {
    display: none;
  }
  .sidebar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 300px;
    min-width: 300px;
  }
  .sidebar.collapsed {
    margin-left: -300px;
  }
  .basemap-switcher {
    min-width: 190px;
  }
  .custom-basemap-banner {
    display: none;
  }
  .style-popup {
    left: 10px;
    right: 10px;
    width: auto;
    top: 60px;
  }
}

/* PWA Waterworks Draft Jurisdiction Layer Box */
.pwa-layer-box {
  margin-top: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.pwa-layer-row {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
}

.pwa-layer-title {
  flex: 1;
}

.pwa-draft-pill {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #0369a1;
}

.pwa-legend {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 22px;
  font-size: 11.5px;
  color: var(--text-secondary);
}

.pwa-legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
}

.pwa-legend-item small {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 10.5px;
}

.pwa-swatch {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  flex-shrink: 0;
  opacity: 0.78;
}

.pwa-line-swatch {
  width: 14px;
  height: 0;
  border-top: 2.5px dashed #f59e0b;
  flex-shrink: 0;
}

.pwa-sub-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
  cursor: pointer;
  font-size: 11.5px;
  color: var(--text-muted);
}

.pwa-zone-tooltip {
  background: rgba(15, 23, 42, 0.86);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 6px;
  font-family: 'Prompt', 'Sarabun', sans-serif;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
}

/* POI Backend Google Sheet Link */
.poi-backend-link {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 6px 10px;
  border-radius: 8px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #047857;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s ease;
}

.poi-backend-link:hover {
  background: #d1fae5;
  border-color: #6ee7b7;
  color: #065f46;
}

.poi-backend-arrow {
  margin-left: auto;
  font-size: 13px;
}

/* Modern Local Admin Detail Card (Google Sheet Profile) */
.detail-card {
  width: 360px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 96px);
  overflow-y: auto;
}

.detail-header-xl {
  align-items: center;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid #e2e8f0;
}

.detail-name-xl {
  font-family: 'Prompt', 'Sarabun', sans-serif;
  font-size: 20px !important;
  font-weight: 700 !important;
  line-height: 1.22;
  color: #0f172a;
  letter-spacing: -0.01em;
  margin: 0;
}

.detail-profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 10px;
}

.dp-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dp-item-full {
  grid-column: 1 / -1;
}

.dp-label {
  font-size: 10.5px;
  color: #64748b;
  font-weight: 500;
}

.dp-val {
  font-size: 12.5px;
  color: #0f172a;
  font-weight: 600;
  line-height: 1.3;
}

/* Target Votes Box (3 ขั้ว vs 1 ต่อ 1) */
.dp-target-box {
  background: linear-gradient(135deg, #eff6ff 0%, #f0f9ff 100%);
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 9px 10px;
  margin-bottom: 10px;
}

.dp-target-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.dp-target-label {
  font-size: 11.5px;
  font-weight: 600;
  color: #1e40af;
}

.dp-target-toggle {
  display: inline-flex;
  background: #dbeafe;
  border-radius: 999px;
  padding: 2px;
  gap: 2px;
}

.dp-toggle-btn {
  border: none;
  background: transparent;
  color: #1e3a8a;
  font-family: 'Prompt', 'Sarabun', sans-serif;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dp-toggle-btn.active {
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 1px 4px rgba(37, 99, 235, 0.35);
}

.dp-target-value-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.dp-target-num {
  font-family: 'Prompt', 'Sarabun', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: #1d4ed8;
  line-height: 1.1;
}

.dp-target-unit {
  font-size: 12px;
  font-weight: 600;
  color: #3b82f6;
}

/* Emphasized Pain Points Box */
.dp-pain-box {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-left: 4px solid #dc2626;
  border-radius: 10px;
  padding: 10px 11px;
  margin-bottom: 10px;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.08);
}

.dp-pain-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}

.dp-pain-title {
  font-family: 'Prompt', 'Sarabun', sans-serif;
  font-size: 13.5px;
  font-weight: 700;
  color: #b91c1c;
}

.dp-pain-badge {
  font-size: 10.5px;
  font-weight: 700;
  background: #fee2e2;
  color: #b91c1c;
  padding: 2px 8px;
  border-radius: 999px;
}

.dp-pain-list {
  margin: 0;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dp-pain-list li {
  font-size: 12.5px;
  font-weight: 600;
  color: #7c2d12;
  line-height: 1.4;
}

.dp-sheet-btn {
  flex: 0 0 auto !important;
  padding: 0 10px !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #047857 !important;
  background: #ecfdf5 !important;
  border-color: #a7f3d0 !important;
}

.dp-sheet-btn:hover {
  background: #d1fae5 !important;
}

/* Expanded Detail Card + Kamonthas Prev Score + Top-3 Toggle + Bottom-Left Basemap */
.detail-card {
  width: 430px;
  max-width: calc(100vw - 24px);
  top: 14px;
  right: 14px;
  bottom: auto;
  max-height: calc(100vh - 76px);
  padding: 16px 18px;
}

.detail-name-xl {
  font-size: 22px !important;
}

.dp-label {
  font-size: 11px;
}

.dp-val {
  font-size: 13px;
}

/* Previous Election Score Box for Kamonthas (#1) */
.dp-prev-kamon-box {
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
  border: 1px solid #fdba74;
  border-radius: 10px;
  padding: 9px 11px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.dp-kamon-photo {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2.5px solid #f97316;
  flex-shrink: 0;
  background: #ffffff;
}

.dp-kamon-info {
  flex: 1;
  min-width: 0;
}

.dp-kamon-sub {
  font-size: 10.5px;
  font-weight: 700;
  color: #c2410c;
  display: block;
}

.dp-kamon-name {
  font-family: 'Prompt', 'Sarabun', sans-serif;
  font-size: 12.5px;
  font-weight: 700;
  color: #0f172a;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dp-kamon-meta {
  font-size: 11px;
  color: #9a3412;
  display: block;
}

.dp-kamon-score {
  text-align: right;
  flex-shrink: 0;
}

.dp-kamon-score strong {
  display: block;
  font-family: 'Prompt', 'Sarabun', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: #ea580c;
  line-height: 1.1;
}

.dp-kamon-score span {
  font-size: 11px;
  font-weight: 600;
  color: #9a3412;
}

/* Top-3 Expand/Collapse Toggle Button */
.ep-toggle-all-btn {
  width: 100%;
  margin-top: 6px;
  padding: 5px 10px;
  border-radius: 7px;
  border: 1px dashed #cbd5e1;
  background: #f8fafc;
  color: #334155;
  font-family: 'Prompt', 'Sarabun', sans-serif;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
}

.ep-toggle-all-btn:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}

.ep-scores-extra {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.ep-scores-extra.hidden {
  display: none;
}

/* Basemap Switcher Positioned Bottom-Left (Dropdown Opens Upward) */
.basemap-switcher.basemap-bottom-left {
  position: absolute;
  left: 12px;
  bottom: 42px;
  z-index: 650;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-start;
}

.basemap-switcher.basemap-bottom-left .basemap-dropdown {
  margin-top: 0;
  margin-bottom: 6px;
}

/* =========================================================
   Strategy Split-Screen Dashboard (50% Map | 50% Strategy)
   ========================================================= */
.workspace.strategy-split-active .map-stage {
  flex: 1 1 50%;
  min-width: 0;
}

.strategy-drawer {
  flex: 1 1 50%;
  min-width: 0;
  height: 100%;
  background: #f8fafc;
  border-left: 1px solid #cbd5e1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 500;
}

.strategy-drawer.hidden {
  display: none;
}

.sd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
  color: #ffffff;
  flex-shrink: 0;
}

.sd-kicker {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #93c5fd;
  letter-spacing: 0.02em;
}

.sd-title {
  font-family: 'Prompt', 'Sarabun', sans-serif;
  font-size: 19px;
  font-weight: 700;
  margin: 2px 0 0;
  color: #ffffff;
}

.sd-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sd-header .icon-btn-sm {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.25);
}

.sd-header .icon-btn-sm:hover {
  background: rgba(255, 255, 255, 0.25);
}

.sd-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sd-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.sd-kpi-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 11px;
  padding: 10px 12px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.sd-kpi-label {
  display: block;
  font-size: 11px;
  color: #64748b;
  font-weight: 600;
}

.sd-kpi-value {
  display: block;
  font-family: 'Prompt', 'Sarabun', sans-serif;
  font-size: 19px;
  font-weight: 700;
  color: #0f172a;
  margin-top: 2px;
  line-height: 1.2;
}

.sd-kpi-sub {
  display: block;
  font-size: 10.5px;
  color: #64748b;
  margin-top: 2px;
}

.sd-target-banner {
  background: linear-gradient(135deg, #eff6ff 0%, #e0f2fe 100%);
  border: 1px solid #93c5fd;
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.sd-target-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sd-target-title {
  font-size: 12px;
  font-weight: 700;
  color: #1e40af;
}

.sd-target-big {
  font-family: 'Prompt', 'Sarabun', sans-serif;
  font-size: 26px;
  font-weight: 700;
  color: #1d4ed8;
  line-height: 1.1;
}

.sd-target-compare {
  font-size: 11.5px;
  color: #334155;
}

.sd-section-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.sd-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.sd-section-head h3 {
  font-family: 'Prompt', 'Sarabun', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

.sd-section-hint {
  font-size: 11px;
  color: #64748b;
}

.sd-area-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.sd-area-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
  width: 100%;
}

.sd-area-row:hover {
  background: #eff6ff;
  border-color: #60a5fa;
  transform: translateX(2px);
}

.sd-area-row.active {
  background: #eff6ff;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.sd-area-rank {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #334155;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sd-area-main {
  flex: 1;
  min-width: 0;
}

.sd-area-name {
  font-family: 'Prompt', 'Sarabun', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  display: block;
}

.sd-area-meta {
  font-size: 11px;
  color: #64748b;
  display: block;
}

.sd-area-scores {
  text-align: right;
  flex-shrink: 0;
}

.sd-area-target {
  font-family: 'Prompt', 'Sarabun', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #1d4ed8;
  display: block;
}

.sd-area-prev {
  font-size: 11px;
  color: #ea580c;
  font-weight: 600;
  display: block;
}

.sd-pain-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sd-pain-theme {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 4px solid #dc2626;
  border-radius: 9px;
  padding: 8px 10px;
}

.sd-pain-theme-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
}

.sd-pain-theme-title {
  font-family: 'Prompt', 'Sarabun', sans-serif;
  font-size: 12.5px;
  font-weight: 700;
  color: #b91c1c;
}

.sd-pain-theme-count {
  font-size: 10.5px;
  font-weight: 700;
  background: #fee2e2;
  color: #b91c1c;
  padding: 1px 7px;
  border-radius: 999px;
}

.sd-pain-theme-areas {
  font-size: 11.5px;
  color: #7c2d12;
  line-height: 1.4;
}

/* Collapsible Main Layer Nav Header */
.module-nav-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.module-nav-caption-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-collapse-nav {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  font-family: 'Prompt', 'Sarabun', sans-serif;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.14s ease;
}

.btn-collapse-nav:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}

.module-nav.is-collapsed .module-tab {
  display: none;
}

.module-nav.is-collapsed {
  padding-bottom: 8px;
}

/* Strategy Drawer Fixed 1/3 Width (Does Not Expand When Left Sidebar Collapses) */
.workspace.strategy-split-active .map-stage {
  flex: 1 1 auto;
  min-width: 0;
}

.strategy-drawer {
  flex: 0 0 33.333vw;
  width: 33.333vw;
  min-width: 340px;
  max-width: 500px;
}

.sd-kpi-card {
  padding: 8px 9px;
}

.sd-kpi-value {
  font-size: 16.5px;
}

.sd-target-big {
  font-size: 22px;
}

/* Floating Restore Sidebar Button (Left Edge with Right Arrow) */
.btn-show-sidebar-float {
  position: absolute;
  left: 12px;
  top: 94px;
  z-index: 650;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 13px 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(37, 99, 235, 0.35);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  color: #1d4ed8;
  font-family: 'Prompt', 'Sarabun', sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.16);
  cursor: pointer;
  transition: all 0.16s ease;
}

.btn-show-sidebar-float:hover {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
  transform: translateX(2px);
}

.btn-show-sidebar-float.hidden {
  display: none;
}

/* Split Election 2569 (Left) vs Target Votes (Right) in Strategy Drawer */
.sd-score-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.sd-prev69-box {
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
  border: 1px solid #fdba74;
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 3px;
}

.sd-prev69-label {
  font-size: 11.5px;
  font-weight: 700;
  color: #c2410c;
}

.sd-prev69-big {
  font-family: 'Prompt', 'Sarabun', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: #ea580c;
  line-height: 1.15;
}

.sd-prev69-sub {
  font-size: 11px;
  font-weight: 600;
  color: #9a3412;
}

.sd-target-box-half {
  background: linear-gradient(135deg, #eff6ff 0%, #e0f2fe 100%);
  border: 1px solid #93c5fd;
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 3px;
}

.sd-target-half-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  flex-wrap: wrap;
}

.sd-target-half-head .dp-toggle-btn {
  padding: 2px 7px;
  font-size: 10.5px;
}

/* Collapsible District Election 69 Dropdown in Strategy Drawer */
.sd-accordion-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 0;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-family: 'Prompt', 'Sarabun', sans-serif;
}

.sd-accordion-btn h3 {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

.sd-accordion-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: #2563eb;
}

.sd-accordion-body {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #e2e8f0;
}

.sd-accordion-body.hidden {
  display: none;
}

/* Detail Card 2x Expand Mode (Only for Municipality/Local Admin Detail Card) */
.detail-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-expand-detail {
  height: 28px;
  padding: 0 9px;
  border-radius: 7px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #1e3a8a;
  font-family: 'Prompt', 'Sarabun', sans-serif;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.14s ease;
}

.btn-expand-detail:hover {
  background: #eff6ff;
  border-color: #60a5fa;
  color: #1d4ed8;
}

.detail-card.is-expanded-2x {
  position: fixed;
  left: 50%;
  top: 50%;
  right: auto;
  bottom: auto;
  transform: translate(-50%, -50%);
  width: min(860px, calc(100vw - 36px));
  max-width: calc(100vw - 36px);
  max-height: calc(100vh - 36px);
  padding: 26px 30px;
  z-index: 2000;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.38), 0 0 0 100vmax rgba(15, 23, 42, 0.42);
  border-radius: 18px;
}

.detail-card.is-expanded-2x .btn-expand-detail {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
  height: 36px;
  padding: 0 14px;
  font-size: 14px;
}

.detail-card.is-expanded-2x .detail-swatch {
  width: 24px;
  height: 24px;
  border-radius: 6px;
}

.detail-card.is-expanded-2x .detail-name-xl {
  font-size: 38px !important;
  line-height: 1.2;
}

.detail-card.is-expanded-2x .detail-profile-grid {
  gap: 12px;
  margin-bottom: 16px;
}

.detail-card.is-expanded-2x .dp-item {
  padding: 12px 14px;
  border-radius: 12px;
}

.detail-card.is-expanded-2x .dp-label {
  font-size: 15px;
}

.detail-card.is-expanded-2x .dp-val {
  font-size: 21px;
}

.detail-card.is-expanded-2x .dp-prev-kamon-box {
  padding: 16px 18px;
  gap: 16px;
  margin-bottom: 14px;
  border-radius: 14px;
}

.detail-card.is-expanded-2x .dp-kamon-photo {
  width: 68px;
  height: 68px;
  border-width: 3px;
}

.detail-card.is-expanded-2x .dp-kamon-sub {
  font-size: 15px;
}

.detail-card.is-expanded-2x .dp-kamon-name {
  font-size: 22px;
}

.detail-card.is-expanded-2x .dp-kamon-meta {
  font-size: 16px;
}

.detail-card.is-expanded-2x .dp-kamon-score strong {
  font-size: 36px;
}

.detail-card.is-expanded-2x .dp-kamon-score span {
  font-size: 17px;
}

.detail-card.is-expanded-2x .dp-target-box {
  padding: 16px 18px;
  margin-bottom: 16px;
  border-radius: 14px;
}

.detail-card.is-expanded-2x .dp-target-label {
  font-size: 17px;
}

.detail-card.is-expanded-2x .dp-toggle-btn {
  font-size: 15px;
  padding: 5px 16px;
}

.detail-card.is-expanded-2x .dp-target-num {
  font-size: 40px;
}

.detail-card.is-expanded-2x .dp-target-unit {
  font-size: 20px;
}

.detail-card.is-expanded-2x .dp-pain-box {
  padding: 16px 18px;
  margin-bottom: 16px;
  border-radius: 14px;
  border-left-width: 6px;
}

.detail-card.is-expanded-2x .dp-pain-title {
  font-size: 22px;
}

.detail-card.is-expanded-2x .dp-pain-badge {
  font-size: 14px;
  padding: 3px 12px;
}

.detail-card.is-expanded-2x .dp-pain-list {
  padding-left: 24px;
  gap: 8px;
}

.detail-card.is-expanded-2x .dp-pain-list li {
  font-size: 19px;
}

.detail-card.is-expanded-2x .detail-election-title strong,
.detail-card.is-expanded-2x .detail-election-title span {
  font-size: 17px;
}

.detail-card.is-expanded-2x .ep-mini-photo {
  width: 38px;
  height: 38px;
}

.detail-card.is-expanded-2x .ep-score-label,
.detail-card.is-expanded-2x .ep-score-num {
  font-size: 16px;
}

.detail-card.is-expanded-2x .ep-bar-bg {
  height: 8px;
}

.detail-card.is-expanded-2x .ep-toggle-all-btn {
  font-size: 15px;
  padding: 8px 14px;
}

.detail-card.is-expanded-2x .ep-footer {
  font-size: 15px;
}

.detail-card.is-expanded-2x .detail-actions button,
.detail-card.is-expanded-2x .detail-actions a {
  height: 40px;
  font-size: 15px;
}
