/* InmunoSec — portal. Colores por rol; el modo oscuro tiene sus propios pasos, no una inversión. */
:root {
  color-scheme: light;
  --surface-0: #f4f4f2;
  --surface-1: #fcfcfb;
  --surface-2: #ffffff;
  --border: #dedcd6;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #7a7872;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --edge: #b9b7b0;
  /* Paleta de estado (validada, fija): siempre acompañada de icono y etiqueta. */
  --st-ok: #0ca30c;
  --st-info: #2a78d6;
  --st-warn: #fab219;
  --st-serious: #ec835a;
  --st-crit: #d03b3b;
  --st-offline: #9a988f;
  --bar: #2a78d6;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 16px rgba(0, 0, 0, .05);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-0: #121211;
    --surface-1: #1a1a19;
    --surface-2: #222220;
    --border: #34332f;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #8f8d85;
    --accent: #3987e5;
    --edge: #55534d;
    --st-info: #3987e5;
    --st-offline: #6f6d66;
    --bar: #3987e5;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--surface-0); color: var(--text-primary);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
h1 { font-size: 20px; margin: 0 0 2px; }
h2 { font-size: 17px; margin: 18px 0 6px; }
h3 { font-size: 14px; margin: 16px 0 4px; }
.muted { color: var(--text-muted); margin: 0; }
button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-primary); padding: 7px 12px; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
button.ghost { background: transparent; }
button.danger { color: var(--st-crit); }
button:disabled { opacity: .5; cursor: default; }
input, select { font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-primary); }
code, pre { font-family: ui-monospace, "Cascadia Code", Menlo, monospace; font-size: 12.5px; }

/* Acceso */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 460px; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.brand { font-size: 24px; letter-spacing: -.3px; margin: 0; }
.brand.small { font-size: 17px; padding: 18px 18px 10px; }
.tabs { display: flex; gap: 4px; margin: 18px 0 14px; border-bottom: 1px solid var(--border); }
.tab { border: 0; border-radius: 0; background: none; padding: 8px 10px; color: var(--text-secondary);
  border-bottom: 2px solid transparent; }
.tab.active { color: var(--text-primary); border-bottom-color: var(--accent); }
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 4px; color: var(--text-secondary); font-size: 13px; }
.error { color: var(--st-crit); min-height: 1em; margin: 0; }
.warn-text { color: var(--text-primary); background: color-mix(in srgb, var(--st-warn) 22%, transparent);
  border-left: 3px solid var(--st-warn); padding: 8px 10px; border-radius: 6px; }
.secret { display: flex; gap: 8px; align-items: center; background: var(--surface-0); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; }
.secret code { flex: 1; overflow-wrap: anywhere; }
.code { background: var(--surface-0); border: 1px solid var(--border); border-radius: 8px; padding: 10px;
  overflow-x: auto; white-space: pre; }
.keys .primary { margin-top: 16px; width: 100%; }

/* Aplicación */
.app { display: grid; grid-template-columns: 208px 1fr; min-height: 100%; }
.sidebar { background: var(--surface-1); border-right: 1px solid var(--border); position: sticky; top: 0; height: 100vh; }
.sidebar ul { list-style: none; margin: 0; padding: 4px 8px; }
.sidebar li.sep { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
.sidebar a { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 8px;
  color: var(--text-secondary); text-decoration: none; }
.sidebar a:hover { background: var(--surface-0); color: var(--text-primary); }
.sidebar a.active { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--text-primary); font-weight: 600; }
.ico { width: 18px; text-align: center; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 20px;
  border-bottom: 1px solid var(--border); background: var(--surface-1); flex-wrap: wrap; }
