/* ============================================================
   VicoGuard AI — Design System (implementa web/DESIGN_SYSTEM.md)
   Estética editorial-técnica. Ink frío + paper cálido, azul de marca,
   severidad semántica, tipografía Fraunces / IBM Plex Sans / IBM Plex Mono.
   ============================================================ */

:root {
  /* — Base: Ink (frío) — */
  --bg:        #0A0C11;
  --bg-1:      #0E121A;
  --surface:   #131820;
  --surface-1: #171D27;
  --surface-2: #1D242F;
  --line:      #262D39;
  --line-2:    #333B49;

  /* — Texto: Paper (cálido) — */
  --paper:    #F6F3ED;
  --text:     #E6E2DA;
  --text-dim: #9D988F;
  --text-mut: #6E6A63;

  /* — Marca: Signal Blue — */
  --blue:        #4C86FF;
  --blue-bright: #6EA0FF;
  --blue-deep:   #3A6DEB;
  --on-blue:     #081428;
  --blue-tint:   rgba(76,134,255,.14);
  --blue-line:   rgba(76,134,255,.38);

  /* — Severidad (semántico) — */
  --critical: #FF6B6B; --critical-tint: rgba(255,107,107,.10); --critical-line: rgba(255,107,107,.34);
  --high:     #FF9145; --high-tint:     rgba(255,145,69,.10);  --high-line:     rgba(255,145,69,.32);
  --medium:   #F4C24E; --medium-tint:   rgba(244,194,78,.10);  --medium-line:   rgba(244,194,78,.30);
  --low:      #7FB0FF; --low-tint:      rgba(127,176,255,.10); --low-line:      rgba(127,176,255,.30);
  --secure:   #46D3A0; --secure-tint:   rgba(70,211,160,.10);  --secure-line:   rgba(70,211,160,.32);

  /* — Radio / elevación — */
  --r-lg: 14px; --r: 11px; --r-sm: 8px;
  --shadow-1: 0 1px 0 rgba(255,255,255,.03) inset, 0 1px 2px rgba(0,0,0,.45);
  --shadow-2: 0 10px 34px rgba(0,0,0,.38);

  /* — Tipografía — */
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-sans: "IBM Plex Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;

  --fs-display: clamp(38px, 5vw, 52px);
  --fs-h1: 28px; --fs-h2: 19px; --fs-h3: 15px;
  --fs-body: 15px; --fs-small: 13px; --fs-micro: 11.5px;

  /* Alias de compatibilidad (marcado antiguo usa --accent / --border) */
  --accent: var(--secure);
  --border: var(--line);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-variant-numeric: tabular-nums;
}
::selection { background: var(--blue-tint); color: var(--paper); }
a { color: var(--blue-bright); text-decoration: none; }
a:hover { color: #8fb5ff; }
h1, h2, h3 { margin: 0; color: var(--paper); font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; }
p { margin: 0; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 999px; border: 3px solid var(--bg); }
*::-webkit-scrollbar-track { background: transparent; }

:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--blue-tint); border-radius: 8px; }

/* ---------- Layout ---------- */
.container { max-width: 1140px; margin: 0 auto; padding: 0 24px; }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; }
.grow { flex: 1; }
.muted { color: var(--text-dim); }
.mono { font-family: var(--font-mono); }
.small { font-size: var(--fs-small); }
.mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; } .mb-8 { margin-bottom: 8px; }

.eyebrow {
  font-size: var(--fs-micro); text-transform: uppercase; letter-spacing: .09em;
  color: var(--text-mut); font-weight: 600;
}

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 11px; }
.brand .mark {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  background: linear-gradient(155deg, var(--blue-bright), var(--blue-deep));
  box-shadow: 0 1px 0 rgba(255,255,255,.22) inset, 0 2px 8px rgba(58,109,235,.35);
  display: grid; place-items: center; color: var(--on-blue);
  font-family: var(--font-display); font-weight: 600; font-size: 16px;
}
.brand .name { font-size: 16px; color: var(--text-dim); font-weight: 500; letter-spacing: -0.01em; }
.brand .name b { color: var(--paper); font-weight: 600; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(10,12,17,.72); backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar .inner { height: 62px; display: flex; align-items: center; gap: 22px; }
.nav { display: flex; gap: 4px; }
.nav a {
  color: var(--text-dim); font-size: 14px; padding: 7px 12px; border-radius: 8px; font-weight: 500;
}
.nav a:hover { color: var(--paper); background: var(--surface); }
.nav a.active { color: var(--paper); background: var(--surface); }
.usermenu { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2);
  border: 1px solid var(--blue-line); display: grid; place-items: center;
  font-size: 13px; font-weight: 600; color: var(--blue-bright);
}

