/* ==========================================================================
   Control de suministros — inventario (card + tabla compacta)
   Colores: #235B4E, #1A443A, #BC955C, #E8F3F0
   ========================================================================== */

.inv-sum-card {
  border-radius: 8px;
  overflow: hidden;
}

.inv-sum-card__header {
  background: linear-gradient(180deg, #fff 0%, #f8faf9 100%);
  border-bottom: 2px solid #BC955C;
  padding: 0.65rem 1rem;
}

.inv-sum-card__title {
  font-weight: 600;
  font-size: 0.95rem;
  color: #1A443A;
  display: flex;
  align-items: center;
}

.inv-sum-card__body {
  padding: 0.85rem 1rem 1rem;
}

.inv-sum-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.inv-sum-btn-outline {
  color: #235B4E;
  border: 1px solid #235B4E;
  background: #fff;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.25rem 0.55rem;
  line-height: 1.3;
}

.inv-sum-btn-outline:hover {
  background: #E8F3F0;
  color: #1A443A;
  border-color: #1A443A;
}

.inv-sum-btn-primary {
  color: #fff;
  border: 1px solid #235B4E;
  background: #235B4E;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  line-height: 1.3;
}

.inv-sum-btn-primary:hover {
  color: #fff;
  background: #1A443A;
  border-color: #1A443A;
}

.inv-sum-export-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  border-radius: 4px;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.inv-sum-export-link:hover {
  background-color: #E8F3F0;
  transform: translateY(-1px);
}

.inv-sum-export-link img {
  display: block;
}

/* KPIs */
.inv-sum-kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.inv-sum-kpi {
  background: #f3f4f6;
  border-radius: 6px;
  padding: 0.45rem 0.65rem;
  text-align: center;
  border-left: 3px solid #6B7280;
}

.inv-sum-kpi--ok {
  background: #E8F3F0;
  border-left-color: #235B4E;
}

.inv-sum-kpi--warn {
  background: #FEF3C7;
  border-left-color: #D97706;
}

.inv-sum-kpi__value {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
  color: #1A443A;
}

.inv-sum-kpi__label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #6B7280;
  margin-top: 2px;
}

/* Toolbar búsqueda */
.inv-sum-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.inv-sum-search {
  position: relative;
  flex: 1 1 220px;
  max-width: 360px;
}

.inv-sum-search__icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #235B4E;
  font-size: 0.8rem;
  opacity: 0.75;
  pointer-events: none;
}

.inv-sum-search__input {
  width: 100%;
  height: 32px;
  padding: 0 0.65rem 0 2rem;
  font-size: 0.82rem;
  border: 1px solid #E5E7EB;
  border-radius: 6px;
  background: #fff;
  color: #1F2937;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.inv-sum-search__input:focus {
  outline: none;
  border-color: #235B4E;
  box-shadow: 0 0 0 3px rgba(35, 91, 78, 0.15);
}

.inv-sum-toolbar__hint {
  font-size: 0.72rem;
  color: #6B7280;
}

/* Tabla compacta */
.inv-sum-table-wrap {
  border: 1px solid #E5E7EB;
  border-radius: 6px;
  overflow: auto;
  max-height: min(68vh, 520px);
}

.inv-sum-table {
  margin-bottom: 0;
  font-size: 0.8rem;
  table-layout: fixed;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.inv-sum-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #235B4E;
  color: #fff;
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.45rem 0.5rem;
  border: none;
  white-space: nowrap;
}

.inv-sum-th-name { width: 34%; }
.inv-sum-th-unit { width: 10%; }
.inv-sum-th-num { width: 11%; text-align: right; }
.inv-sum-th-status { width: 9%; text-align: center; }
.inv-sum-th-actions { width: 14%; text-align: center; }

.inv-sum-table tbody td {
  padding: 0.35rem 0.5rem;
  vertical-align: middle;
  border-top: 1px solid #E5E7EB;
  line-height: 1.25;
}

.inv-sum-row--ok {
  border-left: 3px solid transparent;
}

.inv-sum-row--bajo {
  background-color: rgba(217, 119, 6, 0.06);
  border-left: 3px solid #D97706;
}

.inv-sum-row--bajo:hover {
  background-color: rgba(217, 119, 6, 0.1);
}

.inv-sum-row--ok:hover {
  background-color: rgba(35, 91, 78, 0.04);
}

.inv-sum-cell-name {
  overflow: hidden;
}

.inv-sum-name {
  display: block;
  font-weight: 500;
  color: #1F2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inv-sum-stock-bar {
  display: block;
  height: 3px;
  margin-top: 4px;
  background: #E5E7EB;
  border-radius: 2px;
  overflow: hidden;
}

