/* Cascade layers keep the previous section order: identical precedence,
   explicit structure. */
@layer tokens, base, topbar, layout, cards, kpis, buttons, chips, tables, tabs, dossier, callouts, forms, states, chart, dialog, responsive, print, docreader, legend, landing, terminal;

@layer tokens {
  /* OpenVenue · variante terminal (guía front §10): un solo tema oscuro.
     Los 11 colores de §10, verbatim; los nombres antiguos de la hoja apuntan a
     ellos (ningún color más). Tipografía IBM Plex autohospedada (OFL 1.1,
     web/fonts/OFL.txt): sin CDN. */
  @font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-sans-400.woff2") format("woff2"); }
  @font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/ibm-plex-sans-500.woff2") format("woff2"); }
  @font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/ibm-plex-sans-600.woff2") format("woff2"); }
  @font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-mono-400.woff2") format("woff2"); }
  @font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/ibm-plex-mono-500.woff2") format("woff2"); }
  @font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/ibm-plex-mono-600.woff2") format("woff2"); }

  :root {
    color-scheme: dark;
    --bg: #0a0c0f;      /* fondo */
    --panel: #10141a;   /* fondo de panel */
    --line: #222a35;    /* bordes y separadores */
    --text: #d9dee6;    /* 14,5:1 */
    --muted: #8a94a3;   /* 6,4:1, rótulos y fuentes */
    --amber: #f2a93b;   /* 9,8:1, cabeceras de panel, teclas, foco */
    --link: #6cc4ff;    /* 10,2:1 */
    --up: #3ecf8e;      /* sube / vigente / OK */
    --down: #ff6b6b;    /* baja / error */
    --warn: #f2d03b;    /* aviso */
    --row-sel: #1b2430; /* fila seleccionada */

    --font-sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
      "Helvetica Neue", Arial, sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas,
      "Liberation Mono", monospace;

    /* Nombres de la hoja anterior, sobre los tokens de §10. */
    --surface: var(--panel);
    --surface-2: var(--row-sel);
    --surface-3: var(--line);
    --border: var(--line);
    --border-strong: var(--muted);
    --text-2: var(--text);
    --text-3: var(--muted);
    --accent: var(--link);
    --accent-hover: var(--amber);
    --accent-text: var(--bg);
    --accent-soft: var(--row-sel);
    --hero-grid: transparent;
    --focus: var(--amber);
    --series: var(--link);
    --grid: var(--line);
    --axis: var(--muted);
    --shadow: none;
    --shadow-pop: 0 12px 32px color-mix(in srgb, var(--bg) 80%, transparent);
    --ok: var(--up);
    --ok-bg: color-mix(in srgb, var(--up) 13%, transparent);
    --bad: var(--down);
    --bad-bg: color-mix(in srgb, var(--down) 13%, transparent);
    --warn-bg: color-mix(in srgb, var(--warn) 13%, transparent);
    --info: var(--link);
    --info-bg: color-mix(in srgb, var(--link) 13%, transparent);
    --neutral: var(--muted);
    --neutral-bg: var(--row-sel);

    --radius: 6px;
    --radius-sm: 4px;
    --topbar-h: 52px;
    --keybar-h: 44px;
    --gutter: clamp(16px, 3vw, 32px);
  }
}

