/* =============================================================================
   styles.css : capa de componentes del Business OS.
   Heredada de agency-os/cockpit/styles.css (misma estructura de componentes),
   extendida a las 8 secciones. NO contiene valores de marca: todo sale de las
   custom properties de skin.css.

   Unica excepcion deliberada: el sello "built by Mardini IA" (.built-by) usa
   valores literales de la paleta para que un skin de cliente no pueda ocultarlo.
   ========================================================================== */

/* --- tipografia de marca (archivos locales, CSP font-src 'self') ---------- */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("./assets/fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("./assets/fonts/inter-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Instrument Serif";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("./assets/fonts/instrument-serif-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Instrument Serif";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("./assets/fonts/instrument-serif-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* --- base ---------------------------------------------------------------- */
* { box-sizing: border-box; }

html { background: var(--bg-primary); }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(920px 620px at 78% 104%, rgba(99, 102, 241, 0.13), transparent 62%),
    radial-gradient(1100px 720px at 42% -18%, var(--blue-950), transparent 58%),
    var(--bg-primary);
  background-attachment: fixed;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: var(--size-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
}

button, select, textarea, input { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; color: var(--text-primary); }
p { margin: 0; }

:focus-visible { outline: 2px solid var(--blue-500); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

[hidden] { display: none !important; }

/* --- tipografia compartida ------------------------------------------------ */
.eyebrow {
  color: var(--blue-400);
  font-size: var(--size-xs);
  font-weight: var(--weight-extrabold);
  letter-spacing: .18em;
  text-transform: uppercase;
}

.display {
  font-family: var(--font-display);
  font-weight: var(--weight-normal);
  letter-spacing: -.01em;
  line-height: var(--leading-tight);
}

.accent { color: var(--blue-400); }

/* =============================================================================
   LOGIN GATE
   ========================================================================== */
.gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: var(--space-6);
  background:
    radial-gradient(760px 520px at 50% 8%, rgba(23, 37, 84, 0.9), transparent 62%),
    var(--bg-primary);
}

.gate-card {
  width: min(430px, 100%);
  padding: var(--space-10) var(--space-8) var(--space-8);
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-section);
  box-shadow: var(--shadow-glow);
  text-align: center;
}

.gate-logo { width: 176px; height: auto; margin: 0 auto var(--space-6); display: block; }

.gate-card h1 {
  font-family: var(--font-display);
  font-size: var(--size-4xl);
  font-weight: var(--weight-normal);
  line-height: var(--leading-tight);
}

.gate-claim {
  margin-top: var(--space-2);
  color: var(--text-tertiary);
  font-size: var(--size-sm);
}

.gate-form { margin-top: var(--space-8); display: grid; gap: var(--space-3); }

.gate-form label {
  color: var(--text-muted);
  font-size: var(--size-xs);
  font-weight: var(--weight-extrabold);
  letter-spacing: .14em;
  text-transform: uppercase;
  text-align: left;
}

.gate-form input {
  width: 100%;
  padding: var(--space-4);
  background: var(--bg-primary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-button);
  color: var(--text-primary);
  font-size: var(--size-xl);
  font-weight: var(--weight-bold);
  letter-spacing: .5em;
  text-align: center;
}
.gate-form input:focus { border-color: var(--blue-500); outline: 0; box-shadow: 0 0 0 3px var(--border-accent); }
.gate-form input { text-indent: .5em; }

.gate-error {
  min-height: 18px;
  color: var(--error-400);
  font-size: var(--size-xs);
  font-weight: var(--weight-semibold);
}

.gate-hint { margin-top: var(--space-5); color: var(--text-muted); font-size: var(--size-xs); }

/* --- boton primario compartido ------------------------------------------- */
.btn-primary {
  padding: var(--space-3) var(--space-6);
  background: var(--gradient-brand);
  border: 0;
  border-radius: var(--radius-button);
  color: var(--text-primary);
  font-size: var(--size-xs);
  font-weight: var(--weight-extrabold);
  letter-spacing: .12em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: var(--shadow-blue-md);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}
