/* =============================================================
   Vision 360 — "Ámbar Sereno" Design System  (ver. DESIGN.md)
   Consola SOC · oscuro cálido + glass · paleta ADV · modo Operate
   THESIS: instrumento de precisión sereno; oscuro espresso (no negro
   neón), glass en capas, aire generoso, la historia contada con
   gráficos. Rechaza la gramática "dark cyber" anterior.
   ============================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Spectral:ital,wght@0,300;0,400;0,500;0,600;1,400&display=swap');

/* ─── CSS Variables · mundo Índigo Sereno (navy + glass) ────── */
:root {
  /* ADV Brand — acentos claros sobre navy profundo */
  --adv-blue:   #6db3f0;   /* azul claro */
  --adv-cyan:   #5fc9e8;
  --adv-orange: #f0a350;   /* acento cálido de firma */
  --adv-navy:   #24345e;

  /* Backgrounds — navy profundo con tinte azul, nunca negro neón */
  --bg-main:    #0a1020;
  --bg-1:       #0e1526;
  --bg-2:       #121b30;
  --bg-3:       #1a2540;

  /* Borders — azul translúcido */
  --border-1:   #24304a;
  --border-2:   #182238;

  /* Text — blanco frío ligeramente azulado */
  --text-primary: #e8eef7;
  --text-dim:     #9aa8c0;
  --text-mute:    #5f6f8c;

  /* Semantic colors — claros sobre navy, no neón */
  --c-cyan:    #5fc9e8;
  --c-green:   #4fd08a;
  --c-red:     #ff5f6d;
  --c-orange:  #f0a350;
  --c-yellow:  #f5c542;
  --c-purple:  #b98ce0;
  --c-blue:    #6db3f0;

  /* Semantic dim (~12% sobre navy) */
  --c-cyan-dim:   #5fc9e81f;
  --c-green-dim:  #4fd08a1f;
  --c-red-dim:    #ff5f6d1f;
  --c-orange-dim: #f0a3501f;
  --c-yellow-dim: #f5c5421f;
  --c-purple-dim: #b98ce01f;
  --c-blue-dim:   #6db3f01f;

  /* Glass — material específico (paneles + navbar), tinte azul */
  --glass-bg:   rgba(18, 27, 48, 0.60);
  --glass-bg-2: rgba(26, 37, 64, 0.55);
  --glass-brd:  rgba(180, 205, 240, 0.12);
  --glass-glow: rgba(180, 205, 240, 0.20);
  --glass-blur: blur(18px) saturate(125%);

  /* Sombras — offset + blur reales (profundidad, no halo) */
  --shadow-1: 0 1px 2px rgba(0,0,0,.3), 0 10px 24px -14px rgba(0,0,0,.65);
  --shadow-2: 0 2px 6px rgba(0,0,0,.35), 0 22px 44px -18px rgba(0,0,0,.7);

  /* Data-viz — paleta categórica única (derivada de ADV) */
  --chart-1: #6db3f0;  /* azul claro ADV */
  --chart-2: #5fc9e8;  /* cyan ADV */
  --chart-3: #f0a350;  /* naranja ADV */
  --chart-4: #4fd08a;  /* verde */
  --chart-5: #b98ce0;  /* púrpura */
  --chart-6: #f5c542;  /* ámbar */
  --chart-track: rgba(180, 205, 240, 0.09);

  /* Spacing & shape */
  --radius:     14px;
  --radius-sm:  10px;
  --radius-xs:  7px;
  --radius-pill: 999px;

  --font-display: 'Spectral', Georgia, 'Times New Roman', serif;

  /* Curvas de movimiento (Emil): más fuertes que las nativas de CSS */
  --ease-out:    cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
}