.device-picker { display: flex; gap: 8px; align-items: center; }
.device-picker label { color: var(--text-muted); }
.device-picker select { min-width: 220px; }
.who { color: var(--text-secondary); display: flex; gap: 8px; align-items: center; }
.view { padding: 18px 20px 28px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.view-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { background: var(--surface-1); border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px;
  color: var(--text-secondary); font-size: 12.5px; }
.chip b { color: var(--text-primary); }
.notice { background: var(--surface-1); border: 1px dashed var(--border); border-radius: 10px; padding: 14px; margin: 0; color: var(--text-secondary); }
.workspace { display: grid; grid-template-columns: 1fr 320px; gap: 12px; min-height: 540px; }
.canvas { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; position: relative;
  overflow: hidden; min-height: 540px; outline: none; }
.canvas svg { width: 100%; height: 100%; display: block; cursor: grab; }
.canvas svg.dragging { cursor: grabbing; }
.canvas .hint { position: absolute; left: 12px; bottom: 10px; color: var(--text-muted); font-size: 12px; pointer-events: none; }
.detail { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 14px;
  overflow: auto; max-height: 640px; }
.detail h2 { margin-top: 0; overflow-wrap: anywhere; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 10px; margin: 8px 0; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.list { margin: 6px 0; padding-left: 18px; }
.list li { margin: 3px 0; overflow-wrap: anywhere; }
.extra:empty { display: none; }
.extra { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; color: var(--text-secondary); font-size: 12.5px; }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.ok, .badge.ok { background: var(--st-ok); }
.dot.info, .badge.info { background: var(--st-info); }
.dot.warn, .badge.warn { background: var(--st-warn); }
.dot.crit, .badge.crit { background: var(--st-crit); }
.dot.offline, .badge.offline { background: var(--st-offline); }
.badge { color: #fff; border-radius: 999px; padding: 2px 9px; font-size: 12px; }
.badge.warn { color: #0b0b0b; }
.status { display: inline-flex; gap: 6px; align-items: center; font-weight: 600; }

/* Grafo SVG */
.g-edge { stroke: var(--edge); stroke-width: 1.5; fill: none; }
.g-edge.crit { stroke: var(--st-crit); stroke-width: 2; }
.g-edge.warn { stroke: var(--st-warn); }
.g-node circle { stroke: var(--surface-1); stroke-width: 2; }
.g-node.selected circle { stroke: var(--text-primary); stroke-width: 3; }
.g-node text { fill: var(--text-primary); font-size: 11.5px; pointer-events: none; }
.g-node text.glyph { fill: #fff; font-weight: 700; font-size: 11px; }
/* Grafos densos: etiqueta de hojas solo al pasar, enfocar o seleccionar; halo del color del lienzo. */
.g-node text.lbl-hover { display: none; paint-order: stroke; stroke: var(--surface-1); stroke-width: 4px; }
.g-node:hover text.lbl-hover, .g-node:focus text.lbl-hover, .g-node.selected text.lbl-hover { display: inline; }
.g-node:hover, .g-node:focus { outline: none; }
.g-node.st-warn text.glyph { fill: #0b0b0b; }
.g-node .halo { fill: none; stroke: var(--st-crit); stroke-opacity: .35; stroke-width: 6; }
.g-node { cursor: pointer; }
.fill-ok { fill: var(--st-ok); } .fill-info { fill: var(--st-info); } .fill-warn { fill: var(--st-warn); }
.fill-crit { fill: var(--st-crit); } .fill-offline { fill: var(--st-offline); }
.fill-center { fill: var(--text-secondary); }
.g-label-bg { fill: var(--surface-1); fill-opacity: .8; }

/* Histórico */
.bars .bar { fill: var(--bar); }
.bars .bar.crit { fill: var(--st-crit); }
.bars .axis { stroke: var(--border); }
.bars text { fill: var(--text-muted); font-size: 11px; }
.bars .hit { fill: transparent; cursor: default; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.timeline li { display: grid; grid-template-columns: 150px 110px 1fr; gap: 10px; align-items: start;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; }
.timeline time { color: var(--text-muted); font-size: 12.5px; }
.timeline .type { font-size: 12px; color: var(--text-secondary); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.filters button.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.tooltip { position: fixed; z-index: 10; background: var(--surface-2); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px; font-size: 12.5px; box-shadow: var(--shadow);
  pointer-events: none; max-width: 320px; }
table.inv { width: 100%; border-collapse: collapse; font-size: 13px; }
table.inv th, table.inv td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--border); }
table.inv th { color: var(--text-muted); font-weight: 500; }
.inv-tools { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; margin-top: 10px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sidebar ul { display: flex; overflow-x: auto; }
  .sidebar li.sep { margin: 0; border: 0; padding: 0; }
  .workspace { grid-template-columns: 1fr; }
  .timeline li { grid-template-columns: 1fr; }
}
