html, body {
  height: 100%;
  width: 100%;
  margin: 0;
}

body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #f0f0f0;
}

/* App root */
#app {
  position: relative;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

/* Map fills container */
#map {
  width: 100%;
  height: 100%;
}

/* Loading overlay */
#loadingOverlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 12px;
  background: rgba(15, 15, 18, 0.85);
  z-index: 9999;
}

#loadingOverlay.hidden {
  display: none;
}

#loadingOverlay .spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.25);
  border-top-color: rgba(255, 255, 255, 0.95);
  animation: spin 0.9s linear infinite;
}

#loadingOverlay .loading-text {
  color: #fff;
  font-size: 14px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* App Shell */
.app-shell {
  height: 100vh;
  width: 100%;
  overflow: hidden;
  position: relative;
}

/* Left panel for threat details */
.left-panel {
  position: absolute;
  left: 0;
  top: 0;
  width: 360px;
  height: 100%;
  background: rgba(17, 24, 39, 0.96);
  backdrop-filter: blur(12px);
  color: #fff;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(59, 130, 246, 0.2);
  transition: transform 0.25s ease;
  z-index: 1000;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.3);
}

.left-panel.hidden {
  transform: translateX(-100%);
}

.panel-header {
  padding: 12px 12px 16px 12px;
  border-bottom: 1px solid rgba(59, 130, 246, 0.15);
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(0, 0, 0, 0.2);
}

.panel-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #60a5fa;
  padding-top: 20px;
}

.panel-header button {
  padding: 10px 14px;
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.panel-header button:hover {
  transform: scale(1.02);
}

#showThreatMapBtn:hover {
  background: #059669 !important;
}

#panelHideBtn:hover {
  background: #dc2626 !important;
}

/* Floating close button for left panel - hidden */
.floating-panel-close {
  display: none !important;
  position: fixed !important;
  top: 100px !important;
  left: 380px !important;
  z-index: 99999 !important;
  padding: 16px 28px !important;
  background: #dc2626 !important;
  backdrop-filter: blur(8px);
  border: 4px solid #ffffff !important;
  border-radius: 8px;
  color: white !important;
  cursor: pointer;
  font-size: 18px !important;
  font-weight: 700;
  transition: all 0.2s;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.8) !important;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.floating-panel-close:hover {
  background: #b91c1c;
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(220, 38, 38, 0.6);
  border-color: #fef2f2;
}

.floating-panel-close.hidden {
  display: none;
}

/* Color legend for country view */
.country-legend {
  position: absolute;
  bottom: 25px;
  left: 10px;
  z-index: 600;
  background: rgba(50, 50, 55, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 12px 16px;
  padding-bottom: 20px;
  color: white;
  font-size: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.country-legend.hidden {
  display: none;
}

.country-legend h4 {
  margin: 0 0 8px 0;
  font-size: 13px;
  font-weight: 600;
  color: #60a5fa;
}

.legend-close {
  position: absolute;
  bottom: 4px;
  right: 6px;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.legend-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
}

.legend-color {
  width: 24px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.legend-label {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.9);
}

/* Layer Control Panel */
.layer-control {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 700;
}

.layer-control-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 6px;
  color: #83888D;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.layer-control-toggle:hover {
  background: rgba(255, 255, 255, 1);
  border-color: rgba(0, 123, 255, 0.8);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.layer-control-toggle .icon {
  font-size: 16px;
}

.layer-control-panel {
  display: none;
  margin-top: 8px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  min-width: 220px;
}

.layer-control.expanded .layer-control-panel {
  display: block;
}

.layer-control-header {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.layer-control-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #83888D;
}

.layer-control-content {
  padding: 8px;
}

.layer-item {
  padding: 8px 6px;
  border-radius: 4px;
  transition: background 0.2s;
}

.layer-item:hover:not(.disabled) {
  background: rgba(0, 0, 0, 0.05);
}

.layer-item.disabled {
  opacity: 0.4;
}

.layer-item label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: #83888D;
  font-size: 13px;
}

.layer-item.disabled label {
  cursor: not-allowed;
}

.layer-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #3b82f6;
}

.layer-item input[type="checkbox"]:disabled {
  cursor: not-allowed;
}

.layer-name {
  flex: 1;
}

.layer-mode {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  margin-left: 24px;
}

.ta-mode-btn {
  flex: 1;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 4px;
  color: #83888D;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
}

.ta-mode-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #333;
}

.ta-mode-btn.active {
  background: #3b82f6;
  border-color: #3b82f6;
  color: white;
}

.layer-note {
  margin-top: 12px;
  padding: 8px 6px;
  font-size: 11px;
  color: #83888D;
  font-style: italic;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  line-height: 1.4;
}

