/* ===== ARMS FLOWS — OXUS DESIGN LANGUAGE ===== */

:root {
  --accent: #00AA9B;
  --accent-hover: #009388;
  --text: #333;
  --text-sec: #555;
  --text-muted: #888;
  --border: #e0e0e0;
  --border-light: #eee;
  --bg: #fff;
  --radius: 10px;
}

* { margin:0; padding:0; box-sizing:border-box; }
body { font-family: 'Segoe UI', -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; }
#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; }

/* Year slider group */
#slider-group { display:flex; align-items:center; gap:6px; }
#year-label { font-size:12px; font-weight:700; color:var(--accent); min-width:32px; }
#year-slider {
  -webkit-appearance:none; width:120px; height:4px; border-radius:2px;
  background:#ddd; outline:none;
}
#year-slider::-webkit-slider-thumb {
  -webkit-appearance:none; width:16px; height:16px; border-radius:50%;
  background:var(--accent); cursor:pointer; box-shadow:0 1px 3px rgba(0,0,0,0.3);
}
#year-slider::-moz-range-thumb {
  width:16px; height:16px; border-radius:50%; background:var(--accent);
  cursor:pointer; border:none;
}

/* Pill buttons */
.pill-btn {
  padding:4px 14px; border:1.5px solid #ccc; background:var(--bg); color:var(--text-sec);
  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;
}
.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; }

/* ---- SIDE PANEL ---- */
#panel {
  width:340px; flex-shrink:0; background:#fafafa; 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-title {
  font-size:14px; font-weight:700; color:var(--text); margin-bottom:12px;
}
#panel-year { color:var(--accent); }

.stat-big { font-size:28px; font-weight:800; color:var(--text); line-height:1.1; }
.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;
}

/* Bar chart rows */
.bar-row {
  display:flex; align-items:center; gap:8px; margin-bottom:7px;
  cursor:pointer; padding:3px 4px; 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-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:52px; flex-shrink:0; text-align:right; font-weight:500; font-variant-numeric:tabular-nums; }

/* 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; }
.origin-filter-hint { font-size:10px; color:#aaa; font-style:italic; margin-top:8px; }

/* Panel toggle button */
#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;
}
#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(0,0,0,0.45);
  z-index:2000; justify-content:center; align-items:center;
}
.modal-overlay.show { display:flex; }
.hidden { display:none !important; }

.modal-container {
  background:var(--bg); border-radius:var(--radius); max-width:520px; width:90%;
  max-height:75vh; 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; }

/* ---- 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:6px; }

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

/* ---- RESPONSIVE ---- */
@media (max-width:700px) {
  #panel { display:none; }
  #panel-toggle { display:none; }
  #header { padding:6px 10px; }
  #title-text { font-size:12px; }
  .pill-btn { padding:3px 8px; font-size:10px; }
  #year-slider { width:80px; }
  #panel-toggle-btn { display:none; }
}
