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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--t-med) var(--ease), color var(--t-med) var(--ease);
}

h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

img, svg { display: block; }

.num, table, input[type="number"], .kpi-value {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

::selection { background: var(--accent-soft); }

.skip-link {
  position: absolute; left: -9999px; top: 8px; z-index: 100;
  background: var(--surface); padding: 8px 12px; border-radius: var(--r-sm); box-shadow: var(--shadow-md);
}
.skip-link:focus { left: 8px; }

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

.noscript { padding: 24px; text-align: center; }
.load-error {
  position: fixed; inset: 16px 16px auto; z-index: 1000; max-width: 560px; margin: 0 auto;
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 16px;
  border: 1px solid var(--border, #ccc); border-radius: 12px; background: var(--surface, #fff); color: var(--text, #111);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .18); font-size: 14px;
}
.load-error p { flex: 1 1 260px; margin: 0; }
.load-error button { padding: 8px 14px; border-radius: 8px; border: 1px solid currentColor; background: transparent; color: inherit; font: inherit; cursor: pointer; }

.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--text-2); }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }

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

/* Logotipo en línea: los colores salen de los tokens, así cambia con el tema. */
.logo, .logo-symbol { display: block; }
.logo .logo-main, .logo-symbol .logo-main { fill: var(--logo-main); }
.logo .logo-accent, .logo-symbol .logo-accent { fill: var(--logo-accent); }
.logo .logo-word { stroke: var(--logo-main); }

/* Cambio de tema suave (lo activa js/utils/theme.js durante 300 ms). */
html.theme-anim, html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after {
  transition: background-color 220ms var(--ease), color 220ms var(--ease), border-color 220ms var(--ease), fill 220ms var(--ease), stroke 220ms var(--ease), box-shadow 220ms var(--ease) !important;
}
@media (prefers-reduced-motion: reduce) {
  html.theme-anim, html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after { transition: none !important; }
}