@layer base { /* Base */


  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-padding-top: calc(var(--topbar-h) + 16px);
  }

  body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.5 var(--font-sans);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: flex;
    flex-direction: column;
  }

  h1,
  h2,
  h3,
  h4 {
    margin: 0;
    line-height: 1.25;
    font-weight: 600;
    letter-spacing: -0.01em;
  }

  h1 {
    font-size: clamp(20px, 2.4vw, 26px);
  }

  h2 {
    font-size: 16px;
  }

  h3 {
    font-size: 14px;
  }

  p {
    margin: 0;
  }

  a {
    color: var(--accent);
    text-decoration: none;
  }

  a:hover {
    text-decoration: underline;
  }

  code,
  .mono {
    font-family: var(--font-mono);
    font-size: 0.92em;
    font-variant-numeric: tabular-nums;
  }

  button,
  input,
  select {
    font: inherit;
    color: inherit;
  }

  :focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
  }

  [hidden] {
    display: none !important;
  }

  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .skip-link {
    position: absolute;
    left: 8px;
    top: -48px;
    z-index: 100;
    padding: 8px 14px;
    background: var(--accent);
    color: var(--accent-text);
    border-radius: var(--radius-sm);
  }

  .skip-link:focus {
    top: 8px;
  }

  .muted {
    color: var(--text-3);
  }

  .small {
    font-size: 12.5px;
  }

  /* index.html pre-renders the Inicio shell for the first paint: without
     scripting there is no data fetch, so the loading stack would shimmer forever;
     on the first paint of any other hash route the shell itself would flash.
     theme.js sets both classes before this stylesheet is applied. */
  html:not(.js) #home-loading,
  html.not-home #home-shell {
    display: none;
  }
}

@layer topbar { /* Barra de órdenes (§10): marca corta en ámbar, campo `>` y la fecha de cada fuente */

  .topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
  }

  .topbar-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    min-height: var(--topbar-h);
    padding: 6px var(--gutter);
    max-width: 1440px;
    margin: 0 auto;
  }

  .brand {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--amber);
    white-space: nowrap;
  }

  .brand:hover {
    text-decoration: none;
    color: var(--amber);
  }

  .search {
    flex: 1;
    min-width: 220px;
    max-width: 560px;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
  }

  .cmd-prompt {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--amber);
  }

  .search input {
    flex: 1;
    min-width: 0;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--panel);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 13px;
  }

  .search input::placeholder {
    color: var(--muted);
  }

  .search input:focus {
    outline: 2px solid var(--amber);
    outline-offset: -1px;
  }

  .cmd-msg {
    flex-basis: 100%;
    margin: 0;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--warn);
  }

  .cmd-msg:empty {
    display: none;
  }

  /* Una sola línea de fechas en escritorio; a ≤760 px cada fuente va en su línea. */
  .freshness {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px 14px;
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--muted);
  }

  .freshness strong {
    color: var(--text);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
  }

  .freshness .fresh-ok {
    color: var(--up);
  }

  .freshness .fresh-late {
    color: var(--warn);
  }

  .topnav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    margin-left: auto;
    font-size: 13px;
  }

  .topnav a {
    color: var(--muted);
    padding: 6px 8px;
    border-radius: var(--radius-sm);
  }

  .topnav a:hover,
  .topnav a[aria-current="page"] {
    color: var(--text);
    background: var(--row-sel);
    text-decoration: none;
  }
}

@layer layout { /* Layout */


  main {
    flex: 1;
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 24px var(--gutter) 48px;
  }

  main:focus {
    outline: none;
  }

  .page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
  }

  .page-head p {
    color: var(--text-2);
    margin-top: 6px;
    max-width: 760px;
  }

  .eyebrow {
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 6px;
  }

  .crumbs {
    font-size: 12.5px;
    color: var(--text-3);
    margin-bottom: 8px;
  }

  .crumbs a {
    color: var(--text-3);
  }

  .actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .grid {
    display: grid;
    gap: 16px;
  }

  .grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .grid-main-side {
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  }

  .stack > * + * {
    margin-top: 16px;
  }

  .footer {
    border-top: 1px solid var(--border);
    color: var(--text-3);
    font-size: 12px;
  }

  .footer-inner {
    max-width: 1440px;
    margin: 0 auto;
    padding: 14px var(--gutter);
    display: flex;
    flex-wrap: wrap;
    gap: 6px 20px;
    justify-content: space-between;
  }
}

@layer cards { /* Cards */


  .card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 0;
  }

  .card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
  }

  .card-head .sub {
    color: var(--text-3);
    font-size: 12.5px;
    margin-top: 2px;
  }

  .card-body {
    padding: 16px 18px;
  }

  .card-body.flush {
    padding: 0;
  }

  .card-body > * + * {
    margin-top: 12px;
  }

  .card-foot {
    padding: 10px 18px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
  }

  /* Guía front §10: cabecera fina del panel con el título en mayúsculas ámbar y la
     fuente a la derecha; el pie lleva la trazabilidad (fichero#fila o fecha). */
  .panel-head {
    align-items: flex-start;
    padding: 10px 18px;
  }

  .panel-title {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--amber);
  }

  .panel-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin-left: auto;
  }

  .panel-source {
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
  }

  .panel-foot {
    font-size: 12px;
    color: var(--muted);
  }
}

