/* ==========================================================================
   Fragmental · tema oscuro + estilos
   Paleta: neutrales tintados de violeta (Void/Slate) + acento periwinkle
   (Lumen) y un teal atenuado (Signal) reservado para "fresco / sincronizado".
   Tipografías: Space Grotesk (marca/títulos), Roboto Flex (interfaz),
   JetBrains Mono (datos, claves, contexto).
   ========================================================================== */

:root {
  color-scheme: dark;

  /* --- Material 3 · esquema de color (dark) ------------------------------ */
  --md-sys-color-primary: #c6beff;
  --md-sys-color-on-primary: #2b1d66;
  --md-sys-color-primary-container: #43367f;
  --md-sys-color-on-primary-container: #e5deff;

  --md-sys-color-secondary: #c9c3dc;
  --md-sys-color-on-secondary: #312d41;
  --md-sys-color-secondary-container: #484459;
  --md-sys-color-on-secondary-container: #e6def8;

  --md-sys-color-tertiary: #93d5c6;
  --md-sys-color-on-tertiary: #003731;
  --md-sys-color-tertiary-container: #1f4e47;
  --md-sys-color-on-tertiary-container: #aff2e3;

  --md-sys-color-error: #f2b8b5;
  --md-sys-color-on-error: #601410;
  --md-sys-color-error-container: #8c1d18;
  --md-sys-color-on-error-container: #f9dedc;

  --md-sys-color-background: #0c0b10;
  --md-sys-color-on-background: #e7e1e9;
  --md-sys-color-surface: #0c0b10;
  --md-sys-color-on-surface: #e7e1e9;
  --md-sys-color-surface-variant: #48454e;
  --md-sys-color-on-surface-variant: #c9c3d3;

  --md-sys-color-surface-dim: #0c0b10;
  --md-sys-color-surface-bright: #322f39;
  --md-sys-color-surface-container-lowest: #070609;
  --md-sys-color-surface-container-low: #15131a;
  --md-sys-color-surface-container: #19171f;
  --md-sys-color-surface-container-high: #232028;
  --md-sys-color-surface-container-highest: #2e2b34;

  --md-sys-color-outline: #948f9c;
  --md-sys-color-outline-variant: #35323c;
  --md-sys-color-inverse-surface: #e7e1e9;
  --md-sys-color-inverse-on-surface: #322f39;
  --md-sys-color-inverse-primary: #5c4d99;
  --md-sys-color-surface-tint: #c6beff;
  --md-sys-color-shadow: #000000;
  --md-sys-color-scrim: #000000;

  /* Tipografías que usan los componentes Material */
  --md-ref-typeface-brand: "Roboto Flex", system-ui, sans-serif;
  --md-ref-typeface-plain: "Roboto Flex", system-ui, sans-serif;

  /* --- Tokens propios de Fragmental ------------------------------------- */
  --fr-display: "Space Grotesk", system-ui, sans-serif;
  --fr-body: "Roboto Flex", system-ui, sans-serif;
  --fr-mono: "JetBrains Mono", ui-monospace, monospace;

  --fr-accent: #c6beff;       /* Lumen  */
  --fr-accent-dim: #9a8fe0;
  --fr-signal: #93d5c6;       /* Signal (teal atenuado) */
  --fr-ok: #8ed6a4;
  --fr-warn: #e7c08b;
  --fr-stale: #e0a19d;
  --fr-muted: #8b8695;

  --fr-hairline: #24222b;
  --fr-hairline-strong: #322f3a;

  --fr-rail-w: 264px;
  --fr-topbar-h: 60px;
  --fr-radius: 18px;
  --fr-radius-sm: 12px;

  --fr-shadow: 0 1px 0 rgba(255, 255, 255, 0.02) inset,
    0 18px 40px -24px rgba(0, 0, 0, 0.7);
}

