/* =========================================================================
   Tehran Smart Traffic Light System — stylesheet
   RTL, dark theme. Adapted/extended from the earlier prototype's design
   language for the new whole-city FastAPI app (real OSM graph + TomTom).
   ========================================================================= */

:root {
  --bg: #0b1220;
  --panel: #121b2e;
  --panel-2: #16223b;
  --panel-3: #1b2740;
  --border: #23324f;
  --text: #e8edf7;
  --text-dim: #9fb0cc;
  --text-faint: #6f80a0;
  --accent: #22c55e;
  --accent-2: #38bdf8;
  --warn: #f59e0b;
  --danger: #ef4444;
  --purple: #a78bfa;
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: linear-gradient(180deg, #0b1220 0%, #0d1626 100%);
  color: var(--text);
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  min-height: 100%;
  direction: rtl;
}

body {
  max-width: 1500px;
  margin: 0 auto;
  padding: 16px 18px 44px;
  min-height: 100vh;
}

a { color: var(--accent-2); }

/* ---------------------------------------------------------------- Boot */
#boot-loading {
  position: fixed;
  inset: 0;
  background: #0b1220;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 9999;
  color: var(--text-dim);
  font-size: 14.5px;
  text-align: center;
  padding: 0 24px;
  transition: opacity .4s ease, visibility .4s ease;
}
#boot-loading.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.boot-spinner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 4px solid #23324f;
  border-top-color: var(--accent-2);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------- Header */
