/* ════════════════════════════════════════════════════════════════════
   screener.css — estética densa Bloomberg Terminal
   Hereda CSS variables de main.css. Sin estética editorial;
   máxima densidad, mono donde haya datos, monocromo + acento navy.
   ════════════════════════════════════════════════════════════════════ */


/* ─── TITLE BAR (una línea: SCREENER + tabs + contexto opcional) ────── */
.scr-titlebar {
    background: var(--c-bg-alt);
    border-bottom: 1px solid var(--c-border);
}
.scr-titlebar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
    flex-wrap: wrap;
}
.scr-title {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    min-width: 0;
}
.scr-title-label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    color: var(--c-text-subtle);
    border-right: 1px solid var(--c-border);
    padding-right: 1rem;
    line-height: 1;
}
.scr-tabs {
    display: flex;
    gap: 0;
}
.scr-tab {
    padding: 0.4rem 0.85rem;
    color: var(--c-text-muted);
    font-size: 0.86rem;
    font-weight: 500;
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: color 0.1s ease, border-color 0.1s ease;
    line-height: 1.4;
}
.scr-tab:hover {
    color: var(--c-accent);
    text-decoration: none;
}
.scr-tab.is-active {
    color: var(--c-accent);
    border-bottom-color: var(--c-accent);
    font-weight: 600;
}
.scr-context {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: var(--c-text-muted);
    min-width: 0;
}
.scr-context-label {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    color: var(--c-text-subtle);
}
.scr-context-text {
    color: var(--c-text);
    font-style: italic;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


/* ─── STAT STRIP (KPIs en fila horizontal compacta) ──────────────── */
.scr-statstrip {
    background: white;
    border-bottom: 1px solid var(--c-border);
}
.scr-statstrip-row {
    display: flex;
    gap: 0;
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
    flex-wrap: wrap;
}
.scr-stat {
    flex: 1 1 auto;
    min-width: 140px;
    padding: 0 1.25rem;
    border-right: 1px solid var(--c-border);
    line-height: 1.2;
}
.scr-stat:first-child { padding-left: 0; }
.scr-stat:last-child { border-right: none; }
.scr-stat-k {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--c-text-subtle);
    margin-bottom: 0.25rem;
}
.scr-stat-v {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--c-text-strong);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}
.scr-stat-flag {
    flex: 0 0 auto;
    min-width: 0;
}
.scr-stat-v-flag {
    font-size: 0.78rem;
    color: var(--c-warning);
    font-weight: 500;
    cursor: help;
}
.scr-stat-v-flag span {
    color: var(--c-text-subtle);
    font-weight: 400;
}


/* ─── LAYOUT ───────────────────────────────────────────────────── */
.scr-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 1.5rem;
    padding: 1.25rem 0 3rem;
    align-items: start;
}
.scr-layout > .scr-sidebar,
.scr-layout > .scr-main {
    min-width: 0;
}

@media (max-width: 980px) {
    .scr-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 1rem;
    }
}


/* ─── SIDEBAR (compacto, mono labels) ──────────────────────────── */
.scr-sidebar {
    position: sticky;
    top: calc(60px + 0.75rem);
    align-self: start;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    padding-right: 0.25rem;
    font-size: 0.86rem;
}
@media (max-width: 980px) {
    .scr-sidebar { position: static; max-height: none; }
}

.scr-fset {
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--c-border);
}
.scr-fset:first-child { padding-top: 0; }
.scr-fset:last-of-type { border-bottom: none; }

.scr-flabel {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--c-text-subtle);
    margin-bottom: 0.35rem;
}

.scr-fselect {
    width: 100%;
    max-width: 100%;
    padding: 0.35rem 0.5rem;
    background: white;
    border: 1px solid var(--c-border-strong);
    border-radius: 3px;
    color: var(--c-text);
    font-size: 0.84rem;
    font-family: inherit;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%238a8a8a' stroke-width='2'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    padding-right: 1.6rem;
    transition: border-color 0.1s;
}
.scr-fselect:hover { border-color: var(--c-accent); }
.scr-fselect:focus {
    outline: none;
    border-color: var(--c-border-focus);
    box-shadow: 0 0 0 2px rgba(31, 64, 104, 0.12);
}

