/* Centinela - looking glass.
   Tema oscuro deliberado. Paleta de estado validada para contraste >= 3:1
   sobre la superficie; el color nunca es el unico canal: cada estado lleva
   siempre icono y etiqueta de texto. */

:root {
  color-scheme: dark;

  --bg:        #08090c;
  --bg-glow:   #0d1119;
  --surface:   #0e1015;
  --surface-2: #141821;
  --surface-3: #1b2029;

  --line:        rgba(255,255,255,.075);
  --line-strong: rgba(255,255,255,.15);

  --ink:    #e9ebf1;
  --ink-2:  #98a0b1;
  --ink-3:  #626a7b;

  --accent:      #3987e5;
  --accent-soft: rgba(57,135,229,.12);
  --accent-line: rgba(57,135,229,.35);

  --good: #0ca30c;
  --warn: #fab219;
  --crit: #d03b3b;

  --good-soft: rgba(12,163,12,.12);
  --warn-soft: rgba(250,178,25,.11);
  --crit-soft: rgba(208,59,59,.12);

  --r:  10px;
  --r-s: 7px;

  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono { font-family: var(--mono); }
.shell { max-width: 1180px; margin: 0 auto; padding: 0 22px; }

/* ============================================================ cabecera === */
.masthead {
  position: relative;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(900px 320px at 50% -140px, var(--bg-glow), transparent 70%),
    var(--bg);
  overflow: hidden;
}
/* Rejilla tenue: da textura tecnica sin robar atencion */
.masthead::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(600px 220px at 50% 0, #000 20%, transparent 78%);
  opacity: .5;
  pointer-events: none;
}
.masthead .shell { position: relative; padding-top: 26px; padding-bottom: 26px; }

.mast-top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 11px; }
.logo-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(150deg, var(--accent), #1c5cab);
  display: grid; place-items: center;
  box-shadow: 0 0 0 1px var(--accent-line), 0 6px 18px rgba(57,135,229,.22);
}
.logo-mark svg { width: 19px; height: 19px; }
.logo-text .name { font-size: 16px; font-weight: 660; letter-spacing: -.2px; line-height: 1.15; }
.logo-text .kicker {
  font-family: var(--mono); font-size: 10.5px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 1.3px;
}
.mast-top .grow { flex: 1; }

.node-chip {
  display: inline-flex; align-items: center; gap: 9px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 14px 6px 11px;
  font-size: 12.5px; color: var(--ink-2);
}
.node-chip .live {
  width: 7px; height: 7px; border-radius: 50%; background: var(--good);
  box-shadow: 0 0 0 3px rgba(12,163,12,.16);
  animation: breathe 2.6s ease-in-out infinite;
}
@keyframes breathe { 0%,100% { opacity: 1; } 50% { opacity: .45; } }
.node-chip b { color: var(--ink); font-weight: 600; }

.mast-title { margin: 22px 0 0; font-size: 27px; font-weight: 680; letter-spacing: -.7px; }
.mast-sub { margin: 7px 0 0; color: var(--ink-2); font-size: 14.5px; max-width: 62ch; }

.node-facts {
  display: flex; gap: 26px; flex-wrap: wrap;
  margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line);
}
.node-fact .k {
  font-family: var(--mono); font-size: 10px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 1.1px;
}
.node-fact .v { font-size: 13.5px; color: var(--ink); margin-top: 3px; font-weight: 550; }
.node-fact .v.mono { font-family: var(--mono); font-size: 12.5px; }

/* ========================================================= herramientas === */
main { padding: 30px 0 70px; }

.section-label {
  font-family: var(--mono); font-size: 10px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 1.4px;
  margin: 0 0 12px; display: flex; align-items: center; gap: 10px;
}
.section-label::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}

.tool-groups { display: grid; gap: 22px; }
.tool-grid {
  display: grid; gap: 9px;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
}