.btn-primary:hover:not(:disabled) { transform: scale(1.02); box-shadow: var(--shadow-blue-xl); }
.btn-primary:disabled { background: var(--bg-tertiary); color: var(--text-muted); box-shadow: none; cursor: not-allowed; }

/* =============================================================================
   TOPBAR
   ========================================================================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(10, 10, 15, 0.97);
  backdrop-filter: blur(var(--blur-navbar));
  border-bottom: 1px solid var(--border-medium);
}

.topbar-shell {
  width: min(100%, calc(var(--shell-max) + var(--rail-width) + var(--space-16)));
  min-height: 76px;
  margin: 0 auto;
  padding: var(--space-3) var(--space-8);
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.brand-lockup { display: flex; align-items: center; gap: var(--space-4); min-width: 0; }
.brand-logo { width: 148px; height: auto; display: block; }
.brand-divider { width: 1px; height: 30px; background: var(--border-medium); }
.brand-copy { min-width: 0; }
.brand-name {
  color: var(--text-primary);
  font-size: var(--size-sm);
  font-weight: var(--weight-extrabold);
  letter-spacing: .14em;
  text-transform: uppercase;
  white-space: nowrap;
}
.brand-claim {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: var(--size-xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-badge);
  color: var(--success-400);
  font-size: var(--size-xs);
  font-weight: var(--weight-extrabold);
  letter-spacing: .12em;
  white-space: nowrap;
}
.pulse {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success-500);
  box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.14);
}

/* --- SELLO: fuera del skin, valores literales de la paleta ---------------- */
.built-by {
  flex: none;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 9999px;
  color: #9ca3af;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
  white-space: nowrap;
}
.built-by b { color: #ffffff; font-weight: 800; }

/* =============================================================================
   SHELL + NAV RAIL
   ========================================================================== */
#app { display: flex; flex-direction: column; min-height: 100vh; }

.shell {
  flex: 1;
  width: min(100%, calc(var(--shell-max) + var(--rail-width) + var(--space-16)));
  margin: 0 auto;
  padding: var(--space-8) var(--space-8) var(--space-16);
  display: grid;
  grid-template-columns: var(--rail-width) minmax(0, 1fr);
  gap: var(--space-8);
  align-items: start;
}

.rail { position: sticky; top: 100px; display: grid; gap: var(--space-2); }

.rail-title {
  padding: 0 var(--space-3) var(--space-2);
  color: var(--text-muted);
  font-size: var(--size-xs);
  font-weight: var(--weight-extrabold);
  letter-spacing: .16em;
  text-transform: uppercase;
}

.rail-item {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-button);
  color: var(--text-tertiary);
  font-size: var(--size-sm);
  font-weight: var(--weight-semibold);
  text-align: left;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
.rail-item:hover { background: var(--bg-secondary); color: var(--text-primary); }
.rail-item.active {
  background: var(--bg-secondary);
  border-color: var(--border-accent);
  color: var(--text-primary);
  box-shadow: var(--shadow-blue-sm);
}
.rail-index {
  color: var(--text-muted);
  font-size: var(--size-xs);
  font-weight: var(--weight-extrabold);
  letter-spacing: .05em;
}
.rail-item.active .rail-index { color: var(--blue-400); }
.rail-item span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rail-tag {
  padding: 3px 8px;
  border-radius: var(--radius-badge);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: var(--weight-extrabold);
  letter-spacing: .1em;
  text-transform: uppercase;
}
.rail-item.active .rail-tag { background: var(--blue-950); color: var(--blue-400); }

/* =============================================================================
   SECCIONES
   ========================================================================== */
.view { display: none; }
.view.active { display: block; }

.view-head { margin-bottom: var(--space-8); }
.view-head h1 {
  margin: var(--space-3) 0 var(--space-3);
  font-family: var(--font-display);
  font-size: clamp(34px, 4vw, 52px);
  font-weight: var(--weight-normal);
  line-height: 1.05;
  letter-spacing: -.015em;
}
.view-head p { max-width: 62ch; color: var(--text-tertiary); font-size: var(--size-lg); line-height: var(--leading-relaxed); }

.head-row { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-3); }
.view-head .head-row { margin-top: var(--space-5); }

