/* Design System & Variables */
:root {
  /* Common values */
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --border-radius: 16px;
  --transition-speed: 0.4s;
  
  /* Status/Threat colors */
  --color-safe: #10b981;
  --color-safe-glow: rgba(16, 185, 129, 0.2);
  --color-medium: #f59e0b;
  --color-medium-glow: rgba(245, 158, 11, 0.2);
  --color-high: #ef4444;
  --color-high-glow: rgba(239, 68, 68, 0.35);
}

/* Dark Theme Variables (Default) */
body, body[data-theme="dark"] {
  --bg-main: #060913;
  --bg-panel: rgba(13, 20, 35, 0.5);
  --bg-panel-opaque: rgba(13, 20, 35, 0.96);
  --bg-card: rgba(22, 30, 49, 0.35);
  --bg-input: rgba(0, 0, 0, 0.25);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.16);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  
  --accent-cyan: #00f0ff;
  --accent-cyan-glow: rgba(0, 240, 255, 0.25);
  --shadow-color: rgba(0, 0, 0, 0.4);
  
  --glass-shine: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, transparent 100%);
  --blob-opacity: 0.14;
}

/* Light Theme Variables */
body[data-theme="light"] {
  --bg-main: #eef2f6;
  --bg-panel: rgba(255, 255, 255, 0.6);
  --bg-panel-opaque: rgba(238, 242, 246, 0.96);
  --bg-card: rgba(255, 255, 255, 0.4);
  --bg-input: rgba(255, 255, 255, 0.85);
  --border-color: rgba(15, 23, 42, 0.09);
  --border-hover: rgba(15, 23, 42, 0.18);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  
  --accent-cyan: #0284c7;
  --accent-cyan-glow: rgba(2, 132, 199, 0.2);
  --shadow-color: rgba(31, 38, 135, 0.06);
  
  --glass-shine: linear-gradient(135deg, rgba(255, 255, 255, 0.3) 0%, transparent 100%);
  --blob-opacity: 0.09;
}

/* Base resets & styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-sans);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
  transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
}

/* Liquid background animated blobs */
.liquid-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background: transparent;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  mix-blend-mode: screen;
  opacity: var(--blob-opacity);
  transition: opacity var(--transition-speed) ease;
}

body[data-theme="light"] .blob {
  mix-blend-mode: multiply;
  filter: blur(120px);
}

.blob-cyan {
  top: -10%;
  left: -10%;
  width: 60vw;
  height: 60vw;
  background: radial-gradient(circle, var(--accent-cyan) 0%, rgba(0, 240, 255, 0.2) 80%);
  animation: float-blob-cyan 25s ease-in-out infinite alternate;
}

.blob-rose {
  bottom: -20%;
  right: -10%;
  width: 65vw;
  height: 65vw;
  background: radial-gradient(circle, #f43f5e 0%, rgba(244, 63, 94, 0.2) 80%);
  animation: float-blob-rose 30s ease-in-out infinite alternate;
}

.blob-amber {
  top: 40%;
  left: 45%;
  width: 40vw;
  height: 40vw;
  background: radial-gradient(circle, var(--color-medium) 0%, rgba(245, 158, 11, 0.15) 80%);
  animation: float-blob-amber 22s ease-in-out infinite alternate;
}

/* Theme Toggle Button */
.btn-theme-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-primary);
  transition: all var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 10px 0 var(--shadow-color);
  position: relative;
  overflow: hidden;
  margin-right: 8px;
}

.btn-theme-toggle:hover {
  transform: scale(1.1) rotate(15deg);
  border-color: var(--border-hover);
  background: var(--bg-panel);
}

.btn-theme-toggle:active {
  transform: scale(0.95);
}

.theme-icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
  position: absolute;
  transition: transform var(--transition-speed) ease, opacity var(--transition-speed) ease;
}

body[data-theme="light"] .icon-moon {
  opacity: 0;
  transform: translateY(-20px) rotate(-90deg);
}

body[data-theme="light"] .icon-sun {
  opacity: 1;
  transform: translateY(0) rotate(0);
}

body:not([data-theme="light"]) .icon-moon {
  opacity: 1;
  transform: translateY(0) rotate(0);
}

body:not([data-theme="light"]) .icon-sun {
  opacity: 0;
  transform: translateY(20px) rotate(90deg);
}

/* Liquid Blob Animations */
@keyframes float-blob-cyan {
  0% {
    transform: translate(0, 0) scale(1) rotate(0deg);
    border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
  }
  50% {
    transform: translate(10vw, 5vh) scale(1.1) rotate(180deg);
    border-radius: 50% 50% 30% 70% / 50% 60% 40% 50%;
  }
  100% {
    transform: translate(-5vw, 15vh) scale(0.9) rotate(360deg);
    border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
  }
}

@keyframes float-blob-rose {
  0% {
    transform: translate(0, 0) scale(1) rotate(0deg);
    border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
  }
  50% {
    transform: translate(-8vw, -10vh) scale(0.9) rotate(-180deg);
    border-radius: 40% 60% 50% 50% / 50% 50% 50% 50%;
  }
  100% {
    transform: translate(5vw, 5vh) scale(1.1) rotate(-360deg);
    border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
  }
}

