/* ==========================================================================
   DioGuard — sistema visual
   Sala de análisis: fondo oscuro por defecto, una sola tinta de acento, y el
   color reservado casi por completo para el riesgo. Densidad alta y legible.
   ========================================================================== */

:root {
  --bg:            #08090d;
  --bg-deep:       #05060a;
  --surface:       #0f1118;
  --surface-2:     #151824;
  --surface-3:     #1c2030;
  --line:          #232838;
  --line-soft:     #1a1e2b;

  --text:          #e9ebf2;
  --text-2:        #a4abc0;
  --text-3:        #6d7488;

  --accent:        #7c8cff;
  --accent-soft:   rgba(124, 140, 255, .14);
  --accent-line:   rgba(124, 140, 255, .38);

  --alta:          #ff5d73;
  --alta-soft:     rgba(255, 93, 115, .13);
  --media:         #ffb340;
  --media-soft:    rgba(255, 179, 64, .13);
  --baja:          #47c3f5;
  --baja-soft:     rgba(71, 195, 245, .13);
  --ok:            #3ddc97;
  --ok-soft:       rgba(61, 220, 151, .13);

  --radius:        14px;
  --radius-sm:     9px;
  --shadow:        0 1px 2px rgba(0,0,0,.5), 0 12px 40px -12px rgba(0,0,0,.7);
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

:root[data-theme="light"] {
  --bg:            #f6f7fb;
  --bg-deep:       #eef0f7;
  --surface:       #ffffff;
  --surface-2:     #f7f8fc;
  --surface-3:     #eef0f7;
  --line:          #e0e3ee;
  --line-soft:     #eaecf4;
  --text:          #10131c;
  --text-2:        #4d5468;
  --text-3:        #838aa0;
  --accent:        #4f5fe0;
  --accent-soft:   rgba(79, 95, 224, .09);
  --accent-line:   rgba(79, 95, 224, .3);
  --alta:          #e0304c;
  --alta-soft:     rgba(224, 48, 76, .08);
  --media:         #c07b0d;
  --media-soft:    rgba(192, 123, 13, .1);
  --baja:          #1682b0;
  --baja-soft:     rgba(22, 130, 176, .1);
  --ok:            #14895c;
  --ok-soft:       rgba(20, 137, 92, .1);
  --shadow:        0 1px 2px rgba(16,19,28,.05), 0 12px 32px -16px rgba(16,19,28,.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv02", "cv03", "cv04", "ss01";
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.018em; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* --- estructura ---------------------------------------------------------- */

.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }

.side {
  background: var(--bg-deep);
  border-right: 1px solid var(--line-soft);
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 26px;
  position: sticky; top: 0; height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 0; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(145deg, var(--accent), #b06dff 90%);
  display: grid; place-items: center; flex: none;
  box-shadow: 0 4px 14px -4px var(--accent-line);
}
.brand-mark svg { width: 17px; height: 17px; }
.brand-name { font-weight: 650; letter-spacing: -.03em; font-size: 15.5px; }
.brand-sub { font-size: 10.5px; color: var(--text-3); letter-spacing: .07em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--text-3); padding: 0 10px 7px; font-weight: 600;
}
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; font-size: 13.4px;
  transition: background .13s, color .13s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.on { background: var(--accent-soft); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent-line); }
.nav a svg { width: 15px; height: 15px; opacity: .8; flex: none; }
.nav .count {
  margin-left: auto; font-size: 11px; font-variant-numeric: tabular-nums;
  background: var(--alta); color: #fff; border-radius: 20px; padding: 1px 7px; font-weight: 600;
}

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }

.sync {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm); padding: 10px 11px; font-size: 11.5px; color: var(--text-3);
}
.sync-top { display: flex; align-items: center; gap: 7px; color: var(--text-2); font-weight: 550; margin-bottom: 3px; }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: pulse 2.6s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(61,220,151,.5); }
  70% { box-shadow: 0 0 0 7px rgba(61,220,151,0); }
  100% { box-shadow: 0 0 0 0 rgba(61,220,151,0); }
}

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 30px; border-bottom: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px); position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 17px; }
.topbar .sub { color: var(--text-3); font-size: 12.5px; margin-top: 1px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 9px; }

