/* ===== RESOURCE TRACKER — OXUS DESIGN LANGUAGE ===== */

:root {
  --accent: #00AA9B;
  --accent-hover: #009388;
  --text: #333;
  --text-sec: #555;
  --text-muted: #888;
  --border: #e0e0e0;
  --border-light: #eee;
  --bg: #fff;
  --bg-panel: #fafafa;
  --radius: 10px;
  --gauge-reserves: #94A3B8;
  --gauge-production: #00AA9B;
  --gauge-track: #e5e7eb;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  overflow: hidden; height: 100vh;
}

#app { display: flex; flex-direction: column; height: 100vh; }

/* ---- HEADER ---- */
#header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px; gap: 10px; flex-wrap: wrap;
  background: var(--bg); border-bottom: 1px solid var(--border);
  z-index: 1000; flex-shrink: 0;
}
#title-area { display: flex; align-items: center; gap: 10px; }
#title-area img { height: 32px; display: block; }
#title-text {
  font-size: 14px; font-weight: 700; color: var(--text);
  white-space: nowrap;
}
.title-accent { color: var(--accent); }

#header-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Mode toggle buttons */
#mode-buttons { display: flex; gap: 0; }
.mode-btn {
  padding: 5px 14px; border: 1.5px solid var(--border);
  background: var(--bg); color: var(--text-sec);
  font-family: inherit; font-size: 11px; font-weight: 600;
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.mode-btn:first-child { border-radius: 14px 0 0 14px; border-right: none; }
.mode-btn:last-child { border-radius: 0 14px 14px 0; }
.mode-btn:hover { border-color: var(--accent); color: var(--accent); }
.mode-btn.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.mode-btn.active + .mode-btn { border-left-color: var(--accent); }

/* Pill buttons */
.pill-btn {
  padding: 4px 14px; border: 1.5px solid #ccc; background: var(--bg); color: var(--text-sec);
  font-family: inherit; font-size: 11px; font-weight: 600; border-radius: 14px; cursor: pointer;
  transition: all 0.15s; white-space: nowrap;
}
.pill-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Info (?) button */
.info-btn {
  width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid #999;
  background: none; color: #999; font-size: 13px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; flex-shrink: 0; font-family: inherit;
}
.info-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---- MAIN AREA ---- */
#main { display: flex; flex: 1; min-height: 0; position: relative; }
#map { flex: 1; min-width: 0; background: #0a1f33; }
.leaflet-container { background: #0a1f33 !important; }

/* Resources mode: panel and map share space */
#main.mode-resources #panel { flex: 2; width: auto; min-width: 340px; max-width: 520px; }
#main.mode-resources #map { flex: 3; min-width: 300px; }
#main.mode-resources #panel-toggle { display: none; }

/* Flows mode: map dominates */
#main.mode-flows #panel { width: 340px; flex-shrink: 0; }
#main.mode-flows #map { flex: 1; }
#main.mode-flows #panel-toggle { display: flex; }

/* ---- SIDE PANEL ---- */
#panel {
  width: 340px; flex-shrink: 0; background: var(--bg-panel);
  border-left: 1px solid var(--border);
  overflow-y: auto; padding: 0; display: flex; flex-direction: column;
  scrollbar-width: thin;
}
#panel::-webkit-scrollbar { width: 4px; }
#panel::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

.panel-section { padding: 14px 16px; border-bottom: 1px solid var(--border-light); }
.panel-section:last-child { border-bottom: none; }

/* ---- PANEL: OVERVIEW STATS ---- */
.stat-big {
  font-size: 28px; font-weight: 800; color: var(--text); line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--text-muted); font-weight: 600; margin-bottom: 4px;
}
.stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.stat-row { margin-bottom: 12px; }

.section-title {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  color: #999; font-weight: 700; margin-bottom: 10px;
}
/* Country pills section */
.country-pills-section .filter-pills { flex-wrap: wrap; }

