@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@300;400;500&display=swap');

:root {
  --bg:          #0a0c0f;
  --bg2:         #111418;
  --bg3:         #181c22;
  --border:      rgba(255,255,255,0.08);
  --border2:     rgba(255,255,255,0.15);
  --text:        #e8eaed;
  --text2:       #8a9099;
  --text3:       #4a5060;
  --red:         #ff4444;
  --red-dim:     rgba(255,68,68,0.12);
  --amber:       #ffaa00;
  --amber-dim:   rgba(255,170,0,0.12);
  --green:       #00cc77;
  --green-dim:   rgba(0,204,119,0.12);
  --blue:        #4488ff;
  --blue-dim:    rgba(68,136,255,0.10);
  --mono:        'IBM Plex Mono', monospace;
  --sans:        'IBM Plex Sans', sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  min-height: 100vh;
  line-height: 1.5;
}

/* Subtle scanline texture — the "movie screen" feel */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0, 0, 0, 0.07) 3px,
    rgba(0, 0, 0, 0.07) 4px
  );
  pointer-events: none;
  z-index: 9998;
}

/* ── HEADER ─────────────────────────────────────── */
header {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #000;
  position: sticky;
  top: 0;
  z-index: 1000;
}

header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(
    to right,
    transparent 0%,
    var(--red) 20%,
    rgba(255,68,68,0.35) 50%,
    var(--red) 80%,
    transparent 100%
  );
}

/* ── Logo image ── */
.header-logo-wrap {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  overflow: hidden;
}

/* Fade edges into bg so the logo blends with the page */
.header-logo-wrap::before,
.header-logo-wrap::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  width: 15%;
  z-index: 1;
  pointer-events: none;
}
.header-logo-wrap::before { left:  0; background: linear-gradient(to right, #000, transparent); }
.header-logo-wrap::after  { right: 0; background: linear-gradient(to left,  #000, transparent); }

.header-logo-img {
  height: 160px;
  max-width: 900px;
  width: 100%;
  object-fit: contain;
  display: block;
}

/* ── Bottom bar: title + live badge ── */
.header-bottom {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 7px 24px 9px;
  border-top: 1px solid rgba(255,68,68,0.18);
}

.header-title {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text);
}

.header-sep {
  width: 1px;
  height: 16px;
  background: var(--border);
  flex-shrink: 0;
}

.live-badge {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--red);
  letter-spacing: 0.12em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--red);
  animation: blink 1.2s infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(255,68,68,0.4); }
  50%       { opacity: 0.7; box-shadow: 0 0 0 6px rgba(255,68,68,0); }
}

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.last-update { font-family: var(--mono); font-size: 11px; color: var(--text3); }

/* ── NAV ─────────────────────────────────────────── */
nav {
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  position: sticky;
  top: 200px;
  z-index: 999;
}

/* Thin red accent line at top of nav */
nav::before {
  content: '';
  position: absolute;
  top: 0; left: 10%; right: 10%;
  height: 1px;
  background: linear-gradient(
    to right,
    transparent,
    rgba(255,68,68,0.4),
    transparent
  );
}

.nav-btn {
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text3);
  padding: 20px 26px;
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-btn:hover  { color: var(--text2); }
.nav-btn.active { color: var(--text); border-bottom-color: var(--red); }

.nav-badge {
  display: inline-block;
  background: var(--red);
  color: #fff;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 8px;
  line-height: 1.6;
}

/* ── MAIN ────────────────────────────────────────── */
main { padding: 32px; max-width: 1200px; margin: 0 auto; }

.view         { display: none; }
.view.active  { display: block; }

/* ── METRICS ─────────────────────────────────────── */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 32px;
}

.metric {
  background: var(--bg2);
  padding: 20px 24px;
  position: relative;
}

.metric::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}

.metric.red::before   { background: var(--red); }
.metric.amber::before { background: var(--amber); }
.metric.blue::before  { background: var(--blue); }
.metric.green::before { background: var(--green); }
.metric.gray::before  { background: var(--text3); }

.metric-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 10px;
}

.metric-value {
  font-family: var(--mono);
  font-size: 34px;
  font-weight: 600;
  line-height: 1;
  margin-bottom: 6px;
}

.metric.red   .metric-value { color: var(--red); }
.metric.amber .metric-value { color: var(--amber); }
.metric.blue  .metric-value { color: var(--blue); }
.metric.green .metric-value { color: var(--green); }
.metric.gray  .metric-value { color: var(--text2); }

.metric-delta { font-family: var(--mono); font-size: 12px; color: var(--text3); }

/* ── MAP SECTION ─────────────────────────────────── */
.map-section {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  margin-bottom: 32px;
}

.map-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

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

.card-title {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text2);
}

.card-body { padding: 20px; }

/* ── LEAFLET MAP ─────────────────────────────────── */
#map {
  height: 340px;
  isolation: isolate; /* contain Leaflet's internal z-indices */
}

