/* Pruebas diagnósticas — estilos comunes (claro / oscuro) */
:root {
  --bg: #f6f7fb; --card: #ffffff; --ink: #1b2233; --muted: #5d6679; --line: #dde1ea; --soft: #eef1f7;
  --acc: #2952cc; --acc-ink: #ffffff; --acc-soft: #e5ecff;
  --ok: #1f8a4c; --ok-soft: #e2f4ea; --warn: #b36b00; --warn-soft: #fff1d6; --bad: #c0352b; --bad-soft: #fde6e3;
  --fa: #2952cc; --fb: #d0571b; --fc: #1f8a4c; --grid: #e3e7ef; --water: #cfe4ff; --water-line: #5b8fd6; --obj: #eef1f7;
  --n-fortaleza: #1f8a4c; --n-aceptable: #6a9f2a; --n-desarrollo: #d08a00; --n-critico: #c0352b;
  --radius: 12px; --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 4px 16px rgba(20, 30, 60, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11151f; --card: #1a202d; --ink: #e8ecf5; --muted: #a2abbd; --line: #2d3546; --soft: #222a39;
    --acc: #7c9cff; --acc-ink: #0d1220; --acc-soft: #22305a;
    --ok: #53c486; --ok-soft: #173326; --warn: #f0b04a; --warn-soft: #3a2c12; --bad: #ff7b6e; --bad-soft: #3d1c1a;
    --fa: #86a5ff; --fb: #ff9a62; --fc: #5fd394; --grid: #2a3242; --water: #1d3657; --water-line: #6fa3ea; --obj: #2a3243;
    --n-fortaleza: #53c486; --n-aceptable: #a5cf55; --n-desarrollo: #f0b04a; --n-critico: #ff7b6e;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11151f; --card: #1a202d; --ink: #e8ecf5; --muted: #a2abbd; --line: #2d3546; --soft: #222a39;
  --acc: #7c9cff; --acc-ink: #0d1220; --acc-soft: #22305a;
  --ok: #53c486; --ok-soft: #173326; --warn: #f0b04a; --warn-soft: #3a2c12; --bad: #ff7b6e; --bad-soft: #3d1c1a;
  --fa: #86a5ff; --fb: #ff9a62; --fc: #5fd394; --grid: #2a3242; --water: #1d3657; --water-line: #6fa3ea; --obj: #2a3243;
  --n-fortaleza: #53c486; --n-aceptable: #a5cf55; --n-desarrollo: #f0b04a; --n-critico: #ff7b6e;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--acc); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 560px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.hidden { display: none !important; }

/* Barra superior */
.top { background: var(--card); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; gap: 12px; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.brand .logo { width: 28px; height: 28px; border-radius: 8px; background: var(--acc); color: var(--acc-ink); display: grid; place-items: center; font-size: 15px; }

/* Botones y formularios */
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 10px; padding: 9px 16px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; min-height: 42px; }
button:hover, .btn:hover { border-color: var(--acc); }
button:disabled { opacity: .5; cursor: not-allowed; }
.primary { background: var(--acc); color: var(--acc-ink); border-color: var(--acc); font-weight: 600; }
.danger { color: var(--bad); border-color: var(--bad); }
.danger.solid { background: var(--bad); color: #fff; }
.ghost { background: transparent; }
.sm { padding: 5px 10px; min-height: 32px; font-size: .875rem; }
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  font: inherit; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink);
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 3px solid var(--acc-soft); border-color: var(--acc); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 4px; width: 18px; height: 18px; flex: none; }
.code-input { font-size: 1.6rem; letter-spacing: .18em; text-align: center; text-transform: uppercase; font-family: Consolas, "Courier New", monospace; }

/* Chips y estados */
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--soft); color: var(--muted); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.acc { background: var(--acc-soft); color: var(--acc); }
.n-fortaleza { --nc: var(--n-fortaleza); } .n-aceptable { --nc: var(--n-aceptable); } .n-desarrollo { --nc: var(--n-desarrollo); } .n-critico { --nc: var(--n-critico); }
.nivel { color: var(--nc); font-weight: 700; }
.bar { height: 10px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--nc, var(--acc)); border-radius: 99px; }
.notice { border-radius: 10px; padding: 12px 14px; background: var(--acc-soft); }
.notice.warn { background: var(--warn-soft); }
.notice.bad { background: var(--bad-soft); }
.notice.ok { background: var(--ok-soft); }

