/* ---------- Tokens ---------- */
:root {
  --paper: #f4f2ec;
  --paper-alt: #ebe8df;
  --card: #fbfaf6;
  --ink: #0e1a24;
  --ink-soft: #2c3a46;
  --muted: #5d6871;
  --line: #d8d3c6;
  --signal: #e4472d;
  --signal-ink: #b8321c;
  --good: #1d7a6a;

  /* consola: siempre oscura */
  --c-bg: #0a131b;
  --c-panel: #111e29;
  --c-line: #1f3040;
  --c-text: #e3ebf1;
  --c-muted: #8597a6;
  --c-dot: #5fb3c2;
  --c-good: #4cc39e;
  --c-bad: #ff7a5c;

  --serif: "Instrument Serif", Georgia, serif;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;

  --wrap: 1180px;
  --gutter: clamp(16px, 4vw, 40px);
  --radius: 10px;
  --header-h: 64px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0d151c;
    --paper-alt: #111c25;
    --card: #142230;
    --ink: #eef2f4;
    --ink-soft: #c9d3da;
    --muted: #93a1ac;
    --line: #243443;
    --signal: #ff5a3d;
    --signal-ink: #ff7a61;
    --good: #4cc39e;
  }
}
:root[data-theme="dark"] {
  --paper: #0d151c;
  --paper-alt: #111c25;
  --card: #142230;
  --ink: #eef2f4;
  --ink-soft: #c9d3da;
  --muted: #93a1ac;
  --line: #243443;
  --signal: #ff5a3d;
  --signal-ink: #ff7a61;
  --good: #4cc39e;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 8px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.015em; line-height: 1.15; }
p { margin: 0; }
a { color: inherit; }
img, svg { display: block; }
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--ink); color: var(--paper); padding: 8px 12px; border-radius: 6px; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 22px;
  background: var(--ink); color: var(--paper);
  border: 1px solid var(--ink); border-radius: 999px;
  font: 500 15px/1 var(--sans); text-decoration: none; cursor: pointer;
  transition: background .2s, color .2s, border-color .2s, transform .2s;
}
.btn:hover { background: var(--signal); border-color: var(--signal); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn-small { min-height: 38px; padding: 0 18px; font-size: 14px; }
.btn[disabled] { opacity: .6; cursor: progress; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.site-header.scrolled { border-bottom-color: var(--line); }
.header-inner { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-size: 21px; letter-spacing: -0.02em; }
.logo b { font-weight: 600; }
.logo-mark { width: 30px; height: 30px; color: var(--ink); }
.nav { display: flex; align-items: center; gap: 28px; }
.nav a:not(.btn) { font-size: 15px; color: var(--ink-soft); text-decoration: none; }
.nav a:not(.btn):hover { color: var(--signal-ink); }
.nav-toggle { display: none; }

@media (max-width: 860px) {
  .nav-toggle {
    display: inline-flex; flex-direction: column; justify-content: center; gap: 6px;
    width: 44px; height: 44px; padding: 0 11px; margin-right: -11px;
    background: none; border: 0; cursor: pointer;
  }
  .nav-toggle span { display: block; height: 2px; background: var(--ink); border-radius: 2px; transition: transform .2s; }
  .nav-toggle[aria-expanded="true"] span:first-child { transform: translateY(4px) rotate(45deg); }
  .nav-toggle[aria-expanded="true"] span:last-child { transform: translateY(-4px) rotate(-45deg); }
  .nav {
    position: absolute; top: var(--header-h); left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    padding: 8px var(--gutter) 20px;
    background: var(--paper); border-bottom: 1px solid var(--line);
    display: none;
  }
  .nav.open { display: flex; }
  .nav a:not(.btn) { padding: 14px 0; border-bottom: 1px solid var(--line); font-size: 17px; }
  .nav .btn { margin-top: 16px; }
}

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; padding: clamp(72px, 12vw, 150px) 0 clamp(72px, 11vw, 140px); }
@media (max-width: 759px) { .hero { padding-bottom: 150px; } }
.hero-signal { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.hero-inner { position: relative; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font: 500 13px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  margin-bottom: 28px;
}
.eyebrow::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--signal); }
.hero h1 {
  max-width: 13ch;
  font-size: clamp(44px, 8.4vw, 104px);
  font-weight: 500; letter-spacing: -0.035em; line-height: .98;
}
.hero h1 em { font-family: var(--serif); font-style: italic; font-weight: 400; color: var(--signal); letter-spacing: -0.01em; }
.lead { max-width: 60ch; margin-top: 28px; font-size: clamp(17px, 1.6vw, 20px); line-height: 1.55; color: var(--ink-soft); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 36px; }

