/* =============================================================
   LeanCP Seguridad — Design System
   Hereda tokens de la Suite + componentes propios
   ============================================================= */

:root {
  --bg: #0A0A0A;
  --bg-1: #0E0E0E;
  --bg-2: #131313;
  --bg-3: #1A1A1A;
  --bg-4: #212121;
  --bg-card: rgba(26,26,26,0.55);
  --bg-card-solid: #161616;
  --bg-elev: #1C1C1C;

  --border: rgba(255,255,255,0.06);
  --border-strong: rgba(255,255,255,0.12);
  --border-oro: rgba(201,162,39,0.18);
  --border-oro-hover: rgba(201,162,39,0.45);

  --text: #F5F2EB;
  --text-2: rgba(245,242,235,0.72);
  --text-3: rgba(245,242,235,0.48);
  --text-4: rgba(245,242,235,0.28);

  --oro: #C9A227;
  --oro-2: #E2C044;
  --oro-dim: rgba(201,162,39,0.12);
  --oro-glow: rgba(201,162,39,0.28);

  --rojo: #EF4444;
  --rojo-dim: rgba(239,68,68,0.12);
  --naranja: #F97316;
  --naranja-dim: rgba(249,115,22,0.12);
  --amarillo: #EAB308;
  --amarillo-dim: rgba(234,179,8,0.12);
  --verde: #22C55E;
  --verde-dim: rgba(34,197,94,0.12);
  --azul: #3B82F6;
  --azul-dim: rgba(59,130,246,0.12);
  --violeta: #8B5CF6;
  --violeta-dim: rgba(139,92,246,0.12);

  --font-title: 'Montserrat', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --r-xs: 4px;
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  --tr: 180ms cubic-bezier(.2,.8,.2,1);
  --tr-slow: 320ms cubic-bezier(.2,.8,.2,1);

  --shadow-lg: 0 16px 48px rgba(0,0,0,.5), 0 2px 8px rgba(0,0,0,.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,.35);

  --rail-w: 64px;
  --topbar-h: 52px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; background: none; border: none; color: inherit; }
input, textarea, select { font-family: inherit; color: inherit; }
kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 5px;
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--text-2);
}

/* Background sutil con grain + glow sutil oro */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 60% at 20% -10%, rgba(201,162,39,0.05), transparent 70%),
    radial-gradient(ellipse 60% 40% at 110% 110%, rgba(201,162,39,0.04), transparent 70%);
  z-index: 0;
}

/* =============================================================
   SHELL
   ============================================================= */
.app-shell {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  height: 100vh;
  position: relative;
  z-index: 1;
}

.rail {
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0;
  gap: 4px;
  overflow: hidden;
}
.rail-brand {
  width: 40px; height: 40px;
  border-radius: var(--r);
  background: linear-gradient(135deg, rgba(201,162,39,0.18), rgba(201,162,39,0.04));
  border: 1px solid var(--border-oro);
  color: var(--oro);
  display: flex; align-items: center; justify-content: center;
  transition: var(--tr);
  flex-shrink: 0;
}
.rail-brand:hover { border-color: var(--oro); transform: scale(1.03); box-shadow: 0 0 0 3px var(--oro-dim); }
.rail-divider { width: 24px; height: 1px; background: var(--border); margin: 6px 0 4px; }
.rail-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.rail-bottom { margin-top: auto; }

.rail-item {
  width: 44px;
  height: 44px;
  border-radius: var(--r);
  color: var(--text-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  position: relative;
  transition: var(--tr);
}
.rail-item .rail-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-4);
  transition: var(--tr);
}
.rail-item:hover { color: var(--text); background: var(--bg-3); }
.rail-item:hover .rail-label { color: var(--text-2); }
.rail-item.active { color: var(--oro); background: var(--oro-dim); }
.rail-item.active .rail-label { color: var(--oro); }
.rail-item.active::before {
  content: "";
  position: absolute; left: -10px; top: 10px; bottom: 10px;
  width: 2px; border-radius: 2px;
  background: var(--oro);
  box-shadow: 0 0 8px var(--oro-glow);
}

