/* ══════════════════════════════════════════════════════════════
   KACHAI · Sistema de diseño (CSS propio, sin frameworks)
   Kernel de Acceso y Conexión de Herramientas de Inteligencia Artificial
   ══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=swap');

/* ─────────── Tokens ─────────── */
:root {
  --bg: #020713;
  --bg-2: #01040c;
  --panel: #0b1830;
  --panel-2: #0D1A33;
  --cyan: #4E8CF0;
  --violet: #E8657A;
  --mid: #1E5BD6;
  --ink: #F4F7FF;
  --slate-200: #E2E8F0;
  --slate-300: #CBD5E1;
  --slate-400: #94A3B8;
  --slate-500: #64748B;
  --slate-600: #475569;
  --muted: #8A93A6;
  --muted-2: #6B7386;
  --success: #3EE6A0;
  --success-bg: rgba(62,230,160,.08);
  --warning: #FBBF24;
  --danger: #F87171;
  --line: rgba(255,255,255,.06);
  --line-2: rgba(255,255,255,.1);
  --grad: linear-gradient(102deg, #6BA3FF 0%, #0033A0 42%, #FFFFFF 62%, #C8102E 100%);
  --grad-soft: linear-gradient(120deg, rgba(78,140,240,.8), rgba(232,101,122,.8));
  --r-lg: 20px;
  --r-md: 16px;
  --r-sm: 12px;
  --shadow-1: 0 8px 24px -8px rgba(0,0,0,.8);

  /* ── Tipografía normalizada ── */
  --font-sans: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --fs-xs: 11px;
  --fs-sm: 12.5px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;
  --fs-2xl: 28px;
  --fs-3xl: 40px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }

/* Tap highlight transparente en móvil para evitar flashes grises */
* { -webkit-tap-highlight-color: transparent; }

/* Normalizar selección */
::selection { background: rgba(78,140,240,.3); }

.mono, .font-mono { font-family: var(--font-mono); }
.ms, .msr {
  font-family: 'Material Symbols Rounded';
  font-weight: normal; font-style: normal; line-height: 1;
  display: inline-block; white-space: nowrap; direction: ltr;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  -webkit-font-smoothing: antialiased;
}
.ms-fill, .msr-fill { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }

.grad-text {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.grad-bg { background: var(--grad); }

/* ─────────── Logo normalizado (KACHAI) ─────────── */
.brand-logo {
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: .22em;
  font-size: 15px;
  color: #fff;
  white-space: nowrap;
}
.brand-logo .grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(120deg, rgba(78,140,240,.8), rgba(232,101,122,.8)) padding-box;
  display: grid; place-items: center; font-weight: 700; color: #fff;
  box-shadow: 0 0 18px rgba(78,140,240,.35);
  font-family: var(--font-mono); font-size: 15px;
}

/* ─────────── Botones ─────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 999px; font-weight: 600; font-size: var(--fs-md);
  padding: 12px 28px; border: none; transition: filter .18s, box-shadow .18s;
}
.btn-grad { background: var(--grad); color: var(--bg); box-shadow: 0 0 24px rgba(78,140,240,.3); }
.btn-grad:hover { filter: brightness(1.1); }
.btn-ghost {
  background: transparent; color: var(--slate-300, #CBD5E1);
  border: 1px solid var(--line-2); border-radius: 999px;
  padding: 11px 28px; font-weight: 500;
}
.btn-ghost:hover { border-color: rgba(255,255,255,.35); }
.btn-sm { padding: 8px 20px; font-size: 13px; border-radius: 999px; }
.btn-icon {
  width: 36px; height: 36px; display: inline-grid; place-items: center;
  border-radius: 12px; background: var(--panel); border: 1px solid var(--line);
  color: var(--slate-400); transition: color .15s, border-color .15s;
}
.btn-icon:hover { color: #fff; border-color: rgba(255,255,255,.2); }

/* ─────────── Chips ─────────── */
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 16px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line);
  font-size: var(--fs-sm); color: var(--slate-300, #CBD5E1);
  transition: border-color .15s, color .15s;
}
.chip:hover { border-color: rgba(78,140,240,.5); color: #fff; }

/* ─────────── Barras de búsqueda normalizadas ─────────── */
.search-box {
  display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 12px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line);
  transition: border-color .15s;
}
.search-box:focus-within { border-color: rgba(78,140,240,.4); }
.search-box input {
  flex: 1; min-width: 0; background: transparent; border: none; outline: none;
  color: var(--slate-200); font-family: var(--font-sans); font-size: var(--fs-sm);
}
.search-box input::placeholder { color: var(--slate-500); }
.search-box .ms { color: var(--slate-500); font-size: 16px; flex: none; }
.search-box .kbd {
  font-family: var(--font-mono); font-size: 9.5px; color: var(--slate-500);
  border: 1px solid var(--line); background: rgba(255,255,255,.04);
  border-radius: 4px; padding: 1px 5px; flex: none;
}