/* ─── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Atmósfera: aurora ADV cálida muy sutil, fija detrás de todo.
   Da profundidad al espresso sin competir con el contenido. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(58vw 48vh at 82% -8%, rgba(91,155,213,.10), transparent 60%),
    radial-gradient(52vw 46vh at 8% 4%,  rgba(232,148,58,.07), transparent 62%),
    radial-gradient(60vw 55vh at 50% 112%, rgba(95,197,217,.06), transparent 60%);
}

a {
  color: var(--c-cyan);
  text-decoration: none;
}

a:hover {
  color: var(--adv-cyan);
  text-decoration: underline;
}

/* ─── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: var(--bg-1);
}

::-webkit-scrollbar-thumb {
  background: var(--border-1);
  border-radius: var(--radius-pill);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--adv-blue);
}

/* ─── Animations ────────────────────────────────────────────── */
@keyframes v3-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(232, 148, 58, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(232, 148, 58, 0);
  }
}

@keyframes v3-glow-red {
  0%, 100% {
    box-shadow: 0 0 4px rgba(255, 69, 96, 0.3);
  }
  50% {
    box-shadow: 0 0 16px rgba(255, 69, 96, 0.7), 0 0 32px rgba(255, 69, 96, 0.2);
  }
}

@keyframes v3-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes v3-slide-down {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Navigation ────────────────────────────────────────────── */
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/static/fonts/SpaceGrotesk.woff2) format('woff2');
}

.v3-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 28px;
  font-family: 'Inter', -apple-system, 'Segoe UI', sans-serif;
  background: var(--glass-bg);
  border-bottom: 1px solid var(--glass-brd);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: 0 1px 0 rgba(243,237,227,.04) inset, 0 8px 24px -18px rgba(0,0,0,.7);
}

.v3-nav-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.v3-nav-logo {
  height: 32px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

.v3-nav-brand {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.v3-nav-brand span {
  color: var(--adv-orange);
  font-style: italic;
}

.v3-nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.v3-nav-sep {
  width: 1px;
  height: 20px;
  background: var(--border-1);
  margin: 0 4px;
  flex-shrink: 0;
}

.v3-nav-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-dim);
  padding: 5px 9px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background 0.15s var(--ease-out), color 0.15s var(--ease-out),
              transform 0.13s var(--ease-out);
}
.v3-nav-user:active { transform: scale(0.97); }

.v3-nav-user:hover {
  background: rgba(180, 205, 240, 0.06);
  color: var(--text-primary);
}

/* Nav Pills */
.v3-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 9px 13px;
  border-radius: var(--radius-xs);
  font-size: 0.96rem;
  font-weight: 550;
  letter-spacing: 0.002em;
  cursor: pointer;
  border: none;
  color: var(--text-dim);
  background: transparent;
  transition: background 0.16s var(--ease-out), color 0.16s var(--ease-out),
              transform 0.13s var(--ease-out);
  text-decoration: none;
  white-space: nowrap;
  will-change: transform;
}
/* feedback de press — el navbar "escucha" el clic */
.v3-pill:active { transform: scale(0.97); }

.v3-pill-default { color: var(--text-dim); }
@media (hover: hover) and (pointer: fine) {
  .v3-pill-default:hover {
    background: rgba(180, 205, 240, 0.06);
    color: var(--text-primary);
    text-decoration: none;
  }
}

/* activo: texto claro + indicador de acento naranja (subrayado), no bloque */
.v3-pill-active { color: var(--text-primary); }
.v3-pill-active::after {
  content: '';
  position: absolute;
  left: 13px; right: 13px; bottom: -1px;
  height: 2px; border-radius: 2px;
  background: var(--adv-orange);
  box-shadow: 0 0 10px rgba(240,163,80,.5);
}
.v3-pill-active:hover { color: var(--text-primary); text-decoration: none; }