/* --- badges de honestidad ------------------------------------------------- */
.data-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 5px 12px;
  border: 1px solid var(--warning-500);
  border-radius: var(--radius-badge);
  background: rgba(245, 158, 11, 0.10);
  color: var(--warning-400);
  font-size: var(--size-xs);
  font-weight: var(--weight-extrabold);
  letter-spacing: .1em;
  text-transform: uppercase;
}
.data-badge.preview { border-color: var(--border-accent); background: var(--blue-950); color: var(--blue-400); }
.data-badge.real { border-color: rgba(34, 197, 94, 0.35); background: rgba(34, 197, 94, 0.10); color: var(--success-400); }

/* --- card generica -------------------------------------------------------- */
.card {
  padding: var(--space-6);
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-card);
}

.empty {
  padding: var(--space-12);
  border: 1px dashed var(--border-medium);
  border-radius: var(--radius-card);
  color: var(--text-muted);
  text-align: center;
}

.panel-error {
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--error-500);
  border-radius: var(--radius-button);
  background: rgba(239, 68, 68, 0.08);
  color: var(--error-400);
  font-size: var(--size-sm);
}

/* =============================================================================
   01 · CHAT
   ========================================================================== */
.chat-shell {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 520px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-section);
  overflow: hidden;
}

.messages {
  min-height: 380px;
  max-height: 56vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-6);
}

.welcome { margin: auto 0; display: grid; gap: var(--space-5); justify-items: center; text-align: center; }
.welcome-title {
  font-family: var(--font-display);
  font-size: var(--size-3xl);
  color: var(--text-primary);
  line-height: var(--leading-tight);
}
.welcome p { max-width: 46ch; color: var(--text-tertiary); font-size: var(--size-sm); }
.suggestions { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: center; }
.suggestion {
  padding: var(--space-2) var(--space-4);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-badge);
  color: var(--text-secondary);
  font-size: var(--size-xs);
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast);
}
.suggestion:hover { border-color: var(--blue-500); color: var(--text-primary); }

.message { width: fit-content; max-width: 84%; display: grid; gap: var(--space-2); }
.message.user { justify-self: end; }
.message.assistant, .message.error, .message.thinking { justify-self: start; }
.message-label {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: var(--weight-extrabold);
  letter-spacing: .14em;
  text-transform: uppercase;
}
.message.user .message-label { text-align: right; }
.message-content {
  padding: var(--space-4) var(--space-5);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-card);
  color: var(--text-secondary);
  font-size: var(--size-sm);
  line-height: var(--leading-relaxed);
  overflow-wrap: anywhere;
}
.message.user .message-content { background: var(--blue-950); border-color: var(--border-accent); color: var(--text-primary); }
.message.error .message-content { border-color: var(--error-500); color: var(--error-400); }
.message.thinking .message-content { color: var(--text-tertiary); }
.message.thinking .message-content::after {
  content: "...";
  display: inline-block;
  animation: blink 1s steps(2, start) infinite;
}
.message-content .plain { white-space: pre-wrap; }
.message-content pre {
  overflow-x: auto;
  margin: var(--space-3) 0 0;
  padding: var(--space-3);
  background: var(--bg-primary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-button);
  color: var(--blue-400);
  font-family: var(--font-mono);
  font-size: var(--size-xs);
  white-space: pre-wrap;
}