@keyframes float-blob-amber {
  0% {
    transform: translate(0, 0) scale(1) rotate(0deg);
    border-radius: 40% 60% 60% 40% / 40% 40% 60% 60%;
  }
  50% {
    transform: translate(-15vw, 10vh) scale(1.2) rotate(120deg);
    border-radius: 70% 30% 50% 50% / 50% 70% 30% 50%;
  }
  100% {
    transform: translate(10vw, -10vh) scale(0.8) rotate(240deg);
    border-radius: 40% 60% 60% 40% / 40% 40% 60% 60%;
  }
}

/* App container */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 24px;
  max-width: 1600px;
  margin: 0 auto;
  gap: 24px;
  z-index: 10;
  position: relative;
}

/* Header styling */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-panel);
  backdrop-filter: blur(24px) saturate(120%);
  -webkit-backdrop-filter: blur(24px) saturate(120%);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 20px 32px;
  box-shadow: 0 10px 40px 0 var(--shadow-color);
  position: relative;
  overflow: hidden;
  transition: all var(--transition-speed) ease;
}

.app-header::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  background: var(--glass-shine);
  pointer-events: none;
  z-index: 1;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 20px;
  z-index: 2;
}

.title-container h1 {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--text-primary);
  transition: color var(--transition-speed) ease;
}

.title-container h1 span {
  color: var(--accent-cyan);
  text-shadow: 0 0 10px var(--accent-cyan-glow);
  transition: color var(--transition-speed) ease, text-shadow var(--transition-speed) ease;
}

.subtitle {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  letter-spacing: 3px;
  margin-top: 2px;
  transition: color var(--transition-speed) ease;
}

/* Radar Animation */
.radar-container {
  position: relative;
  width: 50px;
  height: 50px;
  background: #111827;
  border: 2px solid var(--accent-cyan);
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 0 15px var(--accent-cyan-glow);
}

.radar-sweep {
  position: absolute;
  width: 100%;
  height: 100%;
  background: conic-gradient(from 0deg, transparent 50%, var(--accent-cyan-glow) 100%);
  animation: radar-sweep-anim 4s linear infinite;
  transform-origin: center;
}

.radar-blip {
  position: absolute;
  top: 30%;
  left: 40%;
  width: 6px;
  height: 6px;
  background: var(--color-high);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--color-high);
  animation: blip-anim 2s ease-out infinite;
}

@keyframes radar-sweep-anim {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes blip-anim {
  0% { transform: scale(0.5); opacity: 0; }
  50% { opacity: 1; }
  100% { transform: scale(2.5); opacity: 0; }
}

/* System status bar */
.system-status-panel {
  display: flex;
  align-items: center;
  gap: 20px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.2);
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

.status-dot {
  width: 10px;
  height: 10px;
  background: var(--accent-cyan);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-cyan);
}

.status-dot.pulsing {
  animation: status-pulse 1.5s infinite alternate;
}

.status-dot.safe {
  background: var(--color-safe);
  box-shadow: 0 0 8px var(--color-safe);
}

.status-dot.warning {
  background: var(--color-high);
  box-shadow: 0 0 8px var(--color-high);
}

.status-text {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
}

.last-check {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #64748b;
}

@keyframes status-pulse {
  0% { opacity: 0.4; transform: scale(0.9); }
  100% { opacity: 1; transform: scale(1.1); }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition-speed) ease;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--accent-cyan);
  color: #0f172a;
  box-shadow: 0 4px 14px var(--accent-cyan-glow);
}

.btn-primary:hover {
  background: #00d8e6;
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card);
  color: #e2e8f0;
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-hover);
}

.btn-success {
  background: var(--color-safe);
  color: #0f172a;
}

.btn-success:hover {
  background: #059669;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 6px;
}

.btn-full {
  width: 100%;
}

.icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* Dashboard Grid Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 380px 1fr 420px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 1400px) {
  .dashboard-grid {
    grid-template-columns: 350px 1fr;
  }
  .feed-area {
    grid-column: span 2;
  }
}

@media (max-width: 968px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .feed-area, .map-area {
    grid-column: span 1;
  }
}

/* Sidebar Columns */
.control-sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.metrics-grid .metric-card:first-child {
  grid-column: span 2;
}

/* Glass Panels */
.glass-panel {
  background: var(--bg-panel);
  backdrop-filter: blur(24px) saturate(120%);
  -webkit-backdrop-filter: blur(24px) saturate(120%);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 24px;
  box-shadow: 0 10px 40px 0 var(--shadow-color);
  position: relative;
  overflow: hidden;
  transition: background var(--transition-speed) ease, border var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
}

.glass-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  background: var(--glass-shine);
  pointer-events: none;
  z-index: 1;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  z-index: 2;
  position: relative;
}

.glass-panel h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: color var(--transition-speed) ease;
}

.header-icon {
  width: 20px;
  height: 20px;
  fill: var(--accent-cyan);
}

/* Metric Card */
.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  box-shadow: 0 4px 20px 0 var(--shadow-color);
  position: relative;
  overflow: hidden;
  transition: all var(--transition-speed) ease;
}

.metric-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  background: var(--glass-shine);
  pointer-events: none;
  z-index: 1;
}

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 2;
  position: relative;
}

.metric-title {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  letter-spacing: 1px;
  transition: color var(--transition-speed) ease;
}

.threat-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--border-hover);
  transition: all var(--transition-speed) ease;
}

.metric-value {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 1px;
  color: var(--color-safe);
  margin: 6px 0;
  z-index: 2;
  position: relative;
  transition: color var(--transition-speed) ease;
}

