@import url("https://fonts.googleapis.com/css2?family=Archivo:wght@300;400;600;700&family=Fraunces:opsz,wght@9..144,600;700&display=swap");

:root {
  color-scheme: light;
  --paper: #f8f4ef;
  --ink: #1f1b16;
  --accent: #d96830;
  --accent-dark: #b55223;
  --stone: #e2d9cf;
  --sage: #c1cbb6;
  --night: #2b2b2b;
  --card: #ffffff;
  --muted: #6a5f55;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Archivo", "Helvetica Neue", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top left, #fef4e8 0%, var(--paper) 55%, #efe7de 100%);
  scrollbar-gutter: stable;
}

body.modal-open {
  overflow: hidden;
  padding-right: var(--scrollbar-comp, 0px);
}

.ambient {
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
      120deg,
      rgba(217, 104, 48, 0.05) 0px,
      rgba(217, 104, 48, 0.05) 1px,
      transparent 1px,
      transparent 24px
    ),
    radial-gradient(circle at 80% 20%, rgba(98, 116, 111, 0.15), transparent 50%),
    radial-gradient(circle at 10% 90%, rgba(217, 104, 48, 0.12), transparent 45%);
  pointer-events: none;
  z-index: -1;
}

main {
  padding: 80px clamp(24px, 4vw, 72px) 80px;
  display: grid;
  gap: 32px;
}

.panel {
  background: var(--card);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 28px;
  border: 1px solid rgba(31, 27, 22, 0.08);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.panel h2 {
  margin: 0 0 6px;
  font-size: 26px;
}

.panel p {
  margin: 0;
  color: var(--muted);
}

.settings-actions {
  display: flex;
  justify-content: flex-start;
  gap: 12px;
}

.settings-section {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

.filter-toggle {
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  background: #f6efe7;
  border: 1px solid rgba(31, 27, 22, 0.1);
}

.filter-toggle-button {
  border: none;
  background: transparent;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  box-shadow: none;
}

.filter-toggle-button:hover {
  color: var(--ink);
}

.filter-toggle-button.is-active {
  background: #fff;
  color: var(--ink);
  border: 1px solid rgba(31, 27, 22, 0.12);
  box-shadow: 0 8px 16px rgba(31, 27, 22, 0.12);
}

.listing-filter {
  margin-bottom: 16px;
  display: flex;
  justify-content: flex-start;
}

.settings-section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  cursor: pointer;
}

.settings-section.is-collapsed .listing-grid {
  display: none;
}

button {
  border: none;
  font-family: inherit;
  cursor: pointer;
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 600;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:active {
  transform: scale(0.98);
}

.primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 10px 20px rgba(217, 104, 48, 0.35);
}

.primary:hover {
  background: var(--accent-dark);
}

.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid rgba(31, 27, 22, 0.2);
}

.status {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.status .spinner {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(31, 27, 22, 0.2);
  border-top-color: rgba(31, 27, 22, 0.6);
  animation: spin 0.8s linear infinite;
  display: none;
}

.status .status-icon {
  display: none;
  font-size: 13px;
  line-height: 1;
}

.status.loading .spinner {
  display: inline-block;
}

.status .status-text {
  display: inline-block;
}

.airtable-add-fields {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

input,
select,
textarea {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(31, 27, 22, 0.15);
  font-size: 15px;
  font-family: inherit;
  background: #fffdf9;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

.grid {
  display: grid;
  gap: 18px;
}

.grid.two {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.full {
  width: 100%;
}

.mapping {
  background: #f6efe7;
  border-radius: 16px;
  padding: 20px;
  border: 1px solid rgba(31, 27, 22, 0.08);
}

.mapping-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.mapping-header h3 {
  margin: 0;
  font-size: 18px;
}

.mapping-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.mapping-grid label {
  text-transform: none;
  letter-spacing: 0.02em;
  font-size: 12px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.request-cards {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.request-card {
  border-radius: 18px;
  padding: 18px;
  background: #fef8f1;
  border: 1px solid rgba(31, 27, 22, 0.08);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
  min-height: 160px;
}

.request-card.brand-colored {
  background: var(--source-card-bg);
  color: var(--source-card-ink);
  border-color: rgba(255, 255, 255, 0.22);
}

.request-card.brand-colored span,
.request-card.brand-colored .status {
  color: var(--source-card-ink);
  opacity: 0.85;
}

.request-card.brand-colored .run-source {
  color: var(--source-card-ink);
  border-color: currentColor;
}

.request-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.08);
}

.request-card.active {
  border-color: var(--accent);
  box-shadow: 0 16px 24px rgba(217, 104, 48, 0.2);
}

.request-card h4 {
  margin: 0 0 12px;
}

.request-card span {
  font-size: 12px;
  color: var(--muted);
}

.source-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: auto;
}

.source-actions .run-source {
  font-size: 12px;
  padding: 6px 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.source-actions .run-source:hover {
  background: rgba(31, 27, 22, 0.08);
}

.request-card.brand-colored .run-source:hover {
  background: rgba(255, 255, 255, 0.18);
}

.listing-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.agency-section.is-single .listing-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 320px));
  justify-content: start;
}

.agency-section {
  display: grid;
  gap: 16px;
  margin-bottom: 28px;
}

.agency-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(31, 27, 22, 0.08);
  cursor: pointer;
}

