.archive-shell { padding-bottom: calc(34px + env(safe-area-inset-bottom)); }
.archive-hero { padding-bottom: 16px; }

.archive-toolbar { display: grid; gap: 14px; }
.archive-toolbar p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.periods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.period {
  min-height: 39px;
  border: 1px solid #d8ddd9;
  border-radius: 11px;
  color: var(--text);
  background: transparent;
  font-size: 13px;
  font-weight: 700;
}
.period.selected { border-color: var(--accent); color: #fff; background: var(--accent); }

.archive-views {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;
  padding: 4px;
  border-radius: 13px;
  background: color-mix(in srgb, var(--text) 7%, transparent);
}
.archive-view {
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 800;
}
.archive-view.selected {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 3px 12px rgb(15 30 20 / 9%);
}

.archive-message {
  display: none;
  margin: 14px 2px;
  padding: 16px;
  border-radius: 15px;
  color: var(--muted);
  background: var(--surface);
  font-size: 14px;
  line-height: 1.45;
  text-align: center;
}
.archive-message.visible { display: block; }
.archive-message.error { color: #9a2f2f; background: #ffe9e7; }

.archive-results { display: grid; gap: 13px; margin-top: 13px; }
.archive-load-more {
  width: 100%;
  min-height: 46px;
  margin-top: 14px;
  border: 1px solid var(--accent);
  border-radius: 13px;
  color: var(--accent);
  background: var(--surface);
  font-size: 14px;
  font-weight: 800;
}
.archive-load-more.hidden { display: none; }
.archive-load-more:disabled { cursor: wait; opacity: .65; }
.archive-results.hidden,
.archive-map-panel.hidden { display: none; }
.listing-card { overflow: hidden; padding: 0; }

.archive-shell.map-view { width: min(100%, 980px); }
.archive-map-panel { margin-top: 13px; }
.archive-map-frame {
  position: relative;
  overflow: hidden;
  height: min(68vh, 680px);
  min-height: 480px;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: #e8ece9;
  box-shadow: var(--shadow);
}
.archive-map { width: 100%; height: 100%; }
.archive-map-search {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 3;
  min-height: 40px;
  padding: 8px 15px;
  transform: translateX(-50%);
  border: 0;
  border-radius: 999px;
  color: var(--accent-text);
  background: var(--accent);
  box-shadow: 0 7px 20px rgb(0 0 0 / 20%);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}
.archive-map-search.hidden { display: none; }
.archive-map-search:disabled { cursor: wait; opacity: .72; }
.archive-map-count {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  max-width: calc(100% - 24px);
  padding: 7px 10px;
  border-radius: 10px;
  color: #26332b;
  background: rgb(255 255 255 / 92%);
  box-shadow: 0 4px 14px rgb(0 0 0 / 12%);
  font-size: 11px;
  font-weight: 800;
}
.archive-map-search:not(.hidden) + .archive-map-count { top: 61px; }
.archive-map-preview {
  position: absolute;
  right: 10px;
  bottom: 10px;
  left: 10px;
  z-index: 4;
  overflow-y: auto;
  max-height: min(45vh, 390px);
  padding: 10px;
  border: 1px solid rgb(255 255 255 / 55%);
  border-radius: 17px;
  background: rgb(250 252 250 / 96%);
  box-shadow: 0 12px 35px rgb(0 0 0 / 23%);
  backdrop-filter: blur(12px);
}
.archive-map-preview.hidden { display: none; }
.map-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  padding: 1px 2px;
  color: #26332b;
  font-size: 12px;
  font-weight: 850;
}
.map-preview-close {
  display: grid;
  flex: 0 0 30px;
  height: 30px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #26332b;
  background: rgb(20 35 25 / 8%);
  font-size: 18px;
}
.map-preview-list { display: grid; gap: 8px; }
.map-preview-card {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 11px;
  padding: 9px;
  border: 1px solid rgb(20 35 25 / 9%);
  border-radius: 13px;
  color: #26332b;
  background: #fff;
}
.map-preview-photo,
.map-preview-no-photo {
  width: 88px;
  height: 88px;
  border-radius: 10px;
  object-fit: cover;
  background: #e8ece9;
}
.map-preview-no-photo { display: grid; place-items: center; color: #69736b; font-size: 10px; }
.map-preview-content { min-width: 0; }
.map-preview-source {
  color: #16794d;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.map-preview-title {
  overflow: hidden;
  margin-top: 3px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.map-preview-price { margin-top: 5px; font-size: 17px; font-weight: 900; }
.map-preview-location,
.map-preview-facts {
  overflow: hidden;
  margin-top: 3px;
  color: #69736b;
  font-size: 10px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.map-preview-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.map-preview-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 31px;
  padding: 5px 9px;
  border: 1px solid rgb(20 35 25 / 12%);
  border-radius: 9px;
  color: #26332b;
  background: #fff;
  font-size: 10px;
  font-weight: 800;
  text-decoration: none;
}
.map-preview-action.primary { color: #fff; border-color: #16794d; background: #16794d; }
.map-preview-action.whatsapp { color: #fff; border-color: #25d366; background: #25d366; }

.maplibregl-ctrl-group {
  overflow: hidden;
  border-radius: 11px !important;
  box-shadow: 0 4px 14px rgb(0 0 0 / 14%) !important;
}
.maplibregl-ctrl-attrib { font-size: 9px; }

.listing-gallery {
  position: relative;
  display: flex;
  overflow-x: auto;
  min-height: 226px;
  background: #e8ece9;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.listing-gallery img {
  flex: 0 0 100%;
  width: 100%;
  height: 226px;
  object-fit: cover;
  scroll-snap-align: start;
}
.listing-gallery img + img { margin-left: 3px; }
.photo-count {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 5px 9px;
  border-radius: 999px;
  color: #fff;
  background: rgba(0, 0, 0, .62);
  font-size: 11px;
  font-weight: 750;
}
.no-photo {
  display: grid;
  width: 100%;
  min-height: 150px;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}

.listing-body { padding: 16px; }
.listing-source {
  color: var(--accent);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.listing-title { margin-top: 6px; font-size: 18px; line-height: 1.25; }
.listing-location,
.listing-facts,
.listing-time,
.listing-description {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}
.listing-price { margin-top: 10px; color: var(--text); font-size: 21px; font-weight: 850; }
.advertiser-badge {
  width: fit-content;
  margin-top: 9px;
  padding: 5px 8px;
  border-radius: 9px;
  color: var(--muted);
  background: color-mix(in srgb, var(--text) 7%, transparent);
  font-size: 11px;
  font-weight: 800;
}
.advertiser-badge.owner { color: #13653f; background: #ddf5e8; }
.workspace-card { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border, #ddd); }
.workspace-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.workspace-card details { margin-top: 12px; }
.workspace-card summary { cursor: pointer; font-weight: 600; padding: 8px 0; }
.workspace-card label { display: block; margin-top: 12px; }
.workspace-hint, .workspace-feedback { font-size: 12px; line-height: 1.5; margin: 8px 0; }
.workspace-history { font-size: 13px; overflow-wrap: anywhere; }
.workspace-history p { margin: 10px 0; }
.workspace-history h3 { margin-top: 16px; }
.workspace-history a { color: var(--accent, #18765a); }
.advertiser-badge.realtor { color: #8a4d0f; background: #fff0d7; }
.map-preview-content .advertiser-badge { margin-top: 5px; padding: 3px 6px; font-size: 9px; }
.listing-time { font-size: 12px; }
.listing-description { color: var(--text); }
.listing-map,
.listing-contact {
  margin-top: 12px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}
.listing-map-title,
.listing-phone { color: var(--text); font-size: 15px; font-weight: 800; }
.map-actions,
.contact-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; margin-top: 9px; }
.contact-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 39px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: var(--surface);
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  text-decoration: none;
}
.map-button { color: var(--accent); }
.whatsapp-button { grid-column: 1 / -1; color: #fff; border-color: #25d366; background: #25d366; }
.listing-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 46px;
  margin-top: 14px;
  border: 0;
  border-radius: 13px;
  color: var(--accent-text);
  background: var(--accent);
  font-size: 14px;
  font-weight: 800;
}

@media (max-width: 390px) {
  .listing-gallery,
  .listing-gallery img { height: 205px; }
  .archive-map-frame { min-height: 430px; }
  .map-preview-card { grid-template-columns: 76px minmax(0, 1fr); }
  .map-preview-photo,
  .map-preview-no-photo { width: 76px; height: 76px; }
}