@layer kpis { /* KPI tiles */


  .kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
  }

  .kpi {
    padding: 14px 18px;
  }

  .kpi-label {
    font-size: 12px;
    color: var(--text-3);
    font-weight: 500;
  }

  .kpi-value {
    font-size: 24px;
    font-weight: 600;
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
  }

  .kpi-sub {
    font-size: 12px;
    color: var(--text-2);
    margin-top: 2px;
  }
}

@layer buttons { /* Buttons */


  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font-weight: 500;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
  }

  .btn:hover {
    background: var(--surface-2);
    text-decoration: none;
  }

  .btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
  }

  .btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
  }

  .btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
  }

  .btn-ghost {
    border-color: transparent;
    background: transparent;
    color: var(--text-2);
  }

  .btn-sm {
    height: 28px;
    padding: 0 10px;
    font-size: 12.5px;
  }

  .btn svg {
    width: 15px;
    height: 15px;
  }
}

@layer chips { /* Chips */


  .chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    line-height: 18px;
    white-space: nowrap;
    color: var(--neutral);
    background: var(--neutral-bg);
  }

  .chip::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex: none;
  }

  .chip-ok {
    color: var(--ok);
    background: var(--ok-bg);
  }

  .chip-warn {
    color: var(--warn);
    background: var(--warn-bg);
  }

  .chip-warn::before {
    border-radius: 1px;
    transform: rotate(45deg);
  }

  .chip-bad {
    color: var(--bad);
    background: var(--bad-bg);
  }

  .chip-bad::before {
    border-radius: 1px;
  }

  .chip-info {
    color: var(--info);
    background: var(--info-bg);
  }

  .chip-neutral::before {
    background: transparent;
    border: 1.5px solid currentColor;
  }

  .chip-help {
    color: inherit;
    opacity: 0.55;
    text-decoration: none;
    font-size: 10px;
    font-weight: 600;
    width: 14px;
    height: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid currentColor;
    border-radius: 50%;
    flex: none;
  }

  .chip-help:hover {
    opacity: 1;
  }

  .tag {
    display: inline-block;
    padding: 1px 7px;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    font: 500 12px/18px var(--font-mono);
    color: var(--text-2);
    white-space: nowrap;
  }

  .chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
  }
}