/* =============================================================
   TOPBAR
   ============================================================= */
.app-main {
  display: flex; flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.topbar {
  height: var(--topbar-h);
  background: rgba(14,14,14,0.8);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 18px;
  flex-shrink: 0;
  z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 18px; min-width: 0; }
.topbar-center { flex: 1; display: flex; justify-content: center; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.brand { display: flex; align-items: baseline; gap: 6px; font-family: var(--font-title); font-weight: 800; font-size: 13px; white-space: nowrap; }
.brand-oro { color: var(--oro); letter-spacing: -0.01em; }
.brand-dim { color: var(--text-4); font-weight: 400; }
.brand-module { color: var(--text); font-weight: 600; letter-spacing: 0.01em; }

.project-picker {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 12.5px;
  color: var(--text-2);
  transition: var(--tr);
  cursor: pointer;
  position: relative;
}
.project-picker:hover { border-color: var(--border-oro); color: var(--text); }
.project-picker svg { opacity: 0.6; }
.project-picker-menu {
  position: absolute; top: calc(100% + 6px); left: 0;
  min-width: 260px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none;
  z-index: 50;
  animation: menuIn 150ms ease;
}
.project-picker-menu.open { display: block; }
.project-picker-menu .pp-item {
  padding: 8px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 13px;
  display: flex; align-items: center; gap: 10px;
  transition: var(--tr);
}
.project-picker-menu .pp-item:hover { background: var(--bg-3); }
.project-picker-menu .pp-item.active { color: var(--oro); background: var(--oro-dim); }
.project-picker-menu .pp-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--oro); }
@keyframes menuIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.cmd-hint {
  display: flex; align-items: center; gap: 10px;
  min-width: 360px; max-width: 460px;
  padding: 7px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text-3);
  font-size: 12.5px;
  transition: var(--tr);
}
.cmd-hint:hover { border-color: var(--border-oro); color: var(--text-2); }
.cmd-hint span { flex: 1; text-align: left; }

.icon-btn {
  width: 34px; height: 34px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  transition: var(--tr);
  position: relative;
}
.icon-btn:hover { background: var(--bg-3); color: var(--text); }
.notif-dot {
  position: absolute; top: 7px; right: 8px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--rojo);
  box-shadow: 0 0 0 2px var(--bg-1);
  display: none;
}
.notif-dot.show { display: block; }

.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  transition: var(--tr);
}
.user-chip:hover { border-color: var(--border-oro); }
.user-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, var(--oro), var(--oro-2));
  color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-title); font-weight: 700; font-size: 10px;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.1; }
.user-name { font-size: 11.5px; font-weight: 600; color: var(--text); }
.user-role { font-size: 9.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; }

/* =============================================================
   VIEW CONTAINER
   ============================================================= */
.view-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 22px 28px 40px;
  scroll-behavior: smooth;
  position: relative;
}
.view-container::-webkit-scrollbar { width: 10px; height: 10px; }
.view-container::-webkit-scrollbar-track { background: transparent; }
.view-container::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 10px; border: 2px solid var(--bg); }
.view-container::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.12); }

.view { animation: viewIn 240ms cubic-bezier(.2,.8,.2,1); }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.view-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 22px;
  gap: 20px;
  flex-wrap: wrap;
}
.view-title {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 26px;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.view-subtitle {
  color: var(--text-3);
  font-size: 13px;
  margin-top: 4px;
}
.view-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.view-loading {
  display: flex; align-items: center; justify-content: center;
  min-height: 400px;
}
/* =============================================================
   BOTONES
   ============================================================= */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-weight: 600;
  transition: var(--tr);
  border: 1px solid transparent;
  line-height: 1;
  white-space: nowrap;
}
.btn svg { width: 14px; height: 14px; }
.btn-primary {
  background: var(--oro);
  color: var(--bg);
}
.btn-primary:hover { background: var(--oro-2); box-shadow: 0 0 0 3px var(--oro-dim); }
.btn-ghost {
  background: var(--bg-2);
  border-color: var(--border);
  color: var(--text-2);
}
.btn-ghost:hover { border-color: var(--border-oro); color: var(--text); background: var(--bg-3); }
.btn-danger {
  background: var(--rojo-dim);
  border-color: rgba(239,68,68,0.3);
  color: var(--rojo);
}
.btn-danger:hover { background: rgba(239,68,68,0.22); }
.btn-sm { padding: 5px 10px; font-size: 11.5px; }
.btn-lg { padding: 11px 20px; font-size: 13.5px; }
.btn-icon {
  width: 32px; height: 32px; padding: 0; justify-content: center;
}

