/* Portero — estilos. Tokens en :root, modo oscuro por preferencia. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dde1e7;
  --text: #17202b;
  --muted: #5d6877;
  --accent: #0f766e;
  --accent-strong: #0b5c56;
  --accent-soft: #e2f3f1;
  --down: #0f7a3c;
  --up: #b4372a;
  --danger: #b4372a;
  --warn-bg: #fff5db;
  --err-bg: #fdeceb;
  --ok-bg: #e5f5ea;
  /* Series categóricas (orden fijo; validadas con dataviz: claro sobre #fff). */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419;
    --surface: #161c23;
    --surface-2: #1d252e;
    --border: #2b3540;
    --text: #e6eaef;
    --muted: #97a3b1;
    --accent: #2bb3a5;
    --accent-strong: #5fd0c3;
    --accent-soft: #123432;
    --down: #4cc57f;
    --up: #f0806f;
    --danger: #f0806f;
    --warn-bg: #3a3116;
    --err-bg: #3d1d1a;
    --ok-bg: #16331f;
    --shadow: none;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
code, .mono { font-family: var(--mono); font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hint { color: var(--muted); font-size: .85rem; margin: .35rem 0 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Barra superior */
.topbar { display: flex; align-items: center; gap: 1.5rem; padding: .6rem 1.5rem; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 18px; height: 18px; border-radius: 5px; background: linear-gradient(135deg, var(--accent), var(--accent-strong)); display: inline-block; }
.nav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.nav a { color: var(--muted); padding: .35rem .7rem; border-radius: 8px; font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); }
.logout { display: flex; align-items: center; gap: .75rem; margin: 0; }
.who { font-size: .9rem; }

.page { max-width: 1280px; margin: 0 auto; padding: 1.75rem 1.5rem 4rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head p { margin: 0; }
.actions, .row-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.actions form, .row-actions form { margin: 0; }
.crumbs { margin-bottom: .5rem; font-size: .9rem; }
.section { margin-top: 2rem; }
.two-col { display: grid; grid-template-columns: 2fr 1fr; gap: 2rem; }

/* Botones y formularios */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .5rem .95rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
  white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); }
.btn-sm { padding: .3rem .65rem; font-size: .85rem; }
.btn-block { width: 100%; }
input, select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .45rem .6rem; min-width: 0; }
input:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
label, legend { font-weight: 600; font-size: .85rem; }
.field { display: flex; flex-direction: column; gap: .3rem; margin: 0 0 1rem; border: 0; padding: 0; min-width: 0; }
.field legend { margin-bottom: .4rem; padding: 0; }
.field-row { display: flex; gap: .75rem; flex-wrap: wrap; }
.field-row .field { flex: 1 1 5.5rem; }
.field-row input { width: 100%; }
.stack { display: flex; flex-direction: column; gap: .25rem; }
.checks { display: flex; flex-direction: column; gap: .2rem; }
.checks-scroll { max-height: 15rem; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: .4rem .6rem; background: var(--surface); }
.check { display: flex; align-items: center; gap: .45rem; font-weight: 400; font-size: .9rem; cursor: pointer; margin-bottom: .35rem; }
.check .muted { margin-left: auto; font-size: .8rem; }
.list-filter { margin-bottom: .4rem; }

.layout-split { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow); }
.layout-split > .panel { position: sticky; top: 4.5rem; max-height: calc(100vh - 6rem); overflow-y: auto; }
.saveform { display: flex; gap: .5rem; margin: 0 0 1rem; flex-wrap: wrap; }
.saveform input[name="name"] { flex: 1 1 16rem; }

/* Alertas */
.alert { padding: .7rem 1rem; border-radius: 8px; background: var(--warn-bg); margin-bottom: 1rem; }
.alert-error { background: var(--err-bg); }
.alert-ok { background: var(--ok-bg); }

