/* ============================================
   STK Platform — Design Tokens
   ============================================ */
:root {
  /* Background layers */
  --bg-base: #07090f;
  --bg-canvas: #0b0f18;
  --bg-surface: #131824;
  --bg-surface-2: #1a2030;
  --bg-elevated: #1f2638;
  --bg-hover: #232b40;

  /* Borders */
  --border-soft: rgba(255, 255, 255, 0.06);
  --border-medium: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.16);

  /* Text */
  --text-primary: #e8ecf4;
  --text-secondary: #9aa3b8;
  --text-tertiary: #6b7388;
  --text-disabled: #4a5165;

  /* Brand */
  --brand: #4d9fff;
  --brand-strong: #2b7dff;
  --brand-soft: rgba(77, 159, 255, 0.12);
  --brand-glow: rgba(77, 159, 255, 0.35);

  /* Status */
  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.12);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.12);
  --info: #06b6d4;
  --info-soft: rgba(6, 182, 212, 0.12);

  /* Spacing */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 24px var(--brand-glow);
  --focus-ring: rgba(77, 159, 255, 0.38);
  --text-on-brand: #f7fbff;

  /* Fonts */
  --font-sans: 'IBM Plex Sans', 'IBM Plex Sans Thai', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

#root { height: 100vh; width: 100vw; }

/* Subtle background grid + gradient atmosphere */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 15% 0%, rgba(77, 159, 255, 0.08), transparent 50%),
    radial-gradient(ellipse at 85% 100%, rgba(16, 185, 129, 0.04), transparent 50%);
  z-index: 0;
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.12); background-clip: padding-box; }

/* ============================================
   App shell layout
   ============================================ */
.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  height: 100vh;
  position: relative;
  z-index: 1;
}

.sidebar {
  background: var(--bg-canvas);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-base);
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
}

/* ============================================
   Sidebar
   ============================================ */
.brand {
  padding: 20px 20px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-soft);
}

.brand-mark {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand) 0%, #1e5fd9 100%);
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  color: white;
  box-shadow: 0 4px 14px rgba(77, 159, 255, 0.4), inset 0 1px 0 rgba(255,255,255,0.2);
  position: relative;
  overflow: hidden;
}
.brand-mark::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 40%, rgba(255,255,255,0.2) 50%, transparent 60%);
}
.brand-name {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.02em;
}
.brand-sub {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

.nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
  padding: 12px 12px 6px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s ease;
  position: relative;
  user-select: none;
}
.nav-item:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}
.nav-item.active {
  background: linear-gradient(90deg, var(--brand-soft), transparent);
  color: var(--text-primary);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 2px;
  background: var(--brand);
  border-radius: 2px;
  box-shadow: 0 0 8px var(--brand-glow);
}
.nav-item.active .nav-icon { color: var(--brand); }
.nav-item .nav-icon {
  width: 16px; height: 16px;
  flex-shrink: 0;
  transition: color 0.15s;
}
.nav-item .nav-count {
  margin-left: auto;
  font-size: 11px;
  font-family: var(--font-mono);
  background: var(--bg-surface);
  padding: 2px 7px;
  border-radius: 10px;
  color: var(--text-tertiary);
}
.nav-item.active .nav-count {
  background: var(--brand-soft);
  color: var(--brand);
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-soft);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  cursor: pointer;
  transition: background 0.15s;
}
.user-card:hover { background: var(--bg-hover); }
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: grid; place-items: center;
  font-size: 12px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 500; }
.user-role { font-size: 11px; color: var(--text-tertiary); font-family: var(--font-mono); }

/* ============================================
   Topbar
   ============================================ */
.topbar {
  height: 56px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  background: rgba(11, 15, 24, 0.6);
  backdrop-filter: blur(12px);
  position: relative;
  z-index: 10;
}

.crumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}
.crumb-current { color: var(--text-primary); font-weight: 500; }
.crumb-sep { color: var(--text-disabled); }

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.search {
  width: 280px;
  position: relative;
}
.search input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  padding: 7px 12px 7px 32px;
  border-radius: var(--radius-md);
  outline: none;
  transition: all 0.15s;
}
.search input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.search input::placeholder { color: var(--text-tertiary); }
.search .search-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  color: var(--text-tertiary);
}
.search .kbd {
  position: absolute;
  right: 8px; top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 5px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-medium);
  border-radius: 4px;
  color: var(--text-tertiary);
}

