:root{
  --bg:#0b1320; --panel: rgba(15,23,42,0.5); --border: rgba(255,255,255,.10);
  --muted:#9fb2d6; --text:#eaf1ff; --accent:#60a5fa; --card: rgba(255,255,255,.06);
  --shadow: 0 8px 24px rgba(0,0,0,.25); --radius: 14px;
}
*{ box-sizing:border-box; }
html,body{ height:100%; margin:0; background:var(--bg); color:var(--text); font-family:Inter,system-ui,Segoe UI,Roboto,Arial,sans-serif; }
#map{ position:absolute; inset:20px 320px 20px 20px; border-radius: var(--radius); box-shadow: var(--shadow); overflow:hidden; }

.leaflet-control-layers{ background: rgba(17,24,39,.9); color:#fff; border:1px solid var(--border); border-radius:10px; }
.leaflet-control-zoom a{ background: rgba(17,24,39,.9); color:#fff; border:1px solid var(--border); }

.sidepanel{
  position:absolute; top:20px; right:20px; bottom:20px; width:300px;
  background: var(--panel); backdrop-filter: blur(6px); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px;
  display: grid; grid-template-rows: repeat(4, 1fr); gap: 12px;
}
.subsection{
  border:1px solid var(--border); border-radius:12px; background: var(--card);
  display:grid; grid-template-rows:auto 1fr auto; padding:14px;
}
.subsection h3{ margin:0 0 6px; font-size:12px; letter-spacing:.14em; text-transform:uppercase; color:var(--muted); font-weight:700; }
.valueBox{ display:grid; place-items:center; }
.metric-value {
  display: flex;
  align-items: center;      /* inline center with unit */
  justify-content: center;  /* horizontal center */
  gap: 4px;                  /* small space between value and unit */
  height: 100%;
  text-align: center;
  font-size: 30px;
}
.subtle{ color:var(--muted); font-size:12px; }
.metricsGroup{ opacity:0; pointer-events:none; }
.metricsGroup.ready{ opacity:1; pointer-events:auto; }
@keyframes popIn{0%{transform:scale(.85);opacity:.6}60%{transform:scale(1.08);opacity:.95}100%{transform:scale(1);opacity:1}}
.metricsGroup.ready .metric-value{ animation: popIn .45s cubic-bezier(.2,.9,.2,1) both; }
.row{ display:flex; align-items:center; justify-content:space-between; gap:10px; }
.toolbar{ display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-top:10px; }
button{ cursor:pointer; padding:10px 12px; border-radius:10px; border:1px solid var(--border);
  background:rgba(255,255,255,.06); color:var(--text); font-weight:600; }

@media (max-width:1100px){
  #map{ inset:20px 20px 420px 20px; }
  .sidepanel{ left:20px; right:20px; top:auto; height:380px; }
}

/* --- Basemap toggle control --- */
.leaflet-control-basetoggle {
  background: rgba(17,24,39,.9);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: #fff;
  padding: 6px;
}
.basetoggle-btn{
  cursor:pointer;
  padding:6px 10px;
  border-radius:8px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.06);
  color:#fff;
  font-weight:600;
  width:100%;
}
.basetoggle-panel{
  margin-top:6px;
  border-top:1px solid var(--border);
  padding-top:6px;
}
.basetoggle-panel label{
  display:block;
  font-size:12px;
  margin:4px 0;
}
.basetoggle-panel .subtle{
  margin-top:6px;
}
.basetoggle-panel input[type="range"]{
  width:100%; height:10px; border-radius:999px; border:1px solid var(--border);
  background: linear-gradient(90deg, var(--accent), rgba(96,165,250,.25));
  -webkit-appearance:none; appearance:none;
}
.basetoggle-panel input[type="range"]::-webkit-slider-thumb{
  -webkit-appearance:none; width:18px; height:18px; border-radius:50%;
  background:#fff; border:2px solid var(--accent); box-shadow:0 2px 6px rgba(0,0,0,.25);
}
/* --- Map top-right transparent toolbar --- */
.mapToolbar{
  position:absolute;
  top:12px; right:12px;
  z-index: 500; /* above tiles & raster */
  display:grid; gap:8px;
  width: 260px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(17,24,39,.35); /* transparent / glassy */
  backdrop-filter: blur(6px);
  box-shadow: var(--shadow);
}
.mapToolbar .toolbar-row{
  display:flex; align-items:center; justify-content:space-between;
}
.mapToolbar input[type="range"]{
  width:100%; height:10px; border-radius:999px; border:1px solid var(--border);
  background: linear-gradient(90deg, var(--accent), rgba(96,165,250,.25));
  -webkit-appearance:none; appearance:none;
}
.mapToolbar input[type="range"]::-webkit-slider-thumb{
  -webkit-appearance:none; width:18px; height:18px; border-radius:50%;
  background:#fff; border:2px solid var(--accent); box-shadow:0 2px 6px rgba(0,0,0,.25);
}
.mapToolbar .buttons{
  grid-template-columns: 1fr 1fr;
}

@media (max-width:1100px){
  /* Keep toolbar visible when map shifts below */
  .mapToolbar{ top: 28px; right: 28px; }
}


.metric-value {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  height: 100%;
}
.metric-value.column {          /* value on one line, unit below */
  flex-direction: column;
}
.metric-value.row {             /* value and unit on same line */
  flex-direction: row;
  gap: 6px;
}
.unit-below {                   /* smaller unit under value */
  font-size: 0.5em;
  opacity: 0.9;
  line-height: 1;
  margin-top: 4px;
}
.unit-inline {                  /* smaller unit beside value */
  font-size: 0.8em;
  opacity: 0.9;
}



/* --- Raster legend --- */
.leaflet-control.legend {
  background: rgba(17,24,39,.35);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  color: var(--text);
  padding: 12px;
  min-width: 260px;
}
.legend h4{
  margin:0 0 8px;
  font-size:12px; letter-spacing:.14em; text-transform:uppercase;
  color: var(--muted); font-weight:700;
}
.legend .bar{
  height: 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: linear-gradient(to right, #440154,#482878,#3E4989,#31688E,#26828E,#1F9E89,#35B779,#6ECE58,#B5DE2B,#FDE725);
  position: relative;
}
.legend .labels{
  display:flex; justify-content:space-between; align-items:center;
  margin-top:8px; font-size:12px; color: var(--muted);
}
.legend .tickrow{
  position: relative; height: 16px; margin-top:4px;
}
.legend .tick{
  position:absolute; top:0;
  width:1px; height:8px; background: var(--border);
}
.legend .ticklabel{
  position:absolute; top:8px; transform: translateX(-50%);
  font-size:10px; color: var(--muted);
}