@layer tables { /* Tables */


  .table-wrap {
    position: relative; /* contains absolutely positioned .sr-only text inside scrolled tables */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
  }

  th,
  td {
    text-align: left;
    padding: 9px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
  }

  th {
    position: sticky;
    top: 0;
    background: var(--surface-2);
    color: var(--text-2);
    font-weight: 600;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1;
  }

  tbody tr:last-child td {
    border-bottom: 0;
  }

  tbody tr:hover td {
    background: var(--surface-2);
  }

  td.num,
  th.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
  }

  td.nowrap {
    white-space: nowrap;
  }

  tr.clickable {
    cursor: pointer;
  }

  .table-sticky-first th:first-child,
  .table-sticky-first td:first-child {
    position: sticky;
    left: 0;
    background: var(--surface);
    z-index: 2;
    box-shadow: 1px 0 0 var(--border);
  }

  .table-sticky-first th:first-child {
    background: var(--surface-2);
    z-index: 3;
  }

  .table-sticky-first tbody tr:hover td:first-child {
    background: var(--surface-2);
  }

  .flag-yes {
    color: var(--ok);
    font-weight: 600;
  }

  .flag-no {
    color: var(--text-3);
  }

  .matrix td,
  .matrix th {
    text-align: center;
    padding: 7px 8px;
  }

  .matrix th:first-child,
  .matrix td:first-child {
    text-align: left;
    min-width: 220px;
  }

  /* Key–value lists */

  .kv {
    display: grid;
    grid-template-columns: minmax(160px, 34%) minmax(0, 1fr);
    margin: 0;
  }

  .kv > div {
    display: contents;
  }

  .kv dt,
  .kv dd {
    margin: 0;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
    min-width: 0;
  }

  .kv > div:last-child dt,
  .kv > div:last-child dd {
    border-bottom: 0;
  }

  .kv dt {
    color: var(--text-2);
    padding-right: 16px;
  }

  .kv dt .native {
    display: block;
    font: 11px/1.4 var(--font-mono);
    color: var(--text-3);
    margin-top: 1px;
  }

  .kv dd {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    align-items: baseline;
    justify-content: space-between;
    overflow-wrap: anywhere;
  }

  .kv .value {
    font-family: var(--font-mono);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
  }

  .verbatim,
  .kv .value {
    white-space: pre-wrap; /* official strings keep their exact spacing (e.g. FISN) */
  }

  .kv .value.text {
    font-family: var(--font-sans);
    font-size: 14px;
  }

  .unknown {
    color: var(--text-3);
    font-style: italic;
    font-family: var(--font-sans);
  }

  .group-title {
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
    margin: 18px 0 2px;
  }

  .group-title:first-child {
    margin-top: 0;
  }

  /* Issue #177: ISIN admitidos de un mercado, en columnas dentro de su tarjeta. */
  .isin-list {
    columns: 3 200px;
    column-gap: 24px;
  }

  .isin-list li {
    break-inside: avoid;
  }
}

@layer tabs { /* Tabs */


  .tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--border);
    margin: 4px 0 20px;
    overflow-x: auto;
    scrollbar-width: none;
    position: sticky;
    top: var(--topbar-h);
    background: var(--bg);
    z-index: 20;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  /* Indicación de desplazamiento (issue #126): con más pestañas que ancho, la barra
     fina se ve en lugar de quedar oculta, también a 390 px. */
  .tabs.tabs-overflow {
    scrollbar-width: thin;
    scrollbar-color: var(--amber) transparent;
  }

  .tabs.tabs-overflow::-webkit-scrollbar {
    display: block;
    height: 3px;
  }

  .tabs.tabs-overflow::-webkit-scrollbar-thumb {
    background: var(--amber);
    border-radius: 2px;
  }

  .tab {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    border: 0;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    background: transparent;
    color: var(--text-2);
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
  }

  .tab:hover {
    color: var(--text);
  }

  .tab[aria-selected="true"] {
    color: var(--text);
    border-bottom-color: var(--accent);
  }

  .tab .count {
    font-size: 11.5px;
    font-variant-numeric: tabular-nums;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--text-2);
    line-height: 18px;
  }
}

@layer dossier { /* Dossier header */


  .dossier-head {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
  }

  .dossier-title {
    min-width: 0;
    flex: 1 1 420px;
  }

  .dossier-title h1 {
    overflow-wrap: anywhere;
  }

  .ident {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    align-items: center;
    margin-top: 10px;
    color: var(--text-2);
  }

  .ident .isin {
    font: 600 15px/1 var(--font-mono);
    color: var(--text);
    letter-spacing: 0.02em;
  }

  /* Issue #89: tira de datos clave bajo la cabecera. */
  .keyfacts {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 28px;
    padding: 12px 0 14px;
    margin-bottom: 16px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
  }

  .keyfact {
    min-width: 0;
  }

  .keyfact-label {
    display: block;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
  }

  .keyfact-value {
    display: block;
    font-size: 14px;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
  }

  .keyfact-source {
    display: block;
    font-size: 12px;
    color: var(--text-3);
  }
}