.scr-frange {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0.25rem;
    align-items: center;
}
.scr-finput {
    width: 100%;
    padding: 0.35rem 0.45rem;
    border: 1px solid var(--c-border-strong);
    border-radius: 3px;
    background: white;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
}
.scr-finput:focus {
    outline: none;
    border-color: var(--c-border-focus);
    box-shadow: 0 0 0 2px rgba(31, 64, 104, 0.12);
}
.scr-frange-sep {
    color: var(--c-text-faint);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    padding: 0 0.1rem;
}

.scr-fcheck {
    display: flex;
    align-items: flex-start;
    gap: 0.45rem;
    padding: 0.3rem 0;
    cursor: pointer;
    line-height: 1.35;
}
.scr-fcheck input[type="checkbox"] {
    margin: 2px 0 0 0;
    accent-color: var(--c-accent);
    flex-shrink: 0;
}
.scr-fcheck span {
    color: var(--c-text);
    font-size: 0.84rem;
}
.scr-fcheck code {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    background: var(--c-bg-alt);
    padding: 0.05rem 0.3rem;
    border-radius: 2px;
    color: var(--c-text-muted);
}

.scr-fclear {
    display: inline-block;
    margin-top: 1rem;
    color: var(--c-text-muted);
    font-size: 0.82rem;
    text-decoration: none;
    font-family: var(--font-mono);
    letter-spacing: 0.02em;
}
.scr-fclear:hover { color: var(--c-danger); text-decoration: underline; }


/* ─── TOOLBAR (chips activos + meta resultados) ────────────────── */
.scr-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 0 0.75rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--c-border);
    flex-wrap: wrap;
}
.scr-toolbar-meta {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--c-text-muted);
    font-variant-numeric: tabular-nums;
}
.scr-toolbar-meta strong {
    color: var(--c-text-strong);
    font-weight: 600;
}
.scr-toolbar-sep {
    color: var(--c-text-faint);
    margin: 0 0.2rem;
}
.scr-toolbar-unit {
    color: var(--c-text-subtle);
    margin-left: 0.25rem;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
}
.scr-toolbar-empty {
    color: var(--c-text-muted);
    font-style: italic;
}

.scr-toolbar-chips {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}
.scr-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.4rem 0.2rem 0.55rem;
    background: var(--c-accent-soft);
    border: 1px solid rgba(31, 64, 104, 0.18);
    border-radius: 3px;
    font-size: 0.78rem;
    color: var(--c-text);
    text-decoration: none;
    line-height: 1.3;
    font-family: inherit;
    transition: all 0.1s;
}
.scr-chip:hover {
    border-color: var(--c-danger);
    background: var(--c-danger-bg);
    color: var(--c-danger);
    text-decoration: none;
}
.scr-chip-k {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--c-accent);
}
.scr-chip:hover .scr-chip-k { color: var(--c-danger); }
.scr-chip-v {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--c-text-strong);
}
.scr-chip:hover .scr-chip-v { color: var(--c-danger); }
.scr-chip-x {
    color: var(--c-text-muted);
    font-size: 0.95rem;
    line-height: 1;
    margin-left: 0.1rem;
    font-weight: 400;
}
.scr-chip:hover .scr-chip-x { color: var(--c-danger); }


/* ─── TABLA densa Bloomberg ────────────────────────────────────── */
.scr-tablewrap {
    overflow-x: auto;
    border: 1px solid var(--c-border);
    border-radius: 4px;
    background: white;
}
.scr-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    margin: 0;
}

/* Thead sticky con mono uppercase */
.scr-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--c-bg-alt);
    padding: 0.4rem 0.55rem;
    text-align: left;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--c-text-subtle);
    font-weight: 600;
    border-bottom: 1px solid var(--c-border-strong);
    white-space: nowrap;
    line-height: 1.5;
}
.scr-table thead th.num { text-align: right; }
.scr-table thead th.c-nif { width: 90px; }

