/* ============================================================
   VIETNAM FISHING GEODASHBOARD -- styles.css
   Design tokens from simondatalab.de
   ============================================================ */

/* ---- Reset & Variables ---- */
*,*::before,*::after{margin:0;padding:0;box-sizing:border-box}

:root{
  /* Palette */
  --void:        #020617;
  --surface:     #0f172a;
  --surface-2:   #1e293b;
  --surface-3:   #334155;
  --border-glass:rgba(148,163,184,0.08);
  --border-hover:rgba(148,163,184,0.16);
  --text-primary:  #f1f5f9;
  --text-secondary:#94a3b8;
  --text-muted:    #64748b;

  --primary:   #0ea5e9;
  --secondary: #8b5cf6;
  --accent:    #10b981;
  --warning:   #f59e0b;
  --danger:    #ef4444;
  --pink:      #ec4899;

  --primary-10: rgba(14,165,233,0.10);
  --primary-20: rgba(14,165,233,0.20);
  --secondary-10:rgba(139,92,246,0.10);
  --accent-10:  rgba(16,185,129,0.10);

  /* Typo */
  --font-body: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Layout */
  --topbar-h: 44px;
  --sidebar-w: 310px;
  --detail-w:  340px;
  --radius:    8px;
  --radius-sm: 4px;

  /* Motion */
  --ease: cubic-bezier(0.16,1,0.3,1);
}

