.controles-card .form-row {
  flex-wrap: wrap;
  gap: 12px;
}

.controles-card label {
  font-weight: 600;
  color: var(--color-text-main);
}

.controles-card select,
.controles-card input[type="date"],
.controles-card input[type="month"],
.controles-card input[type="number"] {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--color-input-border);
  background: var(--color-input-bg);
  font-size: 0.9rem;
  color: var(--color-text-main);
}

.controles-card select:focus,
.controles-card input[type="date"]:focus,
.controles-card input[type="month"]:focus,
.controles-card input[type="number"]:focus {
  outline: none;
  border-color: #1976d2;
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.15);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.stat-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 16px;
}

.stat-card h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--color-text-muted);
}

.stat-card.total {
  background: var(--color-primary-soft);
}

.stat-value {
  margin: 10px 0 0;
  font-size: 1.8rem;
  font-weight: 700;
}

.histogram-card {
  margin-top: 20px;
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  background: linear-gradient(180deg, var(--color-surface) 0%, var(--color-surface-alt) 100%);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
}

.histogram-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 0%, rgba(25, 118, 210, 0.12), transparent 55%);
  pointer-events: none;
}

.histogram-card > * {
  position: relative;
  z-index: 1;
}

.histogram-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.histogram-header h3 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--color-text-main);
}

.histogram-range {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  background: var(--color-surface-muted);
  padding: 6px 10px;
  border-radius: 999px;
}

.histogram {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 230px;
  overflow-x: auto;
  padding: 18px 14px 10px;
  border-radius: 14px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-muted);
  background-image: linear-gradient(180deg, rgba(148, 163, 184, 0.15) 1px, transparent 1px);
  background-size: 100% 26px;
}

.histogram-bar {
  flex: 1 0 28px;
  min-width: 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.histogram-bar.selected .bar-track {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.25);
}

.histogram-bar.selected .bar-value {
  opacity: 1;
  transform: translateY(0);
  border-color: var(--color-primary);
}

.bar-track {
  width: 100%;
  height: 170px;
  background: transparent;
  border-radius: 12px;
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
}

.bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column-reverse;
  border-radius: 10px;
  overflow: hidden;
  transition: height 0.4s ease;
}

.segment {
  width: 100%;
  transition: height 0.4s ease;
}

.segment.autorizadas {
  background: #16a34a;
}

.segment.no-autorizadas {
  background: #dc2626;
}

.segment.pendientes {
  background: #f59e0b;
}

.segment:not(:first-child) {
  border-top: 1px solid rgba(255, 255, 255, 0.65);
}

.bar-label {
  margin-top: 4px;
  font-size: 0.7rem;
  color: var(--color-text-muted);
  min-height: 14px;
}

.bar-value {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-text-main);
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 2px 8px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.histogram-bar:hover .bar-value {
  opacity: 1;
  transform: translateY(0);
}

.histogram-bar:hover .bar-track {
  border-color: var(--color-primary-soft);
  box-shadow: var(--shadow-card);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
  font-size: 0.85rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--color-surface);
  border-radius: 999px;
  border: 1px solid var(--color-border);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot.autorizadas {
  background: #2e7d32;
}

.legend-dot.no-autorizadas {
  background: #c62828;
}

.legend-dot.pendientes {
  background: #f9a825;
}

.detalle-card {
  margin-top: 18px;
  border-radius: 16px;
  border: 1px solid var(--color-border);
  background: var(--color-card);
  box-shadow: var(--shadow-card);
}

.detalle-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.detalle-header h4 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--color-text-main);
}

.detalle-status {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  padding: 8px 0;
}

.detalle-status.error {
  color: var(--color-error);
}

.detalle-empty {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  padding: 8px 0;
}

.detalle-table .estado-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--color-surface-muted);
  color: var(--color-text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

@media (max-width: 720px) {
  .histogram-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .histogram {
    padding: 14px 10px 8px;
  }

  .detalle-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