/* ── Iconos de la derecha (tema / campana) ── */
.nav-ibtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 37px; height: 37px; border-radius: 11px;
  background: transparent; border: 1px solid transparent; color: var(--text-dim);
  cursor: pointer; position: relative; padding: 0;
  transition: background 0.15s var(--ease-out), color 0.15s var(--ease-out),
              border-color 0.15s var(--ease-out), transform 0.13s var(--ease-out);
}
.nav-ibtn:hover { background: rgba(180,205,240,.07); border-color: var(--glass-brd); color: var(--text-primary); }
.nav-ibtn:active { transform: scale(0.92); }
.nav-ibtn svg { width: 18px; height: 18px; display: block; }
.nav-ibtn .ic-sun { display: none; }
:root.theme-light .nav-ibtn .ic-sun { display: block; }
:root.theme-light .nav-ibtn .ic-moon { display: none; }
.nav-badge {
  position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--adv-orange); color: #241206; font-size: 0.6rem; font-weight: 700;
  border-radius: var(--radius-pill); display: flex; align-items: center; justify-content: center; line-height: 1;
}

/* ── Avatar de usuario + menú ── */
.nav-user { position: relative; display: inline-flex; }
.nav-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 12px;
  background: linear-gradient(150deg, var(--adv-blue), var(--adv-navy));
  color: #fff; font-weight: 650; font-size: 0.82rem; letter-spacing: 0.03em;
  cursor: pointer; border: 1px solid rgba(180,205,240,.22); user-select: none;
  transition: transform 0.13s var(--ease-out), box-shadow 0.16s var(--ease-out);
}
.nav-avatar:hover { box-shadow: 0 0 0 3px rgba(109,179,240,.14); }
.nav-avatar:active { transform: scale(0.95); }
.nav-user::after { content: ''; position: absolute; top: 100%; right: 0; left: 0; height: 10px; }
.nav-usermenu {
  position: absolute; top: calc(100% + 9px); right: 0; min-width: 232px;
  background: rgba(15, 23, 42, 0.96); border: 1px solid var(--glass-brd); border-radius: var(--radius-sm);
  backdrop-filter: blur(20px) saturate(140%); -webkit-backdrop-filter: blur(20px) saturate(140%);
  box-shadow: var(--shadow-2); z-index: 200; padding: 6px; overflow: hidden;
  transform-origin: top right; opacity: 0; visibility: hidden; transform: scale(0.96) translateY(-6px);
  pointer-events: none;
  transition: opacity 0.18s var(--ease-out), transform 0.18s var(--ease-out), visibility 0s linear 0.18s;
}
.nav-user:hover .nav-usermenu, .nav-user:focus-within .nav-usermenu {
  opacity: 1; visibility: visible; transform: none; pointer-events: auto;
  transition: opacity 0.18s var(--ease-out), transform 0.18s var(--ease-out), visibility 0s;
}
.nav-um-head { padding: 11px 12px 10px; display: flex; gap: 11px; align-items: center; }
.nav-um-ava { width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(150deg, var(--adv-blue), var(--adv-navy)); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 650; font-size: 0.78rem; }
.nav-um-mail { font-size: 0.82rem; color: var(--text-primary); font-weight: 500; word-break: break-all; line-height: 1.3; }
.nav-um-role { font-size: 0.68rem; color: var(--text-mute); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.06em; }
.nav-um-sep { height: 1px; background: var(--glass-brd); margin: 4px 0; }
.nav-um-item { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: var(--radius-xs);
  font-size: 0.86rem; color: var(--text-dim); text-decoration: none;
  transition: background 0.14s var(--ease-out), color 0.14s var(--ease-out); }
.nav-um-item:hover { background: rgba(255,95,109,.10); color: var(--c-red); text-decoration: none; }
.nav-um-item svg { width: 16px; height: 16px; }

/* ─── Nav dropdown groups ───────────────────────────────────── */
.v3-navgroup {
  position: relative;
  display: inline-flex;
}
.v3-navgroup-toggle {
  background: transparent;
  font-family: inherit;
}
.v3-caret {
  font-size: 0.58rem;
  opacity: 0.65;
  margin-left: 2px;
  transition: transform 0.18s var(--ease-out), opacity 0.18s var(--ease-out);
}
.v3-navgroup:hover .v3-caret,
.v3-navgroup:focus-within .v3-caret { transform: rotate(180deg); opacity: 1; }