/* Filas: cebra sutil + hover destacado */
.scr-table tbody tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.012);
}
.scr-table tbody tr {
    transition: background 0.08s ease;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}
.scr-table tbody tr:hover {
    background: var(--c-bg-hover);
    box-shadow: inset 2px 0 0 var(--c-accent);
}
.scr-table tbody tr:last-child { border-bottom: none; }

/* Filas clicables al drawer */
.scr-table tbody tr.scr-tr-clickable {
    cursor: pointer;
}
.scr-table tbody tr.scr-tr-clickable:hover {
    background: var(--c-accent-soft);
}

.scr-table td {
    padding: 0.35rem 0.55rem;
    vertical-align: middle;
    line-height: 1.3;
}
.scr-table td.num {
    text-align: right;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 0.76rem;
    color: var(--c-text);
}
.scr-table td.muted { color: var(--c-text-subtle); }
.scr-table td.strong, .scr-table .strong {
    font-weight: 600;
    color: var(--c-text-strong);
}

/* NIF: badge mono navy */
.scr-nif {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    color: var(--c-accent);
    background: var(--c-accent-soft);
    padding: 0.1rem 0.4rem;
    border-radius: 2px;
    text-decoration: none;
    letter-spacing: 0.02em;
    line-height: 1.3;
}
.scr-nif:hover {
    background: var(--c-accent);
    color: white;
    text-decoration: none;
}

/* Entity name */
.scr-ename {
    color: var(--c-text-strong);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid transparent;
    transition: border-color 0.1s, color 0.1s;
}
.scr-ename:hover {
    color: var(--c-accent);
    border-bottom-color: var(--c-accent);
    text-decoration: none;
}

/* PYME inline flag */
.scr-flag-pyme {
    display: inline-block;
    margin-left: 0.4rem;
    background: var(--c-success-bg);
    color: var(--c-pyme);
    border: 1px solid rgba(45, 90, 61, 0.2);
    padding: 0 0.35rem;
    border-radius: 2px;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    vertical-align: 1px;
    line-height: 1.5;
}

/* CCAA: nombre + extra count */
.scr-ccaa-primary { color: var(--c-text); }
.scr-ccaa-more {
    display: inline-block;
    margin-left: 0.3rem;
    background: var(--c-bg-alt);
    color: var(--c-text-muted);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 0.05rem 0.35rem;
    border-radius: 2px;
    cursor: help;
}

/* CPV badge */
.scr-table .cpv-badge,
.cpv-badge {
    display: inline-block;
    background: var(--c-accent-soft);
    color: var(--c-accent);
    border: 1px solid rgba(31, 64, 104, 0.15);
    padding: 0.12rem 0.45rem;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-decoration: none;
    line-height: 1.3;
}

/* ── MINI-BAR ARRIBA del importe (estilo Datawrapper) ─────────── */
.scr-amount {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
    line-height: 1.1;
}
.scr-amount-bar {
    width: 100%;
    max-width: 110px;
    height: 4px;
    background: var(--c-bg-alt);
    border-radius: 1px;
    overflow: hidden;
    position: relative;
}
.scr-amount-bar span {
    display: block;
    height: 100%;
    background: var(--c-accent);
    opacity: 0.55;
    transition: opacity 0.15s ease;
}
.scr-table tbody tr:hover .scr-amount-bar span {
    opacity: 1;
}
.scr-amount-v {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--c-text-strong);
}

/* ── Sort link en thead ─────────────────────────────────────── */
.scr-sort {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: color 0.1s;
}
.scr-sort:hover { color: var(--c-accent); text-decoration: none; }
.scr-sort.is-active { color: var(--c-accent); }
.scr-sort-arrow {
    font-size: 0.68rem;
    color: var(--c-accent);
}


