/* ════════════════════════════════════════════════════════════
   TroubleShooting · Historial de servicios (.sh-*)
   Pestaña de la consola de autoría: troubleshooting_history.js.
   Solo tokens de tokens.css: sirve tal cual a los tres temas.
   ════════════════════════════════════════════════════════════ */

.sh-ic { vertical-align: -2px; flex: none; }

/* ── Pestañas internas ── */
.sh-tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin: -4px 0 16px; }
.sh-tab { border: 0; background: none; padding: 9px 14px; font: 600 13.5px/1 var(--ui); color: var(--text-3); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; border-radius: var(--r-sm) var(--r-sm) 0 0; }
.sh-tab:hover { color: var(--text); background: var(--surface-2); }
.sh-tab.is-active { color: var(--heading); border-bottom-color: var(--accent); }
.sh-tab:focus-visible, .sh-drop:focus-visible, .sh-table tr:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sh-sub { font-size: 12px; color: var(--text-3); }
.sh-warn { color: var(--warn); }
.sh-mono { font-family: var(--mono); font-size: 12px; }
.sh-nowrap { white-space: nowrap; }
.sh-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sh-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.sh-count { font-size: 13px; color: var(--text-2); margin: 10px 0 8px; }
.sh-loading { text-align: center; color: var(--text-3); padding: 22px !important; }

/* ── Filtros ── */
.sh-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.sh-in { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: var(--r-sm); padding: 8px 10px; font: 400 13px/1.2 var(--ui); min-width: 0; }
.sh-in--q { flex: 1 1 260px; }
.sh-in:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.sh-check { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--text-2); cursor: pointer; }

/* ── Tabla ── */
.sh-tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.sh-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.sh-table th { text-align: left; font: 600 12px/1.2 var(--ui); color: var(--text-3); background: var(--surface-2); padding: 9px 12px; white-space: nowrap; border-bottom: 1px solid var(--border); }
.sh-table th.sh-num { text-align: right; }
.sh-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: top; }
.sh-table tbody tr:last-child td { border-bottom: 0; }
.sh-table tbody tr[data-id] { cursor: pointer; }
.sh-table tbody tr[data-id]:hover { background: var(--surface-2); }
.sh-desc { min-width: 280px; max-width: 520px; }
.sh-desc > div:last-child { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.sh-problem { font-weight: 600; color: var(--text-2); margin-bottom: 2px; }
.sh-table .ts-chip { margin: 1px 0; white-space: nowrap; }
.sh-pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 14px 0; }

.sh-type { display: inline-block; font: 700 11px/1 var(--mono); padding: 4px 7px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); letter-spacing: .02em; }
.sh-type--SCNP { color: var(--danger); border-color: var(--danger-bd); background: var(--danger-bg); }
.sh-type--SPREV { color: var(--ok); border-color: var(--ok-bd); background: var(--ok-bg); }
.sh-flag { display: inline-block; font: 600 10.5px/1 var(--ui); padding: 3px 6px; border-radius: 999px; background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border); vertical-align: 1px; }
.sh-flag--warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-bd); }

