:root {
  color-scheme: dark;
  --surface-0: #0d0d0d;
  --surface-1: #1a1a19;
  --surface-2: #232321;
  --surface-3: #2c2c2a;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid-line: #333330;
  --baseline: #46453f;
  --border: rgba(255,255,255,0.10);

  /* Categorical (dataviz skill, paso oscuro validado — orden fijo, no ciclar).
     Slot 1 se sustituyó por el naranja de marca de Extrum (#e86200, tomado
     directo del logo) — es una permutación del mismo trío ya validado
     todos-contra-todos (azul/naranja/aqua), no una paleta nueva. Slot "otros"
     se sustituyó por el gris de marca de Extrum (#747b89, también del logo). */
  --series-1: #e86200; /* naranja Extrum — kg/h, Utilización, acento primario */
  --series-2: #3987e5; /* azul   — Fallos Mecánicos */
  --series-3: #199e70; /* aqua    — Fallos Operativos */
  --series-4: #c98500; /* amarillo — reservado */
  --series-other: #747b89; /* gris Extrum — "Otros" (residual, no es serie) */
  --brand-gray: #747b89; /* gris de marca Extrum, para texto/acentos de identidad */

  /* Estado (paleta reservada — nunca se reusa como color de serie) */
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #e66767;

  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  background: var(--surface-0);
  color: var(--text-primary);
  font-variant-numeric: proportional-nums;
}

header {
  background: var(--surface-1);
  border-bottom: 1px solid var(--grid-line);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
header h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
header .subtitle { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px; background: var(--series-1); color: #fff;
  font-weight: 800; font-size: 17px; display: flex; align-items: center; justify-content: center;
  flex: none; font-style: italic; letter-spacing: -0.02em;
}
.brand-accent { color: var(--series-1); }

#authArea { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-secondary); }
button {
  font-family: inherit; font-size: 13px; border: none; border-radius: var(--radius-sm);
  padding: 9px 15px; cursor: pointer; background: var(--series-1); color: white;
}
button.secondary { background: var(--surface-2); color: var(--text-primary); border: 1px solid var(--grid-line); }
button.ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--grid-line); padding: 6px 12px; font-size: 12px; }