.inv-sum-stock-bar__fill {
  display: block;
  height: 100%;
  border-radius: 2px;
  transition: width 0.2s ease;
}

.inv-sum-stock-bar__fill--ok {
  background: #235B4E;
}

.inv-sum-stock-bar__fill--warn {
  background: #D97706;
}

.inv-sum-unit-badge {
  display: inline-block;
  max-width: 100%;
  padding: 0.1rem 0.35rem;
  font-size: 0.68rem;
  font-weight: 500;
  color: #1A443A;
  background: #E8F3F0;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inv-sum-cell-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: #374151;
}

.inv-sum-cell-stock {
  color: #1A443A;
}

.inv-sum-cell-min {
  color: #6B7280;
  font-weight: 500;
}

.inv-sum-status {
  display: inline-block;
  padding: 0.12rem 0.4rem;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-radius: 10px;
  line-height: 1.2;
}

.inv-sum-status--ok {
  background: #E8F3F0;
  color: #1A443A;
}

.inv-sum-status--bajo {
  background: #FEF3C7;
  color: #92400E;
}

/* Acciones compactas */
.inv-sum-actions {
  display: inline-flex;
  gap: 2px;
  justify-content: center;
}

.inv-sum-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 5px;
  font-size: 0.72rem;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.inv-sum-action:hover {
  transform: translateY(-1px);
}

.inv-sum-action--entrada {
  background: #E8F3F0;
  color: #235B4E;
}

.inv-sum-action--entrada:hover {
  background: #235B4E;
  color: #fff;
}

.inv-sum-action--editar {
  background: #E8EEF7;
  color: #1E3A5F;
}

.inv-sum-action--editar:hover {
  background: #1E3A5F;
  color: #fff;
}

.inv-sum-action--ajuste {
  background: #f3f4f6;
  color: #4B5563;
}

.inv-sum-action--ajuste:hover {
  background: #6B7280;
  color: #fff;
}

.inv-sum-action--minimo {
  background: #F5EFE4;
  color: #9A3412;
}

.inv-sum-action--minimo:hover {
  background: #BC955C;
  color: #fff;
}

.inv-sum-empty,
.inv-sum-no-results {
  padding: 1.5rem;
  color: #6B7280;
  font-size: 0.85rem;
}

.inv-sum-no-results {
  margin: 0.5rem 0 0;
  text-align: center;
  background: #f9fafb;
  border-radius: 6px;
}

/* Legacy badges (historial / otros) */
.inv-sum-badge-bajo {
  background-color: #ffc107;
  color: #212529;
}

.inv-sum-badge-ok {
  background-color: #235B4E;
}

/* ==========================================================================
   Historial de movimientos
   ========================================================================== */

.inv-sum-card--hist {
  margin-bottom: 0;
}

.inv-sum-hist-filters {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: 0.5rem;
  align-items: end;
  margin-bottom: 0.75rem;
  padding: 0.65rem 0.75rem;
  background: #f8faf9;
  border: 1px solid #E5E7EB;
  border-radius: 6px;
}

.inv-sum-hist-filter__label {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #6B7280;
  margin-bottom: 0.2rem;
}

.inv-sum-hist-filter__control {
  width: 100%;
  height: 32px;
  padding: 0 0.5rem;
  font-size: 0.8rem;
  border: 1px solid #E5E7EB;
  border-radius: 6px;
  background: #fff;
  color: #1F2937;
}

.inv-sum-hist-filter__control:focus {
  outline: none;
  border-color: #235B4E;
  box-shadow: 0 0 0 3px rgba(35, 91, 78, 0.12);
}

.inv-sum-hist-btn-filter {
  height: 32px;
  padding: 0 0.85rem;
  background: #235B4E;
  border: none;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: 6px;
  white-space: nowrap;
}

.inv-sum-hist-btn-filter:hover {
  background: #1A443A;
  color: #fff;
}

.inv-sum-hist-container {
  min-height: 120px;
}

.inv-sum-hist-table-wrap {
  border: 1px solid #E5E7EB;
  border-radius: 6px;
  overflow: auto;
  max-height: min(60vh, 480px);
}

.inv-sum-hist-table {
  margin-bottom: 0;
  font-size: 0.78rem;
  table-layout: fixed;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.inv-sum-hist-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #1A443A;
  color: #fff;
  font-weight: 600;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.4rem 0.45rem;
  border: none;
  white-space: nowrap;
}

.inv-sum-hist-th-date { width: 9%; }
.inv-sum-hist-th-name { width: 22%; }
.inv-sum-hist-th-type { width: 9%; text-align: center; }
.inv-sum-hist-th-num { width: 8%; text-align: right; }
.inv-sum-hist-th-stock { width: 14%; text-align: center; }
.inv-sum-hist-th-user { width: 16%; }
.inv-sum-hist-th-obs { width: 22%; }

