:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ink: #1d1b19;
  --muted: #615c55;
  --line: #e2ddd2;
  --accent: #1b4fd8;
  --accent-ink: #ffffff;
  --o: #1b4fd8; --o-bg: #e8eefc;
  --e: #8a5200; --e-bg: #fdeed3;
  --a: #4b4741; --a-bg: #ebe8e1;
  --ok: #0b6b42; --ok-bg: #e2f3ea;
  --step: #6a2fb8; --step-bg: #efe6fb;
  --focus: #1b4fd8;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(30, 25, 15, .05), 0 8px 24px rgba(30, 25, 15, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #13120f; --surface: #1c1a16; --ink: #f1ede4; --muted: #aaa397; --line: #34312b;
    --accent: #86a8ff; --accent-ink: #0a1022;
    --o: #a9c0ff; --o-bg: #1b2850;
    --e: #f2bc66; --e-bg: #3b2b0f;
    --a: #cfcabd; --a-bg: #2a2823;
    --ok: #5fd8a0; --ok-bg: #123122;
    --step: #c9a8ff; --step-bg: #2a1d45;
    --focus: #86a8ff;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.wrap { width: min(1100px, 100% - 32px); margin-inline: auto; }
.skip { position: absolute; left: 12px; top: -48px; background: var(--ink); color: var(--bg); padding: 8px 12px; border-radius: 8px; z-index: 20; }
.skip:focus { top: 12px; }

/* Cabecera */
.hero { padding: 44px 0 28px; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 10px; font-size: 13px; letter-spacing: .12em; font-weight: 700; color: var(--accent); }
h1 { margin: 0; font-size: clamp(28px, 4.6vw, 44px); line-height: 1.08; letter-spacing: -.02em; max-width: 24ch; text-wrap: balance; }
.lede { margin: 14px 0 0; max-width: 62ch; color: var(--muted); font-size: 18px; }
.stats { display: flex; flex-wrap: wrap; gap: 10px 32px; margin: 26px 0 0; }
.stats div { min-width: 0; }
.stats dt { font-size: 13px; color: var(--muted); }
.stats dd { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }

/* Filtros */
.filters {
  position: sticky; top: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 14px 16px; align-items: end;
  margin: 24px 0 8px; padding: 16px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; border: 0; padding: 0; margin: 0; }
