/* Base: reinicio, tipografía, fondo con textura y utilidades. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 90px; scrollbar-color: var(--linea-2) transparent; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  background: var(--fondo); color: var(--tinta);
  font-family: "Inter", -apple-system, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  font-size: var(--t-m); line-height: 1.5;
  font-optical-sizing: auto; font-feature-settings: "cv11", "ss03";
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  transition: background-color .35s linear, color .35s linear;
  overflow-x: hidden;
}

/* Fondo: dos resplandores muy suaves (oro y granate) y un grano casi invisible, como la luz sobre un tejido. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background:
    radial-gradient(1100px 700px at 12% -10%, var(--resplandor-a), transparent 62%),
    radial-gradient(900px 640px at 105% 110%, var(--resplandor-b), transparent 60%);
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: var(--grano);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
:root[data-theme="light"] body::after { filter: invert(1); }

::selection { background: var(--oro-medio); }
h1, h2, h3, h4, p, ul, ol, dl, dd, figure, blockquote { margin: 0; padding: 0; }
h1, h2, h3, h4 { font-weight: 560; letter-spacing: -.015em; line-height: 1.2; }
ul, ol { list-style: none; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; height: auto; display: block; }
svg { display: block; }
table { border-collapse: collapse; width: 100%; }
[hidden] { display: none !important; }

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

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--linea-2); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* Números siempre alineados */
.num, .kpi__valor, td.num, .cifra { font-variant-numeric: tabular-nums; font-feature-settings: "tnum", "cv11", "ss03"; }

/* Utilidades */
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mute { color: var(--tinta-3); }
.suave { color: var(--tinta-2); }
.oro { color: var(--oro-texto); }
.bien { color: var(--bien); } .ojo { color: var(--ojo); } .mal { color: var(--mal); } .info { color: var(--info); }
.peq { font-size: var(--t-s); } .mpeq { font-size: var(--t-xs); }
.fuerte { font-weight: 600; }
.fila { display: flex; align-items: center; gap: 10px; }
.fila--entre { justify-content: space-between; }
.fila--envuelve { flex-wrap: wrap; }
.pila { display: flex; flex-direction: column; gap: 12px; }
.crece { flex: 1 1 auto; min-width: 0; }
.recorta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mayus { text-transform: uppercase; letter-spacing: .12em; font-size: var(--t-xs); font-weight: 600; }
.centro { text-align: center; }
.der { text-align: right; }

/* Animaciones comunes */
@keyframes aparece { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes aparece-suave { from { opacity: 0; } to { opacity: 1; } }
@keyframes latido { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes gira { to { transform: rotate(360deg); } }
@keyframes brilla { from { background-position: -200% 0; } to { background-position: 200% 0; } }

.entra { animation: aparece .7s var(--suave) both; animation-delay: calc(var(--i, 0) * 60ms); }

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

/* Enlaces con flecha */
.enlace { display: inline-flex; align-items: center; gap: 4px; font-size: var(--t-s); color: var(--oro-texto); font-weight: 550; white-space: nowrap; }
.enlace .icono { width: 15px; height: 15px; transition: transform var(--media) var(--suave); }
.enlace:hover .icono { transform: translateX(3px); }

/* Repintado suave (tras una acción): sin animaciones de entrada */
.vista--suave, .vista--suave .entra, .vista--suave .barras-h__fila, .vista--suave .barras-h__pista i, .vista--suave .tarjeta-mini,
.vista--suave .progreso > i, .vista--suave .tiempo__relleno, .vista--suave .g-donut-arco, .vista--suave .g-medidor-arco { animation: none !important; }
