:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e3e2de;
  --grid: #ebeae6;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #7a7974;
  --accent: #2a78d6;
  --accent-soft: #cde2fb;
  --accent-wash: rgba(42, 120, 214, .10);
  --warn: #b26b00;
  --warn-bg: #fff4dc;
  --good: #0a7a0a;
  --bad: #c03a39;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111110;
    --surface: #1a1a19;
    --surface-2: #232321;
    --border: #2f2f2c;
    --grid: #2a2a28;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --text-3: #8e8d86;
    --accent: #3987e5;
    --accent-soft: #1c3d66;
    --accent-wash: rgba(57, 135, 229, .14);
    --warn: #f0b440;
    --warn-bg: #3a2c0d;
    --good: #3cc23c;
    --bad: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110; --surface: #1a1a19; --surface-2: #232321; --border: #2f2f2c; --grid: #2a2a28;
  --text: #f0efec; --text-2: #c3c2b7; --text-3: #8e8d86; --accent: #3987e5; --accent-soft: #1c3d66;
  --accent-wash: rgba(57, 135, 229, .14); --warn: #f0b440; --warn-bg: #3a2c0d; --good: #3cc23c; --bad: #e66767;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}
.wrap { max-width: 1240px; margin: 0 auto; padding: 20px 16px 60px; }
header.top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 16px; justify-content: space-between; margin-bottom: 14px; }
h1 { font-size: 20px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 2px; font-weight: 600; }
.sub { color: var(--text-2); font-size: 13px; }
.muted { color: var(--text-3); }

.btn {
  font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .55; cursor: default; }

nav.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
nav.tabs button {
  font: inherit; background: none; border: 0; padding: 8px 12px; cursor: pointer; color: var(--text-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
nav.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

.filters { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: end; margin-bottom: 16px; }
.filters label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--text-2); }
.filters select, .filters input, .search {
  font: inherit; font-size: 13px; padding: 5px 8px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); min-width: 0;
}

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.tile .label { font-size: 12px; color: var(--text-2); }
.tile .value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-top: 2px; }
.tile .note { font-size: 12px; color: var(--text-3); }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; min-width: 0; }
.card + .card { margin-top: 0; }
.stack > * + * { margin-top: 12px; }
.chart { width: 100%; position: relative; margin-top: 8px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--text-2); font-size: 12px; }
.chart .val { fill: var(--text); font-weight: 600; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .bar.hl { opacity: .8; }

.tip {
  position: fixed; pointer-events: none; z-index: 20; display: none;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 9px; font-size: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.14); max-width: 280px;
}
.tip b { font-weight: 600; }

.tablewrap { overflow-x: auto; margin-top: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { font-weight: 600; color: var(--text-2); font-size: 12px; cursor: pointer; user-select: none; position: sticky; top: 0; background: var(--surface); }
th.num, td.num { text-align: right; }
th[data-dir="asc"]::after { content: " ▲"; font-size: 9px; }
th[data-dir="desc"]::after { content: " ▼"; font-size: 9px; }
tr:hover td { background: var(--surface-2); }
.inbar { display: inline-block; height: 6px; border-radius: 3px; background: var(--accent); vertical-align: middle; margin-left: 6px; }
.inbar-track { display: inline-block; width: 60px; height: 6px; border-radius: 3px; background: var(--accent-soft); vertical-align: middle; margin-left: 6px; position: relative; }
.inbar-track > span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--accent); }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 1px 7px; border-radius: 999px; }
.badge.revisar { background: var(--warn-bg); color: var(--warn); }
.badge.alta { background: var(--surface-2); color: var(--text-2); }
.badge.previa { background: var(--surface-2); color: var(--text-3); }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }

.drop {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 32px 16px; text-align: center;
  background: var(--surface); color: var(--text-2); cursor: pointer;
}
.drop.over { border-color: var(--accent); background: var(--accent-wash); }
.status { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); font-size: 13px; }
.status.error { color: var(--bad); }
.status.ok { color: var(--good); }
ul.files { margin: 6px 0 0; padding-left: 18px; color: var(--text-2); font-size: 13px; }

.hidden { display: none !important; }
@media (max-width: 600px) {
  .tile .value { font-size: 22px; }
  th, td { padding: 5px 6px; }
}
