/* Sistema visual compartido — Venta de desarrollo con IA */
:root {
  color-scheme: light;
  --bg: #F4F6F8; --surface: #FFFFFF; --surface-2: #EAEEF2;
  --ink: #14202E; --ink-2: #4A5866; --muted: #7C8896; --line: #DCE2E8;
  --accent: #0B7A75; --accent-ink: #085E5A; --accent-soft: #DDF0EE;
  --amber: #9A6400; --amber-soft: #FFF3D6;
  --good: #0B7A3B; --warn: #A84B00; --bad: #B4232A;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7;
  --grid: #E1E5EA;
  --font-display: "Bricolage Grotesque", "Source Sans 3", system-ui, sans-serif;
  --font-body: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 6px; --gutter: clamp(16px, 4vw, 40px); --maxw: 1180px;
  --shadow: 0 1px 2px rgba(20,32,46,.06), 0 4px 16px rgba(20,32,46,.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0F1720; --surface: #161F2A; --surface-2: #1E2935;
    --ink: #E8EEF3; --ink-2: #B4C0CB; --muted: #8391A0; --line: #26323F;
    --accent: #3FB8B2; --accent-ink: #6ED0CB; --accent-soft: #143634;
    --amber: #F2C14E; --amber-soft: #3A2E10;
    --good: #4CC56E; --warn: #F0A050; --bad: #F07078;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9;
    --grid: #26323F; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0F1720; --surface: #161F2A; --surface-2: #1E2935;
  --ink: #E8EEF3; --ink-2: #B4C0CB; --muted: #8391A0; --line: #26323F;
  --accent: #3FB8B2; --accent-ink: #6ED0CB; --accent-soft: #143634;
  --amber: #F2C14E; --amber-soft: #3A2E10;
  --good: #4CC56E; --warn: #F0A050; --bad: #F07078;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9;
  --grid: #26323F; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { transition: none !important; animation: none !important; } }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 17px; line-height: 1.55; }
img { max-width: 100%; }
a { color: var(--accent-ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.15; text-wrap: balance; margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 4.5vw, 3.2rem); font-weight: 700; }
h2 { font-size: clamp(1.5rem, 2.6vw, 2rem); }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.05rem; }
p { margin: 0; }
p + p { margin-top: .9em; }
.lead { font-size: 1.2rem; color: var(--ink-2); max-width: 62ch; }
.eyebrow { font-family: var(--font-mono); font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: var(--accent-ink); }
.muted { color: var(--muted); }
.small { font-size: .92rem; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
code { font-family: var(--font-mono); font-size: .9em; background: var(--surface-2); padding: .1em .35em; border-radius: 4px; }

.wrap { max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }

/* Barra de navegación */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar .wrap { display: flex; align-items: center; gap: 1.5rem; min-height: 56px; flex-wrap: wrap; padding-block: .4rem; }
.brand { font-family: var(--font-display); font-weight: 700; text-decoration: none; color: var(--ink); display: inline-flex; align-items: center; gap: .55rem; }
.brand .mark { width: 22px; height: 22px; border-radius: 5px; background: var(--accent); display: inline-block; position: relative; }
.brand .mark::after { content: ""; position: absolute; inset: 5px 5px 5px 11px; background: var(--amber); border-radius: 2px; }
.topnav { display: flex; gap: .25rem; flex-wrap: wrap; margin-left: auto; }
.topnav a { text-decoration: none; color: var(--ink-2); padding: .35rem .7rem; border-radius: var(--radius); font-weight: 500; font-size: .98rem; }
.topnav a:hover { background: var(--surface-2); color: var(--ink); }
.topnav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); }

