/* Pantalla de métricas: usa los colores y la barra de dashboard.css. Las series de los gráficos llevan sus propios
   tonos (validados para daltonismo en claro y oscuro); el texto nunca usa el color de una serie. */
:root {
    --series-1: #2A78D6;
    --series-2: #EB6834;
    --grid: #E5E7EB;
    --bar-hover: rgba(17, 24, 39, 0.05);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --series-1: #3987E5;
        --series-2: #D95926;
        --grid: #343943;
        --bar-hover: rgba(255, 255, 255, 0.05);
    }
}

/* Elegido con el botón de tema (theme.js): gana sobre el del sistema. */
:root[data-theme="dark"] {
    --series-1: #3987E5;
    --series-2: #D95926;
    --grid: #343943;
    --bar-hover: rgba(255, 255, 255, 0.05);
}

body.metrics-page { display: block; height: auto; min-height: 100%; }
.metrics-page .brand { text-decoration: none; }

.metrics {
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* KPIs: etiqueta, valor y una línea de contexto. */
.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}
.kpi {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    min-width: 0;
}
.kpi-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.kpi-value { font-size: 26px; font-weight: 600; line-height: 1.2; margin-top: 4px; font-variant-numeric: proportional-nums; }
.kpi-detail { color: var(--muted); font-size: 12px; margin-top: 2px; }

.note {
    margin: 0;
    padding: 8px 12px;
    border-radius: 6px;
    background: var(--in-progress-bg);
    color: var(--in-progress-fg);
}

.chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}
.chart-grid .wide { grid-column: 1 / -1; }
@media (max-width: 900px) {
    .chart-grid { grid-template-columns: minmax(0, 1fr); }
}

.panel {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    padding: 14px 16px;
    min-width: 0;
}
.panel-head { display: flex; align-items: flex-start; gap: 16px; justify-content: space-between; flex-wrap: wrap; }
.panel h2 { font-size: 14px; margin: 0; }
.panel .sub { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.panel .note { margin-top: 10px; }
.panel-subtitle { font-size: 13px; margin: 16px 0 0; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.chart { margin-top: 10px; position: relative; }
.chart svg { display: block; max-width: 100%; overflow: visible; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--border); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover { fill: var(--bar-hover); }
.chart .empty { fill: var(--muted); font-size: 12px; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { stroke: var(--surface); stroke-width: 1.5; }
.chart .reference { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; }
.legend i.dashed { height: 0; border-radius: 0; border-top: 2px dashed var(--muted); }

details { margin-top: 8px; }
details summary { cursor: pointer; color: var(--accent-text); font-size: 12px; font-weight: 600; }

.table-wrap { margin-top: 8px; overflow-x: auto; }
.metric-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.metric-table th {
    padding: 6px 10px;
    background: var(--column);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    text-align: right;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}
.metric-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.metric-table th:first-child, .metric-table td:first-child { text-align: left; }
.metric-table .text { text-align: left; }
.metric-table tbody tr:last-child td { border-bottom: 0; }
.metric-table tbody tr:hover td { background: var(--app-bg); }
.metric-table .muted { color: var(--muted); }
.metric-table .deleted { color: var(--muted); font-style: italic; }
.metric-table .empty-row td { text-align: center; color: var(--muted); padding: 16px; }

/* Tasa de éxito: barra con el color de estado más el número (nunca solo color). */
.rate { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; }
.rate .track { width: 70px; height: 6px; border-radius: 3px; background: var(--not-started-bg); overflow: hidden; }
.rate .fill { height: 100%; border-radius: 3px; background: var(--completed-fg); }
.rate.warn .fill { background: var(--rejected-fg); }
.rate.bad .fill { background: var(--error-fg); }
.rate-icon { font-size: 11px; }

.tooltip {
    position: fixed;
    z-index: 10;
    pointer-events: none;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
    font-size: 12px;
    min-width: 140px;
}
.tooltip .tt-title { font-weight: 600; margin-bottom: 4px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; }
.tooltip .tt-row i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.tooltip .tt-row b { margin-left: auto; font-weight: 600; padding-left: 12px; }

/* Color de la prioridad o de la etiqueta junto a su nombre */
.swatch-label { display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