/* =============================================================
   CARDS
   ============================================================= */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  transition: var(--tr);
  backdrop-filter: blur(14px);
}
.card:hover { border-color: var(--border-strong); }
.card-interactive { cursor: pointer; }
.card-interactive:hover { border-color: var(--border-oro-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.card-title {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.005em;
}
.card-title-eyebrow {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 4px;
}

/* =============================================================
   STAT CARDS
   ============================================================= */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
.kpi {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
  transition: var(--tr);
}
.kpi::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(180px 80px at 100% 0, rgba(201,162,39,0.10), transparent 70%);
  opacity: 0;
  transition: var(--tr);
}
.kpi:hover { border-color: var(--border-oro-hover); transform: translateY(-1px); }
.kpi:hover::after { opacity: 1; }
.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}
.kpi-label svg { width: 13px; height: 13px; opacity: 0.6; }
.kpi-value {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 30px;
  letter-spacing: -0.02em;
  margin: 8px 0 4px;
  color: var(--text);
}
.kpi-delta {
  font-size: 11.5px;
  display: flex; align-items: center; gap: 4px;
  color: var(--text-3);
}
.kpi-delta .up { color: var(--verde); }
.kpi-delta .down { color: var(--rojo); }
.kpi-accent { height: 3px; margin-top: 10px; border-radius: 2px; background: var(--oro); opacity: 0.5; }
.kpi.rojo .kpi-accent { background: var(--rojo); }
.kpi.verde .kpi-accent { background: var(--verde); }
.kpi.azul .kpi-accent { background: var(--azul); }

/* =============================================================
   BADGES
   ============================================================= */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2.5px 8px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
  line-height: 1.3;
}
.badge-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}
.badge-bajo, .badge-verde { background: var(--verde-dim); color: var(--verde); }
.badge-medio, .badge-amarillo { background: var(--amarillo-dim); color: var(--amarillo); }
.badge-alto, .badge-naranja { background: var(--naranja-dim); color: var(--naranja); }
.badge-extremo, .badge-rojo { background: var(--rojo-dim); color: var(--rojo); }
.badge-azul { background: var(--azul-dim); color: var(--azul); }
.badge-violeta { background: var(--violeta-dim); color: var(--violeta); }
.badge-oro { background: var(--oro-dim); color: var(--oro); }
.badge-ghost { background: rgba(255,255,255,0.04); color: var(--text-3); border-color: var(--border); }

.badge-borrador { background: rgba(255,255,255,0.05); color: var(--text-3); }
.badge-vigente { background: var(--verde-dim); color: var(--verde); }
.badge-vencido { background: var(--rojo-dim); color: var(--rojo); }
.badge-cerrado { background: var(--azul-dim); color: var(--azul); }

/* =============================================================
   MATRIZ DE RIESGO 5x5
   ============================================================= */
