/* NexoOT AI · consola web. Estilo industrial sobrio, claro/oscuro según el sistema. Sin dependencias externas. */
:root {
  --bg: #eef0f2; --surface: #ffffff; --surface-2: #f5f6f8; --border: #d3d8de; --text: #16191d; --muted: #5a636e;
  --accent: #b85c00; --accent-ink: #ffffff; --accent-soft: #fbead7; --link: #0b5cad; --focus: #0b5cad;
  --hi: #b42318; --hi-soft: #fde8e6; --mid: #a15c00; --mid-soft: #fdf0dc; --lo: #3d5a73; --lo-soft: #e4ebf2;
  --ok: #1d7a3a; --ok-soft: #e1f3e6; --err: #b42318;
  --radius: 6px; --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418; --surface: #191d23; --surface-2: #20252c; --border: #2f3640; --text: #e6e9ed; --muted: #9aa4af;
    --accent: #f59e3a; --accent-ink: #1a1206; --accent-soft: #3a2810; --link: #7cb8ff; --focus: #7cb8ff;
    --hi: #ff8a7a; --hi-soft: #3d1c19; --mid: #f5b056; --mid-soft: #3a2a12; --lo: #9fbad3; --lo-soft: #1f2b37;
    --ok: #6fd18f; --ok-soft: #15301f; --err: #ff8a7a; --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); min-height: 100vh;
  display: flex; flex-direction: column; }
main { flex: 1; outline: none; }
a { color: var(--link); text-underline-offset: 2px; }
h1 { font-size: 1.55rem; line-height: 1.25; margin: .1rem 0 .3rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1.25rem 0 .5rem; }
p { margin: .4rem 0; }
pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .65rem;
  overflow-x: auto; font: 12.5px/1.45 var(--mono); white-space: pre-wrap; word-break: break-all; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--accent-ink); padding: .5rem .8rem; z-index: 10; }
.skip:focus { left: .5rem; top: .5rem; }
.mono { font-family: var(--mono); font-size: .92em; }
.small { font-size: .85rem; }
.muted { color: var(--muted); }
.ok-t { color: var(--ok); font-weight: 600; }
.err-t { color: var(--err); font-weight: 600; }
.empty { color: var(--muted); font-style: italic; }

.wrap { width: 100%; max-width: 1240px; margin: 0 auto; padding: 1.25rem 1rem 2rem; }
.wrap.center { display: grid; place-items: center; min-height: 80vh; }