.chat-form { padding: var(--space-4); border-top: 1px solid var(--border-medium); background: var(--bg-secondary); }
.chat-form textarea {
  width: 100%;
  min-height: 84px;
  max-height: 200px;
  padding: var(--space-4);
  resize: vertical;
  background: var(--bg-primary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-button);
  color: var(--text-primary);
  font-size: var(--size-sm);
  outline: 0;
}
.chat-form textarea:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px var(--border-accent); }
.chat-form textarea::placeholder { color: var(--text-muted); }
.composer-bottom {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); margin-top: var(--space-3);
}
.composer-bottom > span { color: var(--text-muted); font-size: var(--size-xs); }

/* =============================================================================
   02 · ORGANIGRAMA DE CAPACIDADES
   ========================================================================== */
.status-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}
.metric {
  padding: var(--space-4) var(--space-5);
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-card);
}
.metric strong {
  display: block;
  color: var(--text-primary);
  font-size: var(--size-4xl);
  font-weight: var(--weight-extrabold);
  line-height: 1;
  letter-spacing: -.02em;
}
.metric span {
  display: block;
  margin-top: var(--space-2);
  color: var(--text-muted);
  font-size: var(--size-xs);
  font-weight: var(--weight-bold);
  letter-spacing: .1em;
  text-transform: uppercase;
}
.metric.is-operativo strong { color: var(--success-400); }
.metric.is-probado strong { color: var(--blue-400); }
.metric.is-experimental strong { color: var(--warning-400); }
.metric.is-gap strong { color: var(--error-400); }

.filters-row {
  display: flex; align-items: end; justify-content: space-between;
  flex-wrap: wrap; gap: var(--space-4); margin-bottom: var(--space-4);
}
.coverage { color: var(--text-muted); font-size: var(--size-sm); }
.filters label {
  display: grid; gap: var(--space-2);
  color: var(--text-muted);
  font-size: var(--size-xs);
  font-weight: var(--weight-extrabold);
  letter-spacing: .12em;
  text-transform: uppercase;
}
select {
  min-width: 168px;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-button);
  font-size: var(--size-sm);
}

.department-filter {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-8);
}
.department-filter button {
  padding: var(--space-3) var(--space-2);
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-button);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 10px;
  font-weight: var(--weight-extrabold);
  letter-spacing: .08em;
  text-transform: uppercase;
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}
.department-filter button b { display: block; margin-top: 3px; font-size: var(--size-sm); }
.department-filter button:hover,
.department-filter button.active {
  color: var(--text-primary);
  border-color: var(--blue-500);
  background: var(--blue-950);
}

.departments { display: grid; gap: var(--space-10); }
.department-header {
  display: flex; align-items: center; gap: var(--space-3);
  margin-bottom: var(--space-4); padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}
.department-header h3 {
  font-size: var(--size-sm);
  font-weight: var(--weight-extrabold);
  letter-spacing: .16em;
  text-transform: uppercase;
}
.department-count {
  padding: 3px 9px;
  border-radius: var(--radius-badge);
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
  font-size: var(--size-xs);
  font-weight: var(--weight-extrabold);
}
.systems-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); }

.system-card {
  min-height: 132px;
  display: flex;
  flex-direction: column;
  padding: var(--space-4);
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-card);
  transition: border-color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
}
.system-card:hover { border-color: var(--blue-500); background: var(--bg-tertiary); transform: translateY(-2px); }
.system-card:focus-visible { outline: 2px solid var(--blue-400); outline-offset: 2px; }
.system-card.gap { border-style: dashed; border-color: rgba(239, 68, 68, 0.45); }
.system-top { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); }
.system-card h4 {
  margin: var(--space-4) 0 var(--space-2);
  font-size: var(--size-sm);
  font-weight: var(--weight-bold);
  line-height: var(--leading-snug);
}
.system-desc { margin-top: auto; color: var(--text-muted); font-size: var(--size-xs); line-height: var(--leading-normal); }