.matrix-wrap {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
}
.matrix-y-axis {
  display: flex; flex-direction: column-reverse;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  color: var(--text-3);
  text-transform: uppercase;
  padding: 4px 0;
}
.matrix {
  display: grid;
  grid-template-columns: 28px repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr) 22px;
  gap: 4px;
}
.matrix-cell {
  aspect-ratio: 1 / 0.7;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  cursor: pointer;
  transition: var(--tr);
  border: 1px solid transparent;
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 15px;
}
.matrix-cell:hover { outline: 2px solid var(--oro); outline-offset: -2px; transform: scale(1.02); z-index: 5; }
.matrix-cell.selected { outline: 2px solid var(--oro); outline-offset: -2px; }
.matrix-cell .count {
  position: absolute; top: 4px; right: 6px;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  color: rgba(0,0,0,0.7);
}
.matrix-cell .score {
  color: rgba(0,0,0,0.78);
  font-size: 13px;
}
.matrix-y-label, .matrix-x-label {
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
}
.matrix-x-label { height: 22px; }
.matrix-axis-title {
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-3);
  text-align: center;
  margin-top: 6px;
}

/* Colores por score R = P × S */
.risk-1, .risk-2, .risk-3, .risk-4 { background: linear-gradient(135deg, #16a34a, #22c55e); }
.risk-5, .risk-6, .risk-7, .risk-8 { background: linear-gradient(135deg, #ca8a04, #eab308); }
.risk-9, .risk-10, .risk-11, .risk-12, .risk-13, .risk-14 { background: linear-gradient(135deg, #ea580c, #f97316); }
.risk-15, .risk-16, .risk-18, .risk-20, .risk-25 { background: linear-gradient(135deg, #b91c1c, #ef4444); }

/* =============================================================
   TABS
   ============================================================= */
.tabs {
  display: flex; gap: 2px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 3px;
  border-radius: var(--r);
  width: fit-content;
}
.tab {
  padding: 7px 16px;
  border-radius: calc(var(--r) - 3px);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  transition: var(--tr);
}
.tab:hover { color: var(--text-2); }
.tab.active { color: var(--text); background: var(--bg-4); }

.tabs-underline { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tabs-underline .tab {
  border-radius: 0;
  border-bottom: 2px solid transparent;
  padding: 10px 14px;
}
.tabs-underline .tab.active { background: none; border-bottom-color: var(--oro); color: var(--oro); }

/* =============================================================
   LISTS / TABLES
   ============================================================= */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
}
.table thead th {
  text-align: left;
  padding: 10px 12px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  position: sticky; top: 0;
  z-index: 2;
}
.table tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  vertical-align: middle;
}
.table tbody tr { transition: var(--tr); cursor: pointer; }
.table tbody tr:hover { background: var(--bg-2); }
.table tbody tr:hover td { color: var(--text); }
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  backdrop-filter: blur(14px);
}

/* =============================================================
   FORMULARIOS
   ============================================================= */
.form-grid { display: grid; gap: 14px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
}
.form-label .required { color: var(--oro); }
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text);
  transition: var(--tr);
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--oro);
  box-shadow: 0 0 0 3px var(--oro-dim);
}
.form-textarea { resize: vertical; min-height: 78px; font-family: inherit; }

.chip-group { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 6px 12px;
  border-radius: 99px;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--tr);
  display: inline-flex; align-items: center; gap: 5px;
}
.chip:hover { border-color: var(--border-oro); color: var(--text); }
.chip.selected { background: var(--oro-dim); border-color: var(--oro); color: var(--oro); font-weight: 600; }
.chip svg { width: 12px; height: 12px; }

.check-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: var(--tr);
  font-size: 12.5px;
}
.check-row:hover { border-color: var(--border-strong); background: var(--bg-2); }
.check-row.checked { border-color: var(--oro); background: var(--oro-dim); }
.check-box {
  width: 16px; height: 16px;
  border-radius: 4px;
  border: 1.5px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  transition: var(--tr);
  flex-shrink: 0;
}
.check-row.checked .check-box { background: var(--oro); border-color: var(--oro); }
.check-row.checked .check-box::after {
  content: "";
  width: 5px; height: 9px;
  border: 2px solid var(--bg); border-top: 0; border-left: 0;
  transform: rotate(45deg) translate(-1px, -1px);
}

/* =============================================================
   MODAL
   ============================================================= */
.modal {
  position: fixed; inset: 0;
  display: none;
  z-index: 300;
}
.modal.open { display: block; }
.modal-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  animation: fadeIn 150ms ease;
}
.modal-box {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 900px);
  max-height: 88vh;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: modalIn 200ms cubic-bezier(.2,.8,.2,1);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn {
  from { opacity: 0; transform: translate(-50%, -46%) scale(0.97); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
}
.modal-title {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 15px;
}
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.modal-close {
  width: 28px; height: 28px;
  border-radius: 6px;
  color: var(--text-3);
  transition: var(--tr);
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--bg-3); color: var(--text); }