.ip-lookup-row {
  display: flex;
  gap: 4px;
  margin-bottom: 3px;
}

.ip-lookup-input {
  width: 15ch;
  min-width: 0;
  flex: none;
  padding: 4px 6px;
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 4px;
  color: #83888D;
  font-size: 11px;
  outline: none;
  transition: border-color 0.15s;
}

.ip-lookup-input::placeholder {
  color: rgba(131, 136, 141, 0.5);
}

.ip-lookup-input:focus {
  border-color: rgba(0, 0, 0, 0.3);
  background: rgba(0, 0, 0, 0.12);
}

@keyframes ip-blink-red {
  0%   { border-color: #dc2626; background: rgba(220, 38, 38, 0.12); }
  50%  { border-color: #f87171; background: rgba(220, 38, 38, 0.05); }
  100% { border-color: #dc2626; background: rgba(220, 38, 38, 0.12); }
}

.ip-lookup-input.ip-input-error {
  animation: ip-blink-red 0.35s ease-in-out 2;
  border-color: #dc2626;
}

.ip-lookup-btn {
  padding: 4px 7px;
  background: rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  color: #83888D;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.ip-lookup-btn:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.18);
  color: #555;
}

.ip-lookup-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ip-find-row {
  display: none;
}

.ip-find-btn {
  padding: 4px 6px;
  background: rgba(0, 0, 0, 0.07);
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  color: #83888D;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
  line-height: 1;
}

.ip-find-btn:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.14);
  color: #555;
}

.ip-find-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ip-lookup-status {
  font-size: 10px;
  color: #83888D;
  min-height: 12px;
  line-height: 1.3;
  word-break: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  max-width: 100%;
}

.panel-meta {
  padding: 14px 20px;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 13px;
  color: rgba(255, 255, 255, 0.9);
}

.panel-list {
  flex: 1;
  overflow-y: auto;
}

.panel-list::-webkit-scrollbar {
  width: 6px;
}

.panel-list::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
}

.panel-list::-webkit-scrollbar-thumb {
  background: rgba(59, 130, 246, 0.3);
  border-radius: 3px;
}

.panel-list::-webkit-scrollbar-thumb:hover {
  background: rgba(59, 130, 246, 0.5);
}

/* Map host takes full space */
.map-host {
  width: 100%;
  height: 100%;
  position: relative;
}

.map-host #map {
  width: 100%;
  height: 100%;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* App Shell */
.app-shell {
  height: 100vh;
  width: 100%;
  overflow: hidden;
  position: relative;
}

  flex: 1;
  overflow-y: auto;
}

.panel-list::-webkit-scrollbar {
  width: 6px;
}

.panel-list::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
}

.panel-list::-webkit-scrollbar-thumb {
  background: rgba(59, 130, 246, 0.3);
  border-radius: 3px;
}

.panel-list::-webkit-scrollbar-thumb:hover {
  background: rgba(59, 130, 246, 0.5);
}

/* Map host takes full space */
.map-host {
  width: 100%;
  height: 100%;
  position: relative;
}

.map-host #map {
  width: 100%;
  height: 100%;
}

/* -----------------------------------------------------------------------
   Cyber News Ticker
   Fixed bar along the bottom of the viewport.
   Inner span is doubled for a seamless CSS scroll loop.
----------------------------------------------------------------------- */
.news-ticker {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: rgba(12, 18, 28, 0.92);
  backdrop-filter: blur(8px);
  border-top: 1px solid rgba(59, 130, 246, 0.3);
  display: flex;
  align-items: center;
  z-index: 750;
  overflow: hidden;
}
.news-ticker.hidden { display: none; }
.news-ticker-label {
  flex-shrink: 0;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #60a5fa;
  border-right: 1px solid rgba(59, 130, 246, 0.3);
  white-space: nowrap;
  height: 100%;
  display: flex;
  align-items: center;
}
.news-ticker-scroll {
  flex: 1;
  overflow: hidden;
  height: 100%;
  display: flex;
  align-items: center;
}
#newsTickerInner {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  animation: ticker-scroll 70s linear infinite;
}
#newsTickerInner:hover { animation-play-state: paused; }
@keyframes ticker-scroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}
.news-ticker-item {
  color: rgba(220, 230, 245, 0.88);
  text-decoration: none;
  font-size: 15px;
  padding: 0 4px;
  transition: color 0.2s;
}
.news-ticker-item:hover { color: #93c5fd; text-decoration: underline; }
.news-ticker-source {
  color: #60a5fa;
  font-weight: 600;
  font-size: 13px;
  margin-right: 5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.news-ticker-sep {
  color: rgba(59, 130, 246, 0.4);
  padding: 0 14px;
  font-size: 11px;
}