/* --- base ---------------------------------------------------------------- */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--md-sys-color-background);
  color: var(--md-sys-color-on-surface);
  font-family: var(--fr-body);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Fondo ambiental muy sutil: dos halos del acento, casi imperceptibles */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(120vw 80vh at 88% -10%, rgba(129, 111, 240, 0.10), transparent 55%),
    radial-gradient(90vw 70vh at -10% 110%, rgba(93, 213, 198, 0.06), transparent 55%);
}

::selection { background: rgba(198, 190, 255, 0.28); }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb {
  background: #2b2833;
  border: 3px solid transparent;
  background-clip: padding-box;
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover { background: #3a3745; background-clip: padding-box; }

a { color: inherit; }

/* material typescale font override para que herede Roboto Flex */
.md-typescale-body-medium,
.md-typescale-body-large { font-family: var(--fr-body); }

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

/* El overlay solo existe en móvil; nunca debe ocupar una celda del grid */
.scrim { display: none; }

/* --- Riel de navegación -------------------------------------------------- */
.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 14px 14px;
  border-right: 1px solid var(--fr-hairline);
  background: linear-gradient(180deg, rgba(21, 19, 26, 0.6), rgba(12, 11, 16, 0.6));
  backdrop-filter: blur(8px);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 6px 8px 16px;
}
.brand__mark { flex: none; }
.brand__name {
  font-family: var(--fr-display);
  font-weight: 600;
  font-size: 20px;
  letter-spacing: -0.02em;
  color: var(--md-sys-color-on-surface);
}
.brand__name b { color: var(--fr-accent); font-weight: 600; }
.brand__tag {
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fr-muted);
  margin-top: 1px;
}

.rail__group-label {
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fr-muted);
  padding: 16px 14px 6px;
}

.navitem {
  display: flex;
  align-items: center;
  gap: 13px;
  height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  position: relative;
  user-select: none;
  transition: background 0.16s ease, color 0.16s ease;
}
.navitem md-icon {
  --md-icon-size: 21px;
  font-variation-settings: "wght" 350, "opsz" 22;
}
.navitem span { font-size: 14px; font-weight: 450; }
.navitem:hover { background: rgba(255, 255, 255, 0.035); color: var(--md-sys-color-on-surface); }
.navitem.is-active {
  background: color-mix(in srgb, var(--fr-accent) 15%, transparent);
  color: var(--md-sys-color-on-surface);
}
.navitem.is-active md-icon { font-variation-settings: "wght" 500, "opsz" 22; color: var(--fr-accent); }
.navitem.is-active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--fr-accent);
}

.rail__spacer { flex: 1; }