@layer callouts { /* Callouts & lists */


  .callout {
    display: flex;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-2);
  }

  .callout svg {
    flex: none;
    width: 18px;
    height: 18px;
    margin-top: 1px;
  }

  .callout-warn {
    background: var(--warn-bg);
    border-color: transparent;
    color: var(--text);
  }

  .callout-warn svg {
    color: var(--warn);
  }

  .callout-info {
    background: var(--info-bg);
    border-color: transparent;
    color: var(--text);
  }

  .callout-info svg {
    color: var(--info);
  }

  .callout-bad {
    background: var(--bad-bg);
    border-color: transparent;
    color: var(--text);
  }

  .callout-bad svg {
    color: var(--bad);
  }

  .notes {
    list-style: none;
    margin: 0;
    padding: 0;
  }

  .notes li {
    position: relative;
    padding: 8px 0 8px 18px;
    border-bottom: 1px solid var(--border);
    color: var(--text-2);
  }

  .notes li:last-child {
    border-bottom: 0;
  }

  .notes li::before {
    content: "";
    position: absolute;
    left: 2px;
    top: 16px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-3);
  }

  .checklist {
    list-style: none;
    margin: 0;
    padding: 0;
  }

  .checklist li {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
  }

  .checklist li:last-child {
    border-bottom: 0;
  }

  .link-list {
    list-style: none;
    margin: 0;
    padding: 0;
  }

  .link-list li {
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    overflow-wrap: anywhere;
    font-size: 13px;
  }

  .link-list li:last-child {
    border-bottom: 0;
  }

  .ext::after {
    content: " ↗";
    font-size: 0.85em;
  }

  details.more > summary {
    cursor: pointer;
    color: var(--accent);
    font-weight: 500;
    list-style: none;
  }

  details.more > summary::-webkit-details-marker {
    display: none;
  }

  details.more > summary::before {
    content: "▸ ";
  }

  details.more[open] > summary::before {
    content: "▾ ";
  }
}

@layer forms { /* Forms */


  .filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
  }

  .field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
  }

  .field label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-2);
  }

  .field input,
  .field select,
  .select {
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    min-width: 0;
  }

  .field input:focus,
  .field select:focus,
  .select:focus {
    border-color: var(--focus);
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-soft);
  }

  .field-grow {
    flex: 1 1 260px;
  }

  .field-mic input {
    width: 110px;
    text-transform: uppercase;
    font-family: var(--font-mono);
  }
}

@layer states { /* States: empty, error, skeleton */


  .empty {
    padding: 28px 18px;
    text-align: center;
    color: var(--text-3);
  }

  .empty strong {
    display: block;
    color: var(--text-2);
    margin-bottom: 4px;
  }

  .skeleton {
    display: block;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.4s ease-in-out infinite;
  }

  @keyframes shimmer {
    from {
      background-position: 200% 0;
    }
    to {
      background-position: -200% 0;
    }
  }

  .loading-note {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-2);
    margin-bottom: 16px;
  }

  .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex: none;
  }

  @keyframes spin {
    to {
      transform: rotate(360deg);
    }
  }

  .pager {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
  }

  /* Glosario (#108): lista de estados que cabe en 390 px */
  .glossary-list {
    list-style: none;
    margin: 0;
    padding: 0;
  }
  .glossary-list > li {
    padding: 10px 16px;
    border-top: 1px solid var(--line);
  }
  .glossary-term {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
  }
  .glossary-term code {
    overflow-wrap: anywhere;
  }
  .glossary-def {
    margin: 4px 0 0;
  }
  .glossary-list > li.row-focus {
    background: var(--accent-soft);
  }

  .row-focus > td {
    background: var(--accent-soft);
  }
}

