/* SECOP Intel — estilo "data-terminal" (taste-skill, pantallas de app)
   Pantalla de monitoreo para sesiones largas: paneles más oscuros que el fondo,
   cifras monoespaciadas que se alinean, y un único acento (azul gov.co) que solo
   marca la selección con una línea de 1px. */

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

:root {
    color-scheme: dark;
    --ground: #171719;  --surface: #131217;  --raised: #212023;
    --border: #222224;  --rule: #1b1a1f;     --control: #3a3a3e;
    --text: #ffffff;    --soft: #b6b7bc;     --muted: #8a8c92;
    --accent: #4a8ad6;  /* azul gov.co aclarado para fondo oscuro */
    --positive: #44a282; --negative: #e5566f; --warning: #d9a441;
    --pill-positive-bg: #1b2828; --pill-positive-ink: #5fc39c;
    --pill-negative-bg: #2c1a20; --pill-negative-ink: #e5566f;
    --pill-warning-bg: #2a2416;  --pill-warning-ink: #d9a441;
    --pill-accent-bg: #16233a;   --pill-accent-ink: #8db8ea;
    --pill-neutral-bg: #212023;  --pill-neutral-ink: #bdbdc0;
    --shadow: 0 12px 28px rgba(0, 0, 0, .2);

    --radius-card: 6px; --radius-field: 6px; --radius-chip: 4px;
    --gap: 24px; --pad: 32px; --card-pad: 24px;
    --control-height: 38px; --row-height: 46px;
    /* Letra del sistema: San Francisco en Mac e iPhone, como las apps de Apple */
    --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Inter, system-ui, sans-serif;
    /* Las cifras usan la misma letra con dígitos de ancho fijo (tabular-nums) */
    --mono: var(--font);
    --fs-title: 30px; --fs-kpi: 24px; --fs-body: 15px; --fs-small: 13px;
}