.badge, .state {
  border-radius: var(--radius-badge);
  font-size: 10px;
  font-weight: var(--weight-extrabold);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.badge { padding: 4px 9px; background: var(--bg-tertiary); color: var(--text-secondary); }
.badge.agent { color: var(--purple-500); background: rgba(168, 85, 247, 0.14); }
.badge.skill { color: var(--blue-400); background: var(--blue-950); }
.badge.rutina { color: var(--success-400); background: rgba(34, 197, 94, 0.12); }
.badge.manual { color: var(--text-secondary); background: var(--bg-tertiary); }
.state { color: var(--text-tertiary); white-space: nowrap; }
.state.operativo { color: var(--success-400); }
.state.probado { color: var(--blue-400); }
.state.experimental { color: var(--warning-400); }
.state.gap { color: var(--error-400); }

/* =============================================================================
   03 · WORKFLOW ESTRELLA
   ========================================================================== */
.workflow-hero {
  padding: var(--space-8);
  background: linear-gradient(135deg, var(--blue-950), var(--bg-secondary) 62%);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-section);
}
.workflow-hero p {
  max-width: 62ch;
  margin-top: var(--space-4);
  color: var(--text-secondary);
  font-size: var(--size-lg);
  line-height: var(--leading-relaxed);
}
.workflow-facts { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-6); }

.steps {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--space-3);
  margin: var(--space-8) 0;
}
.step {
  position: relative;
  padding: var(--space-5) var(--space-4);
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-card);
}
.step::after {
  content: "";
  position: absolute;
  top: 50%;
  right: calc(var(--space-3) * -1);
  width: var(--space-3);
  height: 1px;
  background: var(--border-accent);
}
.step:last-child::after { display: none; }
.step-index {
  display: inline-grid;
  place-content: center;
  width: 28px; height: 28px;
  margin-bottom: var(--space-3);
  border-radius: var(--radius-badge);
  background: var(--blue-950);
  border: 1px solid var(--border-accent);
  color: var(--blue-400);
  font-size: var(--size-xs);
  font-weight: var(--weight-extrabold);
}
.step h4 { font-size: var(--size-sm); font-weight: var(--weight-bold); }
.step p { margin-top: var(--space-2); color: var(--text-muted); font-size: var(--size-xs); line-height: var(--leading-normal); }

.run-panel { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); }
.run-fact {
  padding: var(--space-4) var(--space-5);
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-card);
}
.run-fact span {
  display: block;
  color: var(--text-muted);
  font-size: var(--size-xs);
  font-weight: var(--weight-bold);
  letter-spacing: .1em;
  text-transform: uppercase;
}
.run-fact strong {
  display: block;
  margin-top: var(--space-2);
  color: var(--text-primary);
  font-size: var(--size-xl);
  font-weight: var(--weight-bold);
}
.run-fact strong.ok { color: var(--success-400); }
.run-artifact {
  margin-top: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--bg-primary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-button);
  color: var(--text-muted);
  font-size: var(--size-xs);
}
.run-artifact code { color: var(--blue-400); font-family: var(--font-mono); }

/* =============================================================================
   04 · ROI
   ========================================================================== */
.roi-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }
.roi-card {
  padding: var(--space-6);
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-card);
}
.roi-card .roi-label {
  color: var(--text-muted);
  font-size: var(--size-xs);
  font-weight: var(--weight-bold);
  letter-spacing: .1em;
  text-transform: uppercase;
}
.roi-card .roi-value {
  display: block;
  margin: var(--space-3) 0;
  font-family: var(--font-display);
  font-size: var(--size-5xl);
  font-weight: var(--weight-normal);
  line-height: 1;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.roi-card .roi-nota { color: var(--text-tertiary); font-size: var(--size-sm); line-height: var(--leading-relaxed); }

/* =============================================================================
   05 · REPORTES · 07 · DOCUMENTOS (lista + lector)
   ========================================================================== */
.reader-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: var(--space-6); align-items: start; }
.doc-list { display: grid; gap: var(--space-2); }
.doc-item {
  display: grid;
  gap: var(--space-1);
  padding: var(--space-4);
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-button);
  color: var(--text-secondary);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.doc-item:hover { border-color: var(--blue-500); background: var(--bg-tertiary); }
