/* Demo Plataforma SSDM — estilos (sin dependencias) */
:root {
  --bg: #f5f4ef;
  --surface: #ffffff;
  --surface-2: #eeece4;
  --ink: #1b2330;
  --muted: #5a6371;
  --line: #d8d4c8;
  --accent: #1d4a73;
  --accent-ink: #ffffff;
  --accent-soft: #e3ebf3;
  --teal: #2a6f62;
  --ai: #8a5a00;
  --ai-bg: #fdf4dc;
  --ai-line: #d9a93a;
  --ok: #2c6e31;
  --ok-bg: #e3f0e2;
  --rev: #8a5a00;
  --rev-bg: #fbf0d6;
  --pend: #5a6371;
  --pend-bg: #ebe9e2;
  --bad: #a3261d;
  --pos: #1d4a73;
  --neg: #a3261d;
  --seq-0: #f4ecdb;
  --seq-1: #ebcf9f;
  --seq-2: #dba763;
  --seq-3: #c0713a;
  --seq-4: #8b3c22;
  --blu-0: #e6eef6;
  --blu-1: #bcd0e5;
  --blu-2: #86aacd;
  --blu-3: #4a79a8;
  --blu-4: #1d4a73;
  --shadow: 0 1px 2px rgba(20, 25, 35, .06), 0 2px 8px rgba(20, 25, 35, .05);
  --radius: 10px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10141a; --surface: #171c24; --surface-2: #1f2631; --ink: #e5e7ea; --muted: #9aa3ae; --line: #2d3541;
    --accent: #7eaedc; --accent-ink: #0e1620; --accent-soft: #1c2a3a; --teal: #6cc0ab;
    --ai: #e8b65a; --ai-bg: #2a2315; --ai-line: #8f6d26;
    --ok: #86c98a; --ok-bg: #1b2a1c; --rev: #e8b65a; --rev-bg: #2b2414; --pend: #9aa3ae; --pend-bg: #222832; --bad: #f08a80;
    --pos: #7eaedc; --neg: #f08a80;
    --seq-0: #2b2620; --seq-1: #5a4128; --seq-2: #8d5b2e; --seq-3: #c47c3b; --seq-4: #f2a95e;
    --blu-0: #1a2431; --blu-1: #23405e; --blu-2: #2f5f8c; --blu-3: #4f86bd; --blu-4: #8fbbe6;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #10141a; --surface: #171c24; --surface-2: #1f2631; --ink: #e5e7ea; --muted: #9aa3ae; --line: #2d3541;
  --accent: #7eaedc; --accent-ink: #0e1620; --accent-soft: #1c2a3a; --teal: #6cc0ab;
  --ai: #e8b65a; --ai-bg: #2a2315; --ai-line: #8f6d26;
  --ok: #86c98a; --ok-bg: #1b2a1c; --rev: #e8b65a; --rev-bg: #2b2414; --pend: #9aa3ae; --pend-bg: #222832; --bad: #f08a80;
  --pos: #7eaedc; --neg: #f08a80;
  --seq-0: #2b2620; --seq-1: #5a4128; --seq-2: #8d5b2e; --seq-3: #c47c3b; --seq-4: #f2a95e;
  --blu-0: #1a2431; --blu-1: #23405e; --blu-2: #2f5f8c; --blu-3: #4f86bd; --blu-4: #8fbbe6;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 var(--sans);
  overflow-x: hidden;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.25; margin: 0 0 .5rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.08rem; }
