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

:root {
  --bg: #0b1a1e;
  --bg-2: #0d1f23;
  --surface: #0f2428;
  --surface-2: #132d32;
  --border: #1a4040;
  --border-hi: #2a5a5a;
  --text: #9cc2b9;
  --text-dim: #5a8279;
  --text-hi: #dff3ee;
  --accent: #3ecfb4;
  --accent-dim: rgba(62, 207, 180, 0.12);
  --orange: #e8833a;
  --crit: #e05a48;
  --info: #4a9ab8;
  --mono: 'SF Mono', 'Cascadia Code', 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --radius: 10px;
  --wrap: 1180px;
}

html { scroll-behavior: smooth; scroll-padding-top: 72px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); }
code { font-size: 0.86em; color: var(--text-hi); background: var(--surface-2); padding: 1px 6px; border-radius: 4px; }
.muted { color: var(--text-dim); }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }

/* --- Cabecera --- */
.top {
  position: sticky; top: 0; z-index: 1000;
  background: rgba(11, 26, 30, 0.88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.top-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text-hi); }
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--accent); display: flex; }
.brand-name { font-family: var(--mono); font-weight: 700; letter-spacing: 0.12em; }
.brand-full { color: var(--text-dim); font-size: 14px; }
.top-nav { display: flex; align-items: center; gap: 24px; font-size: 15px; }
.top-nav a { color: var(--text); }
.top-nav a:hover { color: var(--text-hi); text-decoration: none; }

.btn {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px;
  border-radius: 8px; font-size: 14px; font-weight: 600;
}
.btn-ghost { border: 1px solid var(--border-hi); color: var(--text-hi) !important; }
.btn-ghost:hover { border-color: var(--accent); background: var(--accent-dim); }