/* Secciones */
.hero { padding-block: clamp(2.5rem, 7vw, 5rem) clamp(2rem, 5vw, 3.5rem); display: grid; gap: 1.2rem; }
.hero .lead { margin-top: .4rem; }
section.block { padding-block: clamp(2rem, 5vw, 3.5rem); border-top: 1px solid var(--line); }
section.block > .wrap > h2 { margin-bottom: 1rem; }
.stack { display: grid; gap: 1rem; }
.stack-lg { display: grid; gap: 1.75rem; }
.prose { max-width: 68ch; }
.prose > * + * { margin-top: 1rem; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li + li { margin-top: .4rem; }
.two-col { display: grid; gap: 2rem; grid-template-columns: 1fr; }
@media (min-width: 900px) { .two-col { grid-template-columns: 1fr 1fr; } }
.grid-3 { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.card h3 { margin-bottom: .5rem; }
.callout { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: 1rem 1.2rem; border-radius: 0 var(--radius) var(--radius) 0; }
.callout.amber { border-color: var(--amber); background: var(--amber-soft); }
.callout strong { color: var(--ink); }
.pill { display: inline-block; font-family: var(--font-mono); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; padding: .15rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }
.pill.ok { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); }
.pill.warn { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.pill.bad { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }

/* Tablas */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--ink-2); font-size: .85rem; letter-spacing: .02em; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 600; background: var(--surface-2); }

/* Botones y controles */
.btn { display: inline-flex; align-items: center; gap: .5rem; padding: .6rem 1.1rem; border-radius: var(--radius); border: 1px solid var(--accent); background: var(--accent); color: #fff; font-weight: 600; font-family: var(--font-body); font-size: 1rem; cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.07); color: #fff; }
.btn.ghost { background: transparent; color: var(--accent-ink); }
.btn.ghost:hover { background: var(--accent-soft); color: var(--accent-ink); }
.btn.sm { padding: .35rem .7rem; font-size: .9rem; }
label { font-weight: 600; font-size: .9rem; color: var(--ink-2); }
input[type=number], input[type=text], select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .45rem .6rem; width: 100%; }
input[type=number] { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.field { display: grid; gap: .3rem; align-content: start; }
.field .hint { font-size: .8rem; color: var(--muted); font-weight: 400; }
.check { display: flex; gap: .6rem; align-items: flex-start; font-weight: 500; color: var(--ink); }
.check input { margin-top: .3rem; accent-color: var(--accent); }
.check .hint { display: block; font-size: .85rem; color: var(--muted); font-weight: 400; }

/* Índice lateral */
.with-toc { display: grid; gap: 2.5rem; grid-template-columns: 1fr; }
@media (min-width: 980px) { .with-toc { grid-template-columns: 230px minmax(0, 1fr); } .toc { position: sticky; top: calc(64px + env(safe-area-inset-top, 0px)); align-self: start; } }
.toc { font-size: .92rem; }
.toc ol { list-style: none; padding: 0; margin: 0; display: grid; gap: .2rem; border-left: 1px solid var(--line); }
.toc a { display: block; padding: .3rem .8rem; color: var(--ink-2); text-decoration: none; border-left: 2px solid transparent; margin-left: -1px; }
.toc a:hover, .toc a.active { color: var(--accent-ink); border-left-color: var(--accent); }
.toc .eyebrow { display: block; margin-bottom: .6rem; }
.chapter { padding-block: 1.5rem 2.5rem; border-bottom: 1px solid var(--line); scroll-margin-top: 80px; }
.chapter:last-child { border-bottom: 0; }
.chapter h2 { margin-bottom: .75rem; }
.chapter h3 { margin-top: 1.75rem; margin-bottom: .5rem; }
.chapter .eyebrow { display: block; margin-bottom: .4rem; }

/* Cifras */
.stat { display: grid; gap: .15rem; }
.stat .label { font-size: .85rem; color: var(--muted); }
.stat .value { font-family: var(--font-display); font-size: 1.9rem; font-weight: 700; letter-spacing: -0.01em; }
.stat .value.amber { color: var(--amber); }
.stat .sub { font-size: .85rem; color: var(--ink-2); }

/* Pie */
footer.site { border-top: 1px solid var(--line); padding-block: 2rem 3rem; color: var(--muted); font-size: .9rem; }
footer.site .wrap { display: flex; flex-wrap: wrap; gap: 1rem 2rem; justify-content: space-between; }
.print-only { display: none; }
@media print {
  .topbar, .toc, .no-print, footer.site { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .print-only { display: block; }
  .chapter { break-inside: avoid; }
}