.metric-value-large {
  font-size: 40px;
  font-weight: 900;
  color: var(--text-primary);
  font-family: var(--font-mono);
  z-index: 2;
  position: relative;
  transition: color var(--transition-speed) ease;
}

.metric-footer {
  font-size: 12px;
  color: var(--text-secondary);
  z-index: 2;
  position: relative;
  transition: color var(--transition-speed) ease;
}

/* Alert levels in metrics */
.metric-card.alert-level-high {
  border-color: rgba(239, 68, 68, 0.2);
  background: radial-gradient(circle at 90% 10%, rgba(239, 68, 68, 0.05) 0%, transparent 70%), var(--bg-card);
}

.metric-card.alert-level-high .metric-value {
  color: var(--color-safe);
  text-shadow: none;
}

/* Danger Threat levels */
.metric-card.alert-level-danger {
  border-color: var(--color-high);
  box-shadow: 0 10px 30px rgba(239, 68, 68, 0.25);
  background: radial-gradient(circle at 90% 10%, rgba(239, 68, 68, 0.15) 0%, transparent 70%), var(--bg-card);
}

.metric-card.alert-level-danger .metric-value {
  color: var(--color-high);
  text-shadow: 0 0 10px var(--color-high-glow);
  animation: glow-pulse 1s infinite alternate;
}

.metric-card.alert-level-danger .threat-badge {
  background: var(--color-high);
  color: #fff;
}

/* Medium Threat levels */
.metric-card.alert-level-warning {
  border-color: var(--color-medium);
  box-shadow: 0 10px 30px rgba(245, 158, 11, 0.2);
  background: radial-gradient(circle at 90% 10%, rgba(245, 158, 11, 0.1) 0%, transparent 70%), var(--bg-card);
}

.metric-card.alert-level-warning .metric-value {
  color: var(--color-medium);
  text-shadow: 0 0 10px var(--color-medium-glow);
}

.metric-card.alert-level-warning .threat-badge {
  background: var(--color-medium);
  color: #000;
}

@keyframes glow-pulse {
  from { text-shadow: 0 0 5px var(--color-high-glow); }
  to { text-shadow: 0 0 15px var(--color-high); }
}

/* Settings Form */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
  transition: color var(--transition-speed) ease;
}

.form-group textarea,
.form-group input,
.form-group select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  transition: all var(--transition-speed) ease;
}

.form-group textarea:focus,
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan-glow);
}

.alert-settings-shortcuts {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 15px;
}

.alert-settings-shortcuts .btn {
  text-align: left;
  justify-content: flex-start;
}

/* Feed Area */
.feed-area {
  display: flex;
  flex-direction: column;
  min-height: 500px;
}

.feed-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 16px;
}

.feed-header h2 {
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 12px;
}

.alert-icon {
  width: 24px;
  height: 24px;
  fill: var(--color-high);
}

.feed-filters {
  display: flex;
  background: var(--bg-input);
  padding: 4px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  transition: all var(--transition-speed) ease;
}

.filter-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 6px 16px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 4px;
  transition: all var(--transition-speed) ease;
}

.filter-btn:hover {
  color: var(--text-primary);
}

.filter-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: 0 2px 8px 0 var(--shadow-color);
}

/* Alert Feed list */
.alert-feed-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex-grow: 1;
  max-height: 700px;
  overflow-y: auto;
  padding-right: 8px;
}

/* Custom Scrollbar for Alert Feed */
.alert-feed-container::-webkit-scrollbar {
  width: 6px;
}

.alert-feed-container::-webkit-scrollbar-track {
  background: transparent;
}

.alert-feed-container::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: 3px;
  transition: background var(--transition-speed) ease;
}

.alert-feed-container::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Feed Status Placeholders */
.feed-status-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-grow: 1;
  color: var(--text-secondary);
  font-size: 14px;
  position: relative;
  overflow: hidden;
  border: 1px dashed var(--border-color);
  border-radius: var(--border-radius);
  padding: 40px;
  transition: all var(--transition-speed) ease;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--accent-cyan-glow);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.scanner-line {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-cyan), transparent);
  animation: scan-line-anim 3s ease-in-out infinite;
  box-shadow: 0 0 8px var(--accent-cyan);
}

@keyframes scan-line-anim {
  0% { top: 0%; }
  50% { top: 100%; }
  100% { top: 0%; }
}

.no-alerts-placeholder {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}

/* Message Card style */
.message-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 20px;
  transition: all var(--transition-speed) ease, border-left 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 4px 15px 0 var(--shadow-color);
}

.message-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
  box-shadow: 0 8px 30px var(--shadow-color);
}

.message-card.threat-high {
  border-left: 4px solid var(--color-high);
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.03) 0%, transparent 100%), var(--bg-card);
}
.message-card.threat-high:hover {
  border-color: var(--border-hover);
  border-left-color: var(--color-high);
  box-shadow: 0 8px 30px var(--shadow-color);
}

.message-card.threat-medium {
  border-left: 4px solid var(--color-medium);
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.02) 0%, transparent 100%), var(--bg-card);
}
.message-card.threat-medium:hover {
  border-color: var(--border-hover);
  border-left-color: var(--color-medium);
  box-shadow: 0 8px 30px var(--shadow-color);
}

.message-card.threat-low {
  border-left: 4px solid var(--accent-cyan);
}

/* Card Header & Metadata */
.msg-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.msg-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}

.msg-channel {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-cyan);
}

.msg-threat-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.5px;
  display: inline-block;
}