/* --- Hero --- */
.hero { padding: 72px 0 40px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 13px; color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 999px; padding: 4px 14px 4px 10px;
  margin-bottom: 24px;
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); }
.live-dot.on { background: var(--accent); box-shadow: 0 0 0 0 rgba(62, 207, 180, 0.6); animation: beat 2s infinite; }
.live-dot.off { background: var(--orange); }
@keyframes beat {
  0% { box-shadow: 0 0 0 0 rgba(62, 207, 180, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(62, 207, 180, 0); }
  100% { box-shadow: 0 0 0 0 rgba(62, 207, 180, 0); }
}
h1 {
  color: var(--text-hi); font-size: clamp(32px, 5vw, 54px); line-height: 1.1;
  letter-spacing: -0.02em; max-width: 18ch; text-wrap: balance;
}
.lede { margin-top: 20px; max-width: 62ch; font-size: 18px; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin-top: 40px;
  background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.kpi { background: var(--surface); padding: 18px 20px; }
.kpi dt { font-size: 13px; color: var(--text-dim); }
.kpi dd { font-family: var(--mono); font-size: 30px; color: var(--text-hi); font-variant-numeric: tabular-nums; margin-top: 4px; }

/* --- Secciones --- */
section { padding: 56px 0; }
.section-head { margin-bottom: 28px; max-width: 760px; }
h2 { color: var(--text-hi); font-size: clamp(24px, 3vw, 32px); line-height: 1.2; letter-spacing: -0.01em; text-wrap: balance; }
.section-head p { margin-top: 10px; }
.lede-sm { font-size: 17px; }
h3 { font-size: 14px; font-weight: 600; color: var(--text-hi); }
h4 { color: var(--text-hi); font-size: 16px; margin-bottom: 4px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 16px 10px; gap: 12px; }

/* --- Monitor --- */
.monitor { background: var(--bg-2); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.monitor-grid {
  display: grid; gap: 16px;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  grid-template-areas:
    "map feed"
    "chart feed"
    "types countries";
}
.map-card { grid-area: map; overflow: hidden; position: relative; }
.feed-card { grid-area: feed; display: flex; flex-direction: column; min-height: 0; max-height: 640px; }
.chart-card { grid-area: chart; }
.bars-card:nth-of-type(4) { grid-area: types; }
.bars-card:nth-of-type(5) { grid-area: countries; }

#map { height: 420px; background: #091417; }
.leaflet-container { font-family: var(--sans); }
.leaflet-control-attribution { background: rgba(11, 26, 30, 0.7) !important; color: var(--text-dim) !important; }
.leaflet-control-attribution a { color: var(--text) !important; }
.map-legend {
  display: flex; flex-wrap: wrap; gap: 16px; padding: 10px 16px;
  font-size: 13px; color: var(--text-dim); border-top: 1px solid var(--border);
}
.sw { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.sw-info { background: var(--info); }
.sw-med { background: var(--orange); }
.sw-crit { background: var(--crit); }
.sw-srv { background: var(--accent); }

.pulse-icon { pointer-events: none; }
.pulse-ring {
  width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid var(--ring, var(--info));
  animation: ring 1.6s ease-out forwards;
}
@keyframes ring { from { transform: scale(0.2); opacity: 1; } to { transform: scale(1.4); opacity: 0; } }

.feed { list-style: none; overflow-y: auto; flex: 1; padding: 0 8px 8px; }
.feed li {
  display: grid; grid-template-columns: 8px 1fr auto; gap: 4px 10px; align-items: baseline;
  padding: 10px 8px; border-top: 1px solid var(--border); font-size: 14px;
}
.feed li:first-child { border-top: 0; }
.feed li.new { animation: slide 0.4s ease-out; }
@keyframes slide { from { opacity: 0; transform: translateY(-6px); background: var(--accent-dim); } to { opacity: 1; transform: none; } }
.feed .sev { width: 8px; height: 8px; border-radius: 50%; align-self: center; }
.feed .what { color: var(--text-hi); }
.feed .when { font-family: var(--mono); font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.feed .where { grid-column: 2 / 4; font-family: var(--mono); font-size: 12px; color: var(--text-dim); }
.sev-info, .sev-low { background: var(--info); }
.sev-medium { background: var(--orange); }
.sev-high, .sev-critical { background: var(--crit); }
.feed-empty { padding: 8px 16px 18px; color: var(--text-dim); font-size: 14px; }

.spark { display: block; width: 100%; height: 120px; padding: 0 16px; }
.spark-axis { display: flex; justify-content: space-between; padding: 4px 16px 14px; font-size: 11px; color: var(--text-dim); }

.bars { list-style: none; padding: 0 16px 16px; }
.bars li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 6px 0; font-size: 14px; }
.bars .label { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .val { font-family: var(--mono); color: var(--text-hi); font-variant-numeric: tabular-nums; }
.bars .track { grid-column: 1 / 3; height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.bars .fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.4s ease; }
.bars .empty { color: var(--text-dim); font-size: 14px; display: block; }

/* --- Que es --- */
.layers { list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.layers li { display: flex; gap: 14px; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.layers p { font-size: 15px; }
.layer-n {
  flex: none; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  font-family: var(--mono); font-weight: 700; color: var(--accent); background: var(--accent-dim);
}

/* --- Como funciona --- */
.how { background: var(--bg-2); border-top: 1px solid var(--border); }
.pipeline { list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; counter-reset: s; }
.pipeline li { position: relative; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.pipeline .step { font-family: var(--mono); font-size: 13px; color: var(--accent); display: block; margin-bottom: 8px; }
.pipeline p { font-size: 15px; }
.pipeline .here { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border-hi); color: var(--text-dim); font-size: 14px; }
.pipeline .here b { color: var(--text); }

.notes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 32px; }
.note { padding: 20px; border-left: 2px solid var(--accent); }
.note p { font-size: 15px; }

/* --- Pie --- */
.foot { border-top: 1px solid var(--border); padding: 28px 0; font-size: 14px; }
.foot-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; }

/* --- Responsive --- */
@media (max-width: 960px) {
  .monitor-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "map map" "feed feed" "chart chart" "types countries";
  }
  .feed-card { max-height: 420px; }
  .layers, .pipeline, .notes { grid-template-columns: repeat(2, 1fr); }
  .brand-full { display: none; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .top-nav a:not(.btn) { display: none; }
  .hero { padding: 48px 0 24px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi dd { font-size: 24px; }
  .monitor-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "map" "feed" "chart" "types" "countries"; }
  #map { height: 300px; }
  .layers, .pipeline, .notes { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot.on, .pulse-ring, .feed li.new { animation: none; }
  .pulse-ring { display: none; }
}