/* puente invisible: evita que el hover se corte entre toggle y menú */
.v3-navgroup::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: 10px;
}
.v3-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 9px;
  min-width: 190px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 7px;
  /* menú legible: glass casi sólido (el contenido detrás no debe leerse) */
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid var(--glass-brd);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  box-shadow: var(--shadow-2);
  z-index: 200;
  /* escala desde el trigger (arriba-izquierda), no desde el centro */
  transform-origin: top left;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.96) translateY(-6px);
  pointer-events: none;
  transition: opacity 0.18s var(--ease-out), transform 0.18s var(--ease-out),
              visibility 0s linear 0.18s;
}
.v3-dropdown::after {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: linear-gradient(90deg, transparent, var(--glass-glow) 30%, var(--glass-glow) 70%, transparent);
}
.v3-navgroup:hover .v3-dropdown,
.v3-navgroup:focus-within .v3-dropdown {
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
  transition: opacity 0.18s var(--ease-out), transform 0.18s var(--ease-out), visibility 0s;
}
.v3-dropdown-item {
  position: relative;
  display: block;
  padding: 9px 13px;
  border-radius: var(--radius-xs);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-dim);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.14s var(--ease-out), color 0.14s var(--ease-out);
}
.v3-dropdown-item:hover {
  background: rgba(180, 205, 240, 0.07);
  color: var(--text-primary);
  text-decoration: none;
}
/* activo: acento naranja de señal a la izquierda + texto claro */
.v3-dropdown-item.active {
  background: rgba(240, 163, 80, 0.10);
  color: var(--text-primary);
}
.v3-dropdown-item.active::before {
  content: '';
  position: absolute;
  left: 3px; top: 50%;
  width: 3px; height: 14px;
  transform: translateY(-50%);
  border-radius: 2px;
  background: var(--adv-orange);
}

@media (prefers-reduced-motion: reduce) {
  .v3-pill, .v3-caret { transition: background 0.14s, color 0.14s; }
  .v3-pill:active { transform: none; }
  .v3-navgroup:hover .v3-caret, .v3-navgroup:focus-within .v3-caret { transform: none; }
  .v3-dropdown { transform: none; transition: opacity 0.14s, visibility 0s linear 0.14s; }
  .v3-navgroup:hover .v3-dropdown, .v3-navgroup:focus-within .v3-dropdown { transform: none; }
}

/* ─── Bell Notification ─────────────────────────────────────── */
.v3-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-xs);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 1rem;
  transition: background 0.15s var(--ease-out), border-color 0.15s var(--ease-out),
              color 0.15s var(--ease-out), transform 0.13s var(--ease-out);
}

.v3-bell:hover {
  background: rgba(180, 205, 240, 0.06);
  border-color: var(--glass-brd);
  color: var(--text-primary);
}
.v3-bell:active { transform: scale(0.94); }

.v3-bell-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--c-red);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  animation: v3-pulse 2s infinite;
}

/* ─── KPI Cards ─────────────────────────────────────────────── */
.v3-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  padding: 0;
}

.v3-kpi {
  background: var(--glass-bg);
  border: 1px solid var(--glass-brd);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-1);
  transition: transform 0.2s cubic-bezier(.2,.8,.2,1), box-shadow 0.2s cubic-bezier(.2,.8,.2,1), border-color 0.2s;
  animation: v3-fade-in 0.35s ease both;
}

/* brillo cálido en el borde superior (glass real, no halo) */
.v3-kpi::after {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-glow) 30%, var(--glass-glow) 70%, transparent);
  pointer-events: none;
}

.v3-kpi::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.v3-kpi:hover {
  transform: translateY(-2px);
  border-color: var(--glass-glow);
  box-shadow: var(--shadow-2);
}