/* Tablas */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: var(--soft); position: sticky; top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Indicadores */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.tile .v { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile .k { font-size: .8rem; color: var(--muted); }

/* Modal y avisos (los diálogos nativos están bloqueados en algunos navegadores) */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 15, 30, .55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--card); border-radius: var(--radius); max-width: 520px; width: 100%; padding: 22px; box-shadow: var(--shadow); max-height: 90vh; overflow: auto; }
.modal.wide { max-width: 900px; }
.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 10px; z-index: 60; max-width: calc(100% - 32px); }
.toast.err { background: var(--bad); color: #fff; }

/* Matrices dentro de los enunciados */
table.mat { display: inline-table; width: auto; border-collapse: separate; border-spacing: 0; vertical-align: middle; margin: 2px 4px;
  border-left: 2px solid currentColor; border-right: 2px solid currentColor; border-radius: 7px; font-size: inherit; }
table.mat td { border: 0; padding: 1px 7px; text-align: center; font-variant-numeric: tabular-nums; }

/* Figuras SVG */
.fig { margin: 12px 0; text-align: center; }
.fig svg { width: 100%; max-width: 420px; height: auto; color: var(--ink); }
.fig .l { stroke: currentColor; stroke-width: 2; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.fig .lt { stroke: var(--muted); stroke-width: 1.2; fill: none; }
.fig .lw { stroke: currentColor; stroke-width: 4; }
.fig .lc { stroke: currentColor; stroke-width: 2; fill: none; }
.fig .g { stroke: var(--grid); stroke-width: 1; }
.fig .d { stroke: var(--muted); stroke-width: 1.4; stroke-dasharray: 5 4; fill: none; }
.fig .fa { stroke: var(--fa); fill: var(--fa); stroke-width: 2.4; }
.fig .fb { stroke: var(--fb); fill: var(--fb); stroke-width: 2.4; }
.fig .fc { stroke: var(--fc); fill: var(--fc); stroke-width: 2.4; }
.fig .ln { fill: none; stroke-width: 3; stroke-linejoin: round; }
.fig .ar { fill: none; }
.fig .s1 { fill: var(--obj); stroke: currentColor; stroke-width: 1.6; }
.fig .inc { fill: var(--obj); stroke: currentColor; stroke-width: 1.6; }
.fig .b1 { fill: var(--fb); stroke: currentColor; stroke-width: 1.2; }
.fig .b2 { fill: var(--fa); stroke: currentColor; stroke-width: 1.2; }
.fig .b1r { fill: var(--fb); fill-opacity: .25; stroke: currentColor; stroke-width: 1.6; }
.fig .b2r { fill: var(--fa); fill-opacity: .2; stroke: currentColor; stroke-width: 1.6; }
.fig .wh { fill: var(--card); stroke: currentColor; stroke-width: 2; }
.fig .w { fill: var(--water); stroke: none; }
.fig .wl { stroke: var(--water-line); stroke-width: 2; }
.fig .ice { fill: var(--water); fill-opacity: .6; stroke: var(--water-line); }
.fig .sh { fill: var(--fa); fill-opacity: .18; stroke: none; }
.fig .dot { fill: currentColor; stroke: none; }
.fig .cab { fill: none; stroke: currentColor; stroke-width: 2.4; }
.fig .wall { fill: var(--obj); stroke: currentColor; stroke-width: 1.6; }
.fig .mir { fill: var(--water-line); stroke: currentColor; stroke-width: 1; }
.fig .lens { fill: var(--water); stroke: var(--water-line); stroke-width: 2; }
.fig .bulb { fill: #ffe9a8; stroke: currentColor; stroke-width: 1.6; }
.fig .qp { fill: var(--bad-soft); stroke: var(--bad); stroke-width: 2; }
.fig .qn { fill: var(--acc-soft); stroke: var(--fa); stroke-width: 2; }
.fig .gauss { fill: var(--fa); fill-opacity: .06; stroke: var(--fa); stroke-width: 2; stroke-dasharray: 7 5; }
.fig .cel0 { fill: var(--card); stroke: currentColor; stroke-width: 1.4; }
.fig .cel1 { fill: var(--fa); fill-opacity: .28; stroke: currentColor; stroke-width: 1.4; }
.fig .cel2 { fill: var(--fb); fill-opacity: .28; stroke: currentColor; stroke-width: 1.4; }
.fig .hueco { fill: none; stroke: currentColor; stroke-width: 1.4; stroke-dasharray: 5 4; }
.fig .pfill { fill: var(--fa); stroke: var(--fa); stroke-width: 2; }
.fig .phueco { fill: var(--card); stroke: var(--fa); stroke-width: 2.4; }
.fig .ejes { stroke: currentColor; fill: currentColor; stroke-width: 1.4; }
.fig .curva { fill: none; stroke: var(--fa); stroke-width: 3; }
.fig .recto { fill: none; stroke: currentColor; stroke-width: 1.2; }
.fig .arco-a { fill: none; stroke: var(--fa); stroke-width: 2.4; }
.fig .arco-b { fill: none; stroke: var(--fb); stroke-width: 2.4; }
.fig .tronco { fill: #8a5a2b; stroke: currentColor; stroke-width: 1.2; }
.fig .copa { fill: var(--fc); fill-opacity: .45; stroke: currentColor; stroke-width: 1.2; }
.fig .barra { fill: var(--fa); fill-opacity: .75; stroke: none; }
.fig .t { fill: currentColor; font-size: 14px; font-family: inherit; }
.fig .tm { fill: var(--muted); font-size: 12px; font-family: inherit; }
.fig .ta { fill: var(--fa); font-size: 14px; font-weight: 700; font-family: inherit; }
.fig .tb { fill: var(--fb); font-size: 14px; font-weight: 700; font-family: inherit; }

/* Impresión */
@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  .top, .noprint, button, .btn { display: none !important; }
  .card { box-shadow: none; border: 1px solid #bbb; break-inside: avoid; }
  .wrap { max-width: none; padding: 0; }
  .pagebreak { break-before: page; }
}
footer.pie { padding: 28px 16px; text-align: center; color: var(--muted); font-size: .85rem; }