body{
  font-family: var(--font-body);
  background: var(--void);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  min-height: 100dvh;
  height: 100dvh;
  width: 100vw;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

a{color: var(--primary); text-decoration:none;}
a:hover{text-decoration:underline;}

/* ---- TOPBAR ---- */
.topbar{
  position:fixed;top:0;left:0;right:0;height:var(--topbar-h);
  display:flex;align-items:center;justify-content:space-between;
  background:rgba(15,23,42,0.88);
  backdrop-filter:blur(16px) saturate(1.4);
  -webkit-backdrop-filter:blur(16px) saturate(1.4);
  border-bottom:1px solid var(--border-glass);
  padding: max(env(safe-area-inset-top), 0px) 16px 0;
  z-index:900;
}
.topbar__left,.topbar__right{display:flex;align-items:center;gap:10px;}
.topbar__center{flex:1;display:flex;justify-content:center;overflow:hidden;}

.topbar__brand{display:flex;align-items:center;gap:8px;color:var(--text-primary);font-weight:600;font-size:13px;letter-spacing:0.02em;}
.topbar__brand:hover{text-decoration:none;}
.topbar__mark{
  display:inline-flex;align-items:center;justify-content:center;
  width:26px;height:26px;border-radius:6px;
  background:linear-gradient(135deg,var(--primary),var(--secondary));
  color:#fff;font-weight:800;font-size:10px;letter-spacing:0.06em;
  font-family:var(--font-mono);
}
.topbar__title{white-space:nowrap;}

/* Metrics in topbar */
.topbar__metrics{
  display:flex;gap:20px;
}
.metric-chip{
  display:flex;flex-direction:column;align-items:center;gap:1px;
}
.metric-chip__val{font-family:var(--font-mono);font-size:12px;font-weight:600;color:var(--primary);letter-spacing:0.04em;}
.metric-chip__label{font-size:9px;color:var(--text-muted);text-transform:uppercase;letter-spacing:0.08em;}
.metric-chip__trend{font-size:9px;font-weight:600;}
.metric-chip__trend--up{color:var(--accent);}
.metric-chip__trend--down{color:var(--danger);}

.topbar__status{display:flex;align-items:center;gap:6px;font-size:10px;color:var(--text-muted);font-family:var(--font-mono);letter-spacing:0.03em;}
.topbar__dot{width:6px;height:6px;border-radius:50%;background:var(--accent);box-shadow:0 0 6px rgba(16,185,129,0.6);animation:pulse-dot 2.4s ease-in-out infinite;}
@keyframes pulse-dot{0%,100%{opacity:1;}50%{opacity:0.4;}}
.topbar__btn{
  display:inline-flex;align-items:center;justify-content:center;
  width:28px;height:28px;border-radius:var(--radius-sm);
  border:1px solid var(--border-glass);background:transparent;
  color:var(--text-secondary);cursor:pointer;transition:all .2s var(--ease);
}
.topbar__btn:hover{background:var(--primary-10);color:var(--primary);border-color:var(--primary-20);}
.topbar__status-text{
  max-width:180px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}

/* ---- DASHBOARD GRID ---- */
.dashboard{
  position:fixed;top:var(--topbar-h);left:0;right:0;bottom:0;
  display:flex;
}

/* ---- SIDEBAR ---- */
.sidebar{
  width:var(--sidebar-w);min-width:var(--sidebar-w);
  display:flex;flex-direction:column;
  background:rgba(15,23,42,0.92);
  backdrop-filter:blur(20px) saturate(1.4);
  -webkit-backdrop-filter:blur(20px) saturate(1.4);
  border-right:1px solid var(--border-glass);
  z-index:800;
  overflow:hidden;
}
.sidebar__tabs{
  display:flex;border-bottom:1px solid var(--border-glass);flex-shrink:0;
}
.sidebar__tab{
  flex:1;display:flex;flex-direction:column;align-items:center;gap:2px;
  padding:10px 4px 8px;border:none;background:none;
  color:var(--text-muted);cursor:pointer;font-size:9px;
  font-family:var(--font-body);font-weight:500;letter-spacing:0.06em;text-transform:uppercase;
  transition:all .2s var(--ease);position:relative;
}
.sidebar__tab svg{opacity:0.5;transition:opacity .2s var(--ease);}
.sidebar__tab:hover{color:var(--text-secondary);}
.sidebar__tab:hover svg{opacity:0.8;}
.sidebar__tab--active{color:var(--primary);}
.sidebar__tab--active svg{opacity:1;stroke:var(--primary);}
.sidebar__tab--active::after{
  content:'';position:absolute;bottom:0;left:20%;right:20%;height:2px;
  background:var(--primary);border-radius:1px;
}

.sidebar__panel{display:none;flex:1;overflow-y:auto;padding:12px;gap:8px;flex-direction:column;-webkit-overflow-scrolling:touch;}
.sidebar__panel--active{display:flex;}

.sidebar__footer{
  flex-shrink:0;padding:8px 12px;border-top:1px solid var(--border-glass);
  display:flex;justify-content:space-between;font-size:9px;color:var(--text-muted);
  font-family:var(--font-mono);letter-spacing:0.03em;
}

/* Panel internals */
.panel__section{margin-bottom:10px;}
.panel__section--compact{margin-bottom:4px;}
.panel__heading{
  font-size:10px;text-transform:uppercase;letter-spacing:0.1em;
  color:var(--text-muted);font-weight:600;margin-bottom:8px;
  padding-bottom:4px;border-bottom:1px solid var(--border-glass);
}
.panel__heading--collapsible{
  cursor:pointer;display:flex;align-items:center;justify-content:space-between;
  transition:color .15s var(--ease);user-select:none;
}
.panel__heading--collapsible:hover{color:var(--text-secondary);}
.panel__chevron{font-size:10px;opacity:0.5;transition:transform .2s var(--ease);}
.panel__search{padding-bottom:8px;flex-shrink:0;}

/* Layer groups */
.layer-group__body{overflow:hidden;transition:max-height .25s var(--ease);}

/* Preset buttons */
.preset-btns{display:flex;flex-wrap:wrap;gap:4px;margin-top:4px;}
.preset-btn{
  padding:5px 10px;border-radius:20px;border:1px solid var(--border-glass);
  background:transparent;color:var(--text-muted);font-size:10px;font-family:var(--font-body);
  font-weight:500;cursor:pointer;transition:all .15s var(--ease);
}
.preset-btn:hover{border-color:var(--primary-20);color:var(--primary);background:var(--primary-10);}
.preset-btn--active{background:var(--primary-10);border-color:var(--primary-20);color:var(--primary);}

.toggle__swatch--live {
  position: relative;
  animation: live-pulse 2s ease-in-out infinite;
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34,211,238,0.5); }
  50%       { opacity: 0.7; box-shadow: 0 0 0 4px rgba(34,211,238,0); }
}
.live-label { color: #22d3ee; font-weight: 600; }
.live-badge {
  font-size: 8px;
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(34,211,238,0.15);
  border: 1px solid rgba(34,211,238,0.35);
  color: #22d3ee;
  vertical-align: middle;
  margin-left: 2px;
}

/* Layer toggles */
.layer-toggle{
  display:flex;align-items:center;gap:8px;padding:5px 6px;
  border-radius:var(--radius-sm);cursor:pointer;font-size:12px;color:var(--text-secondary);
  transition:background .15s var(--ease);
}
.layer-toggle:hover{background:rgba(148,163,184,0.05);}
.layer-toggle input[type="checkbox"]{
  appearance:none;-webkit-appearance:none;width:14px;height:14px;border-radius:3px;
  border:1.5px solid var(--text-muted);cursor:pointer;position:relative;flex-shrink:0;
  transition:all .15s var(--ease);
}
.layer-toggle input[type="checkbox"]:checked{background:var(--primary);border-color:var(--primary);}
.layer-toggle input[type="checkbox"]:checked::after{
  content:'';position:absolute;top:1px;left:4px;width:4px;height:7px;
  border:solid #fff;border-width:0 1.5px 1.5px 0;transform:rotate(45deg);
}
.toggle__swatch{width:10px;height:10px;border-radius:2px;flex-shrink:0;}
.toggle__swatch[style*="gradient"]{border-radius:2px;}
.hotspot-swatch{background:linear-gradient(135deg,var(--primary),var(--accent));}
.mpa-swatch{background:linear-gradient(135deg,var(--secondary),var(--pink));border-radius:50%;}

/* Season / category pills */
.season-pills,.species-filters{display:flex;flex-wrap:wrap;gap:4px;}
.pill{
  padding:4px 10px;border-radius:20px;border:1px solid var(--border-glass);
  background:transparent;color:var(--text-muted);font-size:11px;font-family:var(--font-body);
  font-weight:500;cursor:pointer;transition:all .15s var(--ease);
}
.pill:hover{border-color:var(--border-hover);color:var(--text-secondary);}
.pill--active{background:var(--primary-10);border-color:var(--primary-20);color:var(--primary);}

/* Legend */
.legend{display:flex;flex-direction:column;gap:5px;}
.legend__row{display:flex;align-items:center;gap:8px;font-size:11px;color:var(--text-muted);}
.legend__dot{width:10px;height:10px;border-radius:50%;flex-shrink:0;}
.legend__line{width:16px;height:2px;flex-shrink:0;border-radius:1px;}
.legend__grad{
  width:60px;height:8px;border-radius:2px;flex-shrink:0;
  background:linear-gradient(90deg,#1e3a5f,#0ea5e9,#f59e0b,#ef4444);
}

/* Search input */
.search-input{
  width:100%;padding:7px 10px;border-radius:var(--radius-sm);
  border:1px solid var(--border-glass);background:rgba(2,6,23,0.6);
  color:var(--text-primary);font-size:12px;font-family:var(--font-body);
  outline:none;transition:border-color .2s var(--ease);
}
.search-input::placeholder{color:var(--text-muted);}
.search-input:focus{border-color:var(--primary-20);}

/* Spot list */
.spot-list,.species-list{display:flex;flex-direction:column;gap:4px;overflow-y:auto;flex:1;-webkit-overflow-scrolling:touch;}
.spot-card,.species-card{
  padding:10px;border-radius:var(--radius);
  border:1px solid var(--border-glass);background:rgba(2,6,23,0.4);
  cursor:pointer;transition:all .2s var(--ease);
}
.species-card{display:flex;gap:10px;align-items:flex-start;}
.species-card__img{
  width:56px;height:56px;border-radius:var(--radius-sm);
  object-fit:cover;flex-shrink:0;
  border:1px solid var(--border-glass);background:var(--surface);
}
.species-card__info{flex:1;min-width:0;}
.spot-card:hover,.species-card:hover{border-color:var(--border-hover);background:rgba(2,6,23,0.7);}

/* Species detail hero image */
.detail-species-hero{
  width:100%;height:160px;border-radius:var(--radius);
  overflow:hidden;margin-bottom:12px;
  border:1px solid var(--border-glass);
  background:var(--surface);
}
.detail-species-hero img{
  width:100%;height:100%;object-fit:cover;
}
.spot-card--active,.species-card--active{border-color:var(--primary-20);background:var(--primary-10);}
.spot-card__name,.species-card__name{font-size:13px;font-weight:600;margin-bottom:2px;}
.spot-card__meta,.species-card__meta{font-size:10px;color:var(--text-muted);font-family:var(--font-mono);letter-spacing:0.02em;}
.spot-card__rating{font-size:10px;color:var(--warning);margin-top:3px;display:flex;align-items:center;gap:2px;}

/* Star rating component */
.star {
  display: inline-block;
  width: 10px;
  height: 10px;
  position: relative;
}
.star::before {
  content: '';
  display: block;
  width: 0; height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 3.5px solid var(--surface-3);
  position: absolute;
  top: 0;
}
.star--full::before { border-bottom-color: var(--warning); }
.star--half::before {
  border-bottom-color: var(--warning);
  clip-path: inset(0 50% 0 0);
}
.star--empty::before { border-bottom-color: var(--surface-3); }
.spot-card__tags{display:flex;gap:4px;margin-top:4px;flex-wrap:wrap;}
.spot-card__tag{
  padding:2px 6px;border-radius:10px;font-size:9px;
  background:rgba(148,163,184,0.06);color:var(--text-muted);
  border:1px solid var(--border-glass);
}
.species-card__iucn{
  display:inline-block;padding:1px 6px;border-radius:3px;font-size:9px;
  font-weight:600;font-family:var(--font-mono);margin-top:3px;
}
.iucn--LC{background:rgba(16,185,129,0.15);color:var(--accent);}
.iucn--NT{background:rgba(245,158,11,0.15);color:var(--warning);}
.iucn--VU{background:rgba(239,68,68,0.15);color:var(--danger);}
.iucn--EN{background:rgba(239,68,68,0.25);color:var(--danger);}
.iucn--DD{background:rgba(148,163,184,0.1);color:var(--text-muted);}
.iucn--CR{background:rgba(239,68,68,0.35);color:#fca5a5;}
.iucn--NE{background:rgba(148,163,184,0.06);color:var(--text-muted);font-style:italic;}

/* Chart boxes */
.chart-box{height:140px;position:relative;}
.chart-box--sm{height:110px;}

/* ---- MAP VIEWPORT ---- */
.map-viewport{flex:1;position:relative;overflow:hidden;}
.map-canvas{width:100%;height:100%;}

/* Coord display */
.coord-display{
  position:absolute;bottom:32px;left:12px;
  padding:4px 10px;border-radius:var(--radius-sm);
  background:rgba(15,23,42,0.85);backdrop-filter:blur(8px);
  border:1px solid var(--border-glass);
  font-size:10px;font-family:var(--font-mono);color:var(--text-muted);
  z-index:100;pointer-events:none;letter-spacing:0.03em;
}
.coord-sep{margin:0 6px;opacity:0.3;}

/* Info strip at bottom */
.map-info-strip{
  position:absolute;bottom:8px;left:12px;right:12px;
  display:flex;align-items:center;justify-content:center;gap:0;
  padding:4px 12px;border-radius:var(--radius-sm);
  background:rgba(15,23,42,0.8);backdrop-filter:blur(8px);
  border:1px solid var(--border-glass);
  font-size:10px;font-family:var(--font-mono);color:var(--text-muted);
  z-index:100;pointer-events:none;letter-spacing:0.03em;
}

/* ---- DETAIL PANEL (right side) ---- */
.detail-panel{
  position:absolute;top:0;right:0;bottom:0;width:var(--detail-w);
  background:rgba(15,23,42,0.94);backdrop-filter:blur(20px) saturate(1.4);
  -webkit-backdrop-filter:blur(20px) saturate(1.4);
  border-left:1px solid var(--border-glass);
  z-index:800;transform:translateX(100%);
  transition:transform .35s var(--ease);
  display:flex;flex-direction:column;overflow:hidden;
}
.detail-panel--open{transform:translateX(0);}
.detail__header{
  display:flex;align-items:flex-start;justify-content:space-between;
  padding:16px;border-bottom:1px solid var(--border-glass);flex-shrink:0;
}
.detail__name{font-size:15px;font-weight:700;}
.detail__sub{font-size:11px;color:var(--text-muted);margin-top:2px;font-family:var(--font-mono);}
.detail__close{
  background:none;border:1px solid var(--border-glass);border-radius:var(--radius-sm);
  color:var(--text-muted);font-size:18px;width:28px;height:28px;cursor:pointer;
  display:inline-flex;align-items:center;justify-content:center;
  transition:all .15s var(--ease);line-height:1;
}
.detail__close:hover{color:var(--text-primary);border-color:var(--border-hover);}
.detail__body{flex:1;overflow-y:auto;padding:16px;-webkit-overflow-scrolling:touch;}

/* Detail body grid items */
.detail-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px;}
.detail-stat{
  padding:10px;border-radius:var(--radius-sm);
  border:1px solid var(--border-glass);background:rgba(2,6,23,0.4);
}
.detail-stat__label{font-size:9px;color:var(--text-muted);text-transform:uppercase;letter-spacing:0.08em;}
.detail-stat__val{font-size:14px;font-weight:700;font-family:var(--font-mono);margin-top:2px;}
.detail-stat--wide{grid-column:1/-1;}
.detail-desc{
  font-size:12px;color:var(--text-secondary);line-height:1.6;
  margin-bottom:10px;
}
.detail-tag-list{display:flex;flex-wrap:wrap;gap:4px;margin-bottom:10px;}
.detail-tag{
  padding:3px 8px;border-radius:12px;font-size:10px;
  background:rgba(148,163,184,0.06);color:var(--text-muted);
  border:1px solid var(--border-glass);
}
.detail-tag--primary{background:var(--primary-10);color:var(--primary);border-color:var(--primary-20);}
.detail-tag--accent{background:var(--accent-10);color:var(--accent);border-color:rgba(16,185,129,0.2);}
.detail-tag--secondary{background:var(--secondary-10);color:var(--secondary);border-color:rgba(139,92,246,0.2);}

.detail-section-title{
  font-size:10px;text-transform:uppercase;letter-spacing:0.1em;
  color:var(--text-muted);font-weight:600;margin:12px 0 6px;
  padding-bottom:4px;border-bottom:1px solid var(--border-glass);
}
.detail-species-list{display:flex;flex-direction:column;gap:4px;margin-bottom:10px;}
.detail-species-item{
  display:flex;align-items:center;gap:8px;padding:5px 8px;border-radius:var(--radius-sm);
  border:1px solid var(--border-glass);font-size:11px;color:var(--text-secondary);
  background:rgba(2,6,23,0.3);cursor:pointer;transition:all .15s var(--ease);
}
.detail-species-item:hover{border-color:var(--primary-20);background:var(--primary-10);}
.detail-species-dot{width:6px;height:6px;border-radius:50%;flex-shrink:0;}

/* ---- MapLibre overrides ---- */
.maplibregl-popup-content{
  background:rgba(15,23,42,0.94) !important;
  backdrop-filter:blur(16px);
  border:1px solid var(--border-glass) !important;
  border-radius:var(--radius) !important;
  color:var(--text-primary) !important;
  padding:12px 14px !important;
  font-family:var(--font-body) !important;
  font-size:12px !important;
  box-shadow:0 12px 40px rgba(0,0,0,0.5) !important;
  max-width:240px !important;
}
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip{border-top-color:rgba(15,23,42,0.94) !important;}
.maplibregl-popup-anchor-top .maplibregl-popup-tip{border-bottom-color:rgba(15,23,42,0.94) !important;}
.maplibregl-popup-anchor-left .maplibregl-popup-tip{border-right-color:rgba(15,23,42,0.94) !important;}
.maplibregl-popup-anchor-right .maplibregl-popup-tip{border-left-color:rgba(15,23,42,0.94) !important;}
.maplibregl-popup-close-button{color:var(--text-muted) !important;font-size:16px !important;padding:4px 8px !important;}
.maplibregl-popup-close-button:hover{color:var(--text-primary) !important;background:none !important;}

.maplibregl-ctrl-group{
  background:rgba(15,23,42,0.85) !important;
  border:1px solid var(--border-glass) !important;
  border-radius:var(--radius-sm) !important;
  box-shadow:0 4px 16px rgba(0,0,0,0.3) !important;
}
.maplibregl-ctrl-group button{color:var(--text-secondary) !important;}
.maplibregl-ctrl-group button+button{border-top:1px solid var(--border-glass) !important;}
.maplibregl-ctrl-group button:hover{background:rgba(148,163,184,0.1) !important;}
.maplibregl-ctrl-attrib{
  background:rgba(15,23,42,0.7) !important;
  color:var(--text-muted) !important;font-size:9px !important;
}
.maplibregl-ctrl-attrib a{color:var(--text-muted) !important;}

/* Marker styles */
.marker-hotspot{
  width:16px;height:16px;border-radius:50%;
  border:2px solid rgba(255,255,255,0.85);
  cursor:pointer;transition:transform .2s var(--ease),box-shadow .2s var(--ease);
  box-shadow:0 0 8px rgba(14,165,233,0.4);
}
.marker-hotspot:hover{transform:scale(1.35);box-shadow:0 0 16px rgba(14,165,233,0.7);}

.marker-port{
  width:10px;height:10px;border-radius:2px;transform:rotate(45deg);
  background:var(--warning);border:1.5px solid rgba(255,255,255,0.7);
  cursor:pointer;transition:transform .2s var(--ease);
  box-shadow:0 0 6px rgba(245,158,11,0.4);
}
.marker-port:hover{transform:rotate(45deg) scale(1.35);}

.marker-mpa{
  width:12px;height:12px;border-radius:50%;
  background:rgba(139,92,246,0.25);border:2px solid var(--secondary);
  cursor:pointer;transition:transform .2s var(--ease);
}
.marker-mpa:hover{transform:scale(1.3);}

/* Popup content specifics */
.popup-img{width:100%;height:100px;object-fit:cover;border-radius:4px;margin-bottom:6px;display:block;}
.popup-title{font-weight:700;font-size:13px;margin-bottom:4px;}
.popup-row{display:flex;justify-content:space-between;gap:8px;margin-top:3px;}
.popup-label{color:var(--text-muted);font-size:10px;text-transform:uppercase;letter-spacing:0.06em;}
.popup-val{font-family:var(--font-mono);font-size:11px;font-weight:600;}

/* ---- COUNTRY BADGE ---- */
.country-badge{
  display:inline-block;
  font-size:9px;font-weight:600;
  padding:1px 6px;border-radius:8px;
  background:rgba(14,165,233,0.12);color:#0ea5e9;
  margin-left:4px;vertical-align:middle;
  letter-spacing:0.04em;text-transform:uppercase;
}

/* ---- RECORD MARKER ---- */
.marker-record{
  width:14px;height:14px;
  background:#ef4444;
  border:2px solid rgba(255,255,255,0.9);
  border-radius:50%;
  cursor:pointer;
  box-shadow:0 0 8px rgba(239,68,68,0.5);
  transition:transform 0.18s ease;
}
.marker-record:hover{transform:scale(1.4);}

/* ---- RECORD CARDS ---- */
.record-list{overflow-y:auto;flex:1;-webkit-overflow-scrolling:touch;}
.record-card{
  display:flex;align-items:flex-start;gap:10px;
  padding:10px 14px;border-bottom:1px solid var(--surface-3);
  cursor:pointer;transition:background 0.15s;
}
.record-card:hover{background:var(--surface-2);}
.record-card__img{
  width:60px;height:44px;object-fit:cover;
  border-radius:4px;flex-shrink:0;
}
.record-card__info{min-width:0;flex:1;}
.record-card__title{font-size:12px;font-weight:700;line-height:1.3;}
.record-card__meta{font-size:10px;color:var(--text-muted);margin-top:2px;}
.record-card__weight{
  font-family:var(--font-mono);font-size:13px;font-weight:700;
  color:#ef4444;margin-top:2px;
}

/* Scrollbar */
::-webkit-scrollbar{width:5px;}
::-webkit-scrollbar-track{background:transparent;}
::-webkit-scrollbar-thumb{background:var(--surface-3);border-radius:4px;}
::-webkit-scrollbar-thumb:hover{background:var(--text-muted);}

/* ============================================================
   HAMBURGER & MOBILE
   ============================================================ */
.hamburger {
  display: none;
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  flex-direction: column;
  justify-content: space-around;
  width: 34px;
  height: 30px;
  background: rgba(14, 165, 233, 0.2);
  border: 1px solid rgba(125, 211, 252, 0.7);
  border-radius: 6px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  padding: 5px 4px;
  z-index: 1001;
  box-shadow: 0 4px 16px rgba(14, 165, 233, 0.28), 0 0 0 1px rgba(125, 211, 252, 0.25) inset;
}
.hamburger span {
  display: block;
  width: 24px;
  height: 2.5px;
  background: #e0f2fe;
  border-radius: 2px;
  transition: all 0.3s var(--ease);
  transform-origin: center;
  margin: 0 auto;
}
.hamburger:hover,
.hamburger:focus-visible {
  border-color: rgba(186, 230, 253, 0.95);
  background: rgba(14, 165, 233, 0.32);
}
.hamburger:focus-visible {
  outline: 2px solid rgba(14, 165, 233, 0.4);
  outline-offset: 1px;
}
.hamburger.active span {
  background: #f0f9ff;
}
.hamburger.active span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.hamburger.active span:nth-child(2) {
  opacity: 0;
}
.hamburger.active span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.mobile-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.75);
  z-index: 899;
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.mobile-overlay.active {
  display: block;
  opacity: 1;
}

/* =============================================================
   MOBILE — Responsive breakpoints
   ============================================================= */
@media(max-width:860px){
  /* ── Topbar ─────────────────────────────────────────────── */
  .hamburger          { display: flex; }
  .topbar             { padding-left: 48px; padding-right: 12px; padding-top: max(env(safe-area-inset-top), 0px); }
  .topbar__mark       { font-size: 12px; width: 28px; height: 28px; }
  .topbar__title      { font-size: 12px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar__center     { display: none; }
  .topbar__status-text{ display: none; }
  .topbar__dot        { display: none; }

  /* ── Sidebar as full-height drawer ─────────────────────── */
  .sidebar {
    position: fixed;
    width: 288px;
    min-width: 288px;
    left: -300px;
    top: 0;
    height: 100dvh;
    z-index: 950;
    transition: left 0.3s var(--ease);
    padding-top: calc(var(--topbar-h) + max(env(safe-area-inset-top), 0px));
    will-change: left;
    background: #0b1120;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-right: 1px solid rgba(125, 211, 252, 0.4);
    box-shadow: 10px 0 32px rgba(0, 0, 0, 0.7);
    /* global bright text so nothing is invisible */
    color: #cbd5e1;
  }
  .sidebar.open { left: 0; }

  /* Tabs */
  .sidebar .sidebar__tab { color: #94a3b8; }
  .sidebar .sidebar__tab svg { opacity: 0.72; }
  .sidebar .sidebar__tab:hover { color: #cbd5e1; }
  .sidebar .sidebar__tab--active { color: #38bdf8; }
  .sidebar .sidebar__tab--active svg { stroke: #38bdf8; opacity: 1; }

  /* Headings */
  .sidebar .panel__heading { color: #7dd3fc; border-bottom-color: rgba(125, 211, 252, 0.28); }

  /* Layer rows + legend */
  .sidebar .layer-toggle { color: #cbd5e1; }
  .sidebar .legend__row  { color: #cbd5e1; }

  /* Presets & pills */
  .sidebar .preset-btn { color: #cbd5e1; border-color: rgba(148,163,184,0.25); }
  .sidebar .preset-btn:hover { color: #38bdf8; }
  .sidebar .preset-btn--active { color: #38bdf8; background: rgba(14,165,233,0.15); border-color: rgba(14,165,233,0.4); }
  .sidebar .pill { color: #cbd5e1; border-color: rgba(148,163,184,0.25); }
  .sidebar .pill:hover { color: #38bdf8; }
  .sidebar .pill--active { color: #38bdf8; background: rgba(14,165,233,0.15); border-color: rgba(14,165,233,0.4); }

  /* Cards */
  .sidebar .spot-card,
  .sidebar .species-card,
  .sidebar .record-card {
    background: rgba(30, 41, 59, 0.85);
    border-color: rgba(125, 211, 252, 0.18);
  }
  .sidebar .spot-card__name,
  .sidebar .species-card__name,
  .sidebar .record-card__name { color: #f1f5f9; }
  .sidebar .spot-card__meta,
  .sidebar .species-card__meta,
  .sidebar .record-card__meta { color: #94a3b8; }
  .sidebar .spot-card__tag    { color: #94a3b8; border-color: rgba(148,163,184,0.2); }

  /* Search */
  .sidebar .search-input { color: #f1f5f9; background: rgba(30, 41, 59, 0.9); border-color: rgba(125,211,252,0.22); }
  .sidebar .search-input::placeholder { color: #64748b; }

  /* Checkbox */
  .sidebar .layer-toggle input[type="checkbox"] { border-color: #94a3b8; }

  /* Footer */
  .sidebar .sidebar__footer { color: #64748b; border-top-color: rgba(125,211,252,0.15); }

  /* Sidebar tabs: horizontal strip on mobile */
  .sidebar__tabs {
    flex-direction: row;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .sidebar__tabs::-webkit-scrollbar { display: none; }
  .sidebar__tab {
    flex-shrink: 0;
    min-width: 60px;
    height: 52px;
    flex-direction: column;
    justify-content: center;
    padding: 0 8px;
    gap: 3px;
  }
  .sidebar__tab span { display: inline; font-size: 9px; }
  .sidebar__panel    { padding: 12px; }

  /* ── Map viewport fills screen ──────────────────────────── */
  .map-viewport { left: 0; width: 100%; }

  /* ── Detail panel full-width ────────────────────────────── */
  .detail-panel {
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100vw;
    z-index: 870;
    max-height: 80dvh;
    top: auto;
    bottom: max(env(safe-area-inset-bottom), 0px);
    transform: translateY(100%);
    border-top: 2px solid var(--primary);
    border-radius: var(--radius) var(--radius) 0 0;
  }
  .detail-panel--open { transform: translateY(0); }

  /* ── Coord display ──────────────────────────────────────── */
  .coord-display {
    bottom: 12px;
    left: 8px;
    font-size: 9px;
    padding: 3px 8px;
  }

  /* ── Info strip ─────────────────────────────────────────── */
  .map-info-strip {
    display: none; /* hide on very small — save space for widget */
  }

  /* ── Touch-friendly minimum sizes ──────────────────────── */
  .preset-btn, .pill { min-height: 36px; }
  button            { touch-action: manipulation; }

  /* ── Popups ─────────────────────────────────────────────── */
  .maplibregl-popup-content {
    max-width: 82vw !important;
    font-size: 12px !important;
  }

  /* ── Detail panel content ───────────────────────────────── */
  .detail__header { padding: 14px 14px 10px; }
  .detail__name   { font-size: 15px; }
  .detail__sub    { font-size: 11px; }
  .detail__close  { width: 36px; height: 36px; font-size: 22px; }
  .detail__body   { padding: 12px 14px; }
  .detail-grid    { grid-template-columns: 1fr 1fr; gap: 6px; }
}

@media (max-width: 420px) {
  .sidebar {
    width: 100vw;
    min-width: 100vw;
    left: -104vw;
  }
  .sidebar.open { left: 0; }
  .topbar__title { max-width: 116px; }
  .hamburger { left: 8px; }
}

/* =============================================================
   INTELLIGENCE WIDGET — complete redesign, no emojis
   ============================================================= */
.intelligence-widget {
  position: absolute;
  top: 68px;
  right: 16px;
  width: 340px;
  max-height: calc(100vh - 100px);
  background: rgba(9, 14, 28, 0.96);
  backdrop-filter: blur(24px) saturate(1.6);
  -webkit-backdrop-filter: blur(24px) saturate(1.6);
  border: 1px solid rgba(148,163,184,0.12);
  border-top: 2px solid var(--primary);
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: 0 16px 48px rgba(0,0,0,0.6), 0 0 0 1px rgba(14,165,233,0.06);
  font-family: var(--font-body);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 600;
}
.intelligence-widget::-webkit-scrollbar { width: 3px; }
.intelligence-widget::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 2px; }

/* ── Header ─────────────────────────────────────────────── */
.intel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  flex-shrink: 0;
  background: rgba(14,165,233,0.06);
  border-bottom: 1px solid rgba(148,163,184,0.08);
}
.intel-header h3 {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}
.intel-header-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  animation: pulse-dot 2.4s ease-in-out infinite;
}
.intel-header-sub {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  margin-left: 4px;
}
.intel-toggle {
  width: 22px; height: 22px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(148,163,184,0.12);
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  line-height: 1;
  flex-shrink: 0;
}
.intel-toggle:hover { color: var(--primary); border-color: rgba(14,165,233,0.3); }

/* ── Body ───────────────────────────────────────────────── */
.intel-body {
  padding: 12px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 160px);
  opacity: 1;
  transition: max-height 0.3s ease, opacity 0.2s ease, padding 0.25s ease;
}
.intel-body--collapsed {
  max-height: 0 !important;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
  overflow: hidden;
}

/* ── Divider ────────────────────────────────────────────── */
.intel-divider {
  height: 1px;
  background: rgba(148,163,184,0.07);
  margin: 2px 0;
}

/* ── States ─────────────────────────────────────────────── */
.intel-loading {
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 6px 0;
  font-style: italic;
  letter-spacing: 0.02em;
}
.intel-error {
  font-size: 0.78rem;
  color: var(--danger);
  padding: 6px 0 6px 10px;
  border-left: 2px solid var(--danger);
  background: rgba(239,68,68,0.04);
  border-radius: 0 2px 2px 0;
}

/* ── Weather Grid ───────────────────────────────────────── */
.intel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}
.intel-card {
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(148,163,184,0.07);
  border-radius: 5px;
  padding: 8px 10px;
  transition: border-color 0.2s ease;
}
.intel-card:hover { border-color: rgba(14,165,233,0.2); }
.intel-card--wide {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 7px 10px;
}
.intel-card__label {
  font-size: 0.62rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  margin-bottom: 3px;
}
.intel-card--wide .intel-card__label {
  margin-bottom: 0;
  margin-right: 8px;
  color: var(--primary);
  font-size: 0.65rem;
}
.intel-card__val {
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font-mono);
  line-height: 1;
}
.intel-card--wide .intel-card__val {
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font-body);
}
.intel-card__sub {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 3px;
  font-weight: 500;
}
.intel-card--wide .intel-card__sub {
  margin-top: 0;
  margin-left: auto;
  font-size: 0.65rem;
}
.intel-card__sub--ok     { color: #10b981; }
.intel-card__sub--warn   { color: #f59e0b; }
.intel-card__sub--danger { color: #ef4444; }
.intel-unit { font-size: 0.68rem; font-weight: 400; color: var(--text-muted); }

/* ── Section ────────────────────────────────────────────── */
.intel-section { display: flex; flex-direction: column; gap: 4px; }

/* ── Score row ──────────────────────────────────────────── */
.intel-score-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.intel-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.intel-score-pct {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.intel-phase-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Confidence bar ─────────────────────────────────────── */
.intel-bar-track {
  height: 3px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  overflow: hidden;
}
.intel-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.9s cubic-bezier(0.16,1,0.3,1);
}

/* ── Rank labels ────────────────────────────────────────── */
.intel-rank-label {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--primary);
  padding: 2px 0;
}
.intel-rank-label--2 { color: var(--text-muted); }

/* ── Pick cards ─────────────────────────────────────────── */
.intel-pick {
  padding: 7px 10px 7px 12px;
  background: rgba(255,255,255,0.025);
  border-left: 2px solid var(--pick-color, var(--primary));
  border-radius: 0 4px 4px 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.intel-pick--minor { opacity: 0.75; }
.intel-pick__name {
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.2;
}
.intel-pick__meta {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.intel-pick__meta strong { color: var(--text-secondary); }
.intel-pick__row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 2px;
}
.intel-pick__loc {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ── Field labels / tags ────────────────────────────────── */
.intel-field-label {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(148,163,184,0.1);
  padding: 1px 5px;
  border-radius: 3px;
  flex-shrink: 0;
  align-self: flex-start;
}
.intel-tag {
  display: inline-block;
  font-size: 0.68rem;
  color: var(--text-secondary);
  background: rgba(14,165,233,0.07);
  border: 1px solid rgba(14,165,233,0.12);
  padding: 1px 6px;
  border-radius: 10px;
  white-space: nowrap;
}

/* ── Meta row (moon) ────────────────────────────────────── */
.intel-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.intel-moon-text {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* ── Tips ───────────────────────────────────────────────── */
.intel-tips { gap: 3px; }
.intel-tip {
  font-size: 0.74rem;
  color: var(--text-secondary);
  padding: 5px 8px 5px 10px;
  border-left: 2px solid var(--warning);
  background: rgba(245,158,11,0.05);
  border-radius: 0 3px 3px 0;
  line-height: 1.4;
}

/* ── Species Explorer ───────────────────────────────────── */
.intel-explorer { margin-top: 2px; }
.intel-explorer summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(148,163,184,0.07);
  transition: background 0.15s ease;
}
.intel-explorer summary:hover { background: rgba(14,165,233,0.06); }
.intel-explorer summary::-webkit-details-marker { display: none; }
.intel-explorer__label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 0.04em;
}
.intel-explorer__count {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.intel-species-grid {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 6px;
}
.intel-scard {
  padding: 7px 10px 7px 12px;
  background: rgba(255,255,255,0.02);
  border-left: 2px solid var(--sc-color, var(--primary));
  border-radius: 0 4px 4px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.intel-scard__name { font-size: 0.8rem; font-weight: 700; }
.intel-scard__sci  { font-size: 0.68rem; color: var(--text-muted); }
.intel-scard__row  {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  font-size: 0.7rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
}
.intel-scard__lures { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 2px; }

/* ── Mobile positioning ─────────────────────────────────── */
@media (max-width: 860px) {
  .intelligence-widget {
    position: fixed;
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 55vh;
    border-radius: var(--radius) var(--radius) 0 0;
    border-top: 2px solid var(--primary);
    border-left: none;
    border-right: none;
    border-bottom: none;
    z-index: 850;
  }
  .intel-body {
    max-height: 48vh;
  }
  .intel-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .intel-card--wide {
    grid-column: 1 / -1;
  }
}
