:root {
  color-scheme: dark;
  --bg: #111110; --surface-1: #1a1a19; --surface-2: #232321; --surface-3: #2d2d2a; --line: #34342f;
  --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #8d8c84;
  --accent: #fab219;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --mono: 'IBM Plex Mono', ui-monospace, monospace; --sans: 'Inter', system-ui, sans-serif;
  --header-bg: rgba(17,17,16,.94); --on-accent: #111; --accent-fill: #fab219;
  --banner-bg: #3a2c08; --banner-line: #6b5212; --banner-fg: #f6dc9a;
  --down-bg: rgba(57,135,229,.18); --down-fg: #8fbcf2; --up-bg: rgba(12,163,12,.18); --up-fg: #6fd56f;
  --bad-bg: rgba(208,59,59,.2); --mid-bg: rgba(250,178,25,.16); --ok-bg: rgba(12,163,12,.18);
  --danger-line: #6a2626; --danger-fg: #f39b9b; --grid: #2d2d2a; --shadow: 0 1px 0 rgba(0,0,0,.2);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f3ef; --surface-1: #ffffff; --surface-2: #f1f0eb; --surface-3: #e7e5de; --line: #dddbd2;
  --text-primary: #1c1c1a; --text-secondary: #4a4943; --text-muted: #77756c;
  --accent: #a86f00; --accent-fill: #fab219; --on-accent: #1c1c1a;
  --s1: #2a6fc9; --s2: #c24a1b; --s3: #12805a; --s4: #a86f00;
  --good: #0a840a; --warning: #a86f00; --serious: #c45a2e; --critical: #c22f2f;
  --header-bg: rgba(255,255,255,.94);
  --banner-bg: #fff4d6; --banner-line: #f0d48a; --banner-fg: #5c4300;
  --down-bg: rgba(42,111,201,.12); --down-fg: #1f5aa6; --up-bg: rgba(10,132,10,.12); --up-fg: #0a6e0a;
  --bad-bg: rgba(194,47,47,.13); --mid-bg: rgba(250,178,25,.22); --ok-bg: rgba(10,132,10,.12);
  --danger-line: #e5b4b4; --danger-fg: #b02a2a; --grid: #e7e5de; --shadow: 0 1px 2px rgba(0,0,0,.06);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text-primary); font: 14px/1.45 var(--sans); }
a { color: var(--s1); }
.hidden { display: none !important; }
.top { position: sticky; top: 0; z-index: 10; display: flex; gap: 12px; align-items: center; padding: 10px 20px; background: var(--header-bg); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; gap: 10px; align-items: center; }
.brand b { font: 600 13px var(--mono); letter-spacing: .14em; display: block; }
.brand small { color: var(--text-muted); font: 12px var(--mono); }
nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
nav button { background: none; border: 0; color: var(--text-secondary); padding: 7px 9px; border-radius: 6px; font: 500 13px var(--sans); cursor: pointer; }
nav button:hover { background: var(--surface-2); color: var(--text-primary); }
nav button.on { background: var(--surface-3); color: var(--text-primary); box-shadow: inset 0 -2px 0 var(--accent-fill); }
.badge { background: var(--accent-fill); color: var(--on-accent); border-radius: 9px; padding: 0 6px; font: 600 11px var(--mono); margin-left: 4px; }
.badge:empty { display: none; }
.status { font: 12px var(--mono); color: var(--text-muted); }
.banner { margin: 12px 20px 0; padding: 10px 14px; border-radius: 8px; background: var(--banner-bg); border: 1px solid var(--banner-line); color: var(--banner-fg); }
.banner.info { background: var(--surface-2); border-color: var(--line); color: var(--text-secondary); }
main { padding: 16px 20px 60px; max-width: 1500px; margin: 0 auto; }
.tab { display: none; } .tab.on { display: block; }
h2 { font: 600 12px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--text-muted); margin: 26px 0 10px; }
h2:first-child { margin-top: 6px; }
.grid { display: grid; gap: 12px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.two { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.card { background: var(--surface-1); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 10px; padding: 14px 16px; min-width: 0; }
.card h3 { margin: 0 0 8px; font: 600 13px var(--sans); color: var(--text-secondary); }
.kpi .lbl { color: var(--text-muted); font: 500 11px var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.kpi .val { font: 600 26px var(--mono); margin: 4px 0 2px; letter-spacing: -.02em; }
.kpi .sub { font: 12px var(--mono); color: var(--text-secondary); }
.up { color: var(--good); } .down { color: var(--critical); }
.chart { position: relative; height: 260px; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 9px 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 22px 1fr; gap: 6px; }
.list li:first-child { border-top: 0; }
.list b { font-weight: 600; } .list p { margin: 2px 0 0; color: var(--text-secondary); font-size: 13px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font: 500 11px var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); padding: 8px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface-1); white-space: nowrap; cursor: pointer; }
td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.n, th.n { text-align: right; font-family: var(--mono); white-space: nowrap; }
.tbl { max-height: 620px; overflow: auto; }
.pill { display: inline-flex; gap: 4px; align-items: center; padding: 1px 8px; border-radius: 10px; font: 600 11px var(--mono); white-space: nowrap; }
.pill.BAJAR { background: var(--down-bg); color: var(--down-fg); }
.pill.SUBIR { background: var(--up-bg); color: var(--up-fg); }
.pill.MANTENER, .pill.SIN { background: var(--surface-3); color: var(--text-secondary); }
.why { color: var(--text-secondary); font-size: 12.5px; max-width: 520px; }
.btn { background: var(--surface-3); color: var(--text-primary); border: 1px solid var(--line); border-radius: 7px; padding: 6px 12px; font: 500 13px var(--sans); cursor: pointer; }
.btn:hover { border-color: var(--text-muted); }
.btn.pri { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--on-accent); font-weight: 600; }
.btn.danger { border-color: var(--danger-line); color: var(--danger-fg); }
.btn.sm { padding: 3px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--text-muted); } .small { font-size: 12px; }
.score { font: 600 13px var(--mono); padding: 2px 8px; border-radius: 6px; }
.todo { margin: 4px 0 0; padding-left: 16px; color: var(--text-secondary); font-size: 12.5px; }
.todo li { margin: 2px 0; }
textarea, input, select { background: var(--surface-2); color: var(--text-primary); border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; font: 13px var(--sans); }
textarea { width: 100%; min-height: 70px; resize: vertical; }
label.f { display: grid; gap: 4px; font-size: 12px; color: var(--text-secondary); }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.bar { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--s1); border-radius: 3px; }
.md { white-space: pre-wrap; line-height: 1.55; }
.md h1, .md h2, .md h3 { font-family: var(--sans); text-transform: none; letter-spacing: 0; color: var(--text-primary); }
#toast { position: fixed; bottom: 20px; right: 20px; background: var(--surface-3); border: 1px solid var(--line); padding: 10px 14px; border-radius: 8px; opacity: 0; transition: .2s; pointer-events: none; max-width: 420px; }
#toast.on { opacity: 1; }
code { font: 12px var(--mono); background: var(--surface-2); padding: 1px 5px; border-radius: 4px; word-break: break-all; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
@media (max-width: 700px) {
  .top { padding: 8px 12px; } main { padding: 12px 12px 50px; } .two { grid-template-columns: 1fr; }
  .kpi .val { font-size: 21px; } .banner { margin: 10px 12px 0; }
}

/* ---- v2 ---- */
.themesel { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.themesel button { background: none; border: 0; color: var(--text-muted); padding: 4px 8px; border-radius: 6px; cursor: pointer; font-size: 14px; line-height: 1; }
.themesel button.on { background: var(--surface-3); color: var(--text-primary); }
.userbox { display: flex; gap: 8px; align-items: center; font: 12px var(--mono); color: var(--text-muted); }
.userbox a { color: var(--text-secondary); text-decoration: none; cursor: pointer; }
.userbox a:hover { color: var(--text-primary); }
.motd { display: grid; grid-template-columns: 1fr 1fr; gap: 0; padding: 0; overflow: hidden; }
.motd > div { padding: 14px 16px; }
.motd > div + div { border-left: 1px solid var(--line); }
.motd .k { font: 600 11px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }
.motd b { display: block; font-size: 15px; margin-bottom: 2px; }
.motd p { margin: 0; color: var(--text-secondary); }
.guide { border-left: 3px solid var(--accent-fill); }
.guide h3 { color: var(--text-primary); }
.guide ol, .guide ul { margin: 6px 0 0; padding-left: 20px; color: var(--text-secondary); }
.guide li { margin: 3px 0; }
details.guide > summary { cursor: pointer; font-weight: 600; list-style: none; }
details.guide > summary::before { content: '▸ '; color: var(--accent); }
details.guide[open] > summary::before { content: '▾ '; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.seg button, .seg select { background: var(--surface-2); color: var(--text-secondary); border: 1px solid var(--line); border-radius: 7px; padding: 5px 10px; font: 500 12.5px var(--sans); cursor: pointer; }
.seg button.on { background: var(--surface-3); color: var(--text-primary); border-color: var(--text-muted); }
.ml-impact { margin-top: 4px; font-size: 12.5px; color: var(--text-muted); border-left: 2px solid var(--line); padding-left: 8px; }
.ml-impact b { display: inline; font-weight: 600; color: var(--text-secondary); font-size: 12px; }
th.stack { white-space: normal; text-align: center; line-height: 1.15; width: 74px; }
td.c { text-align: center; }
.comps { margin-top: 4px; font-size: 12px; color: var(--text-muted); }
.comps a { color: var(--s1); text-decoration: none; }
.comps a:hover { text-decoration: underline; }
.src { font-size: 11px; color: var(--text-muted); }
.chip { display: inline-block; font: 500 11px var(--mono); padding: 1px 6px; border-radius: 4px; background: var(--surface-3); color: var(--text-secondary); }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(380px, 100%); padding: 24px; }
.login h1 { font: 600 14px var(--mono); letter-spacing: .14em; margin: 10px 0 18px; }
.login label.f { margin-bottom: 12px; }
.login input { width: 100%; }
.err { color: var(--critical); font-size: 13px; min-height: 18px; }
.temp { font: 600 16px var(--mono); background: var(--surface-2); padding: 8px 12px; border-radius: 6px; display: inline-block; user-select: all; }
@media (max-width: 700px) { .motd { grid-template-columns: 1fr; } .motd > div + div { border-left: 0; border-top: 1px solid var(--line); } }

.status { display: none; }
@media (min-width: 1650px) { .status { display: block; } }
nav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
nav button { white-space: nowrap; }
.pw { position: relative; display: block; }
.pw input { width: 100%; padding-right: 38px; }
.pw-eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--text-muted); cursor: pointer; padding: 5px; border-radius: 5px; display: grid; place-items: center; }
.pw-eye:hover { color: var(--text-primary); background: var(--surface-3); }
@media (max-width: 700px) { .top { flex-wrap: wrap; } nav { order: 3; flex-basis: 100%; } }