/* ─────────── Motivo puntitos ─────────── */
.dots {
  background-image: radial-gradient(rgba(78,140,240,.18) 1px, transparent 1px);
  background-size: 14px 14px;
}
.dots-violet {
  background-image: radial-gradient(rgba(232,101,122,.2) 1px, transparent 1px);
  background-size: 14px 14px;
}

/* ─────────── Layout app (chat/admin/account) ─────────── */
.app-shell { display: flex; min-height: 100dvh; }

/* Sidebar */
.sidebar {
  width: 260px; flex: none; background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100dvh;
}
.sidebar__head { padding: 24px 20px 20px; }
.sidebar__brand { display: flex; align-items: center; gap: 12px; }
.sidebar__logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(120deg, rgba(78,140,240,.8), rgba(232,101,122,.8)) padding-box;
  display: grid; place-items: center; font-weight: 700; color: #fff;
  box-shadow: 0 0 18px rgba(78,140,240,.35);
  font-family: var(--font-mono); font-size: 15px;
}
.sidebar__name { font-family: var(--font-mono); font-weight: 600; letter-spacing: .22em; font-size: 15px; }
.sidebar__sub { font-size: 10.5px; color: var(--slate-500); margin-top: 2px; letter-spacing: .05em; }
.sidebar__nav { flex: 1; overflow-y: auto; padding: 8px 12px; }
.sidebar__label {
  padding: 10px 12px 6px; font-size: 10px; font-weight: 500;
  text-transform: uppercase; letter-spacing: .18em; color: var(--slate-600);
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: 10px; font-size: 13px;
  color: var(--slate-400); transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.04); color: #fff; }
.nav-item.is-active {
  background: linear-gradient(90deg, rgba(78,140,240,.12), rgba(232,101,122,.08));
  color: #fff; font-weight: 500; border: 1px solid rgba(78,140,240,.22);
}
.nav-item.is-active .ms { color: var(--cyan); }
.sidebar__foot { padding: 12px; border-top: 1px solid var(--line); display: grid; gap: 12px; }

/* Card perfil */
.profile-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px;
}
.profile-card img { width: 38px; height: 38px; border-radius: 50%; }
.profile-card__name { font-size: 13px; font-weight: 500; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-card__meta { font-size: 10px; margin-top: 2px; }
.badge-plan {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 9px; letter-spacing: .04em;
  color: #8FD0FF; background: rgba(78,140,240,.08);
  border: 1px solid rgba(232,101,122,.3); padding: 2px 7px; border-radius: 999px;
}
.badge-plan .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--cyan); }

/* Main */
.shell-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  min-height: 60px; padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(4,7,15,.85); backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 10;
}
.content { flex: 1; padding: 24px; display: grid; gap: 20px; align-content: start; }

