/* Dirección editorial: cifras grandes contra etiquetas chicas, blanco y negro, el color solo para avisar. */
:root {
  --bg: #ffffff;
  --ink: #0b0b0b;
  --ink-soft: #3d3d3d;
  --muted: #8a8a8a;
  --rule: #0b0b0b;
  --hairline: #e4e4e4;
  --row-alt: #f7f7f7;
  --bad: #d0021b;
  --warn: #b25e00;
  --good: #1b7a46;
  --font-figure: "Barlow Condensed", "Arial Narrow", sans-serif;
  --font-text: "Montserrat", system-ui, sans-serif;
  --gutter: clamp(16px, 4vw, 48px);
  --radius: 0;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 14px;
  line-height: 1.45;
}

/* Encabezado */
.top {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap;
  padding: 28px var(--gutter) 18px;
  border-bottom: 2px solid var(--rule);
}
.brand-mark {
  display: block; font-size: 11px; font-weight: 700; letter-spacing: .18em; color: var(--bad);
}
.top h1 {
  margin: 2px 0 0; font-family: var(--font-figure); font-weight: 700; font-size: clamp(30px, 5vw, 44px);
  line-height: 1; letter-spacing: -.01em; text-transform: uppercase;
}
.top-meta { display: flex; align-items: center; gap: 14px; }
.updated { font-size: 11px; color: var(--muted); letter-spacing: .04em; }

.btn {
  font: 600 11px/1 var(--font-text); letter-spacing: .12em; text-transform: uppercase;
  background: var(--ink); color: var(--bg); border: 1px solid var(--ink); border-radius: var(--radius);
  padding: 0 16px; min-height: 40px; cursor: pointer;
}
.btn:hover { background: var(--ink-soft); }
.btn:disabled { opacity: .45; cursor: progress; }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { background: var(--row-alt); }

/* Pestañas */
.tabs {
  display: flex; gap: 4px; padding: 0 var(--gutter); border-bottom: 1px solid var(--hairline);
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  font: 600 12px/1 var(--font-text); letter-spacing: .1em; text-transform: uppercase; white-space: nowrap;
  background: none; border: 0; border-bottom: 3px solid transparent; color: var(--muted);
  padding: 18px 12px 15px; min-height: 48px; cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }

/* Periodo */
.toolbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 18px var(--gutter) 0; }
.toolbar-label, .tab-hint { font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.tab-hint { margin: 0; padding: 18px var(--gutter) 0; }
.segmented { display: flex; flex-wrap: wrap; border: 1px solid var(--ink); }
.segmented button {
  font: 500 12px/1 var(--font-text); background: var(--bg); color: var(--ink); border: 0;
  border-right: 1px solid var(--ink); padding: 0 14px; min-height: 40px; cursor: pointer;
}
.segmented button:last-child { border-right: 0; }
.segmented button[aria-checked="true"] { background: var(--ink); color: var(--bg); font-weight: 600; }

/* Secciones */
main { padding: 8px var(--gutter) 64px; }
.section { padding-top: 36px; }
.section + .section { border-top: 1px solid var(--hairline); margin-top: 36px; }
.section-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.section-head h2 {
  margin: 0; font-family: var(--font-figure); font-weight: 700; font-size: 28px; line-height: 1;
  text-transform: uppercase; letter-spacing: .01em;
}
.section-head .sub { font-size: 12px; color: var(--muted); }
.block-title {
  margin: 28px 0 10px; font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
}

/* Cifras */
.stats {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  border-top: 2px solid var(--rule);
}
.stat { padding: 14px 18px 16px 0; border-bottom: 1px solid var(--hairline); }
.stat-label { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); }
.stat-value {
  display: block; margin-top: 6px; font-family: var(--font-figure); font-weight: 600;
  font-size: clamp(44px, 6vw, 64px); line-height: .95; font-variant-numeric: tabular-nums;
}
.stat-value.long { font-size: clamp(30px, 3.4vw, 42px); line-height: 1.05; }
.stat-hint { display: block; margin-top: 6px; font-size: 11px; color: var(--muted); }
.stat.tone-bad .stat-value, .stat.tone-bad .stat-label { color: var(--bad); }
.stat.tone-warn .stat-value { color: var(--warn); }
.stat.tone-good .stat-value { color: var(--good); }

/* Tablas */
.table-wrap { border: 1px solid var(--ink); }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
thead th {
  background: var(--ink); color: var(--bg); font-size: 10px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; text-align: left; padding: 12px 14px;
}
tbody td, tfoot td { padding: 11px 14px; border-top: 1px solid var(--hairline); font-size: 14px; }
tbody tr:nth-child(even) { background: var(--row-alt); }
.num { text-align: right; }
td.num { font-family: var(--font-figure); font-size: 20px; font-weight: 600; }
td a { color: inherit; text-decoration: underline; text-decoration-color: var(--hairline); text-underline-offset: 3px; }
td a:hover { text-decoration-color: var(--ink); }
.tone-bad { color: var(--bad); font-weight: 600; }
.tone-warn { color: var(--warn); font-weight: 600; }
.tone-good { color: var(--good); }
.tone-muted { color: var(--muted); }
.empty { padding: 18px 14px; color: var(--muted); font-size: 13px; }

/* Notas y errores */
.note { margin: 14px 0 0; padding-left: 14px; border-left: 2px solid var(--hairline); font-size: 12px; color: var(--muted); max-width: 72ch; }
.alert { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  border-top: 2px solid var(--bad); padding: 14px 0; }
.alert p { margin: 0; color: var(--bad); font-weight: 600; }

/* Carga */
.sk { background: linear-gradient(90deg, var(--row-alt), var(--hairline), var(--row-alt)); background-size: 200% 100%;
  animation: sk 1.4s ease-in-out infinite; }
.sk-title { height: 28px; width: 220px; margin-bottom: 18px; }
.sk-stat { height: 92px; margin: 14px 18px 0 0; }
.sk-table { height: 180px; margin-top: 28px; }
@keyframes sk { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } }

/* Celular: cada fila de tabla se vuelve tarjeta con su etiqueta */
@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding-right: 12px; }
  .table-wrap { border: 0; }
  thead { display: none; }
  table, tbody, tr, td { display: block; width: 100%; }
  tbody tr { border: 1px solid var(--ink); margin-bottom: 10px; background: var(--bg) !important; }
  tbody td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 8px 12px; text-align: right; }
  tbody td:first-child { background: var(--ink); color: var(--bg); font-weight: 600; text-align: left; border-top: 0; }
  tbody td:first-child a { color: var(--bg); }
  tbody td:not(:first-child)::before {
    content: attr(data-label); font-family: var(--font-text); font-size: 10px; font-weight: 700; letter-spacing: .12em;
    text-transform: uppercase; color: var(--muted); text-align: left;
  }
  td.num { font-size: 18px; }
  .empty { border: 1px solid var(--hairline); }
}
