/* ==========================================================================
   Brando — brand.css
   Tokens + componentes base. Lo usan la landing (index.html) y el panel (app.html).
   Convención: tokens en --b-*, componentes con prefijo .b- (BEM ligero).
   Tema: claro por defecto; oscuro por prefers-color-scheme o [data-theme="dark"].
   ========================================================================== */

/* ---------- Fallbacks métricos (evitan saltos de layout mientras cargan las fuentes) ---------- */
/* Medidos contra Arial/Liberation Sans (métricamente iguales) con el texto del hero; ver BRAND.md §5. */
@font-face { font-family: "Bricolage Fallback"; font-weight: 600 900; src: local("Arial Bold"), local("Arial-BoldMT"), local("Liberation Sans Bold"), local("Helvetica Bold"); size-adjust: 84.7%; ascent-override: 109.8%; descent-override: 31.9%; line-gap-override: 0%; }
@font-face { font-family: "Bricolage Fallback"; font-weight: 100 599; src: local("Arial"), local("ArialMT"), local("Liberation Sans"), local("Helvetica"); size-adjust: 90%; ascent-override: 103%; descent-override: 30%; line-gap-override: 0%; }
@font-face { font-family: "Schibsted Fallback"; font-weight: 100 549; src: local("Arial"), local("ArialMT"), local("Liberation Sans"), local("Helvetica"); size-adjust: 102.7%; ascent-override: 95.4%; descent-override: 25.3%; line-gap-override: 0%; }
@font-face { font-family: "Schibsted Fallback"; font-weight: 550 900; src: local("Arial Bold"), local("Arial-BoldMT"), local("Liberation Sans Bold"), local("Helvetica Bold"); size-adjust: 101.2%; ascent-override: 96.8%; descent-override: 25.7%; line-gap-override: 0%; }
@font-face { font-family: "Plex Mono Fallback"; src: local("Courier New"), local("CourierNewPSMT"), local("Liberation Mono"), local("Courier"); size-adjust: 100%; ascent-override: 103%; descent-override: 28%; line-gap-override: 0%; }