.content { padding: 26px 30px 60px; display: flex; flex-direction: column; gap: 22px; }

/* --- controles ----------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 9px; font-size: 13px; font-weight: 550;
  border: 1px solid var(--line); background: var(--surface); color: var(--text-2);
  cursor: pointer; font-family: inherit; transition: .13s;
}
.btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--accent-line); }
.btn svg { width: 14px; height: 14px; }
.btn-primary {
  background: var(--accent); border-color: transparent; color: #fff;
  box-shadow: 0 4px 14px -6px var(--accent-line);
}
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #fff); color: #fff; }
.btn-ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); background: var(--ok-soft); }
.btn-danger { color: var(--alta); border-color: color-mix(in srgb, var(--alta) 35%, transparent); background: var(--alta-soft); }
.btn-sm { padding: 5px 10px; font-size: 12.2px; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 5px 11px; border-radius: 20px; font-size: 12.4px; font-weight: 500;
  border: 1px solid var(--line); color: var(--text-2); background: var(--surface);
  transition: .13s; white-space: nowrap;
}
.chip:hover { border-color: var(--accent-line); color: var(--text); }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }
.chip .n { opacity: .55; margin-left: 4px; font-variant-numeric: tabular-nums; }

/* --- superficies --------------------------------------------------------- */

.card {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-head {
  padding: 15px 18px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 12px;
}
.card-head h3 { font-size: 13.6px; }
.card-head .hint { font-size: 12px; color: var(--text-3); }
.card-head .right { margin-left: auto; }
.card-body { padding: 18px; }

.grid { display: grid; gap: 16px; }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-2-1 { grid-template-columns: 1.9fr 1fr; }
@media (max-width: 1180px) { .g-4 { grid-template-columns: repeat(2, 1fr); } .g-2-1, .g-3 { grid-template-columns: 1fr; } }

/* --- KPI ----------------------------------------------------------------- */

.kpi { padding: 16px 18px; position: relative; overflow: hidden; }
.kpi::after {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-line), transparent);
  opacity: .5;
}
.kpi .label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .085em;
  color: var(--text-3); font-weight: 600;
}
.kpi .value {
  font-size: 27px; font-weight: 640; letter-spacing: -.035em; margin-top: 7px;
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.kpi .value small { font-size: 15px; color: var(--text-3); font-weight: 500; margin-left: 2px; }
.kpi .foot { font-size: 12px; color: var(--text-3); margin-top: 5px; }
.kpi.risk .value { color: var(--alta); }

/* --- histograma: el gráfico de firma ------------------------------------- */

.hist { position: relative; height: 200px; display: flex; align-items: flex-end; gap: 3px; padding-top: 22px; }
.hist .bar { flex: 1; position: relative; display: flex; align-items: flex-end; height: 100%; }
.hist .bar i {
  display: block; width: 100%; border-radius: 3px 3px 1px 1px;
  background: linear-gradient(180deg, var(--surface-3), var(--surface-2));
  box-shadow: inset 0 0 0 1px var(--line);
  transition: .2s;
}
.hist .bar.crit i {
  background: linear-gradient(180deg, var(--alta), color-mix(in srgb, var(--alta) 45%, transparent));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--alta) 55%, transparent),
              0 0 22px -6px var(--alta);
}
.hist .bar:hover i { filter: brightness(1.35); }
.hist .bar:hover .tip { opacity: 1; transform: translate(-50%, -6px); }
.tip {
  position: absolute; bottom: 100%; left: 50%; transform: translate(-50%, 2px);
  background: var(--surface-3); border: 1px solid var(--line); color: var(--text);
  font-size: 11.5px; padding: 5px 9px; border-radius: 7px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: .15s; z-index: 5; box-shadow: var(--shadow);
}
.umbral-line {
  position: absolute; top: 0; bottom: 0; width: 0;
  border-left: 1.5px dashed var(--alta); opacity: .85;
}
.umbral-tag {
  position: absolute; top: -2px; transform: translateX(-50%);
  font-size: 10.5px; font-weight: 650; letter-spacing: .04em;
  color: var(--alta); background: var(--alta-soft); border: 1px solid color-mix(in srgb, var(--alta) 40%, transparent);
  padding: 2px 8px; border-radius: 20px; white-space: nowrap;
}
.hist-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); margin-top: 8px; }

