* {
  box-sizing: border-box;
}

.is-hidden {
  display: none !important;
}

:root {
  --green-700: #2e7d32;
  --green-500: #4caf50;
  --green-200: #a5d6a7;

  --red-700: #d32f2f;
  --red-500: #f44336;
  --red-100: #ffcdd2;

  --blue-800: #1e3a5f;
  --blue-700: #2c5282;
  --blue-300: #90caf9;

  --gray-900: #212121;
  --gray-600: #757575;
  --gray-300: #e0e0e0;
  --gray-100: #f5f5f5;

  --white: #ffffff;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
}

.topbar {
  background: var(--green-700);
  color: var(--white);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 8px 24px;
}

.brand-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  padding: 7px 10px;
}

.brand-logo {
  width: auto;
  height: 56px;
  max-width: 280px;
  object-fit: contain;
  display: block;
}

.quick-search {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
  max-width: 620px;
}

.quick-label {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: #e8f6e9;
}

.quick-input-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
}

.quick-input-row input {
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--gray-900);
  font-weight: 600;
}

.quick-input-row input:focus {
  outline: none;
  border-color: var(--green-200);
  box-shadow: 0 0 0 3px rgba(165, 214, 167, 0.35);
}

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px;
}

h1 {
  margin: 2px 0 8px;
  color: var(--blue-800);
}

.subtitle {
  margin: 0 0 20px;
  color: var(--gray-600);
}

.filters-toggle-wrap {
  display: flex;
  justify-content: flex-start;
  margin: 0 0 12px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: 10px;
  padding: 14px;
}

.filters.is-collapsed {
  display: none;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.checkline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 6px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
}

.field input,
.field select {
  height: 38px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--white);
  color: var(--gray-900);
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.18);
}

.location {
  justify-content: end;
}

.actions {
  display: flex;
  align-items: end;
}

.actions .btn-primary {
  min-width: 190px;
}

button {
  height: 38px;
  border: none;
  border-radius: 8px;
  padding: 0 14px;
  color: var(--white);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.16s ease, transform 0.08s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--red-700);
}

.btn-primary:hover {
  background: var(--red-500);
}

.btn-secondary {
  background: #256b2a;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.btn-secondary:hover {
  background: var(--green-500);
}

.btn-secondary.active {
  box-shadow: 0 0 0 3px rgba(165, 214, 167, 0.45);
}

.btn-tertiary {
  background: var(--white);
  color: var(--blue-700);
  border: 1px solid var(--gray-300);
}

.btn-tertiary:hover {
  background: #eef5ff;
  border-color: var(--blue-300);
}

.status {
  margin: 14px 0 10px;
  min-height: 36px;
  color: var(--blue-700);
}

#orderText {
  margin: 0 0 4px;
  font-weight: 600;
  color: var(--blue-800);
}

#statusText {
  margin: 0;
}

#freshnessText {
  margin: 8px 0 0;
  font-size: 0.86rem;
  color: var(--gray-600);
}

.freshness-wrap {
  margin-top: 8px;
  padding-bottom: 12px;
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
  align-items: center;
}

.active-filters-label {
  color: var(--gray-600);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 5px 0;
}

.filter-chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #eef5ff;
  border: 1px solid #d0ddef;
  color: var(--blue-800);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
}

.filter-chip-btn.is-active {
  border-color: var(--green-500);
  background: #e7f4e8;
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
}

.filter-chip-main {
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 0;
  cursor: pointer;
}

.chip-remove-btn {
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 0;
  opacity: 0;
  cursor: pointer;
  transition: opacity 0.14s ease;
}

.filter-chip-btn:hover .chip-remove-btn {
  opacity: 1;
}

.clear-filters-btn {
  border: none;
  background: transparent;
  color: var(--red-700);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  padding: 4px 2px;
}

.chip-editor {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 12px;
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: 10px;
  padding: 8px 10px;
  box-shadow: 0 8px 18px rgba(18, 28, 45, 0.09);
}

.chip-editor.is-hidden {
  display: none;
}

.chip-editor-label {
  margin: 0;
  font-size: 0.9rem;
  color: var(--gray-600);
  font-weight: 700;
}

.chip-editor select,
.chip-editor input {
  height: 34px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  padding: 0 8px;
}

.chip-editor-quick {
  display: inline-flex;
  gap: 6px;
}

.chip-quick-btn {
  height: 34px;
  border: 1px solid var(--gray-300);
  border-radius: 999px;
  background: var(--white);
  color: var(--blue-700);
  font-weight: 700;
  padding: 0 10px;
}

.chip-quick-btn:hover {
  border-color: var(--blue-300);
  background: #eef5ff;
}

.chip-quick-btn.is-selected {
  border-color: var(--green-500);
  background: #e7f4e8;
  color: var(--green-700);
}

.chip-editor-actions {
  display: inline-flex;
  gap: 6px;
}

.chip-editor-actions .btn {
  height: 34px;
  padding: 0 10px;
}

.top3 {
  background: var(--white);
  border: 1px solid #ffe0b2;
  border-radius: 12px;
  padding: 12px 14px;
  margin: 0 0 14px;
}

.top3.is-hidden {
  display: none;
}