@layer chart { /* Chart */


  .chart-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    align-items: center;
    justify-content: space-between;
  }

  .chart-plot {
    position: relative;
    width: 100%;
    touch-action: pan-y;
  }

  .chart-plot svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
  }

  .chart-plot svg:focus-visible {
    outline-offset: 4px;
  }

  .c-grid {
    stroke: var(--grid);
    stroke-width: 1;
  }

  .c-axis {
    stroke: var(--axis);
    stroke-width: 1;
  }

  .c-tick {
    fill: var(--text-3);
    font: 11px var(--font-sans);
    font-variant-numeric: tabular-nums;
  }

  .c-dot {
    fill: var(--series);
    stroke: var(--surface);
    stroke-width: 2;
  }

  .c-dot-active {
    fill: var(--series);
    stroke: var(--surface);
    stroke-width: 3;
  }

  .c-cross {
    stroke: var(--text-3);
    stroke-width: 1;
    stroke-dasharray: 3 3;
  }

  .c-hit {
    fill: transparent;
    cursor: crosshair;
  }

  .chart-tip {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 5;
    min-width: 180px;
    max-width: 260px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-pop);
    font-size: 12px;
    color: var(--text-2);
    pointer-events: none;
  }

  .chart-tip[data-position="left"] { left: 8px; right: auto; }
  .section-gap { margin-top: 16px; }
  .skeleton { height: 14px; width: 40%; margin-top: 12px; }
  .skeleton:first-child { margin-top: 0; }
  .skeleton:nth-child(3n + 2) { width: 77%; }
  .skeleton:nth-child(3n) { width: 59%; }
  .callout a:not(.btn) { text-decoration: underline; text-underline-offset: 2px; }

  .chart-tip strong {
    display: block;
    font-size: 15px;
    color: var(--text);
    font-variant-numeric: tabular-nums;
  }
}

@layer dialog { /* Dialog & toast */


  dialog.evidence {
    width: min(920px, calc(100vw - 32px));
    max-height: calc(100vh - 64px);
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-pop);
  }

  dialog.evidence::backdrop {
    background: rgba(8, 12, 18, 0.55);
  }

  dialog.evidence[open] {
    display: flex;
    flex-direction: column;
  }

  .dialog-body {
    overflow: auto;
    padding: 0;
    flex: 1;
  }

  .dialog-body pre {
    margin: 0;
    padding: 16px 18px;
    font: 12px/1.55 var(--font-mono);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: var(--text-2);
  }

  .toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 60;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    background: var(--text);
    color: var(--bg);
    font-weight: 500;
    box-shadow: var(--shadow-pop);
  }
}