.rail__foot {
  border-top: 1px solid var(--fr-hairline);
  padding-top: 12px;
  display: flex;
  align-items: center;
  gap: 11px;
}
.rail__foot .avatar { flex: none; }
.rail__foot .who { line-height: 1.25; min-width: 0; }
.rail__foot .who b { font-size: 13px; font-weight: 550; display: block; }
.rail__foot .who small { font-size: 11.5px; color: var(--fr-muted); }

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--fr-mono);
  font-size: 12px; font-weight: 600;
  color: var(--md-sys-color-on-primary-container);
  background: linear-gradient(135deg, #4a3d86, #6f5cc0);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* --- Zona de contenido --------------------------------------------------- */
.main { min-width: 0; display: flex; flex-direction: column; height: 100vh; }

.topbar {
  height: var(--fr-topbar-h);
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 26px;
  border-bottom: 1px solid var(--fr-hairline);
  background: rgba(12, 11, 16, 0.72);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.instance-switch {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 12px 6px 8px;
  border: 1px solid var(--fr-hairline-strong);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease;
}
.instance-switch:hover { background: var(--md-sys-color-surface-container-low); border-color: #43404c; }
.instance-switch .dot {
  width: 22px; height: 22px; border-radius: 7px;
  display: grid; place-items: center;
  font-family: var(--fr-display); font-weight: 600; font-size: 12px;
  color: #0c0b10; background: var(--fr-accent);
}
.instance-switch b { font-size: 13.5px; font-weight: 550; }
.instance-switch md-icon { --md-icon-size: 18px; color: var(--fr-muted); }

.topbar .search {
  flex: 1;
  max-width: 460px;
  display: flex; align-items: center; gap: 10px;
  height: 38px; padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--fr-hairline);
  background: var(--md-sys-color-surface-container-low);
  color: var(--fr-muted);
  cursor: text;
}
.topbar .search md-icon { --md-icon-size: 19px; }
.topbar .search span { font-size: 13.5px; }
.topbar .search kbd {
  margin-left: auto;
  font-family: var(--fr-mono); font-size: 11px;
  color: var(--fr-muted);
  border: 1px solid var(--fr-hairline-strong);
  border-radius: 6px; padding: 1px 6px;
}
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.topbar__right md-icon-button { --md-icon-button-icon-color: var(--md-sys-color-on-surface-variant); }

.content {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
}
.content__inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 34px 40px 96px;
  animation: rise 0.34s cubic-bezier(0.2, 0.7, 0.2, 1);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* --- Encabezado de página ------------------------------------------------ */
.page-head { margin-bottom: 26px; }
.eyebrow {
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--fr-accent-dim);
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.eyebrow::before {
  content: ""; width: 18px; height: 1px; background: var(--fr-accent-dim); opacity: 0.6;
}
h1.title {
  font-family: var(--fr-display);
  font-weight: 500;
  font-size: clamp(26px, 3vw, 34px);
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.08;
}
.subtitle {
  margin: 9px 0 0;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 15px;
  max-width: 68ch;
  line-height: 1.5;
}
.page-head__row { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }

/* --- Tarjetas / superficies --------------------------------------------- */
.card {
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--fr-hairline);
  border-radius: var(--fr-radius);
  box-shadow: var(--fr-shadow);
}
.card--pad { padding: 22px; }
.card--hover { transition: border-color 0.18s ease, transform 0.18s ease, background 0.18s ease; cursor: pointer; }
.card--hover:hover {
  border-color: var(--fr-hairline-strong);
  background: var(--md-sys-color-surface-container);
  transform: translateY(-2px);
}

.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.section-gap { margin-top: 30px; }

.section-label {
  display: flex; align-items: center; gap: 10px;
  font-size: 12.5px; font-weight: 600; letter-spacing: 0.04em;
  color: var(--md-sys-color-on-surface-variant);
  margin: 0 0 14px;
  text-transform: uppercase;
}
.section-label md-icon { --md-icon-size: 18px; color: var(--fr-muted); }
.section-label .count {
  font-family: var(--fr-mono); font-weight: 500; color: var(--fr-muted);
  background: var(--md-sys-color-surface-container); border-radius: 6px;
  padding: 1px 7px; font-size: 11px;
}

/* --- Stat cards (resumen) ------------------------------------------------ */
.stat { padding: 20px; display: flex; flex-direction: column; gap: 4px; }
.stat__top { display: flex; align-items: center; justify-content: space-between; }
.stat__icon {
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--fr-accent) 14%, transparent);
  color: var(--fr-accent);
}
.stat__icon md-icon { --md-icon-size: 21px; }
.stat__value {
  font-family: var(--fr-mono);
  font-size: 30px; font-weight: 600; letter-spacing: -0.02em;
  margin-top: 8px;
}
.stat__label { font-size: 13.5px; color: var(--md-sys-color-on-surface-variant); }
.stat__delta { font-size: 12px; color: var(--fr-signal); margin-top: 6px; display: flex; align-items: center; gap: 5px; }
.stat__delta md-icon { --md-icon-size: 15px; }

