:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --text: #0f172a;
  --muted: #475569;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --primary: #0b4479;
  --primary-dark: #072f56;
  --primary-hover: #093864;
  --primary-accent: #1d70b8;
  --primary-soft: #eff6ff;
  --cyan-badge: #0284c7;
  --danger: #dc2626;
  --success: #15803d;
  --warning: #b45309;
  --radius: 10px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.09);
}

* { box-sizing: border-box; }
::selection { background: #bfdbfe; color: #0f172a; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.tabular { font-variant-numeric: tabular-nums; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--primary-accent);
  outline-offset: 2px;
}

.topbar {
  background: var(--primary-dark);
  color: #fff;
  padding: 0 1.5rem;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}
.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
}
.topbar-toggle {
  display: none;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  font-size: 1.08rem;
  color: #fff;
  letter-spacing: -0.01em;
}
.topbar-logo {
  height: 30px;
  width: auto;
  display: block;
}
.topbar-brand-tag {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.16rem 0.48rem;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}
.login-logo {
  height: 44px;
  width: auto;
  display: block;
  margin: 0 auto 1rem;
}
.topbar-brand:hover { text-decoration: none; opacity: 0.95; }

.topbar-nav { display: flex; gap: 0.35rem; align-items: center; flex-wrap: wrap; }
.topbar-nav a {
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.88rem;
  font-weight: 500;
  padding: 0.44rem 0.78rem;
  border-radius: 6px;
  transition: background-color 150ms ease, color 150ms ease;
}
.topbar-nav a:hover { background: rgba(255, 255, 255, 0.12); color: #fff; text-decoration: none; }
.topbar-nav a.active { background: rgba(255, 255, 255, 0.2); color: #fff; }
.topbar-user-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.topbar-user {
  font-size: 0.84rem;
  color: rgba(255, 255, 255, 0.82);
  padding: 0 0.6rem;
  border-left: 1px solid rgba(255, 255, 255, 0.22);
}

@media (max-width: 860px) {
  .topbar {
    display: block;
    padding: 0 1rem;
  }
  .topbar-toggle { display: inline-flex; }
  .topbar-nav {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    padding: 0.5rem 0 0.9rem;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
  }
  .topbar-nav.is-open { display: flex; }
  .topbar-nav a {
    padding: 0.65rem 0.75rem;
    font-size: 0.95rem;
  }
  .topbar-user-group {
    margin-top: 0.4rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
    justify-content: space-between;
  }
  .topbar-user {
    border-left: none;
    padding: 0 0.75rem;
  }
}

.container { max-width: 1320px; margin: 1.5rem auto; padding: 0 1.25rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.15rem;
  box-shadow: var(--shadow-sm);
}

/* Barra de pesquisa principal estilo portal */
.search-hero {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  border-radius: 14px;
  padding: 1.35rem 1.5rem 1.25rem;
  margin-bottom: 1.15rem;
  box-shadow: var(--shadow-md);
  color: #fff;
}
.search-mode-tabs {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
  flex-wrap: wrap;
}
.mode-tab {
  padding: 0.42rem 1.15rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.14);
  transition: background-color 150ms ease, transform 150ms ease;
}
.mode-tab:hover { background: rgba(255, 255, 255, 0.24); color: #fff; text-decoration: none; }
.mode-tab.active { background: var(--primary-accent); color: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22); }

.search-pill-bar {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 0.45rem;
  display: grid;
  grid-template-columns: 1.1fr 1.1fr 0.85fr 0.9fr auto;
  gap: 0.45rem;
  align-items: center;
}
.pill-field select,
.pill-field input {
  width: 100%;
  height: 44px;
  border: none;
  border-radius: 999px;
  padding: 0 1rem;
  font-size: 0.88rem;
  color: var(--text);
  background: #fff;
}
.pill-submit {
  height: 44px;
  padding: 0 1.65rem;
  border: none;
  border-radius: 999px;
  background: var(--primary-accent);
  color: #fff;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 150ms ease;
}
.pill-submit:hover { background: #155a96; }

/* Atalhos rápidos separados e identificados */
.quick-filters-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
  margin-bottom: 1.15rem;
  box-shadow: var(--shadow-sm);
}
.quick-filters-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}
.quick-filters-label {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.quick-filters-list {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.preset-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.42rem 0.9rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
  transition: all 150ms ease;
}
.preset-chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); text-decoration: none; }
.preset-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }

.filter-accordion-toggle {
  display: none;
  width: 100%;
  padding: 0.7rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

@media (max-width: 768px) {
  .container { margin: 1rem auto; padding: 0 0.85rem; }
  .search-hero { padding: 1rem; border-radius: 12px; }
  .search-mode-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
    margin-bottom: 0.75rem;
  }
  .mode-tab {
    padding: 0.48rem 0.35rem;
    font-size: 0.72rem;
    text-align: center;
    white-space: nowrap;
  }
  .pill-field select,
  .pill-field input,
  .sidebar-group input[type="text"],
  .sidebar-group input[type="number"],
  .sidebar-group select,
  .form-group input,
  .form-group select {
    font-size: 16px;
  }
  .quick-filters-bar { padding: 0.85rem; }
  .quick-filters-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.45rem;
  }
  .preset-chip {
    padding: 0.5rem 0.5rem;
    font-size: 0.8rem;
    text-align: center;
  }
  .filter-accordion-toggle { display: flex; }
  .filter-sidebar { display: none; }
  .filter-sidebar.is-open { display: block; margin-bottom: 1rem; }
  .bar-row { grid-template-columns: 105px 1fr 48px; gap: 0.5rem; }
  .results-bar { flex-direction: column; align-items: stretch; }
}

