/* ============================================================
   CoreKpital · Decision Engine — Design System
   Banca digital clara · primario índigo-violeta · firma IA en
   gradiente índigo→teal (todo lo que "piensa" lleva el gradiente)
   ============================================================ */

:root {
  --bg: #F5F7FB;
  --surface: #FFFFFF;
  --surface-2: #F9FAFD;
  --ink: #16233B;
  --ink-soft: #5B6B85;
  --ink-faint: #8B96AB;
  --line: #E6EAF3;
  --line-strong: #D6DCE9;

  --primary: #4B2FE0;
  --primary-600: #3D24C4;
  --primary-soft: #EEEBFC;
  --teal: #0EA5A4;
  --grad-ia: linear-gradient(120deg, #4B2FE0 0%, #2F6BE0 55%, #0EA5A4 100%);

  --success: #0BA678;
  --success-soft: #E3F6EF;
  --warning: #D97706;
  --warning-soft: #FCF0DE;
  --danger: #DC2626;
  --danger-soft: #FCE8E8;
  --info: #2563EB;
  --info-soft: #E7EFFD;

  --navy: #101A33;
  --navy-2: #18254A;
  --navy-line: rgba(255,255,255,.08);

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-1: 0 1px 2px rgba(22,35,59,.05), 0 1px 3px rgba(22,35,59,.07);
  --shadow-2: 0 10px 30px rgba(22,35,59,.12);

  --font-display: 'Sora', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;

  --sidebar-w: 240px;
  --topbar-h: 64px;
}

/* ---------- Reset & base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; font-size: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #C9D1E0; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; }
.num { font-family: var(--font-display); font-variant-numeric: tabular-nums; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  color: #C6CEE2;
  display: flex; flex-direction: column;
  position: fixed; inset: 0 auto 0 0;
  z-index: 40;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid var(--navy-line);
}
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--grad-ia);
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 19px; color: #fff;
  flex-shrink: 0;
}
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 16px; color: #fff; line-height: 1.1; }
.brand-sub { font-size: 10px; letter-spacing: .14em; color: #7E8BAD; font-weight: 600; }

.nav { flex: 1; padding: 14px 12px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  width: 100%; padding: 10px 12px; margin-bottom: 2px;
  border-radius: 9px; color: #A7B2CD; font-weight: 500; font-size: 13.5px;
  transition: background .15s, color .15s;
  text-align: left;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #E8ECF6; }
.nav-item.active { background: rgba(255,255,255,.10); color: #fff; position: relative; }
.nav-item.active::before {
  content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 3px; background: var(--grad-ia);
}

.sidebar-user {
  border-top: 1px solid var(--navy-line);
  padding: 14px 16px; display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.sidebar-user .avatar { background: rgba(255,255,255,.12); color: #fff; }
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { color: #fff; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; color: #7E8BAD; }
.logout-btn { color: #7E8BAD; padding: 6px; border-radius: 8px; }
.logout-btn:hover { color: #fff; background: rgba(255,255,255,.08); }
.logout-btn svg { width: 17px; height: 17px; display: block; }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px;
  padding: 0 28px;
  position: sticky; top: 0; z-index: 30;
}
.crumb { font-size: 13px; color: var(--ink-faint); }
.crumb b { color: var(--ink); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 12px; width: 240px;
  color: var(--ink-faint);
}
.search-box input { border: none; background: none; outline: none; width: 100%; font-size: 13px; }
.search-box svg { width: 15px; height: 15px; flex-shrink: 0; }

/* Selector de entidad (multi-tenant) */
.ent-select { position: relative; }
.ent-btn {
  display: flex; align-items: center; gap: 9px;
  border: 1px solid var(--line); background: var(--surface);
  padding: 8px 12px; border-radius: 10px; font-weight: 600; font-size: 13px;
  box-shadow: var(--shadow-1);
}
.ent-btn:hover { border-color: var(--line-strong); }
.ent-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.ent-btn svg { width: 14px; height: 14px; color: var(--ink-faint); }
.ent-menu {
  position: absolute; top: calc(100% + 6px); right: 0; min-width: 220px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-2); padding: 6px; z-index: 60; display: none;
}
.ent-menu.open { display: block; animation: pop .14s ease; }
.ent-opt {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border-radius: 8px; font-size: 13px; font-weight: 500; text-align: left;
}
.ent-opt:hover { background: var(--surface-2); }
.ent-opt.sel { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.ent-opt small { margin-left: auto; color: var(--ink-faint); font-weight: 400; }

/* Campana */
.icon-btn { position: relative; padding: 9px; border-radius: 10px; color: var(--ink-soft); border: 1px solid transparent; }
.icon-btn:hover { background: var(--bg); border-color: var(--line); }
.icon-btn svg { width: 18px; height: 18px; display: block; }
.icon-btn .dot-badge {
  position: absolute; top: 5px; right: 5px; min-width: 15px; height: 15px;
  background: var(--danger); color: #fff; font-size: 9.5px; font-weight: 700;
  border-radius: 8px; display: grid; place-items: center; padding: 0 4px;
  border: 2px solid var(--surface);
}
.notif-menu {
  position: absolute; top: calc(100% + 6px); right: 0; width: 360px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-2); z-index: 60; display: none; overflow: hidden;
}
.notif-menu.open { display: block; animation: pop .14s ease; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.notif-head b { font-size: 13.5px; }
.notif-head button { color: var(--primary); font-size: 12px; font-weight: 600; }
.notif-list { max-height: 380px; overflow-y: auto; }
.notif-item { display: flex; gap: 11px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: #F6F4FE; }
.notif-ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; }
.notif-ico svg { width: 15px; height: 15px; }
.notif-txt { font-size: 12.5px; line-height: 1.45; color: var(--ink); }
.notif-txt small { display: block; color: var(--ink-faint); margin-top: 2px; font-size: 11px; }

/* ---------- Área de contenido ---------- */
#view-root { padding: 26px 28px 48px; animation: viewIn .25s ease; max-width: 1440px; width: 100%; margin: 0 auto; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(-3px); } to { opacity: 1; transform: none; } }

.view-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.view-title h1 { font-size: 22px; letter-spacing: -.01em; }
.view-title p { color: var(--ink-soft); margin-top: 3px; font-size: 13.5px; }
.view-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- Componentes base ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-head h3 { font-size: 14.5px; font-weight: 600; }
.card-head .hint { font-size: 12px; color: var(--ink-faint); font-family: var(--font-body); font-weight: 400; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px; border-radius: 10px; font-weight: 600; font-size: 13px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  transition: all .15s; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: #C4CCDD; }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(75,47,224,.25); }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); }
.btn-ia { background: var(--grad-ia); border: none; color: #fff; box-shadow: 0 4px 16px rgba(47,107,224,.3); }
.btn-ia:hover { filter: brightness(1.07); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--bg); color: var(--ink); }
.btn-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn-danger:hover { background: #F8D8D8; }
.btn-success { background: var(--success-soft); border-color: transparent; color: var(--success); }
.btn-success:hover { background: #D2F0E4; }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 8px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.b-success { background: var(--success-soft); color: var(--success); }
.badge.b-warning { background: var(--warning-soft); color: #B45309; }
.badge.b-danger  { background: var(--danger-soft); color: var(--danger); }
.badge.b-info    { background: var(--info-soft); color: var(--info); }
.badge.b-primary { background: var(--primary-soft); color: var(--primary); }
.badge.b-neutral { background: #EEF1F7; color: var(--ink-soft); }
.badge.no-dot::before { display: none; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px;
  border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 12.5px; font-weight: 500; color: var(--ink-soft); transition: all .15s;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.sel { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }

.input, select.input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line-strong);
  border-radius: 10px; background: var(--surface); font-size: 13.5px; outline: none;
  transition: border .15s, box-shadow .15s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(75,47,224,.12); }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235B6B85' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 32px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.field .req { color: var(--danger); }

/* Range slider */
input[type=range] { -webkit-appearance: none; width: 100%; height: 5px; border-radius: 4px; background: var(--line-strong); outline: none; }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 17px; height: 17px; border-radius: 50%;
  background: var(--primary); border: 3px solid #fff; box-shadow: 0 1px 5px rgba(22,35,59,.3); cursor: pointer;
}

/* Toggle */
.toggle { position: relative; width: 38px; height: 21px; border-radius: 999px; background: #CBD3E1; transition: background .18s; flex-shrink: 0; }
.toggle::after { content: ''; position: absolute; top: 2.5px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.toggle.on { background: var(--success); }
.toggle.on::after { transform: translateX(16px); }

/* Tablas */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; padding: 11px 14px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--ink-faint); font-weight: 600;
  border-bottom: 1px solid var(--line); background: var(--surface-2);
  white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #FAFBFE; }
.table tbody tr.clickable { cursor: pointer; }
.table td .num { font-size: 13px; font-weight: 600; }
.row-enter { animation: rowIn .45s ease; }
@keyframes rowIn { from { opacity: 0; transform: translateX(-14px); background: var(--primary-soft); } to { opacity: 1; } }

/* Menú de acciones por fila */
.row-menu { position: relative; }
.row-menu-panel {
  position: absolute; right: 0; top: calc(100% + 4px); min-width: 190px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px;
  box-shadow: var(--shadow-2); padding: 5px; z-index: 50; display: none;
}
.row-menu-panel.open { display: block; animation: pop .12s ease; }
.row-menu-panel button {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border-radius: 7px; font-size: 12.5px; font-weight: 500; text-align: left;
}
.row-menu-panel button:hover { background: var(--surface-2); }
.row-menu-panel button.danger { color: var(--danger); }
.row-menu-panel button svg { width: 14px; height: 14px; opacity: .7; }
.row-menu-panel hr { border: none; border-top: 1px solid var(--line); margin: 4px 0; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tab {
  padding: 10px 16px; font-weight: 600; font-size: 13.5px; color: var(--ink-soft);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* KPI */
.kpi-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 20px; }
@media (max-width: 1200px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }
.kpi { padding: 16px 18px; position: relative; overflow: hidden; }
.kpi-label { font-size: 12px; color: var(--ink-soft); font-weight: 500; display: flex; align-items: center; gap: 7px; }
.kpi-label svg { width: 14px; height: 14px; color: var(--ink-faint); }
.kpi-value { font-family: var(--font-display); font-size: 26px; font-weight: 700; margin-top: 8px; letter-spacing: -.02em; }
.kpi-delta { font-size: 11.5px; font-weight: 600; margin-top: 5px; display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.kpi-delta svg { width: 12px; height: 12px; flex-shrink: 0; }
.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--danger); }
.kpi-delta.flat { color: var(--ink-faint); }

/* Grid utilitario */
.grid { display: grid; gap: 16px; }
.g-12 { grid-template-columns: repeat(12, 1fr); }
.col-3 { grid-column: span 3; } .col-4 { grid-column: span 4; } .col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; } .col-7 { grid-column: span 7; } .col-8 { grid-column: span 8; }
.col-9 { grid-column: span 9; } .col-12 { grid-column: span 12; }
@media (max-width: 1100px) { .g-12 > * { grid-column: span 12 !important; } }

/* Charts */
.chart-svg { width: 100%; display: block; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--ink-soft); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 52px; align-items: center; gap: 12px; margin-bottom: 11px; font-size: 12.5px; }
.bar-row .bar-label { color: var(--ink-soft); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 9px; background: #EDF0F7; border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; background: var(--primary); transition: width .8s cubic-bezier(.2,.8,.2,1); }
.bar-val { text-align: right; font-weight: 600; }

/* Weight bars (explainability) — llevan la firma IA */
.wbar { margin-bottom: 13px; }
.wbar-top { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 5px; }
.wbar-top b { font-weight: 600; }
.wbar-top .aporte { font-weight: 700; }
.wbar-top .aporte.pos { color: var(--success); }
.wbar-top .aporte.neg { color: var(--danger); }
.wbar-track { height: 8px; background: #EDF0F7; border-radius: 6px; overflow: hidden; }
.wbar-fill { height: 100%; border-radius: 6px; background: var(--grad-ia); transition: width .9s cubic-bezier(.2,.8,.2,1); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(16,26,51,.45); z-index: 80;
  display: grid; place-items: center; animation: fadeIn .15s ease; padding: 24px;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal-card {
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-2);
  width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto;
  animation: pop .18s ease;
}
.modal-card.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 14px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 16px; }
.modal-close { color: var(--ink-faint); padding: 5px; border-radius: 8px; }
.modal-close:hover { background: var(--bg); color: var(--ink); }
.modal-close svg { width: 17px; height: 17px; display: block; }
.modal-body { padding: 20px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px 18px; border-top: 1px solid var(--line); }

/* Toast */
#toast-root { position: fixed; bottom: 24px; right: 24px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 12px;
  box-shadow: var(--shadow-2); font-size: 13px; font-weight: 500;
  animation: toastIn .25s cubic-bezier(.2,.8,.2,1); max-width: 380px;
}
.toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.toast.t-success svg { color: #34D399; }
.toast.t-error svg { color: #F87171; }
.toast.t-info svg { color: #7DA7F9; }
.toast.out { animation: toastOut .25s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }

/* Empty state */
.empty {
  padding: 48px 24px; text-align: center; color: var(--ink-faint);
}
.empty svg { width: 38px; height: 38px; margin-bottom: 10px; opacity: .5; }
.empty p { font-size: 13.5px; }

/* Score chip */
.score-chip { font-family: var(--font-display); font-weight: 700; font-size: 13px; padding: 3px 9px; border-radius: 7px; }
.score-chip.alto { background: var(--success-soft); color: var(--success); }
.score-chip.medio { background: var(--warning-soft); color: #B45309; }
.score-chip.bajo { background: var(--danger-soft); color: var(--danger); }

/* Timeline */
.tl { position: relative; padding-left: 26px; }
.tl::before { content: ''; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 2px; background: var(--line-strong); border-radius: 2px; }
.tl-item { position: relative; padding-bottom: 20px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot {
  position: absolute; left: -26px; top: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--line-strong); display: grid; place-items: center;
}
.tl-item.done .tl-dot { border-color: var(--success); background: var(--success); }
.tl-item.done .tl-dot svg { width: 10px; height: 10px; color: #fff; }
.tl-item.now .tl-dot { border-color: var(--primary); }
.tl-item.now .tl-dot::after { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.tl-title { font-weight: 600; font-size: 13px; }
.tl-sub { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }

/* Etiqueta IA (firma) */
.ia-tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .05em;
  background: var(--grad-ia); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.ia-tag::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: var(--grad-ia); animation: pulse 2s infinite;
}
.ia-border { position: relative; }
.ia-border::before {
  content: ''; position: absolute; inset: 0; border-radius: var(--radius); padding: 1.5px;
  background: var(--grad-ia);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none;
}

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
@media (max-width: 900px) { .login-page { grid-template-columns: 1fr; } .login-brand { display: none; } }
.login-brand {
  background: var(--navy); color: #fff; padding: 56px;
  display: flex; flex-direction: column; position: relative; overflow: hidden;
}
.login-brand::after {
  content: ''; position: absolute; right: -180px; bottom: -180px; width: 520px; height: 520px;
  border-radius: 50%; background: radial-gradient(circle, rgba(75,47,224,.35), transparent 65%);
}
.login-brand::before {
  content: ''; position: absolute; left: -120px; top: -120px; width: 380px; height: 380px;
  border-radius: 50%; background: radial-gradient(circle, rgba(14,165,164,.18), transparent 65%);
}
.login-brand .brand { border: none; padding: 0; margin-bottom: 60px; }
.login-tagline { font-family: var(--font-display); font-size: 34px; font-weight: 700; line-height: 1.25; letter-spacing: -.02em; max-width: 440px; }
.login-tagline em { font-style: normal; background: var(--grad-ia); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-points { margin-top: 44px; display: flex; flex-direction: column; gap: 18px; z-index: 1; }
.login-point { display: flex; gap: 13px; align-items: flex-start; max-width: 400px; }
.login-point-ico { width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.08); display: grid; place-items: center; flex-shrink: 0; }
.login-point-ico svg { width: 16px; height: 16px; color: #9DB4F5; }
.login-point b { font-size: 13.5px; display: block; }
.login-point span { font-size: 12.5px; color: #93A1C2; line-height: 1.5; }
.login-foot { margin-top: auto; font-size: 12px; color: #5E6C90; z-index: 1; }
.login-form-side { display: grid; place-items: center; padding: 40px; background: var(--bg); }
.login-card { width: 100%; max-width: 400px; }
.login-card h1 { font-size: 24px; margin-bottom: 6px; }
.login-card > p { color: var(--ink-soft); margin-bottom: 28px; font-size: 13.5px; }
.login-card .field { margin-bottom: 16px; }
.login-links { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 22px; font-size: 12.5px; }
.demo-hint {
  margin-top: 22px; padding: 12px 14px; border-radius: 10px;
  background: var(--primary-soft); color: var(--primary); font-size: 12px; line-height: 1.5;
}

/* ---------- Flow Builder (Constructor de Reglas) ---------- */
.flow-wrap { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .flow-wrap { grid-template-columns: 1fr; } }
.flow-canvas-card { overflow: hidden; }
.flow-toolbar {
  display: flex; align-items: center; gap: 8px; padding: 12px 16px;
  border-bottom: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap;
}
.flow-toolbar .sep { width: 1px; height: 22px; background: var(--line-strong); margin: 0 4px; }
.flow-canvas {
  position: relative; height: 560px; overflow: auto;
  background-color: #FBFCFE;
  background-image: radial-gradient(#DDE3EF 1.1px, transparent 1.1px);
  background-size: 22px 22px;
  cursor: grab;
}
.flow-inner { position: relative; width: 1280px; height: 720px; }
.flow-edges { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.flow-node {
  position: absolute; border-radius: 12px; background: var(--surface);
  border: 1.5px solid var(--line-strong); box-shadow: var(--shadow-1);
  user-select: none; cursor: grab; transition: box-shadow .15s, border-color .15s;
}
.flow-node:hover { box-shadow: var(--shadow-2); }
.flow-node.sel { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(75,47,224,.15), var(--shadow-2); }
.flow-node.dragging { cursor: grabbing; opacity: .92; z-index: 10; }
.fn-inicio {
  width: 175px; padding: 12px 16px; border-radius: 999px;
  background: var(--navy); border-color: var(--navy); color: #fff;
  display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 12.5px;
}
.fn-inicio svg { width: 14px; height: 14px; color: #6EE7B7; }
.fn-cond { width: 195px; }
.fn-cond-head {
  display: flex; align-items: center; gap: 7px; padding: 8px 12px;
  border-bottom: 1px solid var(--line); font-size: 10.5px; font-weight: 700;
  letter-spacing: .08em; color: var(--primary);
}
.fn-cond-head .pri { margin-left: auto; background: var(--primary-soft); border-radius: 6px; padding: 1px 7px; font-size: 10px; }
.fn-cond-head .exc { background: var(--warning-soft); color: var(--warning); border-radius: 6px; padding: 1px 7px; font-size: 10px; }
.fn-cond-body { padding: 10px 12px; font-family: var(--font-display); font-size: 13px; font-weight: 600; }
.fn-cond-body small { display: block; color: var(--ink-faint); font-family: var(--font-body); font-weight: 400; font-size: 11px; margin-top: 2px; }
.fn-accion { width: 185px; padding: 12px 14px; display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 12.5px; border-width: 1.5px; }
.fn-accion svg { width: 15px; height: 15px; flex-shrink: 0; }
.flow-edit { position: sticky; top: 84px; }
.flow-edit .field { margin-bottom: 13px; }
.flow-palette-btn { border-style: dashed; }
.edge-label { font-size: 10px; font-weight: 700; }

/* ---------- Simulador ---------- */
.sim-steps { display: flex; flex-direction: column; gap: 0; }
.sim-step { display: flex; gap: 13px; opacity: .32; transition: opacity .3s; padding-bottom: 18px; position: relative; }
.sim-step::before { content: ''; position: absolute; left: 15px; top: 34px; bottom: 2px; width: 2px; background: var(--line-strong); }
.sim-step:last-child::before { display: none; }
.sim-step.on { opacity: 1; }
.sim-step-dot {
  width: 32px; height: 32px; border-radius: 50%; background: var(--surface);
  border: 2px solid var(--line-strong); display: grid; place-items: center; flex-shrink: 0; z-index: 1;
}
.sim-step-dot svg { width: 14px; height: 14px; color: var(--ink-faint); }
.sim-step.on .sim-step-dot { border-color: transparent; background: var(--grad-ia); }
.sim-step.on .sim-step-dot svg { color: #fff; }
.sim-step.running .sim-step-dot { animation: simPulse 1s infinite; }
@keyframes simPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(75,47,224,.35); } 50% { box-shadow: 0 0 0 8px rgba(75,47,224,0); } }
.sim-step-body { flex: 1; padding-top: 5px; }
.sim-step-title { font-weight: 600; font-size: 13.5px; }
.sim-step-sub { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.sim-rule { display: flex; align-items: center; gap: 9px; padding: 7px 11px; border-radius: 8px; background: var(--surface-2); font-size: 12px; font-family: var(--font-display); font-weight: 600; margin-top: 7px; opacity: 0; transform: translateY(4px); transition: all .3s; }
.sim-rule.show { opacity: 1; transform: none; }
.sim-rule.ok { background: var(--success-soft); }
.sim-rule.fail { background: var(--danger-soft); }
.sim-rule svg { width: 13px; height: 13px; }
.sim-result { border-radius: 14px; padding: 22px; text-align: center; animation: pop .4s cubic-bezier(.2,.8,.2,1); }
.sim-result h2 { font-size: 24px; }
.typing-dots { display: inline-flex; gap: 4px; margin-left: 6px; }
.typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; animation: blink 1.2s infinite; }
.typing-dots i:nth-child(2) { animation-delay: .2s; }
.typing-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100% { opacity: .25; } 40% { opacity: 1; } }