/* ─────────── KPI cards ─────────── */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi {
  background: linear-gradient(180deg, #0C1424, #070B16);
  border: 1px solid var(--line); border-radius: 14px; padding: 18px;
  transition: border-color .2s;
}
.kpi:hover { border-color: rgba(78,140,240,.25); }
.kpi__head { display: flex; justify-content: space-between; align-items: center; }
.kpi__label { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--slate-500); }
.kpi__icon { font-size: 22px; opacity: .7; }
.kpi__value { font-family: var(--font-mono); font-size: 26px; font-weight: 600; color: #fff; margin-top: 10px; }
.kpi__trend {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 8px;
  font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 999px;
}
.kpi__trend.up { background: rgba(16,185,129,.1); color: #34D399; }
.kpi__trend.down { background: rgba(251,191,36,.1); color: var(--warning); }
.kpi canvas { width: 92px; height: 38px; }

/* ─────────── Grid ─────────── */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.grid-2-1 { grid-template-columns: 2fr 1fr; }
.grid-1-2 { grid-template-columns: 1fr 2fr; }
.grid-7-5 { grid-template-columns: 7fr 5fr; }

/* ─────────── Cards genéricas ─────────── */
.card {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 20px;
}
.card--flush { padding: 0; overflow: hidden; }
.card__head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; }
.card__title { font-size: var(--fs-lg); font-weight: 600; color: #fff; }
.card__sub { font-size: var(--fs-sm); color: var(--slate-500); margin-top: 2px; }
.card__body { padding: 0 20px 20px; }
.card--flush .card__body { padding: 0; }

.link-muted { color: var(--cyan); font-size: var(--fs-sm); display: inline-flex; align-items: center; gap: 4px; }
.link-muted:hover { color: #fff; }

/* ─────────── Tablas con formato mejorado ─────────── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
thead th {
  text-align: left; font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .12em; color: var(--slate-500);
  padding: 12px 16px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  white-space: nowrap; background: rgba(255,255,255,.015);
}
tbody td {
  padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,.04);
  white-space: nowrap; vertical-align: middle; color: var(--slate-300);
}
tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(255,255,255,.03); }
tbody tr:last-child td { border-bottom: none; }
td.right, th.right { text-align: right; }
.td-user { display: flex; align-items: center; gap: 10px; }
.td-user img { width: 32px; height: 32px; border-radius: 50%; }
.td-user__name { font-weight: 500; color: var(--slate-200); }
.td-user__mail { font-size: 11px; color: var(--slate-500); }

/* Tablas en móvil: celdas más compactas y legibles */
@media (max-width: 640px) {
  thead th { padding: 10px 10px; font-size: 9.5px; }
  tbody td { padding: 10px; font-size: var(--fs-xs); }
  .td-user__mail { font-size: 10px; }
}

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 500; padding: 3px 10px; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap;
}
.badge-pro { color: #A78BFA; background: rgba(232,101,122,.12); border-color: rgba(232,101,122,.25); }
.badge-business { color: var(--cyan); background: rgba(78,140,240,.12); border-color: rgba(78,140,240,.25); }
.badge-free { color: var(--slate-300); background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.15); }
.badge-starter { color: #34D399; background: rgba(16,185,129,.1); border-color: rgba(16,185,129,.25); }
.badge-enterprise { color: var(--warning); background: rgba(251,191,36,.1); border-color: rgba(251,191,36,.25); }
.badge-success { color: #34D399; background: rgba(16,185,129,.1); border-color: rgba(16,185,129,.2); }
.badge-danger { color: var(--danger); background: rgba(248,113,113,.1); border-color: rgba(248,113,113,.2); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; }
.dot-emerald { background: #34D399; }
.dot-rose { background: var(--danger); }

/* ─────────── Barras de progreso ─────────── */
.progress { height: 6px; background: rgba(255,255,255,.06); border-radius: 999px; overflow: hidden; }
.progress__bar { height: 100%; border-radius: 999px; background: var(--grad); }

.bar-row { margin-bottom: 12px; }
.bar-row__head { display: flex; justify-content: space-between; font-size: var(--fs-sm); margin-bottom: 6px; }
.bar-row__name { color: var(--slate-300, #CBD5E1); }
.bar-row__val { font-family: var(--font-mono); color: var(--slate-500); }
.bar-row__val strong { color: #fff; font-weight: 600; }

/* ─────────── Toggles ─────────── */
.tgl {
  appearance: none; -webkit-appearance: none;
  width: 40px; height: 22px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line-2);
  position: relative; cursor: pointer; outline: none; flex: none;
}
.tgl::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #8A93A6; transition: transform .2s, background .2s;
}
.tgl:checked { background: var(--grad); border-color: transparent; box-shadow: 0 2px 10px -2px rgba(85,140,255,.5); }
.tgl:checked::after { transform: translateX(18px); background: #fff; }

/* ─────────── Select ─────────── */
.sel {
  background: var(--panel); border: 1px solid var(--line-2); color: var(--ink);
  border-radius: 8px; padding: 6px 10px; font-size: var(--fs-sm); outline: none; cursor: pointer;
  font-family: var(--font-sans);
}

/* ─────────── Health / status ─────────── */
.status-dot { display: inline-flex; align-items: center; gap: 10px; }
.status-dot .ping { position: relative; width: 8px; height: 8px; }
.status-dot .ping::before {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  background: #34D399; animation: ping 1.4s ease-in-out infinite;
}
.status-dot .ping::after { content: ''; position: absolute; inset: 2px; border-radius: 50%; background: #34D399; }
@keyframes ping { 0%,100% { opacity: 1 } 50% { opacity: .35 } }

/* Logs */
.log-line {
  display: flex; gap: 8px; font-family: var(--font-mono); font-size: 10.5px;
  padding: 4px 0 4px 10px; border-left: 2px solid rgba(78,140,240,.6);
}
.log-line__time { color: var(--slate-600); flex: none; width: 52px; }
.log-line__lvl { flex: none; width: 34px; }
.log-line__msg { color: var(--slate-400); }
.log-line.warn { border-left-color: rgba(251,191,36,.6); }
.log-line.error { border-left-color: rgba(248,113,113,.6); }

/* Servicios salud */
.svc { display: flex; align-items: center; justify-content: space-between; }
.svc__name { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--slate-200); }
.svc__lat { font-family: var(--font-mono); font-size: 11px; }

/* RAG docs */
.doc-card {
  border: 1px solid var(--line); border-radius: 14px; background: var(--panel);
  padding: 16px; transition: border-color .18s, background .18s, transform .18s;
}
.doc-card:hover { border-color: rgba(255,255,255,.16); background: var(--panel-2); transform: translateY(-2px); }
.doc-card__fmt { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; }
.doc-card__name { font-size: 13.5px; font-weight: 500; color: #fff; margin-top: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-card__size { font-family: var(--font-mono); font-size: 11px; color: var(--muted-2); margin-top: 3px; }
.doc-card__status { display: flex; align-items: center; gap: 6px; font-size: 12px; margin-top: 10px; }
.doc-card__status .dot { width: 6px; height: 6px; border-radius: 50%; }

.drop-cta {
  border: 1px dashed rgba(255,255,255,.14); border-radius: 16px;
  min-height: 140px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 8px; background: transparent; color: var(--slate-400);
  transition: border-color .18s, background .18s; font-size: 13px;
  cursor: pointer;
}
.drop-cta:hover { border-color: rgba(78,140,240,.55); background: rgba(78,140,240,.04); }
.drop-cta small { font-size: 11.5px; color: var(--muted-2); }

/* ─────────── Nota / callout ─────────── */
.callout {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid rgba(78,140,240,.18); background: rgba(78,140,240,.05);
  border-radius: 12px; padding: 14px;
}
.callout__icon { width: 36px; height: 36px; border-radius: 12px; background: rgba(78,140,240,.12); display: grid; place-items: center; color: var(--cyan); flex: none; }
.callout strong { color: var(--slate-200); font-weight: 500; }

/* ─────────── Responsive ─────────── */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-3, .grid-7-5, .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; z-index: 50; transform: translateX(-100%); transition: transform .25s; }
  .sidebar.is-open { transform: translateX(0); }
  .shell-main { width: 100%; }
  .content { padding: 16px; }
}
@media (max-width: 640px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi__value { font-size: 20px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .content { padding: 12px; }
  .card { padding: 14px; }
}
@media (max-width: 480px) {
  .kpis { grid-template-columns: 1fr; }
}

/* Soportes táctiles: cursor pointer y feedback de toque (evita hover fantasma) */
@media (hover: hover) and (pointer: fine) {
  .btn-icon:hover, .nav-item:hover, .chip:hover { /* hover solo en dispositivos con mouse */ }
}
@media (hover: none) and (pointer: coarse) {
  .btn-icon:active, .nav-item:active, .chip:active, .card:active { transform: scale(.98); transition: transform .08s; }
  tbody tr:active { background: rgba(255,255,255,.05); }
}

/* Utility */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-16 { margin-bottom: 16px; }
.w-full { width: 100%; }
.text-sm { font-size: 13px !important; }
.text-xs { font-size: 12px !important; }
.muted { color: var(--slate-500); }
.hidden { display: none !important; }

/* Scrollbars */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 99px; }
::-webkit-scrollbar-track { background: transparent; }

/* ══════════════════════════════════════════════════════════════
   GRAF · Grafo Interactivo de Módulos (estética KACHAI)
   Paleta: azul #4E8CF0, violeta #E8657A, fondo #04070F.
   ══════════════════════════════════════════════════════════════ */

.graf-body {
  background: #04070F;
  color: var(--ink);
  overflow: hidden;
  height: 100dvh;
  font-family: var(--font-mono);
}

/* ── Fondo de partículas flotantes ── */
.graf-particles {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: .55;
}

/* ── Header ── */
.graf-header {
  position: relative;
  z-index: 30;
  border-bottom: 1px solid rgba(78,140,240,.15);
  background: rgba(4,7,15,.85);
  backdrop-filter: blur(8px);
}
.graf-header__inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.graf-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #fff;
  flex: none;
}
.graf-logo__mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(78,140,240,.5);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0;
  background: linear-gradient(135deg, rgba(78,140,240,.3), rgba(232,101,122,.3));
  color: #fff;
  box-shadow: 0 0 14px rgba(78,140,240,.25);
}
.graf-logo__text {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .28em;
}
.graf-search {
  flex: 1;
  min-width: 200px;
  max-width: 460px;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(78,140,240,.2);
  border-radius: 8px;
  background: rgba(11,17,32,.8);
  color: var(--slate-400);
  transition: border-color .15s;
}
.graf-search:focus-within {
  border-color: rgba(78,140,240,.7);
  box-shadow: 0 0 0 3px rgba(78,140,240,.08);
}
.graf-search .ms { font-size: 18px; flex: none; color: var(--cyan); }
.graf-search input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 13px;
}
.graf-search input::placeholder { color: var(--slate-500); }
.graf-search__hint {
  flex: none;
  font-size: 9px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--slate-500);
  border: 1px solid rgba(78,140,240,.2);
  border-radius: 4px;
  padding: 2px 6px;
}
.graf-metric__value {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  line-height: 1.2;
}
.graf-metric__label {
  font-size: 9px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--slate-500);
}
.graf-metric__value {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  line-height: 1.2;
}
.graf-metric__label {
  font-size: 9px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #666;
}

/* ── Stage / canvas ── */
.graf-stage {
  position: relative;
  z-index: 10;
  flex: 1;
  height: calc(100dvh - 62px);
  overflow: hidden;
}
/* Mientras el mapa de capacidades se reconstruye, el grafo es decorativo:
   no responde al puntero y el foco vive en el cartel de estado. */
.graf-canvas {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  outline: none;
  opacity: .5;
}

/* ── Cartel de estado: el mapa está en construcción ── */
.graf-header__spacer { flex: 1; }
.graf-back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border: 1px solid rgba(78,140,240,.28);
  border-radius: 8px;
  color: var(--slate-300, #c3ccdc);
  font-size: 12px;
  text-decoration: none;
  transition: border-color .2s ease, color .2s ease;
}
.graf-back:hover { border-color: rgba(78,140,240,.6); color: #fff; }
.graf-back .ms { font-size: 16px; }

.graf-wip {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  pointer-events: none;
}
.graf-wip > * { pointer-events: auto; }

.graf-wip__badge {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 6px 14px;
  border: 1px solid rgba(251,191,36,.34);
  border-radius: 999px;
  background: rgba(251,191,36,.07);
  color: #FBBF24;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .22em;
}
.graf-wip__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #FBBF24;
  animation: graf-latido 1.8s ease-in-out infinite;
}
@keyframes graf-latido {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .35; transform: scale(.7); }
}