/* ---- BAR CHART ROWS ---- */
.bar-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 4px;
  cursor: pointer; padding: 6px 8px; border-radius: 4px; transition: background 0.1s;
}
.bar-row:hover { background: rgba(0, 170, 155, 0.06); }
.bar-row.active { background: rgba(0, 170, 155, 0.1); }
.bar-row.active .bar-label { color: var(--text); font-weight: 700; }
.bar-row[data-no-click] { cursor: default; }
.bar-label {
  font-size: 11px; color: var(--text-sec); width: 80px; flex-shrink: 0;
  font-weight: 600; text-align: right; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.bar-track {
  flex: 1; height: 14px; background: #f0f0f0; border-radius: 3px;
  overflow: hidden; position: relative;
}
.bar-fill {
  height: 100%; border-radius: 3px; transition: width 0.4s ease;
  min-width: 2px; background: var(--accent);
}
.bar-val {
  font-size: 10px; color: #777; width: 56px; flex-shrink: 0;
  text-align: right; font-weight: 500; font-variant-numeric: tabular-nums;
}

/* ---- RESOURCE INVENTORY (Resources View) ---- */
.panel-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 4px;
}
.panel-header h3 {
  font-size: 16px; font-weight: 700; color: var(--text); margin: 0;
}
.panel-close {
  background: none; border: none; font-size: 20px; cursor: pointer;
  color: var(--text-muted); line-height: 1; padding: 0 4px;
}
.panel-close:hover { color: var(--text); }

.panel-subtitle {
  font-size: 12px; color: var(--text-muted); margin-bottom: 12px;
}