.tool {
  position: relative; display: flex; gap: 11px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 13px 14px;
  cursor: pointer; text-align: left; width: 100%;
  font-family: inherit; color: inherit;
  transition: border-color .14s, background .14s, transform .14s;
}
.tool:hover { border-color: var(--line-strong); background: var(--surface-2); }
.tool:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tool[aria-pressed="true"] {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}
.tool[aria-pressed="true"]::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: -1px;
  height: 2px; background: var(--accent); border-radius: 2px;
}
.tool .ico {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 8px;
  background: var(--surface-3); display: grid; place-items: center;
  border: 1px solid var(--line);
}
.tool[aria-pressed="true"] .ico { background: rgba(57,135,229,.18); border-color: var(--accent-line); }
.tool .ico svg { width: 15px; height: 15px; stroke: var(--ink-2); }
.tool[aria-pressed="true"] .ico svg { stroke: #8fbdf3; }
.tool .body { min-width: 0; }
.tool .t { font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.tool .d { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; line-height: 1.45; }

/* ============================================================= consulta === */
.query {
  margin-top: 26px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 16px;
}
.query-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px; flex-wrap: wrap;
}
.query-head .active-tool {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600;
}
.query-head .active-tool svg { width: 14px; height: 14px; stroke: var(--accent); }
.query-head .active-desc { color: var(--ink-3); font-size: 12.5px; }

.query-row { display: flex; gap: 9px; align-items: stretch; flex-wrap: wrap; }
.field-wrap { position: relative; flex: 1 1 260px; min-width: 0; }
.field-wrap .prefix {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  font-family: var(--mono); color: var(--ink-3); font-size: 13px; pointer-events: none;
}

input[type=text], input[type=number], select {
  width: 100%; background: var(--bg); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--r-s);
  padding: 11px 13px; font-size: 14px; font-family: var(--mono);
  transition: border-color .14s, box-shadow .14s;
}
#target { padding-left: 30px; }
input:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder { color: var(--ink-3); }
select { font-family: var(--sans); cursor: pointer; }
.opt-field { flex: 0 0 132px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--r-s); border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--ink);
  padding: 11px 18px; font-size: 13.5px; font-weight: 600;
  font-family: inherit; cursor: pointer; white-space: nowrap;
  transition: background .14s, border-color .14s, opacity .14s;
}
.btn:hover:not(:disabled) { background: var(--surface-3); border-color: var(--line-strong); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
  box-shadow: 0 4px 14px rgba(57,135,229,.24);
}
.btn-primary:hover:not(:disabled) { background: #2a78d6; border-color: #2a78d6; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink-2); padding: 7px 12px; font-size: 12.5px; font-weight: 500; }
.btn-ghost:hover { color: var(--ink); background: var(--surface-2); }

.captcha-row {
  display: flex; align-items: center; gap: 11px; flex-wrap: wrap;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line);
}
.captcha-row label { font-size: 13px; color: var(--ink-2); }
.captcha-row .q { color: var(--ink); font-weight: 600; font-family: var(--mono); }
.captcha-row input { width: 90px; text-align: center; flex: 0 0 auto; }

.hintline {
  margin-top: 11px; font-size: 11.5px; color: var(--ink-3);
  display: flex; gap: 14px; flex-wrap: wrap; align-items: center;
}
kbd {
  font-family: var(--mono); font-size: 10.5px; background: var(--surface-3);
  border: 1px solid var(--line-strong); border-bottom-width: 2px;
  border-radius: 4px; padding: 1px 5px; color: var(--ink-2);
}

/* ============================================================ resultados == */
.results { margin-top: 24px; display: grid; gap: 13px; }

.result-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding-bottom: 13px; border-bottom: 1px solid var(--line);
}
.result-head .title { font-size: 15.5px; font-weight: 640; }
.result-head .target { font-family: var(--mono); color: var(--ink-2); font-size: 13px; }
.result-head .grow { flex: 1; }
.result-head .timing {
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-3);
  display: flex; gap: 12px; align-items: center;
}

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); overflow: hidden;
}
.card > h3 {
  margin: 0; padding: 12px 16px;
  font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  color: var(--ink-2); text-transform: uppercase; letter-spacing: 1.2px;
  border-bottom: 1px solid var(--line); background: var(--surface-2);
  display: flex; align-items: center; gap: 9px;
}
.card.st-good > h3 { border-left: 2px solid var(--good); }
.card.st-warn > h3 { border-left: 2px solid var(--warn); }
.card.st-crit > h3 { border-left: 2px solid var(--crit); }

/* Filas clave/valor */
.kv-row {
  display: grid; grid-template-columns: minmax(140px, 240px) 1fr;
  gap: 14px; padding: 10px 16px; border-bottom: 1px solid rgba(255,255,255,.045);
  align-items: baseline;
}
.kv-row:last-child { border-bottom: 0; }
.kv-row .k { color: var(--ink-3); font-size: 12.5px; }
.kv-row .v { font-size: 13.5px; overflow-wrap: anywhere; font-family: var(--mono); }
.kv-row .note { display: block; color: var(--ink-3); font-size: 11.5px; margin-top: 3px; font-family: var(--sans); }
@media (max-width: 620px) { .kv-row { grid-template-columns: 1fr; gap: 2px; } }