/* ─── TABLE FOOTER (paginación + meta) ─────────────────────── */
.scr-tablefoot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 0.85rem;
    padding-top: 0.5rem;
    flex-wrap: wrap;
}
.scr-pag {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
}
.scr-pag a,
.scr-pag-current,
.scr-pag-disabled {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    border: 1px solid var(--c-border);
    border-radius: 3px;
    background: white;
    color: var(--c-text-muted);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
    text-decoration: none;
    transition: all 0.1s;
}
.scr-pag a:hover {
    border-color: var(--c-accent);
    color: var(--c-accent);
    text-decoration: none;
}
.scr-pag-current {
    background: var(--c-accent);
    border-color: var(--c-accent);
    color: white;
    font-weight: 600;
}
.scr-pag-disabled {
    color: var(--c-text-faint);
    background: var(--c-bg-alt);
}
.scr-pag-ell {
    color: var(--c-text-faint);
    padding: 0 4px;
    font-family: var(--font-mono);
}

.scr-tablefoot-meta {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    color: var(--c-text-subtle);
}
.scr-tablefoot-meta strong { color: var(--c-text-muted); }
.scr-tablefoot-meta em {
    color: var(--c-accent);
    font-style: normal;
}


/* ─── EMPTY STATE ──────────────────────────────────────────── */
.scr-empty {
    padding: 3rem 2rem;
    border: 1px dashed var(--c-border-strong);
    border-radius: 4px;
    background: var(--c-bg-alt);
    text-align: center;
}
.scr-empty-icon {
    width: 40px;
    height: 40px;
    color: var(--c-text-faint);
    margin: 0 auto 0.85rem;
}
.scr-empty-title {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    color: var(--c-text-strong);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 0.5rem;
}
.scr-empty-msg {
    color: var(--c-text-muted);
    margin: 0 auto;
    max-width: 40ch;
    font-size: 0.88rem;
    line-height: 1.5;
}
.scr-empty-msg a {
    color: var(--c-accent);
    font-family: var(--font-mono);
    font-size: 0.85rem;
}


/* ─── HTMX LOADING STATE (overlay sutil sobre main) ────────── */
.scr-main {
    position: relative;
    transition: opacity 0.15s ease;
}
.scr-main.htmx-request {
    opacity: 0.6;
    pointer-events: none;
}
.scr-main.htmx-request::after {
    content: "loading…";
    position: absolute;
    top: 0.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--c-accent);
    color: white;
    padding: 0.35rem 0.85rem;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    box-shadow: 0 4px 14px rgba(31, 64, 104, 0.25);
    z-index: 100;
    pointer-events: none;
}


/* ─── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 980px) {
    .scr-titlebar-row { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .scr-statstrip-row { gap: 0; }
    .scr-stat { padding: 0 0.85rem; min-width: 110px; }
    .scr-stat-v { font-size: 0.95rem; }
    .scr-toolbar { flex-direction: column; align-items: flex-start; }
    .scr-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .scr-tab { white-space: nowrap; flex-shrink: 0; }
}

@media (max-width: 640px) {
    .scr-titlebar { padding: 0; }
    .scr-statstrip-row { padding: 0.5rem 0; }
    .scr-stat {
        flex: 1 1 calc(50% - 1rem);
        border-right: none;
        border-bottom: 1px solid var(--c-border);
        padding: 0.4rem 0.6rem;
    }
    .scr-stat-v { font-size: 0.92rem; }
    .scr-table { font-size: 0.78rem; }
    .scr-table th, .scr-table td { padding: 0.4rem 0.45rem; }
    .scr-amount-bar { max-width: 60px; }
}


/* ════════════════════════════════════════════════════════════════════
   COLUMNAS ENRIQUECIDAS (iter4)
   ════════════════════════════════════════════════════════════════════ */