.v3-kpi-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 9px;
}

.v3-kpi-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.02em;
  margin-bottom: 5px;
  font-variant-numeric: tabular-nums;
}

.v3-kpi-sub {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 4px;
}

/* KPI Gradient presets (top border + value tint) */
.v3-g-blue::before  { background: linear-gradient(90deg, var(--adv-blue), var(--c-blue)); }
.v3-g-blue .v3-kpi-value { color: var(--c-blue); }

.v3-g-red::before   { background: linear-gradient(90deg, #b02040, var(--c-red)); }
.v3-g-red .v3-kpi-value  { color: var(--c-red); }

.v3-g-orange::before { background: linear-gradient(90deg, #a05020, var(--c-orange)); }
.v3-g-orange .v3-kpi-value { color: var(--c-orange); }

.v3-g-yellow::before { background: linear-gradient(90deg, #a08010, var(--c-yellow)); }
.v3-g-yellow .v3-kpi-value { color: var(--c-yellow); }

.v3-g-green::before  { background: linear-gradient(90deg, #00805a, var(--c-green)); }
.v3-g-green .v3-kpi-value  { color: var(--c-green); }

.v3-g-cyan::before   { background: linear-gradient(90deg, var(--adv-blue), var(--adv-cyan)); }
.v3-g-cyan .v3-kpi-value   { color: var(--adv-cyan); }

.v3-g-purple::before { background: linear-gradient(90deg, #6020b0, var(--c-purple)); }
.v3-g-purple .v3-kpi-value { color: var(--c-purple); }

/* ─── Cards ─────────────────────────────────────────────────── */
.v3-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-brd);
  border-radius: var(--radius);
  padding: 22px;
  position: relative;
  overflow: hidden;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-1);
  animation: v3-fade-in 0.35s ease both;
}

.v3-card::after {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-glow) 30%, var(--glass-glow) 70%, transparent);
  pointer-events: none;
}

/* Utilidad glass reusable + helpers de data-viz (inline SVG, sin CDN) */
.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-brd);
  border-radius: var(--radius);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-1);
}
.chart-legend { display:flex; flex-wrap:wrap; gap:6px 16px; }
.chart-legend .lg { display:inline-flex; align-items:center; gap:7px; font-size:.72rem; color:var(--text-dim); }
.chart-legend .sw { width:9px; height:9px; border-radius:3px; flex-shrink:0; }
.chart-title { font-family:var(--font-display); font-size:1rem; font-weight:500; color:var(--text-primary); letter-spacing:.01em; }

.v3-card-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.v3-card-title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 14px;
  background: var(--adv-cyan);
  border-radius: var(--radius-pill);
  flex-shrink: 0;
}

.v3-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
}

/* ─── Grid Layouts ──────────────────────────────────────────── */
.v3-grid {
  display: grid;
  gap: 16px;
}

.v3-g2 {
  grid-template-columns: repeat(2, 1fr);
}

.v3-g3 {
  grid-template-columns: repeat(3, 1fr);
}

/* 2/3 + 1/3 split */
.v3-g23 {
  grid-template-columns: 2fr 1fr;
}

.v3-g-full {
  grid-column: 1 / -1;
}

@media (max-width: 1100px) {
  .v3-g2,
  .v3-g3,
  .v3-g23 {
    grid-template-columns: 1fr;
  }

  .v3-g-full {
    grid-column: 1;
  }

  .v3-kpis {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .v3-kpis {
    grid-template-columns: 1fr;
  }

  .v3-nav {
    padding: 0 12px;
  }
}

/* ─── Tables ────────────────────────────────────────────────── */
.v3-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.v3-table th {
  text-align: left;
  padding: 8px 12px;
  color: var(--text-dim);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border-1);
  white-space: nowrap;
}

.v3-table td {
  padding: 9px 12px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-2);
  vertical-align: middle;
}

