:root {
  --bg: #f8f1e6;
  --bg-soft: #fff8ef;
  --ink: #20312a;
  --ink-soft: #536157;
  --panel: rgba(255, 249, 240, 0.86);
  --panel-strong: rgba(255, 252, 247, 0.95);
  --line: rgba(32, 49, 42, 0.1);
  --shadow: 0 24px 60px rgba(80, 62, 34, 0.12);
  --accent-red: #d24d36;
  --accent-red-dark: #ad341f;
  --accent-green: #365f49;
  --accent-yellow: #f2b04d;
  --accent-sage: #dce7ce;
  --pill: rgba(255, 255, 255, 0.75);
  --radius-xl: 32px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --font-title: "Fraunces", "Georgia", serif;
  --font-body: "DM Sans", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(242, 176, 77, 0.23), transparent 28%),
    radial-gradient(circle at top right, rgba(210, 77, 54, 0.16), transparent 24%),
    linear-gradient(180deg, #fbf5eb 0%, #f5ebdc 100%);
}

.page-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.4;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 18px 18px;
  mix-blend-mode: soft-light;
}

.page-orb {
  position: fixed;
  z-index: 0;
  width: 34rem;
  height: 34rem;
  border-radius: 999px;
  filter: blur(16px);
  pointer-events: none;
  opacity: 0.55;
}

.orb-a {
  top: -8rem;
  right: -10rem;
  background: radial-gradient(circle, rgba(210, 77, 54, 0.22), transparent 70%);
}

.orb-b {
  bottom: -10rem;
  left: -8rem;
  background: radial-gradient(circle, rgba(54, 95, 73, 0.24), transparent 72%);
}

.page-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.hero-panel,
.flyer-strip-panel,
.filters-panel,
.scan-panel,
.results-panel {
  background: var(--panel);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow);
  border-radius: var(--radius-xl);
  padding: 28px;
  animation: rise-in 0.7s ease both;
}

.flyer-strip-panel,
.filters-panel,
.scan-panel,
.results-panel {
  margin-top: 20px;
}

.hero-panel {
  display: grid;
  grid-template-columns: 1.3fr 0.9fr;
  gap: 24px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--accent-red-dark);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-title);
  line-height: 1.02;
}

h1 {
  font-size: clamp(2.6rem, 5vw, 5rem);
  max-width: 12ch;
}

h2 {
  font-size: clamp(1.6rem, 2.5vw, 2.3rem);
}

h3 {
  font-size: 1.35rem;
}

.hero-text,
.section-caption,
.results-summary,
.bot-map-copy p,
.empty-state p {
  color: var(--ink-soft);
}

.hero-text {
  margin: 18px 0 0;
  max-width: 58ch;
  font-size: 1.04rem;
  line-height: 1.6;
}

.hero-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.hero-note,
.loading-pill,
.filter-chip,
.command-chip,
.flyer-pill,
.store-badge,
.category-badge,
.page-badge {
  border-radius: 999px;
  padding: 9px 14px;
  background: var(--pill);
  border: 1px solid rgba(32, 49, 42, 0.08);
}

code {
  font-family: "SFMono-Regular", "Menlo", monospace;
  font-size: 0.92em;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-self: start;
}

.hero-stat,
.result-metric {
  padding: 18px;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(248, 240, 228, 0.84));
  border: 1px solid rgba(32, 49, 42, 0.08);
}

.hero-stat-value,
.result-metric-value {
  display: block;
  font-family: var(--font-title);
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  color: var(--accent-green);
}

.hero-stat-label,
.result-metric-label {
  display: block;
  margin-top: 6px;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.section-title-row,
.results-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
}

.flyer-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.flyer-pill {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 230px;
  background: var(--panel-strong);
}

.flyer-pill strong {
  font-size: 1rem;
}

.flyer-pill small {
  color: var(--ink-soft);
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.field {
  display: grid;
  gap: 8px;
}

.field-label {
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--ink-soft);
}