/* Help text bajo el select (FUENTE) y enlace al ⓘ */
.scr-fhelp {
    display: block;
    margin-top: 0.4rem;
    color: var(--c-text-muted);
    font-size: 0.74rem;
    line-height: 1.4;
    font-style: italic;
}
.scr-fhelp.scr-fhelp-muted {
    color: var(--c-text-subtle);
    font-style: normal;
}
.scr-fhelp a {
    color: var(--c-accent);
    text-decoration: none;
    font-style: normal;
}
.scr-fhelp a:hover { text-decoration: underline; }

.scr-fhelp-link {
    display: inline-block;
    color: var(--c-text-subtle);
    font-size: 0.78rem;
    text-decoration: none;
    margin-left: 0.3rem;
    transition: color 0.1s;
    cursor: help;
}
.scr-fhelp-link:hover {
    color: var(--c-accent);
    text-decoration: none;
}

/* Sector CPV en tabla: badge + descripción corta inline */
.scr-cpv-mini {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
}
.scr-cpv-mini-text {
    color: var(--c-text-muted);
    font-size: 0.78rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 130px;
}

/* Trim: celdas con texto largo que se cortan con elipsis */
.scr-trim {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Periodo: rango de años */
.scr-period {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 0.78rem;
    color: var(--c-text-muted);
    white-space: nowrap;
}
.scr-yr {
    color: var(--c-text);
}

/* % PYME: con codificación de color suave */
.scr-pct {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    color: var(--c-text);
    font-weight: 500;
}

/* Asegurar que la tabla con muchas columnas tiene scroll horizontal limpio */
.scr-tablewrap {
    overflow-x: auto;
    overflow-y: visible;
    /* Indicador visual de que hay más a la derecha */
    background:
        linear-gradient(to right, white 30%, rgba(255,255,255,0)),
        linear-gradient(to right, rgba(0,0,0,0), white 70%) 100% 0,
        radial-gradient(farthest-side at 0 50%, rgba(0,0,0,0.08), rgba(0,0,0,0)),
        radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,0.08), rgba(0,0,0,0)) 100% 0;
    background-repeat: no-repeat;
    background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
    background-attachment: local, local, scroll, scroll;
}


/* ════════════════════════════════════════════════════════════════════
   DRAWER LATERAL (iter5) — panel detalle al click en fila
   ════════════════════════════════════════════════════════════════════ */

.scr-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 100%;
    z-index: 1000;
    pointer-events: none;
}

.scr-drawer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(1px);
    -webkit-backdrop-filter: blur(1px);
    pointer-events: auto;
    opacity: 0;
    animation: scrFadeIn 0.18s ease forwards;
}

.scr-drawer-panel {
    position: absolute;
    top: 0;
    right: 0;
    height: 100vh;
    width: 460px;
    max-width: 92vw;
    background: white;
    border-left: 1px solid var(--c-border-strong);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
    overflow-y: auto;
    pointer-events: auto;
    transform: translateX(100%);
    animation: scrSlideIn 0.22s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes scrFadeIn {
    to { opacity: 1; }
}
@keyframes scrSlideIn {
    to { transform: translateX(0); }
}

body.scr-drawer-open {
    overflow: hidden;
}

/* Header del drawer (sticky arriba) */
.scr-drawer-head {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.1rem;
    background: var(--c-bg-alt);
    border-bottom: 1px solid var(--c-border);
}
.scr-drawer-kind {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    color: var(--c-text-subtle);
}
.scr-drawer-close {
    background: transparent;
    border: 1px solid transparent;
    color: var(--c-text-muted);
    font-size: 1.4rem;
    line-height: 1;
    width: 28px;
    height: 28px;
    border-radius: 3px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s;
    padding: 0;
}
.scr-drawer-close:hover {
    background: var(--c-danger-bg);
    color: var(--c-danger);
    border-color: var(--c-danger);
}

/* Body del drawer */
.scr-drawer-body {
    padding: 1.1rem;
}

/* Title */
.scr-drawer-title {
    margin-bottom: 1rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--c-border);
}
.scr-drawer-name {
    font-family: var(--font-sans, inherit);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--c-text-strong);
    margin: 0 0 0.4rem;
    line-height: 1.3;
}
.scr-drawer-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.78rem;
}
.scr-source-mini {
    color: var(--c-text-muted);
    font-size: 0.74rem;
    background: var(--c-bg-alt);
    padding: 0.1rem 0.4rem;
    border-radius: 2px;
}