.v3-table tr:last-child td {
  border-bottom: none;
}

.v3-table tbody tr:hover td {
  background: rgba(77, 168, 213, 0.04);
}

.v3-table tbody tr {
  transition: background 0.1s;
}

/* ─── Risk Meter ────────────────────────────────────────────── */
.v3-risk-meter {
  display: flex;
  gap: 4px;
  align-items: flex-end;
  height: 40px;
}

.v3-risk-seg {
  flex: 1;
  border-radius: 3px;
  transition: opacity 0.2s;
}

.v3-risk-seg:nth-child(1) { background: var(--c-green);  height: 30%; opacity: 0.4; }
.v3-risk-seg:nth-child(2) { background: var(--c-green);  height: 45%; opacity: 0.6; }
.v3-risk-seg:nth-child(3) { background: var(--c-yellow); height: 60%; opacity: 0.6; }
.v3-risk-seg:nth-child(4) { background: var(--c-orange); height: 75%; opacity: 0.6; }
.v3-risk-seg:nth-child(5) { background: var(--c-red);    height: 90%; opacity: 0.6; }
.v3-risk-seg:nth-child(6) { background: var(--c-red);    height: 100%; opacity: 0.9; }

.v3-risk-seg.active {
  opacity: 1;
  filter: brightness(1.2);
}

/* ─── Risk Score Card ───────────────────────────────────────── */
.v3-risk-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 20px;
  background: var(--bg-3);
  border: 1px solid var(--border-1);
  border-radius: var(--radius);
  text-align: center;
}

.v3-risk-val {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.v3-risk-val.low    { color: var(--c-green); }
.v3-risk-val.medium { color: var(--c-yellow); }
.v3-risk-val.high   { color: var(--c-orange); }
.v3-risk-val.critical {
  color: var(--c-red);
  animation: v3-glow-red 2s infinite;
}

/* ─── Bar Chart ─────────────────────────────────────────────── */
.v3-bars {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 120px;
  padding-bottom: 24px;
  position: relative;
}

.v3-bars::after {
  content: '';
  position: absolute;
  bottom: 24px;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border-1);
}

.v3-bar {
  flex: 1;
  border-radius: 4px 4px 0 0;
  background: var(--adv-blue);
  position: relative;
  cursor: pointer;
  transition: filter 0.15s, transform 0.15s;
  min-width: 20px;
}

.v3-bar:hover {
  filter: brightness(1.3);
  transform: scaleY(1.02);
  transform-origin: bottom;
}

/* Tooltip via data-tip */
.v3-bar::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-3);
  border: 1px solid var(--border-1);
  color: var(--text-primary);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10;
}

.v3-bar:hover::after {
  opacity: 1;
}

/* ─── Technology Cards ──────────────────────────────────────── */
.v3-tech-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-2);
  transition: background 0.1s;
}

.v3-tech-item:last-child {
  border-bottom: none;
}

.v3-tech-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-3);
  border: 1px solid var(--border-1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
  color: var(--adv-cyan);
}

.v3-tech-info {
  flex: 1;
  min-width: 0;
}