.resource-group-header {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 8px 0 8px 8px; user-select: none;
  border-left: 3px solid transparent;
}
.resource-group-header.group-critical { border-left-color: #D97706; }
.resource-group-header.group-minerals { border-left-color: #94A3B8; }
.resource-group-header.group-chemicals { border-left-color: #7C3AED; }
.resource-group-header.group-hydrocarbons { border-left-color: #0E7490; }
.resource-group-header.group-agricultural { border-left-color: #16A34A; }
.resource-group-header:hover { color: var(--accent); }
.group-toggle {
  font-size: 10px; color: var(--text-muted); transition: transform 0.2s;
  display: inline-block; width: 12px;
}
.group-toggle.collapsed { transform: rotate(-90deg); }
.group-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.8px; color: var(--text-sec);
}
.group-count {
  font-size: 10px; color: var(--text-muted); font-weight: 500;
}
.resource-group-body { overflow: hidden; }
.resource-group-body.collapsed { display: none; }

/* Individual resource cards */
.resource-card {
  padding: 10px 10px 10px 12px;
  border-bottom: 1px solid var(--border-light);
  border-left: 3px solid transparent;
  transition: background 0.1s;
  border-radius: 0 6px 6px 0;
  margin-bottom: 4px;
}
.resource-card:last-child { border-bottom: none; }
.resource-card.clickable { cursor: pointer; }
.resource-card.clickable:hover { background: rgba(0, 170, 155, 0.04); }
.resource-card.muted { opacity: 0.5; }

.resource-name {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.resource-name-left {
  display: flex; align-items: center; gap: 8px; min-width: 0;
}
.resource-name-left > span:not(.element-badge) { font-size: 13px; font-weight: 600; color: var(--text); }

/* Country tag on resource cards (shown when multiple countries selected) */
.country-tag {
  display: inline-block; font-size: 8px; font-weight: 700;
  color: #fff; padding: 1px 5px; border-radius: 3px;
  margin-left: 6px; vertical-align: middle;
  letter-spacing: 0.5px;
}

/* Element badge (periodic table style) */
.element-badge {
  width: 30px; height: 30px; border-radius: 6px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: #fff;
  font-family: 'Barlow Condensed', 'Arial Narrow', monospace;
  letter-spacing: 0.5px; text-transform: none;
}

/* card-action footer on clickable resource cards */
.card-action {
  font-size: 11px; color: var(--accent); font-weight: 600;
  margin-top: 8px; opacity: 0.85;
}

/* Gauge fill (shared between old/new layouts) */
.gauge-fill {
  height: 100%; border-radius: 4px; transition: width 0.4s ease;
  min-width: 0;
}
.gauge-fill.reserves { background: var(--gauge-reserves); }
.gauge-fill.production { background: var(--gauge-production); }

/* Compact dual gauges */
.gauge-pair {
  display: flex; gap: 12px; margin: 6px 0;
}
.gauge-compact {
  flex: 1; min-width: 0;
}
.gauge-compact-label {
  font-size: 9px; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.5px; margin-bottom: 3px;
}
.gauge-compact-track {
  height: 6px; background: var(--gauge-track);
  border-radius: 3px; overflow: hidden;
}
.gauge-compact-value {
  font-size: 10px; font-weight: 600; color: var(--text-sec);
  margin-top: 2px; font-variant-numeric: tabular-nums;
}

/* Export preview */
.export-preview-label {
  font-size: 9px; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.5px; margin-top: 8px;
}
.export-preview {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 6px;
  font-size: 11px; margin-top: 3px; color: var(--text-sec);
}
.export-preview-value {
  font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.export-preview-arrow { color: var(--accent); font-weight: 600; }
.export-preview-dests {
  color: var(--text-muted); font-size: 10px;
  width: 100%; padding-left: 2px;
}
.export-preview-none { color: #bbb; font-style: italic; font-size: 10px; }

/* ---- EXPORT FLOWS VIEW PANEL ---- */
.filter-pills {
  display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px;
}
.filter-pill {
  padding: 3px 10px; border: 1.5px solid var(--border);
  background: var(--bg); color: var(--text-sec);
  font-family: inherit; font-size: 10px; font-weight: 600;
  border-radius: 12px; cursor: pointer; transition: all 0.15s;
}
.filter-pill:hover { border-color: var(--accent); color: var(--accent); }
.filter-pill.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}

/* Resource search */
.resource-search {
  width: 100%; padding: 7px 10px; border: 1.5px solid var(--border);
  border-radius: 6px; font-family: inherit; font-size: 12px;
  color: var(--text); background: var(--bg);
}
.resource-search:focus { outline: none; border-color: var(--accent); }
.resource-search::placeholder { color: #bbb; }

.resource-select {
  width: 100%; padding: 6px 10px; border: 1.5px solid var(--border);
  border-radius: 6px; font-family: inherit; font-size: 12px;
  color: var(--text); background: var(--bg); cursor: pointer;
  margin-bottom: 12px;
}
.resource-select:focus { outline: none; border-color: var(--accent); }

/* Country list (flows entry state) */
.country-list-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 4px; cursor: pointer; border-radius: 4px;
  transition: background 0.1s;
}
.country-list-item:hover { background: rgba(0, 170, 155, 0.06); }
.country-list-item.active {
  background: rgba(0, 170, 155, 0.08);
  font-weight: 600;
}
.country-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.country-list-name {
  font-size: 13px; font-weight: 500; color: var(--text);
}

/* Legend */
.legend-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.legend-line { height: 3px; border-radius: 2px; background: var(--accent); flex-shrink: 0; }
.legend-text { font-size: 10px; color: #666; }
.filter-hint { font-size: 10px; color: #aaa; font-style: italic; margin-top: 8px; }

/* Back navigation link */
.back-link {
  font-size: 11px; color: var(--accent); font-weight: 600;
  cursor: pointer; text-decoration: none;
}
.back-link:hover { text-decoration: underline; }

/* ---- PANEL TOGGLE ---- */
#panel-toggle {
  position: absolute; right: 340px; top: 8px; z-index: 900;
  width: 24px; height: 24px; border-radius: 4px 0 0 4px;
  background: var(--bg); border: 1px solid #ddd; border-right: none;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--text-muted); transition: all 0.2s;
  font-family: inherit;
}
#panel-toggle:hover { color: var(--accent); }
#panel-toggle.collapsed { right: 0; border-radius: 4px; border: 1px solid #ddd; }

/* ---- LOADING ---- */
#loading {
  position: fixed; inset: 0; background: rgba(255, 255, 255, 0.92);
  z-index: 3000; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
}
#loading.hidden { display: none; }
#loading-bar {
  width: 120px; height: 4px; background: #eee; border-radius: 2px; overflow: hidden;
}
#loading-bar::after {
  content: ''; display: block; width: 40%; height: 100%;
  background: var(--accent); border-radius: 2px;
  animation: loading-slide 1s ease-in-out infinite;
}
@keyframes loading-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}
#loading-text { font-size: 12px; color: var(--text-muted); font-weight: 600; }

/* ---- TOAST ---- */
#toast {
  display: none; position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(0, 170, 155, 0.92); color: #fff; padding: 8px 16px;
  border-radius: 6px; font-size: 12px; z-index: 1200;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* ---- MODAL ---- */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(15, 61, 56, 0.55);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  z-index: 2000; justify-content: center; align-items: center;
  padding: calc(64px + 20px) 20px calc(env(safe-area-inset-bottom, 0px) + 20px);
}
.modal-overlay.show { display: flex; animation: modal-fade 0.2s ease-out; }

@keyframes modal-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-container {
  background: var(--bg); border-radius: var(--radius); max-width: 520px; width: 90%;
  max-height: 100%; overflow-y: auto; box-shadow: 0 16px 48px rgba(0, 0, 0, 0.25);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border-light);
}
.modal-header h4 { font-size: 16px; color: var(--text); margin: 0; }
.modal-close {
  background: none; border: none; font-size: 22px; cursor: pointer; color: #999;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 16px 20px; font-size: 13px; line-height: 1.6; color: #444; }
.modal-body p { margin-bottom: 10px; }
.modal-body a { color: var(--accent); text-decoration: none; }
.modal-body a:hover { text-decoration: underline; }

/* ---- ABOUT MODAL (redesigned) ---- */
.modal-container--about {
  max-width: 560px; padding: 0; overflow: hidden; position: relative;
  display: flex; flex-direction: column;
  animation: modal-pop 0.24s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.modal-container--about .modal-hero,
.modal-container--about .modal-stats { flex-shrink: 0; }
.modal-container--about .modal-body {
  flex: 1 1 auto; overflow-y: auto; min-height: 0;
  -webkit-overflow-scrolling: touch;
}

@keyframes modal-pop {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close--floating {
  position: absolute; top: 12px; right: 14px; z-index: 3;
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.18); color: #fff;
  font-size: 20px; line-height: 1;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: background 0.15s, transform 0.15s;
}
.modal-close--floating:hover {
  background: rgba(255, 255, 255, 0.32); color: #fff; transform: scale(1.05);
}

.modal-hero {
  position: relative; overflow: hidden;
  padding: 28px 28px 22px;
  background: linear-gradient(135deg, #0F3D38 0%, #146B60 60%, #00AA9B 100%);
  color: #fff;
}

.modal-hero-pattern {
  position: absolute; inset: 0; pointer-events: none; opacity: 0.18;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.4) 0, transparent 30%),
    repeating-linear-gradient(45deg, transparent 0, transparent 14px, rgba(255, 255, 255, 0.08) 14px, rgba(255, 255, 255, 0.08) 15px);
}

.modal-kicker {
  position: relative;
  font-size: 10px; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: #F1D240;
  display: inline-block; margin-bottom: 10px;
}

.modal-title {
  position: relative;
  font-size: 24px; font-weight: 800; color: #fff;
  line-height: 1.15; margin: 0 0 8px; letter-spacing: -0.01em;
}
.modal-title-accent { color: #F1D240; }

.modal-subtitle {
  position: relative;
  font-size: 13px; color: rgba(255, 255, 255, 0.82);
  line-height: 1.5; margin: 0; max-width: 440px;
}

.modal-stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-light);
}
.modal-stat {
  padding: 16px 8px; text-align: center;
}
.modal-stat + .modal-stat { border-left: 1px solid var(--border-light); }
.modal-stat-value {
  font-size: 22px; font-weight: 800; color: var(--accent);
  line-height: 1; font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.modal-stat-label {
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-muted); font-weight: 600; margin-top: 6px;
}

.modal-container--about .modal-body {
  padding: 20px 28px 24px; font-size: 13px; color: #444; line-height: 1.6;
}
.modal-container--about .modal-body p { margin-bottom: 12px; }

.modal-project-link {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; margin: 14px 0 18px;
  background: rgba(0, 170, 155, 0.06);
  border: 1px solid rgba(0, 170, 155, 0.2);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  text-decoration: none !important;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.modal-project-link:hover {
  background: rgba(0, 170, 155, 0.1);
  border-color: rgba(0, 170, 155, 0.4);
  border-left-color: var(--accent);
  transform: translateX(2px);
}
.modal-project-link-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 700; color: var(--text-muted);
}
.modal-project-link-title {
  font-size: 13px; font-weight: 700; color: var(--accent);
  text-align: right;
}

.modal-sources {
  margin-top: 20px; padding-top: 16px;
  border-top: 1px solid var(--border-light);
}
.modal-sources-title {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-muted); font-weight: 700;
  margin: 0 0 10px;
}
.modal-sources p {
  font-size: 12px; color: var(--text-sec); line-height: 1.55;
  margin-bottom: 8px;
}
.modal-sources strong {
  color: var(--text); font-weight: 600;
}

