/*
 * Producto: Espinaltech Security Report (panel interno B2B)
 * Tipo: Web App + Dashboard Operativo
 * Paleta aprobada por Daniel 2026-05-09:
 *   off-white #FAFAF7  fondo
 *   sidebar  #FFFFFF  blanco con borde 1px (CLARO, no oscuro)
 *   texto    #0A0A0A  / #525252 metadata
 *   acento   #B45309  ámbar quemado (auditoría/inspección)
 *   crítico  #9B2C2C  rojo brick
 * Look: Linear / Stripe Dashboard / Mercury. Sin terminal-tech.
 * Tipografía: Inter pura. JetBrains Mono SOLO en AUD-IDs y timestamps.
 */

/* ============================================================
   1. TOKENS
   ============================================================ */
:root {
  --bg:           #FAFAF7;
  --surface:      #FFFFFF;
  --surface-alt:  #F4F4F1;
  --line:         #E8E5DD;
  --line-strong:  #D6D2C7;

  --ink:          #0A0A0A;
  --ink-700:      #2A2A28;
  --ink-500:      #525252;
  --ink-400:      #737373;
  --ink-300:      #A3A3A3;
  --ink-200:      #D4D4D4;

  --accent:       #B45309;
  --accent-soft:  #FEF7EC;
  --accent-line:  #F5DDB5;
  --accent-700:   #92400E;

  --critical:     #9B2C2C;
  --critical-soft:#FDEEEE;
  --critical-line:#F5C2C2;
  --high:         #C2410C;
  --high-soft:    #FFF1E5;
  --medium:       #A16207;
  --medium-soft:  #FEF6D8;
  --low:          #3F3F46;
  --low-soft:     #F4F4F5;
  --info:         #525252;
  --success:      #15803D;
  --success-soft: #ECF7EF;

  --shadow-1: 0 1px 2px rgba(20, 20, 18, 0.04);
  --shadow-2: 0 1px 2px rgba(20, 20, 18, 0.04), 0 4px 12px rgba(20, 20, 18, 0.04);
  --shadow-3: 0 1px 2px rgba(20, 20, 18, 0.04), 0 8px 24px rgba(20, 20, 18, 0.06);
  --shadow-modal: 0 1px 2px rgba(20, 20, 18, 0.06), 0 24px 60px rgba(20, 20, 18, 0.14);

  --radius-sm: 4px;
  --radius:    8px;
  --radius-lg: 10px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

/* ============================================================
   2. RESET MÍNIMO
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
  font-feature-settings: "ss01", "cv11";
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; padding: 0; color: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; letter-spacing: -0.025em; color: var(--ink); }
ul { list-style: none; margin: 0; padding: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ============================================================
   3. APP SHELL
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas:
    "topbar topbar"
    "sidebar main";
  min-height: 100vh;
}

/* ---- Topbar ---- */
.topbar {
  grid-area: topbar;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 232px 1fr auto;
  align-items: center;
  position: sticky; top: 0; z-index: 30;
}
.topbar__brand {
  display: flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 18px;
  border-right: 1px solid var(--line);
}
.topbar__brand-mark {
  width: 26px; height: 26px;
  background: var(--ink); color: var(--bg);
  border-radius: 6px;
  font-weight: 600; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: -0.02em;
}
.topbar__brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.topbar__brand-name {
  font-size: 13.5px; font-weight: 600; color: var(--ink);
  letter-spacing: -0.015em;
}
.topbar__brand-sub {
  font-size: 11px; color: var(--ink-400);
  letter-spacing: 0;
}

.topbar__center { padding: 0 22px; }
.topbar__search {
  width: 100%; max-width: 360px;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 11px;
  color: var(--ink-400);
  font-size: 13px;
  transition: border-color .15s, background .15s;
}
.topbar__search:hover { border-color: var(--line-strong); background: var(--surface); }
.topbar__search svg { flex-shrink: 0; }
.topbar__search-kbd {
  margin-left: auto;
  font-family: var(--font-mono); font-size: 11px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--ink-400);
}

.topbar__user {
  display: flex; align-items: center; gap: 12px;
  padding: 0 18px;
}
.topbar__user-name {
  font-size: 13px; font-weight: 500; color: var(--ink-700);
}
.topbar__user-avatar {
  width: 28px; height: 28px;
  background: var(--accent-soft); color: var(--accent-700);
  border: 1px solid var(--accent-line);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.02em;
}
.topbar__logout {
  font-size: 12.5px; color: var(--ink-500);
  padding: 6px 9px; border-radius: var(--radius-sm);
  transition: color .15s, background .15s;
}
.topbar__logout:hover { color: var(--critical); background: var(--critical-soft); }