select,
input[type="number"],
input[type="password"],
.ghost-button,
.preset-button,
.primary-button {
  appearance: none;
  border: 1px solid rgba(32, 49, 42, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font: inherit;
  padding: 14px 16px;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

select:focus,
input[type="number"]:focus,
input[type="password"]:focus,
.ghost-button:focus,
.preset-button:focus,
.primary-button:focus {
  outline: none;
  border-color: rgba(210, 77, 54, 0.45);
  box-shadow: 0 0 0 4px rgba(210, 77, 54, 0.12);
}

.ghost-button,
.preset-button,
.primary-button {
  cursor: pointer;
}

.ghost-button:hover,
.preset-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
}

.ghost-button {
  background: transparent;
}

.preset-row,
.active-filters,
.bot-command-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.preset-row {
  margin-top: 16px;
}

.preset-button {
  background: #fff5eb;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent-red), var(--accent-red-dark));
  color: #fff;
  border-color: transparent;
}

.active-filters {
  margin-top: 16px;
}

.filter-chip {
  background: rgba(220, 231, 206, 0.8);
}

.bot-map-panel {
  margin-top: 22px;
  padding: 20px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(54, 95, 73, 0.08), rgba(255, 255, 255, 0.72));
  border: 1px solid rgba(54, 95, 73, 0.1);
}

.scan-intro {
  margin-bottom: 0;
}

.scan-panel {
  overflow: hidden;
}

.scan-panel-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  cursor: pointer;
  list-style: none;
}

.scan-panel-summary::-webkit-details-marker {
  display: none;
}

.scan-panel-summary::marker {
  content: "";
}

.scan-toggle-pill {
  flex: 0 0 auto;
  align-self: center;
  border-radius: 999px;
  padding: 11px 16px;
  background: rgba(54, 95, 73, 0.1);
  border: 1px solid rgba(54, 95, 73, 0.12);
  color: var(--accent-green);
  font-weight: 700;
}

.scan-panel[open] .scan-toggle-pill {
  background: rgba(210, 77, 54, 0.1);
  border-color: rgba(210, 77, 54, 0.16);
  color: var(--accent-red-dark);
}

.scan-panel-body {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid rgba(32, 49, 42, 0.08);
}

.scan-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.scan-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.scan-status-panel {
  margin-top: 18px;
}

.flyer-search-panel {
  margin-top: 18px;
  padding: 18px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.88), rgba(248, 240, 228, 0.9));
  border: 1px solid rgba(32, 49, 42, 0.08);
}

.flyer-results-header {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}

.flyer-results-list {
  display: grid;
  gap: 12px;
}

.flyer-result-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(32, 49, 42, 0.08);
}

.flyer-result-copy {
  min-width: 0;
}

.flyer-result-store {
  margin: 0 0 6px;
  color: var(--accent-green);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
}

.flyer-result-copy h3 {
  line-height: 1.14;
}

.flyer-result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.flyer-result-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ghost-link {
  color: var(--accent-green);
  text-decoration: none;
  font-weight: 700;
}

.ghost-link:hover {
  text-decoration: underline;
}

.scan-status-card {
  padding: 18px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.88), rgba(252, 245, 237, 0.96));
  border: 1px solid rgba(32, 49, 42, 0.08);
}

.scan-status-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.scan-status-badge {
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
}

.status-pending,
.status-claimed {
  background: rgba(242, 176, 77, 0.22);
  color: #8d5a0a;
}

.status-running {
  background: rgba(54, 95, 73, 0.16);
  color: var(--accent-green);
}

.status-completed {
  background: rgba(47, 153, 87, 0.16);
  color: #1d7c42;
}

.status-failed {
  background: rgba(210, 77, 54, 0.15);
  color: var(--accent-red-dark);
}

.scan-status-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.scan-progress-block {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.scan-progress-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  font-weight: 700;
  color: var(--ink);
}

.scan-progress-bar {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(54, 95, 73, 0.12);
  border: 1px solid rgba(32, 49, 42, 0.08);
}

.scan-progress-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--accent-green), #5e8d73);
  transition: width 240ms ease;
}