/* ---------- Tokens: tema claro ---------- */
:root {
  color-scheme: light;

  /* Marca (fijos, no cambian con el tema) */
  --b-sello: #2a36d9;          /* azul sello: LA acción principal, enlaces */
  --b-resaltador: #ffe03a;     /* amarillo resaltador: resalta texto y datos. Nunca botón. */
  --b-alerta: #e5361b;         /* rojo alerta: riesgo alto, el "ping" */
  --b-tinta-fija: #0f1233;     /* tinta del logo */

  /* Superficies y texto */
  --b-bg: #f4f5f9;             /* fondo de página */
  --b-surface: #ffffff;        /* tarjetas, inputs */
  --b-surface-2: #eceef6;      /* bloques secundarios */
  --b-ink: #0f1233;            /* texto principal */
  --b-ink-2: #464a68;          /* texto secundario (AA sobre bg y surface) */
  --b-ink-3: #6b6f8c;          /* texto terciario: ≥ 13px o decorativo */
  --b-line: #d9dcea;           /* bordes */
  --b-line-strong: #b7bcd4;

  /* Roles. UNA sola acción primaria: --b-primary. */
  --b-primary: var(--b-sello);
  --b-primary-hover: #1f29b8;
  --b-on-primary: #ffffff;
  --b-tint: color-mix(in srgb, var(--b-primary) 11%, transparent);        /* botón secundario */
  --b-tint-hover: color-mix(in srgb, var(--b-primary) 17%, transparent);
  --b-on-tint: #2a36d9;
  --b-link: #2a36d9;
  --b-highlight: var(--b-resaltador);
  --b-on-highlight: #0f1233;
  --b-focus: #2a36d9;

  /* Riesgo (semántico) */
  --b-alto: #c42a12;      --b-alto-bg: #fde7e2;   --b-alto-line: #f5b8aa;
  --b-medio: #8a5a00;     --b-medio-bg: #fff3cc;  --b-medio-line: #f0d27a;
  --b-bajo: #2c6a4a;      --b-bajo-bg: #e1f2e8;   --b-bajo-line: #a9d6bd;
  --b-ok: #2c6a4a;
  --b-error: #c42a12;

  /* Tipografía */
  --b-font-display: "Bricolage Grotesque", "Bricolage Fallback", system-ui, sans-serif;
  --b-font-body: "Schibsted Grotesk", "Schibsted Fallback", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --b-font-mono: "IBM Plex Mono", "Plex Mono Fallback", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  /* Escala tipográfica: 9 pasos (BRAND §5). Móvil primero; se ajusta en ≥ 768px.
     Uso: font: var(--b-w) var(--b-t-body)/var(--b-lh-body) … o las clases .b-t-* de abajo.
     Mínimo absoluto: 12px (caption). Cuerpo: 17px. En rem para respetar el tamaño de texto del sistema. */
  --b-t-display: 2.5rem;    --b-lh-display: 1.1;    /* 40/44 → 68/72  Bricolage 750 */
  --b-t-title1: 1.75rem;    --b-lh-title1: 1.2143;  /* 28/34 → 44/48  Bricolage 700 */
  --b-t-title2: 1.375rem;   --b-lh-title2: 1.2727;  /* 22/28 → 28/34  Bricolage 700 */
  --b-t-title3: 1.25rem;    --b-lh-title3: 1.25;    /* 20/25 → 22/28  Schibsted 600 */
  --b-t-headline: 1.0625rem;--b-lh-headline: 1.294; /* 17/22          Schibsted 600 */
  --b-t-body: 1.0625rem;    --b-lh-body: 1.4706;    /* 17/25 → 17/27  Schibsted 400 */
  --b-t-callout: 0.9375rem; --b-lh-callout: 1.4;    /* 15/21 → 16/24  Schibsted 400 */
  --b-t-footnote: 0.8125rem;--b-lh-footnote: 1.3846;/* 13/18          Schibsted 400/500 */
  --b-t-caption: 0.75rem;   --b-lh-caption: 1.3333; /* 12/16          Schibsted/mono 600 — MÍNIMO */

  /* Alias de la escala anterior (los usan app/admin; apuntan a la escala nueva) */
  --b-text-xs: var(--b-t-caption);
  --b-text-sm: var(--b-t-callout);
  --b-text-base: var(--b-t-body);
  --b-text-md: var(--b-t-body);
  --b-text-lg: var(--b-t-title3);
  --b-text-xl: var(--b-t-title2);
  --b-text-2xl: var(--b-t-title1);
  --b-text-3xl: var(--b-t-display);
  --b-leading-tight: var(--b-lh-display);
  --b-leading-snug: 1.2;
  --b-leading-body: var(--b-lh-body);

  /* Espaciado: rejilla de 8 pt (4 solo para ajustes finos) */
  --b-space-1: 4px;  --b-space-2: 8px;  --b-space-3: 12px; --b-space-4: 16px;
  --b-space-5: 24px; --b-space-6: 32px; --b-space-7: 48px; --b-space-8: 64px;
  --b-space-9: 96px; --b-space-10: 128px;
  --b-section: 64px;           /* 64 móvil · 96 iPad · 128 Mac */
  --b-field-gap: 24px;         /* entre campos de un formulario */
  --b-card-pad: 20px;          /* 20 móvil · 32 escritorio */
  --b-card-gap: 12px;          /* 12 móvil · 16 escritorio */

  /* Radios (concéntricos: interno = externo − relleno) */
  --b-r-xs: 6px;               /* chips internos, marcadores A/B/C */
  --b-r-sm: 10px;              /* inputs, opciones de lista */
  --b-r-md: 14px;              /* avisos, recuadros de plazo */
  --b-r-lg: 20px;              /* tarjetas */
  --b-r-sheet: 16px;           /* borde superior de las hojas inferiores */
  --b-r-pill: 999px;           /* botones, badges, chips */
  --b-radius-sm: var(--b-r-xs);
  --b-radius: var(--b-r-sm);
  --b-radius-lg: var(--b-r-lg);
  --b-radius-pill: var(--b-r-pill);

  /* Elevación: 2 niveles. Las tarjetas de contenido usan borde o fondo, no sombra. */
  --b-e1: 0 1px 2px rgb(15 18 51 / .06);
  --b-e2: 0 12px 32px -12px rgb(15 18 51 / .22), 0 1px 2px rgb(15 18 51 / .05);
  --b-shadow-sm: var(--b-e1);
  --b-shadow: var(--b-e1);
  --b-shadow-lg: var(--b-e2);

  /* Movimiento: cada animación con propósito */
  --b-ease: cubic-bezier(.2, .7, .2, 1);       /* estados */
  --b-ease-out: var(--b-ease);
  --b-spring: cubic-bezier(.32, .72, 0, 1);    /* hojas y modales (curva de hoja de iOS) */
  --b-dur-fast: 100ms;                         /* pressed */
  --b-dur: 150ms;                              /* hover, foco, estados */
  --b-dur-in: 420ms;                           /* entrada de hoja */
  --b-dur-out: 280ms;                          /* salida de hoja */
  --b-dur-slow: 500ms;                         /* momentos (✓ de confirmación) */

  --b-band-bg: #0f1233;        /* franja invertida (precio) */
  --b-band-ink: #f4f5f9;

  --b-container: 1180px;
  --b-gutter: 16px;            /* 16 móvil · 24 iPad · 40 Mac */
  --b-tap: 44px;               /* objetivo táctil mínimo */
}
@media (min-width: 768px) {
  :root {
    --b-t-display: 3.25rem;  --b-lh-display: 1.08;
    --b-t-title1: 2.25rem;   --b-lh-title1: 1.14;
    --b-t-title2: 1.625rem;  --b-lh-title2: 1.23;
    --b-t-title3: 1.375rem;  --b-lh-title3: 1.2727;
    --b-lh-headline: 1.4118;
    --b-lh-body: 1.5882;
    --b-t-callout: 1rem;     --b-lh-callout: 1.5;
    --b-section: 96px; --b-gutter: 24px; --b-card-pad: 28px; --b-card-gap: 16px;
  }
}
@media (min-width: 1200px) {
  :root {
    --b-t-display: 4.25rem;  --b-lh-display: 1.0588;  /* 68/72 */
    --b-t-title1: 2.75rem;   --b-lh-title1: 1.0909;   /* 44/48 */
    --b-t-title2: 1.75rem;   --b-lh-title2: 1.2143;   /* 28/34 */
    --b-section: 128px; --b-gutter: 40px; --b-card-pad: 32px;
  }
}