.top3 h2 {
  margin: 0 0 8px;
  font-size: 1rem;
  color: #8d4e00;
}

.top3-list {
  margin: 0;
  padding: 0 0 0 18px;
  display: grid;
  gap: 5px;
}

.top3-item {
  color: var(--blue-800);
  font-weight: 700;
}

.ad-slot {
  margin: 0 0 14px;
  border: 1px solid var(--gray-300);
  background: #efefef;
  border-radius: 12px;
  padding: 10px;
}

.ad-label {
  margin: 0 0 8px;
  color: var(--gray-600);
  font-size: 0.9rem;
  font-weight: 700;
}

.ad-frame {
  width: min(100%, 728px);
  margin: 0 auto;
  border: 1px dashed #b9b9b9;
  border-radius: 8px;
  background: #dfdfdf;
  color: #555;
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px;
}

.ad-frame-top,
.ad-frame-inline {
  height: 90px;
}

.top3-link {
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.top3-link:hover {
  color: var(--green-700);
}

.results {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.card {
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 4px 10px rgba(18, 28, 45, 0.05);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(18, 28, 45, 0.12);
}

.card.flash {
  animation: cardFlash 2000ms ease;
}

.card.top1 {
  border: 2px solid #3b9b40;
  box-shadow: 0 10px 24px rgba(46, 125, 50, 0.23);
  position: relative;
}

.badge-top1 {
  position: absolute;
  top: -12px;
  left: 14px;
  background: var(--green-500);
  color: var(--white);
  font-size: 0.82rem;
  font-weight: 800;
  border-radius: 999px;
  padding: 4px 10px;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.price-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.price-value {
  margin: 0;
  font-size: 2.35rem;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.card:hover .price-value {
  text-shadow: 0 0 12px rgba(76, 175, 80, 0.2);
}

.price-value.cheap {
  color: var(--green-700);
}

.price-value.mid {
  color: #9a7f00;
}

.price-value.expensive {
  color: var(--red-700);
}

.price-value.na {
  color: var(--gray-600);
}

.station-name {
  margin: 6px 0 0;
  font-size: 1.02rem;
  font-weight: 650;
  color: var(--blue-800);
}

.station-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.station-row .prices {
  margin-top: 6px;
  justify-content: flex-end;
}

.distance-badge {
  background: #f3f6fb;
  border: 1px solid #d7e0ef;
  border-radius: 999px;
  color: #53627a;
  font-weight: 600;
  font-size: 0.84rem;
  padding: 4px 9px;
  white-space: nowrap;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.muted {
  margin: 5px 0 10px;
  color: var(--gray-600);
  font-size: 0.92rem;
}

.price-delta {
  margin: 5px 0 0;
  font-size: 1rem;
  font-weight: 700;
}

.price-delta.cheap {
  color: var(--green-700);
}

.price-delta.mid {
  color: #9a7f00;
}

.price-delta.expensive {
  color: var(--red-700);
}

.prices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.price-pill {
  border: 1px solid var(--gray-300);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.88rem;
  background: var(--gray-100);
}

.price-pill.selected {
  border-color: var(--blue-700);
  background: #e8f0fb;
  color: var(--blue-800);
}

.price-pill.cheap {
  border-color: var(--green-500);
  background: #edf8ee;
  color: var(--green-700);
}

.price-pill.expensive {
  border-color: var(--red-500);
  background: var(--red-100);
  color: var(--red-700);
}

.card-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}

.fav-star {
  width: 34px;
  height: 34px;
  border: 1px solid var(--gray-300);
  border-radius: 999px;
  background: var(--white);
  color: #8d6e00;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0;
}

.fav-star:hover {
  border-color: #ffb300;
  background: #fff8e1;
}

.fav-star.active {
  border-color: #ffb300;
  background: #fff8e1;
  color: #8d6e00;
}

.fav-star.pop {
  animation: popStar 220ms ease;
}

.btn-link.primary {
  background: var(--green-700);
  border-color: var(--green-500);
  color: var(--white);
}

.btn-link.primary:hover {
  background: var(--green-500);
}

.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border-radius: 8px;
  border: 1px solid var(--gray-300);
  background: var(--white);
  color: var(--blue-700);
  padding: 8px 12px;
  font-weight: 600;
}

.btn-link:hover {
  border-color: var(--blue-300);
  background: #eef5ff;
}

@keyframes popStar {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.25);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes cardFlash {
  0% {
    box-shadow: 0 0 0 rgba(76, 175, 80, 0);
  }
  35% {
    box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.32), 0 10px 22px rgba(18, 28, 45, 0.12);
  }
  100% {
    box-shadow: 0 4px 10px rgba(18, 28, 45, 0.05);
  }
}

@media (max-width: 860px) {
  .brand-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .brand-logo {
    height: 58px;
    max-width: 100%;
  }

  .quick-search {
    max-width: 100%;
  }

  .quick-input-row {
    grid-template-columns: 1fr;
  }

  .station-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .station-row .prices {
    justify-content: flex-start;
  }

  .ad-frame {
    width: min(100%, 320px);
  }

  .ad-frame-top,
  .ad-frame-inline {
    height: 100px;
  }
}