.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-soft);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
  position: relative;
}
.icon-btn:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-medium);
  transform: translateY(-1px);
}
.icon-btn:active {
  transform: translateY(0);
}
.icon-btn:focus-visible {
  outline: none;
  border-color: rgba(77, 159, 255, 0.65);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.icon-btn:disabled,
.icon-btn[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}
.icon-btn .dot {
  position: absolute;
  top: 7px; right: 8px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--bg-base);
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease, filter 0.16s ease;
  white-space: nowrap;
  user-select: none;
  position: relative;
  vertical-align: middle;
}
.btn svg {
  flex: 0 0 auto;
  stroke-width: 2.1;
}
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.btn:disabled,
.btn[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.46;
  pointer-events: none;
  filter: saturate(0.65);
  transform: none;
}
.btn-primary {
  background: linear-gradient(180deg, #58a7ff 0%, var(--brand-strong) 100%);
  color: var(--text-on-brand);
  border-color: rgba(119, 185, 255, 0.48);
  box-shadow: 0 1px 0 rgba(255,255,255,0.18) inset, 0 1px 2px rgba(0,0,0,0.35), 0 0 0 1px rgba(77,159,255,0.28);
}
.btn-primary:hover {
  filter: brightness(1.06);
  border-color: rgba(139, 197, 255, 0.72);
  box-shadow: 0 1px 0 rgba(255,255,255,0.18) inset, 0 6px 16px rgba(43,125,255,0.32), 0 0 0 1px rgba(77,159,255,0.48);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); filter: brightness(0.98); }
.btn-secondary {
  background: linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.015));
  color: var(--text-primary);
  border-color: var(--border-medium);
  box-shadow: 0 1px 0 rgba(255,255,255,0.06) inset, 0 1px 2px rgba(0,0,0,0.18);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: 0 1px 0 rgba(255,255,255,0.07) inset, 0 4px 12px rgba(0,0,0,0.24);
}
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-soft);
}
.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.48);
  transform: translateY(-1px);
}
.btn-secondary:active,
.btn-ghost:active,
.btn-danger:active {
  transform: translateY(0);
}
.btn-sm {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 12px;
  gap: 6px;
}
.btn-icon {
  width: 36px;
  padding: 8px;
}
.btn-sm.btn-icon {
  width: 30px;
  min-height: 30px;
  padding: 6px;
}

/* ============================================
   Cards & Panels
   ============================================ */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.2s;
}
.card:hover { border-color: var(--border-medium); }
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.card-subtitle {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}
.card-body { padding: 20px; }

/* ============================================
   Typography helpers
   ============================================ */
.page-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}
.page-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 4px 0 0 0;
}
.section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-tertiary);
  font-weight: 600;
}
.mono { font-family: var(--font-mono); }

/* ============================================
   Stat tiles
   ============================================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.stat {
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 18px;
  position: relative;
  overflow: hidden;
  transition: all 0.2s;
}
.stat::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent);
  pointer-events: none;
}
.stat:hover {
  border-color: var(--border-medium);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.stat-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  margin-bottom: 14px;
  background: var(--brand-soft);
  color: var(--brand);
}
.stat-icon.success { background: var(--success-soft); color: var(--success); }
.stat-icon.warning { background: var(--warning-soft); color: var(--warning); }
.stat-icon.danger { background: var(--danger-soft); color: var(--danger); }
.stat-icon.info { background: var(--info-soft); color: var(--info); }
.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}
.stat-value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 2px;
  font-family: var(--font-mono);
}
.stat-delta {
  font-size: 11px;
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.stat-delta.up { color: var(--success); }
.stat-delta.down { color: var(--danger); }

/* ============================================
   Tables
   ============================================ */
.table-wrap {
  overflow-x: auto;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th {
  text-align: left;
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-canvas);
  position: sticky;
  top: 0;
}
.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
.table tbody tr { transition: background 0.1s; }
.table tbody tr:hover { background: var(--bg-surface-2); }
.table tbody tr:last-child td { border-bottom: none; }

/* ============================================
   Badges & Pills
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 99px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}
.badge .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-brand { background: var(--brand-soft); color: var(--brand); }

.live-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 var(--success);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
  70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ============================================
   Form
   ============================================ */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}