body {
    font-family: var(--font); font-size: var(--fs-body); line-height: 1.47; letter-spacing: -0.01em;
    background: var(--ground); color: var(--text); min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Barra superior: marca, alcance e integraciones ---------- */
.topbar {
    height: 52px; padding: 0 var(--pad);
    display: flex; align-items: center; justify-content: space-between; gap: var(--gap);
    border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { color: var(--accent); flex: none; }
.brand-name { font-weight: 600; font-size: 17px; white-space: nowrap; }
.brand-scope { color: var(--muted); font-size: var(--fs-small); white-space: nowrap; padding-left: 10px; border-left: 1px solid var(--control); }
.brand-scope a { color: var(--muted); }
.brand-scope a:hover { color: var(--text); }

.integrations { position: relative; flex: none; }
.int-summary {
    list-style: none; display: inline-flex; align-items: center; gap: 6px; height: var(--control-height); padding: 0 14px;
    border: 1px solid var(--control); border-radius: 999px; color: var(--soft); font-size: var(--fs-small); cursor: pointer;
}
.int-summary::-webkit-details-marker { display: none; }
.int-summary::after { content: ""; width: 6px; height: 6px; margin-left: 2px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-2px) rotate(45deg); }
.int-summary:hover, .integrations[open] .int-summary { color: var(--text); border-color: #55555b; }
#int-count { color: var(--muted); }
.int-menu {
    position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; width: 300px; padding: 12px;
    background: var(--raised); border-radius: var(--radius-card); box-shadow: 0 16px 40px rgba(0, 0, 0, .45);
}
.int-help { color: var(--muted); font-size: var(--fs-small); padding: 0 8px 8px; }
.int-tools { display: flex; flex-direction: column; }
.int-pill {
    display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 0 8px;
    background: none; border: none; border-radius: var(--radius-field); text-align: left;
    font: inherit; font-size: var(--fs-body); color: var(--soft); cursor: pointer; transition: background .15s, color .15s;
}
.int-pill:hover { background: #2a292d; color: var(--text); }
.int-name { flex: 1; }
.int-state { color: var(--muted); font-size: var(--fs-small); }
.int-on .int-name { color: var(--text); }
.int-on .int-state { color: var(--text); box-shadow: inset 0 -1px 0 var(--accent); }
.int-unavail { cursor: not-allowed; }
.int-unavail .int-name { color: var(--muted); }
.int-unavail:hover { background: none; }
.int-dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.dot-green { background: var(--positive); }
.dot-red { background: var(--negative); }

/* ---------- Lienzo ----------
   Ancho útil máx. 1376px (1440 − 2×32). Dentro del panel de filtros: 1376 − 2×24 = 1328
   = 7 columnas × 176 + 6 huecos × 16. Todos los bloques comparten el mismo borde izquierdo y derecho. */
.canvas { max-width: 1440px; margin: 0 auto; padding: 28px var(--pad) 48px; display: flex; flex-direction: column; gap: var(--gap); }

.title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--gap); }
h1 { font-size: var(--fs-title); font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.title-sub { color: var(--soft); font-size: 16px; margin-top: 6px; }
.title-sub strong { color: var(--text); font-weight: 600; }
.freshness { color: var(--muted); font-size: var(--fs-small); margin-top: 2px; }

/* KPIs: un solo contenedor dividido, sin iconos ni colores */
.kpis {
    display: grid; grid-template-columns: repeat(4, 1fr);
    background: var(--surface); border-radius: var(--radius-card); box-shadow: var(--shadow);
}
.kpi { padding: 16px var(--card-pad); }
.kpi + .kpi { border-left: 1px solid var(--border); }
.kpi-label { color: var(--muted); font-size: var(--fs-small); }
.kpi-value { font-size: var(--fs-kpi); font-weight: 500; margin-top: 4px; white-space: nowrap; }

/* ---------- Paneles ---------- */
.panel { background: var(--surface); border-radius: var(--radius-card); box-shadow: var(--shadow); }

.filters { padding: var(--card-pad); display: flex; flex-direction: column; gap: 20px; }
.filter-summary { display: none; }
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field-label { color: var(--muted); font-size: var(--fs-small); }
.unit { color: var(--muted); opacity: .8; }

.areas-match { color: var(--muted); font-size: var(--fs-small); margin-top: 6px; }
.senales { color: var(--muted); font-size: var(--fs-small); margin-top: 4px; }
.senal-buena { color: var(--positive); }
td.facil-cell { white-space: nowrap; }
.badge .num { margin-left: 5px; }

select, input[type="number"], input[type="date"], input[type="search"], textarea {
    height: var(--control-height); width: 100%; padding: 0 10px;
    background: var(--ground); color: var(--text);
    border: 1px solid var(--control); border-radius: var(--radius-field);
    font: inherit; font-size: var(--fs-body);
}
input[type="number"], input[type="date"] { font-family: var(--mono); font-variant-numeric: tabular-nums; }
input::placeholder { color: var(--muted); }
select:hover, input:hover { border-color: #4a4a50; }
select:focus, input:focus { outline: none; border-color: var(--accent); }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(.7); cursor: pointer; }


/* Botones */
.filter-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.btn {
    height: var(--control-height); padding: 0 16px; border-radius: 999px;
    font: inherit; font-size: var(--fs-body); font-weight: 500; white-space: nowrap; cursor: pointer;
    transition: background .15s, border-color .15s, color .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--text); color: #0d0d0f; border: 1px solid var(--text); padding: 0 22px; }
.btn-primary:hover { background: #dcdcdf; border-color: #dcdcdf; }
.btn-ghost { background: none; color: var(--soft); border: 1px solid var(--control); }
.btn-ghost:hover { color: var(--text); border-color: #55555b; }
/* Pestañas sobre la tabla: la seleccionada lleva la línea de acento */
.tabs { display: flex; gap: 24px; padding: 0 var(--card-pad); border-bottom: 1px solid var(--border); }
.tab {
    height: 44px; padding: 0; background: none; border: none; cursor: pointer;
    font: inherit; font-size: var(--fs-body); color: var(--muted); box-shadow: inset 0 -1px 0 transparent;
    transition: color .15s, box-shadow .15s;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); box-shadow: inset 0 -1px 0 var(--accent); }
.tab-count { color: var(--muted); margin-left: 4px; font-size: var(--fs-small); }

/* ---------- Tabla de resultados ---------- */
.results { overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
    position: sticky; top: 0; background: var(--surface);
    height: 40px; padding: 0 12px; text-align: left; vertical-align: middle;
    color: var(--muted); font-size: var(--fs-small); font-weight: 400;
    border-bottom: 1px solid var(--control); white-space: nowrap;
}
thead th:first-child, tbody td:first-child { padding-left: var(--card-pad); }
thead th:last-child, tbody td:last-child { padding-right: var(--card-pad); }
thead th[data-sort] { cursor: pointer; user-select: none; }
thead th[data-sort]:hover { color: var(--text); }
th.num, td.num { text-align: right; }
thead th.num { font-family: var(--font); }

tbody td { padding: 12px; border-bottom: 1px solid var(--rule); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #18171c; }

.col-entidad { width: 20%; }
.col-objeto { width: 36%; }
.col-modalidad { width: 150px; }
.entidad-cell { color: var(--soft); }
.entidad-cell, .desc-cell { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
td.entidad-cell { display: table-cell; }
.entidad-text { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.objeto { color: var(--text); font-weight: 500; }
.desc-cell { color: var(--muted); margin-top: 4px; -webkit-line-clamp: 2; }
.meta-sub { display: none; color: var(--muted); font-size: var(--fs-small); margin-top: 6px; }
td.valor { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; color: var(--text); }
td.fecha { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; color: var(--soft); }
.cierre { display: block; margin-top: 4px; font-family: var(--font); font-size: .85em; color: var(--positive); }
.cierre-pronto { color: var(--warning); }
td.modalidad, td.ciudad { color: var(--soft); }
.missing { color: var(--muted); }

/* Estados: tinte pálido y tinta del mismo tono */
.badge {
    display: inline-flex; align-items: center; height: 20px; padding: 0 8px; flex: none;
    border-radius: var(--radius-chip); font-size: var(--fs-small); font-weight: 500; white-space: nowrap;
}
.badge-abierto { background: var(--pill-positive-bg); color: var(--pill-positive-ink); }
.badge-publicado { background: var(--pill-accent-bg); color: var(--pill-accent-ink); }
.badge-evaluacion { background: var(--pill-warning-bg); color: var(--pill-warning-ink); }
.badge-cancelado { background: var(--pill-negative-bg); color: var(--pill-negative-ink); }
.badge-borrador, .badge-term { background: var(--pill-neutral-bg); color: var(--pill-neutral-ink); }

.new-tag {
    display: inline-flex; align-items: center; height: 18px; padding: 0 6px; margin-left: 8px; vertical-align: 2px;
    border-radius: var(--radius-chip); background: var(--pill-accent-bg); color: var(--pill-accent-ink);
    font-size: 12px; font-weight: 500;
}

/* Acciones por fila */
.acciones-cell { white-space: nowrap; text-align: right; }
.acciones { display: inline-flex; gap: 4px; }
.action-btn {
    width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
    background: none; border: 1px solid transparent; border-radius: var(--radius-field);
    color: var(--muted); cursor: pointer; text-decoration: none;
    transition: color .15s, border-color .15s;
}
.action-btn:hover { color: var(--text); border-color: var(--control); text-decoration: none; }
.action-btn svg { width: 15px; height: 15px; }
.btn-fav-on { color: var(--warning); }
.btn-fav-on:hover { color: var(--warning); }
.btn-fav-on svg path { fill: currentColor; }

/* Carga: la misma estructura con barras grises a su tamaño real, sin brillo */
.skeleton td { border-bottom: 1px solid var(--rule); }
.sk { display: block; height: 10px; border-radius: 2px; background: var(--raised); }
.sk + .sk { margin-top: 8px; }

/* Vacío y error: una frase dentro del marco */
.empty { padding: 40px var(--card-pad); color: var(--soft); text-align: center; }
.empty .link-btn { margin-left: 6px; }
.link-btn { background: none; border: none; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }
.link-btn:hover { text-decoration: underline; }
.loading { padding: 32px 0; color: var(--muted); text-align: center; }
.spinner { width: 20px; height: 20px; margin: 0 auto 10px; border: 2px solid var(--control); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.source { color: var(--muted); font-size: var(--fs-small); }

/* ---------- Diálogo de resumen con IA ---------- */
.modal { position: fixed; inset: 0; z-index: 1000; background: rgba(0, 0, 0, .6); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-content { width: 100%; max-width: 620px; max-height: 80vh; overflow-y: auto; background: var(--raised); border-radius: var(--radius-card); box-shadow: 0 24px 64px rgba(0, 0, 0, .5); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px var(--card-pad); border-bottom: 1px solid var(--control); }
.modal-title { font-size: 18px; font-weight: 600; }
.modal-close { width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; background: none; border: none; color: var(--muted); cursor: pointer; border-radius: var(--radius-field); }
.modal-close:hover { color: var(--text); }
.modal-body { padding: var(--card-pad); }
.ai-summary { font-size: var(--fs-body); line-height: 1.6; white-space: pre-wrap; }
.ai-model { color: var(--muted); font-size: var(--fs-small); margin-bottom: 12px; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation-duration: .01ms !important; }
}

/* ---------- Tableta ---------- */
@media (max-width: 1100px) {
    :root { --pad: 24px; }
    .col-modalidad, .col-ciudad, td.modalidad, td.ciudad { display: none; }
    .meta-sub { display: block; }
    .col-entidad { width: 24%; }
}

/* ---------- Teléfono: la tabla pasa a filas de dos líneas ---------- */
@media (max-width: 640px) {
    :root { --pad: 16px; --card-pad: 16px; --gap: 16px; }
    .topbar { padding: 0 var(--pad); }
    .brand-scope { display: none; }
    .int-menu { width: min(300px, calc(100vw - 32px)); }
    .title-row { flex-direction: column; align-items: flex-start; gap: 4px; }
    h1 { font-size: 26px; }
    .kpis { grid-template-columns: 1fr 1fr; }
    .kpi:nth-child(3) { border-left: none; }
    .kpi:nth-child(n+3) { border-top: 1px solid var(--border); }
    .filter-summary {
        display: flex; align-items: center; justify-content: space-between; list-style: none; cursor: pointer;
        font-size: 16px; font-weight: 600; min-height: 32px;
    }
    .filter-summary::-webkit-details-marker { display: none; }
    .filter-summary::after { content: "Mostrar"; color: var(--accent); font-weight: 400; font-size: var(--fs-small); }
    .filter-body[open] .filter-summary::after { content: "Ocultar"; }
    .filters { gap: 16px; }
    .filter-body[open] .filter-summary { margin-bottom: 16px; }
    .filter-actions .btn-ghost { padding: 0 12px; }
    .btn-primary { flex: 1; }
    select, input[type="number"], input[type="date"], input[type="search"], .btn { height: 44px; }

    thead { display: none; }
    tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 14px var(--card-pad); border-bottom: 1px solid var(--rule); }
    tbody tr:last-child { border-bottom: none; }
    tbody td { display: block; padding: 0 !important; border: none; }
    td.entidad-cell { grid-column: 1 / -1; order: 1; font-size: var(--fs-small); }
    td.objeto-cell { grid-column: 1; order: 2; }
    td.valor { grid-column: 2; order: 2; }
    td.estado-cell { grid-column: 1; order: 3; }
    td.facil-cell { grid-column: 1 / -1; order: 4; }
    td.fecha { grid-column: 2; order: 3; }
    td.acciones-cell { grid-column: 1 / -1; order: 5; text-align: left; margin-top: 4px; }
    .action-btn { width: 40px; height: 40px; border-color: var(--control); }
    tbody tr.skeleton, tbody tr.message-row { display: block; }
    tbody tr.skeleton td:not(:first-child):not(:nth-child(2)) { display: none; }
    .tabs { padding: 0 var(--card-pad); }
}

/* ---------- Funciones para empezar: sector, búsqueda, montos, ficha, guía ---------- */
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.btn-small { height: 34px; padding: 0 14px; font-size: var(--fs-small); }
.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
a.btn-primary:hover, a.btn:hover { text-decoration: none; }

.saved { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.saved select { width: auto; min-width: 220px; height: 34px; font-size: var(--fs-small); }

textarea { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.4; }
input[type="search"]::-webkit-search-cancel-button { filter: invert(.6); }


/* Filas que abren la ficha */
tbody tr[data-pid] { cursor: pointer; }
.seg-tag {
    display: inline-flex; align-items: center; height: 20px; padding: 0 7px; margin-left: 8px; vertical-align: 2px;
    border-radius: var(--radius-chip); background: var(--pill-warning-bg); color: var(--pill-warning-ink);
    font-size: 12px; font-weight: 500; white-space: nowrap;
}

/* Panel lateral (ficha y guía) */
.drawer-backdrop { position: fixed; inset: 0; z-index: 900; background: rgba(0, 0, 0, .5); }
.drawer {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 901; width: min(560px, 100vw);
    display: flex; flex-direction: column; background: var(--raised); box-shadow: -24px 0 64px rgba(0, 0, 0, .45);
}
.drawer[hidden], .drawer-backdrop[hidden] { display: none; }
body.drawer-open { overflow: hidden; }
.drawer-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px var(--card-pad); border-bottom: 1px solid var(--control); }
.drawer-title { font-size: 18px; font-weight: 600; }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--card-pad); }

.detail-entidad { color: var(--soft); font-size: var(--fs-small); }
.detail-objeto { font-size: 20px; font-weight: 600; line-height: 1.3; letter-spacing: -0.015em; margin-top: 4px; }
.detail-badges { margin-top: 10px; display: flex; gap: 6px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.detail-datos { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; margin-top: 22px; padding: 16px; background: var(--surface); border-radius: var(--radius-card); }
.detail-datos dt { color: var(--muted); font-size: var(--fs-small); }
.detail-datos dd { margin-top: 2px; }
.detail-section { margin-top: 26px; }
.detail-section h4 { font-size: 16px; font-weight: 600; margin-bottom: 10px; }
.detail-text { color: var(--soft); }
.detail-desc { white-space: pre-wrap; }
.detail-note { color: var(--muted); font-size: var(--fs-small); margin-top: 10px; }
.apto { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.checklist { margin-top: 12px; }
.checklist summary { cursor: pointer; color: var(--accent); font-size: var(--fs-small); }
.checklist ul { margin: 10px 0 0 18px; color: var(--soft); }
.checklist li + li { margin-top: 6px; }

.seg-form { display: grid; gap: 8px; }
.seg-form label + select, .seg-form label + textarea { margin-bottom: 6px; }
.seg-save { display: flex; align-items: center; gap: 12px; }
.seg-ok { color: var(--positive); font-size: var(--fs-small); }

.refs-resumen { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 14px 16px; background: var(--surface); border-radius: var(--radius-card); }
.refs-resumen > div { display: flex; flex-direction: column; gap: 2px; }
.refs-valor { font-size: 22px; font-weight: 600; }
.refs-lista { list-style: none; margin-top: 10px; }
.refs-lista li { padding: 10px 0; border-bottom: 1px solid var(--control); }
.refs-lista li:last-child { border-bottom: none; }
.refs-top { display: flex; justify-content: space-between; gap: 12px; }
.refs-top .num { white-space: nowrap; }
.refs-meta { color: var(--muted); font-size: var(--fs-small); margin-top: 2px; }

/* Guía */
.guia h3 { font-size: 17px; font-weight: 600; margin: 26px 0 10px; }
.guia-intro { color: var(--soft); }
.guia ol, .guia ul { margin-left: 20px; color: var(--soft); }
.guia li + li { margin-top: 8px; }
.guia strong { color: var(--text); font-weight: 600; }
.glosario { display: grid; gap: 10px; }
.glosario dt { font-weight: 600; }
.glosario dd { color: var(--soft); margin-top: 2px; }

@media (max-width: 1100px) {
    .title-row { flex-wrap: wrap; }
    .saved { justify-content: flex-start; }
}
@media (max-width: 640px) {
    .topbar-actions .btn-small { padding: 0 10px; }
    .hide-sm { display: none; }
    .brand-name { font-size: 16px; }
    .saved { width: 100%; }
    .saved select { min-width: 0; flex: 1 1 100%; }
    .detail-datos, .refs-resumen { grid-template-columns: 1fr; }
    .drawer { width: 100vw; }
}

/* ---------- Filtros organizados: filas con etiqueta y botones que se activan ---------- */
/* <details> no aplica bien flex/gap a su contenido en todos los navegadores: se usan márgenes */
.frow { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 16px; align-items: start; margin-bottom: 18px; }
.frow-label { padding-top: 8px; color: var(--soft); font-size: var(--fs-small); font-weight: 600; }

/* Sector: control segmentado (la opción activa queda rellena) */
.segmented { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--ground); border: 1px solid var(--control); border-radius: 999px; }
.segmented button {
    height: 32px; padding: 0 16px; border: none; border-radius: 999px; background: none; cursor: pointer;
    font: inherit; font-size: var(--fs-small); font-weight: 500; color: var(--soft);
    transition: background .15s, color .15s;
}
.segmented button:hover { color: var(--text); background: var(--raised); }
.segmented button[aria-checked="true"] { background: var(--text); color: #0d0d0f; }

/* Áreas: un bloque por sector, con atajos "Todas" / "Ninguna" */
.areas { display: flex; flex-direction: column; gap: 14px; }
.area-sector { transition: opacity .15s; }
.area-sector-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.area-sector-name { color: var(--text); font-size: var(--fs-small); font-weight: 600; margin-right: 4px; }
.area-sector-head .link-btn { font-size: var(--fs-small); }
.area-sector-head .link-btn:disabled { color: var(--muted); cursor: not-allowed; text-decoration: none; }
.area-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.area-sector.is-off { opacity: .45; }
.area-sector.is-off .toggle { cursor: not-allowed; }

/* Botón que se activa o desactiva: contorno apagado, relleno con marca cuando está activo */
.toggle, .chips button {
    position: relative; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px;
    border: 1px solid var(--control); border-radius: 999px; background: none; cursor: pointer; user-select: none;
    font: inherit; font-size: var(--fs-small); font-weight: 500; color: var(--soft);
    transition: background .15s, border-color .15s, color .15s;
}
.toggle:hover, .chips button:hover { border-color: #55555b; color: var(--text); }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle .tg-check { width: 12px; height: 12px; display: none; }
.toggle:has(input:checked) { background: var(--pill-accent-bg); border-color: var(--accent); color: var(--text); }
.toggle:has(input:checked) .tg-check { display: block; color: var(--pill-accent-ink); }
.toggle:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.chips button[aria-pressed="true"] { background: var(--pill-accent-bg); border-color: var(--accent); color: var(--text); }

/* Tres grupos: estado y modalidad · valor · fecha */
.fgroups { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 16px; margin-top: 6px; align-items: start; }
.fgroup { min-width: 0; border: none; padding: 16px; background: var(--ground); border-radius: var(--radius-card); }
.fgroup legend { float: left; width: 100%; margin-bottom: 12px; color: var(--text); font-size: var(--fs-small); font-weight: 600; }
.fgroup legend + * { clear: both; }
.fgroup-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.fgroup-grid.fgroup-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fgroup select, .fgroup input { background: var(--surface); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chips button { height: 30px; padding: 0 12px; font-variant-numeric: tabular-nums; }

.filter-actions { padding-top: 18px; border-top: 1px solid var(--border); }

@media (max-width: 1100px) {
    .fgroups { grid-template-columns: 1fr 1fr; }
    .fgroups .fgroup:first-child { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
    .frow { grid-template-columns: 1fr; gap: 8px; }
    .frow-label { padding-top: 0; }
    .segmented { display: grid; grid-template-columns: 1fr 1fr; border-radius: 14px; width: 100%; }
    .segmented button { border-radius: 11px; }
    .fgroups { grid-template-columns: 1fr; }
    .fgroup-grid { grid-template-columns: 1fr; }
    .fgroup-grid.fgroup-2 { grid-template-columns: 1fr 1fr; }
    .toggle { height: 38px; }
}
