:root {
  --bg:#f6f7f9;

  --panel:rgba(16,24,32,.92);
  --ink:#e6f0ff;
  --muted:#91a1b2;

  /* Client trim colour: default Agile gold */
  --accent:#ce8c0d;

  --card:#12202e;
  --card2:#0f1b27;
  --br:#274054;

  --danger:#ffb4b4;
  --danger-bg:#2b1414;
  --danger-br:#7a2f2f;

  --warn:#ffe6a6;
  --warn-bg:#2b2614;
  --warn-br:#7a6a2f;

  --topbar-h:56px;
}

html,body{height:100%;margin:0;}
#map{
  position:absolute;
  left:0; right:0;
  top:var(--topbar-h);
  bottom:0;
  background:var(--bg);
}

.topbar{
  position:fixed; top:0; left:0; right:0;
  height:var(--topbar-h);
  display:flex; align-items:center; justify-content:space-between;
  padding:10px 12px;
  background:rgba(16,24,32,.92);
  color:var(--ink);
  border-bottom:1px solid rgba(255,255,255,.08);
  backdrop-filter: blur(6px);
  z-index:10;
  font:13px/1.25 system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell;
}

.brand{display:flex; align-items:center; gap:10px; min-width:260px;}
#clientLogo{
  width:auto; height:34px; max-width:180px;
  object-fit:contain;
  display:none;
}
.brand-title{font-weight:800; letter-spacing:.2px;}
.brand-sub{color:var(--muted); font-size:12px; margin-top:2px;}
.dot{color:#7d91a5; margin:0 6px;}

.nav{display:flex; align-items:center; gap:8px; flex-wrap:wrap; justify-content:flex-end;}
.tb-btn{
  display:inline-flex; align-items:center;
  padding:6px 10px;
  border-radius:12px;
  border:1px solid var(--br);
  background:var(--card2);
  color:var(--ink);
  cursor:pointer;
  user-select:none;
}
.tb-btn:hover{border-color:#30516a;}
.tb-btn.accent{border-color:rgba(206,140,13,.55);}
.tb-btn.accent:hover{border-color:rgba(206,140,13,.9);}

/* Dropdown panels */
.drop-panel{
  position:fixed;
  top:calc(var(--topbar-h) + 10px);
  left:12px;
  width:390px;
  max-height:calc(100% - var(--topbar-h) - 22px);
  overflow:auto;

  background:var(--panel);
  color:var(--ink);
  border-radius:16px;
  padding:12px 14px;
  box-shadow:0 10px 30px rgba(0,0,0,.35);
  border:1px solid rgba(255,255,255,.08);
  display:none;
  z-index:20;
}
.drop-panel.open{display:block;}
.drop-panel h2{
  margin:0 0 8px;
  font-size:12px;
  color:var(--muted);
  text-transform:uppercase;
  letter-spacing:.06em;
}

.subtle{color:var(--muted); font-size:12px;}
.help{color:var(--ink); font-size:13px; line-height:1.35;}
.help code{color:#cfe7ff;}
.help hr{border:none; border-top:1px solid rgba(255,255,255,.12); margin:10px 0;}

/* Common UI */
.basemap-options{display:flex; flex-direction:column; gap:6px; margin-bottom:8px;}
.toggles label, .basemap-options label{
  display:flex; align-items:center; gap:8px; cursor:pointer;
}
.inline{display:flex; align-items:center; gap:8px; cursor:pointer; margin-top:6px;}
input[type="radio"], input[type="checkbox"]{
  width:14px; height:14px;
  accent-color: var(--accent);
}
.btns{display:flex; gap:8px; flex-wrap:wrap;}
.btn{
  display:inline-flex; align-items:center;
  padding:6px 10px;
  border-radius:10px;
  border:1px solid var(--br);
  background:var(--card);
  color:var(--ink);
  cursor:pointer;
  user-select:none;
}
.btn:hover{border-color:#30516a; background:#0f1b27;}
.btn.small{padding:4px 8px; border-radius:8px; font-size:12px;}
.btn.danger{border-color: rgba(230,57,70,0.55);}
.btn.danger:hover{border-color: rgba(230,57,70,0.85); background: rgba(230,57,70,0.12);}

.chips{display:flex; flex-wrap:wrap; gap:6px; margin-top:8px;}
.chip{
  padding:4px 8px; border-radius:999px;
  background:#152432; color:var(--muted);
  border:1px solid #203040;
  font-size:12px;
}

.legend{
  display:grid;
  grid-template-columns:14px 1fr;
  gap:6px 8px;
  align-items:center;
}
.swatch{
  width:14px; height:14px;
  border-radius:3px;
  border:1px solid rgba(255,255,255,.25);
}

.threshold-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
  margin-top:6px;
}
.threshold-grid label{
  display:flex; align-items:center; justify-content:space-between;
  gap:8px;
  font-size:12px;
  color:var(--ink);
}
.threshold-grid input{
  width:92px;
  border-radius:8px;
  border:1px solid var(--br);
  background:#0f1b27;
  color:var(--ink);
  padding:4px 6px;
  outline:none;
}

/* Status toast */
.status-toast{
  position:fixed;
  top:calc(var(--topbar-h) + 10px);
  left:12px;
  width:390px;
  max-width:calc(100% - 24px);
  padding:10px 12px;
  border-radius:14px;
  border:1px solid var(--br);
  background:var(--card);
  color:var(--muted);
  white-space:pre-wrap;
  display:none;
  z-index:30;
}
.status-toast.error{display:block; border-color:var(--danger-br); background:var(--danger-bg); color:var(--danger);}
.status-toast.warn{display:block; border-color:var(--warn-br); background:var(--warn-bg); color:var(--warn);}

/* Drawer */
.drawer{
  position:fixed;
  top:var(--topbar-h);
  right:0;
  width:360px;
  max-width:calc(100% - 24px);
  height:calc(100% - var(--topbar-h));
  background:var(--panel);
  color:var(--ink);
  border-left:1px solid rgba(255,255,255,.08);
  box-shadow:-10px 0 30px rgba(0,0,0,.35);
  transform:translateX(100%);
  transition:transform .18s ease;
  z-index:25;
  display:flex;
  flex-direction:column;
}
.drawer.open{transform:translateX(0);}
.drawer-head{
  padding:12px 14px;
  border-bottom:1px solid rgba(255,255,255,.10);
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
}
.drawer-title{font-weight:800; font-size:16px;}
.drawer-sub{color:var(--muted); font-size:12px; margin-top:4px;}
.drawer-body{padding:12px 14px; overflow:auto;}
.group{margin:12px 0;}
.group h3{
  margin:0 0 8px;
  font-size:12px;
  color:var(--muted);
  text-transform:uppercase;
  letter-spacing:.06em;
}

/* Pinned list items */
.pin-item{
  border:1px solid var(--br);
  background:var(--card);
  border-radius:12px;
  padding:8px 10px;
  margin-bottom:8px;
}
.pin-top{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
}
.pin-title{font-weight:700;color:#e6f0ff;line-height:1.25;}
.pin-sub{color:var(--muted);font-size:12px;margin-top:2px;}
.pin-meta{color:var(--muted);font-size:12px;margin-top:8px;line-height:1.35;}
.pin-actions{display:flex;gap:8px;margin-top:10px;flex-wrap:wrap;}

.badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:2px 8px;
  border-radius:999px;
  font-size:11px;
  border:1px solid rgba(255,255,255,0.20);
  white-space:nowrap;
}
.badge.ok     { background:rgba(42,157,143,0.25); border-color:rgba(42,157,143,0.45); color:#bdf6ea; }
.badge.warn   { background:rgba(244,162,97,0.25); border-color:rgba(244,162,97,0.45); color:#ffe0c5; }
.badge.danger { background:rgba(230,57,70,0.25); border-color:rgba(230,57,70,0.55); color:#ffd3d7; }
.badge.na     { background:rgba(125,145,165,0.25); border-color:rgba(125,145,165,0.45); color:#d9e7f5; }

/* MapLibre controls: push down below topbar */
.maplibregl-ctrl-top-left,
.maplibregl-ctrl-top-right{
  top:calc(var(--topbar-h) + 6px) !important;
}

/* Translucent popup so catchments remain visible */
.maplibregl-popup-content{
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(4px);
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 10px 28px rgba(0,0,0,0.22);
  max-width: 380px;
}
.maplibregl-popup-close-button{
  color: rgba(0,0,0,0.65);
  font-size: 18px;
}
.maplibregl-popup-anchor-top .maplibregl-popup-tip,
.maplibregl-popup-anchor-top-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-top-right .maplibregl-popup-tip{
  border-bottom-color: rgba(255,255,255,0.72) !important;
}
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip,
.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip{
  border-top-color: rgba(255,255,255,0.72) !important;
}
.maplibregl-popup-anchor-left .maplibregl-popup-tip{
  border-right-color: rgba(255,255,255,0.72) !important;
}
.maplibregl-popup-anchor-right .maplibregl-popup-tip{
  border-left-color: rgba(255,255,255,0.72) !important;
}