/* ---- Sidebar (CLARO) ---- */
.sidebar {
  grid-area: sidebar;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  position: sticky; top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
  display: flex; flex-direction: column;
}
.sidebar__group { margin-bottom: 20px; }
.sidebar__group-label {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-400);
  padding: 0 10px 8px;
}
.sidebar__nav { display: flex; flex-direction: column; gap: 1px; }
.sidebar__nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  font-size: 13.5px; font-weight: 500;
  color: var(--ink-700);
  border-radius: var(--radius-sm);
  position: relative;
  transition: background .12s, color .12s;
}
.sidebar__nav a:hover { background: var(--surface-alt); color: var(--ink); }
.sidebar__nav a.is-active {
  background: var(--accent-soft);
  color: var(--accent-700);
}
.sidebar__nav a.is-active::before {
  content: ""; position: absolute;
  left: -14px; top: 7px; bottom: 7px; width: 2px;
  background: var(--accent); border-radius: 0 2px 2px 0;
}
.sidebar__nav-icon {
  width: 15px; height: 15px; flex-shrink: 0;
  color: var(--ink-400);
}
.sidebar__nav a:hover .sidebar__nav-icon { color: var(--ink-700); }
.sidebar__nav a.is-active .sidebar__nav-icon { color: var(--accent); }
.sidebar__nav a .count {
  margin-left: auto;
  font-size: 11px; font-weight: 500;
  color: var(--ink-400);
  background: var(--surface-alt);
  border-radius: 9999px; padding: 1px 7px;
}
.sidebar__nav a.is-active .count {
  background: var(--surface); color: var(--accent-700);
}

.sidebar__footer {
  margin-top: auto;
  padding: 14px 10px 0;
  border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--ink-400);
}
.sidebar__footer-row { display: flex; justify-content: space-between; padding: 3px 0; }

/* ---- Main ---- */
.main {
  grid-area: main;
  padding: 28px 36px 60px;
  max-width: 1440px; width: 100%;
}

.pageheader {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.pageheader__title {
  font-size: 28px; font-weight: 600;
  letter-spacing: -0.025em;
  margin: 0;
}
.pageheader__sub {
  font-size: 13.5px; color: var(--ink-500);
  margin-top: 4px;
}
.pageheader__actions { display: flex; gap: 8px; flex-shrink: 0; padding-top: 4px; }

/* ============================================================
   4. BOTONES
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  font-family: inherit;
  white-space: nowrap;
}
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(180, 83, 9, 0.18);
}
.btn--primary {
  background: var(--ink); color: var(--surface);
}
.btn--primary:hover { background: var(--ink-700); }
.btn--accent {
  background: var(--accent); color: white;
  font-weight: 500;
}
.btn--accent:hover { background: var(--accent-700); }
.btn--ghost {
  background: var(--surface); color: var(--ink-700);
  border-color: var(--line);
}
.btn--ghost:hover { background: var(--surface-alt); border-color: var(--line-strong); }

.btn svg { flex-shrink: 0; }

/* ============================================================
   5. KPI HERO + STAT ROW (asimétrico, técnica #1 + #2 + #3)
   ============================================================ */
.kpi-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 14px;
  margin-bottom: 22px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  position: relative;
  transition: border-color .15s, box-shadow .15s;
}
.kpi:hover { border-color: var(--line-strong); box-shadow: var(--shadow-1); }

.kpi__label {
  font-size: 11.5px; font-weight: 500;
  color: var(--ink-500);
  letter-spacing: 0.005em;
  display: flex; align-items: center; gap: 6px;
}
.kpi__icon {
  width: 14px; height: 14px; color: var(--ink-300);
}
.kpi__value {
  font-size: 32px; font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin: 10px 0 6px;
  line-height: 1.05;
}
.kpi__delta {
  font-size: 12px; color: var(--ink-400);
}
.kpi__delta--up   { color: var(--success); }
.kpi__delta--down { color: var(--critical); }

/* hero variant — más grande, asimétrica */
.kpi--hero { padding: 22px 24px 20px; }
.kpi--hero .kpi__value {
  font-size: 60px;
  margin: 14px 0 6px;
  letter-spacing: -0.04em;
}
.kpi--hero .kpi__spark {
  display: flex; align-items: flex-end; gap: 3px;
  height: 28px; margin-top: 12px;
}
.kpi--hero .kpi__spark span {
  width: 6px;
  background: var(--accent);
  border-radius: 1px;
  opacity: 0.85;
}
.kpi--hero .kpi__spark span:nth-child(odd) { opacity: 0.4; }
.kpi--hero .kpi__foot {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 12px; color: var(--ink-500);
}

/* ============================================================
   6. PANEL / CARD
   ============================================================ */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.panel__head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
}
.panel__title {
  font-size: 14px; font-weight: 600; color: var(--ink);
  letter-spacing: -0.01em;
}
.panel__action {
  font-size: 12.5px; font-weight: 500;
  color: var(--accent-700);
}
.panel__action:hover { color: var(--accent); }
.panel__body--p { padding: 18px 22px; }

/* ============================================================
   7. TABLA
   ============================================================ */
