/* Global Reset & Base Variables */
:root {
  --bg-dark: #050b14;
  --bg-card: rgba(13, 23, 38, 0.78);
  --bg-card-hover: rgba(20, 36, 58, 0.9);
  --bg-header: rgba(8, 16, 28, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(0, 229, 255, 0.25);
  
  --text-main: #f0f4f8;
  --text-muted: #8ba2b8;
  --text-dim: #5c7287;
  
  --cyan: #00e5ff;
  --cyan-glow: rgba(0, 229, 255, 0.4);
  --green: #00e676;
  --green-glow: rgba(0, 230, 118, 0.4);
  --yellow: #ffd600;
  --orange: #ff9100;
  --red: #ff1744;
  --red-glow: rgba(255, 23, 68, 0.45);
  
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(0, 229, 255, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(255, 23, 68, 0.04) 0%, transparent 45%);
}

.font-mono {
  font-family: var(--font-mono);
}

/* Glassmorphic Panel Helper */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.45);
}

/* App Header */
.app-header {
  height: 64px;
  background: var(--bg-header);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 1000;
  gap: 12px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.logo-container {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #00b4d8, #0077b6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 0 16px var(--cyan-glow);
  flex-shrink: 0;
}

.logo-pulse {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 10px;
  border: 2px solid var(--cyan);
  animation: logo-ripple 2s infinite ease-out;
}

@keyframes logo-ripple {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.4); opacity: 0; }
}

.logo-icon {
  width: 20px;
  height: 20px;
}

.app-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.badge-version {
  font-size: 0.62rem;
  padding: 2px 6px;
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.2), rgba(0, 119, 182, 0.4));
  border: 1px solid var(--cyan);
  color: var(--cyan);
  border-radius: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.live-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  background: rgba(0, 230, 118, 0.12);
  border: 1px solid rgba(0, 230, 118, 0.35);
  border-radius: 12px;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--green);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.app-subtitle {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Header Telemetry stats */
.header-stats {
  display: flex;
  gap: 12px;
  align-items: center;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
}

.stat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
}

.stat-label {
  color: var(--text-muted);
}

.stat-val {
  color: var(--text-main);
  font-weight: 600;
}

.pulse-green {
  background: var(--green);
  box-shadow: 0 0 10px var(--green-glow);
  animation: pulse-dot 1.8s infinite;
}

.pulse-red {
  background: var(--red);
  box-shadow: 0 0 10px var(--red-glow);
  animation: pulse-dot 1.2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* Buttons & Controls */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  font-family: var(--font-main);
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, #00b4d8, #0077b6);
  color: #fff;
  box-shadow: 0 4px 14px var(--cyan-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--cyan-glow);
  filter: brightness(1.1);
}

.btn-godseye {
  background: linear-gradient(135deg, #0284c7, #1d4ed8);
  color: #fff;
  border: 1px solid rgba(0, 229, 255, 0.4);
  box-shadow: 0 0 14px rgba(2, 132, 199, 0.45);
}

.btn-godseye:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.65);
  filter: brightness(1.15);
}

.pulse-tag {
  display: inline-block;
  animation: pulseTagAnim 1.4s infinite ease-in-out;
}

@keyframes pulseTagAnim {
  0% { transform: scale(1); }
  50% { transform: scale(1.04); filter: brightness(1.2); }
  100% { transform: scale(1); }
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}

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

.btn-icon-round {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.75rem;
}

/* Early Warning Banner */
.eew-banner {
  background: linear-gradient(90deg, rgba(255, 23, 68, 0.25) 0%, rgba(13, 23, 38, 0.95) 100%);
  border-bottom: 2px solid var(--red);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 25px rgba(255, 23, 68, 0.25);
  animation: slide-down 0.4s ease-out;
}

@keyframes slide-down {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.eew-content {
  display: flex;
  align-items: center;
  gap: 20px;
}

.eew-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--red);
  color: #fff;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  box-shadow: 0 0 12px var(--red-glow);
}

.eew-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
}

.eew-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.eew-intensity-box {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 23, 68, 0.4);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.intensity-label {
  font-size: 0.62rem;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

.intensity-val {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--red);
}

.eew-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.eew-close:hover {
  color: #fff;
}

/* Metric Quick Cards Bar */
.metrics-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 16px 24px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.metric-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-glow);
}