/* --- alertas ------------------------------------------------------------- */

.alert-row {
  display: flex; align-items: flex-start; gap: 14px; padding: 15px 18px;
  border-bottom: 1px solid var(--line-soft); transition: background .13s; position: relative;
}
.alert-row:last-child { border-bottom: 0; }
.alert-row:hover { background: var(--surface-2); }
.alert-row::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2.5px;
  background: var(--sev, transparent); opacity: 0; transition: .13s;
}
.alert-row:hover::before { opacity: 1; }
.alert-row.alta { --sev: var(--alta); }
.alert-row.media { --sev: var(--media); }
.alert-row.baja { --sev: var(--baja); }

.score {
  width: 42px; height: 42px; flex: none; border-radius: 11px;
  display: grid; place-items: center; font-weight: 680; font-size: 14.5px;
  font-variant-numeric: tabular-nums; letter-spacing: -.03em;
}
.score.alta { background: var(--alta-soft); color: var(--alta); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--alta) 30%, transparent); }
.score.media { background: var(--media-soft); color: var(--media); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--media) 30%, transparent); }
.score.baja { background: var(--baja-soft); color: var(--baja); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--baja) 30%, transparent); }

.alert-main { min-width: 0; flex: 1; }
.alert-title { font-weight: 570; font-size: 14px; letter-spacing: -.012em; }
.alert-why {
  color: var(--text-2); font-size: 12.8px; margin-top: 4px; line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.alert-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }

.tag {
  font-size: 11.3px; padding: 2.5px 8px; border-radius: 6px; font-weight: 520;
  background: var(--surface-3); color: var(--text-2); border: 1px solid var(--line-soft);
  display: inline-flex; align-items: center; gap: 5px;
}
.tag b { font-weight: 620; color: var(--text); }
.tag.accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.tag.alta { background: var(--alta-soft); color: var(--alta); border-color: color-mix(in srgb, var(--alta) 30%, transparent); }
.tag.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.tag.mute { background: transparent; }

/* --- tablas -------------------------------------------------------------- */

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font-size: 10.8px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-3); font-weight: 650; padding: 0 14px 9px; border-bottom: 1px solid var(--line-soft);
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); color: var(--text-2); }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: var(--surface-2); }
table.data td.strong { color: var(--text); font-weight: 540; }
table.data td.n { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12px; color: var(--text-3); }

.bar-mini { height: 5px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.bar-mini i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #b06dff); border-radius: 3px; }

/* --- explicación --------------------------------------------------------- */

.why {
  background: linear-gradient(180deg, var(--accent-soft), transparent);
  border: 1px solid var(--accent-line); border-radius: var(--radius);
  padding: 17px 19px; font-size: 14px; line-height: 1.68; color: var(--text);
}
.why h4 {
  font-size: 10.8px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--accent); margin-bottom: 8px;
}

.callout {
  border-left: 2px solid var(--media); background: var(--media-soft);
  padding: 12px 15px; border-radius: 0 9px 9px 0; font-size: 12.8px; color: var(--text-2);
  line-height: 1.6;
}

/* --- timeline ------------------------------------------------------------ */

.timeline { position: relative; height: 90px; margin: 10px 6px 0; }
.timeline::before {
  content: ""; position: absolute; left: 0; right: 0; top: 40px; height: 1px; background: var(--line);
}
.timeline .dot {
  position: absolute; top: 40px; transform: translate(-50%, -50%);
  border-radius: 50%; background: var(--alta-soft);
  box-shadow: inset 0 0 0 1.5px var(--alta); transition: .16s; cursor: default;
}
.timeline .dot:hover { background: var(--alta); }
.timeline .dot:hover .tip { opacity: 1; }

/* --- grafo --------------------------------------------------------------- */

.graph { width: 100%; height: auto; display: block; }
.graph .link { stroke: var(--line); fill: none; transition: .2s; }
.graph .link.alerta { stroke: var(--alta); opacity: .55; }
.graph .node circle { fill: var(--surface-3); stroke: var(--line); stroke-width: 1.5; }
.graph .node.alerta circle { fill: var(--alta-soft); stroke: var(--alta); }
.graph .node text { fill: var(--text-2); font-size: 11.5px; font-family: var(--sans); }
.graph .node:hover circle { stroke: var(--accent); }
.graph .col-label {
  fill: var(--text-3); font-size: 10.5px; letter-spacing: .1em;
  text-transform: uppercase; font-weight: 650; font-family: var(--sans);
}