.hidden-banner {
  background: #0b0b0b;
  border-bottom: none;
  padding: 12px 16px;
  border-radius: 16px;
}

.agency-header.hidden-banner {
  background: #0b0b0b;
}

.hidden-banner h3,
.hidden-banner .status,
.hidden-banner .toggle-section {
  color: #f9f4ec;
}

.agency-header .agency-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.agency-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.agency-badges .listing-badge {
  font-size: 9px;
  padding: 3px 6px;
}

.toggle-section {
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.agency-has-banner .toggle-section {
  color: var(--agency-banner-ink);
}

.agency-has-banner .toggle-section:hover {
  background: rgba(255, 255, 255, 0.18);
}

.toggle-section:hover {
  background: rgba(255, 255, 255, 0.35);
}

.agency-section.is-collapsed .listing-grid,
.agency-section.is-collapsed .agency-footer {
  display: none;
}

.agency-header h3 {
  margin: 0 0 6px;
  font-size: 22px;
}

.agency-header {
  position: sticky;
  top: 6px;
  z-index: 3;
  background: #fffaf5;
  border-radius: 16px;
  box-shadow: 0 12px 24px rgba(31, 27, 22, 0.12);
}

.agency-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.agency-footer {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 8px 0 4px;
}

.listing-grid .agency-footer {
  grid-column: 1 / -1;
}

.agency-has-banner .agency-header {
  background: var(--agency-banner-bg);
  border-bottom: none;
  padding: 12px 16px;
  border-radius: 16px;
}

.agency-has-banner .agency-header h3,
.agency-has-banner .agency-header p,
.agency-has-banner .agency-header .status {
  color: var(--agency-banner-ink);
}

.listing-card {
  text-decoration: none;
  background: #fffdfb;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(31, 27, 22, 0.08);
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  color: inherit;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.listing-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.08);
}

.listing-image {
  height: 160px;
  background: linear-gradient(135deg, #f0d9c4, #f7f0e6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--muted);
  position: relative;
}

.listing-badges {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 6px;
  z-index: 2;
}

.listing-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.listing-media-actions {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  gap: 8px;
}

.media-button {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(31, 27, 22, 0.15);
  display: grid;
  place-items: center;
  padding: 0;
}

.media-button svg {
  width: 18px;
  height: 18px;
  fill: var(--ink);
}

.media-button:hover {
  background: white;
}

.media-button.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}