/* Layout 2 colunas: Sidebar esquerda + Resultados */
.inventory-layout {
  display: grid;
  grid-template-columns: 270px 1fr;
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 960px) {
  .inventory-layout { grid-template-columns: 1fr; }
}
.filter-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 1rem;
}
@media (max-width: 960px) {
  .filter-sidebar { position: static; }
}
.sidebar-title {
  font-size: 0.92rem;
  font-weight: 700;
  margin: 0 0 0.9rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sidebar-group { margin-bottom: 0.95rem; }
.sidebar-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.3rem;
}
.sidebar-group input[type="text"],
.sidebar-group input[type="number"],
.sidebar-group select {
  width: 100%;
  height: 36px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 0 0.65rem;
  font-size: 0.85rem;
  color: var(--text);
  background: #fff;
}

/* Dual range slider */
.range-values {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin-bottom: 0.5rem;
}
.range-slider-wrap {
  position: relative;
  height: 26px;
  display: flex;
  align-items: center;
}
.range-track-bg {
  position: absolute;
  left: 0; right: 0;
  height: 5px;
  background: var(--surface-alt);
  border-radius: 999px;
}
.range-track-fill {
  position: absolute;
  height: 5px;
  background: var(--primary-accent);
  border-radius: 999px;
}
.range-slider-wrap input[type="range"] {
  position: absolute;
  left: 0; width: 100%;
  margin: 0;
  background: none;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}
.range-slider-wrap input[type="range"]::-webkit-slider-thumb {
  pointer-events: auto;
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.28);
  cursor: pointer;
}
.range-slider-wrap input[type="range"]::-moz-range-thumb {
  pointer-events: auto;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.28);
  cursor: pointer;
}

@media (max-width: 900px) {
  .search-pill-bar {
    grid-template-columns: 1fr;
    border-radius: 16px;
    padding: 0.65rem;
  }
}

/* Painel analítico com gráficos */
.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 860px) {
  .analytics-grid { grid-template-columns: 1fr; }
}
.analytics-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  box-shadow: var(--shadow-sm);
}
.analytics-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.8rem;
}
.analytics-title { font-size: 0.9rem; font-weight: 700; color: var(--text); margin: 0; }
.analytics-sub { font-size: 0.78rem; color: var(--muted); }

.bar-list { display: flex; flex-direction: column; gap: 0.55rem; }
.bar-row {
  display: grid;
  grid-template-columns: 130px 1fr 68px;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.82rem;
  color: var(--text);
}
.bar-row:hover { text-decoration: none; color: var(--primary); }
.bar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.bar-track {
  display: block;
  height: 10px;
  background: var(--surface-alt);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  display: block;
  height: 100%;
  background: var(--primary-accent);
  border-radius: 999px;
}
.bar-fill.alt { background: var(--primary); }
.bar-count { text-align: right; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.95rem;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  transition: background-color 150ms ease, border-color 150ms ease;
}
.btn:hover { background: var(--primary-hover); text-decoration: none; }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-alt); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 0.38rem 0.8rem; font-size: 0.82rem; }
.btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.75rem;
  align-items: end;
}
.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.form-group input, .form-group select {
  width: 100%;
  padding: 0.48rem 0.65rem;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 0.88rem;
  background: #fff;
  color: var(--text);
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

.badge {
  display: inline-block;
  padding: 0.16rem 0.55rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-error { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-muted { background: #e2e8f0; color: #334155; }

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.02em; }

.results-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
  font-size: 0.9rem;
  color: var(--muted);
}

/* Cards de imóveis padronizados */
.property-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(295px, 1fr));
  gap: 1.15rem;
}
.property-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 180ms ease, border-color 180ms ease, transform 180ms ease;
}
.property-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); transform: translateY(-2px); }

.property-thumb-wrap { position: relative; aspect-ratio: 16 / 10; background: var(--surface-alt); overflow: hidden; }
.property-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.property-thumb-empty {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 0.85rem;
}
.property-overlay-badges {
  position: absolute;
  left: 0.65rem;
  bottom: 0.65rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
}
.badge-overlay-primary {
  background: var(--primary);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.22rem 0.6rem;
  border-radius: 5px;
}
.badge-overlay-city {
  background: var(--cyan-badge);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 5px;
}
.badge-overlay-top {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  background: rgba(15, 23, 42, 0.78);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.55rem;
  border-radius: 5px;
}

.property-body { padding: 1rem 1.05rem 1.05rem; flex: 1; display: flex; flex-direction: column; gap: 0.45rem; }
.property-neighborhood {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.25;
}
.property-subtitle {
  font-size: 0.84rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.35em;
}
.property-ref-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--muted);
  padding: 0.45rem 0;
  border-top: 1px dashed var(--border);
  border-bottom: 1px dashed var(--border);
  font-variant-numeric: tabular-nums;
}
.property-specs {
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--text);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.spec-item { display: inline-flex; align-items: center; gap: 0.3rem; }

.property-price-block { margin-top: 0.15rem; }
.property-price-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--primary); }
.property-price { font-size: 1.2rem; font-weight: 700; color: var(--primary-dark); font-variant-numeric: tabular-nums; line-height: 1.2; }
.property-subprice { font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.property-footer {
  margin-top: auto;
  padding-top: 0.7rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.property-provider { font-size: 0.77rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin-top: 1.6rem;
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}
.pagination-ellipsis { padding: 0 0.35rem; color: var(--muted); }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
}

.login-box { max-width: 400px; margin: 4.5rem auto; }