.doc-item.active { border-color: var(--border-accent); background: var(--blue-950); color: var(--text-primary); }
.doc-item strong { font-size: var(--size-sm); font-weight: var(--weight-semibold); }
.doc-item span { color: var(--text-muted); font-size: var(--size-xs); letter-spacing: .06em; text-transform: uppercase; }
.doc-item.active span { color: var(--blue-400); }
.doc-tree-group { display: grid; gap: var(--space-2); }
.doc-tree-folder {
  padding: var(--space-2) var(--space-3);
  padding-left: calc(var(--space-3) + var(--tree-depth, 0) * var(--space-4));
  color: var(--text-muted);
  font-size: var(--size-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.doc-tree-file { padding-left: calc(var(--space-4) + var(--tree-depth, 0) * var(--space-4)); }

.reader {
  min-width: 0;
  padding: var(--space-8);
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-card);
}

/* --- markdown ------------------------------------------------------------- */
.md { color: var(--text-secondary); font-size: var(--size-sm); line-height: var(--leading-relaxed); }
.md > *:first-child { margin-top: 0; }
.md h1 {
  margin: 0 0 var(--space-4);
  font-family: var(--font-display);
  font-size: var(--size-3xl);
  font-weight: var(--weight-normal);
  line-height: var(--leading-tight);
}
.md h2 {
  margin: var(--space-8) 0 var(--space-3);
  color: var(--text-primary);
  font-size: var(--size-xl);
  font-weight: var(--weight-bold);
}
.md h3 { margin: var(--space-6) 0 var(--space-2); color: var(--text-primary); font-size: var(--size-base); font-weight: var(--weight-bold); }
.md p { margin: var(--space-3) 0; }
.md ul, .md ol { margin: var(--space-3) 0; padding-left: var(--space-5); }
.md li { margin: var(--space-2) 0; }
.md li::marker { color: var(--blue-400); }
.md strong { color: var(--text-primary); font-weight: var(--weight-bold); }
.md code {
  padding: 2px 6px;
  background: var(--bg-primary);
  border: 1px solid var(--border-medium);
  border-radius: 6px;
  color: var(--blue-400);
  font-family: var(--font-mono);
  font-size: var(--size-xs);
}
.md pre {
  overflow-x: auto;
  margin: var(--space-4) 0;
  padding: var(--space-4);
  background: var(--bg-primary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-button);
}
.md pre code { padding: 0; border: 0; background: transparent; }
.md blockquote {
  margin: var(--space-4) 0;
  padding: var(--space-3) var(--space-5);
  border-left: 2px solid var(--blue-500);
  background: var(--bg-tertiary);
  border-radius: 0 var(--radius-button) var(--radius-button) 0;
  color: var(--text-tertiary);
}
.md hr { margin: var(--space-6) 0; border: 0; border-top: 1px solid var(--border-subtle); }
.md-table-wrap { overflow-x: auto; margin: var(--space-4) 0; }
.md table { width: 100%; border-collapse: collapse; font-size: var(--size-xs); }
.md th, .md td { padding: var(--space-3); border-bottom: 1px solid var(--border-subtle); text-align: left; }
.md th {
  color: var(--text-muted);
  font-weight: var(--weight-extrabold);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.md td { color: var(--text-secondary); }

/* =============================================================================
   06 · ACTIVIDAD
   ========================================================================== */
.timeline { display: grid; gap: 0; }
.event {
  position: relative;
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: var(--space-5);
  padding: var(--space-5) 0 var(--space-5) var(--space-6);
  border-left: 1px solid var(--border-medium);
}
.event::before {
  content: "";
  position: absolute;
  left: -5px;
  top: calc(var(--space-5) + 7px);
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--success-500);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.14);
}
.event.representativo::before { background: var(--warning-500); box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.14); }
.event:last-child { border-left-color: transparent; }
.event-ts {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--size-xs);
  letter-spacing: .02em;
  white-space: nowrap;
}
.event-body { display: grid; gap: var(--space-2); }
.event-body p { color: var(--text-secondary); font-size: var(--size-sm); line-height: var(--leading-relaxed); }
.event-tag {
  width: max-content;
  padding: 3px 9px;
  border-radius: var(--radius-badge);
  font-size: 10px;
  font-weight: var(--weight-extrabold);
  letter-spacing: .1em;
  text-transform: uppercase;
  background: rgba(34, 197, 94, 0.12);
  color: var(--success-400);
}
.event.representativo .event-tag { background: rgba(245, 158, 11, 0.12); color: var(--warning-400); }