.leaflet-container {
  background: var(--bg3) !important;
  font-family: var(--sans) !important;
}

.leaflet-control-zoom {
  border: 1px solid var(--border2) !important;
  box-shadow: none !important;
}

.leaflet-control-zoom a {
  background: var(--bg2) !important;
  color: var(--text2) !important;
  border-color: var(--border) !important;
  line-height: 26px !important;
}

.leaflet-control-zoom a:hover {
  background: var(--bg3) !important;
  color: var(--text) !important;
}

.leaflet-control-attribution {
  background: rgba(10,12,15,0.75) !important;
  color: var(--text3) !important;
  font-size: 9px !important;
}

.leaflet-control-attribution a { color: var(--text3) !important; }

.leaflet-popup-content-wrapper {
  background: var(--bg3) !important;
  border: 1px solid var(--border2) !important;
  border-radius: 8px !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6) !important;
  padding: 0 !important;
}

.leaflet-popup-content {
  margin: 0 !important;
  padding: 14px 16px !important;
  min-width: 200px;
}

.leaflet-popup-tip-container { display: none; }

.leaflet-popup-close-button {
  color: var(--text3) !important;
  font-size: 16px !important;
  top: 8px !important;
  right: 8px !important;
}

.leaflet-popup-close-button:hover { color: var(--text) !important; }

/* Custom markers */
.map-icon-wrapper { background: none !important; border: none !important; }

.map-dot {
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.15);
  cursor: pointer;
  transition: transform 0.15s;
}

.map-dot:hover { transform: scale(1.4); }

.map-dot.marker-red   { background: var(--red);   box-shadow: 0 0 0 5px rgba(255,68,68,0.18); }
.map-dot.marker-amber { background: var(--amber);  box-shadow: 0 0 0 5px rgba(255,170,0,0.18); }
.map-dot.marker-blue  { background: var(--blue);   box-shadow: 0 0 0 5px rgba(68,136,255,0.18); }
.map-dot.marker-gray  { background: rgba(255,255,255,0.25); }

.map-dot.marker-ship {
  width: 10px;
  height: 10px;
  background: rgba(255,255,255,0.92);
  border-color: rgba(255,255,255,0.3);
  animation: shipPulse 2s infinite;
}

@keyframes shipPulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(255,255,255,0.2), 0 0 0 8px rgba(255,255,255,0.06); }
  50%       { box-shadow: 0 0 0 7px rgba(255,255,255,0.08), 0 0 0 14px rgba(255,255,255,0); }
}

/* Popup content */
.popup-title {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.popup-status {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.popup-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text2);
  padding: 3px 0;
}

.popup-label { color: var(--text3); }

.popup-notes {
  font-size: 12px;
  color: var(--text3);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  line-height: 1.45;
}

/* ── COUNTRY LIST (overview sidebar) ─────────────── */
.country-list-wrap {
  position: relative;
  overflow: hidden;
}
.country-list-wrap::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 40px;
  background: linear-gradient(transparent, var(--bg2));
  pointer-events: none;
  z-index: 1;
}
.country-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  max-height: 340px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}
.country-list::-webkit-scrollbar { width: 4px; }
.country-list::-webkit-scrollbar-track { background: transparent; }
.country-list::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

.country-item {
  background: var(--bg2);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: background 0.15s;
}

.country-item:hover    { background: var(--bg3); }
.country-item.selected { background: rgba(255,68,68,0.06); }

.country-name   { font-size: 14px; font-weight: 500; color: var(--text); margin-bottom: 2px; }
.country-status { font-family: var(--mono); font-size: 11px; color: var(--text3); letter-spacing: 0.06em; }

.country-badge {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
  white-space: nowrap;
}

.badge-red   { background: var(--red-dim);          color: var(--red); }
.badge-amber { background: var(--amber-dim);         color: var(--amber); }
.badge-blue  { background: var(--blue-dim);          color: var(--blue); }
.badge-gray  { background: rgba(255,255,255,0.05);   color: var(--text3); }

/* ── BOTTOM GRID ─────────────────────────────────── */
.bottom-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }

/* ── CHART ───────────────────────────────────────── */
.chart-area { padding: 16px 20px 20px; height: 200px; position: relative; }

/* ── TIMELINE ────────────────────────────────────── */
.timeline { display: flex; flex-direction: column; }

.tl-item {
  display: flex;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.tl-item:last-child { border-bottom: none; }

.tl-date {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text3);
  min-width: 60px;
  padding-top: 2px;
}

.tl-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border2);
  margin-top: 6px;
  flex-shrink: 0;
}

.tl-dot.red   { background: var(--red); }
.tl-dot.amber { background: var(--amber); }
.tl-dot.blue  { background: var(--blue); }

.tl-text { font-size: 14px; color: var(--text2); line-height: 1.5; }
.tl-text strong { color: var(--text); font-weight: 500; }

/* ── FACTS ───────────────────────────────────────── */
.facts { display: flex; flex-direction: column; }