/* ---------- Tema oscuro ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --b-bg: #0b0d22;
    --b-surface: #141736;
    --b-surface-2: #1b1f45;
    --b-ink: #eceef8;
    --b-ink-2: #b3b7d3;
    --b-ink-3: #8c90b0;
    --b-line: #2a2e5a;
    --b-line-strong: #3d4275;
    --b-primary: #3d4bff;        /* sello en oscuro: blanco encima 5,7:1 */
    --b-primary-hover: #5461ff;  /* 4,6:1 */
    --b-on-primary: #ffffff;
    --b-link: #9aa3ff;
    --b-focus: #9aa3ff;
    --b-alto: #ff8a73;  --b-alto-bg: #3a1714;  --b-alto-line: #6e2a20;
    --b-medio: #ffd36b; --b-medio-bg: #33290f; --b-medio-line: #66521c;
    --b-bajo: #7fd6a6;  --b-bajo-bg: #12301f;  --b-bajo-line: #245a3c;
    --b-ok: #7fd6a6;
    --b-error: #ff8a73;
    --b-band-bg: #1b1f45;
    --b-band-ink: #eceef8;
    --b-e1: 0 1px 2px rgb(0 0 0 / .4);
  --b-e2: 0 16px 40px -12px rgb(0 0 0 / .7), 0 0 0 1px rgb(255 255 255 / .06);
  --b-on-tint: #aab2ff;
  --b-tint: color-mix(in srgb, #5461ff 22%, transparent);
  --b-tint-hover: color-mix(in srgb, #5461ff 30%, transparent);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --b-bg: #0b0d22;
  --b-surface: #141736;
  --b-surface-2: #1b1f45;
  --b-ink: #eceef8;
  --b-ink-2: #b3b7d3;
  --b-ink-3: #8c90b0;
  --b-line: #2a2e5a;
  --b-line-strong: #3d4275;
  --b-primary: #3d4bff;
  --b-primary-hover: #5461ff;
  --b-on-primary: #ffffff;
  --b-link: #9aa3ff;
  --b-focus: #9aa3ff;
  --b-alto: #ff8a73;  --b-alto-bg: #3a1714;  --b-alto-line: #6e2a20;
  --b-medio: #ffd36b; --b-medio-bg: #33290f; --b-medio-line: #66521c;
  --b-bajo: #7fd6a6;  --b-bajo-bg: #12301f;  --b-bajo-line: #245a3c;
  --b-ok: #7fd6a6;
  --b-error: #ff8a73;
  --b-band-bg: #1b1f45;
  --b-band-ink: #eceef8;
  --b-e1: 0 1px 2px rgb(0 0 0 / .4);
  --b-e2: 0 16px 40px -12px rgb(0 0 0 / .7), 0 0 0 1px rgb(255 255 255 / .06);
  --b-on-tint: #aab2ff;
  --b-tint: color-mix(in srgb, #5461ff 22%, transparent);
  --b-tint-hover: color-mix(in srgb, #5461ff 30%, transparent);
}


/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--b-bg);
  color: var(--b-ink);
  font-family: var(--b-font-body);
  font-size: var(--b-t-body);
  line-height: var(--b-lh-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; }
[hidden] { display: none !important; }
h1, h2, h3, h4 {
  font-family: var(--b-font-display);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0;
  text-wrap: balance;
  margin: 0;
  font-variation-settings: "wdth" 96;
}
p { margin: 0; text-wrap: pretty; }
a { color: var(--b-link); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--b-focus); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--b-resaltador); color: #0f1233; }
/* Mono SOLO para nombres de marca, expedientes y números de clase */
.b-mono, code, kbd { font-family: var(--b-font-mono); font-size: .94em; }
.b-num { font-variant-numeric: tabular-nums; }
.b-sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.b-skip {
  position: absolute; left: 16px; top: -64px; z-index: 100;
  display: inline-flex; align-items: center; min-height: var(--b-tap);
  background: var(--b-ink); color: var(--b-bg); padding: 0 16px; border-radius: var(--b-r-sm);
  font-weight: 600; text-decoration: none;
  transition: top var(--b-dur) var(--b-ease);
}
.b-skip:focus { top: 12px; }

/* ---------- Estilos de texto (la escala de 9 pasos como clases) ---------- */
.b-t-display  { font: 750 var(--b-t-display)/var(--b-lh-display) var(--b-font-display); letter-spacing: -0.005em; font-variation-settings: "wdth" 96, "opsz" 96; }
.b-t-title1   { font: 700 var(--b-t-title1)/var(--b-lh-title1) var(--b-font-display); font-variation-settings: "wdth" 96, "opsz" 96; }
.b-t-title2   { font: 700 var(--b-t-title2)/var(--b-lh-title2) var(--b-font-display); font-variation-settings: "wdth" 96; }
.b-t-title3   { font: 600 var(--b-t-title3)/var(--b-lh-title3) var(--b-font-body); }
.b-t-headline { font: 600 var(--b-t-headline)/var(--b-lh-headline) var(--b-font-body); }
.b-t-body     { font: 400 var(--b-t-body)/var(--b-lh-body) var(--b-font-body); }
.b-t-callout  { font: 400 var(--b-t-callout)/var(--b-lh-callout) var(--b-font-body); }
.b-t-footnote { font: 400 var(--b-t-footnote)/var(--b-lh-footnote) var(--b-font-body); }
.b-t-caption  { font: 600 var(--b-t-caption)/var(--b-lh-caption) var(--b-font-body); letter-spacing: .02em; }

/* ---------- Layout ---------- */
.b-container { width: 100%; max-width: var(--b-container); margin-inline: auto; padding-inline: max(var(--b-gutter), env(safe-area-inset-left, 0px)); }
.b-stack { display: flex; flex-direction: column; gap: var(--b-space-4); }
.b-row { display: flex; flex-wrap: wrap; gap: var(--b-space-3); align-items: center; }

/* ---------- Texto ---------- */
/* Eyebrow: Schibsted 13/18 w600, sin mayúsculas forzadas */
.b-eyebrow {
  font: 600 var(--b-t-footnote)/var(--b-lh-footnote) var(--b-font-body);
  letter-spacing: 0; text-transform: none; color: var(--b-ink-2);
}
.b-lead { font-size: var(--b-t-body); line-height: var(--b-lh-body); color: var(--b-ink-2); max-width: 60ch; }
.b-muted { color: var(--b-ink-2); }
/* El gesto de la marca: el resaltador */
.b-mark {
  background: linear-gradient(transparent 12%, var(--b-highlight) 12%, var(--b-highlight) 88%, transparent 88%);
  color: var(--b-on-highlight);
  padding-inline: .12em; margin-inline: -.06em;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}

/* ---------- Iconos (un solo set: trazo 2, terminales redondas, rejilla 24) ---------- */
.b-icon { width: 1.25em; height: 1.25em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.25em; }

/* ---------- Botones ----------
   Variantes: (base) primary · --secondary (tinte, sin borde) · --plain (texto) · --destructive.
   Tamaños: --lg 50 · base 44 · --sm 44 táctil / 36 con puntero fino.
   Alias heredados: --ghost = --secondary; --ink y --highlight = primary (ya no hay otro color de acción); --danger = --destructive. */
.b-btn {
  --_bg: var(--b-primary); --_fg: var(--b-on-primary); --_bgh: var(--b-primary-hover);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--b-tap); padding: 0 20px; max-width: 100%;
  font: 600 var(--b-t-headline)/1.2 var(--b-font-body); letter-spacing: 0;
  color: var(--_fg); background: var(--_bg); border: 0;
  border-radius: var(--b-r-pill); cursor: pointer; text-decoration: none; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--b-dur) var(--b-ease), transform var(--b-dur-fast) var(--b-ease), opacity var(--b-dur-fast) var(--b-ease);
}
.b-btn:hover { background: var(--_bgh); text-decoration: none; color: var(--_fg); }
.b-btn:active { transform: scale(.97); opacity: .85; }
.b-btn[disabled], .b-btn[aria-disabled="true"] { opacity: .4; cursor: not-allowed; transform: none; }
.b-btn--lg { min-height: 50px; padding: 0 24px; }
.b-btn--sm { min-height: 36px; padding: 0 16px; font-size: var(--b-t-callout); }
@media (pointer: coarse) { .b-btn--sm { min-height: var(--b-tap); } }
.b-btn--block { width: 100%; }
.b-btn--secondary, .b-btn--ghost { --_bg: var(--b-tint); --_bgh: var(--b-tint-hover); --_fg: var(--b-on-tint); }
.b-btn--plain { --_bg: transparent; --_bgh: var(--b-tint); --_fg: var(--b-link); padding-inline: 12px; }
.b-btn--ink, .b-btn--highlight { --_bg: var(--b-primary); --_bgh: var(--b-primary-hover); --_fg: var(--b-on-primary); }
.b-btn--destructive, .b-btn--danger { --_bg: var(--b-alto); --_bgh: color-mix(in srgb, var(--b-alto) 86%, #000); --_fg: #fff; }
:root[data-theme="dark"] .b-btn--destructive, :root[data-theme="dark"] .b-btn--danger { --_bg: #d8321a; --_bgh: #e5361b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .b-btn--destructive, :root:not([data-theme="light"]) .b-btn--danger { --_bg: #d8321a; --_bgh: #e5361b; } }
.b-btn .b-arrow { display: inline-block; transition: transform var(--b-dur) var(--b-ease); }
.b-btn:hover .b-arrow { transform: translateX(3px); }
.b-spinner {
  width: 1em; height: 1em; border-radius: 50%; flex: none;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: b-spin .7s linear infinite;
}
@keyframes b-spin { to { transform: rotate(360deg); } }

/* ---------- Formularios ----------
   Rótulo callout w600 · 8 · input 50 (body 17, evita el zoom de iOS) · 6 · ayuda o error en el MISMO nodo. */
.b-field { display: flex; flex-direction: column; gap: 8px; }
.b-field > .b-hint, .b-field > .b-field-error { margin-top: -2px; }
.b-label { font: 600 var(--b-t-callout)/var(--b-lh-callout) var(--b-font-body); color: var(--b-ink); }
.b-label .b-opt { font-weight: 400; color: var(--b-ink-2); }
.b-hint { font-size: var(--b-t-footnote); line-height: var(--b-lh-footnote); color: var(--b-ink-2); }
.b-hint.is-error, .b-field-error { color: var(--b-error); font-weight: 500; font-size: var(--b-t-footnote); line-height: var(--b-lh-footnote); }
.b-input, .b-select, .b-textarea {
  width: 100%; min-height: 50px; padding: 12px 16px;
  font: 400 var(--b-t-body)/1.3 var(--b-font-body); color: var(--b-ink);
  background: var(--b-surface); border: 1px solid var(--b-line-strong); border-radius: var(--b-r-sm);
  transition: border-color var(--b-dur), box-shadow var(--b-dur);
}
.b-input.b-mono { font-family: var(--b-font-mono); text-transform: uppercase; letter-spacing: .01em; }
.b-input::placeholder, .b-textarea::placeholder { color: var(--b-ink-3); }
.b-input:hover, .b-select:hover, .b-textarea:hover { border-color: var(--b-ink-2); }
.b-input:focus, .b-select:focus, .b-textarea:focus {
  outline: none; border-color: var(--b-primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--b-primary) 22%, transparent);
}
.b-input[aria-invalid="true"], .b-select[aria-invalid="true"], .b-textarea[aria-invalid="true"] { border-color: var(--b-error); }
.b-input[aria-invalid="true"]:focus, .b-textarea[aria-invalid="true"]:focus { border-color: var(--b-error); box-shadow: 0 0 0 4px color-mix(in srgb, var(--b-error) 22%, transparent); }
.b-check { display: flex; gap: 12px; align-items: flex-start; min-height: var(--b-tap); padding-block: 10px; font-size: var(--b-t-callout); line-height: var(--b-lh-callout); color: var(--b-ink-2); cursor: pointer; }
.b-check input { width: 22px; height: 22px; margin: 0; accent-color: var(--b-primary); flex: none; }

/* ---------- Cards ---------- */
.b-card {
  background: var(--b-surface); border: 1px solid var(--b-line); border-radius: var(--b-r-lg);
  padding: var(--b-card-pad);
}
/* --raised: en claro, sombra de reposo (e1) sin borde; en oscuro se eleva por fondo */
.b-card--raised { box-shadow: var(--b-e1); border-color: transparent; }
.b-card--flat { background: var(--b-surface-2); border-color: transparent; }

/* ---------- Badges de riesgo: punto + palabra («Alto», «Medio», «Bajo») ---------- */
.b-badge {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 24px; padding: 2px 10px 2px 8px; border-radius: var(--b-r-pill);
  font: 600 var(--b-t-caption)/var(--b-lh-caption) var(--b-font-body); letter-spacing: .02em; text-transform: none;
  border: 1px solid var(--b-line); background: var(--b-surface-2); color: var(--b-ink-2); white-space: nowrap;
}
.b-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.b-badge--alto  { color: var(--b-alto);  background: var(--b-alto-bg);  border-color: var(--b-alto-line); }
.b-badge--medio { color: var(--b-medio); background: var(--b-medio-bg); border-color: var(--b-medio-line); }
.b-badge--bajo  { color: var(--b-bajo);  background: var(--b-bajo-bg);  border-color: var(--b-bajo-line); }
.b-badge--plain::before { display: none; }

/* Chip (clases Niza, filtros). El botón de quitar tiene 44 de área táctil. */
.b-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px;
  padding: 2px 4px 2px 12px; border-radius: var(--b-r-pill);
  background: var(--b-surface-2); border: 1px solid var(--b-line); color: var(--b-ink);
  font-size: var(--b-t-footnote); line-height: var(--b-lh-footnote); font-weight: 500;
}
.b-chip button {
  position: relative; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  border: 0; background: transparent; color: var(--b-ink-2); cursor: pointer; padding: 0;
}
.b-chip button::after { content: ""; position: absolute; inset: -10px; }
.b-chip button svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; fill: none; }
.b-chip button:hover { background: var(--b-line); color: var(--b-ink); }
@media (pointer: coarse) { .b-chip button { width: var(--b-tap); height: var(--b-tap); margin: -10px; } }