.msg-threat-tag.high {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.msg-threat-tag.medium {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.msg-threat-tag.low, .msg-threat-tag.neutral {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.msg-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  transition: color var(--transition-speed) ease;
}

/* Card Body */
.msg-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  transition: color var(--transition-speed) ease;
  margin-top: 4px;
}

/* Keyword highlighting inside text */
.highlight-keyword {
  background: rgba(0, 240, 255, 0.12) !important;
  color: var(--accent-cyan) !important;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(0, 240, 255, 0.25);
  transition: all 0.3s ease;
}

.highlight-threat {
  background: rgba(239, 68, 68, 0.15) !important;
  color: #fca5a5 !important;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(239, 68, 68, 0.35);
  transition: all 0.3s ease;
}

/* Card Footer */
.msg-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-color);
  padding-top: 10px;
  font-size: 12px;
  color: var(--text-secondary);
  transition: border-top-color var(--transition-speed) ease, color var(--transition-speed) ease;
}

.msg-views {
  display: flex;
  align-items: center;
  gap: 4px;
}

.msg-link {
  color: var(--accent-cyan);
  text-decoration: none;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: opacity var(--transition-speed) ease, color var(--transition-speed) ease;
}

.msg-link:hover {
  opacity: 0.8;
  text-decoration: underline;
}

/* App Footer styling */
.app-footer {
  text-align: center;
  padding: 16px;
  color: var(--text-secondary);
  font-size: 12px;
  border-top: 1px solid var(--border-color);
  margin-top: auto;
  transition: all var(--transition-speed) ease;
}

.form-group-divider {
  margin: 24px 0 16px 0;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent-cyan);
  transition: border-bottom-color var(--transition-speed) ease;
}

.checkbox-group {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
}

.checkbox-group input[type="checkbox"] {
  width: auto;
  margin: 0;
  cursor: pointer;
}

.tg-collapsible-settings {
  transition: all var(--transition-speed) ease;
}

/* Location item editor styles */
.location-item-block {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 2px 8px 0 var(--shadow-color);
  transition: all var(--transition-speed) ease;
}

.location-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 6px;
  transition: border-bottom-color var(--transition-speed) ease;
}

.location-item-header h4 {
  font-size: 12px;
  color: var(--accent-cyan);
}

.btn-remove-location {
  background: transparent;
  border: none;
  color: var(--color-high);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}

.form-group-sub {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group-sub label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  transition: color var(--transition-speed) ease;
}

.form-group-sub input {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 6px 10px;
  color: var(--text-primary);
  font-size: 12px;
  transition: all var(--transition-speed) ease;
}

.form-group-sub input:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 6px var(--accent-cyan-glow);
}

.msg-location-badge {
  font-size: 10px;
  font-weight: 700;
  background: rgba(0, 240, 255, 0.06);
  color: var(--accent-cyan);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(0, 240, 255, 0.1);
  letter-spacing: 0.5px;
}

/* Interactive Map Area */
.map-area {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
}

.map-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.map-legend {
  display: flex;
  gap: 14px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot.status-safe {
  background: var(--color-safe);
  box-shadow: 0 0 6px var(--color-safe);
}

.legend-dot.status-medium {
  background: var(--color-medium);
  box-shadow: 0 0 6px var(--color-medium);
}

.legend-dot.status-high {
  background: var(--color-high);
  box-shadow: 0 0 6px var(--color-high);
}

.map-wrapper {
  position: relative;
  width: 100%;
  height: 600px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.4);
}

@media (max-width: 768px) {
  .map-wrapper {
    height: 380px;
  }
}

#map {
  width: 100%;
  height: 100%;
  background: #0d121f;
  z-index: 1;
}

body[data-theme="light"] #map {
  background: #e4e9f0;
}

/* Map Overlay Panel (Active locations list) */
.map-overlay-panel {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 10;
  width: 240px;
  background: rgba(10, 16, 30, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 14px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
  max-height: calc(100% - 32px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all var(--transition-speed) ease;
}

body[data-theme="light"] .map-overlay-panel {
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.08);
}

.map-overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
  margin-bottom: 4px;
}

.map-overlay-panel h3 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-primary);
  margin: 0;
  border: none;
  padding: 0;
}

.map-overlay-toggle {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease, color 0.2s ease;
  border-radius: 4px;
}

.map-overlay-toggle:hover {
  color: var(--accent-cyan);
  background: rgba(255, 255, 255, 0.05);
}

.map-overlay-panel.collapsed {
  width: 48px;
  overflow: hidden;
  height: 48px;
  padding: 10px;
}

.map-overlay-panel.collapsed h3,
.map-overlay-panel.collapsed .map-location-list {
  display: none;
}

.map-overlay-panel.collapsed .map-overlay-toggle {
  transform: rotate(180deg);
}

.map-location-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
  padding-right: 4px;
}

/* Custom Scrollbar for overlays */
.map-location-list::-webkit-scrollbar {
  width: 4px;
}
.map-location-list::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.map-location-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

body[data-theme="light"] .map-location-item {
  background: rgba(0, 0, 0, 0.02);
}

.map-location-item:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--border-hover);
  transform: translateX(2px);
}

body[data-theme="light"] .map-location-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

.map-location-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.map-location-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  text-transform: uppercase;
}

