:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #5f6b7a;
  --line: #d9dee6;
  --line-strong: #bac4d1;
  --accent: #0f766e;
  --accent-2: #1f5fbf;
  --ok: #177245;
  --warn: #a15c06;
  --bad: #b42318;
  --soft-ok: #e8f5ee;
  --soft-warn: #fff4df;
  --soft-bad: #fdeceb;
  --shadow: 0 18px 55px rgba(23, 32, 42, 0.13);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px clamp(18px, 4vw, 46px);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 24px;
  line-height: 1.15;
  margin-bottom: 18px;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

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

.timestamp,
.source-state {
  color: var(--muted);
  font-size: 13px;
}

.button,
.row-button {
  border: 1px solid var(--accent);
  color: #ffffff;
  background: var(--accent);
  min-height: 40px;
  border-radius: 6px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 750;
}

.button:disabled {
  cursor: progress;
  opacity: 0.7;
}

main {
  padding: 22px clamp(14px, 4vw, 46px) 42px;
}

.status-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 44px;
  margin-bottom: 16px;
}

.load-state {
  color: var(--text);
  font-weight: 700;
}

.load-state.is-loading::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border-radius: 999px;
  background: var(--accent-2);
  animation: pulse 1s infinite ease-in-out;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 15px;
  min-height: 92px;
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  font-size: 30px;
  line-height: 1;
  margin-top: 12px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.expedient-refresh {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  margin-bottom: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.expedient-refresh__state {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.tabs--areas {
  max-width: 100%;
  flex-wrap: wrap;
}

.tab {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.tab.is-active {
  background: var(--accent);
  color: #ffffff;
}

.area-summary {
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) minmax(300px, 1.8fr);
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.area-summary[hidden] {
  display: none;
}

.area-summary__text,
.area-summary__warning {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.area-summary__text a {
  color: var(--accent-2);
  font-weight: 750;
  text-decoration: none;
}

.area-summary__warning {
  margin-top: 8px;
  color: var(--warn);
}

.new-promotion-panel {
  margin-bottom: 16px;
  padding: 16px;
  border: 2px solid #d97706;
  border-radius: 8px;
  background: #fff8ea;
  box-shadow: 0 14px 34px rgba(161, 92, 6, 0.16);
}

.new-promotion-panel[hidden] {
  display: none;
}

.new-promotion-panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.new-promotion-panel h2 {
  margin: 0;
  font-size: 22px;
}

.new-promotion-panel__date {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 0 11px;
  color: #7c3d00;
  background: #ffe3ad;
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.new-promotion-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.new-promotion-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 76px;
  padding: 12px;
  border: 1px solid #f1be69;
  border-radius: 8px;
  background: var(--panel);
}

.new-promotion-item strong,
.new-promotion-item span {
  display: block;
}

.new-promotion-item strong {
  line-height: 1.2;
}

.new-promotion-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.new-promotion-item .row-button {
  flex: 0 0 auto;
}

.promoter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: flex-end;
}

.promoter-chips span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  color: var(--muted);
  background: #fafbfc;
  font-size: 12px;
  font-weight: 750;
}

.view[hidden] {
  display: none;
}

.toolbar--promos {
  grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(140px, 1fr));
}

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

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.field input,
.field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 11px;
  color: var(--text);
  background: var(--panel);
}

.table-shell {
  position: relative;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

table {
  width: 100%;
  min-width: 1060px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
}

th {
  color: var(--muted);
  background: #f0f3f6;
  font-size: 12px;
  font-weight: 850;
  position: sticky;
  top: 0;
  z-index: 2;
  text-transform: uppercase;
  white-space: nowrap;
}

th[data-sort] {
  cursor: pointer;
}

td {
  font-size: 14px;
}

tr:hover td {
  background: #fafbfc;
}

.address {
  display: grid;
  gap: 4px;
}

.address small,
.muted {
  color: var(--muted);
}

.num {
  text-align: right;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.badge--pendiente {
  color: var(--warn);
  background: var(--soft-warn);
}

.badge--concedido {
  color: var(--ok);
  background: var(--soft-ok);
}

.badge--dr {
  color: var(--accent-2);
  background: #eaf1ff;
}

.badge--cerrado {
  color: var(--bad);
  background: var(--soft-bad);
}

.badge--area {
  color: var(--text);
  background: #eef2f6;
}

.badge--reservas_abiertas {
  color: var(--ok);
  background: var(--soft-ok);
}

.badge--ultimas_viviendas,
.badge--proximamente,
.badge--sin_info {
  color: var(--warn);
  background: var(--soft-warn);
}

.badge--vendido {
  color: var(--bad);
  background: var(--soft-bad);
}

.promo-badge {
  align-self: flex-start;
  white-space: nowrap;
}

.row-button {
  min-height: 32px;
  padding-inline: 11px;
  background: transparent;
  color: var(--accent);
}

.empty {
  color: var(--muted);
  padding: 34px;
  text-align: center;
}

.promotion-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 16px;
}

.promo-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  min-height: 520px;
  display: grid;
  grid-template-rows: 210px 1fr;
}