.v3-tech-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.v3-tech-sub {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ─── Progress Bars ─────────────────────────────────────────── */
.v3-bar-wrap {
  width: 100%;
  height: 6px;
  background: var(--bg-3);
  border-radius: var(--radius-pill);
  overflow: hidden;
  flex-shrink: 0;
}

.v3-bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--adv-blue), var(--adv-cyan));
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.v3-bar-fill.red    { background: linear-gradient(90deg, #b02040, var(--c-red)); }
.v3-bar-fill.orange { background: linear-gradient(90deg, #a05020, var(--c-orange)); }
.v3-bar-fill.green  { background: linear-gradient(90deg, #00805a, var(--c-green)); }
.v3-bar-fill.yellow { background: linear-gradient(90deg, #c09000, var(--c-yellow)); }
.v3-bar-fill.purple { background: linear-gradient(90deg, #6020b0, var(--c-purple)); }

/* ─── Severity Badges ───────────────────────────────────────── */
.v3-sev {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid transparent;
  white-space: nowrap;
}

.v3-sev-critical {
  background: var(--c-red-dim);
  color: var(--c-red);
  border-color: rgba(255, 69, 96, 0.3);
}

.v3-sev-high {
  background: var(--c-orange-dim);
  color: var(--c-orange);
  border-color: rgba(232, 148, 58, 0.3);
}

.v3-sev-medium {
  background: var(--c-yellow-dim);
  color: var(--c-yellow);
  border-color: rgba(249, 197, 19, 0.3);
}

.v3-sev-low {
  background: var(--c-green-dim);
  color: var(--c-green);
  border-color: rgba(0, 224, 150, 0.3);
}

.v3-sev-info {
  background: var(--c-cyan-dim);
  color: var(--c-cyan);
  border-color: rgba(77, 168, 213, 0.3);
}

/* ─── Buttons ───────────────────────────────────────────────── */
.v3-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 18px;
  border-radius: var(--radius-xs);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-1);
  background: var(--bg-3);
  color: var(--text-primary);
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
  line-height: 1;
}

.v3-btn:hover {
  border-color: var(--adv-orange);
  color: var(--adv-orange);
  background: rgba(232, 148, 58, 0.06);
  text-decoration: none;
}

.v3-btn:active {
  transform: scale(0.98);
}

.v3-btn-primary {
  background: linear-gradient(135deg, var(--adv-blue), #3a6dbf);
  border-color: var(--adv-blue);
  color: #fff;
}

.v3-btn-primary:hover {
  background: linear-gradient(135deg, #3a6dbf, #4d80d0);
  border-color: #3a6dbf;
  color: #fff;
}

/* ─── Inputs & Selects ──────────────────────────────────────── */
.v3-input,
.v3-select {
  background: var(--bg-3);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-xs);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-family: inherit;
  padding: 7px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

.v3-input:focus,
.v3-select:focus {
  border-color: var(--adv-cyan);
  box-shadow: 0 0 0 2px rgba(77, 168, 213, 0.15);
}

.v3-input::placeholder {
  color: var(--text-mute);
}

.v3-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
}

.v3-select option {
  background: var(--bg-2);
  color: var(--text-primary);
}

/* ─── Modal ─────────────────────────────────────────────────── */
.v3-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 9, 15, 0.8);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: v3-fade-in 0.2s ease;
}

.v3-modal {
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  animation: v3-slide-down 0.2s ease;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}

.v3-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-xs);
  background: var(--bg-3);
  border: 1px solid var(--border-1);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
  transition: all 0.15s;
  font-family: inherit;
}

.v3-modal-close:hover {
  background: var(--c-red-dim);
  border-color: rgba(255, 69, 96, 0.3);
  color: var(--c-red);
}

/* ─── Section Title ─────────────────────────────────────────── */
.v3-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.v3-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-1);
}

/* ─── Utilities ─────────────────────────────────────────────── */
.v3-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-mute);
  font-size: 0.8rem;
}

.v3-mono {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.8em;
}

.v3-text-red    { color: var(--c-red) !important; }
.v3-text-orange { color: var(--c-orange) !important; }
.v3-text-cyan   { color: var(--c-cyan) !important; }
.v3-text-green  { color: var(--c-green) !important; }
.v3-text-dim    { color: var(--text-dim) !important; }
.v3-text-mute   { color: var(--text-mute) !important; }

.v3-fw-bold   { font-weight: 700 !important; }
.v3-text-right { text-align: right !important; }

/* ─── Page layout helper ────────────────────────────────────── */
.v3-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px 24px;
}

.v3-page {
  padding: 20px 24px;
}