.tbl { width: 100%; border-collapse: collapse; }
.tbl thead th {
  font-size: 11.5px; font-weight: 500;
  color: var(--ink-500);
  text-align: left;
  padding: 10px 22px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--line);
  letter-spacing: 0;
}
.tbl tbody td {
  padding: 13px 22px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px; color: var(--ink-700);
  vertical-align: middle;
}
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover td { background: var(--bg); }

.tbl .id {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-500);
}
.tbl .target {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-700);
  max-width: 320px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tbl .ts {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-400);
}

/* ============================================================
   8. SEVERITY PILLS
   ============================================================ */
.sev {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  font-size: 11.5px; font-weight: 500;
  border-radius: 4px;
  border: 1px solid transparent;
  letter-spacing: 0;
}
.sev::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: currentColor; opacity: 0.85;
}
.sev--critical { color: var(--critical); background: var(--critical-soft); border-color: var(--critical-line); }
.sev--high     { color: var(--high);     background: var(--high-soft); }
.sev--medium   { color: var(--medium);   background: var(--medium-soft); }
.sev--low      { color: var(--low);      background: var(--low-soft); }
.sev--info     { color: var(--info);     background: var(--low-soft); }
.sev--none     { color: var(--success);  background: var(--success-soft); }

/* ============================================================
   9. EMPTY STATE
   ============================================================ */
.empty {
  text-align: center;
  padding: 56px 24px;
}
.empty__icon {
  width: 44px; height: 44px;
  margin: 0 auto 14px;
  color: var(--ink-300);
}
.empty__title {
  font-size: 15px; font-weight: 600; color: var(--ink);
  margin-bottom: 4px;
}
.empty__text {
  font-size: 13.5px; color: var(--ink-500);
  max-width: 380px; margin: 0 auto;
}

/* ============================================================
   10. AUTH (login)
   ============================================================ */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  background: var(--bg);
}
.auth__form {
  display: flex; flex-direction: column;
  justify-content: center;
  padding: 60px 64px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.auth__brand {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 56px;
}
.auth__brand-mark {
  width: 32px; height: 32px;
  background: var(--ink); color: var(--bg);
  border-radius: 8px;
  font-weight: 600; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: -0.02em;
}
.auth__brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.auth__brand-name { font-size: 14px; font-weight: 600; color: var(--ink); }
.auth__brand-sub { font-size: 12px; color: var(--ink-500); }

.auth__title {
  font-size: 28px; font-weight: 600;
  letter-spacing: -0.025em;
  margin-bottom: 6px;
}
.auth__lead {
  font-size: 14.5px; color: var(--ink-500);
  margin-bottom: 32px;
  max-width: 380px;
}
.auth__panel { max-width: 380px; width: 100%; }
.auth__error {
  display: flex; align-items: center; gap: 8px;
  background: var(--critical-soft);
  border: 1px solid var(--critical-line);
  color: var(--critical);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
}
.auth__foot {
  margin-top: 28px;
  font-size: 12px; color: var(--ink-400);
}

.auth__aside {
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 60px 64px;
  background: var(--surface-alt);
  position: relative;
  overflow: hidden;
}
.auth__aside-quote {
  font-size: 22px; font-weight: 500;
  color: var(--ink);
  line-height: 1.4;
  letter-spacing: -0.02em;
  max-width: 480px;
}
.auth__aside-quote em {
  font-style: normal;
  color: var(--accent-700);
  background: var(--accent-soft);
  padding: 0 4px; border-radius: 3px;
}
.auth__aside-meta {
  display: flex; gap: 32px;
  font-size: 12.5px; color: var(--ink-500);
}
.auth__aside-meta strong {
  display: block; font-size: 22px; color: var(--ink);
  font-weight: 600; letter-spacing: -0.02em;
  margin-bottom: 2px;
}
.auth__aside-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 32px 32px;
  background-position: -1px -1px;
  opacity: 0.5;
  pointer-events: none;
  mask-image: radial-gradient(ellipse 70% 50% at 70% 30%, black 30%, transparent 70%);
}

/* ============================================================
   11. FORM
   ============================================================ */
.field { margin-bottom: 14px; }
.field__label {
  display: block;
  font-size: 12.5px; font-weight: 500;
  color: var(--ink-700);
  margin-bottom: 6px;
}
.field__input,
.field__select,
.field__textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--surface);
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.field__input:focus,
.field__select:focus,
.field__textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(180, 83, 9, 0.14);
}
.btn--block { width: 100%; justify-content: center; padding: 11px 16px; font-size: 13.5px; }

/* ============================================================
   12. RESPONSIVE
   ============================================================ */
@media (max-width: 1100px) {
  .kpi-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth__aside { display: none; }
  .auth__form { border-right: none; padding: 40px 28px; }
}
@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
  .topbar { grid-template-columns: 1fr auto; }
  .topbar__brand { display: none; }
  .topbar__center { display: none; }
  .sidebar { display: none; }
  .main { padding: 20px 16px 40px; }
  .kpi-row { grid-template-columns: 1fr; }
  .pageheader { flex-direction: column; }
}