/* ── Detalle de un parte ── */
.sh-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.sh-detail h4 { margin: 0 0 10px; font: 700 13.5px/1.3 var(--ui); color: var(--heading); }
.sh-detail dl { margin: 0; }
.sh-kv { display: grid; grid-template-columns: 150px 1fr; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.sh-kv dt { color: var(--text-3); }
.sh-kv dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.sh-kv--long { grid-template-columns: 1fr; gap: 4px; }
.sh-kv--long dd { white-space: pre-line; }
.sh-crit--critica { color: var(--danger); border-color: var(--danger-bd); background: var(--danger-bg); }
.sh-crit--alta { color: var(--warn); border-color: var(--warn-bd); background: var(--warn-bg); }

/* ── Cargar Excel ── */
.sh-drop { border: 2px dashed var(--border); border-radius: var(--r-lg); background: var(--surface); padding: 30px 18px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.sh-drop:hover, .sh-drop.is-over { border-color: var(--accent); background: var(--surface-2); }
.sh-drop.has-file { border-style: solid; }
.sh-drop__ic { color: var(--text-3); margin-bottom: 6px; }
.sh-drop__t { font: 600 15px/1.3 var(--ui); color: var(--heading); }
.sh-drop__s { font-size: 12.5px; color: var(--text-3); margin-top: 3px; }
.sh-drop__f { font: 600 13px/1.3 var(--ui); color: var(--text); margin-top: 10px; overflow-wrap: anywhere; }
.sh-report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin: 14px 0; }
.sh-report-grid h4 { margin: 0 0 8px; font: 700 13px/1.3 var(--ui); color: var(--heading); }
.sh-q { display: grid; grid-template-columns: minmax(120px, 1.3fr) 1fr 64px 46px; gap: 10px; align-items: center; font-size: 12.5px; color: var(--text-2); padding: 4px 0; }
.sh-q__bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.sh-q__bar i { display: block; height: 100%; background: var(--blue); border-radius: 999px; min-width: 2px; }
.sh-q b { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
.sh-q em { text-align: right; font-style: normal; color: var(--text-3); font-variant-numeric: tabular-nums; }

@media (max-width: 760px) {
    .sh-detail, .sh-report-grid { grid-template-columns: 1fr; gap: 16px; }
    .sh-kv { grid-template-columns: 112px 1fr; }
    .sh-filters .sh-in { flex: 1 1 140px; }
    .sh-tabs { flex-wrap: nowrap; overflow-x: auto; }
    .sh-tab { white-space: nowrap; }
}

/* ── Preguntas (el banco) ── */
.sh-bank { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.sh-bank__list { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); padding: 10px; max-height: calc(100vh - 250px); overflow-y: auto; position: sticky; top: 8px; }
.sh-bank__list .sh-in { width: 100%; margin-bottom: 6px; }
.sh-bank__cat { font: 700 11px/1.2 var(--ui); letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); padding: 12px 8px 5px; }
.sh-bank__q { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 8px; border-radius: var(--r-sm); font: 400 13px/1.35 var(--ui); color: var(--text); cursor: pointer; }
.sh-bank__q:hover { background: var(--surface-2); }
.sh-bank__q.is-active { background: var(--surface-2); color: var(--heading); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.sh-bank__q:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.sh-param { display: flex; flex-direction: column; gap: 3px; font: 600 11.5px/1.2 var(--ui); color: var(--text-3); }
.sh-ans { margin-top: 14px; }
.sh-ans__t { margin: 0 0 6px; font: 700 16px/1.3 var(--ui); color: var(--heading); }
.sh-ans__s { font: 400 13px/1.3 var(--ui); color: var(--text-3); margin-left: 6px; }
.sh-ans__lead { margin: 0 0 12px; font-size: 14px; color: var(--text); }
.sh-ans__notes { font-size: 12px; line-height: 1.5; color: var(--text-3); margin: 10px 0 0; }
.sh-table--ans td, .sh-table--ans th { padding: 7px 12px; }
.sh-more { margin-top: 6px; }
.sh-chart:empty { display: none; }
.sh-chart { margin: 0 0 14px; }
/* Al dibujar se le pone .sh-viz ANTES de medir: oculto mediría 0 de ancho. */
.sh-chart.sh-viz { display: block; }
@media (max-width: 900px) {
    .sh-bank { grid-template-columns: 1fr; }
    .sh-bank__list { position: static; max-height: 260px; }
}

/* ── Gráficos (troubleshooting_history_charts.js) ──
   Colores de serie y rampa de un solo tono, validados contra las tres superficies del portal
   (clara, oscura y oscura «puerto») para daltonismo y contraste. El texto usa los tokens de
   texto de la app, nunca el color de la serie. */
.sh-viz, .sh-legend {
    --vz-1: #2a78d6; --vz-2: #eb6834; --vz-3: #1baf7a; --vz-4: #eda100; --vz-5: #e87ba4; --vz-6: #008300;
    --vz-soft: #9ec5f4; --vz-wash: rgba(42, 120, 214, .10); --vz-grid: #e1e0d9; --vz-axis: #c3c2b7;
    --vz-h0: var(--surface-2); --vz-h1: #cde2fb; --vz-h2: #9ec5f4; --vz-h3: #6da7ec; --vz-h4: #3987e5;
    --vz-h5: #256abf; --vz-h6: #184f95; --vz-h7: #0d366b;
}
[data-theme="dark"] .sh-viz, [data-theme="dark"] .sh-legend {
    --vz-1: #3987e5; --vz-2: #d95926; --vz-3: #199e70; --vz-4: #c98500; --vz-5: #d55181; --vz-6: #008300;
    --vz-soft: #184f95; --vz-wash: rgba(57, 135, 229, .14); --vz-grid: #2c2c2a; --vz-axis: #383835;
    /* En oscuro la rampa va al revés: lo más intenso es lo más claro. */
    --vz-h1: #0d366b; --vz-h2: #184f95; --vz-h3: #256abf; --vz-h4: #3987e5; --vz-h5: #6da7ec; --vz-h6: #9ec5f4; --vz-h7: #cde2fb;
}
.sh-svg { display: block; max-width: none; overflow: visible; }
.sh-svg__lab { font: 400 12px/1 var(--ui); fill: var(--text-2); }
.sh-svg__val { font: 600 12px/1 var(--ui); fill: var(--text); font-variant-numeric: tabular-nums; }
.sh-svg__tick { font: 400 11px/1 var(--ui); fill: var(--text-3); font-variant-numeric: tabular-nums; }
.sh-svg__grid { stroke: var(--vz-grid); stroke-width: 1; }
.sh-svg__axis, .sh-svg__cross { stroke: var(--vz-axis); stroke-width: 1; }
.sh-hit { fill: transparent; cursor: default; }
.sh-cell { cursor: default; }
.sh-viz__scroll { overflow-x: auto; }
.sh-viz__more { font-size: 11.5px; color: var(--text-3); padding: 2px 0 0 4px; }
.sh-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.sh-legend span { display: inline-flex; align-items: center; gap: 6px; }
.sh-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sh-legend--ramp { gap: 2px; align-items: center; }
.sh-legend--ramp i { width: 18px; border-radius: 2px; }
.sh-legend--ramp span { margin: 0 5px; color: var(--text-3); }
.sh-tip { position: fixed; z-index: var(--z-float); display: none; pointer-events: none; background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--r-sm); box-shadow: var(--shadow-md); padding: 8px 10px; font: 400 12px/1.45 var(--ui); max-width: 300px; }
.sh-tip b { display: block; margin-bottom: 3px; color: var(--heading); }
.sh-tip div { display: flex; justify-content: space-between; gap: 16px; }
.sh-tip span { color: var(--text-3); }
.sh-tip i { font-style: normal; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ── Resumen ── */
.sh-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.sh-tile { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); padding: 14px 16px; box-shadow: var(--shadow-sm); }
.sh-tile__l { font: 600 12px/1.2 var(--ui); color: var(--text-3); }
.sh-tile__v { font: 700 26px/1.2 var(--ui); color: var(--heading); margin: 4px 0 2px; }
.sh-tile__s { font-size: 11.5px; line-height: 1.35; color: var(--text-3); }
.sh-switch { display: flex; gap: 10px; align-items: flex-start; margin: 14px 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); font-size: 12.5px; line-height: 1.45; color: var(--text-2); cursor: pointer; }
.sh-switch input { margin-top: 3px; width: 16px; height: 16px; flex: none; }
.sh-switch b { color: var(--text); font-size: 13.5px; }
.sh-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.sh-card { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); padding: 16px; box-shadow: var(--shadow-sm); min-width: 0; }
.sh-card--wide { grid-column: 1 / -1; }
.sh-card h4 { margin: 0 0 4px; font: 700 14.5px/1.3 var(--ui); color: var(--heading); }
.sh-card__lead { margin: 0 0 12px; font-size: 12.5px; line-height: 1.45; color: var(--text-2); }
.sh-card__notes { margin: 10px 0 0; font-size: 11.5px; line-height: 1.45; color: var(--text-3); }
.sh-card__notes:empty { display: none; }
.sh-card__link { margin-top: 8px; border: 0; background: none; padding: 0; font: 600 12.5px/1 var(--ui); color: var(--blue-bright); cursor: pointer; }
.sh-card__link:hover { text-decoration: underline; }
.sh-card .sh-chart { margin: 0; }
@media (max-width: 900px) {
    .sh-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sh-cards { grid-template-columns: 1fr; }
}