.badge-safe {
  background: rgba(16, 185, 129, 0.15);
  color: var(--color-safe);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-medium {
  background: rgba(245, 158, 11, 0.15);
  color: var(--color-medium);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-high {
  background: rgba(239, 68, 68, 0.15);
  color: var(--color-high);
  border: 1px solid rgba(239, 68, 68, 0.35);
  animation: pulse-high-bg 1.5s infinite alternate;
}

@keyframes pulse-high-bg {
  0% { box-shadow: 0 0 2px var(--color-high); }
  100% { box-shadow: 0 0 8px var(--color-high); }
}

/* Custom Leaflet overrides */
.leaflet-container {
  font-family: var(--font-sans) !important;
}

.leaflet-bar {
  border: 1px solid var(--border-color) !important;
  box-shadow: 0 4px 12px var(--shadow-color) !important;
  border-radius: 8px !important;
  overflow: hidden;
}

.leaflet-bar a {
  background-color: var(--bg-panel) !important;
  color: var(--text-primary) !important;
  border-bottom: 1px solid var(--border-color) !important;
  transition: all 0.2s ease;
}

.leaflet-bar a:hover {
  background-color: var(--border-hover) !important;
  color: var(--accent-cyan) !important;
}

/* Popup Glassmorphism styling */
.leaflet-popup-content-wrapper {
  background: rgba(10, 16, 30, 0.88) !important;
  backdrop-filter: blur(16px) !important;
  -webkit-backdrop-filter: blur(16px) !important;
  border: 1px solid var(--border-color) !important;
  color: var(--text-primary) !important;
  border-radius: 12px !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5) !important;
  padding: 4px;
}

body[data-theme="light"] .leaflet-popup-content-wrapper {
  background: rgba(255, 255, 255, 0.92) !important;
  box-shadow: 0 10px 30px rgba(31, 38, 135, 0.08) !important;
}

.leaflet-popup-tip {
  background: rgba(10, 16, 30, 0.88) !important;
  border-left: 1px solid var(--border-color) !important;
  border-bottom: 1px solid var(--border-color) !important;
}

body[data-theme="light"] .leaflet-popup-tip {
  background: rgba(255, 255, 255, 0.92) !important;
}

.leaflet-popup-content {
  margin: 12px 14px !important;
  line-height: 1.4 !important;
}

/* Custom Popup content inside map */
.map-popup-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 220px;
}

.map-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 6px;
}

.map-popup-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.map-popup-status {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 8px;
}

.map-popup-body {
  font-size: 12px;
  color: var(--text-secondary);
}

.map-popup-alerts-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-primary);
  margin-top: 4px;
  margin-bottom: 4px;
  letter-spacing: 0.5px;
}

.map-popup-alerts-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 120px;
  overflow-y: auto;
  margin-bottom: 8px;
}

.map-popup-alert-item {
  font-size: 11px;
  background: rgba(255, 255, 255, 0.04);
  padding: 6px 8px;
  border-radius: 6px;
  border-left: 2px solid var(--color-safe);
}

.map-popup-alert-item.alert-medium {
  border-left-color: var(--color-medium);
}

.map-popup-alert-item.alert-high {
  border-left-color: var(--color-high);
}

.map-popup-alert-time {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 2px;
}

.map-popup-alert-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
}

.map-popup-footer {
  margin-top: 4px;
}

.btn-popup-join {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 8px 12px;
  background: #24A1DE;
  color: #fff !important;
  text-decoration: none;
  font-size: 11px;
  font-weight: 700;
  border-radius: 6px;
  text-align: center;
  transition: background 0.2s ease;
}

.btn-popup-join:hover {
  background: #1d82b2;
}

/* Custom Marker styles */
.map-pulse-marker {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-safe);
  border: 2px solid #fff;
  box-shadow: 0 0 10px rgba(0,0,0,0.5);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.map-pulse-marker.threatened {
  width: 32px;
  height: 32px;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.6);
}

.map-pulse-marker.marker-medium {
  background: var(--color-medium);
}

.map-pulse-marker.marker-high {
  background: var(--color-high);
}

.map-pulse-marker::after {
  content: '';
  position: absolute;
  top: -6px;
  left: -6px;
  right: -6px;
  bottom: -6px;
  border-radius: 50%;
  border: 2px solid var(--color-safe);
  opacity: 0;
  animation: marker-pulse-anim 1.5s infinite;
  pointer-events: none;
}

.map-pulse-marker.threatened::after {
  top: -8px;
  left: -8px;
  right: -8px;
  bottom: -8px;
}

.map-pulse-marker.marker-medium::after {
  border-color: var(--color-medium);
}

.map-pulse-marker.marker-high::after {
  border-color: var(--color-high);
}

.threat-icon-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 16px;
  line-height: 1;
}

.threat-icon-badge .threat-icon-img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.2));
}