/* =============================================================
   COMMAND PALETTE
   ============================================================= */
.cmd-palette {
  position: fixed; inset: 0;
  display: none;
  z-index: 400;
}
.cmd-palette.open { display: block; }
.cmd-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  animation: fadeIn 120ms ease;
}
.cmd-box {
  position: absolute;
  top: 18%; left: 50%;
  transform: translateX(-50%);
  width: min(92vw, 620px);
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalIn 180ms cubic-bezier(.2,.8,.2,1);
}
.cmd-input-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-3);
}
.cmd-input-wrap input {
  flex: 1;
  background: none; border: none; outline: none;
  font-size: 14px;
  color: var(--text);
}
.cmd-results { max-height: 420px; overflow-y: auto; padding: 4px; }
.cmd-section-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-4);
  padding: 10px 12px 6px;
}
.cmd-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--tr);
}
.cmd-item:hover, .cmd-item.active { background: var(--bg-3); }
.cmd-item.active { box-shadow: inset 2px 0 0 var(--oro); }
.cmd-item-icon {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
}
.cmd-item-text { flex: 1; }
.cmd-item-title { font-size: 13px; color: var(--text); font-weight: 500; }
.cmd-item-sub { font-size: 11px; color: var(--text-3); }
.cmd-item-kbd { color: var(--text-4); font-family: var(--font-mono); font-size: 10px; }
.cmd-footer {
  border-top: 1px solid var(--border);
  padding: 8px 14px;
  display: flex; gap: 14px;
  font-size: 11px; color: var(--text-3);
}
.cmd-footer-right { margin-left: auto; color: var(--oro); font-weight: 600; }

/* =============================================================
   APP SWITCHER (copia del portal)
   ============================================================= */
