/* Telemetry Pilot 1.4.0 — Históricos avanzados */
.history-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin: 26px 0 18px;
  padding: 26px;
  border: 1px solid rgba(49, 215, 255, 0.25);
  border-radius: 24px;
  background:
    radial-gradient(circle at 88% 10%, rgba(115, 191, 255, 0.15), transparent 34%),
    linear-gradient(135deg, rgba(8, 29, 48, 0.96), rgba(4, 17, 31, 0.92));
  box-shadow: 0 22px 55px rgba(0, 0, 0, 0.24);
}

.history-hero h2 {
  margin: 3px 0 8px;
  font-size: clamp(28px, 4vw, 42px);
}

.history-hero p {
  max-width: 760px;
  color: var(--muted);
}

.history-context-line,
.history-hero-actions,
.history-status-line,
.history-section-head,
.history-quality-line,
.history-card-comparison,
.history-event-meta {
  display: flex;
  align-items: center;
}

.history-context-line {
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
}

.history-context-line strong { color: var(--text); }

.history-live-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 5px rgba(158, 184, 204, 0.08);
}

.history-live-dot.loading {
  background: var(--yellow);
  box-shadow: 0 0 0 5px rgba(255, 213, 74, 0.11), 0 0 20px rgba(255, 213, 74, 0.45);
}

.history-live-dot.ready {
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(68, 242, 161, 0.11), 0 0 20px rgba(68, 242, 161, 0.45);
}

.history-live-dot.error {
  background: var(--red);
  box-shadow: 0 0 0 5px rgba(255, 95, 109, 0.11), 0 0 20px rgba(255, 95, 109, 0.45);
}

.history-hero-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.history-overview-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.history-overview-card {
  min-width: 0;
  padding: 18px;
  border: 1px solid rgba(49, 215, 255, 0.18);
  border-radius: 19px;
  background: linear-gradient(180deg, rgba(9, 28, 46, 0.9), rgba(4, 17, 31, 0.94));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}

.history-overview-card span,
.history-overview-card small {
  display: block;
  color: var(--muted);
}

.history-overview-card span {
  min-height: 33px;
  font-size: 12px;
  font-weight: 760;
  line-height: 1.35;
}

.history-overview-card strong {
  display: block;
  margin: 8px 0 6px;
  color: var(--cyan);
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1;
  overflow-wrap: anywhere;
}

.history-overview-card small {
  min-height: 28px;
  font-size: 11px;
  line-height: 1.3;
}

.history-workspace {
  padding: 24px;
}

.history-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 0.75fr) minmax(520px, 1.6fr);
  gap: 24px;
  align-items: end;
}

.history-toolbar-copy h3 {
  margin: 2px 0 7px;
  font-size: 22px;
}

.history-toolbar-copy p:last-child {
  color: var(--muted);
  font-size: 13px;
}

.history-controls {
  display: grid !important;
  grid-template-columns: minmax(160px, .8fr) minmax(320px, 1.5fr) minmax(210px, .85fr);
  gap: 10px !important;
  align-items: end !important;
}

.history-controls .history-date-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.history-compare-toggle {
  min-height: 48px;
  display: flex !important;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(49, 215, 255, 0.17);
  border-radius: 13px;
  background: rgba(5, 17, 31, 0.48);
}

.history-compare-toggle input {
  width: 18px !important;
  height: 18px;
  margin: 0;
}

.history-compare-copy {
  min-width: 0;
}

.history-compare-copy strong,
.history-compare-copy small {
  display: block;
}

.history-compare-copy strong {
  color: var(--text);
  font-size: 12px;
  line-height: 1.25;
}

.history-compare-copy small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.3;
}

.history-control-footer {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-top: 2px;
  padding-top: 12px;
  border-top: 1px solid rgba(49, 215, 255, 0.11);
}

.history-range-preview {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.history-range-preview span,
.history-range-preview small {
  color: var(--muted);
}

.history-range-preview span {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.history-range-preview strong {
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
}

.history-range-preview small {
  font-size: 11px;
  line-height: 1.35;
}

.history-controls .history-refresh-row {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.history-controls .history-refresh-row button {
  min-width: 150px;
  min-height: 44px;
  margin: 0;
}

.history-status-line {
  justify-content: space-between;
  gap: 16px;
  margin: 18px 0 4px;
  padding: 12px 14px;
  border: 1px solid rgba(49, 215, 255, 0.13);
  border-radius: 14px;
  background: rgba(4, 15, 27, 0.5);
}

.history-status-line p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.history-metric-section,
.history-event-section,
.history-chart-section {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid rgba(49, 215, 255, 0.13);
}

.history-section-head {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.history-section-head h3 { margin-top: 2px; }
.history-section-head > span { color: var(--muted); font-size: 12px; text-align: right; }

.history-metric-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.history-metric-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid rgba(49, 215, 255, 0.16);
  border-radius: 18px;
  background: rgba(5, 17, 31, 0.56);
}

.history-metric-card.is-poor { border-color: rgba(255, 95, 109, 0.42); }
.history-metric-card.is-partial { border-color: rgba(255, 213, 74, 0.4); }
.history-metric-card.is-good { border-color: rgba(68, 242, 161, 0.25); }

.history-metric-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.history-metric-head strong {
  color: var(--text);
  font-size: 15px;
  line-height: 1.25;
}

.history-metric-head span {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--cyan);
  background: rgba(49, 215, 255, 0.08);
  font-size: 10px;
  font-weight: 800;
}

.history-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin-top: 13px;
}

.history-stat-grid div {
  min-width: 0;
  padding: 9px;
  border-radius: 11px;
  background: rgba(9, 28, 46, 0.58);
}

.history-stat-grid span,
.history-stat-grid strong {
  display: block;
}

.history-stat-grid span {
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.history-stat-grid strong {
  margin-top: 5px;
  color: var(--text);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.history-quality-line {
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 11px;
}

.history-quality-bar {
  height: 5px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(158, 184, 204, 0.14);
}

.history-quality-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--green));
}