p { margin: 0 0 .75rem; }
a { color: var(--accent); }
small, .muted { color: var(--muted); }
code, .mono { font-family: var(--mono); font-size: .86em; }
pre { overflow-wrap: anywhere; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Cabecera */
.top {
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 12px 16px 10px;
}
.top-in { max-width: 1180px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; }
.brand { display: flex; gap: 12px; align-items: center; min-width: 0; }
.brand-mark { flex: 0 0 auto; width: 38px; height: 38px; }
.brand-txt { min-width: 0; }
.brand-txt strong { display: block; font-family: var(--serif); font-size: 1.05rem; line-height: 1.2; }
.brand-txt span { display: block; color: var(--muted); font-size: .8rem; }
.top-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.top-tools label { font-size: .8rem; color: var(--muted); }
select, input[type="text"], input[type="search"], input[type="number"], textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px;
}
textarea { width: 100%; resize: vertical; min-height: 64px; line-height: 1.45; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px;
  padding: 6px 12px; font-size: .88rem; line-height: 1.3;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ai { border-color: var(--ai-line); color: var(--ai); background: var(--ai-bg); }
.btn.ok { border-color: var(--ok); color: var(--ok); }
.btn.bad { border-color: var(--bad); color: var(--bad); }
.btn.sm { padding: 3px 9px; font-size: .8rem; }
.btn-ico { width: 34px; height: 34px; padding: 0; justify-content: center; }

.banner {
  background: var(--ai-bg); border-bottom: 1px solid var(--ai-line); color: var(--ink);
  font-size: .82rem; padding: 7px 16px; text-align: center;
}

/* Navegación por módulos */
.tabs {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.tabs-in {
  max-width: 1180px; margin: 0 auto; display: flex; gap: 2px; overflow-x: auto; padding: 0 8px;
  scrollbar-width: thin;
}
.tabs a {
  flex: 0 0 auto; text-decoration: none; color: var(--muted); padding: 11px 12px 9px;
  border-bottom: 3px solid transparent; font-size: .88rem; white-space: nowrap;
}
.tabs a .n { font-family: var(--mono); font-size: .75rem; opacity: .7; margin-right: 4px; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 60px; }
section[hidden] { display: none !important; }
.lead { color: var(--muted); max-width: 70ch; }

.grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) {
  .g-2 { grid-template-columns: 1fr 1fr; }
  .g-3-2 { grid-template-columns: 3fr 2fr; }
  .g-2-3 { grid-template-columns: 2fr 3fr; }
}
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); min-width: 0;
}
.card > h3:first-child { margin-top: 0; }
.kicker { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.note {
  border-left: 3px solid var(--ai-line); background: var(--ai-bg); padding: 8px 12px; border-radius: 0 8px 8px 0;
  font-size: .86rem; margin: 0 0 14px;
}
.note.info { border-left-color: var(--accent); background: var(--accent-soft); }
blockquote {
  margin: 0; padding: 10px 14px; border-left: 3px solid var(--teal); background: var(--surface-2);
  border-radius: 0 8px 8px 0; font-family: var(--serif); font-size: 1rem;
}
blockquote cite { display: block; font-family: var(--sans); font-style: normal; font-size: .78rem; color: var(--muted); margin-top: 6px; }

/* Mundos / etapas */
.mundos { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1000px) { .mundos { grid-template-columns: repeat(3, 1fr); } }
.mundo { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.mundo-h { padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.mundo-h b { font-family: var(--serif); font-size: 1.02rem; }
.mundo-h small { display: block; }
.etapa { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.etapa:last-child { border-bottom: 0; }
.etapa-h { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; }
.etapa-h b { font-size: .92rem; }
.etapa .num { font-family: var(--mono); font-size: .75rem; color: var(--muted); }
.etapa .meta { font-size: .78rem; color: var(--muted); margin: 4px 0 6px; }
.etapa .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-block; font-size: .72rem; padding: 2px 8px; border-radius: 99px; white-space: nowrap; font-weight: 600;
}
.chip.aprobado { background: var(--ok-bg); color: var(--ok); }
.chip.revision { background: var(--rev-bg); color: var(--rev); }
.chip.pendiente { background: var(--pend-bg); color: var(--pend); }
.chip.ia { background: var(--ai-bg); color: var(--ai); border: 1px dashed var(--ai-line); }
.chip.hum { background: var(--accent-soft); color: var(--accent); }

.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 6px 0 2px; }
.progress > i { display: block; height: 100%; background: var(--ok); }

/* Tablas */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* CATWOE */
.catwoe { display: grid; gap: 10px; }
@media (min-width: 700px) { .catwoe { grid-template-columns: 1fr 1fr; } }
.cw label { display: flex; justify-content: space-between; gap: 6px; font-size: .82rem; font-weight: 600; margin-bottom: 3px; }
.cw label .l { font-family: var(--serif); font-size: 1.15rem; color: var(--accent); margin-right: 6px; }
.cw textarea.from-ai { border-color: var(--ai-line); }
.cw textarea.flash { animation: flash 1.2s ease; }
@keyframes flash { 0% { background: var(--ai-bg); } 100% { background: var(--surface); } }

/* Borrador IA (inline, nunca modal) */
.draft {
  margin-top: 12px; border: 1px dashed var(--ai-line); background: var(--ai-bg);
  border-radius: var(--radius); padding: 12px 14px;
}
.draft-h { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.draft-h strong { color: var(--ai); font-size: .86rem; }
.draft-meta { font-size: .75rem; color: var(--muted); font-family: var(--mono); }
.draft-body { font-size: .9rem; }
.draft-body [contenteditable="true"] { outline: 1px solid var(--ai-line); background: var(--surface); padding: 6px 8px; border-radius: 6px; }
.draft-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.draft.done { border-style: solid; opacity: .85; }
.draft details { margin-top: 8px; font-size: .78rem; }
.draft details pre { white-space: pre-wrap; background: var(--surface); border: 1px solid var(--line); padding: 8px; border-radius: 6px; font-size: .74rem; max-height: 220px; overflow: auto; }
.loading { display: inline-flex; gap: 8px; align-items: center; color: var(--ai); font-size: .86rem; }
.loading i { width: 14px; height: 14px; border: 2px solid var(--ai-line); border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sugg { display: grid; gap: 6px; }
.sugg dt { font-weight: 600; font-size: .82rem; color: var(--ai); }
.sugg dd { margin: 0 0 4px; }

/* SVG genérico */
svg { max-width: 100%; height: auto; display: block; }
.svg-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }
.svg-box svg text { fill: var(--ink); font-family: var(--sans); }

/* Rich picture */
.rp .actor circle { fill: var(--surface-2); stroke: var(--accent); stroke-width: 1.5; }
.rp .actor.crim circle { stroke: var(--bad); }
.rp .core ellipse { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2; }
.rp .rel { stroke: var(--muted); stroke-width: 1.3; fill: none; }
.rp .conf { stroke: var(--bad); stroke-width: 1.6; stroke-dasharray: 6 4; fill: none; }
.rp .bubble rect { fill: var(--surface); stroke: var(--line); }
.rp .bubble text { font-size: 11px; font-style: italic; fill: var(--muted); }
.rp .lbl { font-size: 12px; font-weight: 600; }
.rp .sub { font-size: 10px; fill: var(--muted) !important; }
.rp .rel-t { font-size: 10px; fill: var(--muted) !important; }
.rp .conf-t { font-size: 10px; fill: var(--bad) !important; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .78rem; color: var(--muted); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 22px; height: 0; border-top: 2px solid var(--muted); }
.sw.conf { border-top: 2px dashed var(--bad); }
.sw.pos { border-top-color: var(--pos); }
.sw.neg { border-top-color: var(--neg); }
.sw.ai { border-top: 2px dashed var(--ai); }
.box { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }

/* Diagrama causal */
.cld .node rect { fill: var(--surface); stroke: var(--line); stroke-width: 1.2; }
.cld .node.lever rect { fill: var(--accent-soft); stroke: var(--accent); }
.cld .node.ai rect { stroke: var(--ai); stroke-dasharray: 4 3; }
.cld .node text { font-size: 13px; font-weight: 600; }
.cld .edge path { fill: none; stroke-width: 1.6; }
.cld .edge.pos path { stroke: var(--pos); }
.cld .edge.neg path { stroke: var(--neg); }
.cld .edge.ai path { stroke-dasharray: 6 4; }
.cld .edge .pol { font-size: 15px; font-weight: 700; }
.cld .edge.pos .pol { fill: var(--pos) !important; }
.cld .edge.neg .pol { fill: var(--neg) !important; }
.cld .loop circle { fill: var(--surface); stroke: var(--muted); }
.cld .loop text { font-size: 12px; font-weight: 700; }
.cld.focus .edge { opacity: .12; }
.cld.focus .edge.hl { opacity: 1; }
.cld.focus .edge.hl path { stroke-width: 3; }
.cld.focus .node { opacity: .35; }
.cld.focus .node.hl { opacity: 1; }
.loops { display: grid; gap: 8px; }
@media (min-width: 800px) { .loops { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); } }
.loop-btn {
  text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 10px; cursor: pointer;
}
.loop-btn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.loop-btn b { font-family: var(--mono); margin-right: 6px; }
.loop-btn small { display: block; }

/* Simulación */
.ctrls { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
select { max-width: 100%; }
.ctrl label { display: flex; justify-content: space-between; font-size: .86rem; font-weight: 600; }
.ctrl output { font-family: var(--mono); color: var(--accent); }
.ctrl small { display: block; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 6px 10px; font-size: .82rem; cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--surface-2); border-radius: 8px; padding: 10px; }
.kpi .k { font-size: .74rem; color: var(--muted); }
.kpi .v { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .d { font-size: .78rem; font-variant-numeric: tabular-nums; }
.kpi .d.good { color: var(--ok); } .kpi .d.badd { color: var(--bad); }
.chart svg .grid line { stroke: var(--line); }
.chart svg .axis text { font-size: 11px; fill: var(--muted) !important; }
.chart svg .base { stroke: var(--muted); stroke-dasharray: 5 4; stroke-width: 2; fill: none; }
.chart svg .alt { stroke: var(--accent); stroke-width: 2.5; fill: none; }
.chart svg .start { stroke: var(--ai); stroke-dasharray: 2 3; }
.chart svg .cursor { stroke: var(--muted); }
.chart svg .tip rect { fill: var(--surface); stroke: var(--line); }
.chart svg .tip text { font-size: 11px; }
.sfd rect.stock { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.5; }
.sfd .flow { stroke: var(--muted); stroke-width: 3; fill: none; }
.sfd .link { stroke: var(--muted); stroke-width: 1; fill: none; stroke-dasharray: 3 3; }
.sfd .valve { fill: var(--surface); stroke: var(--muted); stroke-width: 1.5; }
.sfd .cloud { fill: var(--surface-2); stroke: var(--line); }
.sfd text { font-size: 11px; }
.sfd text.sl { font-weight: 700; font-size: 12px; }
.sfd text.fl { fill: var(--muted) !important; font-size: 10px; }

/* Mapa */
.map svg path.d { stroke: var(--surface); stroke-width: .7; cursor: pointer; }
.map svg path.d:hover { stroke: var(--ink); stroke-width: 1.2; }
.map svg path.d.sel { stroke: var(--ink); stroke-width: 2; }
.map svg text.ml { font-size: 9px; font-weight: 700; pointer-events: none; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
.scale { display: flex; gap: 0; margin-top: 6px; }
.scale span { flex: 1; height: 10px; }
.scale-l { display: flex; justify-content: space-between; font-size: .72rem; color: var(--muted); }
.dist-panel { font-size: .88rem; }
.dist-panel .big { font-size: 1.6rem; font-weight: 700; font-family: var(--serif); }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; min-width: 60px; }
.bar > i { display: block; height: 100%; background: var(--seq-3); }

/* Asistente documental */
.ask { display: flex; gap: 8px; }
.ask input { flex: 1; min-width: 0; padding: 9px 11px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chips button { border: 1px solid var(--line); background: var(--surface-2); border-radius: 99px; padding: 5px 11px; font-size: .8rem; cursor: pointer; text-align: left; }
.pipeline { display: flex; flex-wrap: wrap; gap: 6px; font-size: .76rem; margin: 6px 0 12px; }
.pipeline span { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; }
.pipeline span.on { border-color: var(--ai-line); background: var(--ai-bg); color: var(--ai); }
.cite { font-family: var(--mono); font-size: .75rem; color: var(--accent); vertical-align: super; }
.frag { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-top: 8px; background: var(--surface); font-size: .82rem; }
.frag .src { font-size: .74rem; color: var(--muted); margin-bottom: 4px; display: flex; justify-content: space-between; gap: 8px; }

/* Arquitectura */
.arch .lay { fill: var(--surface-2); stroke: var(--line); }
.arch .comp { fill: var(--surface); stroke: var(--accent); stroke-width: 1.3; }
.arch .comp.ai { stroke: var(--ai); stroke-dasharray: 5 3; fill: var(--ai-bg); }
.arch .comp.db { stroke: var(--teal); }
.arch .ext { fill: var(--surface); stroke: var(--muted); stroke-dasharray: 3 3; }
.arch text { font-size: 12px; }
.arch text.t { font-weight: 700; font-size: 12.5px; }
.arch text.s { fill: var(--muted) !important; font-size: 10.5px; }
.arch text.h { font-size: 10.5px; letter-spacing: .08em; font-weight: 700; fill: var(--muted) !important; }
.arch .arr { stroke: var(--muted); stroke-width: 1.4; fill: none; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 28px 1fr; gap: 8px; align-items: start; font-size: .88rem; }
.steps li::before { content: counter(s); width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; display: grid; place-items: center; font-size: .78rem; }
.steps li.hum::before { background: var(--ok-bg); color: var(--ok); }
.steps li.ia::before { background: var(--ai-bg); color: var(--ai); }

/* Bitácora */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
@media (min-width: 700px) { .stats { grid-template-columns: repeat(5, 1fr); } }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; }

footer { max-width: 1180px; margin: 0 auto; padding: 0 16px 40px; font-size: .78rem; color: var(--muted); }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.between { justify-content: space-between; }
.mt { margin-top: 14px; }
.toast-inline { font-size: .8rem; color: var(--ok); }

/* Diagrama de contexto (Etapa 4.1) */
.ctx .m rect { fill: var(--surface); stroke: var(--line); stroke-width: 1.3; }
.ctx .m.hl rect { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2; }
.ctx text.mn { font-size: 13px; font-weight: 600; }
.ctx text.el { font-size: 10.5px; fill: var(--muted) !important; }
.ctx .ln { stroke: var(--muted); stroke-width: 1.5; fill: none; }
.ctx .ln.neg { stroke: var(--neg); }
/* Marca de retardo en diagramas causales */
.cld .edge line.dly { stroke: var(--ink); stroke-width: 2; }
/* Auxiliares en el diagrama de Forrester */
.sfd .auxc { fill: var(--surface); stroke: var(--accent); stroke-width: 1.5; }
/* Candidatos de IA (Etapa 3) */
.cand { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 8px; font-size: .88rem; }
.cand input { margin-top: 4px; }
/* Componente opcional en arquitectura */
.arch .comp.opt { stroke-dasharray: 6 4; }

/* IB&PTA · Consenso (Módulo 2b) */
:root { --on-0: #e98a80; --on-1: #f4b77c; --on-2: #f3dc86; --on-3: #b5d99c; --on-4: #a9cbe8; --on-stroke: rgba(27,35,48,.35); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --on-0: #8e3a33; --on-1: #8a5524; --on-2: #756628; --on-3: #3f6a3a; --on-4: #2c4f74; --on-stroke: rgba(229,231,234,.3); }
}
:root[data-theme="dark"] { --on-0: #8e3a33; --on-1: #8a5524; --on-2: #756628; --on-3: #3f6a3a; --on-4: #2c4f74; --on-stroke: rgba(229,231,234,.3); }
.ib-ident { display: flex; flex-wrap: wrap; gap: 6px; }
.ib-st { border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); border-radius: 99px; padding: 4px 10px; font-size: .78rem; cursor: pointer; text-align: left; }
.ib-st[aria-pressed="true"] { background: var(--accent-soft); color: var(--ink); border-color: var(--accent); font-weight: 600; }
.ib-st.nh { border-style: dashed; }
.ib-st .chip { font-size: .64rem; padding: 1px 6px; margin-left: 2px; }
.ib-st:disabled { cursor: default; }
.ib-cadenas { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .ib-cadenas { grid-template-columns: 1fr 1fr; align-items: start; } }
.ib-chain { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; background: var(--surface); }
.ib-chain > summary { cursor: pointer; display: flex; gap: 8px; justify-content: space-between; align-items: center; list-style: none; }
.ib-chain > summary::-webkit-details-marker { display: none; }
.ib-chain > summary::before { content: "▸"; color: var(--muted); margin-right: 2px; }
.ib-chain[open] > summary::before { content: "▾"; }
.ib-sum { flex: 1; min-width: 0; font-size: .9rem; }
.ib-links { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 7px; }
.ib-links > li { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 8px; font-size: .84rem; align-items: start; }
.ib-k { font-family: var(--serif); font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 6px; text-align: center; padding: 1px 0; font-size: .82rem; }
.ib-links .pend { color: var(--rev); font-style: italic; font-size: .82rem; }
.ib-txt[contenteditable="true"] { border-bottom: 1px dashed var(--line); outline: none; }
.ib-txt[contenteditable="true"]:focus { border-bottom-color: var(--accent); background: var(--accent-soft); }
.ib-cw { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 4px; font-size: .76rem; color: var(--muted); }
.ib-cw b { color: var(--accent); }
.ib-cm { margin: 2px 0 0; padding-left: 0; list-style: none; }
.ib-cm li { margin-bottom: 2px; }
.ib-cm .mono { color: var(--muted); font-size: .72rem; }
.ib-cols { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 700px) { .ib-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .ib-cols { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.ib-col { background: var(--surface-2); border-radius: 8px; padding: 8px; }
.ib-col-h { font-family: var(--serif); font-weight: 700; margin-bottom: 6px; }
.ib-task, .ib-grp { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; font-size: .78rem; margin-bottom: 5px; line-height: 1.35; }
.ib-grp { border-color: var(--ok); }
.ib-prop { display: flex; flex-wrap: wrap; gap: 6px 12px; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--ai-line); }
.ib-prop .draft-acts { margin-top: 0; }
.onion { width: 100%; height: auto; display: block; }
.onion .on-l { stroke: var(--on-stroke); stroke-width: 1.5; }
.on-0 { fill: var(--on-0); background: var(--on-0); } .on-1 { fill: var(--on-1); background: var(--on-1); } .on-2 { fill: var(--on-2); background: var(--on-2); }
.on-3 { fill: var(--on-3); background: var(--on-3); } .on-4 { fill: var(--on-4); background: var(--on-4); }
.onion .on-b circle { fill: var(--surface); stroke: var(--ink); stroke-width: 1.5; }
.onion .on-b text { font-size: 17px; font-weight: 700; fill: var(--ink); }
.onion .on-b.hl circle { stroke: var(--bad); stroke-width: 4; }
.onion .on-fact { fill: var(--surface); stroke: var(--muted); stroke-width: 1.5; }
.onion .on-ft { font-size: 17px; font-weight: 600; fill: var(--ink); }
.onion .on-arr { stroke: var(--muted); stroke-width: 1.8; }
.onion .on-arrh { fill: var(--muted); }
.onion .on-call { fill: none; stroke: var(--bad); stroke-width: 2; stroke-dasharray: 5 4; }
.onion .on-relbox { fill: var(--surface); stroke: var(--bad); stroke-width: 2; }
.onion .on-rel { font-size: 17px; font-weight: 700; fill: var(--bad); }
.on-list { font-size: .82rem; }
.on-cap { margin-bottom: 8px; }
.on-cap-h { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.on-sw { width: 14px; height: 14px; border-radius: 4px; display: inline-block; border: 1px solid var(--on-stroke); }
.on-cap ol { margin: 2px 0 0; padding-left: 26px; }
.on-cap li.hl { font-weight: 700; }

/* Escenarios anidados (Módulo 4) */
.nest svg { width: 100%; max-width: 420px; height: auto; display: block; margin: 0 auto; }
.nest circle { stroke: var(--line); stroke-width: 1.5; cursor: pointer; }
.nest circle.n0 { fill: var(--blu-3); } .nest circle.n1 { fill: var(--blu-2); } .nest circle.n2 { fill: var(--blu-1); } .nest circle.n3 { fill: var(--blu-0); }
.nest circle.sel { stroke: var(--ai); stroke-width: 4; }
.nest circle:hover { stroke: var(--accent); stroke-width: 3; }
.nest text { font-size: 15px; font-weight: 700; fill: var(--ink); pointer-events: none; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
.nest text.sm { font-size: 11px; font-weight: 600; }
.pol-list { margin: 6px 0 0; padding-left: 22px; font-size: .86rem; }
.pol-list li { margin-bottom: 4px; }

/* ================= App (prototipo con API) ================= */
:root { --c0: #1d4a73; --c1: #c0582b; --c2: #2a7a62; --c3: #7a4fa0; --band: rgba(29, 74, 115, .13); --pin: #a3261d; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --c0: #7eaedc; --c1: #f2a05e; --c2: #6cc0ab; --c3: #c3a3ea; --band: rgba(126, 174, 220, .18); --pin: #f08a80; } }
:root[data-theme="dark"] { --c0: #7eaedc; --c1: #f2a05e; --c2: #6cc0ab; --c3: #c3a3ea; --band: rgba(126, 174, 220, .18); --pin: #f08a80; }

/* visibilidad por modo y rol */
.mode-online .demo-only, .mode-demo .online-only { display: none !important; }
body:not(.rol-rt) .solo-rt, body:not(.rol-rt) .solo-rt-btn { display: none !important; }
body.ro .needs-edit, body.ro .needs-edit-form, body.ro .needs-edit-block { display: none !important; }
[hidden] { display: none !important; }
.grow { flex: 1 1 200px; min-width: 0; }

.boot { text-align: center; color: var(--muted); padding: 40px 16px; }
.demo-badge { background: var(--ai-bg); color: var(--ai); border: 1px solid var(--ai-line); }
.user-chip { display: inline-flex; flex-direction: column; line-height: 1.15; font-size: .8rem; padding: 2px 10px; border-left: 3px solid var(--accent); }
.user-chip b { font-weight: 600; max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip small { color: var(--muted); }

/* login */
.login { padding: 28px 16px 40px; display: flex; justify-content: center; }
.login-card { width: 100%; max-width: 420px; display: grid; gap: 12px; }
.fld { display: grid; gap: 4px; font-size: .84rem; font-weight: 600; }
.fld input, .fld select, .fld textarea { font-weight: 400; width: 100%; }
.fld.sm { font-size: .78rem; }
input[type="email"], input[type="password"] { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; font-size: 16px; }
.btn.wide { width: 100%; justify-content: center; padding: 10px 12px; }
.login-demo .row { margin-top: 6px; }
.login-demo .btn { font-family: var(--mono); font-size: .72rem; }

/* mensajes inline */
.errbar-wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.msg { margin-top: 10px; padding: 8px 12px; border-radius: 8px; font-size: .86rem; border: 1px solid; }
.msg.err { color: var(--bad); border-color: var(--bad); background: var(--surface); }
.msg.ok { color: var(--ok); border-color: var(--ok); background: var(--ok-bg); }
.msg.info { color: var(--ink); border-color: var(--accent); background: var(--accent-soft); }
#errBar .msg { margin: 10px 0 0; }
.btn.is-busy { opacity: .6; cursor: progress; }
.btn.xs { padding: 0 7px; font-size: .78rem; line-height: 1.5; }
.flash-row { animation: flashrow 1.4s ease; }
@keyframes flashrow { 0% { background: var(--ai-bg); } 100% { background: transparent; } }
.empty-li { list-style: none; }
.hint { font-size: .8rem; margin: 6px 0 0; }
.hint.on { color: var(--ai); font-weight: 600; }

/* tablero de etapas */
.sboard { width: 100%; }
.sboard .lane { fill: var(--surface-2); stroke: var(--line); }
.sboard .ln { font-size: 11px; font-weight: 700; fill: var(--muted) !important; letter-spacing: .04em; }
.sboard .seq { stroke: var(--muted); stroke-width: 1.5; }
.sboard .ret { stroke: var(--ai); stroke-width: 1.5; stroke-dasharray: 5 4; fill: none; }
.sboard .arrh { fill: var(--muted); }
.sboard .st { cursor: pointer; }
.sboard .st circle { stroke-width: 2; }
.sboard .st.aprobado circle { fill: var(--ok-bg); stroke: var(--ok); }
.sboard .st.revision circle { fill: var(--rev-bg); stroke: var(--rev); }
.sboard .st.pendiente circle { fill: var(--surface); stroke: var(--line); }
.sboard .st:hover circle, .sboard .st:focus circle { stroke-width: 3.5; }
.sboard .st:focus { outline: none; }
.sboard .n { font-weight: 700; font-size: 15px; }
.sboard .lb { font-size: 10px; fill: var(--muted) !important; }
.dot-l { display: inline-block; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--line); }
.dot-l.aprobado { background: var(--ok-bg); border-color: var(--ok); } .dot-l.revision { background: var(--rev-bg); border-color: var(--rev); } .dot-l.pendiente { background: var(--surface); }
.dot-l.act { background: var(--accent); border-color: var(--accent); } .dot-l.dec { background: var(--ok); border-color: var(--ok); } .dot-l.ia { background: var(--ai); border-color: var(--ai); } .dot-l.cfg { background: var(--bad); border-color: var(--bad); }

/* rich picture */
.rp-box svg { width: 100%; }
.rp.pinning { cursor: crosshair; outline: 2px dashed var(--ai-line); outline-offset: 2px; }
.rp .pin circle { fill: var(--pin); stroke: var(--surface); stroke-width: 2; cursor: pointer; }
.rp .pin line { stroke: var(--pin); stroke-width: 1.5; }
.rp .pin .pn { fill: #fff !important; font-size: 13px; font-weight: 700; pointer-events: none; }
.rp .pin .pt { font-size: 19px; font-weight: 600; fill: var(--ink); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; pointer-events: none; }
.rp-list { margin: 6px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.rp-list li { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 8px; align-items: start; font-size: .86rem; border-bottom: 1px solid var(--line); padding: 4px 0 6px; border-radius: 6px; }
.rp-n { width: 22px; height: 22px; border-radius: 50%; background: var(--pin); color: #fff; display: grid; place-items: center; font-size: .72rem; font-weight: 700; }
.rp-t[contenteditable="true"] { outline: none; border-bottom: 1px dashed var(--line); }
.rp-t[contenteditable="true"]:focus { background: var(--accent-soft); border-bottom-color: var(--accent); }
.pin-l { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--pin); }

/* IB&PTA */
.ib-txt.is-empty::before { content: attr(data-ph); color: var(--rev); font-style: italic; }
.ib-txt[contenteditable="true"]:focus.is-empty::before { content: ""; }
.ib-cwg { display: grid; gap: 4px 10px; grid-template-columns: minmax(0, 1fr); margin-top: 6px; font-size: .78rem; }
@media (min-width: 560px) { .ib-cwg { grid-template-columns: 1fr 1fr; } }
.ib-cwg > div { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 6px; }
.ib-cwg b { color: var(--accent); font-family: var(--serif); }
.ib-cm li { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: baseline; margin-bottom: 4px; }
.ib-cm li .ib-txt { flex: 1 1 160px; min-width: 0; }
.ib-cm .vsel { font-size: .74rem; padding: 1px 4px; }
.ib-addt { margin-top: 6px; }
.ib-addt input { flex: 1 1 160px; min-width: 0; }
.chain-msg .msg { margin-top: 6px; padding: 4px 8px; font-size: .78rem; }
.vm-wrap { overflow-x: auto; }
.vmatrix { width: 100%; }
.vmatrix .vh { font-size: 11px; font-weight: 700; fill: var(--ink); }
.vmatrix .rl { font-size: 11px; fill: var(--ink); }
.vmatrix .b { font-weight: 700; }
.vmatrix .cv { font-size: 11px; font-weight: 700; fill: var(--ink); pointer-events: none; }
.vmatrix .cell { stroke: var(--line); }
.vmatrix .c0 { fill: var(--surface); } .vmatrix .c1 { fill: var(--blu-1); } .vmatrix .c2 { fill: var(--blu-2); } .vmatrix .c3 { fill: var(--blu-3); }
.dec-list { margin: 4px 0 0; padding-left: 18px; font-size: .82rem; }
.dec-list li { margin-bottom: 3px; }
.onion .on-b.ag circle { stroke: var(--ok); stroke-width: 3; }
.on-cap li { margin-bottom: 3px; }
.on-cap li .mv { font-size: .72rem; padding: 0 3px; max-width: 120px; }
.on-t[contenteditable="true"], .on-f[contenteditable="true"] { outline: none; border-bottom: 1px dashed var(--line); }
.on-t[contenteditable="true"]:focus, .on-f[contenteditable="true"]:focus { background: var(--accent-soft); }
.on-fact-list { margin: 4px 0 0; padding-left: 18px; font-size: .82rem; }
.on-fact-list li { margin-bottom: 3px; }
#onRel, #onFromG { max-width: 260px; }

/* causal: lazos R/B */
.cld .loop.lr circle { stroke: var(--rev); stroke-width: 2; }
.cld .loop.lb circle { stroke: var(--ok); stroke-width: 2; }
.cld .loop.on circle { fill: var(--accent-soft); stroke-width: 4; }
.cld .loop:focus { outline: none; }
.loop-btn.lr { border-left: 4px solid var(--rev); } .loop-btn.lb { border-left: 4px solid var(--ok); }

/* simulación */
.chip.motor { font-size: .76rem; }
.chip.motor.propio { background: var(--accent-soft); color: var(--accent); }
.chip.motor.stella { background: var(--rev-bg); color: var(--rev); }
#modelSel { max-width: 100%; flex: 1 1 220px; }
.warn-row td { color: var(--rev); }
.warn-list { margin: 8px 0 0; padding-left: 18px; font-size: .82rem; color: var(--rev); }
.series .run { fill: none; stroke-width: 2.4; }
.series .run.r0, .series .dot.r0 { stroke: var(--c0); fill-opacity: 0; } .series .run.r1, .series .dot.r1 { stroke: var(--c1); }
.series .run.r2, .series .dot.r2 { stroke: var(--c2); } .series .run.r3, .series .dot.r3 { stroke: var(--c3); }
.series .run.r1 { stroke-dasharray: 7 4; } .series .run.r3 { stroke-dasharray: 2 3; }
.series .dot.r0 { fill: var(--c0); fill-opacity: 1; } .series .dot.r1 { fill: var(--c1); } .series .dot.r2 { fill: var(--c2); } .series .dot.r3 { fill: var(--c3); }
.series .band { fill: var(--band); stroke: none; }
.series .tip text { font-size: 11px; }
.sw-run { display: inline-block; width: 18px; height: 0; border-top: 3px solid var(--c0); margin-right: 6px; vertical-align: middle; }
.sw-run.r1 { border-top: 3px dashed var(--c1); } .sw-run.r2 { border-top-color: var(--c2); } .sw-run.r3 { border-top: 3px dotted var(--c3); }
.sw-band { display: inline-block; width: 18px; height: 10px; background: var(--band); border: 1px solid var(--line); }
.run-tbl td, .run-tbl th { padding: 5px 6px; }
.esc-form { margin-top: 10px; }
#escNew > summary { list-style: none; display: inline-flex; }
#escNew > summary::-webkit-details-marker { display: none; }
@media (min-width: 700px) { .ctrls.two { grid-template-columns: 1fr 1fr; } }
.nest circle.n4 { fill: var(--blu-4); }
.nest .btn { font-size: .78rem; }

/* bitácora */
.tline { width: 100%; }
.tline .lane { stroke: var(--line); }
.tline .ll { font-size: 11px; fill: var(--muted) !important; }
.tline .tk { font-size: 10px; fill: var(--muted) !important; }
.tline .ev { stroke: var(--surface); stroke-width: 1.5; cursor: pointer; opacity: .9; }
.tline .ev.act { fill: var(--accent); } .tline .ev.dec { fill: var(--ok); } .tline .ev.ia { fill: var(--ai); } .tline .ev.cfg { fill: var(--bad); }
.tline .ev:hover { stroke: var(--ink); }
.log-tbl td small { overflow-wrap: anywhere; }

/* asistente */
.answer p { margin: 4px 0 0; }

/* ajustes */
.opt-list { display: grid; gap: 8px; }
.opt { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; align-items: start; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer; font-size: .88rem; }
.opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.opt small { display: block; color: var(--muted); }
.opt input { margin-top: 4px; }

@media (max-width: 520px) {
  .top-tools { width: 100%; }
  .user-chip { flex: 1 1 auto; }
  .tabs a { padding: 10px 9px 8px; font-size: .84rem; }
  main { padding: 16px 16px 48px; }
  h2 { font-size: 1.28rem; }
}

#ibNewName { flex: 1 1 220px; min-width: 0; }
.on-cap ol { padding-left: 0; list-style: none; }
.on-cap li { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: baseline; }
.on-num { min-width: 22px; text-align: right; }
.on-cap li .on-t { flex: 1 1 180px; min-width: 0; }