@keyframes marker-pulse-anim {
  0% { transform: scale(0.6); opacity: 0; }
  50% { opacity: 0.5; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* Threat Polygon highlight animations (flashing borders) */
.leaflet-interactive {
  transition: stroke var(--transition-speed) ease, fill var(--transition-speed) ease, stroke-dashoffset 2s linear;
}

.threat-polygon-high {
  animation: polygon-glow-high 2s infinite alternate;
}

.threat-polygon-medium {
  animation: polygon-glow-medium 2s infinite alternate;
}

@keyframes polygon-glow-high {
  0% { stroke-opacity: 0.7; fill-opacity: 0.25; }
  100% { stroke-opacity: 1; fill-opacity: 0.45; }
}

@keyframes polygon-glow-medium {
  0% { stroke-opacity: 0.6; fill-opacity: 0.15; }
  100% { stroke-opacity: 0.9; fill-opacity: 0.3; }
}

/* Custom styles for Telegram Link editor in settings */
.settings-loc-channel-link {
  font-size: 11px;
  width: 100%;
  padding: 6px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  margin-top: 4px;
}

/* Fullscreen mode for map-area */
.map-area.fullscreen-mode {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 2000;
  background: var(--bg-dashboard);
  padding: 20px;
  border-radius: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
}

.map-area.fullscreen-mode .map-wrapper {
  height: calc(100vh - 100px) !important;
  flex: 1;
}

/* Map search box */
.map-search-box {
  position: relative;
  display: flex;
  align-items: center;
  margin: 0 16px;
}

.map-search-box input {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 6px 12px 6px 32px;
  border-radius: 20px;
  font-size: 13px;
  width: 180px;
  transition: all 0.3s ease;
}

.map-search-box input:focus {
  width: 240px;
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan-glow);
}

.map-search-box .search-icon {
  position: absolute;
  left: 10px;
  font-size: 12px;
  color: var(--text-secondary);
  pointer-events: none;
}

/* Coordinates HUD */
.map-coordinates-hud {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 10;
  background: rgba(10, 16, 30, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 4px 8px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: color var(--transition-speed) ease, background var(--transition-speed) ease;
}

body[data-theme="light"] .map-coordinates-hud {
  background: rgba(255, 255, 255, 0.85);
  color: var(--text-primary);
}

/* Fullscreen client layout */
.client-layout-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#map-fullscreen-container {
  width: 100%;
  height: 100%;
  position: relative;
}

#map-fullscreen-container #map {
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Floating header over the map */
.floating-header {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: auto;
  max-width: 95vw;
  z-index: 100;
  margin: 0;
  border-radius: 40px; /* Capsule shape */
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
  padding: 8px 20px;
  gap: 24px;
}

.floating-header .brand p {
  display: none; /* Hide subtitle to keep it compact */
}

.floating-header .brand h1 {
  font-size: 15px;
  letter-spacing: 0.5px;
  margin: 0;
}

.floating-header .app-logo {
  font-size: 16px;
}

.floating-header .status-indicator {
  padding: 6px 12px;
}

.floating-header .status-text {
  font-size: 10px;
}

/* Floating Left Panel for stats & tools */
.floating-left-panel {
  position: absolute;
  top: 100px;
  left: 16px;
  width: 220px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
  border-radius: 12px;
}

.floating-panel-section {
  display: flex;
  flex-direction: column;
}

.panel-divider {
  border: 0;
  border-top: 1px solid var(--border-color);
  margin: 4px 0;
}

.metric-mini {
  padding: 10px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-mini .title {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  opacity: 0.7;
}

.metric-mini .value {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1px;
}

.metric-mini-stat {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
}

.metric-mini-stat div {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.metric-mini-stat div:first-child {
  border-right: 1px solid var(--border-color);
}

.metric-mini-stat .num {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-cyan);
}

.metric-mini-stat .lbl {
  font-size: 9px;
  color: var(--text-secondary);
  text-transform: uppercase;
}

/* Floating action button for TG feed */
.floating-feed-btn {
  position: absolute;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 30px;
  box-shadow: 0 4px 20px rgba(0, 240, 255, 0.25);
  font-weight: 600;
  font-size: 13px;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.floating-feed-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0, 240, 255, 0.4);
}

/* Slide-out Drawer: Telegram Feed */
.feed-drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: 440px;
  height: 100%;
  z-index: 500;
  border-radius: 0;
  border-left: 1px solid var(--border-color);
  border-top: none;
  border-right: none;
  border-bottom: none;
  display: flex;
  flex-direction: column;
  padding: 20px;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.5);
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.feed-drawer.open {
  transform: translateX(0);
}

.feed-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

.feed-drawer-header h2 {
  margin: 0;
  font-size: 18px;
}

.alert-feed-wrapper {
  flex: 1;
  overflow-y: auto;
  margin-top: 12px;
  padding-right: 4px;
}

.alert-feed-wrapper::-webkit-scrollbar {
  width: 4px;
}
.alert-feed-wrapper::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

/* Adjust map overlay panel location in client full viewport view */
#map-fullscreen-container .map-overlay-panel {
  top: 100px;
  right: 16px;
  max-height: calc(100vh - 140px);
}

/* When drawer is open, keep overlay panel pushed to the left of the drawer */
.feed-drawer.open ~ .map-overlay-panel {
  right: 456px;
}

.feed-drawer.open ~ .floating-feed-btn {
  right: 456px;
}

/* Desktop default hides mobile bottom sheet elements */
.bottom-sheet-drag-handle {
  display: none;
}
.mobile-threat-badge {
  display: none;
}
.mobile-update-time {
  display: none;
}
.mobile-floating-controls {
  display: none;
}