.history-card-comparison {
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(49, 215, 255, 0.1);
  color: var(--muted);
  font-size: 11px;
}

.history-card-comparison strong.up { color: var(--orange); }
.history-card-comparison strong.down { color: var(--green); }
.history-card-comparison strong.stable { color: var(--muted); }

.history-event-list {
  display: grid;
  gap: 9px;
}

.history-event-item {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 13px 14px;
  border: 1px solid rgba(49, 215, 255, 0.13);
  border-radius: 14px;
  background: rgba(5, 17, 31, 0.48);
}

.history-event-marker {
  width: 10px;
  height: 10px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 12px rgba(49, 215, 255, 0.45);
}

.history-event-item.severity-warning .history-event-marker { background: var(--yellow); box-shadow: 0 0 12px rgba(255, 213, 74, 0.45); }
.history-event-item.severity-high .history-event-marker { background: var(--red); box-shadow: 0 0 12px rgba(255, 95, 109, 0.48); }
.history-event-item.severity-normal .history-event-marker { background: var(--green); box-shadow: 0 0 12px rgba(68, 242, 161, 0.45); }

.history-event-body strong,
.history-event-body span { display: block; }
.history-event-body strong { font-size: 13px; }
.history-event-body span { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.history-event-meta { justify-content: flex-end; gap: 8px; color: var(--muted); font-size: 10px; white-space: nowrap; }

.history-charts-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.history-chart-card {
  position: relative;
}

.history-chart-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 10px;
}

.history-chart-head strong { display: block; font-size: 15px; }
.history-chart-head span { color: var(--muted); font-size: 11px; }

.history-chart-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.history-chart-badges span {
  padding: 4px 7px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(158, 184, 204, 0.08);
  font-size: 9px;
  font-weight: 800;
}

.history-chart-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 11px;
}

.history-chart-stats span {
  display: block;
  min-width: 0;
  padding: 7px;
  border-radius: 9px;
  color: var(--muted);
  background: rgba(9, 28, 46, 0.48);
  font-size: 9px;
  text-align: center;
}

.history-chart-stats strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.history-empty-state {
  grid-column: 1 / -1;
  padding: 22px;
  border: 1px dashed rgba(49, 215, 255, 0.2);
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1180px) {
  .history-overview-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .history-toolbar { grid-template-columns: 1fr; }
  .history-controls { grid-template-columns: minmax(160px, .7fr) minmax(320px, 1.5fr) minmax(210px, .8fr); }
}

@media (max-width: 900px) {
  .history-metric-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-charts-grid { grid-template-columns: 1fr; }
  .history-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-compare-toggle { grid-column: 1 / -1; }
}

@media (max-width: 700px) {
  .history-hero { flex-direction: column; padding: 20px; }
  .history-hero-actions { width: 100%; justify-content: stretch; }
  .history-hero-actions button { flex: 1 1 170px; }
  .history-overview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-workspace { padding: 18px; }
  .history-controls { grid-template-columns: 1fr; }
  .history-controls .history-date-row,
  .history-compare-toggle { grid-column: auto; }
  .history-control-footer {
    align-items: stretch;
    flex-direction: column;
  }
  .history-controls .history-refresh-row {
    width: 100%;
    justify-content: stretch;
  }
  .history-controls .history-refresh-row button { flex: 1 1 150px; }
  .history-status-line,
  .history-section-head { align-items: flex-start; flex-direction: column; }
  .history-section-head > span { text-align: left; }
  .history-metric-summary { grid-template-columns: 1fr; }
  .history-event-item { grid-template-columns: 12px minmax(0, 1fr); }
  .history-event-meta { grid-column: 2; justify-content: flex-start; white-space: normal; }
}

@media (max-width: 430px) {
  .history-overview-grid { grid-template-columns: 1fr; }
  .history-controls .history-date-row { grid-template-columns: 1fr; }
  .history-stat-grid,
  .history-chart-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-hero-actions button,
  .history-controls .history-refresh-row button { width: 100%; flex-basis: 100%; }
}