.modal-footer-note {
  font-size: 11px; color: var(--text-muted);
  padding-top: 14px; margin-top: 14px;
  border-top: 1px solid var(--border-light);
  margin-bottom: 0 !important;
}

@media (max-width: 500px) {
  .modal-hero { padding: 22px 20px 18px; }
  .modal-title { font-size: 20px; }
  .modal-stats { grid-template-columns: repeat(3, 1fr); }
  .modal-stat { padding: 12px 4px; }
  .modal-stat-value { font-size: 18px; }
  .modal-container--about .modal-body { padding: 16px 20px 20px; }
  .modal-project-link { flex-direction: column; align-items: flex-start; gap: 4px; }
  .modal-project-link-title { text-align: left; }
}

/* ---- MAP COUNTRY LABELS ---- */
.country-map-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: rgba(255,255,255,0.95);
  text-shadow: 0 0 4px rgba(0,0,0,0.85), 0 0 4px rgba(0,0,0,0.85), 0 0 6px rgba(0,0,0,0.6);
  pointer-events: none; white-space: nowrap;
  text-align: center;
}

/* ---- HERO STATS ---- */
.hero-stats {
  display: flex; gap: 0; text-align: center;
}
.hero-stat {
  flex: 1; padding: 8px 4px;
}
.hero-stat + .hero-stat { border-left: 1px solid var(--border-light); }
.hero-stat-value {
  font-size: 22px; font-weight: 800; color: var(--text);
  line-height: 1.1; font-variant-numeric: tabular-nums;
}
.hero-stat-label {
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted); font-weight: 600; margin-top: 4px;
}