/* CPV badge grande para drawer header */
.cpv-badge-lg {
    font-size: 0.95rem;
    padding: 0.2rem 0.55rem;
    margin-right: 0.4rem;
    vertical-align: 1px;
}

/* KPIs strip 2x2 en drawer */
.scr-drawer-kpis {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--c-border);
    border: 1px solid var(--c-border);
    border-radius: 3px;
    margin-bottom: 1.25rem;
}
.scr-drawer-kpi {
    background: white;
    padding: 0.7rem 0.85rem;
    line-height: 1.2;
}
.scr-drawer-kpi-k {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--c-text-subtle);
    margin-bottom: 0.25rem;
}
.scr-drawer-kpi-v {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 600;
    color: var(--c-text-strong);
    font-variant-numeric: tabular-nums;
}

/* Sections */
.scr-drawer-sec {
    margin-bottom: 1.4rem;
}
.scr-drawer-sech {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--c-text-subtle);
    margin: 0 0 0.55rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--c-border);
}

/* Top-N list rows */
.scr-drawer-list {
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: rank;
}
.scr-drawer-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.2rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    counter-increment: rank;
    position: relative;
    padding-left: 1.5rem;
}
.scr-drawer-row::before {
    content: counter(rank) ".";
    position: absolute;
    left: 0;
    top: 0.45rem;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--c-text-faint);
    font-weight: 500;
    width: 1.2rem;
}
.scr-drawer-row:last-child {
    border-bottom: none;
}
.scr-drawer-rname {
    font-size: 0.83rem;
    color: var(--c-text-strong);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
    line-height: 1.4;
}
.scr-drawer-rname:hover {
    color: var(--c-accent);
    text-decoration: underline;
}
.scr-drawer-rbar {
    height: 3px;
    background: var(--c-bg-alt);
    border-radius: 1px;
    overflow: hidden;
}
.scr-drawer-rbar span {
    display: block;
    height: 100%;
    background: var(--c-accent);
    opacity: 0.7;
}
.scr-drawer-rmeta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    font-variant-numeric: tabular-nums;
    color: var(--c-text-muted);
}
.scr-drawer-rmeta .num {
    color: var(--c-text);
    font-weight: 500;
}

/* Facts dl (Periodo, etc) */
.scr-drawer-facts {
    display: grid;
    grid-template-columns: minmax(120px, auto) 1fr;
    gap: 0.4rem 1rem;
    font-size: 0.83rem;
    margin: 0;
}
.scr-drawer-facts dt {
    color: var(--c-text-muted);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    align-self: center;
}
.scr-drawer-facts dd {
    color: var(--c-text);
    margin: 0;
    align-self: center;
}
.scr-drawer-facts dd .muted {
    color: var(--c-text-subtle);
    font-size: 0.78rem;
}

/* CTA al final */
.scr-drawer-cta {
    display: block;
    margin-top: 1.5rem;
    padding: 0.7rem 1rem;
    text-align: center;
    background: var(--c-accent);
    color: white;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.84rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-decoration: none;
    transition: background 0.1s;
}
.scr-drawer-cta:hover {
    background: var(--c-accent-strong, var(--c-accent));
    text-decoration: none;
    filter: brightness(1.1);
}

/* Empty state en drawer */
.scr-drawer-empty {
    color: var(--c-text-muted);
    font-size: 0.88rem;
    text-align: center;
    padding: 2rem 1rem;
}
.scr-drawer-empty code {
    font-family: var(--font-mono);
    background: var(--c-bg-alt);
    padding: 0.1rem 0.4rem;
    border-radius: 2px;
}