/* =============================================================================
   08 · PIDE UN CAMBIO
   ========================================================================== */
.cambio-form {
  display: grid;
  gap: var(--space-6);
  width: 100%;
  padding: var(--space-6);
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-section);
  box-shadow: var(--shadow-card);
}
.cambio-form-head {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--border-medium);
}
.cambio-form-head h3 { font-size: var(--size-lg); }
.cambio-form-head p {
  margin-top: var(--space-1);
  color: var(--text-muted);
  font-size: var(--size-xs);
  line-height: var(--leading-relaxed);
}
.cambio-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-5);
}
.cambio-field {
  display: grid;
  align-content: start;
  gap: var(--space-2);
}
.cambio-field-wide { grid-column: 1 / -1; }
.cambio-field > span {
  color: var(--text-secondary);
  font-size: var(--size-xs);
  font-weight: var(--weight-extrabold);
  letter-spacing: .1em;
  text-transform: uppercase;
}
.cambio-field small { color: var(--text-muted); font-size: var(--size-xs); }
.cambio-form input,
.cambio-form select,
.cambio-form textarea {
  width: 100%;
  min-width: 0;
  padding: var(--space-4);
  background: var(--bg-primary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-button);
  color: var(--text-primary);
  font-size: var(--size-sm);
  line-height: var(--leading-relaxed);
  outline: 0;
}
.cambio-form textarea { min-height: 144px; resize: vertical; }
.cambio-form textarea.cambio-textarea-compact { min-height: 104px; }
.cambio-form input:focus,
.cambio-form select:focus,
.cambio-form textarea:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px var(--border-accent);
}
.cambio-form input::placeholder,
.cambio-form textarea::placeholder { color: var(--text-muted); }
.cambio-actions { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.cambio-actions > span { max-width: 460px; color: var(--text-muted); font-size: var(--size-xs); }
.cambio-ok {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-5);
  border: 1px solid rgba(34, 197, 94, 0.4);
  border-radius: var(--radius-card);
  background: rgba(34, 197, 94, 0.08);
  color: var(--success-400);
  font-size: var(--size-sm);
}
.cambio-ok code { color: var(--text-primary); font-family: var(--font-mono); }

.que-sigue { margin-top: var(--space-12); }
.que-sigue-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); margin-top: var(--space-4); }
.que-sigue .card h4 { margin: var(--space-3) 0 var(--space-2); font-size: var(--size-sm); font-weight: var(--weight-bold); }
.que-sigue .card p { color: var(--text-muted); font-size: var(--size-xs); line-height: var(--leading-relaxed); }

/* =============================================================================
   FOOTER
   ========================================================================== */