/* Indicadores */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem; box-shadow: var(--shadow); }
.tile-label { color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.tile-value { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: .15rem; }
.tile-sub { color: var(--muted); font-size: .82rem; margin-top: .1rem; }
.tile-empty { color: var(--muted); grid-column: 1 / -1; }

/* Tarjetas de búsquedas */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem; color: var(--text); box-shadow: var(--shadow); transition: border-color .15s; }
.card:hover { border-color: var(--accent); text-decoration: none; }
.card-title { margin: 0 0 .2rem; font-size: 1.05rem; }
.card-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: .9rem 0 0; }
.card-stats dt { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; }
.card-stats dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.empty-state { text-align: center; padding: 3rem 1rem; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }

/* Pestañas */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin: 0 0 1rem; overflow-x: auto; }
.tabs a { padding: .55rem .9rem; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--accent-strong); border-bottom-color: var(--accent); }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented a { padding: .3rem .7rem; color: var(--muted); font-size: .85rem; font-weight: 600; }
.segmented a + a { border-left: 1px solid var(--border); }
.segmented a[aria-current="true"] { background: var(--accent-soft); color: var(--accent-strong); }
.segmented a:hover { text-decoration: none; }

/* Tablas */
.table-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .5rem; flex-wrap: wrap; }
.table-head p { margin: 0; }
.sort { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
.data th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600;
  padding: .6rem .75rem; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.data td { padding: .55rem .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data tbody tr:last-child td { border-bottom: 0; }
.data tbody tr:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data th.num { text-align: right; }
.cell-title { display: flex; gap: .7rem; align-items: center; min-width: 18rem; }
.cell-title > span { display: flex; flex-direction: column; }
.thumb { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; flex: none; background: var(--surface-2); }
.thumb-empty { display: inline-block; }
.row-delisted td { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 2rem !important; }
.down { color: var(--down); font-weight: 600; }
.up { color: var(--up); font-weight: 600; }
.err { color: var(--danger); }
.pager { display: flex; justify-content: center; gap: .5rem; margin-top: 1rem; }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge-done { background: var(--ok-bg); color: var(--down); }
.badge-running, .badge-queued { background: var(--accent-soft); color: var(--accent-strong); }
.badge-blocked { background: var(--warn-bg); color: var(--text); }
.badge-failed { background: var(--err-bg); color: var(--danger); }
.badge-auto { border: 1px dashed var(--muted); background: transparent; }
.amenities .badge { margin: 0 .15rem .25rem 0; }

/* Ficha */
.chart { margin: 0 0 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.chart canvas { width: 100% !important; height: 260px !important; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .5rem; }
.gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: var(--surface-2); }
.prose { white-space: pre-line; max-width: 70ch; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* Login */
.auth { max-width: 380px; margin: 8vh auto 0; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 2rem; box-shadow: var(--shadow); }
.auth-title { display: flex; align-items: center; gap: .6rem; font-size: 1.35rem; }
.auth .field input { width: 100%; }

.htmx-request #results, #results.htmx-request { opacity: .55; transition: opacity .15s; }

@media (max-width: 900px) {
  .layout-split, .two-col { grid-template-columns: 1fr; }
  .layout-split > .panel { position: static; max-height: none; }
  .topbar { padding: .6rem 1rem; gap: .75rem; }
  .page { padding: 1.25rem 1rem 3rem; }
  .who { display: none; }
}
.tile-note { background: transparent; box-shadow: none; border-style: dashed; }
.tile-note .tile-value { font-size: 1.1rem; }

/* Favoritos */
.star { background: none; border: 0; font-size: 1.15rem; line-height: 1; color: var(--muted); cursor: pointer; padding: .2rem; flex: none; text-decoration: none; }
.star:hover { color: var(--accent); text-decoration: none; }
.star-on { color: #d99a00; }
.btn-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
.fav-lists { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.fav-lists form { margin: 0; }
.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: 0; }
.saveform-anon { align-items: center; justify-content: space-between; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: .6rem 1rem; }
.saveform-anon p { margin: 0; }
.narrow { max-width: 520px; }
.logout .btn { white-space: nowrap; }

/* Evolución semanal */
.evolution { margin: 0 0 1.5rem; }
.evolution h2 { margin: 0; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: .75rem; }
.charts .chart { margin: 0; }
.chart figcaption { font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: .5rem; }
.charts .chart canvas { height: 220px !important; }
.evolution-empty { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: .8rem 1rem; margin: 0; }
.card-trend { margin: .75rem 0 0; }

/* Estadísticas */
.stats-section { margin: 0 0 2.5rem; }
.stats-section > .table-head { margin-bottom: .75rem; }
.stats-section h2 { margin: 0; }
.stats-section .chart canvas { height: 300px !important; }
.swatch { display: inline-block; width: .7rem; height: .7rem; border-radius: 3px; margin-right: .35rem; vertical-align: baseline; }
.swatch-s1 { background: var(--series-1); }
.swatch-s2 { background: var(--series-2); }
.swatch-s3 { background: var(--series-3); }
.swatch-s4 { background: var(--series-4); }
.swatch-s5 { background: var(--series-5); }
.swatch-muted { background: var(--muted); opacity: .5; }
.hero-pct { font-size: 2.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.section-gap { margin-top: .75rem; }
.row-current th, .row-current td { background: var(--accent-soft); }
.data th[scope="row"] { text-align: left; font-weight: 600; font-size: .9rem; text-transform: none; letter-spacing: 0; color: var(--text); background: transparent; }
.data .row-current th[scope="row"] { background: var(--accent-soft); }

/* Vistas */
.data .sub { display: block; font-size: .75rem; color: var(--muted); font-weight: 400; }

/* Comparación con la zona */
.compare-form .field input[name="aviso"] { width: 100%; }
.compare-form .checks { gap: 1.25rem; margin-bottom: 1rem; }
.compare-form .checks label { display: inline-flex; gap: .4rem; align-items: center; font-weight: 400; }
.insights { margin: 0; padding: 0; list-style: none; display: grid; gap: .5rem; }
.insights li { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px; padding: .6rem .9rem; }
/* Percentil: posición, no juicio (sin los colores bueno/malo del navegador). */
.rank { display: block; width: 100%; height: .5rem; margin: .5rem 0 .1rem; appearance: none; border: 0; border-radius: 999px; background: var(--surface-2); }
.rank::-webkit-meter-bar { background: var(--surface-2); border: 0; border-radius: 999px; height: .5rem; }
.rank::-webkit-meter-optimum-value, .rank::-webkit-meter-suboptimum-value, .rank::-webkit-meter-even-less-good-value { background: var(--accent); border-radius: 999px; }
.rank::-moz-meter-bar { background: var(--accent); border-radius: 999px; }
.row-target td { background: var(--accent-soft); }
.pending:empty { display: none; }
.share-url { flex: 1 1 24rem; min-width: 0; font-family: var(--mono); font-size: .85rem; }
.print-only { display: none; }

/* Impresión / PDF: A4 apaisado, siempre en claro, sin navegación ni
   acciones, y la tabla entera a lo ancho de la hoja. */
@media print {
  @page { size: A4 landscape; margin: 12mm; }
  :root {
    --bg: #ffffff; --surface: #ffffff; --surface-2: #f0f2f5; --border: #cfd5dd;
    --text: #17202b; --muted: #4f5a68; --accent: #0f766e; --accent-strong: #0b5c56;
    --accent-soft: #e2f3f1; --down: #0f7a3c; --up: #b4372a; --shadow: none;
    color-scheme: light;
  }
  html, body { background: #fff !important; color: var(--text); font-size: 10pt; }
  * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .topbar, .crumbs, .no-print, .actions, #pending, .thumb, form { display: none !important; }
  .print-only { display: block; }
  .print-meta { color: var(--muted); font-size: 8pt; margin: 0 0 .6rem; }
  .page { max-width: none; padding: 0; margin: 0; }
  a { color: var(--text); text-decoration: none; }
  h1 { font-size: 15pt; margin: 0 0 .2rem; }
  h2 { font-size: 12pt; break-after: avoid; }
  .section { margin: 0 0 .9rem; }
  .insights li { padding: .3rem .6rem; break-inside: avoid; }
  .tiles { grid-template-columns: repeat(3, 1fr); gap: .4rem; }
  .tile { padding: .45rem .6rem; break-inside: avoid; }
  .tile-value { font-size: 12pt; }
  .charts { grid-template-columns: repeat(2, 1fr); gap: .5rem; }
  .chart { padding: .5rem; break-inside: avoid; }
  .chart canvas, .charts .chart canvas { height: 190px !important; }
  .table-wrap { overflow: visible; border: 0; box-shadow: none; }
  .data { font-size: 8pt; width: 100%; }
  .data th, .data td { padding: .2rem .35rem; }
  .data thead { display: table-header-group; }
  .data tr { break-inside: avoid; }
  .data tbody tr:hover { background: transparent; }
  .cell-title { display: table-cell; min-width: 0; }
  .cell-title > span { display: block; }
  .cell-title a { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
}

/* /zonas: comando para sumar una zona */
pre.code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: .75rem 1rem; overflow-x: auto; margin: .5rem 0; }
pre.code code { font-size: .85rem; }

/* Web local: avance de una búsqueda */
progress.progress { display: block; width: 100%; height: .75rem; margin: 1rem 0 .5rem; appearance: none; border: 0; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
progress.progress::-webkit-progress-bar { background: var(--surface-2); border-radius: 999px; }
progress.progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; transition: width .4s ease; }
progress.progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
progress.progress-thin { height: .3rem; margin: .35rem 0 0; }
.live { margin-top: 1.5rem; }
.now { font-weight: 600; margin: 0 0 .5rem; min-height: 1.5em; }
.wait { margin-bottom: 1rem; }
.wait-text { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.live-title { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin: 1.25rem 0 .5rem; }
.feed { list-style: none; margin: 0; padding: 0; max-height: 22rem; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); font-size: .85rem; }
.feed li { padding: .35rem .75rem; border-top: 1px solid var(--border); overflow-wrap: anywhere; }
.feed li:first-child { border-top: 0; }
.feed li.warn { background: var(--warn-bg); }
.feed time { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: .35rem; }
@media (prefers-reduced-motion: reduce) { progress.progress::-webkit-progress-value { transition: none; } }

/* Web local: tablero de resultados (static/results.js) */
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; font-weight: 600; }
.linkish:hover { text-decoration: underline; }
.filters { margin: 0 0 1.25rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); }
.filters-toggle { display: none; list-style: none; }
.filters-toggle::-webkit-details-marker { display: none; }
.filters-body { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem 1.25rem; padding: .8rem 1rem; margin: 0; }
.filters .f { display: flex; flex-direction: column; gap: .3rem; margin: 0; padding: 0; border: 0; min-width: 0; }
.filters legend, .filters .f > label { font-size: .75rem; font-weight: 600; color: var(--muted); padding: 0; margin: 0; }
.filters legend:not(.sr-only) { float: left; width: 100%; margin-bottom: .3rem; }
.filters legend:not(.sr-only) + * { clear: both; }
.f-q { flex: 1 1 14rem; }
.f-q input { width: 100%; }
.range { display: flex; align-items: center; gap: .35rem; color: var(--muted); }
.range input { width: 6.5rem; }
.f-range + .f-range .range input { width: 5rem; }
.chips { display: flex; gap: .25rem; flex-wrap: wrap; }
.chip { font: inherit; font-size: .85rem; font-weight: 600; padding: .38rem .6rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; font-variant-numeric: tabular-nums; transition: background-color .15s, border-color .15s; }
.chip .muted { font-weight: 400; font-size: .78rem; }
.chip:hover { background: var(--surface-2); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
.cur-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.segmented button { font: inherit; font-size: .85rem; font-weight: 600; padding: .38rem .7rem; border: 0; background: var(--surface); color: var(--muted); cursor: pointer; }
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-strong); }
.fx { display: inline-flex; align-items: center; gap: .3rem; font-weight: 400; font-size: .85rem; white-space: nowrap; }
.fx input { width: 5.5rem; font-variant-numeric: tabular-nums; }
.f-toggles { flex-direction: row !important; align-items: center; min-height: 2.35rem; gap: .25rem 1rem; flex-wrap: wrap; }
.f-toggles .check { margin: 0; }
.filters-status { margin: 0 0 0 auto; font-size: .85rem; white-space: nowrap; min-height: 2.35rem; display: flex; align-items: center; font-variant-numeric: tabular-nums; }
.filters-status strong { margin-right: .5rem; }
.filters-count { color: var(--accent-strong); }

.dash-tiles { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }
.dash-tiles .tile-sub { text-wrap: pretty; }
.tabs button[role="tab"] { font: inherit; background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  padding: .6rem .95rem; color: var(--muted); font-weight: 600; white-space: nowrap; cursor: pointer; transition: color .15s, border-color .15s; }
.tabs button[role="tab"]:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--accent-strong); border-bottom-color: var(--accent); }
.tab-panel { padding-top: .25rem; }
#tablist { scroll-margin-top: 4.5rem; }
.tabs button[role="tab"]:focus-visible, .segmented button:focus-visible { outline-offset: -2px; }
.dash-tiles .tile-value { overflow-wrap: anywhere; }
.tab-panel:focus-visible { outline: none; }

.dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.dash-grid .chart-wide { grid-column: 1 / -1; }
.dash-chart { display: flex; flex-direction: column; padding: 1rem 1.1rem .75rem; }
.dash-chart figcaption { display: flex; flex-direction: column; gap: .15rem; margin-bottom: .75rem; }
.fig-title { font-size: 1rem; font-weight: 700; color: var(--text); }
.fig-note { font-size: .82rem; font-weight: 400; color: var(--muted); }
.fig-note strong { color: var(--text); font-variant-numeric: tabular-nums; }
.canvas-box { position: relative; height: 240px; }
.chart-tall .canvas-box { height: 340px; }
.dash-chart canvas, .charts .dash-chart canvas { width: 100% !important; height: 100% !important; }
canvas.is-pointing { cursor: pointer; }
.key { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; vertical-align: baseline; margin: 0 .1rem 0 .25rem; }
.key-deal { background: var(--down); }
.key-up { background: var(--up); }
.key-rest { background: var(--muted); opacity: .45; }
.legend { list-style: none; margin: .6rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-size: .85rem; }
.legend li { display: inline-flex; align-items: center; white-space: nowrap; }
.legend-val { color: var(--muted); margin-left: .35rem; font-variant-numeric: tabular-nums; }
.fig-data { margin-top: .5rem; font-size: .82rem; }
.fig-data summary { color: var(--muted); cursor: pointer; width: max-content; }
.fig-data summary:hover { color: var(--text); }
.fig-data > div { max-height: 16rem; overflow: auto; margin-top: .4rem; }
.data-compact { font-size: .82rem; }
.data-compact th, .data-compact td { padding: .3rem .5rem; }

.dash-section { margin: 0 0 2rem; }
.dash-section h2 { margin: 0; display: flex; align-items: baseline; gap: .5rem; }
.dash-section .table-head { align-items: baseline; }
.count { font-size: .8rem; font-weight: 600; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: .05rem .5rem; font-variant-numeric: tabular-nums; }
.dash-two { gap: 1.5rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dash-two .cell-title { min-width: 13rem; }
.dash-lede { max-width: 75ch; margin: 0 0 1.25rem; color: var(--muted); }
.dash-lede strong { color: var(--text); }
.dash-empty { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: .9rem 1rem; margin: 0; color: var(--muted); max-width: 75ch; }
.vs { display: inline-block; font-weight: 600; font-variant-numeric: tabular-nums; padding: .05rem .45rem; border-radius: 999px; }
.vs-deal { background: var(--ok-bg); color: var(--down); }
.vs-below { color: var(--down); }
.vs-above { color: var(--muted); }
.data-list .cell-title { min-width: 16rem; }
.data-list .cell-title a { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.th-sort { font: inherit; text-transform: inherit; letter-spacing: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer;
  display: inline-flex; align-items: center; gap: .25rem; }
.th-sort:hover { color: var(--text); }
.sort-ind { font-size: .65rem; min-width: .65rem; }
th[aria-sort] .th-sort { color: var(--accent-strong); }
.pager { align-items: center; }
.btn:disabled { opacity: .45; cursor: default; }
::selection { background: var(--accent-soft); color: var(--text); }

@media (max-width: 900px) {
  .filters-toggle { display: inline-flex; margin: .6rem; }
  .filters:not([open]) { background: transparent; border: 0; box-shadow: none; }
  .filters:not([open]) .filters-toggle { margin: 0; }
  .filters-status { margin-left: 0; }
  .dash-grid, .dash-two { grid-template-columns: minmax(0, 1fr); }
  .canvas-box { height: 220px; }
  .chart-tall .canvas-box { height: 300px; }
  .dash-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile-value { font-size: 1.2rem; }
}
@media (prefers-reduced-motion: reduce) { .chip, .tabs button[role="tab"] { transition: none; } }

/* Tablero: exportar */
.fig-tools { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-top: .5rem; }
.fig-tools .fig-data { margin-top: 0; flex: 1; min-width: 0; }
.fig-csv { font-size: .82rem; font-weight: 500; white-space: nowrap; }
.table-tools { display: inline-flex; gap: 1rem; align-items: baseline; flex-wrap: wrap; }
.dash-section .table-head .linkish { font-size: .85rem; }
.print-section { display: none; }

/* Informe (Exportar PDF / Cmd+P): html.printing se pone antes de imprimir,
   así los gráficos se dibujan ya en claro y al ancho de un A4 apaisado
   (297 mm − 24 mm de márgenes ≈ 1030 px). */
html.printing {
  --bg: #ffffff; --surface: #ffffff; --surface-2: #f0f2f5; --border: #dde1e7; --text: #17202b; --muted: #4f5a68;
  --accent: #0f766e; --accent-strong: #0b5c56; --accent-soft: #e2f3f1; --down: #0f7a3c; --up: #b4372a; --ok-bg: #e5f5ea;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100; --series-5: #e87ba4;
  --shadow: none; color-scheme: light;
}
html.printing .page { width: 1030px; max-width: none; }
html.printing .canvas-box, html.printing .chart-tall .canvas-box { height: 200px; }
html.printing .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
html.printing .dash-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
html.printing .tabs, html.printing .filters, html.printing .fig-tools, html.printing .pager,
html.printing [data-goto], html.printing .table-head .linkish, html.printing .th-sort .sort-ind { display: none !important; }
html.printing .print-section { display: block; font-size: 1.25rem; margin: 0 0 .75rem; }

@media print {
  html.printing .page { width: auto; padding: 0; }
  .print-section { break-before: page; }
  .print-section:first-of-type { break-before: auto; }
  .dash-chart, .tile, .dash-lede, .dash-empty { break-inside: avoid; }
  .dash-section h2, .print-section { break-after: avoid; }
  .dash-grid { gap: .5rem; margin-bottom: .75rem; }
  .dash-chart { padding: .5rem .6rem; }
  .fig-title { font-size: 10.5pt; }
  .fig-note, .legend { font-size: 8pt; }
  .dash-tiles { grid-template-columns: repeat(6, 1fr); }
  .tile-sub { font-size: 7.5pt; }
  .th-sort { pointer-events: none; }
  .vs { padding: 0; }
  #print-summary { margin-bottom: .75rem; }
  /* Todas las secciones salen en el informe aunque alguna haya quedado oculta. */
  .tab-panel[hidden] { display: block !important; }
  .print-section { display: block; font-size: 14pt; margin: 0 0 .5rem; }
}