/* Responsive: en mobile, drawer ocupa 100% */
@media (max-width: 640px) {
    .scr-drawer-panel {
        width: 100%;
        max-width: 100%;
        border-left: none;
    }
    .scr-drawer-kpis {
        grid-template-columns: 1fr 1fr;
    }
}
/* ════════════════════════════════════════════════════════════════════
   ITER 6 — SOURCE BAR (segmented control de fuente)
   Bloomberg-dense: un row, scroll horizontal en móvil, activo en azul.
   Append a screener.css existente.
   ════════════════════════════════════════════════════════════════════ */

.scr-source-bar {
    background: white;
    border-bottom: 1px solid var(--c-border);
    padding: 0.45rem 0;
    overflow-x: auto;
    overflow-y: hidden;
    /* Sutil separador con la titlebar de arriba */
    box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.02);
}

/* Scrollbar discreto en móvil */
.scr-source-bar::-webkit-scrollbar {
    height: 4px;
}
.scr-source-bar::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 2px;
}

.scr-source-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    white-space: nowrap;
    min-width: max-content;
}

.scr-source-label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--c-text-subtle);
    letter-spacing: 0.1em;
    flex-shrink: 0;
    user-select: none;
}

.scr-source-group {
    display: inline-flex;
    align-items: center;
    gap: 0;
    flex-wrap: nowrap;
}

/* Hide los radios visualmente, accesibles por teclado */
.scr-source-group input[type='radio'] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.scr-source-pill {
    display: inline-block;
    padding: 0.32rem 0.7rem;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--c-text);
    background: var(--c-bg-alt);
    border: 1px solid var(--c-border);
    border-right: none;
    cursor: pointer;
    user-select: none;
    transition: background 0.08s, color 0.08s, border-color 0.08s;
    line-height: 1.2;
    /* Quitar el subrayado / decoración default si en algún momento se renderiza como link */
    text-decoration: none;
}
.scr-source-pill:hover {
    background: rgba(31, 64, 104, 0.06);
    color: var(--c-accent);
}

/* Bordes redondeados en los extremos del grupo */
.scr-source-group label.scr-source-pill:first-of-type {
    border-radius: 3px 0 0 3px;
}
.scr-source-group label.scr-source-pill:last-of-type {
    border-radius: 0 3px 3px 0;
    border-right: 1px solid var(--c-border);
}

/* Estado activo: el label adyacente a un input checked */
.scr-source-group input[type='radio']:checked + label.scr-source-pill {
    background: var(--c-accent);
    color: white;
    border-color: var(--c-accent);
}
.scr-source-group input[type='radio']:checked + label.scr-source-pill:hover {
    background: var(--c-accent);
    color: white;
}

/* Foco accesible (teclado) */
.scr-source-group input[type='radio']:focus-visible + label.scr-source-pill {
    outline: 2px solid var(--c-accent);
    outline-offset: 1px;
    z-index: 2;
    position: relative;
}

/* Variante autonómicas: fontsize ligeramente menor para densidad */
.scr-source-pill-aut {
    font-size: 0.74rem;
    padding: 0.32rem 0.6rem;
    color: var(--c-text-muted);
}
.scr-source-group input[type='radio']:checked + label.scr-source-pill-aut {
    color: white;
}

/* Divisor entre estatales/europea y autonómicas */
.scr-source-divider {
    color: var(--c-text-faint);
    font-size: 0.85rem;
    font-weight: 500;
    margin: 0 0.4rem;
    user-select: none;
}

/* Help icon ⓘ a la derecha */
.scr-source-help {
    margin-left: auto;
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--c-text-faint);
    font-size: 0.85rem;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: 50%;
    transition: color 0.1s, border-color 0.1s;
}
.scr-source-help:hover {
    color: var(--c-accent);
    border-color: var(--c-border);
    text-decoration: none;
}

/* Responsive: en móvil reducimos un poco el padding */
@media (max-width: 720px) {
    .scr-source-row {
        gap: 0.4rem;
    }
    .scr-source-pill,
    .scr-source-pill-aut {
        font-size: 0.72rem;
        padding: 0.3rem 0.55rem;
    }
    .scr-source-label {
        font-size: 0.62rem;
    }
}

