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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-size: var(--fs-m);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; line-height: 1.25; }
h1 { font-size: var(--fs-2xl); letter-spacing: -0.02em; }
h2 { font-size: var(--fs-l); }
h3 { font-size: var(--fs-m); }
p { margin: 0 0 var(--sp-2); }
a { color: var(--acc); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--acc-hover); }
code, kbd, pre { font-family: var(--mono); font-size: 0.92em; }
code { background: var(--soft); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
kbd { background: var(--soft); border: 1px solid var(--bd); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; }
pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--soft); border-radius: var(--radius-s); padding: var(--sp-3); }
hr { border: 0; border-top: 1px solid var(--bd); margin: var(--sp-4) 0; }
small, .small { font-size: var(--fs-s); }
.muted { color: var(--mut); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.center { text-align: center; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* Foco siempre visible: 2 px con 2 px de separación */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}
:focus:not(:focus-visible) { outline: none; }
dialog :focus-visible { outline-offset: 1px; }

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

.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 1000;
  background: var(--btn-bg); color: var(--btn-fg); border: 0; border-radius: var(--radius-m);
  padding: 10px 16px; font-weight: 600;
}
.skip-link:focus { top: 8px; }

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

/* Contraste forzado de Windows: bordes visibles y iconos con colores del sistema */
@media (forced-colors: active) {
  .pill, .kpi, .btn, .input, .chip, .badge, .card, .chip-filter, .seg, .tab { border: 1px solid CanvasText; }
  :focus-visible { outline: 2px solid Highlight; }
}