.promo-card--new {
  border: 2px solid #d97706;
  box-shadow: 0 14px 34px rgba(161, 92, 6, 0.16);
}

.promo-card__media {
  position: relative;
  overflow: hidden;
  background: #e9edf2;
}

.promo-card__media img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.promo-card__media--empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

.flag {
  position: absolute;
  top: 12px;
  left: 12px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  color: #ffffff;
  background: rgba(23, 32, 42, 0.78);
  font-size: 12px;
  font-weight: 850;
}

.seen-chip {
  position: absolute;
  right: 12px;
  bottom: 12px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  color: #ffffff;
  background: rgba(23, 32, 42, 0.78);
  font-size: 12px;
  font-weight: 850;
}

.seen-chip--new {
  background: #b45309;
}

.new-ribbon {
  position: absolute;
  top: 12px;
  right: 12px;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 12px;
  color: #ffffff;
  background: #d97706;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.promo-card__body {
  display: grid;
  grid-template-rows: auto auto minmax(66px, auto) auto auto auto;
  gap: 12px;
  padding: 16px;
}

.promo-card__head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.promo-card h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.15;
}

.promo-meta,
.promo-desc {
  color: var(--muted);
  line-height: 1.45;
}

.promo-desc {
  color: var(--text);
}

.promo-facts,
.chips,
.promo-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.promo-facts span,
.chips span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  color: var(--muted);
  background: #fafbfc;
  font-size: 12px;
  font-weight: 750;
}

.promo-facts span {
  color: var(--text);
  background: #f0f7f6;
  border-color: #cde5e1;
}

.promo-actions {
  align-self: end;
  justify-content: space-between;
}

.external-link {
  color: var(--accent-2);
  font-weight: 800;
  text-decoration: none;
}

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

.detail {
  position: fixed;
  inset: 0;
  z-index: 30;
}

.detail__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 32, 42, 0.35);
}

.detail__card {
  position: absolute;
  inset: 22px 22px 22px auto;
  width: min(660px, calc(100vw - 44px));
  overflow: auto;
  background: var(--panel);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.detail__close {
  position: sticky;
  top: 0;
  float: right;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--panel);
  cursor: pointer;
  color: var(--muted);
}

.detail-section {
  padding-block: 16px;
  border-top: 1px solid var(--line);
}

.detail-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.detail-gallery img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 6px;
  background: #e9edf2;
}

.detail-section h3 {
  margin: 0 0 10px;
  font-size: 14px;
  text-transform: uppercase;
  color: var(--muted);
}

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

.doc-list a {
  color: var(--accent-2);
  font-weight: 700;
  text-decoration: none;
}

.doc-list a:hover {
  text-decoration: underline;
}

.kv {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 10px;
  margin-bottom: 8px;
}

.kv dt {
  color: var(--muted);
  font-weight: 750;
}

.kv dd {
  margin: 0;
}

@media (max-width: 920px) {
  .topbar,
  .status-strip,
  .expedient-refresh {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar__actions {
    justify-content: flex-start;
  }

  .metrics,
  .toolbar,
  .area-summary {
    grid-template-columns: 1fr 1fr;
  }

  .promoter-chips {
    justify-content: flex-start;
  }

  .field--search {
    grid-column: 1 / -1;
  }
}

@media (max-width: 620px) {
  .metrics,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .tabs {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .area-summary {
    grid-template-columns: 1fr;
  }

  .new-promotion-panel__head,
  .new-promotion-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .promotion-grid {
    grid-template-columns: 1fr;
  }

  .promo-card {
    min-height: auto;
    grid-template-rows: 190px 1fr;
  }

  .topbar {
    position: static;
  }

  .detail__card {
    inset: 10px;
    width: auto;
    padding: 18px;
  }

  .kv {
    grid-template-columns: 1fr;
    gap: 3px;
  }
}