.metric-icon-box {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.metric-icon-box svg {
  width: 22px;
  height: 22px;
}

.metric-icon-box.cyan {
  background: rgba(0, 229, 255, 0.12);
  color: var(--cyan);
}

.metric-icon-box.red {
  background: rgba(255, 23, 68, 0.15);
  color: var(--red);
}

.metric-icon-box.orange {
  background: rgba(255, 145, 0, 0.15);
  color: var(--orange);
}

.metric-icon-box.green {
  background: rgba(0, 230, 118, 0.15);
  color: var(--green);
}

.metric-data {
  display: flex;
  flex-direction: column;
}

.metric-num {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.metric-title {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.text-red { color: var(--red); }
.text-green { color: var(--green); }
.text-cyan { color: var(--cyan); }

/* Main Layout */
.main-layout {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 16px;
  padding: 0 24px 24px 24px;
  flex: 1;
}

/* Map Section */
.map-section {
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  height: calc(100vh - 220px);
  min-height: 540px;
}

.map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(5, 11, 20, 0.6);
  flex-shrink: 0;
}

.map-title-box {
  display: flex;
  align-items: center;
  gap: 12px;
}

.map-title-box h2 {
  font-size: 0.95rem;
  font-weight: 600;
}

.live-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--cyan);
  background: rgba(0, 229, 255, 0.12);
  border: 1px solid rgba(0, 229, 255, 0.3);
  padding: 2px 7px;
  border-radius: 12px;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  animation: pulse-dot 1.5s infinite;
}

.map-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.select-dark {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  outline: none;
}

.select-dark:focus {
  border-color: var(--cyan);
}

#map {
  flex: 1 1 auto;
  min-height: 420px;
  width: 100%;
  height: calc(100% - 55px);
  background: #08101a;
  position: relative;
  z-index: 1;
}

/* Map Legend */
.map-legend {
  position: absolute;
  bottom: 16px;
  left: 16px;
  background: rgba(8, 16, 28, 0.88);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.7rem;
  color: var(--text-muted);
  z-index: 800;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-color.cyan { background: var(--cyan); }
.legend-color.yellow { background: var(--yellow); }
.legend-color.orange { background: var(--orange); }
.legend-color.red { background: var(--red); }

.legend-divider {
  width: 1px;
  height: 14px;
  background: var(--border-subtle);
}

.legend-ring {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border-width: 2px;
  border-style: solid;
}

.legend-ring.wave-p { border-color: #2979ff; }
.legend-ring.wave-s { border-color: #ff1744; }

.legend-plate-line {
  width: 14px;
  height: 2px;
  background: #ff5722;
  box-shadow: 0 0 6px rgba(255, 87, 34, 0.6);
}

/* Sidebar */
.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: calc(100vh - 220px);
  min-height: 520px;
}

/* Seismograph Waveform Panel */
.seismograph-panel {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-title-wrap h3 {
  font-size: 0.85rem;
  font-weight: 600;
}

.freq-tag {
  font-size: 0.68rem;
  color: var(--cyan);
  background: rgba(0, 229, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
}

#seismograph-canvas {
  width: 100%;
  height: 100px;
  background: rgba(3, 8, 15, 0.85);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 229, 255, 0.15);
}

.seismo-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* Quake Feed Panel */
.feed-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 14px 16px;
}

.badge-count {
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 8px;
  border-radius: 12px;
  color: var(--text-main);
}

.quake-list {
  flex: 1;
  overflow-y: auto;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}

/* Custom Scrollbar */
.quake-list::-webkit-scrollbar,
.terminal-view::-webkit-scrollbar,
.modal-body::-webkit-scrollbar {
  width: 5px;
}

.quake-list::-webkit-scrollbar-thumb,
.terminal-view::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

/* Servers Cluster Grid */
.servers-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.server-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.2s ease;
}

.server-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-glow);
  transform: translateY(-2px);
}

.server-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.server-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
}

.server-status-badge {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 12px;
  text-transform: uppercase;
}

.server-status-badge.online {
  background: rgba(0, 230, 118, 0.15);
  color: var(--green);
  border: 1px solid rgba(0, 230, 118, 0.4);
}

.server-status-badge.standby {
  background: rgba(255, 214, 0, 0.15);
  color: var(--yellow);
  border: 1px solid rgba(255, 214, 0, 0.4);
}

.server-host {
  font-size: 0.72rem;
  color: var(--cyan);
}

.server-region {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.server-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 0.7rem;
  color: var(--text-dim);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 6px;
}