.app-switcher-panel {
  position: fixed; top: 64px; left: 74px;
  width: 320px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  max-height: 80vh; overflow-y: auto;
  display: none;
  animation: menuIn 150ms ease;
}
.app-switcher-panel.open { display: block; }
.switcher-header { padding: 14px 16px 10px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.switcher-header h3 { font-family: var(--font-title); font-size: 12px; font-weight: 700; color: var(--oro); }
.switcher-portal-btn {
  font-size: 10.5px; font-weight: 600; color: var(--text-3);
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px;
  transition: var(--tr);
}
.switcher-portal-btn:hover { color: var(--oro); border-color: var(--oro); }
.switcher-apps { padding: 8px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.switcher-loading { grid-column: 1/-1; text-align: center; padding: 20px; color: var(--text-4); font-size: 11px; }
.switcher-app {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 8px;
  border-radius: var(--r-sm); cursor: pointer;
  border: 1px solid transparent;
  transition: var(--tr);
}
.switcher-app:hover { background: var(--bg-2); border-color: var(--border); }
.switcher-app.current { background: var(--oro-dim); border-color: rgba(201,162,39,0.3); }
.switcher-app.disabled { opacity: 0.35; pointer-events: none; }
.switcher-app-icon {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
}
.switcher-app-name { font-size: 10.5px; font-weight: 600; text-align: center; line-height: 1.2; }
.switcher-app-status { font-size: 8.5px; font-weight: 700; letter-spacing: 0.5px; padding: 1px 5px; border-radius: 3px; text-transform: uppercase; }
.status-available { background: var(--verde-dim); color: var(--verde); }
.status-development { background: var(--naranja-dim); color: var(--naranja); }
.status-coming_soon { background: var(--azul-dim); color: var(--azul); }
.status-future { background: rgba(100,116,139,.1); color: var(--text-3); }
.switcher-user { padding: 10px 16px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.switcher-user-info { display: flex; align-items: center; gap: 8px; }
.switcher-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--oro-dim); border: 1px solid rgba(201,162,39,0.3); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: var(--oro); }
.switcher-user-name { font-size: 12px; font-weight: 500; }
.switcher-user-role { font-size: 10px; color: var(--text-3); }
.switcher-logout { font-size: 11px; color: var(--text-3); background: none; border: 1px solid var(--border); border-radius: 5px; padding: 4px 10px; transition: var(--tr); }
.switcher-logout:hover { color: var(--rojo); border-color: var(--rojo); }

/* =============================================================
   NOTIFS
   ============================================================= */
.notifs-panel {
  position: fixed; top: 64px; right: 14px;
  width: 360px; max-height: 520px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: none;
  z-index: 200;
  animation: menuIn 150ms ease;
}
.notifs-panel.open { display: flex; flex-direction: column; }
.notifs-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-title); font-weight: 700; font-size: 13px;
}
.notifs-list { overflow-y: auto; flex: 1; }
.notif-item {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; gap: 12px;
  cursor: pointer;
  transition: var(--tr);
}
.notif-item:hover { background: var(--bg-2); }
.notif-dot-c {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--oro); margin-top: 6px; flex-shrink: 0;
}
.notif-item.read .notif-dot-c { background: var(--text-4); }
.notif-body { flex: 1; }
.notif-text { font-size: 12.5px; line-height: 1.45; }
.notif-time { font-size: 11px; color: var(--text-3); margin-top: 3px; }

/* =============================================================
   SECCIONES ESPECÍFICAS
   ============================================================= */
.bento {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 16px;
  margin-bottom: 22px;
}
.bento-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 22px;
}

/* Bar horizontal para top áreas */
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 7px 0; }
.bar-row .bar-label { font-size: 12.5px; color: var(--text); font-weight: 500; display: flex; align-items: center; gap: 8px; }
.bar-row .bar-label small { color: var(--text-3); font-weight: 400; font-size: 11px; }
.bar-track {
  height: 8px;
  background: var(--bg-3);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 5px;
}
.bar-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--oro), var(--oro-2)); }
.bar-value { font-family: var(--font-mono); font-size: 12px; color: var(--text-2); font-weight: 600; min-width: 32px; text-align: right; }

/* Timeline permisos */
.timeline { display: flex; flex-direction: column; gap: 10px; }
.timeline-item {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--bg-2);
  cursor: pointer;
  transition: var(--tr);
  align-items: center;
}
.timeline-item:hover { border-color: var(--border-oro); transform: translateX(2px); }
.timeline-date {
  text-align: center;
  padding: 5px 0;
  border-right: 1px solid var(--border);
}
.timeline-date .tl-day { font-family: var(--font-title); font-weight: 800; font-size: 18px; line-height: 1; }
.timeline-date .tl-month { font-size: 9.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px; }
.timeline-body .tl-title { font-size: 13px; font-weight: 600; color: var(--text); }
.timeline-body .tl-sub { font-size: 11.5px; color: var(--text-3); display: flex; gap: 8px; margin-top: 3px; }

/* Heatmap / lista riesgo */
.risk-list { display: flex; flex-direction: column; gap: 8px; max-height: 360px; overflow-y: auto; padding-right: 4px; }
.risk-list-item {
  display: grid;
  grid-template-columns: 32px 1fr auto auto;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  align-items: center;
  cursor: pointer;
  transition: var(--tr);
}
.risk-list-item:hover { border-color: var(--border-oro); }
.risk-score-pill {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-title); font-weight: 800; font-size: 13px;
  color: rgba(0,0,0,0.8);
}
.risk-list-item .rl-title { font-size: 12.5px; font-weight: 600; color: var(--text); }
.risk-list-item .rl-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* Pictogramas SGA */
.pictogram {
  width: 38px; height: 38px;
  transform: rotate(45deg);
  border: 2px solid var(--rojo);
  background: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  position: relative;
  flex-shrink: 0;
}
.pictogram-xs { width: 28px; height: 28px; border-width: 1.5px; }
.pictogram svg { transform: rotate(-45deg); }
.pictogram-label {
  font-size: 9.5px; color: var(--text-3); text-align: center; margin-top: 6px;
  text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600;
}