/* barra superior */
.topbar { background: #1b1f24; color: #e9ecef; border-bottom: 3px solid var(--accent); position: sticky; top: 0; z-index: 5; }
.topbar-in { max-width: 1240px; margin: 0 auto; padding: .45rem 1rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: .45rem; color: inherit; text-decoration: none; font-weight: 600; letter-spacing: .02em; }
.brand b { color: #f59e3a; }
.brand.big { font-size: 1.4rem; color: var(--text); }
.brand.big b { color: var(--accent); }
.nav { display: flex; gap: .15rem; flex-wrap: wrap; flex: 1; }
.nav a { color: #c9d0d7; text-decoration: none; padding: .4rem .65rem; border-radius: var(--radius); font-size: .92rem; }
.nav a:hover { background: #2a3038; color: #fff; }
.nav a[aria-current="page"] { background: #2f363f; color: #fff; box-shadow: inset 0 -2px 0 #f59e3a; }
.nav a:focus-visible, .who .btn:focus-visible { outline-color: #f5b056; }
.who { display: flex; align-items: center; gap: .5rem; font-size: .88rem; }
.who-name { max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who .chip { background: #2f363f; color: #e9ecef; border-color: #444d58; }
.who .btn.ghost { color: #e9ecef; border-color: #4a535e; }

/* pie */
.foot { border-top: 1px solid var(--border); background: var(--surface); font-size: .85rem; }
.foot .wrap { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: .8rem 1rem; }

/* tarjetas y rejillas */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem;
  box-shadow: var(--shadow); margin-bottom: 1rem; min-width: 0; }
.card.narrow { max-width: 560px; margin: 2rem auto; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.case-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1rem; align-items: start; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.head.sm { margin-bottom: .5rem; align-items: baseline; }
.head.sm h2 { margin: 0; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .74rem; color: var(--muted); margin: 0; font-weight: 600; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: .4rem; }
.actions, .tags, .btnrow { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }

/* indicadores */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--muted); border-radius: var(--radius);
  padding: .8rem 1rem; display: flex; flex-direction: column; color: var(--text); text-decoration: none; box-shadow: var(--shadow); min-width: 0; }
a.kpi:hover { border-color: var(--accent); }
.kpi-n { font-size: 2rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi-n.small-n { font-size: 1rem; font-weight: 600; padding: .55rem 0 .3rem; }
.kpi span:last-child { color: var(--muted); font-size: .88rem; }
.kpi.prio-alta { border-left-color: var(--hi); }
.kpi.prio-media { border-left-color: var(--mid); }
.kpi.prio-baja { border-left-color: var(--lo); }

/* insignias */
.badge, .chip { display: inline-block; padding: .08rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600;
  border: 1px solid transparent; white-space: nowrap; line-height: 1.5; vertical-align: middle; }
.chip { background: var(--surface-2); border-color: var(--border); color: var(--text); font-weight: 500; }
.chip.ok { color: var(--ok); }
.chip.err { color: var(--err); }
.prio-alta.badge { background: var(--hi-soft); color: var(--hi); border-color: currentColor; }
.prio-media.badge { background: var(--mid-soft); color: var(--mid); border-color: currentColor; }
.prio-baja.badge { background: var(--lo-soft); color: var(--lo); border-color: currentColor; }
.sup-alto { background: var(--accent); color: var(--accent-ink); }
.sup-medio { background: var(--accent-soft); color: var(--text); border-color: var(--accent); }
.sup-bajo { background: var(--surface-2); color: var(--muted); border-color: var(--border); border-style: dashed; }
.st-abierto { background: var(--hi-soft); color: var(--hi); }
.st-en_revision { background: var(--mid-soft); color: var(--mid); }
.st-confirmado { background: var(--ok-soft); color: var(--ok); }
.st-descartado, .st-cerrado { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
.st-derivado { background: var(--lo-soft); color: var(--lo); }
.dot { display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; margin-right: .25rem; vertical-align: baseline; }
.dot-alta { background: var(--hi); } .dot-media { background: var(--mid); } .dot-baja { background: var(--lo); }
.dot-ok { background: var(--ok); } .dot-none { background: transparent; border: 2px solid var(--muted); }

/* listas */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: .75rem; padding: .5rem 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.list li:first-child { border-top: 0; }
.list-main { font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.list-meta { display: flex; gap: .35rem; align-items: center; color: var(--muted); font-size: .82rem; flex-wrap: wrap; }

/* tablas */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .5rem .55rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.audit .detail { max-width: 340px; overflow-wrap: anywhere; }

/* formularios */
label { display: flex; flex-direction: column; gap: .25rem; font-size: .86rem; font-weight: 600; min-width: 0; }
label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 500; }
input, select, textarea { font: inherit; font-size: .92rem; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .45rem .55rem; min-height: 2.35rem; width: 100%; font-weight: 400; }
input[type="checkbox"] { width: 1.1rem; height: 1.1rem; min-height: 0; accent-color: var(--accent); }
input[type="file"] { padding: .35rem; }
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 0; }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.narrow-form { max-width: 560px; }
.row { display: flex; gap: .6rem; align-items: flex-end; margin-top: .75rem; }
.row.wrap-row { flex-wrap: wrap; }
.row.wrap-row > label { flex: 1 1 150px; }
.row.tight { margin-top: 0; gap: .35rem; }
.row.tight > * { flex: 1 1 120px; }
.grow { flex: 1 1 220px; }
.inline { display: inline; margin: 0; }
.filters { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; }
.filters > label { flex: 1 1 160px; }
.filters-btns { display: flex; gap: .4rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; font: inherit; font-size: .9rem; font-weight: 600;
  padding: .45rem .9rem; min-height: 2.35rem; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--err); border-color: currentColor; background: transparent; }
.btn.sm { padding: .2rem .6rem; min-height: 1.9rem; font-size: .82rem; }
.btn[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--accent); }
.btn[disabled] { opacity: .6; cursor: progress; }

/* mensajes */
.flash { border-radius: var(--radius); padding: .6rem .85rem; margin-bottom: 1rem; border: 1px solid; font-weight: 500; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.warn { background: var(--mid-soft); color: var(--mid); }
.flash.error { background: var(--hi-soft); color: var(--err); }
.notice { display: flex; gap: .5rem; align-items: flex-start; background: var(--accent-soft); border: 1px solid var(--accent);
  border-left-width: 5px; border-radius: var(--radius); padding: .55rem .8rem; font-size: .9rem; margin: 0 0 1rem; }
.notice svg { flex: none; color: var(--accent); margin-top: .1rem; }

/* login */
.login { width: 100%; max-width: 400px; padding: 1.5rem; }
.login form { margin-top: 1rem; }

/* detalle de caso */
.hyp { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem .85rem; margin-bottom: .75rem; background: var(--surface); }
.hyp.top { border-color: var(--accent); border-left-width: 5px; }
.hyp-head { display: flex; gap: .7rem; align-items: flex-start; }
.hyp-n { flex: none; width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border);
  display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.hyp.top .hyp-n { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.hyp-text { font-weight: 600; margin: 0 0 .35rem; }
.hyp-meta { display: flex; gap: .35rem; flex-wrap: wrap; margin: 0; }
.hyp details { margin-top: .4rem; }
summary { cursor: pointer; font-weight: 600; font-size: .88rem; }
.checks { margin: .4rem 0 0; padding-left: 1.2rem; }
.checks li { margin: .2rem 0; }
.evref, .evid { font-family: var(--mono); font-size: .8rem; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 4px; padding: 0 .3rem; text-decoration: none; }
.timeline { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--border); margin-left: .4rem; }
.timeline li { position: relative; padding: .35rem 0 .7rem 1rem; display: grid; grid-template-columns: 11.5rem minmax(0, 1fr); gap: .5rem; scroll-margin-top: 5rem; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: .65rem; width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--muted); }
.timeline li.sev-hi::before { border-color: var(--hi); background: var(--hi); }
.timeline li.sev-mid::before { border-color: var(--mid); }
.timeline li:target { background: var(--accent-soft); border-radius: var(--radius); }
.tl-when { font-family: var(--mono); font-size: .8rem; color: var(--muted); padding-top: .1rem; }
.tl-body p { margin: 0 0 .15rem; }
.tl-msg { overflow-wrap: anywhere; }
.deppath { list-style: none; margin: 0; padding: 0; }
.deppath li { padding: .45rem .6rem; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 1.1rem; position: relative; background: var(--surface-2); }
.deppath li:not(:last-child)::after { content: "▲"; position: absolute; left: 50%; bottom: -1.1rem; transform: translateX(-50%); color: var(--muted); font-size: .7rem; line-height: 1.1rem; }
.deppath li.hit { border-color: var(--accent); border-left-width: 4px; }
.note { margin: .5rem 0; padding: .5rem .75rem; border-left: 3px solid var(--accent); background: var(--surface-2); white-space: pre-wrap; }
.ai { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: .65rem .75rem;
  font-size: .9rem; max-height: 32rem; overflow-y: auto; overflow-wrap: anywhere; }
.spark { margin: 0 0 1rem; }
.spark svg { display: block; width: 100%; height: 90px; color: var(--link); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); }
.spark .mark { fill: var(--hi); stroke: var(--surface); stroke-width: 1.5; }
.spark-axis { display: flex; justify-content: space-between; margin-top: .2rem; }
.deps { columns: 3 220px; margin: 0; padding-left: 1.1rem; }
.deps li { break-inside: avoid; }
.pager { display: flex; gap: .5rem; justify-content: flex-end; margin-top: .75rem; }
.chain.ok { border-left: 5px solid var(--ok); }
.chain.bad { border-left: 5px solid var(--err); background: var(--hi-soft); }
.chain.ok h2 { color: var(--ok); } .chain.bad h2 { color: var(--err); }
.token-new { border: 2px solid var(--accent); background: var(--accent-soft); }

/* responsive */
@media (max-width: 980px) {
  .case-grid { grid-template-columns: minmax(0, 1fr); }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { position: static; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .who { margin-left: auto; }
  .timeline li { grid-template-columns: minmax(0, 1fr); gap: 0; }
  h1 { font-size: 1.3rem; }
  .row:not(.wrap-row) { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
@media print {
  .topbar, .foot, form, .actions { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; break-inside: avoid; }
}