/* ---------- Buttons ---------- */
.btn {
  appearance: none; border: 1px solid var(--line-2); background: var(--surface);
  color: var(--text); font: inherit; font-size: 14px; font-weight: 550;
  padding: 9px 16px; border-radius: var(--r); cursor: pointer;
  transition: background .16s, border-color .16s, transform .06s;
  display: inline-flex; align-items: center; gap: 8px;
}
.btn:hover { background: var(--surface-1); border-color: var(--line-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: var(--blue); color: var(--on-blue); border-color: transparent; font-weight: 600;
  box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 4px 14px rgba(58,109,235,.28);
}
.btn-primary:hover { background: var(--blue-deep); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--surface); color: var(--paper); }
.btn-block { width: 100%; justify-content: center; padding: 12px; }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: var(--fs-small); color: var(--text-dim); font-weight: 500; }
.input {
  width: 100%; background: var(--bg-1); border: 1px solid var(--line);
  color: var(--paper); font: inherit; font-size: 14px; padding: 11px 13px; border-radius: var(--r);
  transition: border-color .16s, box-shadow .16s;
}
.input::placeholder { color: var(--text-mut); }
.input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-tint); }
input[type="checkbox"] { accent-color: var(--blue); width: 15px; height: 15px; }

/* ---------- Cards ---------- */
.card {
  position: relative; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 22px; box-shadow: var(--shadow-1);
}
.card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 1px; border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent);
}
.card h2 { font-size: var(--fs-h2); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.card-head h2 { margin-top: 4px; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi {
  position: relative; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 18px; box-shadow: var(--shadow-1);
}
.kpi .label { font-size: var(--fs-small); color: var(--text-dim); display: flex; align-items: center; gap: 8px; }
.kpi .value {
  font-family: var(--font-display); font-optical-sizing: auto;
  font-size: 34px; font-weight: 550; letter-spacing: -0.02em; margin-top: 8px; color: var(--paper);
  line-height: 1.05;
}
.kpi .sub { font-size: var(--fs-micro); color: var(--text-mut); margin-top: 4px; letter-spacing: .01em; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

/* ---------- Score ring ---------- */
.score-wrap { display: flex; align-items: center; gap: 22px; }
.ring { position: relative; width: 124px; height: 124px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring circle { transition: stroke-dashoffset .8s cubic-bezier(.2,.8,.2,1), stroke .3s; }
.ring .num {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--font-display); font-size: 34px; font-weight: 560; letter-spacing: -0.02em;
}

/* ---------- Chips ---------- */
.chip {
  font-size: var(--fs-micro); font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line-2);
  color: var(--text-dim); background: var(--surface-2); white-space: nowrap;
}
.chip.critical { color: var(--critical); border-color: var(--critical-line); background: var(--critical-tint); }
.chip.high     { color: var(--high);     border-color: var(--high-line);     background: var(--high-tint); }
.chip.medium   { color: var(--medium);   border-color: var(--medium-line);   background: var(--medium-tint); }
.chip.low      { color: var(--low);      border-color: var(--low-line);      background: var(--low-tint); }
.chip.secure   { color: var(--secure);   border-color: var(--secure-line);   background: var(--secure-tint); }

/* ---------- Findings ---------- */
.finding { border: 1px solid var(--line); border-radius: var(--r); padding: 15px 17px; background: var(--bg-1); }
.finding + .finding { margin-top: 10px; }
.finding .title { font-weight: 600; font-size: 14px; color: var(--paper); }
.finding .desc { color: var(--text-dim); font-size: var(--fs-small); margin-top: 5px; }
.finding pre {
  margin: 12px 0 0; background: #07090D; border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 12px 14px; overflow-x: auto;
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6; color: #bfe3d3;
}

/* ---------- Live terminal ---------- */
.terminal {
  background: #07090D; border: 1px solid var(--line); border-radius: var(--r-lg);
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.75;
  padding: 15px 17px; height: 320px; overflow-y: auto;
}
.log { display: flex; gap: 12px; align-items: baseline; padding: 1px 0; }
.log .t { color: var(--text-mut); flex: none; }
.log .a { flex: none; color: var(--text-mut); min-width: 94px; letter-spacing: .02em; }
.log .m { color: var(--text-dim); }
.log.OK .m { color: var(--secure); }
.log.WARN .m { color: var(--high); }
.log.ALERT .m { color: var(--critical); }
.log.REASONING .m { color: #a9b6ff; }

/* ---------- Auth ---------- */
.auth { min-height: 100%; display: grid; grid-template-columns: 1.05fr .95fr; }
.auth .panel { display: flex; align-items: center; justify-content: center; padding: 40px; }
.auth .form-card { width: 100%; max-width: 384px; }
.auth .form-card h1 { font-family: var(--font-display); font-optical-sizing: auto; font-size: var(--fs-h1); font-weight: 560; letter-spacing: -0.02em; margin-bottom: 6px; }
.auth .form-card .sub { color: var(--text-dim); margin-bottom: 22px; font-size: 14px; }
.auth .aside {
  position: relative; overflow: hidden; border-left: 1px solid var(--line);
  padding: 52px; display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(130% 90% at 100% 0%, rgba(76,134,255,.12), transparent 55%),
    linear-gradient(180deg, #0C1017, #090B10);
}
.auth .aside::before { /* retícula fina */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 34px 34px;
  -webkit-mask-image: radial-gradient(80% 60% at 70% 30%, #000, transparent 75%);
          mask-image: radial-gradient(80% 60% at 70% 30%, #000, transparent 75%);
}
.auth .aside > * { position: relative; }
.auth .aside .quote {
  font-family: var(--font-display); font-optical-sizing: auto;
  font-size: 25px; font-weight: 420; line-height: 1.32; letter-spacing: -0.01em;
  color: var(--paper); max-width: 440px;
}
.auth .aside .quote span { color: var(--blue-bright); font-style: italic; }
.feature { display: flex; gap: 12px; align-items: flex-start; margin-top: 20px; }
.feature .ic { color: var(--blue-bright); flex: none; margin-top: 3px; font-size: 12px; }
.feature .ft-t { font-weight: 600; font-size: 14px; color: var(--paper); }
.feature .ft-d { color: var(--text-dim); font-size: var(--fs-small); }

.alert-error {
  background: var(--critical-tint); border: 1px solid var(--critical-line);
  color: #ffb0b0; padding: 10px 13px; border-radius: var(--r); font-size: var(--fs-small); display: none;
}
.alert-error.show { display: block; }
.divider { height: 1px; background: var(--line); margin: 20px 0; }
.empty { text-align: center; color: var(--text-mut); padding: 40px 20px; font-size: 14px; }

/* ---------- Grid / responsive ---------- */
.grid-2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

/* ---------- Finding actions (enviar remediación) ---------- */
.finding-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.btn-xs {
  font-size: var(--fs-small); padding: 6px 11px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text-dim);
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: .15s;
}
.btn-xs:hover { background: var(--surface-1); color: var(--paper); }
.btn-xs:disabled { opacity: .5; cursor: default; }
.btn-xs.sent { color: var(--secure); border-color: var(--secure-line); background: var(--secure-tint); }

/* ---------- Topología (grafo) ---------- */
.topo-wrap { position: relative; width: 100%; overflow: hidden; border-radius: var(--r); background: #07090D; border: 1px solid var(--line); }
.topo-wrap svg { display: block; width: 100%; height: auto; }
.topo-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 14px; }
.topo-legend .item { display: flex; align-items: center; gap: 7px; font-size: var(--fs-small); color: var(--text-dim); }
.topo-node-label { font-family: var(--font-mono); font-size: 10.5px; fill: var(--text-dim); }
.topo-hub-label { font-family: var(--font-sans); font-size: 12px; font-weight: 600; fill: var(--paper); }
.topo-edge { stroke: var(--line-2); stroke-width: 1.2; opacity: .55; }
.topo-tip {
  position: absolute; pointer-events: none; background: var(--surface-2); border: 1px solid var(--line-2);
  color: var(--paper); font-size: 12px; padding: 7px 10px; border-radius: 8px; max-width: 260px;
  box-shadow: var(--shadow-2); opacity: 0; transition: opacity .12s; z-index: 5;
}
.topo-tip .k { color: var(--text-mut); font-family: var(--font-mono); font-size: 11px; }
@media (max-width: 820px) {
  .auth { grid-template-columns: 1fr; }
  .auth .aside { display: none; }
}