/* Consensus Badges in Quake Cards & Popups */
.consensus-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  color: #00e676;
  background: rgba(0, 230, 118, 0.12);
  border: 1px solid rgba(0, 230, 118, 0.35);
  padding: 1px 6px;
  border-radius: 4px;
  margin-top: 3px;
  width: fit-content;
}

/* Quake Card Item */
.quake-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s ease;
}

.quake-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-glow);
  transform: translateX(2px);
}

.quake-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mag-pill {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.95rem;
  line-height: 1;
  color: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.mag-pill.cyan { background: linear-gradient(135deg, #00b4d8, #0077b6); }
.mag-pill.yellow { background: linear-gradient(135deg, #f59e0b, #d97706); }
.mag-pill.orange { background: linear-gradient(135deg, #ea580c, #c2410c); }
.mag-pill.red { background: linear-gradient(135deg, #dc2626, #991b1b); box-shadow: 0 0 12px var(--red-glow); }

.mag-scale {
  font-size: 0.55rem;
  font-weight: 400;
  opacity: 0.85;
}

.quake-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 250px;
}

.quake-place {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quake-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.quake-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}

.quake-time-ago {
  font-size: 0.68rem;
  color: var(--text-dim);
}

.quake-depth {
  font-size: 0.7rem;
  color: var(--cyan);
}

/* Loading State */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(0, 229, 255, 0.15);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  width: 820px;
  max-width: 90vw;
  height: 520px;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-title-box h3 {
  font-size: 0.95rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  cursor: pointer;
}

.modal-body {
  flex: 1;
  padding: 16px 20px;
  overflow: hidden;
  background: #02060d;
}

.terminal-view {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  font-size: 0.75rem;
  color: #7dd3fc;
  line-height: 1.6;
}

.terminal-line {
  white-space: pre-wrap;
  word-break: break-all;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 3000;
}

.toast {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glow);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toast-in 0.3s ease-out;
}

@keyframes toast-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Leaflet Custom Marker & Shockwave CSS */
.leaflet-popup-content-wrapper {
  background: rgba(8, 16, 28, 0.95) !important;
  backdrop-filter: blur(12px) !important;
  border: 1px solid var(--border-glow) !important;
  color: var(--text-main) !important;
  border-radius: var(--radius-md) !important;
}

.leaflet-popup-tip {
  background: rgba(8, 16, 28, 0.95) !important;
}

.popup-quake {
  font-family: var(--font-main);
  padding: 4px;
}

.popup-mag {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.popup-place {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.popup-details {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-family: var(--font-mono);
}

/* Country Navigation Bar */
.country-nav-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 24px;
  background: rgba(10, 20, 34, 0.65);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
}

.country-tabs-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.country-tabs-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.country-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  background: rgba(18, 30, 48, 0.75);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.country-pill:hover {
  background: rgba(28, 48, 76, 0.9);
  border-color: var(--border-glow);
  transform: translateY(-1px);
}

.country-pill.active {
  background: linear-gradient(135deg, rgba(0, 180, 216, 0.3), rgba(0, 229, 255, 0.2));
  border-color: var(--cyan);
  color: #fff;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.25);
}

.country-pill-flag {
  font-size: 1rem;
}

.country-pill-count {
  font-size: 0.72rem;
  padding: 1px 7px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 10px;
  color: var(--cyan);
}

.country-pill.active .country-pill-count {
  background: var(--cyan);
  color: #050b14;
  font-weight: 700;
}

/* Country Tag in Quake Feed Card */
.country-badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(0, 229, 255, 0.12);
  color: var(--cyan);
  border: 1px solid rgba(0, 229, 255, 0.25);
  margin-top: 4px;
}

/* Alert Selector in Header */
.alert-selector-wrap {
  display: flex;
  align-items: center;
}

.select-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  background: rgba(14, 28, 48, 0.9);
  color: #fff;
  border: 1px solid var(--border-glow);
  cursor: pointer;
}

.select-sm:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.3);
}

/* Map Wrapper & Mobile Quick Pill */
.map-wrapper {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

#map {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 380px;
}

.mobile-latest-pill {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  background: rgba(6, 14, 26, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(0, 229, 255, 0.35);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  border-radius: 30px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.76rem;
  max-width: 90%;
  cursor: pointer;
  white-space: nowrap;
  animation: bounce-in 0.3s ease-out;
}

@keyframes bounce-in {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.mlp-mag {
  font-weight: 800;
  color: var(--red);
  background: rgba(255, 23, 68, 0.15);
  padding: 2px 6px;
  border-radius: 6px;
}

.mlp-place {
  color: #fff;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 170px;
}

.mlp-time {
  color: var(--text-dim);
  font-size: 0.68rem;
}

/* Settings Cards (Menu Modal) */
.settings-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  transition: all 0.2s ease;
}

.settings-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
}

.settings-card.highlight-card {
  background: rgba(0, 229, 255, 0.06);
  border-color: rgba(0, 229, 255, 0.3);
}

.settings-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.settings-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.settings-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #fff;
}

.settings-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.3;
}

/* Bottom Navigation Bar (App Nativa Android / Móvil) */
.bottom-nav-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: rgba(5, 11, 20, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
  z-index: 1200;
  justify-content: space-around;
  align-items: center;
  padding: 0 10px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 12px;
  transition: all 0.2s ease;
  flex: 1;
  max-width: 90px;
  gap: 2px;
  -webkit-tap-highlight-color: transparent;
}

.nav-tab:hover {
  color: var(--text-muted);
}

.nav-tab.active {
  color: var(--cyan);
}

.nav-tab.active .nav-icon-wrap svg {
  stroke: var(--cyan);
  filter: drop-shadow(0 0 8px var(--cyan-glow));
}

.nav-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 24px;
}

.nav-badge {
  position: absolute;
  top: -4px;
  right: -8px;
  background: var(--red);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 10px;
  font-family: var(--font-mono);
  box-shadow: 0 0 6px rgba(255, 23, 68, 0.6);
}

.nav-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ==========================================================
   RESPONSIVE DESIGN (Tablets, Celulares y Layout Móvil Nativo)
   ========================================================== */

/* 1. Tablets y Pantallas Medianas (<= 1024px) */
@media (max-width: 1024px) {
  .main-layout {
    grid-template-columns: 1fr;
    height: auto;
    gap: 16px;
  }

  .map-section {
    height: 520px;
    min-height: 480px;
  }

  .metrics-bar {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 12px 18px;
  }

  .sidebar-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* 2. Smartphones y Pantallas Móviles (<= 768px) */
@media (max-width: 768px) {
  body {
    padding-bottom: 64px; /* Espacio para el Bottom Nav Bar */
  }

  /* Header ultra-limpio para móvil */
  .app-header {
    height: 54px;
    padding: 0 12px;
  }

  .logo-container {
    width: 32px;
    height: 32px;
    border-radius: 8px;
  }

  .logo-icon {
    width: 17px;
    height: 17px;
  }

  .app-title {
    font-size: 1.05rem;
  }

  .app-subtitle {
    display: none; /* Ocultar subtítulo largo en móvil para no saturar */
  }

  .header-stats {
    display: none !important; /* Ocultar píldoras de telemetría en header móvil */
  }

  .desktop-only {
    display: none !important; /* Ocultar elementos exclusivos de desktop */
  }

  .btn-icon-round {
    width: 36px;
    height: 36px;
  }

  /* Bottom Navigation visible en móvil */
  .bottom-nav-bar {
    display: flex;
  }

  /* Country Navigation Bar deslizable con el pulgar */
  .country-nav-bar {
    padding: 8px 12px;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  .country-nav-bar::-webkit-scrollbar {
    display: none;
  }

  .country-tabs-label {
    display: none; /* Ocultar etiqueta fija para dar 100% de espacio a las banderas */
  }

  .country-tabs-group {
    display: flex;
    gap: 8px;
    width: 100%;
  }

  .country-pill {
    padding: 5px 12px;
    font-size: 0.78rem;
    scroll-snap-align: start;
    flex-shrink: 0;
  }

  /* Métricas compactas */
  .metrics-bar {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 8px 12px;
  }

  .metric-card {
    padding: 10px 12px;
    gap: 10px;
  }

  .metric-icon-box {
    width: 36px;
    height: 36px;
    border-radius: 8px;
  }

  .metric-num {
    font-size: 1.15rem;
  }

  .metric-title {
    font-size: 0.65rem;
  }

  /* Main Layout & Pestañas Móviles */
  .main-layout {
    padding: 0 10px;
    display: block;
  }

  /* Vistas móviles controladas por atributo data-mobile-view en main.main-layout */
  .main-layout[data-mobile-view="map"] .map-section {
    display: flex;
    height: calc(100vh - 195px);
    min-height: 420px;
  }
  .main-layout[data-mobile-view="map"] .sidebar-section {
    display: none !important;
  }

  .main-layout[data-mobile-view="feed"] .map-section {
    display: none !important;
  }
  .main-layout[data-mobile-view="feed"] .sidebar-section {
    display: flex !important;
    flex-direction: column;
  }
  .main-layout[data-mobile-view="feed"] .seismograph-panel {
    display: none !important;
  }
  .main-layout[data-mobile-view="feed"] .feed-panel {
    display: flex !important;
    height: calc(100vh - 195px);
    min-height: 420px;
  }

  .main-layout[data-mobile-view="waves"] .map-section {
    display: none !important;
  }
  .main-layout[data-mobile-view="waves"] .sidebar-section {
    display: flex !important;
    flex-direction: column;
  }
  .main-layout[data-mobile-view="waves"] .feed-panel {
    display: none !important;
  }
  .main-layout[data-mobile-view="waves"] .seismograph-panel {
    display: flex !important;
    height: calc(100vh - 195px);
    min-height: 420px;
  }

  /* Map Header y Controles en móvil */
  .map-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 14px;
  }

  .map-controls {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: space-between;
  }

  .map-controls .filter-group {
    flex: 1;
    min-width: 120px;
  }

  .map-controls select {
    width: 100%;
    font-size: 0.72rem;
    padding: 4px 6px;
  }

  .map-legend {
    display: none; /* En móvil se oculta la leyenda flotante para dejar el mapa totalmente despejado */
  }

  /* Modales en Móvil */
  .modal-content {
    width: 94% !important;
    max-height: 85vh !important;
    margin: auto;
    border-radius: 14px;
  }

  .modal-header {
    padding: 14px 18px;
  }

  .modal-body {
    padding: 16px !important;
  }
}

/* 3. Pantallas Ultra-Estrechas (<= 480px) */
@media (max-width: 480px) {
  .app-title {
    font-size: 0.95rem;
  }

  .badge-version {
    display: none; /* Ocultar versión en pantallas ultrapequeñas para no empujar botones */
  }

  .live-status-pill .live-text {
    display: none; /* Dejar solo el punto verde pulsante */
  }

  .country-pill {
    padding: 4px 10px;
    font-size: 0.72rem;
  }
}

/* Responsive EEW Predict Table */
#modal-predict table {
  min-width: 580px;
}

@media (max-width: 600px) {
  #predict-event-banner {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 8px;
  }
}