/* Puntaje de similitud 0-100 */
.b-score { display: inline-flex; align-items: baseline; gap: 2px; font-family: var(--b-font-mono); font-variant-numeric: tabular-nums; font-weight: 600; }
.b-score small { font-size: var(--b-t-caption); color: var(--b-ink-3); font-weight: 400; }
.b-meter { height: 6px; border-radius: 3px; background: var(--b-surface-2); overflow: hidden; }
.b-meter > span { display: block; height: 100%; border-radius: inherit; background: var(--b-ink-2); }
.b-meter--alto > span { background: var(--b-alto); }
.b-meter--medio > span { background: var(--b-medio); }
.b-meter--bajo > span { background: var(--b-bajo); }

/* ---------- Tablas (tabular-nums solo en celdas numéricas: td.num / .b-num) ---------- */
.b-table-wrap { overflow-x: auto; border: 1px solid var(--b-line); border-radius: var(--b-r-lg); background: var(--b-surface); }
.b-table { width: 100%; border-collapse: collapse; font-size: var(--b-t-callout); line-height: var(--b-lh-callout); }
.b-table td.num, .b-table th.num { font-variant-numeric: tabular-nums; text-align: right; }
.b-table th, .b-table td { padding: 14px 16px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--b-line); }
.b-table thead th {
  font: 600 var(--b-t-footnote)/var(--b-lh-footnote) var(--b-font-body); letter-spacing: 0; text-transform: none;
  color: var(--b-ink-2); background: var(--b-surface-2);
}
.b-table tbody tr:last-child td, .b-table tbody tr:last-child th { border-bottom: 0; }
.b-table tbody tr:hover td { background: color-mix(in srgb, var(--b-surface-2) 55%, transparent); }

