* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', system-ui, -apple-system, sans-serif; background: #0d1117; color: #e6e6e6; overflow: hidden; }

/* TOP BAR */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 52px; z-index: 1000;
  background: rgba(13, 17, 30, 0.95); border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; justify-content: space-between; padding: 0 16px;
  backdrop-filter: blur(8px);
}
.topbar-left { display: flex; align-items: center; gap: 8px; }
.logo { font-size: 20px; }
.app-name { font-size: 16px; font-weight: 700; letter-spacing: 0.5px; }
.app-subtitle { font-size: 11px; color: #888; margin-left: 4px; }
.topbar-center { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #ccc; }
.sim-dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; display: inline-block; animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
#sim-clear { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); color: #ccc; padding: 3px 10px; border-radius: 4px; cursor: pointer; font-size: 12px; }
#sim-clear:hover { background: rgba(255,255,255,0.2); }
.btn-simulate { background: #d4553a; color: #fff; border: none; padding: 8px 16px; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.15s; }
.btn-simulate:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-flood { background: rgba(212,85,58,0.15); color: #e8795a; border: 1px solid #e8795a; padding: 8px 16px; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.15s; }
.btn-flood:hover { background: rgba(212,85,58,0.3); }

/* MAP */
#map { position: fixed; top: 52px; left: 0; right: 0; bottom: 0; z-index: 1; }

/* LEGEND */
#legend {
  position: fixed; bottom: 20px; left: 12px; z-index: 1000;
  background: rgba(20, 24, 40, 0.92); border-radius: 8px; padding: 14px 16px;
  font-size: 12px; min-width: 140px; border: 1px solid rgba(255,255,255,0.06);
  backdrop-filter: blur(8px);
}
.legend-title { font-size: 10px; font-weight: 700; letter-spacing: 1.2px; color: #999; margin-bottom: 6px; margin-top: 10px; }
.legend-section:first-child .legend-title { margin-top: 0; }
.legend-item { display: flex; align-items: center; gap: 8px; padding: 2px 0; color: #ccc; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.dot.gsp { background: #e74c3c; }
.dot.grid-sub { background: #f39c12; }
.dot.primary { background: #5dade2; }
.dot.secondary { background: #95a5a6; }
.swatch { width: 20px; height: 12px; border-radius: 2px; flex-shrink: 0; }
.vuln-65 { background: #d73027; }
.vuln-55 { background: #f46d43; }
.vuln-45 { background: #fdae61; }
.vuln-35 { background: #a6d96a; }
.vuln-25 { background: #66bd63; }
.vuln-0 { background: #1a9850; }
.flood-warn { background: #d4553a; }
.flood-alert { background: #e8975a; }

/* RIGHT PANEL */
#detail-panel {
  position: fixed; top: 52px; right: 0; bottom: 0; width: 380px; z-index: 1001;
  background: rgba(20, 24, 40, 0.96); border-left: 1px solid rgba(255,255,255,0.08);
  overflow-y: auto; padding: 20px; transition: transform 0.3s ease;
  backdrop-filter: blur(8px);
}
.panel-hidden { transform: translateX(100%); }
.panel-close { position: absolute; top: 12px; right: 12px; background: none; border: none; color: #888; font-size: 18px; cursor: pointer; z-index: 10; }
.panel-close:hover { color: #fff; }

/* Panel content styles */
.panel-badge { display: inline-block; padding: 3px 10px; border-radius: 4px; font-size: 10px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; }
.badge-warning { background: rgba(212,85,58,0.2); color: #e8795a; border: 1px solid #e8795a; }
.badge-simulation { background: rgba(212,85,58,0.3); color: #ff6b4a; border: 1px solid #ff6b4a; }
.badge-ai { background: rgba(212,85,58,0.3); color: #ff6b4a; }
.panel-zone-id { font-size: 18px; font-weight: 700; margin: 8px 0 4px; }
.panel-zone-river { font-size: 13px; color: #888; }
.panel-section-title { font-size: 10px; font-weight: 700; letter-spacing: 1.2px; color: #999; margin: 18px 0 8px; text-transform: uppercase; }
.panel-stat-big { font-size: 36px; font-weight: 800; color: #e8795a; }
.panel-stat-label { font-size: 12px; color: #999; }
.panel-stat-row { display: flex; gap: 20px; margin: 8px 0; }
.panel-stat-item { text-align: left; }
.panel-stat-item .val { font-size: 18px; font-weight: 700; }
.panel-stat-item .label { font-size: 11px; color: #888; }

/* Substation pills */
.sub-pill { display: inline-block; padding: 4px 10px; margin: 3px; border-radius: 4px; font-size: 11px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); color: #ccc; }

/* Vulnerability bar rows */
.vuln-row { display: flex; align-items: center; justify-content: space-between; padding: 4px 0; }
.vuln-row .lsoa-name { font-size: 12px; color: #ccc; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vuln-row .vuln-bar-container { width: 80px; height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px; margin: 0 8px; flex-shrink: 0; }
.vuln-row .vuln-bar { height: 100%; border-radius: 2px; background: #d4553a; }
.vuln-row .vuln-score { font-size: 12px; font-weight: 700; color: #e8795a; min-width: 32px; text-align: right; }

/* Hospital list */
.hospital-item { font-size: 12px; color: #e8795a; padding: 3px 0; }

/* Simulate / AI buttons */
.btn-simulate-zone {
  display: block; width: 100%; padding: 14px; margin-top: 20px;
  background: linear-gradient(135deg, #d4553a, #e8795a); color: #fff;
  border: none; border-radius: 8px; font-size: 14px; font-weight: 700; cursor: pointer;
  text-align: center; transition: all 0.15s;
}
.btn-simulate-zone:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-ai-assess {
  display: block; width: 100%; padding: 14px; margin-top: 12px;
  background: linear-gradient(135deg, #d4553a, #e8795a); color: #fff;
  border: none; border-radius: 8px; font-size: 14px; font-weight: 700; cursor: pointer;
  text-align: center; transition: all 0.15s;
}
.btn-ai-assess:hover { filter: brightness(1.1); transform: translateY(-1px); }

/* CHAT WIDGET */
#chat-bubble {
  position: fixed; bottom: 20px; right: 20px; z-index: 1002;
  width: 48px; height: 48px; border-radius: 50%;
  background: #d4553a; display: flex; align-items: center; justify-content: center;
  font-size: 20px; cursor: pointer; box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  transition: transform 0.15s;
}
#chat-bubble:hover { transform: scale(1.1); }
#chat-panel {
  position: fixed; bottom: 80px; right: 20px; z-index: 1002;
  width: 360px; max-height: 480px; border-radius: 12px;
  background: rgba(20, 24, 40, 0.96); border: 1px solid rgba(255,255,255,0.1);
  display: flex; flex-direction: column; box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.chat-header { padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,0.08); display: flex; align-items: center; gap: 8px; }
.chat-title { font-size: 14px; font-weight: 700; flex: 1; }
.chat-subtitle { font-size: 11px; color: #4ade80; }
.chat-minimize, .chat-close { background: none; border: none; color: #888; cursor: pointer; font-size: 16px; padding: 4px; }
.chat-minimize:hover, .chat-close:hover { color: #fff; }
#chat-messages { flex: 1; overflow-y: auto; padding: 12px 16px; max-height: 340px; }
.chat-msg { margin: 8px 0; max-width: 85%; word-wrap: break-word; }
.chat-msg.user { margin-left: auto; background: rgba(212,85,58,0.2); color: #f0c0b0; padding: 8px 12px; border-radius: 12px 12px 2px 12px; font-size: 13px; }
.chat-msg.assistant { background: rgba(255,255,255,0.06); color: #ccc; padding: 8px 12px; border-radius: 12px 12px 12px 2px; font-size: 13px; line-height: 1.5; }
.chat-input-area { display: flex; gap: 8px; padding: 12px; border-top: 1px solid rgba(255,255,255,0.08); }
#chat-input { flex: 1; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); border-radius: 8px; padding: 8px 12px; color: #e6e6e6; font-size: 13px; outline: none; }
#chat-input:focus { border-color: #e8795a; }
.chat-send { background: #d4553a; border: none; color: #fff; padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.chat-send:hover { filter: brightness(1.1); }

/* MARKER CLUSTER OVERRIDES */
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large {
  background-color: rgba(232, 121, 90, 0.5) !important;
}
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div {
  background-color: rgba(232, 121, 90, 0.75) !important;
  color: #fff !important; font-weight: 700; font-size: 12px;
}

/* Leaflet popup overrides */
.leaflet-popup-content-wrapper { background: rgba(20, 24, 40, 0.95) !important; color: #ccc !important; border-radius: 8px !important; border: 1px solid rgba(232,121,90,0.3); }
.leaflet-popup-tip { background: rgba(20, 24, 40, 0.95) !important; }
.leaflet-popup-content { font-size: 12px; line-height: 1.5; margin: 10px 14px !important; }
.leaflet-popup-content strong { color: #e8795a; }

/* Hospital markers */
.hospital-icon {
  background: #fff; border: 2px solid #5dade2; width: 22px !important; height: 22px !important;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: #5dade2; border-radius: 3px;
}

/* Layer control override */
.leaflet-control-layers { background: rgba(20, 24, 40, 0.92) !important; color: #ccc !important; border: 1px solid rgba(255,255,255,0.08) !important; }
.leaflet-control-layers label { color: #ccc; }

/* Loading */
#loading { position: fixed; top: 52px; left: 0; right: 0; bottom: 0; background: rgba(13,17,23,0.9); display: flex; align-items: center; justify-content: center; z-index: 2000; font-size: 15px; color: #e8795a; gap: 12px; }
.spinner { width: 28px; height: 28px; border: 3px solid rgba(232,121,90,0.2); border-top-color: #e8795a; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