.graf-wip__title {
  margin: 0;
  font-family: var(--font-sans, inherit);
  font-size: clamp(26px, 5vw, 42px);
  font-weight: 600;
  letter-spacing: -.01em;
  color: #fff;
}
.graf-wip__text {
  max-width: 44ch;
  margin: 0;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--slate-400, #8a93a6);
}

@media (prefers-reduced-motion: reduce) {
  .graf-wip__dot { animation: none; }
}

/* ── Tooltip monocromático ── */
.graf-tooltip {
  position: absolute;
  z-index: 50;
  max-width: 240px;
  padding: 8px 12px;
  background: #111;
  border: 1px solid #444;
  border-radius: 6px;
  color: #ccc;
  font-size: 11px;
  line-height: 1.5;
  pointer-events: none;
  transform: translate(12px, 12px);
  box-shadow: 0 4px 16px rgba(0,0,0,.6);
}
.graf-tooltip b {
  display: block;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 2px;
}
.graf-tooltip small {
  display: block;
  color: #777;
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* ── Sidebar inspección ── */
.graf-sidebar {
  position: absolute;
  top: 12px;
  right: 12px;
  bottom: 12px;
  width: 300px;
  z-index: 40;
  background: #0a0a0a;
  border: 1px solid #333;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: -8px 0 32px rgba(0,0,0,.7);
}
.graf-sidebar[hidden] { display: none; }
.graf-sidebar__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid #222;
}
.graf-sidebar__cat {
  font-size: 9px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: #666;
}
.graf-sidebar__title {
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  line-height: 1.3;
  margin-top: 4px;
}
.graf-sidebar__close {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid #333;
  background: #111;
  color: #aaa;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: none;
  transition: border-color .15s, color .15s;
}
.graf-sidebar__close:hover {
  border-color: #fff;
  color: #fff;
}
.graf-sidebar__close .ms { font-size: 16px; }
.graf-sidebar__body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
}
.graf-sidebar__meta {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.graf-sidebar__meta > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.graf-sidebar__meta dt {
  font-size: 9px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #666;
}
.graf-sidebar__meta dd {
  margin: 0;
  font-size: 13px;
  color: #ddd;
  word-break: break-all;
}
.graf-sidebar__meta dd a {
  color: #fff;
  border-bottom: 1px solid #444;
  padding-bottom: 1px;
  text-decoration: none;
}
.graf-sidebar__meta dd a:hover { border-color: #fff; }
.graf-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #ccc;
}
.graf-status::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #888;
  flex: none;
}
.graf-status[data-state="online"]::before { background: #fff; box-shadow: 0 0 6px #fff; }
.graf-status[data-state="degraded"]::before { background: #aaa; box-shadow: 0 0 4px #aaa; }
.graf-status[data-state="offline"]::before { background: #444; }
.graf-sidebar__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 20px;
}
.graf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .04em;
  cursor: pointer;
  text-decoration: none;
  background: #111;
  border: 1px solid #333;
  color: #ccc;
  transition: border-color .15s, color .15s, background .15s;
}
.graf-btn:hover {
  border-color: #fff;
  color: #fff;
  background: #1a1a1a;
}
.graf-btn .ms { font-size: 15px; }
.graf-btn--primary {
  background: #fff;
  border-color: #fff;
  color: #000;
}
.graf-btn--primary:hover {
  background: #ddd;
  border-color: #ddd;
  color: #000;
}

/* ── Leyenda ── */
.graf-legend {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 30;
  max-width: 220px;
  padding: 12px;
  background: rgba(0,0,0,.85);
  border: 1px solid #222;
  border-radius: 8px;
  backdrop-filter: blur(4px);
}
.graf-legend__title {
  font-size: 9px;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: #888;
  margin-bottom: 8px;
  font-weight: 600;
}
.graf-legend__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.graf-legend__list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  color: #aaa;
  letter-spacing: .04em;
}
.graf-legend__swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid #fff;
  flex: none;
}

/* ── Responsive graf-graph ── */
@media (max-width: 900px) {
  .graf-metrics { display: none; }
  .graf-header__inner { gap: 12px; padding: 10px 14px; }
  .graf-search { max-width: none; }
  .graf-sidebar {
    right: 8px;
    left: 8px;
    width: auto;
    top: auto;
    bottom: 0;
    max-height: 55dvh;
    border-radius: 10px 10px 0 0;
  }
  .graf-stage { height: calc(100dvh - 60px); }
}
@media (max-width: 480px) {
  .graf-search__hint { display: none; }
  .graf-legenda { display: none; }
}

/* ── GRAF · estados reales de los módulos ───────────────────
   activo = herramienta registrada y habilitada · parcial = servicio
   presente sin exponer al chat · planificado = en hoja de ruta. */
.graf-status[data-state="activo"]::before     { background: #3EE6A0; box-shadow: 0 0 7px #3EE6A0; }
.graf-status[data-state="parcial"]::before    { background: #FBBF24; box-shadow: 0 0 5px #FBBF24; }
.graf-status[data-state="desarrollo"]::before { background: transparent; border: 2px solid #9BAAC4; }
.graf-status[data-state="unknown"]::before    { background: rgba(157,193,245,.35); }