/* --- Hero del resumen ---------------------------------------------------- */
.hero {
  position: relative;
  overflow: hidden;
  padding: 26px 28px;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 20px;
  align-items: center;
}
.hero__field { position: absolute; inset: 0; opacity: 0.9; pointer-events: none; }
.hero__body { position: relative; z-index: 2; }
.hero h2 {
  font-family: var(--fr-display); font-weight: 500;
  font-size: 22px; letter-spacing: -0.01em; margin: 6px 0 8px; line-height: 1.2;
}
.hero p { color: var(--md-sys-color-on-surface-variant); font-size: 14.5px; line-height: 1.55; margin: 0 0 18px; max-width: 46ch; }
.hero__meters { display: flex; gap: 26px; }
.meter { position: relative; z-index: 2; }
.meter__val { font-family: var(--fr-mono); font-size: 22px; font-weight: 600; }
.meter__lbl { font-size: 12px; color: var(--fr-muted); }
.meter__bar { height: 4px; border-radius: 3px; background: var(--md-sys-color-surface-container-highest); margin-top: 8px; width: 128px; overflow: hidden; }
.meter__bar i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--fr-accent), var(--fr-signal)); }

/* --- Barra de fuentes ---------------------------------------------------- */
.sources { display: flex; flex-direction: column; gap: 14px; }
.srcbar { height: 10px; border-radius: 6px; overflow: hidden; display: flex; background: var(--md-sys-color-surface-container-highest); }
.srcbar i { height: 100%; }
.srclegend { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.srclegend div { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--md-sys-color-on-surface-variant); }
.srclegend .sw { width: 9px; height: 9px; border-radius: 3px; }
.srclegend b { font-family: var(--fr-mono); color: var(--md-sys-color-on-surface); font-weight: 500; }

/* --- Chips de estado ----------------------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 550;
  padding: 3px 10px 3px 8px; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap;
}
.pill .led { width: 6px; height: 6px; border-radius: 50%; }
.pill--ok { color: var(--fr-ok); background: color-mix(in srgb, var(--fr-ok) 12%, transparent); }
.pill--ok .led { background: var(--fr-ok); box-shadow: 0 0 8px var(--fr-ok); }
.pill--warn { color: var(--fr-warn); background: color-mix(in srgb, var(--fr-warn) 12%, transparent); }
.pill--warn .led { background: var(--fr-warn); }
.pill--stale { color: var(--fr-stale); background: color-mix(in srgb, var(--fr-stale) 12%, transparent); }
.pill--stale .led { background: var(--fr-stale); }
.pill--muted { color: var(--fr-muted); background: rgba(255,255,255,0.04); }
.pill--muted .led { background: var(--fr-muted); }

.tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--md-sys-color-on-surface-variant);
  background: var(--md-sys-color-surface-container); border: 1px solid var(--fr-hairline);
  border-radius: 999px; padding: 3px 11px;
}
.tag md-icon { --md-icon-size: 14px; color: var(--fr-muted); }

/* --- Feed de actividad --------------------------------------------------- */
.feed { display: flex; flex-direction: column; }
.feed__row { display: flex; gap: 14px; padding: 13px 4px; border-bottom: 1px solid var(--fr-hairline); }
.feed__row:last-child { border-bottom: 0; }
.feed__ic {
  flex: none; width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--md-sys-color-surface-container);
  color: var(--fr-muted);
}
.feed__ic md-icon { --md-icon-size: 19px; }
.feed__ic--primary { color: var(--fr-accent); background: color-mix(in srgb, var(--fr-accent) 12%, transparent); }
.feed__ic--tertiary { color: var(--fr-signal); background: color-mix(in srgb, var(--fr-signal) 12%, transparent); }
.feed__ic--warn { color: var(--fr-warn); background: color-mix(in srgb, var(--fr-warn) 12%, transparent); }
.feed__body { min-width: 0; }
.feed__body .who { font-size: 13.5px; font-weight: 550; }
.feed__body .txt { font-size: 13.5px; color: var(--md-sys-color-on-surface-variant); line-height: 1.45; }
.feed__at { margin-left: auto; font-size: 11.5px; color: var(--fr-muted); white-space: nowrap; font-family: var(--fr-mono); }

