@layer components {
  .filter-summary-card {
    margin-bottom: 0.75rem;
    padding: 0.9rem 1rem;
    border: 1px solid var(--color-border, #dfe3f0);
    border-radius: var(--radius-md, 0.75rem);
    background: color-mix(in srgb, var(--color-surface, #fff) 92%, var(--surface-muted, rgba(17, 47, 109, 0.08)));
  }

  .filter-summary-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-muted, #6c757d);
    margin-bottom: 0.35rem;
  }

  .filter-summary-value {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
  }

  .filter-summary-net {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-fg, #0f172a);
  }

  .filter-summary-gross {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-muted, #6c757d);
  }

  .table-container--statements {
    overflow: visible;
  }

  .table-section--statements {
    overflow: visible;
  }

  .table-container--statements .table-scroll {
    overflow-x: auto;
    overflow-y: visible;
  }

  .data-table thead th.is-filter-open {
    z-index: 60;
  }

  .data-table thead th.is-filter-open .filter-dropdown {
    z-index: 70;
  }

  .th-filter {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
  }

  .th-filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    width: 100%;
    padding: 0.15rem 0.35rem;
    font: inherit;
    color: inherit;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm, 0.5rem);
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  }

  .th-filter-toggle:hover,
  .th-filter-toggle:focus-visible,
  .th-filter-toggle.active {
    background: var(--surface-muted, rgba(17, 47, 109, 0.08));
    border-color: color-mix(in srgb, var(--color-primary, #112f6d) 30%, transparent);
  }

  .th-filter .caret {
    font-size: 0.75rem;
    transition: transform 0.2s ease;
  }

  .th-filter-toggle.active .caret {
    transform: rotate(180deg);
  }

  .filter-dropdown {
    position: absolute;
    top: calc(100% + 0.35rem);
    right: 0;
    min-width: 220px;
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border, #dfe3f0);
    border-radius: var(--radius-md, 0.75rem);
    box-shadow: var(--shadow-sm, 0 12px 30px rgba(15, 23, 42, 0.15));
    padding: var(--space-3, 1rem);
    display: flex;
    flex-direction: column;
    gap: var(--space-3, 1rem);
    z-index: 45;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
  }

  /* Al estar dentro de un contenedor con scroll horizontal, un dropdown absoluto puede quedar recortado.
     Este modo "portal" lo posiciona en el viewport para que se vea siempre (estilo Excel). */
  .filter-dropdown.is-portal {
    position: fixed;
    top: 0;
    left: 0;
    right: auto;
    z-index: 1000;
  }

  .filter-dropdown::before {
    content: "";
    position: absolute;
    top: -8px;
    right: 1.5rem;
    width: 12px;
    height: 12px;
    background: inherit;
    border-left: 1px solid var(--color-border, #dfe3f0);
    border-top: 1px solid var(--color-border, #dfe3f0);
    transform: rotate(45deg);
  }

  .filter-dropdown.is-portal::before {
    left: var(--filter-caret-left, 1.5rem);
    right: auto;
  }

  .filter-dropdown.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  .filter-options {
    max-height: 240px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
  }

  .filter-options label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--color-fg, #0f172a);
  }

  .filter-options input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--color-primary, #112f6d);
  }

  .filter-options .empty {
    font-size: 0.85rem;
    color: var(--color-muted, #6c757d);
    padding: 0.25rem 0;
  }

  .filter-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
  }

  .filter-actions button {
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: var(--radius-sm, 0.5rem);
    padding: 0.35rem 0.9rem;
    border: 1px solid transparent;
    background: var(--surface-muted, rgba(17, 47, 109, 0.08));
    color: var(--color-primary, #112f6d);
  }

  .filter-actions button[data-filter-action="apply"] {
    background: var(--color-primary, #112f6d);
    color: #fff;
  }
}