/* ==============================================================================
   KORSHQUAKE CITIZEN MESH NODE & HARDWARE ACCELEROMETER STYLING
   ============================================================================== */
.sensor-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.68rem;
  background: rgba(0, 0, 0, 0.35);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.sensor-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  transition: all 0.25s ease;
}

.sensor-badge.active-sensor {
  color: #00e676;
}

.sensor-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ffab00;
  display: inline-block;
}

.active-sensor .sensor-dot {
  background: #00e676;
  box-shadow: 0 0 8px #00e676;
}

.node-id-pill {
  color: var(--cyan);
  font-size: 0.65rem;
  background: rgba(0, 229, 255, 0.08);
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid rgba(0, 229, 255, 0.15);
}

.seismo-axes-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.68rem;
  color: var(--text-dim);
  background: rgba(0, 15, 30, 0.4);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid rgba(0, 229, 255, 0.08);
}

.seismo-axes-bar span strong {
  color: #e0f7fa;
}

.seismo-controls {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.seismo-controls .btn {
  flex: 1;
  font-size: 0.72rem;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.seismograph-panel.seismo-trigger-active {
  border-color: #ff3d00 !important;
  box-shadow: 0 0 24px rgba(255, 61, 0, 0.45) !important;
  animation: pulseTriggerBorder 0.8s infinite alternate ease-in-out;
}

@keyframes pulseTriggerBorder {
  0% { border-color: rgba(255, 61, 0, 0.4); }
  100% { border-color: rgba(255, 61, 0, 1); box-shadow: 0 0 30px rgba(255, 61, 0, 0.7); }
}

.leaflet-tooltip.node-tooltip {
  background: rgba(5, 12, 22, 0.92);
  border: 1px solid rgba(0, 229, 255, 0.4);
  color: #e0f7fa;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  border-radius: 6px;
  padding: 6px 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
}