/* Slide responsiveness */
@media (max-width: 768px) {
  .feed-drawer {
    width: 100%;
  }
  .feed-drawer.open ~ .map-overlay-panel {
    display: none; /* Hide location list when feed covers the screen on mobile */
  }
  
  /* Mobile separate floating capsules layout */
  .floating-header {
    position: absolute;
    top: 12px;
    left: 0;
    right: 0;
    transform: none !important;
    height: auto;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    width: 100%;
    max-width: 100vw;
    pointer-events: none;
    z-index: 1200;
  }
  
  .floating-header .header-left {
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-panel-opaque) !important;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 15px var(--shadow-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }
  
  /* Hide text brand on mobile, showing only the logo icon */
  .floating-header .mobile-hide-brand {
    display: none !important;
  }
  
  .floating-header .app-logo {
    font-size: 18px;
    margin: 0;
  }
  
  .header-left-wrapper {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 4px !important;
  }
  
  /* Floating segmented controls capsule below header */
  .mode-segmented-control {
    pointer-events: auto;
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1250;
    margin: 0;
    padding: 4px;
    background: var(--bg-panel-opaque);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 15px var(--shadow-color);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    display: flex;
    gap: 4px;
  }
  
  .mode-segment {
    padding: 4px 8px;
    font-size: 11px;
  }
  .mode-segment .segment-text {
    display: none; /* Hide text labels on mobile to show icons only */
  }
  
  #scan-now-btn {
    display: none; /* Removed entirely */
  }
  #theme-toggle-btn {
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-panel-opaque) !important;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 15px var(--shadow-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 0;
    font-size: 14px;
    margin: 0;
  }
  
  /* Mobile Slide-Up Bottom Sheet: we use feed-drawer itself! */
  .floating-left-panel {
    display: none !important;
  }
  
  .floating-feed-btn {
    display: none !important;
  }
  
  .feed-drawer {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    width: 100% !important;
    height: 62px !important; /* collapsed height fitting drag-handle + filters */
    border-radius: 20px 20px 0 0 !important;
    border: 1px solid var(--border-color) !important;
    border-bottom: none !important;
    background: var(--bg-panel-opaque) !important;
    backdrop-filter: blur(24px) !important;
    -webkit-backdrop-filter: blur(24px) !important;
    z-index: 1200 !important;
    transition: height 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
    transform: none !important; /* disable right slide-out */
    box-shadow: 0 -8px 32px var(--shadow-color) !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 6px 12px 12px 12px !important;
  }
  
  .feed-drawer.open {
    height: 480px !important; /* expanded height */
  }
  
  .feed-drawer-header {
    display: none !important; /* hide header, title and close button on mobile */
  }
  
  .bottom-sheet-drag-handle {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 2px 0 6px 0;
    cursor: pointer;
  }
  
  .bottom-sheet-drag-handle .handle-bar {
    width: 44px;
    height: 4px;
    border-radius: 2px;
    background: var(--text-primary);
    opacity: 0.35;
    transition: opacity 0.3s, background-color 0.3s;
  }

  .feed-drawer.open .bottom-sheet-drag-handle .handle-bar {
    opacity: 0.7;
    background: var(--accent-cyan);
  }

  /* Compact mobile category filter bar */
  .feed-filters {
    display: flex;
    gap: 4px;
    background: var(--bg-input);
    padding: 3px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .feed-filters::-webkit-scrollbar {
    display: none;
  }

  .filter-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 8px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    border-radius: 8px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
  }

  .filter-btn.active {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border-hover);
    box-shadow: 0 2px 6px var(--shadow-color);
  }

  .mobile-only {
    display: flex !important;
  }

  /* Mobile update time capsule tag */
  .mobile-update-time {
    display: block !important;
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 700;
    color: var(--text-secondary);
    background: var(--bg-panel-opaque);
    border: 1px solid var(--border-color);
    padding: 2px 6px;
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow-color);
    pointer-events: auto;
    line-height: 1;
    margin-top: 2px;
  }

  /* Threat level visual glows on the logo container */
  .floating-header .header-left.threat-safe {
    border-color: var(--color-safe) !important;
    box-shadow: 0 0 12px var(--color-safe) !important;
  }
  .floating-header .header-left.threat-medium {
    border-color: var(--color-medium) !important;
    box-shadow: 0 0 12px var(--color-medium) !important;
  }
  .floating-header .header-left.threat-high {
    border-color: var(--color-high) !important;
    box-shadow: 0 0 15px var(--color-high) !important;
    animation: header-danger-pulse 1.5s infinite alternate;
  }

  /* Mobile floating control vertical stack */
  .mobile-floating-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: fixed;
    top: 92px; /* Placed below logo update time */
    left: 16px;
    z-index: 1100;
  }
  
  .btn-floating-control {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-panel-opaque) !important;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 15px var(--shadow-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    transition: all 0.3s;
    outline: none;
    text-decoration: none;
  }
  
  .btn-floating-control:active {
    transform: scale(0.9);
  }
  
  #map-fullscreen-container .map-overlay-panel {
    top: 64px;
    z-index: 1000;
  }
  
  /* Move Leaflet zoom controls to top-right below floating mode capsule */
  .leaflet-top.leaflet-left {
    top: 64px !important;
    left: auto !important;
    right: 16px !important;
  }
}