.fact-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.fact-row:last-child { border-bottom: none; }

.fact-label {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.fact-value { font-size: 14px; color: var(--text); text-align: right; max-width: 55%; }

/* ── RISK BANNER ─────────────────────────────────── */
.risk-banner {
  border-radius: 8px;
  padding: 16px 24px;
  margin-bottom: 32px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.risk-banner.green { background: var(--green-dim);  border: 1px solid rgba(0,204,119,0.2); }
.risk-banner.amber { background: var(--amber-dim);  border: 1px solid rgba(255,170,0,0.2); }
.risk-banner.red   { background: var(--red-dim);    border: 1px solid rgba(255,68,68,0.2); }

.risk-icon { font-family: var(--mono); font-size: 18px; font-weight: 600; }
.risk-banner.green .risk-icon { color: var(--green); }
.risk-banner.amber .risk-icon { color: var(--amber); }
.risk-banner.red   .risk-icon { color: var(--red); }

.risk-text { font-size: 14px; color: var(--text2); line-height: 1.5; }
.risk-banner.green .risk-text strong { color: var(--green); }
.risk-banner.amber .risk-text strong { color: var(--amber); }
.risk-banner.red   .risk-text strong { color: var(--red); }

/* ── TABLE ───────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 14px; }

.th-sort {
  cursor: pointer;
  user-select: none;
  padding: 14px 20px;
  text-align: left;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text3);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
  white-space: nowrap;
  transition: color 0.15s;
}

.th-sort:hover       { color: var(--text2); }
.th-sort.sort-active { color: var(--text); }

.sort-indicator { color: var(--blue); margin-left: 4px; }
.th-right { text-align: right; }

.status-badge { font-family: var(--mono); font-size: 12px; padding: 4px 10px; border-radius: 4px; }
.status-high  { color: var(--red);   background: var(--red-dim); }
.status-med   { color: var(--amber); background: var(--amber-dim); }
.status-low   { color: var(--blue);  background: var(--blue-dim); }
.status-none  { color: var(--text3); background: rgba(255,255,255,0.05); }

/* ── NEWS ────────────────────────────────────────── */
.news-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.news-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.news-filter-btn {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid var(--border2);
  background: none;
  color: var(--text3);
  cursor: pointer;
  transition: all 0.15s;
}

.news-filter-btn:hover { color: var(--text2); }
.news-filter-btn.active { border-color: var(--red); color: var(--red); background: var(--red-dim); }

.news-refresh-btn {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text3);
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
  transition: all 0.15s;
}

.news-refresh-btn:hover { color: var(--text2); border-color: var(--border2); }

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

.news-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s, transform 0.15s;
  cursor: default;
}

.news-card:hover { border-color: var(--border2); transform: translateY(-1px); }

.news-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.news-source-badge {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  padding: 3px 9px;
  border-radius: 4px;
  border: 1px solid;
}

.news-date {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text3);
  white-space: nowrap;
}

.news-title {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--text);
  flex: 1;
}

.news-title a { color: inherit; text-decoration: none; }
.news-title a:hover { color: var(--blue); }

.news-excerpt {
  font-size: 13px;
  color: var(--text3);
  line-height: 1.55;
}

.news-read-more {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--blue);
  text-decoration: none;
  letter-spacing: 0.04em;
  margin-top: auto;
}

.news-read-more:hover { color: var(--text); }

/* Skeleton loading */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.skeleton-line {
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--bg3) 25%, rgba(255,255,255,0.06) 50%, var(--bg3) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.6s infinite;
  margin-bottom: 10px;
}

.skeleton-line.short  { width: 38%; }
.skeleton-line.long   { width: 88%; height: 16px; }
.skeleton-line.medium { width: 62%; }
.skeleton-line.body1  { width: 95%; }
.skeleton-line.body2  { width: 80%; }

.news-empty {
  grid-column: 1 / -1;
  text-align: center;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text3);
  padding: 60px 20px;
  line-height: 2;
}

.news-count {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text3);
}

/* ── SCROLLBAR ───────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* ── RESPONSIVE ──────────────────────────────────── */
@media (max-width: 900px) {
  main          { padding: 16px; }
  .metrics-row  { grid-template-columns: repeat(2, 1fr); }
  .map-section  { grid-template-columns: 1fr; }
  .bottom-grid  { grid-template-columns: 1fr; }
  .news-grid    { grid-template-columns: 1fr; }
  nav                { padding: 0 16px; top: 148px; }
  .nav-btn           { padding: 16px 16px; font-size: 12px; }
  #map               { height: 260px; }
  .header-logo-img   { height: 100px; }
  .header-bottom     { gap: 10px; padding: 6px 16px 8px; flex-wrap: wrap; justify-content: center; }
  .header-title      { font-size: 11px; letter-spacing: 0.15em; }
  .last-update       { font-size: 10px; }
  .header-sep        { display: none; }
}