/* --- login --------------------------------------------------------------- */

.login { display: grid; grid-template-columns: 1.05fr .95fr; min-height: 100vh; }
@media (max-width: 900px) { .login { grid-template-columns: 1fr; } .login-art { display: none; } }

.login-art {
  position: relative; overflow: hidden; background: var(--bg-deep);
  display: flex; flex-direction: column; justify-content: space-between; padding: 44px;
}
.login-art::before {
  content: ""; position: absolute; inset: -30%;
  background:
    radial-gradient(42% 42% at 22% 28%, rgba(124,140,255,.5), transparent 65%),
    radial-gradient(38% 38% at 76% 66%, rgba(176,109,255,.42), transparent 62%),
    radial-gradient(34% 34% at 58% 18%, rgba(61,220,151,.2), transparent 60%);
  filter: blur(46px); animation: drift 26s ease-in-out infinite alternate;
}
@keyframes drift {
  0%   { transform: translate(-3%, -2%) scale(1); }
  50%  { transform: translate(4%, 3%) scale(1.1); }
  100% { transform: translate(-2%, 5%) scale(1.04); }
}
.login-art::after {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(var(--line-soft) 1px, transparent 1px),
                    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 46px 46px; opacity: .35;
  mask-image: radial-gradient(70% 70% at 50% 50%, #000, transparent);
}
.login-art > * { position: relative; z-index: 2; }
.login-art .lead {
  font-size: 34px; font-weight: 640; letter-spacing: -.035em; line-height: 1.18; max-width: 15ch;
}
.login-art .lead em { font-style: normal; color: var(--accent); }
.login-art .desc { color: var(--text-2); margin-top: 16px; max-width: 40ch; line-height: 1.65; font-size: 14.5px; }
.login-net { position: absolute; inset: 0; z-index: 1; opacity: .5; }
.login-net circle { fill: var(--accent); }
.login-net line { stroke: var(--accent); stroke-width: .8; opacity: .3; }

.login-form { display: grid; place-items: center; padding: 40px; background: var(--bg); }
.login-box { width: 100%; max-width: 348px; }
.login-box h2 { font-size: 23px; letter-spacing: -.03em; }
.login-box .sub { color: var(--text-3); margin: 7px 0 26px; font-size: 13.5px; }

.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 11.5px; font-weight: 600; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .07em; margin-bottom: 7px;
}
.field input, .field textarea, .field select {
  width: 100%; padding: 11px 13px; border-radius: 10px; font-size: 14px;
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  font-family: inherit; transition: .15s;
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3.5px var(--accent-soft);
}
.field input::placeholder { color: var(--text-3); }
.btn-block { width: 100%; justify-content: center; padding: 11px; font-size: 14px; margin-top: 6px; }

.hint-box {
  margin-top: 22px; padding: 12px 14px; border-radius: 10px;
  background: var(--surface-2); border: 1px dashed var(--line);
  font-size: 12.3px; color: var(--text-3); line-height: 1.6;
}
.hint-box b { color: var(--text-2); font-weight: 600; }

.errors { color: var(--alta); font-size: 12.8px; margin-bottom: 14px; background: var(--alta-soft);
  border: 1px solid color-mix(in srgb, var(--alta) 30%, transparent); padding: 10px 13px; border-radius: 9px; }

/* --- varios -------------------------------------------------------------- */

.empty { text-align: center; padding: 54px 20px; color: var(--text-3); }
.empty svg { width: 34px; height: 34px; opacity: .35; margin-bottom: 12px; }
.sep { height: 1px; background: var(--line-soft); }
.stack { display: flex; flex-direction: column; gap: 4px; }
.row { display: flex; align-items: center; gap: 10px; }
.muted { color: var(--text-3); }
.small { font-size: 12.3px; }
.avatar {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line);
  display: grid; place-items: center; font-size: 10.5px; font-weight: 650; color: var(--text-2);
}
.theme-toggle { padding: 7px; border-radius: 9px; }
.theme-toggle svg { width: 15px; height: 15px; }