.app-header {
  padding: 6px 4px 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.app-header h1 {
  font-size: 21px;
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.3px;
}
.app-header .subtitle {
  color: var(--text-dim);
  font-size: 13px;
  margin: 8px 0 0;
  line-height: 1.9;
  max-width: 900px;
}
.status-pill {
  font-size: 13px;
  font-weight: 700;
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space: nowrap;
  transition: all .3s ease;
  align-self: flex-start;
}
.status-off { background: #241b1b; color: #f0a3a3; border-color: #52282a; }
.status-on  { background: #0f2b1c; color: #7bf0ac; border-color: #1f5c39; box-shadow: 0 0 18px -4px #22c55e88; }

.header-pills { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }

/* --------------------------------------------------------- TomTom indicator */
.tomtom-connected    { background: #0f2b1c; color: #7bf0ac; border-color: #1f5c39; }
.tomtom-degraded      { background: #2a2210; color: #f5d37b; border-color: #6b551f; }
.tomtom-disconnected  { background: #241b1b; color: #f0a3a3; border-color: #52282a; }
.tomtom-unknown       { background: #1b2233; color: #9fb0cc; border-color: #2b3a5c; }

/* --------------------------------------------------------- Autonomous banner */
.autonomous-status {
  background: var(--panel-2);
  border: 1px solid var(--purple);
  color: #d9cdfa;
  font-size: 12px;
  padding: 8px 14px;
  border-radius: 10px;
  margin: -6px 0 12px;
  line-height: 1.8;
}

/* ------------------------------------------------------------- Controls */
.control-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: stretch;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-content: center;
}
.control-group label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
}
.control-group:first-child { flex: 1 1 300px; }

.algo-toggle-btn {
  display: block;
  background: linear-gradient(135deg, #1b2740, #172033);
  border: 1.5px solid #2b3a5c;
  color: var(--text);
  padding: 12px 18px;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.9;
  transition: all .25s ease;
  width: 100%;
  text-align: center;
}
.algo-toggle-btn:hover { border-color: var(--accent-2); }
.algo-toggle-btn small { color: var(--text-dim); font-size: 11px; font-weight: 400; }
.algo-toggle-btn.is-on {
  background: linear-gradient(135deg, #0f2b1c, #0c2117);
  border-color: #2f7d51;
  box-shadow: 0 0 24px -6px #22c55e77;
}
.algo-toggle-btn.is-on small { color: #b7e6c9; }

#weather-select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 13px;
  min-width: 190px;
  font-family: inherit;
}

.speed-buttons { display: flex; gap: 6px; }
.speed-btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  transition: all .2s ease;
}
.speed-btn.active { background: var(--accent-2); color: #06202f; border-color: var(--accent-2); font-weight: 700; }

.reset-btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.8;
  transition: all .2s ease;
}
.reset-btn:hover { color: var(--text); border-color: var(--accent-2); }

/* traffic-light layers control */
.signals-group { min-width: 220px; }
.signals-toggle-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}
.signals-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  font-weight: 400;
}
.signals-checkbox input { accent-color: var(--accent-2); cursor: pointer; }
.add-signal-btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12.5px;
  transition: all .2s ease;
}
.add-signal-btn:hover { color: var(--text); border-color: #ec4899; }
.add-signal-btn.is-active {
  background: #2c1327;
  border-color: #ec4899;
  color: #fbc7e6;
  box-shadow: 0 0 16px -4px #ec489988;
}

/* routes (congestion polyline) toggle group */
.routes-group { min-width: 190px; }

/* zone-scoped algorithm testing group */
.zone-group { min-width: 240px; }
.zone-select-btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12.5px;
  transition: all .2s ease;
}
.zone-select-btn:hover { color: var(--text); border-color: var(--accent-2); }
.zone-select-btn.is-active {
  background: #0e2636;
  border-color: var(--accent-2);
  color: #bff0ff;
  box-shadow: 0 0 16px -4px #38bdf888;
}
.zone-status {
  font-size: 11px;
  color: var(--text-dim);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  line-height: 1.8;
}
.zone-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.zone-clear-btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 11.5px;
  transition: all .2s ease;
}
.zone-clear-btn:hover:not(:disabled) { color: var(--text); border-color: var(--danger); }
.zone-clear-btn:disabled { opacity: 0.45; cursor: not-allowed; }
#zone-active-toggle:disabled { cursor: not-allowed; opacity: 0.45; }

.zone-select-hint {
  position: absolute;
  top: 12px;
  left: 14px;
  right: 14px;
  z-index: 490;
  background: rgba(14, 28, 42, 0.94);
  border: 1px solid #1f5c78;
  color: #bff0ff;
  font-size: 12.5px;
  line-height: 1.8;
  padding: 9px 13px;
  border-radius: 10px;
  backdrop-filter: blur(3px);
  text-align: center;
}

/* custom-signal popup form (inside Leaflet popup) */
.custom-signal-popup { font-family: 'Vazirmatn', Tahoma, sans-serif; direction: rtl; min-width: 210px; }
.custom-signal-popup h4 { margin: 0 0 8px; font-size: 13px; color: #1a2338; }
.custom-signal-popup input {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 6px;
  padding: 6px 8px;
  border: 1px solid #c7cede;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12.5px;
}
.custom-signal-popup button {
  width: 100%;
  padding: 7px 0;
  border-radius: 6px;
  border: none;
  background: #16a34a;
  color: #fff;
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  font-weight: 700;
}
.custom-signal-popup button:hover { background: #15803d; }
.custom-signal-popup .csp-delete {
  background: #dc2626;
  margin-top: 6px;
}
.custom-signal-popup .csp-delete:hover { background: #b91c1c; }

/* dataset export controls */
.dataset-group { min-width: 230px; }
.dataset-links {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
}
.dataset-links a {
  font-size: 12.5px;
  text-decoration: none;
  background: #0f2338;
  border: 1px solid #234061;
  color: var(--accent-2);
  padding: 6px 10px;
  border-radius: 7px;
  white-space: nowrap;
  transition: all .2s ease;
}
.dataset-links a:hover { border-color: var(--accent-2); color: #bff0ff; }
#dataset-stat {
  font-size: 11.5px;
  color: var(--text-dim);
  margin-inline-start: auto;
  white-space: nowrap;
}

/* --------------------------------------------------------- Scenario bar */
.scenario-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.scenario-panel h3 {
  font-size: 13.5px;
  margin: 0 0 10px;
  color: var(--text-dim);
  font-weight: 700;
}
.scenario-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.scenario-btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12.5px;
  transition: all .2s ease;
}
.scenario-btn:hover { border-color: var(--purple); }
.scenario-btn.active { border-color: var(--purple); background: #241a3b; box-shadow: 0 0 14px -4px #a78bfa88; }
.scenario-desc {
  color: var(--text-dim);
  font-size: 12.5px;
  margin: 10px 2px 0;
  line-height: 1.8;
  min-height: 18px;
}

/* ------------------------------------------------------------- Main grid */
.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, 0.9fr);
  gap: 14px;
  align-items: start;
}
@media (max-width: 980px) {
  .main-grid { grid-template-columns: 1fr; }
}

.map-section {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
#map {
  width: 100%;
  height: 640px;
  background: #0a1524;
  direction: ltr; /* leaflet internals expect LTR layout */
}

.map-legend {
  position: absolute;
  bottom: 14px;
  right: 14px;
  background: rgba(10, 16, 28, 0.9);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 11.5px;
  color: var(--text-dim);
  z-index: 500;
  backdrop-filter: blur(4px);
  max-width: 240px;
  line-height: 1.9;
}
.map-legend strong { display: block; color: var(--text); margin-bottom: 6px; font-size: 12.5px; }
.map-legend > div { display: flex; align-items: center; gap: 8px; }
.legend-dot {
  width: 12px; height: 12px; border-radius: 50%;
  display: inline-block; flex: none;
  border: 2px solid transparent;
}
.legend-low  { background: rgba(34,197,94,0.25); border-color: #22c55e; }
.legend-med  { background: rgba(245,158,11,0.25); border-color: #f59e0b; }
.legend-high { background: rgba(239,68,68,0.28); border-color: #ef4444; }
.legend-real { background: rgba(56,189,248,0.25); border-color: #38bdf8; }
.legend-real-exact { background: rgba(250,204,21,0.3); border-color: #facc15; }
.legend-custom { background: rgba(236,72,153,0.3); border-color: #ec4899; }
.legend-hint { color: var(--text-faint); font-size: 10.5px; margin-top: 4px; line-height: 1.7; }
.legend-line {
  width: 16px; height: 3px; border-radius: 2px;
  display: inline-block; flex: none;
}
.legend-line-low  { background: #22c55e; }
.legend-line-med  { background: #f59e0b; }
.legend-line-high { background: #ef4444; }

.add-signal-hint {
  position: absolute;
  top: 12px;
  left: 14px;
  right: 14px;
  z-index: 490;
  background: rgba(20, 30, 15, 0.94);
  border: 1px solid #3f7d2f;
  color: #c9f2b0;
  font-size: 12.5px;
  line-height: 1.8;
  padding: 9px 13px;
  border-radius: 10px;
  backdrop-filter: blur(3px);
  text-align: center;
}

#honesty-note {
  position: absolute;
  top: 12px;
  right: 14px;
  left: 14px;
  z-index: 480;
  background: rgba(36, 26, 22, 0.92);
  border: 1px solid #6b4a28;
  color: #f3cf9a;
  font-size: 11.5px;
  line-height: 1.8;
  padding: 9px 13px;
  border-radius: 10px;
  backdrop-filter: blur(3px);
}

/* --------------------------------------------------------------- Sidebar */
.sidebar { display: flex; flex-direction: column; gap: 12px; }

.reduction-banner {
  background: linear-gradient(135deg, #0f2b1c, #0c2117);
  border: 1px solid #2f7d51;
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  transition: opacity .4s ease, transform .4s ease;
}
.reduction-banner.is-idle { opacity: 0.55; }
.reduction-pct { font-size: 34px; font-weight: 800; color: #7bf0ac; line-height: 1; }
.reduction-label { color: #b7e6c9; font-size: 12px; margin-top: 6px; }

.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.kpi-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}
.kpi-card .kpi-label { font-size: 11.5px; color: var(--text-dim); margin-bottom: 6px; }
.kpi-card .kpi-value { font-size: 18px; font-weight: 800; }
.kpi-card .kpi-sub { font-size: 10.5px; color: var(--text-dim); margin-top: 4px; line-height: 1.6; }
.kpi-good { color: var(--accent); }
.kpi-bad  { color: var(--danger); }
.kpi-warn { color: var(--warn); }
.kpi-info { color: var(--accent-2); }

.chart-card, .event-log-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.chart-card h4, .event-log-card h4 {
  font-size: 12.5px;
  margin: 0 0 10px;
  color: var(--text-dim);
  font-weight: 700;
}

#event-log {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  max-height: 230px;
  overflow-y: auto;
}
.log-item {
  border-right: 3px solid var(--accent-2);
  padding: 6px 10px;
  background: var(--panel-2);
  border-radius: 6px;
  color: var(--text-dim);
  line-height: 1.7;
}
.log-item.log-warn   { border-right-color: var(--warn); }
.log-item.log-danger { border-right-color: var(--danger); }
.log-item.log-good   { border-right-color: var(--accent); }
.log-item time { color: var(--text-faint); font-size: 10.5px; margin-inline-start: 6px; }

/* --------------------------------------------------------------- Footer */
.app-footer {
  margin-top: 18px;
  color: var(--text-faint);
  font-size: 11.5px;
  text-align: center;
  line-height: 1.9;
}

/* ------------------------------------------------------ Leaflet markers */
.traffic-light-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid #22c55e;
  background: rgba(10, 20, 35, 0.94);
  font-size: 15px;
  cursor: pointer;
  transition: all .25s ease;
  box-shadow: 0 0 0 4px rgba(34,197,94,0.15);
  position: relative;
}
.traffic-light-icon.level-medium { border-color: #f59e0b; box-shadow: 0 0 0 4px rgba(245,158,11,0.18); }
.traffic-light-icon.level-high   { border-color: #ef4444; box-shadow: 0 0 0 4px rgba(239,68,68,0.2); }
.traffic-light-icon.has-real-signal { border-style: double; }
/* outer ring reflects traffic TIER (priority), independent of the inner border
   which reflects live QUEUE level set by .level-medium/.level-high above */
.traffic-light-icon { outline: 2px solid var(--tier-color, transparent); outline-offset: 3px; }
.traffic-light-icon.algo-forced-on  { box-shadow: 0 0 0 4px rgba(34,197,94,0.35), 0 0 14px -2px #22c55eaa; }
.traffic-light-icon.algo-forced-off { box-shadow: 0 0 0 4px rgba(159,176,204,0.3); filter: saturate(0.6); }
.traffic-light-icon.out-of-zone { opacity: 0.45; filter: grayscale(0.4); }
.traffic-light-icon:hover { transform: scale(1.18); z-index: 650 !important; }
.traffic-light-icon .badge-count {
  position: absolute;
  bottom: -8px;
  left: -6px;
  background: #0b1220;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 9.5px;
  border-radius: 999px;
  padding: 1px 5px;
  font-weight: 700;
  direction: ltr;
}
.traffic-light-icon .ped-flag {
  position: absolute;
  top: -10px;
  right: -8px;
  font-size: 13px;
  animation: pulse 1s infinite;
}
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.3); } }

/* ---------------------------------------------- Real (OSM) signal markers */
.real-signal-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2.5px solid #facc15;
  background: rgba(10, 20, 35, 0.94);
  font-size: 13px;
  cursor: pointer;
  transition: all .25s ease;
  box-shadow: 0 0 0 3px rgba(250,204,21,0.18);
}
.real-signal-icon:hover { transform: scale(1.2); z-index: 640 !important; }

.real-signal-cluster {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2.5px solid #facc15;
  background: rgba(10, 20, 35, 0.94);
  color: #facc15;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 0 0 4px rgba(250,204,21,0.16);
}

/* --------------------------------------------- Custom (user) signal markers */
.custom-signal-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2.5px solid #ec4899;
  background: rgba(10, 20, 35, 0.94);
  font-size: 14px;
  cursor: pointer;
  transition: all .25s ease;
  box-shadow: 0 0 0 3px rgba(236,72,153,0.2);
}
.custom-signal-icon:hover { transform: scale(1.2); z-index: 640 !important; }

/* Marker cluster overrides -> match dark theme instead of Leaflet default lime */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background-clip: padding-box;
}
.marker-cluster-small div  { background-color: rgba(34,197,94,0.55); }
.marker-cluster-medium div { background-color: rgba(245,158,11,0.6); }
.marker-cluster-large div  { background-color: rgba(239,68,68,0.65); }
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background-color: rgba(18,27,46,0.55);
}
.marker-cluster div {
  border-radius: 50%;
  color: #0b1220;
  font-weight: 800;
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
}
.marker-cluster span { color: #071019; }

/* live TomTom flow tile layer: keep it slightly muted so our markers pop */
.tomtom-flow-layer { opacity: 0.85; }

/* -------------------------------------------------------------- Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 16, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  width: min(440px, 92vw);
  max-height: 88vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 20px 60px -10px rgba(0,0,0,0.6);
}
.modal-close {
  position: absolute;
  top: 12px;
  left: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
}
#modal-title { margin: 0 26px 6px 0; font-size: 15.5px; line-height: 1.7; }
.modal-phase {
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 10px;
  padding: 8px 12px;
  background: var(--panel-2);
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}
.modal-real-data {
  font-size: 11.5px;
  color: var(--text-dim);
  background: var(--panel-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 12px;
  line-height: 1.9;
}
.modal-real-data .src-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  margin-inline-start: 4px;
}
.modal-real-data .src-real { background: rgba(56,189,248,0.18); color: #7fd8ff; border: 1px solid #1f5c78; }
.modal-real-data .src-model { background: rgba(167,139,250,0.18); color: #cbb8fb; border: 1px solid #4a3a78; }

.modal-lanes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.lane-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
}
.lane-card .lane-dir { font-size: 11px; color: var(--text-dim); }
.lane-card .lane-count { font-size: 21px; font-weight: 800; margin: 4px 0; }
.lane-card.is-green { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(34,197,94,0.15); }
.lane-card .lane-street { font-size: 10.5px; color: var(--text-faint); }
.lane-card .lane-congestion { font-size: 10.5px; margin-top: 4px; font-weight: 600; }

/* --------------------------------------------------- Per-node algo control */
.algo-control-box {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 12px;
}
.algo-control-title { color: var(--text-dim); font-weight: 700; margin-bottom: 6px; }
.algo-status-line { margin-bottom: 8px; }
.algo-status { font-size: 11.5px; font-weight: 700; }
.algo-status-on { color: var(--accent); }
.algo-status-off { color: var(--text-dim); }
.algo-status-suspended { color: var(--danger); }
.algo-control-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.algo-ctrl-btn {
  flex: 1 1 auto;
  background: var(--panel-3);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 11.5px;
  transition: all .2s ease;
}
.algo-ctrl-btn:hover { border-color: var(--accent-2); }
.algo-ctrl-btn.active { background: var(--accent-2); color: #06202f; border-color: var(--accent-2); font-weight: 700; }

.pedestrian-btn {
  width: 100%;
  background: linear-gradient(135deg, #241a3b, #1b1430);
  border: 1px solid var(--purple);
  color: #d9cdfa;
  padding: 11px;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
}
.pedestrian-btn:hover { box-shadow: 0 0 16px -4px #a78bfa99; }

/* leaflet popup RTL */
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--panel);
  color: var(--text);
}
.leaflet-popup-content-wrapper { direction: rtl; font-family: 'Vazirmatn', Tahoma, sans-serif; }
.leaflet-container a.leaflet-popup-close-button { color: var(--text-dim); }

@media (max-width: 640px) {
  .app-header { flex-direction: column; }
  #map { height: 460px; }
  .modal-lanes { grid-template-columns: 1fr; }
}