.listing-body {
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.listing-agent {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  background: #ffe652;
  padding: 12px 16px;
  font-size: 13px;
}

.listing-card.brand-colored .listing-agent {
  background: var(--agency-banner-bg);
  color: var(--agency-banner-ink);
}

.listing-card.brand-colored .agent-avatar {
  background: var(--agency-banner-ink);
  color: var(--agency-banner-bg);
}

.listing-agent.no-agent {
  background: #eee9e1;
  grid-template-columns: 12px 1fr auto;
}

.listing-agent.no-agent .agent-name,
.listing-agent.no-agent .agent-avatar {
  display: none;
}

.agent-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #1f1b16;
  color: #ffe652;
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.agent-name {
  font-weight: 600;
}

.agent-brand {
  font-weight: 700;
  letter-spacing: 0.04em;
}

.listing-detail {
  padding: 14px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.listing-card.no-agent .listing-detail {
  padding-top: 18px;
}

.listing-price {
  font-weight: 600;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.listing-badge {
  background: #1f1b16;
  color: #fffdfb;
  font-size: 10px;
  letter-spacing: 0.08em;
  padding: 4px 8px;
  border-radius: 999px;
  text-transform: uppercase;
}

.listing-badge--new {
  background: #15803d;
}

.listing-badge--updated {
  background: #d97706;
}

.listing-badge--removed {
  background: #dc2626;
}

.listing-badge--hidden {
  background: #6b7280;
}

.listing-address {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.listing-card.is-removed {
  opacity: 1;
  filter: none;
}

.listing-card.is-removed .listing-image img {
  opacity: 0.6;
  filter: grayscale(0.15);
}

.listing-card.is-removed .listing-agent,
.listing-card.is-removed .listing-detail > :not(.listing-actions) {
  opacity: 0.6;
}

.listing-card.is-removed:hover {
  transform: none;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.06);
}

.listing-card .airtable-add.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.listing-image.is-updated,
.listing-agent.is-updated,
.listing-price.is-updated,
.listing-address.is-updated,
.listing-amenities .is-updated,
.listing-inspection.is-updated,
.listing-auction.is-updated {
  background: rgba(217, 119, 6, 0.16);
  border-radius: 10px;
  padding: 2px 6px;
}

.listing-image.is-updated {
  padding: 0;
}

.listing-amenities .is-updated {
  padding: 2px 6px;
}

.listing-amenities {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}

.listing-created {
  margin-left: auto;
}

.listing-inspection {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  border-top: 1px solid rgba(31, 27, 22, 0.08);
  padding-top: 8px;
}

.listing-auction {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.listing-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: auto;
}

.listing-action-secondary {
  padding: 6px 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.listing-card.is-hidden {
  opacity: 0.7;
}

.airtable-add {
  background: #1e6a43;
  color: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 10px 20px rgba(30, 106, 67, 0.25);
  cursor: pointer;
  opacity: 1;
}

.airtable-add:hover {
  background: #155a36;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  z-index: 50;
}

.modal[aria-hidden="false"] {
  display: grid;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.modal-content {
  position: relative;
  background: white;
  border-radius: 18px;
  padding: 16px;
  width: min(90vw, 860px);
  max-height: 90vh;
  overflow: hidden;
  display: grid;
  gap: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
}

.modal-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.icon-button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(31, 27, 22, 0.15);
  background: #f8f4ef;
  font-size: 20px;
  padding: 0;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid rgba(31, 27, 22, 0.15);
  font-size: 20px;
  line-height: 1;
  padding: 0;
}

.modal-body {
  display: grid;
  place-items: center;
  background: #f6efe7;
  border-radius: 14px;
  min-height: 320px;
}

.modal-body img {
  max-width: 100%;
  max-height: 60vh;
  object-fit: contain;
}

.settings-body {
  background: #fffdf9;
  border-radius: 14px;
  padding: 16px;
  border: 1px solid rgba(31, 27, 22, 0.08);
}

.settings-note {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.status.good {
  color: #1e6a43;
}

.status.bad {
  color: #a43b2d;
}

.status.bad .status-icon {
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.airtable-add-form--compact .airtable-add-fields {
  display: none;
}

#airtableAddForm .status {
  display: none;
}

#airtableAddForm.airtable-add-form--compact .status,
#airtableAddForm.airtable-add-form--status .status {
  display: inline-flex;
}

.airtable-add-form--compact .form-actions {
  justify-content: flex-end;
}

.airtable-add-form--compact #airtableAddConfirm {
  display: none;
}

.modal-thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.thumb {
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 0;
  background: transparent;
}

.thumb img {
  width: 70px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.thumb.active {
  border-color: var(--accent);
}

@media (max-width: 720px) {
  .hero {
    padding-top: 48px;
  }

  .hero-actions {
    width: 100%;
  }

  button {
    width: 100%;
  }

  .media-button,
  .icon-button,
  .modal-close {
    width: 34px;
  }

  .form-actions {
    flex-direction: column;
  }
}