/* ---------- Secciones ---------- */
.section { padding: clamp(72px, 10vw, 128px) 0; border-top: 1px solid var(--line); }
.section-alt { background: var(--paper-alt); }
.section-head { display: grid; gap: 14px; max-width: 720px; margin-bottom: clamp(36px, 5vw, 60px); }
.section-head h2 { font-size: clamp(32px, 4.6vw, 54px); font-weight: 500; letter-spacing: -0.03em; }
.section-head p { font-size: 18px; color: var(--muted); }

/* ---------- Capacidades ---------- */
.cap-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line); border-left: 1px solid var(--line);
}
.cap {
  display: flex; flex-direction: column; gap: 14px;
  padding: clamp(24px, 3vw, 36px);
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  transition: background .25s;
}
.cap:hover { background: var(--card); }
.cap-icon { width: 30px; height: 30px; fill: none; stroke: var(--signal); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 8px; }
.cap h3 { font-size: 21px; }
.cap p { color: var(--ink-soft); font-size: 16px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: auto 0 0; padding: 10px 0 0; list-style: none; }
.tags li { font: 400 12.5px/1.3 var(--mono); color: var(--muted); padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px; }
.tags li::first-letter { text-transform: uppercase; }

@media (max-width: 980px) { .cap-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) { .cap-grid { grid-template-columns: 1fr; } }

/* ---------- Centro de control ---------- */
.section-dark { background: var(--c-bg); color: var(--c-text); border-top-color: var(--c-bg); }
.section-dark .section-head p { color: var(--c-muted); }

.console {
  border: 1px solid var(--c-line); border-radius: 14px;
  background: linear-gradient(180deg, #0d1922, #0a131b);
  box-shadow: 0 40px 80px -40px rgba(0,0,0,.6);
  overflow: hidden;
}
.console-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--c-line);
  font: 400 13.5px/1.3 var(--mono); color: var(--c-muted);
}
.console-bar b { color: var(--c-text); font-weight: 500; }
.live { display: inline-flex; align-items: center; gap: 8px; color: var(--c-good); white-space: nowrap; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 1.8s ease-out infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(76,195,158,.6); }
  100% { box-shadow: 0 0 0 9px rgba(76,195,158,0); }
}