/* v6: exportar, modal, termómetro, pasos */
.card.tbl { position: relative; }
.exp { position: absolute; top: 8px; right: 8px; z-index: 2; background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; font: 600 10.5px var(--mono); letter-spacing: .06em; cursor: pointer; opacity: .75; }
.exp:hover { opacity: 1; color: var(--text-primary); border-color: var(--text-muted); }
.card.tbl > .exp + h3 { padding-right: 52px; }
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal > .card { width: min(820px, 100%); max-height: 92vh; overflow: auto; position: relative; }
.modal .close { position: absolute; top: 10px; right: 10px; }
.thermo { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-top: 6px; }
.thermo div { height: 26px; border-radius: 5px; background: var(--c); opacity: .22; display: flex; align-items: center; justify-content: center; }
.thermo div span { font: 600 10.5px var(--mono); color: var(--text-primary); letter-spacing: .04em; text-transform: uppercase; opacity: 0; }
.thermo div.on { opacity: 1; height: 34px; margin-top: -4px; box-shadow: 0 0 0 2px var(--surface-1), 0 0 0 3px var(--c); }
.thermo div.on span { opacity: 1; color: #111; }
ol.steps { margin: 0; padding-left: 20px; } ol.steps li { margin: 4px 0; }
@media (max-width: 720px) { .thermo div span { font-size: 9px; } }
.card.tbl:has(> .exp) { padding-top: 30px; }
.exp { top: 6px; }
.grid.two > .card { overflow-x: auto; }
a.btn { text-decoration: none; }

/* ---- Analizador de producto: autocompletado ---- */
.sug { position: relative; margin-top: 6px; max-width: 560px; }
.sug-i { display: flex; gap: 10px; align-items: center; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; margin-top: 4px; cursor: pointer; background: var(--surface-1); }
.sug-i:hover, .sug-i.on { background: var(--surface-2); border-color: var(--text-muted); }
.sug-i img, .sug-i i { width: 38px; height: 38px; border-radius: 5px; object-fit: contain; background: var(--surface-3); flex: none; }
.sug-i b { font: 600 13px var(--sans); }
.sug-i > div { min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
p.big { font: 600 17px var(--sans); margin: 0 0 6px; }

/* ---- Filas y tarjetas que llevan a otra vista ---- */
tr.clickable { cursor: pointer; }
tr.clickable:hover > td { background: var(--surface-2); }
.card.kpi.clickable { cursor: pointer; transition: border-color .12s, transform .12s; }
.card.kpi.clickable:hover { border-color: var(--text-muted); transform: translateY(-1px); }
.card.kpi.clickable:focus-visible { outline: 2px solid var(--accent-fill); outline-offset: 2px; }

/* == cambios 2026-11-11 == */
/* Encabezado: marca + tema a la izquierda, usuario apilado a la derecha, menú al medio */
.top { flex-wrap: nowrap; }
.brand, .top > .row { flex-shrink: 0; }
.brand-txt .themesel { display: flex; width: max-content; margin-top: 5px; }
.brand-txt .themesel button { padding: 2px 7px; font-size: 12px; }
.userbox { flex-direction: column; align-items: flex-end; gap: 3px; }
.userbox .ub-links { display: flex; gap: 10px; }
/* Si el menú no entra, se desplaza en horizontal (barra fina visible + rueda del mouse) */
nav { min-width: 0; scrollbar-width: thin; }
nav::-webkit-scrollbar { height: 4px; }
nav::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; }
@media (max-width: 700px) { .top { flex-wrap: wrap; } }

/* Tablas con encabezado fijo: el encabezado se pega al borde superior de la tarjeta,
   no al borde del relleno, así no se ven filas por encima al bajar */
.card.tbl th { top: -14px; box-shadow: inset 0 -1px 0 var(--line); }
.card.tbl:has(> .exp) th { top: -30px; }

/* == Impacto sumó una pestaña (12 en total): se compactan los botones del menú para que
   se lean todas hasta Conexión/Usuarios. Si aun así no entra, sigue el desplazamiento horizontal. == */
nav { gap: 0; }
nav button { padding: 7px 7px; }
@media (max-width: 1500px) { nav button { padding: 7px 5px; font-size: 12.5px; } .top { gap: 8px; } }