/* ---------- Lista (filas ≥ 44, separador inset de 0,5) ---------- */
.b-list { list-style: none; margin: 0; padding: 0; background: var(--b-surface); border-radius: var(--b-r-lg); border: 1px solid var(--b-line); overflow: hidden; }
.b-list > li, .b-list__row {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: var(--b-tap);
  padding: 12px 16px;
}
.b-list > li + li::before, .b-list__row + .b-list__row::before {
  content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--b-line-strong);
}
.b-list--plain { background: transparent; border: 0; border-radius: 0; }
.b-list--plain > li { padding-inline: 0; }
.b-list--plain > li + li::before { left: 0; }
.b-list__chev { margin-left: auto; color: var(--b-ink-3); }

/* ---------- Avisos: icono + título + texto. Siempre ARRIBA de lo que describen. ---------- */
.b-notice {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--b-r-md);
  background: var(--b-surface-2); border: 1px solid var(--b-line);
  font-size: var(--b-t-callout); line-height: var(--b-lh-callout); color: var(--b-ink);
}
.b-notice:focus { outline: none; }
.b-notice:focus-visible { outline: 3px solid var(--b-focus); outline-offset: 2px; }
.b-notice .b-icon { margin-top: 1px; }
.b-notice strong { font-weight: 600; }
.b-notice--error { background: var(--b-alto-bg); border-color: var(--b-alto-line); color: var(--b-alto); }
.b-notice--error a { color: inherit; font-weight: 600; }
.b-notice--ok { background: var(--b-bajo-bg); border-color: var(--b-bajo-line); color: var(--b-bajo); }

