:root {
  color-scheme: light;
  --page: #f9f9f7; --surface: #fcfcfb; --surface-2: #f0efec;
  --text: #0b0b0b; --text-2: #52514e; --muted: #898781;
  --grid: #e1e0d9; --axis: #c3c2b7; --border: rgba(11, 11, 11, 0.10);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --good: #006300; --bad: #d03b3b; --warn: #fab219; --accent: #2a78d6;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #262624;
    --text: #f0efec; --text-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --good: #0ca30c; --bad: #e66767; --accent: #3987e5;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 16px 48px; }

header.top { position: sticky; top: 0; z-index: 5; background: var(--page); border-bottom: 1px solid var(--border); }
.top .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding-top: 10px; padding-bottom: 10px; }
.brand { font-size: 17px; font-weight: 700; margin-right: 8px; }
nav.tabs { display: flex; gap: 2px; flex-wrap: wrap; }
nav.tabs button, .seg button, .btn { border: 1px solid transparent; background: none; padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--text-2); }
nav.tabs button:hover, .seg button:hover, .btn:hover { background: var(--surface-2); }
nav.tabs button[aria-selected="true"], .seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); font-weight: 600; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; padding: 2px; }
.btn { border-color: var(--border); color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.small { padding: 2px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.spacer { flex: 1; }
.sync { font-size: 12px; color: var(--muted); }

.grid { display: grid; gap: 16px; margin-top: 16px; }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g2 { grid-template-columns: 2fr 1fr; }
@media (max-width: 960px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g3, .g2 { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; min-width: 0; }
.card > h2 { margin-bottom: 10px; }
.kpi .v { font-size: 26px; font-weight: 700; margin-top: 4px; }
.kpi .s, .hint { font-size: 12px; color: var(--muted); }
.neg { color: var(--bad); } .pos { color: var(--good); }

.tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
@media (max-width: 960px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
.tile { background: var(--surface-2); border-radius: 10px; padding: 10px; }
.tile .l { font-size: 12px; color: var(--text-2); }
.tile .v { font-size: 17px; font-weight: 700; }
.tile .d { font-size: 11px; color: var(--muted); }
.hero { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.hero .v { font-size: 34px; font-weight: 700; }

.row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); }
.row:first-of-type { border-top: 0; }
.row .n { flex: 1; min-width: 0; }
.row .n b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .n span { font-size: 12px; color: var(--muted); }
.row .a { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.meter { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin: 6px 0; }
.meter i { display: block; height: 100%; background: var(--s1); border-radius: 4px; }
.meter i.over { background: var(--bad); }

/* Gráfico de barras */
.chart { position: relative; height: 240px; margin: 8px 0 4px 56px; }
.chart .gl { position: absolute; left: 0; right: 0; border-top: 1px solid var(--grid); }
.chart .gl span { position: absolute; right: 100%; margin-right: 8px; top: -8px; font-size: 11px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chart .cols { position: absolute; inset: 0 0 22px 0; display: flex; align-items: flex-end; border-bottom: 1px solid var(--axis); }
.chart .col { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; position: relative; min-width: 0; }
.chart .col:hover { background: var(--surface-2); }
.chart .col.prev .stack { opacity: .55; }
.chart .stack { width: 42%; max-width: 26px; display: flex; flex-direction: column-reverse; gap: 2px; }
.chart .one .stack { width: 70%; }
.chart .stack i { display: block; min-height: 0; }
.chart .stack i:last-child { border-radius: 4px 4px 0 0; }
.chart .xl { position: absolute; top: 100%; margin-top: 5px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.chart .col.now .xl { color: var(--text); font-weight: 700; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12px; color: var(--text-2); margin-left: 56px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
#tip { position: fixed; z-index: 20; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: 12px; box-shadow: 0 6px 24px rgba(0, 0, 0, .25); display: none; max-width: 280px; }
#tip b { display: block; margin-bottom: 4px; }
#tip div { display: flex; justify-content: space-between; gap: 16px; }
#tip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }

.hbar { display: grid; grid-template-columns: minmax(90px, 34%) 1fr auto; gap: 10px; align-items: center; padding: 4px 0; font-size: 13px; }
.hbar .b { height: 10px; background: var(--s1); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar .v { font-variant-numeric: tabular-nums; color: var(--text-2); }

.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 7px 10px; border-top: 1px solid var(--border); white-space: nowrap; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-top: 0; font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrapcell { white-space: normal; min-width: 180px; }
tr.now td { background: var(--surface-2); }
tr.sub td { color: var(--text-2); }
tr.total td { font-weight: 700; border-top: 2px solid var(--axis); }
td.click { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
td input.cell { width: 96px; text-align: right; background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 3px 6px; font-variant-numeric: tabular-nums; }
td input.cell:hover, td input.cell:focus { border-color: var(--axis); background: var(--page); outline: none; }
td input.cell.aj { font-weight: 700; color: var(--accent); }
td input.name { width: 200px; text-align: left; }
td input.day { width: 48px; }
select, input[type="text"], input[type="search"], input[type="number"], input[type="password"], input[type="month"] { background: var(--page); border: 1px solid var(--axis); border-radius: 8px; padding: 6px 8px; }
td select { padding: 3px 4px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.empty { color: var(--muted); padding: 16px 0; }
.note { font-size: 12px; color: var(--muted); margin-top: 10px; max-width: 80ch; }
[hidden] { display: none !important; }

.login { max-width: 340px; margin: 18vh auto; }
.login form { display: grid; gap: 10px; margin-top: 12px; }
.err { color: var(--bad); font-size: 13px; min-height: 18px; }