/* Indicador de estado: siempre icono + texto, nunca color a secas */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 650; padding: 2px 8px;
  border-radius: 5px; border: 1px solid transparent;
  font-family: var(--sans); letter-spacing: .2px; white-space: nowrap;
}
.pill .g { font-size: 10px; line-height: 1; }
.pill-good { background: var(--good-soft); color: #4ec94e; border-color: rgba(12,163,12,.32); }
.pill-warn { background: var(--warn-soft); color: #f6c453; border-color: rgba(250,178,25,.3); }
.pill-crit { background: var(--crit-soft); color: #ef8b8b; border-color: rgba(208,59,59,.34); }

/* Bloque de nota */
.scoreblock {
  display: flex; align-items: center; gap: 20px; padding: 20px 16px; flex-wrap: wrap;
}
.grade {
  flex-shrink: 0; min-width: 76px; height: 76px; padding: 0 14px;
  border-radius: 12px; display: grid; place-items: center;
  font-size: 30px; font-weight: 750; letter-spacing: -1px;
  border: 1px solid;
}
.grade.st-good { background: var(--good-soft); color: #4ec94e; border-color: rgba(12,163,12,.3); }
.grade.st-warn { background: var(--warn-soft); color: #f6c453; border-color: rgba(250,178,25,.28); }
.grade.st-crit { background: var(--crit-soft); color: #ef8b8b; border-color: rgba(208,59,59,.3); }
.grade.sm { font-size: 20px; min-width: 66px; height: 66px; }
.scoreblock .meta { min-width: 180px; flex: 1; }
.scoreblock .meta .lead { font-size: 14.5px; font-weight: 600; }
.scoreblock .meta .sub { color: var(--ink-2); font-size: 12.5px; margin-top: 3px; }
.meter { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; margin-top: 11px; }
.meter i { display: block; height: 100%; border-radius: 3px; }
.meter i.st-good { background: var(--good); }
.meter i.st-warn { background: var(--warn); }
.meter i.st-crit { background: var(--crit); }

/* Etiquetas */
.tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 14px 16px; }
.tag {
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-2);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 5px; padding: 3px 8px;
}

/* Salida cruda */
.raw { border-top: 1px solid var(--line); }
.raw summary {
  cursor: pointer; padding: 11px 16px; list-style: none;
  font-family: var(--mono); font-size: 10.5px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 1.2px;
  display: flex; align-items: center; gap: 8px;
}
.raw summary::-webkit-details-marker { display: none; }
.raw summary::before { content: "▸"; font-size: 11px; transition: transform .15s; }
.raw[open] summary::before { transform: rotate(90deg); }
.raw summary:hover { color: var(--ink-2); }
.raw pre {
  margin: 0; padding: 0 16px 16px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.6;
  white-space: pre-wrap; overflow-x: auto; color: #cbd0da;
}

/* Estados de la zona de resultados */
.placeholder {
  border: 1px dashed var(--line-strong); border-radius: var(--r);
  padding: 44px 24px; text-align: center; color: var(--ink-3);
}
.placeholder svg { width: 30px; height: 30px; stroke: var(--ink-3); opacity: .6; }
.placeholder p { margin: 12px 0 0; font-size: 13.5px; }

.banner {
  border-radius: var(--r); padding: 13px 15px; font-size: 13.5px;
  display: flex; gap: 10px; align-items: flex-start; border: 1px solid;
}
.banner.err  { background: var(--crit-soft); border-color: rgba(208,59,59,.3); color: #f0a6a6; }
.banner.warn { background: var(--warn-soft); border-color: rgba(250,178,25,.28); color: #f6c453; }
.banner b { color: var(--ink); }

.spinner {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.3); border-top-color: #fff;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.scanning { display: flex; align-items: center; gap: 12px; padding: 22px 16px; color: var(--ink-2); font-size: 13.5px; }
.scanbar { height: 2px; background: var(--surface-3); border-radius: 2px; overflow: hidden; margin-top: 10px; }
.scanbar i {
  display: block; height: 100%; width: 32%; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: sweep 1.15s ease-in-out infinite;
}
@keyframes sweep { 0% { transform: translateX(-110%); } 100% { transform: translateX(340%); } }

/* ============================================================= historial == */
.history { margin-top: 30px; }
.history-list { display: grid; gap: 6px; }
.hitem {
  display: flex; align-items: center; gap: 11px; width: 100%;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-s); padding: 9px 13px;
  font-family: inherit; color: inherit; cursor: pointer; text-align: left;
  transition: border-color .14s, background .14s;
}
.hitem:hover { border-color: var(--line-strong); background: var(--surface-2); }
.hitem .tool-name { font-size: 12.5px; font-weight: 600; min-width: 118px; }
.hitem .tgt { font-family: var(--mono); font-size: 12.5px; color: var(--ink-2); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hitem .when { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }

/* ================================================================ pie ===== */
.foot {
  margin-top: 46px; padding-top: 24px; border-top: 1px solid var(--line);
  display: grid; gap: 22px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}
.foot h4 {
  margin: 0 0 8px; font-family: var(--mono); font-size: 10px;
  color: var(--ink-3); text-transform: uppercase; letter-spacing: 1.2px;
}
.foot p, .foot li { color: var(--ink-2); font-size: 12.5px; margin: 0; line-height: 1.65; }
.foot ul { margin: 0; padding-left: 16px; }
.foot-bottom {
  margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  color: var(--ink-3); font-size: 12px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