.site-footer { border-top: 1px solid var(--border-medium); background: rgba(10, 10, 15, 0.6); }
.footer-shell {
  width: min(100%, calc(var(--shell-max) + var(--rail-width) + var(--space-16)));
  margin: 0 auto;
  padding: var(--space-6) var(--space-8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: var(--size-xs);
}

/* =============================================================================
   MOTION
   ========================================================================== */
@keyframes blink { 50% { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.view.active .view-head,
.view.active .reveal { animation: rise .42s ease both; }
.view.active .reveal:nth-child(1) { animation-delay: .04s; }
.view.active .reveal:nth-child(2) { animation-delay: .10s; }
.view.active .reveal:nth-child(3) { animation-delay: .16s; }
.view.active .reveal:nth-child(4) { animation-delay: .22s; }
.view.active .reveal:nth-child(5) { animation-delay: .28s; }
.view.active .reveal:nth-child(6) { animation-delay: .34s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* =============================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 1180px) {
  .shell { grid-template-columns: 216px minmax(0, 1fr); gap: var(--space-6); padding-inline: var(--space-5); }
  .topbar-shell, .footer-shell { padding-inline: var(--space-5); }
  .systems-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .department-filter { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .roi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .step:nth-child(3)::after { display: none; }
  .run-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .reader-layout { grid-template-columns: 250px minmax(0, 1fr); }
  .brand-claim { display: none; }
}

@media (max-width: 900px) {
  .shell { display: block; padding-top: 0; }
  .rail {
    position: sticky;
    top: 76px;
    z-index: 30;
    display: flex;
    gap: var(--space-2);
    margin: 0 calc(var(--space-5) * -1) var(--space-6);
    padding: var(--space-3) var(--space-5);
    overflow-x: auto;
    background: rgba(10, 10, 15, 0.97);
    backdrop-filter: blur(var(--blur-navbar));
    border-bottom: 1px solid var(--border-medium);
    scrollbar-width: none;
  }
  .rail::-webkit-scrollbar { display: none; }
  .rail-title { display: none; }
  .rail-item {
    flex: none;
    grid-template-columns: auto auto auto;
    padding: var(--space-2) var(--space-4);
    border-color: var(--border-medium);
    border-radius: var(--radius-badge);
    font-size: var(--size-xs);
    white-space: nowrap;
  }
  .rail-index { display: none; }
  .reader-layout { grid-template-columns: minmax(0, 1fr); }
  .doc-list { grid-auto-flow: row; }
}

@media (max-width: 620px) {
  .topbar-shell { min-height: 66px; padding-inline: var(--space-4); gap: var(--space-3); }
  .brand-logo { width: 108px; }
  .brand-divider, .brand-copy, .live-pill { display: none; }
  .built-by { margin-left: auto; padding: 5px 10px; font-size: 10px; letter-spacing: .1em; }
  .shell { padding-inline: var(--space-4); padding-bottom: var(--space-12); }
  .rail { top: 66px; margin-inline: calc(var(--space-4) * -1); padding-inline: var(--space-4); }
  .view-head h1 { font-size: 32px; }
  .view-head p { font-size: var(--size-base); }
  .status-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
  .metric { padding: var(--space-3) var(--space-4); }
  .metric strong { font-size: var(--size-3xl); }
  .department-filter { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .systems-grid, .roi-grid, .steps, .run-panel, .que-sigue-grid, .cambio-form-grid { grid-template-columns: 1fr; }
  .cambio-field-wide { grid-column: auto; }
  .cambio-form { padding: var(--space-5); }
  .cambio-actions .btn-primary { width: 100%; }
  .step::after { display: none; }
  .roi-card .roi-value { font-size: var(--size-4xl); }
  .messages { padding: var(--space-4); max-height: none; min-height: 320px; }
  .message { max-width: 96%; }
  .event { grid-template-columns: 1fr; gap: var(--space-2); padding-left: var(--space-5); }
  .workflow-hero { padding: var(--space-5); }
  .workflow-hero h2 { font-size: var(--size-3xl); }
  .reader { padding: var(--space-5); }
  .footer-shell { padding-inline: var(--space-4); }
}