@layer responsive { /* Responsive */


  @media (max-width: 1100px) {
    .kpis {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .grid-3 {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .grid-main-side {
      grid-template-columns: minmax(0, 1fr);
    }
  }

  /* Single-row topbar needs ~890 px before the nav pushes past the viewport:
     drop the tagline so 761–960 px keeps scrollWidth == clientWidth. */
  @media (max-width: 960px) {
    .brand-sub {
      display: none;
    }
  }

  @media (max-width: 760px) {
    :root {
      --topbar-h: 104px;
    }
    .topbar-inner {
      flex-wrap: wrap;
      gap: 8px 12px;
    }
    .search {
      order: 3;
      flex-basis: 100%;
      max-width: none;
    }
    .search input {
      font-size: 16px; /* prevents iOS zoom-on-focus */
      height: 40px;
    }
    .kbd {
      display: none;
    }
    .grid-2,
    .grid-3 {
      grid-template-columns: minmax(0, 1fr);
    }
    .freshness {
      margin-left: 0;
      flex-wrap: wrap;
      white-space: normal;
    }
    .kv {
      grid-template-columns: minmax(0, 1fr);
    }
    .kv dt {
      border-bottom: 0;
      padding-bottom: 0;
    }
    .field input,
    .field select {
      font-size: 16px;
      height: 40px;
    }
    .field-mic input {
      width: 100%;
    }
    .filters .field {
      flex: 1 1 140px;
    }
    .filters .btn {
      height: 40px;
      flex: 1 1 100%;
    }
    .card-head,
    .card-body {
      padding-left: 14px;
      padding-right: 14px;
    }
    th,
    td {
      padding: 8px 10px;
    }
  }

  @media (max-width: 480px) {
    .kpis {
      grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
      gap: 10px;
    }
    .kpi {
      padding: 12px;
    }
    .kpi-value {
      font-size: 20px;
    }
    .topnav {
      flex-wrap: wrap;
      row-gap: 0;
    }
    .topnav a {
      padding: 6px 8px;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }

  @media (forced-colors: active) {
    .chip {
      border: 1px solid CanvasText;
    }
    .tab[aria-selected="true"] {
      border-bottom-color: Highlight;
    }
  }
}

@layer print { /* Print: a dossier prints as one document */


  @media print {
    :root {
      color-scheme: light;
    }
    body {
      background: #fff;
      color: #000;
      font-size: 11px;
    }
    .topbar,
    .tabs,
    .actions,
    .footer,
    .skip-link,
    .btn,
    .chart-tip,
    .no-print {
      display: none !important;
    }
    .scope-bar {
      border: 0;
      background: none;
    }
    main {
      padding: 0;
      max-width: none;
    }
    [role="tabpanel"][hidden] {
      display: block !important;
    }
    [role="tabpanel"] {
      break-before: page;
    }
    [role="tabpanel"]:first-of-type {
      break-before: auto;
    }
    .card {
      box-shadow: none;
      break-inside: avoid;
      border-color: #bbb;
    }
    th {
      position: static;
    }
    .table-wrap {
      overflow: visible;
    }
    a.ext::after {
      content: " (" attr(href) ")";
      font-size: 9px;
      color: #555;
    }
  }
}

@layer docreader { /* Document reader */


  .doc-text {
    margin: 0;
    max-height: 75vh;
    overflow: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font: 13px/1.6 var(--font-mono);
    color: var(--text);
  }

  .strong {
    font-weight: 700;
  }

  .linklike {
    border: 0;
    padding: 0;
    background: none;
    color: var(--text-3);
    font: inherit;
    cursor: pointer;
  }

  .linklike:hover {
    text-decoration: underline;
  }
}

@layer legend { /* Favourites, issuer line, legend */


  .star[aria-pressed="true"] {
    color: var(--warn);
    border-color: var(--warn);
  }

  .star-icon,
  .star-inline {
    color: var(--warn);
    font-size: 15px;
    line-height: 1;
  }

  .issuer-line {
    margin-top: 6px;
    color: var(--text-2);
  }

  .hero-search {position: relative; display:flex; gap:12px; max-width:760px; margin:24px 0;}
  .hero-search input {font-size:1.2rem; min-width:0; flex:1; padding:16px;
    background:var(--surface); color:var(--text); border:1px solid var(--border-strong);
    border-radius:var(--radius-sm);}
  .suggestions {position:absolute; left:0; right:0; top:100%; z-index:40; margin:4px 0;
    padding:4px; list-style:none; background:var(--surface); color:var(--text);
    border:1px solid var(--border); border-radius:8px; box-shadow:0 8px 24px #0003;
    max-height:320px; overflow:auto;}
  .suggestions li {padding:10px; cursor:pointer; overflow-wrap:anywhere;}
  .suggestions [aria-selected="true"] {outline:2px solid var(--accent); outline-offset:-2px;}
  .market-label {display:block;}
  .follow-options {display:flex; align-items:center; flex-wrap:wrap; gap:8px;}
  .follow-options input {width:auto;}
  @media(max-width:600px) {.hero-search {flex-wrap:wrap;} .hero-search input {width:100%;}}

  details.legend > summary {
    cursor: pointer;
    list-style: none;
    border-bottom: 0;
  }

  details.legend > summary::-webkit-details-marker {
    display: none;
  }

  details.legend[open] > summary {
    border-bottom: 1px solid var(--border);
  }

  .legend .checklist li {
    justify-content: flex-start;
  }
}

@layer landing { /* Home landing, project page and public edition */
  [data-edition="public"] [data-private] {
    display: none !important;
  }

  .hero {
    position: relative;
    margin: 8px 0 32px;
    padding: clamp(24px, 5vw, 56px) clamp(20px, 4vw, 48px);
    border: 1px solid var(--border);
    border-radius: 14px;
    background:
      linear-gradient(var(--hero-grid) 1px, transparent 1px) 0 0 / 32px 32px,
      linear-gradient(90deg, var(--hero-grid) 1px, transparent 1px) 0 0 / 32px 32px,
      radial-gradient(120% 140% at 100% 0%, var(--accent-soft), transparent 60%),
      var(--surface);
    overflow: hidden;
  }

  .hero h1 {
    font-size: clamp(1.75rem, 3.6vw, 2.75rem);
    line-height: 1.12;
    letter-spacing: -0.02em;
    max-width: 30ch;
    text-wrap: balance;
  }

  .hero-lead {
    margin-top: 14px;
    max-width: 68ch;
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--text-2);
  }

  .hero .hero-search {
    margin: 28px 0 16px;
  }

  .hero .hero-search input {
    box-shadow: var(--shadow-pop);
  }

  .hero .hero-search .btn {
    align-self: stretch;
    height: auto;
    padding: 0 24px;
    font-size: 1rem;
  }

  .hero-examples {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
  }

  .example-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .example {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 6px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    text-decoration: none;
  }

  .example:hover,
  .example:focus-visible {
    border-color: var(--accent);
    background: var(--accent-soft);
  }

  .example-kind {
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--text-2);
    font-size: 11.5px;
    font-weight: 600;
  }

  .example-note {
    color: var(--text-3);
  }

  .hero-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, max-content));
    gap: 12px 48px;
    margin: 32px 0 0;
    padding-top: 24px;
    border-top: 1px solid var(--border);
  }

  .hero-stat {
    display: flex;
    flex-direction: column-reverse;
    gap: 2px;
  }

  .hero-stat dd {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
  }

  .hero-stat dt {
    color: var(--text-3);
    font-size: 13px;
  }

  .how {
    margin: 40px 0 8px;
  }

  .how h2 {
    font-size: 1.25rem;
    margin-bottom: 16px;
  }

  .how-steps {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: none;
  }

  .how-steps li {
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
  }

  .how-steps h3 {
    margin: 10px 0 6px;
    font-size: 1rem;
  }

  .how-steps p {
    color: var(--text-2);
    font-size: 13.5px;
    line-height: 1.55;
  }

  .how-index {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 700;
    font-size: 13px;
  }

  .how-more {
    margin-top: 16px;
  }

  .prose > * + * {
    margin-top: 10px;
  }

  .prose ul,
  ul.prose {
    padding-left: 20px;
    line-height: 1.6;
  }

  ul.prose li + li {
    margin-top: 6px;
  }

  @media (max-width: 960px) {
    .how-steps {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }

  @media (max-width: 600px) {
    .how-steps,
    .hero-stats {
      grid-template-columns: minmax(0, 1fr);
    }

    .hero-stats {
      gap: 14px;
    }

    .example-note {
      display: none;
    }

    .hero .hero-search {
      flex-direction: column;
    }

    .hero .hero-search .btn {
      min-height: 44px;
    }
  }
}