.ask {
  display: flex; align-items: center; gap: 10px;
  margin: 20px 20px 0; padding: 6px 6px 6px 16px;
  background: var(--c-panel); border: 1px solid var(--c-line); border-radius: 10px;
  transition: border-color .2s;
}
.ask:focus-within { border-color: var(--c-dot); }
.ask-prompt { font: 500 18px/1 var(--mono); color: var(--signal); }
.ask input {
  flex: 1; min-width: 0; height: 42px;
  background: none; border: 0; outline: none; color: var(--c-text);
  font: 400 16px/1 var(--mono);
}
.ask input::placeholder { color: var(--c-muted); opacity: .8; }
.ask-send {
  flex: none; width: 42px; height: 42px; display: grid; place-items: center;
  background: var(--signal); border: 0; border-radius: 8px; cursor: pointer; color: #fff;
}
.ask-send svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 20px 0; }
.chips button {
  font: 400 13px/1.2 var(--mono); color: var(--c-muted);
  background: none; border: 1px solid var(--c-line); border-radius: 999px;
  padding: 7px 12px; cursor: pointer; transition: color .2s, border-color .2s;
}
.chips button:hover { color: var(--c-text); border-color: var(--c-dot); }
.answer {
  margin: 14px 20px 0; padding: 16px 18px;
  border-left: 2px solid var(--signal); background: rgba(228,71,45,.06); border-radius: 0 8px 8px 0;
}
.answer-text { font-size: 16px; line-height: 1.6; color: var(--c-text); min-height: 1.6em; }
.answer-text.typing::after { content: "▍"; color: var(--signal); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.answer-source { margin-top: 10px; font: 400 12.5px/1.4 var(--mono); color: var(--c-muted); }
.answer-source:empty { display: none; }

.console-grid {
  display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 1px; margin-top: 20px; background: var(--c-line); border-top: 1px solid var(--c-line);
}
.panel { background: var(--c-bg); padding: 20px; min-width: 0; transition: box-shadow .4s; }
.panel.flash { box-shadow: inset 0 0 0 1px var(--signal); }
.panel-title { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 10px; margin-bottom: 16px; font: 500 14px/1.3 var(--sans); letter-spacing: 0; }
.panel-title span { font: 400 12px/1.3 var(--mono); color: var(--c-muted); }
.panel-note { margin-top: 10px; font: 400 12px/1.4 var(--mono); color: var(--c-muted); }

.kpi {
  display: grid; grid-template-columns: 1fr 88px; grid-template-rows: auto auto; gap: 4px 12px; align-items: center;
  padding: 14px 0; border-top: 1px solid var(--c-line); transition: background .4s;
}
.kpi:first-of-type { border-top: 0; padding-top: 0; }
.kpi.flash { background: rgba(228,71,45,.08); }
.kpi-value { font: 500 30px/1.05 var(--sans); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-label { font-size: 14px; color: var(--c-muted); }
.kpi-delta { grid-column: 1 / -1; font: 400 12.5px/1.3 var(--mono); color: var(--c-muted); }
.kpi-delta.good { color: var(--c-good); }
.kpi-delta.bad { color: var(--c-bad); }
.spark { width: 88px; height: 32px; overflow: visible; }
.spark polyline { fill: none; stroke: var(--c-dot); stroke-width: 1.6; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.tick { animation: tick .6s ease-out; }
@keyframes tick { from { color: var(--c-dot); } }

.map { width: 100%; height: auto; }
.map-fill { fill: #0f1d28; stroke: #2a4152; stroke-width: 1.2; }
.map-grid line { stroke: #1a2c3a; stroke-width: 1; }
.map-grid .avenue { stroke: #24394a; stroke-width: 2; }
.map-labels text { font: 400 9.5px var(--mono); fill: #5a7182; letter-spacing: .06em; text-transform: uppercase; }
.map-dots circle { fill: var(--c-dot); opacity: .75; transition: fill 1.2s, opacity 1.2s; }
.map-dots circle.new { fill: var(--signal); opacity: 1; }
.map-dots circle.ping { fill: none; stroke: var(--signal); stroke-width: 1.5; opacity: 1; animation: ping 1.6s ease-out forwards; transform-box: fill-box; transform-origin: center; }
@keyframes ping { to { transform: scale(5); opacity: 0; } }

.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.feed li { padding: 11px 0; border-top: 1px solid var(--c-line); animation: slide-in .5s ease-out; }
.feed li:first-child { border-top: 0; padding-top: 0; }
@keyframes slide-in { from { opacity: 0; transform: translateY(-6px); } }
.feed-meta { display: flex; align-items: center; gap: 8px; font: 400 11.5px/1.3 var(--mono); color: var(--c-muted); }
.feed-tag { color: var(--c-dot); }
.feed-tag::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: currentColor; vertical-align: 1px; }
.feed li.neg .feed-tag { color: var(--c-bad); }
.feed li.warn .feed-tag { color: #f2b84b; }
.feed li.pos .feed-tag { color: var(--c-good); }
.feed-time { margin-left: auto; }
.feed-text { margin-top: 4px; font-size: 14px; line-height: 1.45; color: var(--c-text); }
.feed-sub { margin-top: 2px; font: 400 12px/1.4 var(--mono); color: var(--c-muted); }

@media (max-width: 1020px) {
  .console-grid { grid-template-columns: 1fr 1fr; }
  .panel-map { grid-column: 1 / -1; grid-row: 1; }
}
@media (max-width: 640px) {
  .console-grid { grid-template-columns: 1fr; }
  .console-bar { padding: 12px 16px; font-size: 12px; }
  .ask, .answer { margin-left: 16px; margin-right: 16px; }
  .chips { padding-left: 16px; padding-right: 16px; }
  .panel { padding: 18px 16px; }
}

/* ---------- Módulos ---------- */
.mod-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.mod {
  display: grid; grid-template-columns: 64px minmax(0, 1fr) 170px; gap: 20px; align-items: baseline;
  padding: 26px 0; border-bottom: 1px solid var(--line);
  transition: padding .25s;
}
.mod:hover { padding-left: 10px; }
.mod-n { font: 400 14px/1 var(--mono); color: var(--signal-ink); }
.mod h3 { font-size: 22px; font-weight: 500; }
.mod p { margin-top: 6px; max-width: 64ch; color: var(--ink-soft); font-size: 16px; }
.mod-line { justify-self: end; font: 400 13px/1.2 var(--mono); color: var(--muted); white-space: nowrap; }

@media (max-width: 720px) {
  .mod { grid-template-columns: 40px minmax(0, 1fr); gap: 4px 12px; }
  .mod-line { grid-column: 2; justify-self: start; margin-top: 8px; }
  .mod:hover { padding-left: 0; }
}

/* ---------- Cómo trabajamos ---------- */
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(20px, 3vw, 40px); counter-reset: s; }
.step { position: relative; padding-top: 28px; border-top: 2px solid var(--ink); }
.step:not(:last-child)::after {
  content: ""; position: absolute; top: -6px; right: calc(-1 * clamp(20px, 3vw, 40px) / 2 - 5px);
  width: 10px; height: 10px; border-top: 2px solid var(--ink); border-right: 2px solid var(--ink); transform: rotate(45deg);
}
.step-n { display: block; font: 400 italic 64px/1 var(--serif); color: var(--signal); margin-bottom: 16px; }
.step h3 { font-size: 24px; font-weight: 500; }
.step p { margin-top: 10px; color: var(--ink-soft); }
@media (max-width: 760px) {
  .steps { grid-template-columns: 1fr; }
  .step:not(:last-child)::after { display: none; }
}

/* ---------- Contacto ---------- */
.contact { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(40px, 6vw, 96px); }
.contact h2 { font-size: clamp(32px, 4.6vw, 54px); font-weight: 500; letter-spacing: -0.03em; }
.contact .lead { margin-top: 18px; }
.contact dl { margin: 40px 0 0; display: grid; gap: 0; border-top: 1px solid var(--line); }
.contact dl div { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.contact dt { font: 400 13px/1.6 var(--mono); color: var(--muted); }
.contact dd { margin: 0; overflow-wrap: anywhere; }
.contact dd a { text-decoration-color: var(--line); text-underline-offset: 3px; }
.contact dd a:hover { text-decoration-color: var(--signal); }

.contact-form { display: grid; gap: 18px; align-content: start; padding: clamp(22px, 3vw, 36px); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.field { display: grid; gap: 7px; }
.field label { font-size: 14px; font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  font: 400 16px/1.4 var(--sans);
  transition: border-color .2s;
}
.field textarea { resize: vertical; min-height: 120px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--ink); }
.field .invalid { border-color: var(--signal); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.contact-form .btn { justify-self: start; }
.form-status { font-size: 15px; min-height: 1.5em; }
.form-status.ok { color: var(--good); }
.form-status.err { color: var(--signal-ink); }

@media (max-width: 860px) { .contact { grid-template-columns: 1fr; } }
@media (max-width: 480px) { .contact dl div { grid-template-columns: 1fr; gap: 2px; } }

/* ---------- Footer ---------- */
.site-footer { padding: 28px 0; border-top: 1px solid var(--line); font: 400 13px/1.5 var(--mono); color: var(--muted); }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; }