.inv-sum-hist-table tbody td {
  padding: 0.32rem 0.45rem;
  vertical-align: middle;
  border-top: 1px solid #E5E7EB;
  line-height: 1.25;
}

.inv-sum-hist-row:hover {
  background-color: rgba(35, 91, 78, 0.04);
}

.inv-sum-hist-row--entrada {
  border-left: 3px solid #235B4E;
}

.inv-sum-hist-row--salida {
  border-left: 3px solid #DC2626;
}

.inv-sum-hist-row--devolucion {
  border-left: 3px solid #0E7490;
}

.inv-sum-hist-row--ajuste {
  border-left: 3px solid #BC955C;
}

.inv-sum-hist-cell-date {
  white-space: nowrap;
}

.inv-sum-hist-date {
  display: block;
  font-weight: 600;
  color: #374151;
  font-size: 0.75rem;
}

.inv-sum-hist-time {
  display: block;
  font-size: 0.65rem;
  color: #9CA3AF;
}

.inv-sum-hist-cell-name {
  overflow: hidden;
}

.inv-sum-hist-unit {
  display: block;
  font-size: 0.65rem;
  color: #6B7280;
  margin-top: 1px;
}

.inv-sum-hist-tipo {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-radius: 4px;
  line-height: 1.2;
}

.inv-sum-hist-tipo--entrada {
  background: #E8F3F0;
  color: #1A443A;
}

.inv-sum-hist-tipo--salida {
  background: #FEE2E2;
  color: #991B1B;
}

.inv-sum-hist-tipo--devolucion {
  background: #CFFAFE;
  color: #155E75;
}

.inv-sum-hist-tipo--ajuste {
  background: #F5EFE4;
  color: #78350F;
}

.inv-sum-hist-cell-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: #1A443A;
}

.inv-sum-hist-cell-stock {
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 0.72rem;
  white-space: nowrap;
}

.inv-sum-hist-stock-from {
  color: #6B7280;
  font-weight: 500;
}

.inv-sum-hist-stock-arrow {
  color: #BC955C;
  font-size: 0.6rem;
  margin: 0 0.15rem;
  vertical-align: middle;
}

.inv-sum-hist-stock-to {
  color: #1A443A;
  font-weight: 700;
}

.inv-sum-hist-cell-user,
.inv-sum-hist-cell-obs {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #4B5563;
  max-width: 0;
}

.inv-sum-hist-pagination {
  margin-top: 0.65rem;
  padding-top: 0.5rem;
  border-top: 1px solid #E5E7EB;
}

.inv-sum-hist-pagination .pagination {
  justify-content: center;
  margin-bottom: 0;
}

.inv-sum-hist-pagination .page-link {
  font-size: 0.78rem;
  padding: 0.3rem 0.55rem;
  color: #235B4E;
}

.inv-sum-hist-pagination .page-item.active .page-link {
  background-color: #235B4E;
  border-color: #235B4E;
}

/* Responsive */
@media screen and (max-width: 767px) {
  .inv-sum-kpis {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.35rem;
  }

  .inv-sum-kpi__value {
    font-size: 1.05rem;
  }

  .inv-sum-kpi__label {
    font-size: 0.6rem;
  }

  .inv-sum-table-wrap {
    max-height: none;
  }

  .inv-sum-th-unit,
  .inv-sum-cell-unit {
    display: none;
  }

  .inv-sum-th-name { width: 42%; }
  .inv-sum-th-num { width: 14%; }
  .inv-sum-th-actions { width: 18%; }

  .inv-sum-stock-bar {
    display: none;
  }

  .inv-sum-hist-filters {
    grid-template-columns: 1fr 1fr;
  }

  .inv-sum-hist-filter--wide {
    grid-column: 1 / -1;
  }

  .inv-sum-hist-filter--action {
    grid-column: 1 / -1;
  }

  .inv-sum-hist-btn-filter {
    width: 100%;
  }

  .inv-sum-hist-th-user,
  .inv-sum-hist-cell-user {
    display: none;
  }

  .inv-sum-hist-th-name { width: 28%; }
  .inv-sum-hist-th-stock { width: 18%; }
  .inv-sum-hist-th-obs { width: 26%; }

  .inv-sum-hist-table-wrap {
    max-height: none;
  }
}

@media screen and (max-width: 540px) {
  .inv-sum-card__header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.5rem;
  }

  .inv-sum-header-actions {
    width: 100%;
    justify-content: flex-end;
  }
}