/* --- Lista de conocimiento ---------------------------------------------- */
.klist { display: flex; flex-direction: column; gap: 12px; }
.krow { padding: 18px 20px; display: grid; grid-template-columns: 1fr auto; gap: 6px 18px; align-items: start; }
.krow__title { font-family: var(--fr-display); font-weight: 500; font-size: 16.5px; letter-spacing: -0.01em; }
.krow__sum { font-size: 13.5px; color: var(--md-sys-color-on-surface-variant); line-height: 1.5; max-width: 74ch; margin-top: 3px; }
.krow__meta { display: flex; align-items: center; gap: 14px; margin-top: 12px; flex-wrap: wrap; }
.krow__meta small { font-size: 12px; color: var(--fr-muted); display: flex; align-items: center; gap: 6px; }
.krow__meta small md-icon { --md-icon-size: 15px; }
.krow__side { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.conf { display: flex; align-items: center; gap: 8px; font-family: var(--fr-mono); font-size: 12px; color: var(--md-sys-color-on-surface-variant); }
.conf .track { width: 54px; height: 5px; border-radius: 3px; background: var(--md-sys-color-surface-container-highest); overflow: hidden; }
.conf .track i { display: block; height: 100%; background: linear-gradient(90deg, var(--fr-signal), var(--fr-accent)); }

/* --- Documento renderizado (markdown) ----------------------------------- */
.md { font-size: 14.5px; line-height: 1.68; color: var(--md-sys-color-on-surface); }
.md h2 { font-family: var(--fr-display); font-weight: 500; font-size: 18px; letter-spacing: -0.01em; margin: 26px 0 10px; }
.md h3 { font-size: 15px; font-weight: 600; margin: 20px 0 8px; }
.md p { margin: 0 0 14px; color: var(--md-sys-color-on-surface-variant); }
.md strong { color: var(--md-sys-color-on-surface); font-weight: 600; }
.md ul, .md ol { margin: 0 0 16px; padding-left: 22px; color: var(--md-sys-color-on-surface-variant); }
.md li { margin: 5px 0; }
.md li::marker { color: var(--fr-accent-dim); }
.md blockquote {
  margin: 16px 0; padding: 12px 18px;
  border-left: 2px solid var(--fr-accent); border-radius: 0 10px 10px 0;
  background: color-mix(in srgb, var(--fr-accent) 7%, transparent);
  color: var(--md-sys-color-on-surface-variant); font-size: 13.5px;
}
.md code { font-family: var(--fr-mono); font-size: 0.9em; background: var(--md-sys-color-surface-container-high); padding: 2px 6px; border-radius: 6px; }

.detail-grid { display: grid; grid-template-columns: 1fr 300px; gap: 22px; align-items: start; }
.aside-card { position: sticky; top: 18px; }
.aside-block { padding: 18px 20px; }
.aside-block + .aside-block { margin-top: 16px; }
.aside-h { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fr-muted); margin: 0 0 12px; font-weight: 600; }
.src-item { display: flex; gap: 11px; padding: 9px 0; border-bottom: 1px solid var(--fr-hairline); }
.src-item:last-child { border-bottom: 0; }
.src-item md-icon { --md-icon-size: 18px; color: var(--fr-accent-dim); margin-top: 1px; }
.src-item b { font-size: 13px; font-weight: 500; display: block; line-height: 1.35; }
.src-item small { font-size: 11.5px; color: var(--fr-muted); }
.hist-item { padding: 9px 0 9px 18px; position: relative; border-left: 1px solid var(--fr-hairline-strong); }
.hist-item::before { content: ""; position: absolute; left: -4px; top: 14px; width: 7px; height: 7px; border-radius: 50%; background: var(--fr-accent-dim); }
.hist-item small { font-family: var(--fr-mono); font-size: 11px; color: var(--fr-muted); }
.hist-item p { font-size: 13px; margin: 3px 0 0; color: var(--md-sys-color-on-surface-variant); line-height: 1.45; }

