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

:root {
  --bg-primary: #080c14;
  --bg-secondary: #0d1117;
  --bg-card: #151b26;
  --bg-card-hover: #1a2233;
  --border: #1e2a3a;
  --border-light: #2a3a50;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #586374;
  --accent-red: #ef4444;
  --accent-orange: #f97316;
  --accent-yellow: #eab308;
  --accent-green: #22c55e;
  --accent-blue: #3b82f6;
  --accent-purple: #a855f7;
  --accent-cyan: #06b6d4;
  --accent-teal: #14b8a6;
  --map-land: #141c28;
  --map-land-stroke: #1e2d42;
  --map-water: #080c14;
  --map-graticule: #0e1420;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
}

/* ─── Header ──────────────────────────── */
.header {
  background: rgba(13, 17, 23, 0.92);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 100;
  backdrop-filter: blur(16px);
  height: 52px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent-red), var(--accent-orange));
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.header h1 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, #fff, var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-subtitle {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.header-stats {
  display: flex;
  gap: 1.75rem;
}

.stat-item {
  text-align: center;
}

.stat-value {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--accent-cyan);
  line-height: 1;
}

.stat-label {
  font-size: 0.55rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-top: 2px;
}

/* ─── Tab Navigation ─────────────────── */
.tab-nav {
  display: flex;
  gap: 0;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 1rem;
  z-index: 90;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tab-btn:hover {
  color: var(--text-secondary);
}

.tab-btn.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
}

.tab-btn svg {
  opacity: 0.6;
}

.tab-btn.active svg {
  opacity: 1;
}

/* ─── Main Layout ─────────────────────── */
.main-container {
  display: grid;
  grid-template-columns: 1fr 350px;
  height: calc(100vh - 52px - 38px);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ─── Map ──────────────────────────────── */
.map-section {
  position: relative;
  overflow: hidden;
  background: var(--map-water);
}

.map-container {
  width: 100%;
  height: 100%;
}

.map-container svg {
  width: 100%;
  height: 100%;
}

/* D3 map elements */
.land {
  fill: var(--map-land);
  stroke: var(--map-land-stroke);
  stroke-width: 0.4;
  transition: fill 0.2s ease;
}

.land:hover {
  fill: #1a2840;
}

.land.origin-highlighted {
  fill: #1e3050;
  stroke: #2a4a6a;
  stroke-width: 0.8;
}

.land.target-highlighted {
  fill: #1a2540;
}

.graticule {
  fill: none;
  stroke: var(--map-graticule);
  stroke-width: 0.3;
}

.sphere {
  fill: var(--map-water);
}

.country-border {
  fill: none;
  stroke: var(--map-land-stroke);
  stroke-width: 0.4;
}

/* Markers */
.apt-marker-group {
  cursor: pointer;
}

.marker-glow {
  opacity: 0.15;
}

.marker-ring {
  fill: none;
  stroke-width: 1;
  opacity: 0;
}

.apt-marker-group:hover .marker-ring {
  opacity: 0.5;
}

.marker-dot {
  transition: r 0.2s ease;
}

.apt-marker-group:hover .marker-dot {
  filter: brightness(1.3);
}

.marker-inner {
  pointer-events: none;
}

.marker-label-bg {
  pointer-events: none;
}

.marker-label {
  pointer-events: none;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  text-shadow: 0 1px 4px rgba(0,0,0,0.9), 0 0 8px rgba(0,0,0,0.7);
}

/* Attack arcs */
.attack-arc {
  fill: none;
  stroke-width: 1;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.attack-arc.visible {
  opacity: 0.35;
}

.attack-arc-glow {
  fill: none;
  stroke-width: 3;
  opacity: 0;
  filter: blur(2px);
  transition: opacity 0.4s ease;
}

.attack-arc-glow.visible {
  opacity: 0.1;
}

/* Animated particle along arc */
.arc-particle {
  opacity: 0;
  transition: opacity 0.4s ease;
}

.arc-particle.visible {
  opacity: 0.8;
}

/* Tooltip */
.map-tooltip {
  position: fixed;
  padding: 8px 12px;
  background: rgba(13, 17, 23, 0.95);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.75rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 300;
  max-width: 200px;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

.map-tooltip.show {
  opacity: 1;
}

.map-tooltip .tt-name {
  font-weight: 700;
  font-size: 0.8rem;
  margin-bottom: 2px;
}

.map-tooltip .tt-origin {
  color: var(--text-muted);
  font-size: 0.65rem;
}

.map-tooltip .tt-threat {
  display: inline-block;
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 1px 5px;
  border-radius: 2px;
  margin-top: 3px;
}

/* Legend */
.map-legend {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  z-index: 10;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.6rem;
  color: var(--text-muted);
  background: rgba(13, 17, 23, 0.8);
  padding: 3px 8px;
  border-radius: 3px;
  border: 1px solid var(--border);
  backdrop-filter: blur(4px);
  cursor: pointer;
  transition: all 0.15s ease;
}

.legend-item:hover {
  color: var(--text-primary);
  border-color: var(--border-light);
}

.legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Map controls */
.map-controls {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 10;
}

.map-ctrl-btn {
  width: 30px;
  height: 30px;
  background: rgba(13, 17, 23, 0.85);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  backdrop-filter: blur(4px);
}

.map-ctrl-btn:hover {
  background: rgba(21, 27, 38, 0.95);
  color: var(--text-primary);
  border-color: var(--accent-cyan);
}

/* ─── Sidebar ─────────────────────────── */
.sidebar {
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.search-box {
  width: 100%;
  padding: 7px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-primary);
  font-size: 0.8rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.search-box:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.1);
}

.search-box::placeholder {
  color: var(--text-muted);
}

.filter-row {
  display: flex;
  gap: 4px;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 2px 8px;
  font-size: 0.6rem;
  font-family: inherit;
  font-weight: 500;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.12s ease;
}

.filter-btn:hover {
  border-color: var(--accent-cyan);
  color: var(--text-secondary);
}

.filter-btn.active {
  background: rgba(6, 182, 212, 0.15);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  font-weight: 600;
}

/* ─── APT List ────────────────────────── */
.apt-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.apt-list::-webkit-scrollbar {
  width: 3px;
}

.apt-list::-webkit-scrollbar-track {
  background: transparent;
}

.apt-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.apt-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.65rem 0.75rem;
  margin-bottom: 4px;
  cursor: pointer;
  transition: all 0.12s ease;
  border-left: 3px solid transparent;
}

.apt-card:hover {
  background: var(--bg-card-hover);
  border-left-color: var(--accent-cyan);
}

.apt-card.selected {
  border-color: var(--accent-cyan);
  border-left-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.05);
}

