:root {
  --filter-text: #1f2d3d;
  --filter-muted: #5f6f82;
  --filter-border: #dfe4ea;
  --filter-border-strong: #c8d0da;
  --filter-primary: #0f766e;
  --filter-primary-soft: #e7f6f4;
  --filter-shadow: 0 22px 46px -28px rgba(15, 23, 42, 0.55);
}

.search-results {
  max-width: 1240px;
  margin: 26px auto 50px;
  padding: 0 16px;
}

.search-results__head {
  margin-bottom: 10px;
}

.search-results__title {
  margin: 0;
  color: var(--filter-text);
}

.search-results__subtitle {
  margin: 6px 0 0;
  color: var(--filter-muted);
}

.filter-shell {
  position: relative;
  margin: 0 0 10px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  z-index: 82;
}

.filter-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-height: 40px;
}

#filter-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--filter-border-strong);
  border-radius: 999px;
  background: #ffffff;
  color: var(--filter-text);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
  padding: 10px 14px;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

#filter-trigger:hover {
  border-color: var(--filter-primary);
  background: #f4f9f8;
}

#filter-trigger[aria-expanded="true"] {
  border-color: var(--filter-primary);
  background: var(--filter-primary-soft);
  color: #0b534d;
}

.filter-count {
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  background: var(--filter-primary);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 800;
}

.results-meta {
  display: none;
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.active-filters[hidden] {
  display: none;
}

.active-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid #d7dfe8;
  border-radius: 999px;
  background: #f7f9fc;
  color: #344559;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 6px 10px;
}

.filter-backdrop {
  position: fixed;
  inset: 0;
  z-index: 78;
  background: rgba(0, 0, 0, 0.42);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.filter-backdrop.active {
  opacity: 1;
}

.search-results .filter-options {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(360px, 92vw);
  max-height: min(76vh, 620px);
  overflow: auto;
  border: 1px solid var(--filter-border);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: var(--filter-shadow);
  padding: 12px;
  grid-template-columns: 1fr;
  gap: 10px;
}

.search-results .filter-options.active {
  display: grid;
}

.filter-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #ebeff4;
  margin-bottom: 4px;
}

.filter-panel__head h3 {
  margin: 0;
  color: #16263a;
  font-size: 1rem;
  font-weight: 800;
}

.filter-panel__close {
  border: 0;
  background: transparent;
  color: #42556b;
  font-size: 0.86rem;
  font-weight: 700;
  padding: 4px 6px;
  cursor: pointer;
}

.search-results .filter-options fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.search-results .filter-options label {
  display: block;
  margin-bottom: 5px;
  color: #37465a;
  font-size: 0.77rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.search-results .filter-options input,
.search-results .filter-options select {
  box-sizing: border-box;
  width: 100%;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--filter-border);
  background: #ffffff;
  color: var(--filter-text);
  padding: 0 11px;
  font-size: 0.91rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-results .filter-options input:focus,
.search-results .filter-options select:focus {
  outline: 0;
  border-color: #58a9a2;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.search-results .filter-options input:disabled,
.search-results .filter-options select:disabled {
  color: #708096;
  background: #eef2f6;
  border-color: #d7dee7;
  cursor: not-allowed;
}

.filter-price {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.filter-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid #d6dde6;
  border-radius: 10px;
  background: #f7f9fc;
  padding: 0 12px;
}

.search-results .filter-options .filter-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--filter-primary);
  margin: 0;
  padding: 0;
}

.filter-checkbox span {
  color: #2e3c4f;
  font-size: 0.86rem;
  font-weight: 600;
}

.filter-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 2px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.btn.btn-primary {
  background: var(--filter-primary);
  border-color: var(--filter-primary);
  color: #ffffff;
}

.btn.btn-primary:hover {
  background: #0d645d;
  border-color: #0d645d;
}

.btn.btn-secondary {
  background: #ffffff;
  border-color: var(--filter-border-strong);
  color: #314254;
}

.btn.btn-secondary:hover {
  border-color: #95a3b4;
  background: #f4f7fa;
}

.product-grid__actions {
  margin-top: 18px;
  display: flex;
  justify-content: center;
}

#load-more-products {
  min-width: 220px;
}

.product-grid__loading,
.product-grid__empty {
  border-radius: 10px;
  border: 1px dashed #cfd8e3;
  background: #f7f9fc;
  color: #5c6f83;
  text-align: center;
  font-weight: 600;
  padding: 22px 16px;
}

@media (max-width: 820px) {
  .search-results {
    margin: 22px auto 40px;
    padding: 0 12px;
  }

  .filter-toolbar {
    min-height: 38px;
  }

  #filter-trigger {
    min-height: 38px;
  }

  .search-results .filter-options {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 79;
    width: 100%;
    max-height: 88dvh;
    margin: 0;
    border: 1px solid #d8dee8;
    border-radius: 18px 18px 0 0;
    padding: 14px 14px calc(18px + env(safe-area-inset-bottom));
    transform: translateY(104%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.24s ease, opacity 0.2s ease, visibility 0s linear 0.24s;
  }

  .search-results .filter-options.active {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition-delay: 0s;
  }

  .filter-panel__head {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #ffffff;
  }

  .filter-actions {
    position: sticky;
    bottom: calc(-14px - env(safe-area-inset-bottom));
    z-index: 2;
    background: #ffffff;
    border-top: 1px solid #e7ecf3;
    padding-top: 10px;
  }

  body.is-filter-open {
    overflow: hidden;
    touch-action: none;
  }
}