/* Matriz compatibilidad química */
.compat-matrix {
  display: grid;
  grid-template-columns: 180px repeat(7, 1fr);
  gap: 3px;
  font-size: 11px;
}
.compat-header, .compat-label {
  padding: 8px;
  font-weight: 600;
  display: flex; align-items: center;
  color: var(--text-2);
  background: var(--bg-2);
  border-radius: 4px;
  min-height: 44px;
}
.compat-header {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em;
  justify-content: center;
  text-align: center;
  background: var(--bg-3);
  writing-mode: horizontal-tb;
}
.compat-cell {
  aspect-ratio: 1;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 14px;
  cursor: help;
  transition: var(--tr);
}
.compat-cell:hover { transform: scale(1.08); z-index: 2; box-shadow: 0 4px 12px rgba(0,0,0,0.4); }
.compat-si { background: linear-gradient(135deg, #16a34a, #22c55e); color: #fff; }
.compat-no { background: linear-gradient(135deg, #b91c1c, #ef4444); color: #fff; }
.compat-cau { background: linear-gradient(135deg, #ca8a04, #eab308); color: #000; }
.compat-self { background: var(--bg-3); color: var(--text-4); }

/* Wizard */
.wizard-steps {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
}
.wizard-step {
  flex: 1;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  position: relative;
  cursor: pointer;
  transition: var(--tr);
}
.wizard-step.active { border-color: var(--oro); background: var(--oro-dim); }
.wizard-step.done { border-color: var(--verde); }
.wizard-step-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--bg-4);
  color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  flex-shrink: 0;
}
.wizard-step.active .wizard-step-num { background: var(--oro); color: var(--bg); }
.wizard-step.done .wizard-step-num { background: var(--verde); color: var(--bg); }
.wizard-step-label { font-size: 11.5px; font-weight: 600; color: var(--text-2); }
.wizard-step.active .wizard-step-label { color: var(--text); }

/* Canvas firmas */
.signature-box {
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  height: 140px;
  cursor: crosshair;
  touch-action: none;
}
.signature-label { font-size: 11px; color: var(--text-3); text-align: center; margin-top: 6px; }

/* Filter bar */
.filter-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 8px 10px;
  margin-bottom: 16px;
}
.filter-bar .form-input { min-width: 180px; flex: 1; max-width: 320px; }
.filter-bar .form-select { min-width: 130px; }

/* Empty state */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-3);
}
.empty svg { width: 42px; height: 42px; margin-bottom: 14px; opacity: 0.4; stroke: currentColor; }
.empty-title { font-family: var(--font-title); font-weight: 700; font-size: 15px; color: var(--text-2); margin-bottom: 6px; }
.empty-sub { font-size: 12.5px; }

/* =============================================================
   RESPONSIVE
   ============================================================= */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .bento { grid-template-columns: 1fr; }
  .bento-3 { grid-template-columns: 1fr; }
  .form-grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  :root { --rail-w: 56px; }
  .topbar { padding: 0 12px; }
  .cmd-hint { display: none; }
  .user-meta { display: none; }
  .user-chip { padding: 4px; }
  .project-picker { padding: 5px 8px; }
  .view-container { padding: 16px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .matrix { grid-template-columns: 22px repeat(5, 1fr); }
  .matrix-cell { font-size: 13px; }
  .wizard-step-label { display: none; }
  .view-title { font-size: 20px; }
  .compat-matrix { grid-template-columns: 100px repeat(7, 1fr); font-size: 9px; }
}