/* ---- POPUP OVERRIDES ---- */
.leaflet-popup-content-wrapper { border-radius: 8px; box-shadow: 0 3px 14px rgba(0, 0, 0, 0.18); }
.leaflet-popup-content { margin: 10px 14px; font-size: 12px; line-height: 1.5; }
.leaflet-popup-content b { color: var(--text); }

.popup-title { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 4px; }

.feature-table { width: 100%; border-collapse: collapse; margin-top: 4px; }
.feature-table td { padding: 4px 0; font-size: 11px; }
.feature-table .field-label { color: var(--text-sec); padding-right: 12px; }
.feature-table .field-value {
  text-align: right; font-weight: 600; color: var(--text);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.feature-table .total-row td {
  border-top: 1px solid var(--border-light); padding-top: 6px;
}

/* ---- DEST LABEL FIX ---- */
.dest-label { background: none !important; border: none !important; }

/* ---- RESPONSIVE ---- */

/* Tablet */
@media (max-width: 900px) {
  #main.mode-flows #panel { width: 300px; }
  #main.mode-resources #panel { max-width: 400px; }
  #panel-toggle { right: 300px; }
  #panel-toggle.collapsed { right: 0; }
}

/* Mobile */
@media (max-width: 700px) {
  #header { padding: 8px 10px; gap: 8px; }
  #title-text { font-size: 13px; }
  .mode-btn { padding: 10px 14px; font-size: 11px; min-height: 40px; }
  .info-btn { width: 40px; height: 40px; font-size: 15px; }
  .pill-btn { display: none; }
  #panel-toggle { display: none !important; }

  /* Touch targets for panel controls (panel visible on mobile) */
  .bar-row { padding: 10px 8px; margin-bottom: 2px; }
  .filter-pill { padding: 10px 14px; font-size: 11px; min-height: 36px; }
  .region-pill { padding: 10px 14px; font-size: 11px; min-height: 36px; }
  .resource-search { padding: 12px 12px; font-size: 13px; min-height: 44px; }
  .resource-select { padding: 12px 12px; font-size: 13px; min-height: 44px; }
  .resource-card { padding: 14px 12px 14px 14px; }
  .resource-group-header { padding: 12px 8px; }

  /* RESOURCES mode: hide map, panel is full-screen data browser */
  #main.mode-resources #map { display: none; }
  #main.mode-resources #panel {
    flex: 1 !important; width: 100% !important; max-width: none !important;
    min-width: unset !important; border-left: none !important;
    overflow-y: auto !important; position: static !important;
    display: flex !important; box-shadow: none !important;
    border-radius: 0 !important;
    padding-bottom: max(env(safe-area-inset-bottom, 0px), 48px);
  }

  /* FLOWS mode: vertical stack — controls above map, panel below */
  #main.mode-flows { flex-direction: column; }
  #main.mode-flows #map {
    display: block !important; flex: 1 !important; min-height: 0;
    order: 2;
  }
  #main.mode-flows #panel {
    position: static !important;
    width: 100% !important; max-width: none !important;
    min-width: unset !important;
    max-height: 40vh;
    border-left: none !important;
    border-top: 1px solid var(--border);
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow-y: auto !important;
    z-index: auto;
    display: flex !important; flex-direction: column;
    background: var(--bg-panel);
    order: 3;
    padding-bottom: max(env(safe-area-inset-bottom, 0px), 48px);
  }

  /* Controls injected above the map */
  #mobile-flows-controls {
    order: 1; flex-shrink: 0;
    background: var(--bg); border-bottom: 1px solid var(--border);
  }

  /* Region picker */
  .region-picker {
    display: flex; gap: 4px; padding: 6px 10px;
    overflow-x: auto; white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    border-bottom: 1px solid var(--border);
  }
  .region-pill {
    padding: 4px 10px; font-size: 10px; font-weight: 600;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--bg); color: var(--text-sec);
    cursor: pointer; white-space: nowrap; flex-shrink: 0;
    font-family: inherit;
  }
  .region-pill.active {
    background: #0F3D38; color: #fff; border-color: #0F3D38;
  }

  /* Mobile filters toggle */
  .mobile-filters-toggle {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 12px; background: var(--bg);
    border-bottom: 1px solid var(--border-light);
    cursor: pointer; -webkit-user-select: none; user-select: none;
  }
  .mobile-filters-toggle span:first-child {
    font-size: 11px; font-weight: 600; color: var(--text-sec);
  }
  .mobile-filters-toggle .chevron {
    font-size: 10px; color: var(--text-muted);
    transition: transform 0.2s;
  }
  .mobile-filters-toggle.expanded .chevron {
    transform: rotate(180deg);
  }
  .mobile-filters-body {
    display: none; padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
  }
  .mobile-filters-body.show { display: block; }

  /* When detail card is showing, panel becomes a fixed overlay */
  #main.mode-flows #panel.showing-detail {
    position: fixed !important;
    bottom: 0; left: 0; right: 0;
    max-height: 60vh;
    z-index: 1200;
    border-radius: 12px 12px 0 0 !important;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.2) !important;
  }

  /* Destination detail card */
  .dest-detail-card {
    background: var(--bg); border-top: 2px solid var(--accent);
    padding: 10px 12px;
    padding-bottom: max(env(safe-area-inset-bottom, 0px), 48px);
  }
  .dest-detail-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 8px;
  }
  .dest-detail-title { font-size: 13px; font-weight: 700; }
  .dest-detail-subtitle { font-size: 10px; color: var(--text-muted); }
  .dest-detail-close {
    font-size: 18px; color: var(--text-muted); cursor: pointer;
    padding: 4px 8px; border: none; background: none; font-family: inherit;
  }
  .dest-detail-row {
    display: flex; align-items: center; gap: 6px;
    padding: 5px 0; border-bottom: 1px solid var(--border-light);
  }
  .dest-detail-row:last-child { border-bottom: none; }
  .dest-detail-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; border-radius: 4px;
    color: #fff; font-size: 9px; font-weight: 700; flex-shrink: 0;
  }
  .dest-detail-name { font-size: 11px; flex: 1; }
  .dest-detail-value { font-size: 11px; font-weight: 600; }

  /* Mobile country pills in controls bar (compact) */
  .mobile-country-pills {
    display: flex; gap: 4px; padding: 6px 10px;
    overflow-x: auto; white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  /* Hide the FAB mobile panel button */
  .mobile-panel-btn { display: none !important; }

  /* No bottom sheet clearance needed */
  .leaflet-bottom { bottom: 4px !important; }

  /* Hero stats */
  .hero-stat-value { font-size: 18px; }
  .hero-stat-label { font-size: 8px; }

  /* Resource cards */
  .resource-card { padding: 12px 10px 12px 12px; }

  /* Bar rows: larger touch targets */
  .bar-row { padding: 8px 8px; margin-bottom: 2px; }
  .bar-label { width: 90px; font-size: 12px; }
  .bar-val { width: 52px; }

  /* Country pills wrap tighter */
  .filter-pill { padding: 4px 8px; font-size: 10px; }

}