/* ════════════════════════════════════════════════════════════════
   BORME drawer block — iter7
   Bloque "Registro Mercantil" en drawer de empresa.
   Honesto: tag ámbar "match por nombre", warn cuando hay variantes,
   foot disclaimer pequeño con link a metodología.
   ════════════════════════════════════════════════════════════════ */

/* Sección entera: separador top más fuerte que las normales para
   marcar que es un dataset DIFERENTE (no agregación de contracts) */
.scr-drawer-borme {
  border-top: 2px solid var(--scr-accent, #f5a623);
  padding-top: 14px;
  margin-top: 18px;
  background: linear-gradient(180deg,
              rgba(245, 166, 35, 0.04) 0%,
              transparent 60%);
}

.scr-drawer-borme .scr-drawer-sech {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.scr-borme-bar {
  color: var(--scr-accent, #f5a623);
  font-weight: 700;
  font-size: 1.1em;
  margin-right: -4px;
}

.scr-borme-tag {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 6px;
  background: rgba(245, 166, 35, 0.15);
  color: var(--scr-accent, #f5a623);
  border: 1px solid rgba(245, 166, 35, 0.4);
  border-radius: 2px;
  white-space: nowrap;
}

.scr-borme-query {
  font-size: 0.78rem;
  color: var(--scr-text-muted, #888);
  margin: 0 0 12px 0;
  line-height: 1.5;
}

.scr-borme-query code {
  display: inline-block;
  font-family: var(--scr-mono, 'SF Mono', 'Consolas', monospace);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 1px 6px;
  background: var(--scr-bg-alt, #1a1a1a);
  color: var(--scr-text, #e0e0e0);
  border: 1px solid var(--scr-border, #333);
  border-radius: 2px;
  word-break: break-word;
}

.scr-borme-warn {
  display: inline-block;
  font-size: 0.7rem;
  color: var(--scr-accent, #f5a623);
  font-weight: 500;
  margin-left: 4px;
}

.scr-borme-h4 {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--scr-text-muted, #888);
  margin: 16px 0 6px 0;
  padding-bottom: 4px;
  border-bottom: 1px dotted var(--scr-border, #333);
}

.scr-borme-list .scr-drawer-rname {
  font-size: 0.78rem;
  color: var(--scr-text, #d0d0d0);
}

.scr-borme-list .scr-drawer-rbar span {
  background: var(--scr-accent, #f5a623);
  opacity: 0.7;
}

.scr-borme-list .scr-drawer-rmeta .num {
  color: var(--scr-text, #e0e0e0);
}

.scr-borme-foot {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dashed var(--scr-border, #2a2a2a);
  font-size: 0.7rem;
  line-height: 1.5;
  color: var(--scr-text-muted, #777);
}

.scr-borme-foot a {
  color: var(--scr-accent, #f5a623);
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
}

.scr-borme-foot a:hover {
  text-decoration: underline;
}

/* Periodo: enlace al ancla de explicación del sentinela en /metodologia */
.period-info {
  color: var(--c-text-subtle);
  text-decoration: none;
  margin-left: 1px;
}
.period-info:hover {
  color: var(--c-text);
  text-decoration: none;
}
.period-info sup {
  font-size: 0.75em;
}

/* Pills de fuentes sin adjudicatario en origen — gris desaturado.
   No deshabilitamos el click (transparencia: el usuario debe poder
   navegar y ver el explainer). Solo señalamos visualmente que es
   distinta. Ver /metodologia#fuentes para detalles. */
.scr-source-pill-noadj {
    color: var(--c-text-subtle);
    opacity: 0.7;
}
.scr-source-pill-noadj:hover {
    opacity: 0.9;
}
.scr-source-group input[type='radio']:checked + label.scr-source-pill-noadj {
    background: var(--c-text-subtle);
    border-color: var(--c-text-subtle);
    color: white;
    opacity: 1;
}