.apt-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3px;
}

.apt-name {
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: -0.01em;
}

.threat-badge {
  font-size: 0.5rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.threat-badge.critical {
  background: rgba(239, 68, 68, 0.12);
  color: var(--accent-red);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.threat-badge.high {
  background: rgba(249, 115, 22, 0.12);
  color: var(--accent-orange);
  border: 1px solid rgba(249, 115, 22, 0.25);
}

.threat-badge.medium {
  background: rgba(234, 179, 8, 0.12);
  color: var(--accent-yellow);
  border: 1px solid rgba(234, 179, 8, 0.25);
}

.apt-origin {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.apt-aliases {
  font-size: 0.6rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.apt-tags {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  margin-top: 5px;
}

.apt-tag {
  font-size: 0.5rem;
  padding: 1px 5px;
  border-radius: 2px;
  background: rgba(59, 130, 246, 0.08);
  color: var(--accent-blue);
  border: 1px solid rgba(59, 130, 246, 0.15);
}

/* ─── Detail Panel ────────────────────── */
.detail-panel {
  position: fixed;
  top: 52px;
  right: -500px;
  width: 460px;
  height: calc(100vh - 52px);
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  z-index: 200;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.5);
}

.detail-panel.open {
  right: 0;
}

.detail-header {
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  z-index: 1;
}

.detail-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.detail-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
  transition: color 0.15s;
}

.detail-close:hover {
  color: var(--text-primary);
}

.detail-body {
  padding: 1rem 1.5rem 2rem;
}

.detail-section {
  margin-bottom: 1.25rem;
}

.detail-section-title {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--accent-cyan);
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.detail-section-title::before {
  content: '';
  width: 3px;
  height: 10px;
  background: var(--accent-cyan);
  border-radius: 1px;
}

.detail-description {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.detail-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.meta-item {
  background: var(--bg-card);
  padding: 0.5rem 0.7rem;
  border-radius: 5px;
  border: 1px solid var(--border);
}

.meta-label {
  font-size: 0.55rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.meta-value {
  font-size: 0.8rem;
  font-weight: 700;
  margin-top: 1px;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.detail-tag {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 3px;
  font-weight: 500;
}

.detail-tag.alias {
  background: rgba(59, 130, 246, 0.08);
  color: var(--accent-blue);
  border: 1px solid rgba(59, 130, 246, 0.18);
}

.detail-tag.malware {
  background: rgba(239, 68, 68, 0.08);
  color: var(--accent-red);
  border: 1px solid rgba(239, 68, 68, 0.18);
}

.detail-tag.ttp {
  background: rgba(168, 85, 247, 0.08);
  color: var(--accent-purple);
  border: 1px solid rgba(168, 85, 247, 0.18);
}

.detail-tag.target {
  background: rgba(34, 197, 94, 0.08);
  color: var(--accent-green);
  border: 1px solid rgba(34, 197, 94, 0.18);
}

.detail-tag.region {
  background: rgba(20, 184, 166, 0.08);
  color: var(--accent-teal);
  border: 1px solid rgba(20, 184, 166, 0.18);
}

.active-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

.active-dot.on {
  background: var(--accent-green);
  box-shadow: 0 0 6px var(--accent-green);
}

.active-dot.off {
  background: var(--text-muted);
}

/* ─── Overlay ─────────────────────────── */
.overlay-dimmer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

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

/* ─── Loading ─────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 0.8rem;
  gap: 0.5rem;
}

.loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ─── Responsive ──────────────────────── */
@media (max-width: 1024px) {
  .main-container {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 40vh;
  }

  .sidebar {
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .detail-panel {
    width: 100%;
    right: -100%;
  }
}

@media (max-width: 640px) {
  .header { padding: 0.5rem 0.75rem; }
  .header-stats { display: none; }
  .header h1 { font-size: 0.85rem; }
  .main-container { grid-template-rows: 55vh 1fr; }
  .tab-nav { overflow-x: auto; }
  .tab-btn { white-space: nowrap; padding: 6px 10px; font-size: 0.6rem; }
}

/* ─── Statistics Dashboard ───────────── */
.stats-section {
  overflow-y: auto;
  background: var(--bg-primary);
}

.stats-dashboard {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  overflow: hidden;
}

.chart-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent-cyan);
  margin-bottom: 0.75rem;
  padding-left: 8px;
  border-left: 3px solid var(--accent-cyan);
}

.chart-container {
  width: 100%;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-container svg text {
  font-family: 'Inter', sans-serif;
}

/* ─── Timeline ───────────────────────── */
.timeline-section {
  overflow: hidden;
  background: var(--bg-primary);
}

.timeline-container {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.timeline-container svg text {
  font-family: 'Inter', sans-serif;
}

.timeline-dot circle {
  transition: opacity 0.15s, stroke-width 0.15s;
}

/* ─── News Feed ──────────────────────── */
.news-section {
  overflow-y: auto;
  background: var(--bg-primary);
}

.news-container {
  padding: 1rem;
}

.news-header {
  margin-bottom: 1rem;
}

.news-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.news-count {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

.news-source {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 0.6rem;
}

.news-card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.15s ease;
  border-left: 3px solid var(--border);
}

.news-card:hover {
  background: var(--bg-card-hover);
  border-left-color: var(--accent-cyan);
  transform: translateY(-1px);
}

.news-card.relevant {
  border-left-color: var(--accent-red);
}

.news-card.relevant:hover {
  border-left-color: var(--accent-orange);
}

.news-card-cat {
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent-cyan);
  margin-bottom: 4px;
}

.news-card.relevant .news-card-cat {
  color: var(--accent-orange);
}

.news-card-title {
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-primary);
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news-card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.6rem;
  color: var(--text-muted);
}

/* ─── MITRE ATT&CK ──────────────────── */
.mitre-badge {
  font-size: 0.5rem;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 2px;
  background: rgba(168, 85, 247, 0.15);
  color: var(--accent-purple);
  border: 1px solid rgba(168, 85, 247, 0.25);
  margin-left: 6px;
  vertical-align: middle;
}

.mitre-link {
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mitre-link:hover {
  background: rgba(168, 85, 247, 0.15);
  border-color: var(--accent-purple);
  transform: translateY(-1px);
}

.mitre-id {
  font-size: 0.55rem;
  opacity: 0.7;
  margin-left: 4px;
  font-weight: 400;
}

/* ─── Country click highlight ────────── */
.land {
  cursor: pointer;
}

.land:hover {
  fill: #1a2840;
}