/* ---------- Cifra (stat): rótulo footnote · valor display 28–32 tabular · sub footnote. Nunca mono. ---------- */
.b-stat { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.b-stat__label { font-size: var(--b-t-footnote); line-height: var(--b-lh-footnote); color: var(--b-ink-2); font-weight: 500; }
.b-stat__value { font: 700 clamp(1.75rem, 1.4rem + .8vw, 2rem)/1.1 var(--b-font-display); font-variation-settings: "wdth" 96; font-variant-numeric: tabular-nums; white-space: nowrap; }
.b-stat__sub { font-size: var(--b-t-footnote); line-height: var(--b-lh-footnote); color: var(--b-ink-2); }

/* ---------- Estado vacío ---------- */
.b-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 32px 16px; }
.b-empty > svg, .b-empty .b-icon { width: 48px; height: 48px; color: var(--b-ink-3); margin-bottom: 8px; }
.b-empty h3, .b-empty__title { font: 600 var(--b-t-title3)/var(--b-lh-title3) var(--b-font-body); }
.b-empty p { font-size: var(--b-t-callout); line-height: var(--b-lh-callout); color: var(--b-ink-2); max-width: 40ch; }
.b-empty .b-btn { margin-top: 8px; }

/* ---------- Hoja (sheet): hoja inferior ≤ 600 px, diálogo centrado de 520 en escritorio ----------
   Estructura: <dialog class="b-sheet"> <div class="b-sheet__grab"></div> <header class="b-sheet__head">…
   <div class="b-sheet__body">… <footer class="b-sheet__foot">… */