/* --- Filtros de entidades ------------------------------------------------ */
.typefilter { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.typechip {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 15px; border-radius: 13px; cursor: pointer;
  border: 1px solid var(--fr-hairline);
  background: var(--md-sys-color-surface-container-low);
  transition: border-color 0.16s ease, background 0.16s ease;
}
.typechip:hover { border-color: var(--fr-hairline-strong); }
.typechip.is-active { border-color: color-mix(in srgb, var(--fr-accent) 55%, transparent); background: color-mix(in srgb, var(--fr-accent) 10%, transparent); }
.typechip md-icon { --md-icon-size: 20px; color: var(--fr-accent); }
.typechip b { font-size: 13.5px; font-weight: 550; }
.typechip small { font-family: var(--fr-mono); font-size: 11.5px; color: var(--fr-muted); }

.ent-card { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.ent-card__head { display: flex; gap: 13px; align-items: center; }
.ent-avatar {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  font-family: var(--fr-mono); font-weight: 600; font-size: 14px;
}
.ent-avatar--primary { color: var(--fr-accent); background: color-mix(in srgb, var(--fr-accent) 15%, transparent); }
.ent-avatar--tertiary { color: var(--fr-signal); background: color-mix(in srgb, var(--fr-signal) 15%, transparent); }
.ent-card__name { font-weight: 600; font-size: 15px; }
.ent-card__sub { font-size: 12px; color: var(--fr-muted); margin-top: 1px; }
.ent-card__fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.kv small { font-size: 11px; color: var(--fr-muted); display: block; }
.kv b { font-size: 13px; font-weight: 500; }

/* --- Detalle de entidad -------------------------------------------------- */
.ent-hero { display: flex; gap: 18px; align-items: center; padding: 24px; }
.ent-hero .ent-avatar { width: 60px; height: 60px; border-radius: 16px; font-size: 20px; }
.ent-hero h1 { font-family: var(--fr-display); font-weight: 500; font-size: 26px; margin: 0; letter-spacing: -0.02em; }
.ent-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px 24px; padding: 22px; }
.related-chip {
  display: flex; align-items: center; gap: 9px; padding: 10px 12px;
  border-radius: 11px; border: 1px solid var(--fr-hairline);
  background: var(--md-sys-color-surface-container-low); font-size: 13px;
  transition: border-color 0.16s ease; cursor: pointer;
}
.related-chip:hover { border-color: var(--fr-hairline-strong); }
.related-chip md-icon { --md-icon-size: 17px; color: var(--fr-accent-dim); }

/* --- Tabla de documentos ------------------------------------------------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--fr-muted); font-weight: 600; padding: 0 16px 12px; border-bottom: 1px solid var(--fr-hairline-strong);
}
.table td { padding: 14px 16px; border-bottom: 1px solid var(--fr-hairline); font-size: 13.5px; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background 0.14s ease; }
.table tbody tr:hover { background: var(--md-sys-color-surface-container-low); }
.doc-title { display: flex; align-items: center; gap: 12px; }
.doc-title .ficon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--md-sys-color-surface-container-high); color: var(--fr-accent-dim); flex: none; }
.doc-title .ficon md-icon { --md-icon-size: 18px; }
.doc-title b { font-weight: 500; }
.muted { color: var(--fr-muted); }
.mono { font-family: var(--fr-mono); }

/* --- Agentes ------------------------------------------------------------- */
.agent-card { padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.agent-card__head { display: flex; gap: 14px; align-items: flex-start; }
.agent-ic { width: 44px; height: 44px; border-radius: 13px; flex: none; display: grid; place-items: center; background: color-mix(in srgb, var(--fr-accent) 14%, transparent); color: var(--fr-accent); }
.agent-ic md-icon { --md-icon-size: 24px; }
.agent-card__name { font-family: var(--fr-display); font-weight: 500; font-size: 17px; letter-spacing: -0.01em; }
.agent-card__purpose { font-size: 13px; color: var(--md-sys-color-on-surface-variant); line-height: 1.5; }
.agent-runs { border-top: 1px solid var(--fr-hairline); padding-top: 14px; display: flex; flex-direction: column; gap: 9px; }
.run { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.run .led { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.run .at { font-family: var(--fr-mono); font-size: 11px; color: var(--fr-muted); width: 62px; flex: none; }
.run .note { color: var(--md-sys-color-on-surface-variant); }
.chip-wrap { display: flex; flex-wrap: wrap; gap: 7px; }

/* --- Integraciones ------------------------------------------------------- */
.intg-card { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.intg-head { display: flex; align-items: center; gap: 12px; }
.intg-logo { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--md-sys-color-surface-container-high); color: var(--md-sys-color-on-surface); flex: none; }
.intg-logo md-icon { --md-icon-size: 22px; }
.intg-name { font-weight: 600; font-size: 15px; }
.intg-cat { font-size: 11.5px; color: var(--fr-muted); }
.intg-meta { display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; }
.intg-meta .r { display: flex; justify-content: space-between; }
.intg-meta .r span { color: var(--fr-muted); }
.intg-meta .r b { font-weight: 500; }

/* --- Explorador de contexto --------------------------------------------- */
.ctx-hero { position: relative; overflow: hidden; padding: 30px 30px 26px; }
.ctx-field { position: absolute; inset: 0; opacity: 0.85; pointer-events: none; }
.ctx-inner { position: relative; z-index: 2; }
.ctx-box {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 6px 6px 18px; margin-top: 18px;
  background: var(--md-sys-color-surface-container); border: 1px solid var(--fr-hairline-strong);
  border-radius: 15px; transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.ctx-box:focus-within { border-color: color-mix(in srgb, var(--fr-accent) 60%, transparent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--fr-accent) 12%, transparent); }
.ctx-box md-icon { --md-icon-size: 22px; color: var(--fr-accent); }
.ctx-box input {
  flex: 1; background: transparent; border: 0; outline: 0;
  color: var(--md-sys-color-on-surface); font-family: var(--fr-body); font-size: 15px;
}
.ctx-box input::placeholder { color: var(--fr-muted); }
.ctx-suggest { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 16px; }

.ctx-result { display: grid; grid-template-columns: 1fr 340px; gap: 22px; align-items: start; margin-top: 26px; }
.frag { padding: 16px 18px; display: flex; flex-direction: column; gap: 9px; margin-bottom: 12px; }
.frag__head { display: flex; align-items: center; gap: 10px; }
.frag__kind { font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--fr-accent-dim); font-weight: 600; }
.frag__src { font-weight: 550; font-size: 14px; }
.frag__rel { margin-left: auto; display: flex; align-items: center; gap: 8px; font-family: var(--fr-mono); font-size: 12px; color: var(--md-sys-color-on-surface-variant); }
.frag__rel .track { width: 56px; height: 5px; border-radius: 3px; background: var(--md-sys-color-surface-container-highest); overflow: hidden; }
.frag__rel .track i { display: block; height: 100%; background: linear-gradient(90deg, var(--fr-signal), var(--fr-accent)); }
.frag__snip { font-size: 13.5px; color: var(--md-sys-color-on-surface-variant); line-height: 1.55; }
.frag.reveal { animation: fragin 0.4s cubic-bezier(0.2,0.7,0.2,1) backwards; }
@keyframes fragin { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.payload { position: sticky; top: 18px; padding: 0; overflow: hidden; }
.payload__head { display: flex; align-items: center; gap: 8px; padding: 14px 18px; border-bottom: 1px solid var(--fr-hairline); }
.payload__head b { font-size: 13px; font-weight: 600; }
.payload__head md-icon { --md-icon-size: 18px; color: var(--fr-signal); }
.payload pre { margin: 0; padding: 16px 18px; font-family: var(--fr-mono); font-size: 11.5px; line-height: 1.7; color: var(--md-sys-color-on-surface-variant); white-space: pre-wrap; word-break: break-word; max-height: 420px; overflow: auto; }
.payload .k { color: var(--fr-accent); }
.payload .s { color: var(--fr-signal); }

.empty-ctx { text-align: center; padding: 60px 20px; color: var(--fr-muted); }
.empty-ctx md-icon { --md-icon-size: 40px; color: var(--fr-hairline-strong); }
.empty-ctx p { margin: 12px 0 0; font-size: 14px; }

/* --- Ajustes ------------------------------------------------------------- */
.set-nav { display: flex; gap: 8px; margin-bottom: 22px; flex-wrap: wrap; }
.member-row { display: flex; align-items: center; gap: 14px; padding: 13px 4px; border-bottom: 1px solid var(--fr-hairline); }
.member-row:last-child { border-bottom: 0; }
.member-row .who b { font-size: 13.5px; font-weight: 550; }
.member-row .who small { font-size: 12px; color: var(--fr-muted); display: block; }
.member-row .role { margin-left: auto; }
.consumer-row { padding: 16px 18px; display: flex; align-items: center; gap: 14px; }
.consumer-row .keydot { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.consumer-row .keydot md-icon { --md-icon-size: 20px; }
.consumer-row b { font-size: 14px; font-weight: 550; }
.consumer-row small { font-size: 12px; color: var(--fr-muted); display: block; margin-top: 1px; }
.consumer-row .key { margin-left: auto; font-family: var(--fr-mono); font-size: 12px; color: var(--md-sys-color-on-surface-variant); background: var(--md-sys-color-surface-container); padding: 5px 11px; border-radius: 8px; border: 1px solid var(--fr-hairline); }

.field-line { display: flex; align-items: center; justify-content: space-between; padding: 15px 0; border-bottom: 1px solid var(--fr-hairline); }
.field-line:last-child { border-bottom: 0; }
.field-line .l b { font-size: 14px; font-weight: 550; display: block; }
.field-line .l small { font-size: 12.5px; color: var(--fr-muted); }

/* --- utilidades ---------------------------------------------------------- */
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.gap-s { gap: 6px; }
.mt-s { margin-top: 8px; } .mt-m { margin-top: 16px; } .mt-l { margin-top: 26px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--fr-muted); cursor: pointer; margin-bottom: 16px; }
.back-link:hover { color: var(--md-sys-color-on-surface); }
.back-link md-icon { --md-icon-size: 18px; }
.divider-soft { height: 1px; background: var(--fr-hairline); margin: 20px 0; }

/* --- responsive ---------------------------------------------------------- */
.rail-toggle { display: none; }
@media (max-width: 1120px) {
  .cols-4 { grid-template-columns: repeat(2, 1fr); }
  .detail-grid, .ctx-result { grid-template-columns: 1fr; }
  .aside-card, .payload { position: static; }
  .ent-fields { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .rail {
    position: fixed; z-index: 60; left: 0; top: 0; width: 280px;
    transform: translateX(-102%); transition: transform 0.24s cubic-bezier(0.2,0.7,0.2,1);
    box-shadow: 30px 0 60px -30px #000;
  }
  .app.nav-open .rail { transform: none; }
  .scrim { display: none; position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,0.55); }
  .app.nav-open .scrim { display: block; }
  .rail-toggle { display: inline-flex; }
  .content__inner { padding: 24px 18px 80px; }
  .hero { grid-template-columns: 1fr; }
  .cols-3, .cols-2, .cols-4 { grid-template-columns: 1fr; }
  .topbar .search { display: none; }
  .ent-fields { grid-template-columns: 1fr; }
}

/* --- accesibilidad ------------------------------------------------------- */
:focus-visible { outline: 2px solid var(--fr-accent); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.05ms !important; }
}