.field > label, .field > legend { font-size: 13px; font-weight: 600; color: var(--muted); padding: 0; }
select {
  width: 100%; height: 44px; padding: 0 38px 0 12px; font: inherit; color: var(--ink);
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='M1 1l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 14px center;
  border: 1px solid var(--line); border-radius: 10px; appearance: none; -webkit-appearance: none; text-overflow: ellipsis;
}
select:hover { border-color: var(--muted); }
.segmented { display: flex; height: 44px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.segmented label { flex: 1; display: flex; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { flex: 1; display: flex; align-items: center; justify-content: center; padding: 0 10px; border-radius: 7px; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; }
.segmented span i { font-style: normal; font-weight: 500; opacity: .75; margin-left: 4px; font-variant-numeric: tabular-nums; }
.segmented input:checked + span { background: var(--accent); color: var(--accent-ink); }
.segmented input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.row-end { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; gap: 16px; padding-top: 2px; }
.check { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
button.link { background: none; border: 0; padding: 6px 4px; font: inherit; font-size: 14px; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* Resultados */
.results-head { margin: 26px 0 10px; }
.results-head h2 { margin: 0; font-size: 22px; letter-spacing: -.01em; }
.note { margin: 6px 0 0; color: var(--muted); font-size: 14px; max-width: 80ch; }
.year { display: flex; align-items: baseline; gap: 12px; margin: 30px 0 10px; }
.year h3 { margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.year span { color: var(--muted); font-size: 14px; }
.row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 20px; align-items: center;
  padding: 14px 16px; margin-bottom: 8px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.row h4 { margin: 0; font-size: 17px; line-height: 1.3; }
.row h4 small { display: block; margin-top: 2px; font-size: 13px; font-weight: 400; color: var(--muted); }
.meta { margin: 6px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 14px; color: var(--muted); }
.meta a { color: var(--muted); }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.chip.o { color: var(--o); background: var(--o-bg); }
.chip.e { color: var(--e); background: var(--e-bg); }
.chip.a { color: var(--a); background: var(--a-bg); }
.acts { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn[hidden] { display: none; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.sol { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
.btn.ghost { color: var(--muted); font-weight: 500; }
.btn.step { color: var(--step); background: var(--step-bg); border-color: transparent; }
.btn .tag { font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 1px 6px; border-radius: 5px; background: rgba(127, 127, 127, .22); }
.more { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }
.more summary { cursor: pointer; width: fit-content; }
.more ul { margin: 8px 0 0; padding-left: 18px; }
.more li { margin: 3px 0; }
.more-wrap { display: grid; place-items: center; margin: 18px 0 0; }
.empty { padding: 36px 20px; text-align: center; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 18px; margin-bottom: 6px; }
.empty .btn { margin-top: 14px; }

.nosol { align-self: center; padding: 0 6px; font-size: 13px; color: var(--muted); }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; font-size: 13px; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-align: left; }

/* Visor de documentos */
dialog#viewer { width: min(1200px, 96vw); height: 92vh; max-width: none; max-height: none; padding: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); overflow: hidden; }
dialog#viewer[open] { display: flex; flex-direction: column; }
dialog#viewer::backdrop { background: rgba(8, 8, 8, .62); }
body:has(dialog#viewer[open]) { overflow: hidden; }
.v-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px 16px 4px; }
.v-info { min-width: 0; }
.v-head h2 { margin: 0; font-size: 18px; line-height: 1.3; overflow-wrap: anywhere; }
.v-head p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.v-bar { display: flex; flex-wrap: wrap; gap: 8px 12px; justify-content: space-between; align-items: center; padding: 8px 16px 12px; border-bottom: 1px solid var(--line); }
.v-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.v-tabs button { min-height: 34px; padding: 0 12px; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.v-tabs button[aria-selected="true"] { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.v-tabs select { max-width: min(560px, 100%); height: 38px; font-size: 14px; }
.v-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.v-actions .btn, .v-head .btn { min-height: 36px; }
.v-actions [hidden] { display: none; }
.v-body { flex: 1; min-height: 0; background: var(--bg); }
.v-body iframe { display: block; width: 100%; height: 100%; border: 0; }

/* Cobertura */
.coverage { margin: 56px 0 24px; }
.coverage h2 { margin: 0; font-size: 22px; letter-spacing: -.01em; }
.table-wrap { margin-top: 16px; overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 900px; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
th { font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
tbody th { font-size: 14px; letter-spacing: 0; text-transform: none; color: var(--ink); font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
td { white-space: nowrap; }
td.obs { white-space: normal; min-width: 300px; max-width: 460px; font-size: 13px; color: var(--muted); }
.badge { display: inline-block; white-space: nowrap; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--a-bg); }
.foot { padding: 12px 0 48px; color: var(--muted); font-size: 13px; }

@media (max-width: 860px) {
  .filters { position: static; grid-template-columns: 1fr 1fr; }
  .filters .seg { grid-column: 1 / -1; }
}
@media (max-width: 620px) {
  dialog#viewer { width: 100vw; height: 100dvh; border-radius: 0; border: 0; }
  .v-actions .btn { flex: 1 1 auto; justify-content: center; }
  .hero { padding-top: 30px; }
  .filters { grid-template-columns: 1fr; padding: 14px; }
  .row-end { flex-wrap: wrap; }
  .row { grid-template-columns: 1fr; }
  .acts { justify-content: flex-start; }
  .btn { flex: 1 1 auto; justify-content: center; }
  .segmented span { padding: 0 6px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