.b-sheet {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); padding: 0; border: 0;
  border-radius: var(--b-r-lg); background: var(--b-surface); color: var(--b-ink); box-shadow: var(--b-e2); overflow: hidden;
}
.b-sheet[open] { display: flex; flex-direction: column; animation: b-sheet-in var(--b-dur-in) var(--b-spring); }
.b-sheet::backdrop { background: rgb(11 13 34 / .5); }
.b-sheet__grab { display: none; }
.b-sheet__head { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: 8px; padding: 12px 12px 8px; }
.b-sheet__title { grid-column: 2; text-align: center; font: 600 var(--b-t-headline)/var(--b-lh-headline) var(--b-font-body); }
.b-sheet__body { padding: 8px 24px 24px; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: var(--b-field-gap); }
.b-sheet__foot { padding: 16px 24px calc(16px + env(safe-area-inset-bottom, 0px)); border-top: .5px solid var(--b-line-strong); display: flex; flex-direction: column; gap: 8px; background: var(--b-surface); }
/* Cerrar: xmark en círculo relleno de 30 dentro de un área de 44 */
.b-close {
  display: grid; place-items: center; width: var(--b-tap); height: var(--b-tap); padding: 0; border: 0; background: transparent;
  color: var(--b-ink-2); cursor: pointer; border-radius: 50%;
}
.b-close::before { content: ""; grid-area: 1 / 1; width: 30px; height: 30px; border-radius: 50%; background: var(--b-surface-2); transition: background-color var(--b-dur); }
.b-close svg { grid-area: 1 / 1; position: relative; width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.b-close:hover::before { background: var(--b-line); }
@keyframes b-sheet-in { from { opacity: 0; transform: translateY(16px) scale(.98); } }
@media (max-width: 600px) {
  .b-sheet {
    width: 100vw; max-width: 100vw; margin: auto 0 0; height: calc(100dvh - 12px); max-height: calc(100dvh - 12px);
    border-radius: var(--b-r-sheet) var(--b-r-sheet) 0 0;
  }
  /* Hoja a la medida del contenido: un <dialog> modal tiene top y bottom en 0, así que
     con height:auto se estira a toda la pantalla; fit-content la deja pegada abajo y del alto justo. */
  .b-sheet--fit { height: fit-content; }
  .b-sheet[open] { animation-name: b-sheet-up; }
  .b-sheet__grab { display: block; flex: none; width: 36px; height: 5px; border-radius: 3px; background: var(--b-line-strong); margin: 6px auto 0; }
  .b-sheet__body { padding-inline: 16px; }
  .b-sheet__foot { padding-inline: 16px; }
}
@keyframes b-sheet-up { from { transform: translateY(100%); } }

/* ---------- Logo inline (usa currentColor para el texto) ---------- */
.b-logo { display: inline-flex; align-items: center; min-height: var(--b-tap); color: var(--b-ink); text-decoration: none; }
.b-logo svg { height: 30px; width: auto; display: block; }

/* ---------- Movimiento reducido: fundidos cortos en vez de desplazamientos ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
  html { scroll-behavior: auto; }
}
