@layer components {
  /* Filter drawer — slide-in overlay panel with apply/reset/close actions and focus trap. */
  .app-visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
  }

  body.filter-drawer-open {
    overflow: hidden;
    overscroll-behavior: none;
  }

  .app-filter-drawer {
    position: fixed;
    inset: 0;
    z-index: 2100;
    display: flex;
    justify-content: flex-end;
    background: rgba(15, 23, 42, 0.35);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
  }

  .app-filter-drawer[hidden] {
    display: none;
  }

  .app-filter-drawer-panel {
    display: flex;
    flex-direction: column;
    width: min(420px, 100vw);
    height: 100%;
    background: var(--app-card-background-color, #fff);
    border-left: 1px solid
      var(--app-muted-border-color, rgba(148, 163, 184, 0.35));
    box-shadow: -12px 0 30px rgba(15, 23, 42, 0.18);
  }

  .app-filter-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.45rem;
    padding: 0.5rem 0.65rem;
    border-bottom: 1px solid
      var(--app-muted-border-color, rgba(148, 163, 184, 0.35));
  }

  .app-filter-drawer-header h2 {
    margin: 0;
    font-size: var(--text-sm);
    line-height: var(--leading-tight);
  }

  .app-filter-drawer-header .icon-button {
    min-height: auto;
    padding: 0.2rem 0.4rem;
    margin: 0;
  }

  .app-filter-drawer-body {
    --app-drawer-field-gap: 0.35rem;
    --app-drawer-row-gap: 1.1rem;
    --app-drawer-control-height: calc(
      1rem * var(--app-line-height) + var(--app-form-element-spacing-vertical) * 2 +
        var(--app-border-width) * 2
    );
    flex: 1;
    overflow: auto;
    padding: 1rem 1rem 1.1rem;
    display: grid;
    align-content: start;
    gap: var(--app-drawer-row-gap);
  }

  .app-filter-drawer-body .app-list-toolbar {
    margin-bottom: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--app-drawer-row-gap);
  }

  .app-filter-drawer-body .app-list-toolbar > * {
    width: 100% !important;
  }

  .app-filter-drawer-body .app-list-toolbar > * > * {
    width: 100% !important;
  }

  .app-filter-drawer-body .app-list-toolbar > * > * > * {
    width: 100% !important;
  }

  .app-filter-drawer-body .app-list-toolbar .app-field,
  .app-filter-drawer-body .app-list-toolbar > label {
    width: 100%;
    display: grid;
    gap: var(--app-drawer-field-gap);
    align-items: start;
    margin: 0 !important;
  }

  .app-filter-drawer-body .app-list-toolbar .app-field > span,
  .app-filter-drawer-body .app-list-toolbar > label > span {
    margin: 0 !important;
    line-height: var(--leading-tight);
  }

  .app-filter-drawer-body .app-list-toolbar input:not([type="hidden"]),
  .app-filter-drawer-body .app-list-toolbar select,
  .app-filter-drawer-body .app-list-toolbar textarea {
    width: 100% !important;
    box-sizing: border-box;
    min-height: var(--app-drawer-control-height);
    margin: 0 !important;
  }

  .app-filter-drawer-body .app-list-toolbar .multi-select {
    width: 100% !important;
    margin: 0 !important;
    line-height: var(--app-line-height);
    --input-min-height: var(--app-drawer-control-height);
  }

  .app-filter-drawer-body .app-list-toolbar .multi-select .multi-select-header {
    min-height: var(--app-drawer-control-height);
    margin: 0 !important;
    padding-top: var(--app-form-element-spacing-vertical);
    padding-bottom: var(--app-form-element-spacing-vertical);
    box-sizing: border-box;
  }

  .app-filter-drawer-body
    .app-list-toolbar
    .multi-select
    .multi-select-options {
    margin-top: 0.25rem;
  }

  .app-filter-drawer-body
    .app-list-toolbar
    .multi-select
    .multi-select-header-placeholder,
  .app-filter-drawer-body
    .app-list-toolbar
    .multi-select
    .multi-select-header-option {
    line-height: var(--leading-tight);
  }

  .app-filter-drawer-body #address-book-custom-filters {
    margin: 0;
  }

  .app-filter-drawer-footer {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-end;
    gap: 0.4rem;
    padding: 0.9rem 1rem 1.1rem;
    border-top: 1px solid
      var(--app-muted-border-color, rgba(148, 163, 184, 0.35));
  }

  .app-filter-drawer-footer > button {
    width: 100%;
    margin: 0;
  }

  @media (max-width: 768px) {
    .app-filter-drawer-panel {
      width: 100vw;
      border-left: 0;
    }
  }
}