/* Premium Segmented Control in Header */
.mode-segmented-control {
  display: flex;
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid var(--border-color);
  padding: 4px;
  border-radius: 30px;
  margin: 0 16px;
  gap: 4px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.mode-segment {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mode-segment:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.mode-segment.active {
  background: var(--accent-cyan);
  color: #000000; /* Dark text for high contrast on cyan background */
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(0, 242, 254, 0.4);
}

/* Light Theme overrides */
body[data-theme="light"] .mode-segmented-control {
  background: rgba(241, 245, 249, 0.8);
  border-color: #cbd5e1;
}

body[data-theme="light"] .mode-segment {
  color: #475569;
}

body[data-theme="light"] .mode-segment:hover {
  color: #0f172a;
  background: rgba(0, 0, 0, 0.04);
}

body[data-theme="light"] .mode-segment.active {
  background: #0ea5e9; /* Sleek blue active state for light mode */
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
}

/* Responsive adjustment */
@media (max-width: 768px) {
  .mode-segmented-control {
    flex-wrap: wrap;
    justify-content: center;
    border-radius: 12px;
    padding: 6px;
    margin: 8px 0;
  }
  .mode-segment {
    padding: 6px 10px;
    font-size: 12px;
  }
}

/* System Status Indicator */
.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.2);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.status-dot.safe {
  background-color: var(--color-safe) !important;
  box-shadow: 0 0 8px var(--color-safe) !important;
}

.status-dot.warning {
  background-color: var(--color-high) !important;
  box-shadow: 0 0 8px var(--color-high) !important;
}

.status-dot.pulsing {
  animation: status-pulse 1.8s infinite ease-in-out;
}

@keyframes status-pulse {
  0% {
    transform: scale(0.9);
    opacity: 0.6;
  }
  50% {
    transform: scale(1.1);
    opacity: 1;
  }
  100% {
    transform: scale(0.9);
    opacity: 0.6;
  }
}

/* ==========================================
   Favorites System (v1.7)
   ========================================== */

/* Leaflet Popup Star Button */
.map-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  width: 100%;
}
.map-popup-header h3 {
  margin: 0 !important;
}
.popup-fav-btn {
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  outline: none;
  transition: transform 0.2s ease;
  user-select: none;
  color: var(--text-secondary);
}
.popup-fav-btn:hover {
  transform: scale(1.25);
}
.popup-fav-btn.fav-active {
  color: #fbbf24 !important; /* Premium Amber Star */
  text-shadow: 0 0 8px rgba(251, 191, 36, 0.4);
}

/* Desktop Sidebar Favorites list */
.favorites-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}
.favorite-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.favorite-item:hover {
  border-color: var(--border-hover);
  background: var(--bg-panel);
}
.favorite-item span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}
.favorite-item .fav-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}

/* Mobile favorites button badge */
.btn-floating-control.has-favorites {
  color: #fbbf24 !important;
  border-color: rgba(251, 191, 36, 0.4) !important;
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.2) !important;
}

/* Modal Overlay & Dialog Card */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 10000;
  display: flex;
  justify-content: center;
  align-items: center;
}
.modal-card {
  width: 90%;
  max-width: 380px;
  background: var(--bg-panel-opaque);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 20px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.5);
  animation: modalScaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: var(--font-sans);
}
@keyframes modalScaleIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
}
.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.btn-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
}
.btn-close:hover {
  color: var(--text-primary);
}
.mobile-fav-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 12px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: transform 0.2s, background-color 0.2s;
}
.mobile-fav-item:active {
  transform: scale(0.98);
}
.mobile-fav-item .fav-item-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mobile-fav-item .fav-item-name {
  font-size: 13px;
  font-weight: 600;
}
.mobile-fav-item .fav-item-status-text {
  font-size: 11px;
  color: var(--text-secondary);
}
.empty-fav-state {
  text-align: center;
  padding: 30px 20px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.6;
}

/* ==========================================
   Toast Notifications System (Critical Alerts)
   ========================================== */
.toast-container {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 24px);
}

.toast-item {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 10px;
  border-radius: 24px;
  background: rgba(20, 8, 13, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(239, 68, 68, 0.45);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  color: #ffffff;
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  animation: toastIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

body[data-theme="light"] .toast-item {
  background: rgba(255, 241, 241, 0.95);
  border: 1px solid rgba(239, 68, 68, 0.55);
  color: #991b1b;
  box-shadow: 0 6px 18px rgba(239, 68, 68, 0.18);
}

.toast-item.toast-hiding {
  animation: toastOut 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast-icon {
  font-size: 13.5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  animation: toastPulse 1.2s infinite ease-in-out;
  flex-shrink: 0;
}

.toast-badge {
  background: var(--color-high);
  color: #ffffff;
  font-size: 9.5px;
  font-weight: 700;
  padding: 1.5px 7px;
  border-radius: 10px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  flex-shrink: 0;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 2px 5px rgba(239, 68, 68, 0.35);
}

.toast-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #f1f5f9;
  font-size: 11px;
  max-width: 240px;
}

body[data-theme="light"] .toast-text {
  color: #7f1d1d;
}

.toast-time {
  font-family: var(--font-mono);
  font-size: 10px;
  color: rgba(255, 255, 255, 0.55);
  margin-left: 2px;
  flex-shrink: 0;
}

body[data-theme="light"] .toast-time {
  color: rgba(127, 29, 29, 0.65);
}

.toast-close {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.45);
  font-size: 14px;
  cursor: pointer;
  padding: 0 2px;
  margin-left: 1px;
  line-height: 1;
  display: flex;
  align-items: center;
  transition: color 0.2s;
  flex-shrink: 0;
}

body[data-theme="light"] .toast-close {
  color: rgba(127, 29, 29, 0.45);
}

.toast-close:hover {
  color: #ffffff;
}

body[data-theme="light"] .toast-close:hover {
  color: #991b1b;
}

@keyframes toastIn {
  0% {
    opacity: 0;
    transform: translateY(-16px) scale(0.92);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toastOut {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
    max-height: 40px;
  }
  100% {
    opacity: 0;
    transform: translateY(-10px) scale(0.9);
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-top: -6px;
    border-color: transparent;
  }
}

@keyframes toastPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}