.filter-bar { background: var(--surface-1); border-bottom: 1px solid var(--grid-line); padding: 12px 28px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-bar .filter-label { font-size: 12px; color: var(--text-muted); margin-right: 6px; text-transform: uppercase; letter-spacing: .04em; }
.press-tab {
  font-family: inherit; font-size: 14.5px; font-weight: 600; border: 1px solid var(--grid-line); background: var(--surface-2);
  color: var(--text-secondary); border-radius: 999px; padding: 8px 18px; cursor: pointer;
}
.press-tab.active { background: var(--series-1); color: #fff; border-color: var(--series-1); }

.month-select {
  font-family: inherit; font-size: 13.5px; font-weight: 600; border: 1px solid var(--grid-line);
  background: var(--surface-2); color: var(--text-primary); border-radius: 999px; padding: 7px 14px; cursor: pointer;
}
.month-select:focus { outline: 1.5px solid var(--series-1); }

main { max-width: 1280px; margin: 0 auto; padding: 22px 28px 60px; }
.period-note { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }
.period-note strong { color: var(--text-secondary); }

.upload-box {
  background: var(--surface-1); border: 1.5px dashed var(--grid-line); border-radius: var(--radius);
  padding: 20px; text-align: center; margin-bottom: 24px;
}
.upload-box p { color: var(--text-secondary); font-size: 12.5px; margin: 5px 0 12px; }

/* --- Vista "Todas": tabla comparativa --- */
.compare-table { width: 100%; border-collapse: separate; border-spacing: 0 8px; }
.compare-table th { text-align: left; font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; padding: 0 14px 4px; }
.compare-table th.press-col { text-align: center; }
.compare-table td { padding: 14px; border-top: 1px solid var(--grid-line); border-bottom: 1px solid var(--grid-line); }
.compare-table td:first-child { background: var(--surface-1); border-left: 1px solid var(--grid-line); border-radius: 10px 0 0 10px; color: var(--text-secondary); font-size: 13.5px; font-weight: 600; }
.compare-table td:last-child { border-right: 1px solid var(--grid-line); border-radius: 0 10px 10px 0; }
.compare-cell { text-align: center; }
.compare-cell .cval { font-size: 22px; font-weight: 700; }
.compare-cell .cdelta { font-size: 10.5px; margin-top: 3px; }
.cell-good { background: rgba(12,163,12,0.14); }
.cell-warning { background: rgba(250,178,25,0.12); }
.cell-critical { background: rgba(230,103,103,0.14); }
.tgood { color: #4ade4a; } .twarning { color: var(--status-warning); } .tcritical { color: #ff8a8a; }
.overview-hint { font-size: 12.5px; color: var(--text-muted); margin-top: 14px; text-align: center; }

.util-mini-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 22px; }
.util-mini-card { background: var(--surface-1); border-radius: var(--radius-sm); padding: 14px 16px; border: 1px solid var(--grid-line); }
.util-mini-card h4 { font-size: 12.5px; margin: 0 0 8px; color: var(--text-secondary); font-weight: 600; }

/* --- Vista detalle de prensa --- */
.press-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.press-head h2 { font-size: 24px; margin: 0; }
.press-head .updated { font-size: 12px; color: var(--text-muted); }

.kpi-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 20px; }
@media (max-width: 1100px) { .kpi-row { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }

.kpi-tile {
  background: var(--surface-1); border-radius: var(--radius-sm); padding: 14px 14px 12px; cursor: pointer;
  border: 1.5px solid var(--grid-line); transition: border-color .15s;
}
.kpi-tile:hover { border-color: var(--series-1); }
.kpi-tile.active { border-color: var(--series-1); background: var(--surface-2); }
.kpi-tile .label { font-size: 11.5px; color: var(--text-secondary); font-weight: 600; }
.kpi-tile .value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.kpi-tile .value.na { color: var(--text-muted); font-weight: 400; font-size: 15px; }
.kpi-tile .delta { font-size: 11px; margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.kpi-tile .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.dgood { background: var(--status-good); } .dwarning { background: var(--status-warning); } .dcritical { background: var(--status-critical); }

.detail-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; margin-bottom: 20px; }
@media (max-width: 950px) { .detail-grid { grid-template-columns: 1fr; } }

.chart-card { background: var(--surface-1); border-radius: var(--radius); border: 1px solid var(--grid-line); padding: 18px 20px; }
.chart-card h3 { font-size: 14px; margin: 0 0 2px; display: inline; }
.chart-card .chart-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chart-card .chart-sub { font-size: 11.5px; color: var(--text-muted); margin-bottom: 12px; margin-top: 2px; }
.chart-empty { color: var(--text-muted); font-size: 12.5px; padding: 30px 0; text-align: center; }
.turno-filter-chip {
  font-family: inherit; font-size: 11px; font-weight: 600; border: 1px solid var(--series-1); background: rgba(232,98,0,0.14);
  color: var(--series-1); border-radius: 999px; padding: 3px 10px; cursor: pointer;
}
.chart-hint { font-size: 11px; color: var(--text-muted); margin-top: 8px; font-style: italic; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11px; color: var(--text-secondary); margin-top: 10px; }
.chart-legend span { display: flex; align-items: center; gap: 5px; }
.chart-legend .sw { width: 9px; height: 9px; border-radius: 2px; }

.util-section { margin-bottom: 20px; }
.util-breakdown .stack-bar { display: flex; height: 30px; border-radius: 6px; overflow: hidden; border: 1px solid var(--border); }
.util-breakdown .seg { height: 100%; }
.util-breakdown .seg.util { background: var(--series-1); } .util-breakdown .seg.mecanico { background: var(--series-2); }
.util-breakdown .seg.operativo { background: var(--series-3); } .util-breakdown .seg.otros { background: var(--series-other); }
.util-breakdown .stack-gap { width: 2px; background: var(--surface-1); }
.util-legend { display: flex; flex-wrap: wrap; gap: 12px 20px; margin-top: 10px; font-size: 12px; color: var(--text-secondary); }
.util-legend span { display: flex; align-items: center; gap: 6px; }
.util-legend .sw { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.util-legend .sw.util { background: var(--series-1); } .util-legend .sw.mecanico { background: var(--series-2); }
.util-legend .sw.operativo { background: var(--series-3); } .util-legend .sw.otros { background: var(--series-other); }

.metas-panel { background: var(--surface-1); border-radius: var(--radius); border: 1px solid var(--grid-line); padding: 16px 18px; margin-top: 4px; display: none; }
.metas-panel.open { display: block; }
.metas-panel h3 { font-size: 13px; margin: 0 0 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .03em; }
.metas-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 14px; }
.metas-grid label { font-size: 11px; color: var(--text-secondary); display: block; margin-bottom: 3px; }
.metas-grid input { width: 100%; font-family: inherit; font-size: 13px; padding: 7px 9px; border: 1px solid var(--grid-line); border-radius: 6px; background: var(--surface-2); color: var(--text-primary); }
.metas-panel .metas-actions { margin-top: 12px; display: flex; gap: 8px; align-items: center; }
.metas-panel .saved-note { font-size: 11px; color: #4ade4a; }

.uploads-log { background: var(--surface-1); border-radius: var(--radius); border: 1px solid var(--grid-line); padding: 16px 20px; margin-top: 20px; }
.uploads-log h2 { font-size: 14px; margin: 0 0 10px; }
.upload-item { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--grid-line); font-size: 12.5px; }
.upload-item:last-child { border-bottom: none; }
.upload-item .estado { font-weight: 600; }
.estado.completado { color: #4ade4a; }
.estado.procesando { color: var(--status-warning); }
.estado.error { color: var(--status-critical); }

svg.barchart text { fill: var(--text-muted); font-size: 10px; font-family: system-ui, sans-serif; }
svg.barchart .meta-line { stroke: var(--text-secondary); stroke-width: 1; stroke-dasharray: 3 3; }
svg.barchart .meta-label { fill: var(--text-secondary); font-size: 10px; font-weight: 600; paint-order: stroke; stroke: var(--surface-1); stroke-width: 3px; stroke-linejoin: round; }
svg.barchart .gridline { stroke: var(--grid-line); stroke-width: 1; }
svg.barchart rect.bar { rx: 3; }
svg.barchart text.bar-value { fill: var(--text-primary); font-size: 11px; font-weight: 600; paint-order: stroke; stroke: var(--surface-1); stroke-width: 3px; stroke-linejoin: round; }
svg.barchart text.axis-label { fill: var(--text-muted); }
svg.barchart rect.bar-selectable { cursor: pointer; }
svg.barchart rect.bar-selectable:hover { opacity: 0.82; }
svg.barchart rect.bar-active { stroke: #ffffff; stroke-width: 2px; }

.hidden { display: none !important; }