@layer terminal { /* Variante terminal (§10): cifras tabulares, foco ámbar, fila seleccionada y barra de teclas fija */

  body {
    padding-bottom: var(--keybar-h);
  }

  :focus-visible {
    outline: 2px solid var(--amber);
    outline-offset: 2px;
  }

  /* #main recibe el foco al cambiar de vista (lectores de pantalla): no es un control. */
  #main:focus,
  #main:focus-visible {
    outline: none;
  }

  .btn-primary,
  .btn-primary:hover {
    background: var(--amber);
    border-color: var(--amber);
    color: var(--bg);
  }

  td,
  .mono,
  .verbatim,
  time {
    font-variant-numeric: tabular-nums;
  }

  tbody tr.sel > * {
    background: var(--row-sel);
  }

  tbody tr.sel > :first-child {
    box-shadow: inset 2px 0 0 var(--amber);
  }

  .key-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    background: var(--panel);
    border-top: 1px solid var(--line);
  }

  .key-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 14px;
    min-height: var(--keybar-h);
    max-width: 1440px;
    margin: 0 auto;
    padding: 4px var(--gutter);
    font-size: 12px;
    color: var(--muted);
  }

  .key {
    font: inherit;
    font-family: var(--font-mono);
    color: inherit;
    background: none;
    border: 0;
    padding: 4px 2px;
    min-height: 32px;
    cursor: pointer;
    white-space: nowrap;
  }

  .key:hover {
    color: var(--text);
  }

  .key kbd {
    font: inherit;
    color: var(--amber);
    margin-right: 4px;
  }

  .keys-note {
    margin-left: auto;
  }

  @media (max-width: 720px) {
    .keys-note {
      display: none;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
      scroll-behavior: auto !important;
    }
  }

  @media print {
    .key-bar {
      display: none;
    }
  }
}