/* ─── Status dot helper ─────────────────────────────────────── */
.v3-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.v3-dot-green  { background: var(--c-green); box-shadow: 0 0 6px var(--c-green); }
.v3-dot-red    { background: var(--c-red);   box-shadow: 0 0 6px var(--c-red); animation: v3-glow-red 2s infinite; }
.v3-dot-orange { background: var(--c-orange); }
.v3-dot-dim    { background: var(--text-mute); }

/* ─── Light theme overrides ─────────────────────────────────── */
/* Se activa agregando la clase `theme-light` a <html>. El modo
   oscuro sigue siendo el default. Los colores semánticos
   (--c-red, --c-green, --c-orange, etc.) se mantienen para que
   los badges de severidad/estado conserven su significado. */
:root.theme-light {
  /* Backgrounds invertidos a tonos claros */
  --bg-main:    #f5f7fa;
  --bg-1:       #ffffff;
  --bg-2:       #fafbfc;
  --bg-3:       #eef1f5;

  /* Borders más definidos sobre fondo claro */
  --border-1:   #e2e8f0;
  --border-2:   #cbd5e1;

  /* Texto invertido: oscuro sobre claro */
  --text-primary: #0f172a;
  --text-dim:     #475569;
  --text-mute:    #94a3b8;

  /* Cyan ligeramente más oscuro para contraste AA sobre blanco */
  --adv-cyan:   #2d7aa8;
  --c-cyan:     #2d7aa8;

  /* Dim semánticos: en claro el 12% de opacidad es casi invisible,
     subimos a ~20% para que los badges sigan visibles */
  --c-cyan-dim:   #2d7aa820;
  --c-green-dim:  #00a67020;
  --c-red-dim:    #ff456020;
  --c-orange-dim: #e8943a20;
  --c-yellow-dim: #f9c51320;
  --c-purple-dim: #a855f720;
  --c-blue-dim:   #4d9fff20;
}

/* =============================================================
   RESPONSIVE — Mobile & Tablet (≤768px / ≤480px)
   ============================================================= */
@media (max-width: 768px) {
  /* Navbar: permitir envolver en dos filas (left wrap + right fijo) */
  .v3-nav {
    flex-wrap: wrap;
    height: auto;
    min-height: 56px;
    padding: 8px 12px;
    gap: 6px;
    row-gap: 6px;
  }

  /* Fila izquierda: pills pueden envolver */
  .v3-nav-left {
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
    order: 2;
  }

  /* Fila derecha: campanita, theme y salir visibles arriba */
  .v3-nav-right {
    gap: 4px;
    width: 100%;
    justify-content: flex-end;
    order: 1;
  }

  /* Logo y brand mas chicos */
  .v3-nav-logo {
    height: 24px;
  }

  .v3-nav-brand {
    font-size: 0.9rem;
  }

  /* Pills: padding y tipografia reducidos ~12% */
  .v3-pill {
    padding: 4px 10px;
    font-size: 0.72rem;
  }

  /* Separador vertical pierde sentido cuando hay wrap; lo escondemos */
  .v3-nav-sep {
    display: none;
  }

  /* Bell mas compacto en movil */
  .v3-bell {
    width: 30px;
    height: 30px;
    font-size: 0.9rem;
  }

  /* Grids globales ya colapsan en 1100px; aseguramos tabla con scroll */
  .v3-table {
    font-size: 0.72rem;
  }
}

@media (max-width: 480px) {
  /* En pantallas muy chicas: ocultar email del usuario para liberar espacio.
     El theme toggle, bell y boton Salir siguen funcionales. */
  .v3-nav-right > span[title] {
    display: none;
  }

  .v3-nav {
    padding: 6px 10px;
  }

  .v3-nav-brand {
    font-size: 0.8rem;
  }

  .v3-pill {
    padding: 3px 8px;
    font-size: 0.68rem;
  }

  /* Reducir brand a solo logo+VISION si hace falta */
  .v3-nav-logo {
    height: 22px;
  }
}