.input, .select, .textarea {
  background: var(--bg-canvas);
  border: 1px solid var(--border-medium);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 13px;
  outline: none;
  transition: all 0.15s;
  width: 100%;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.textarea { resize: vertical; min-height: 80px; font-family: inherit; }
.select {
  appearance: none;
  background-image: 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='%239aa3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

/* ============================================
   Tabs (in-page)
   ============================================ */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 20px;
}
.tab {
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.tab:hover { color: var(--text-primary); }
.tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--brand);
}
.tab .tab-count {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-surface);
  padding: 1px 6px;
  border-radius: 99px;
}
.tab.active .tab-count {
  background: var(--brand-soft);
  color: var(--brand);
}

/* ============================================
   Misc
   ============================================ */
.divider {
  height: 1px;
  background: var(--border-soft);
  border: none;
  margin: 16px 0;
}

.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-surface), var(--bg-hover), var(--bg-surface));
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Page transition */
.page-enter {
  animation: pageEnter 0.3s ease-out;
}
@keyframes pageEnter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Tooltip-y small text */
.hint { font-size: 11px; color: var(--text-tertiary); }

/* Toggle */
.toggle {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--bg-elevated);
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--text-secondary);
  transition: all 0.2s ease;
}
.toggle.on { background: var(--brand); }
.toggle.on::after { left: 18px; background: white; }

/* Progress bar */
.progress {
  width: 100%;
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), #5ec8ff);
  border-radius: 99px;
  transition: width 0.6s ease;
}
.progress-fill.success { background: linear-gradient(90deg, var(--success), #4ade80); }
.progress-fill.warning { background: linear-gradient(90deg, var(--warning), #fbbf24); }
.progress-fill.danger { background: linear-gradient(90deg, var(--danger), #f87171); }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 9, 15, 0.75);
  backdrop-filter: blur(8px);
  /* Must be above Leaflet's max pane z-index (700) so modal renders ABOVE any map */
  z-index: 1000;
  display: grid;
  place-items: center;
  animation: fadeIn 0.2s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  width: min(560px, 92vw);
  max-height: 88vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-body { padding: 22px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--bg-canvas);
}

/* Drawer (right slide) */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 9, 15, 0.6);
  backdrop-filter: blur(4px);
  /* Must be above Leaflet's max pane z-index (700) so the drawer hides any map underneath */
  z-index: 1000;
  animation: fadeIn 0.2s ease-out;
}
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(520px, 92vw);
  /* Force fully opaque so map tiles/markers can't bleed through */
  background: var(--bg-surface);
  background-color: #131824; /* solid fallback in case --bg-surface is overridden */
  border-left: 1px solid var(--border-medium);
  box-shadow: var(--shadow-lg);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  animation: drawerIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  /* Create its own stacking context so nothing inside can bleed out */
  isolation: isolate;
}
@keyframes drawerIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

/* Map / chart placeholder */
.map-bg {
  background:
    linear-gradient(rgba(77,159,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(77,159,255,0.04) 1px, transparent 1px),
    radial-gradient(ellipse at 30% 40%, rgba(77,159,255,0.12), transparent 60%),
    radial-gradient(ellipse at 70% 60%, rgba(16,185,129,0.08), transparent 60%),
    var(--bg-canvas);
  background-size: 24px 24px, 24px 24px, auto, auto, auto;
}
.stk-location-pin {
  background: transparent;
  border: 0;
}
.stk-location-pin span {
  position: relative;
  width: 18px;
  height: 18px;
  display: block;
  border-radius: 50% 50% 50% 4px;
  background: var(--pin, var(--brand));
  border: 2px solid rgba(241, 248, 255, 0.95);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--pin, var(--brand)) 22%, transparent), 0 10px 22px rgba(0, 0, 0, 0.36);
  transform: rotate(-45deg);
}
.stk-location-pin span::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: rgba(248, 252, 255, 0.92);
}
/* Service-center variant: square rounded badge with a cross dot — visually distinct from warehouse teardrops */
.stk-location-pin--service span {
  border-radius: 5px;
  transform: rotate(0deg);
  width: 20px;
  height: 20px;
}
.stk-location-pin--service span::after {
  inset: 5px;
  border-radius: 2px;
  background: rgba(248, 252, 255, 0.95);
}

/* Hover lift */
.lift { transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease; }
.lift:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

/* Bar chart sparkline */
.sparkbar {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 36px;
}
.sparkbar span {
  flex: 1;
  background: linear-gradient(180deg, var(--brand), rgba(77,159,255,0.2));
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  transition: all 0.4s ease;
}

/* Connection line glow for live elements */
.glow-border {
  box-shadow: 0 0 0 1px var(--brand), 0 0 16px var(--brand-glow);
}