.command-chip {
  background: rgba(255, 255, 255, 0.9);
}

.results-toolbar {
  align-items: end;
}

.result-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 12px;
  min-width: min(100%, 420px);
}

.results-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 24px;
}

.deal-card,
.loading-card,
.empty-state {
  border-radius: var(--radius-lg);
  background: var(--panel-strong);
  border: 1px solid rgba(32, 49, 42, 0.08);
  box-shadow: 0 16px 32px rgba(60, 48, 28, 0.08);
}

.deal-card {
  padding: 18px 20px;
  animation: rise-in 0.45s ease both;
  animation-delay: calc(var(--stagger, 0) * 45ms);
}

.deal-row {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) 180px;
  gap: 18px;
  align-items: center;
  border-radius: 20px;
}

.deal-thumb-shell {
  display: flex;
  align-items: center;
  justify-content: center;
}

.deal-thumb {
  width: 104px;
  height: 104px;
  object-fit: cover;
  border-radius: 18px;
  background: #f5ece0;
  border: 1px solid rgba(32, 49, 42, 0.08);
}

.deal-thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  font-size: 0.92rem;
  text-align: center;
  padding: 10px;
}

.deal-main {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.deal-main-top {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.deal-title-block {
  display: grid;
  gap: 6px;
  min-width: 0;
  flex: 1 1 auto;
}

.deal-side {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.loading-card,
.empty-state {
  padding: 22px;
}

.deal-card-top,
.deal-card-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.store-badge {
  background: rgba(242, 176, 77, 0.24);
}

.category-badge {
  background: rgba(54, 95, 73, 0.12);
}

.page-badge {
  background: rgba(210, 77, 54, 0.12);
}

.discount-badge {
  padding: 10px 14px;
  border-radius: 16px;
  color: white;
  background: linear-gradient(135deg, var(--accent-red), var(--accent-red-dark));
  font-weight: 700;
  white-space: nowrap;
}

.deal-card h3 {
  font-size: 1.22rem;
  line-height: 1.16;
  overflow-wrap: anywhere;
}

.brand-line {
  margin: 0;
  font-weight: 700;
  color: var(--accent-green);
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.description-line,
.flyer-line,
.validity-line {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.55;
}

.flyer-line {
  font-weight: 700;
  color: var(--ink);
}

.price-line {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: baseline;
  justify-content: flex-end;
}

.sale-price {
  font-family: var(--font-title);
  font-size: 1.7rem;
}

.full-price {
  color: var(--ink-soft);
  text-decoration: line-through;
}

.savings-pill {
  color: var(--accent-red-dark);
  background: rgba(210, 77, 54, 0.09);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.92rem;
  font-weight: 700;
}

.empty-state {
  margin-top: 24px;
  text-align: center;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  .hero-panel,
  .section-title-row,
  .results-toolbar {
    grid-template-columns: 1fr;
    display: grid;
  }

  .filters-grid,
  .scan-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .result-metrics {
    min-width: 0;
  }

  .deal-row {
    grid-template-columns: 92px minmax(0, 1fr);
  }

  .deal-side {
    grid-column: 2;
    justify-items: start;
  }

  .price-line {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .hero-panel,
  .flyer-strip-panel,
  .filters-panel,
  .scan-panel,
  .results-panel {
    padding: 20px;
    border-radius: 24px;
  }

  h1 {
    max-width: 11ch;
  }

  .hero-stats,
  .filters-grid,
  .scan-grid,
  .result-metrics {
    grid-template-columns: 1fr;
  }

  .deal-card-top,
  .deal-card-footer,
  .deal-main-top,
  .scan-status-top,
  .scan-panel-summary,
  .flyer-result-row {
    flex-direction: column;
  }

  .flyer-result-row {
    display: flex;
    align-items: flex-start;
  }

  .flyer-result-actions {
    justify-content: flex-start;
  }

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

  .deal-side {
    grid-column: auto;
    justify-items: start;
  }

  .deal-thumb {
    width: 100%;
    max-width: 140px;
    height: 140px;
  }
}
