:root {
  --navy: #1a2744;
  --navy-deep: #121c32;
  --gold: #b8956a;
  --gold-light: #d4b896;
  --cream: #f5f0e8;
  --cream-dark: #ebe4d8;
  --white: #ffffff;
  --text-muted: #5c6478;
  --shadow: 0 12px 40px rgba(26, 39, 68, 0.12);
  --radius: 12px;
  --font-serif: "Cormorant Garamond", Georgia, serif;
  --font-sans: "DM Sans", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-sans);
  color: var(--navy);
  background: var(--cream);
}

body.page-app {
  background: var(--cream) url("/static/bg-farol-barra.png") center bottom / cover no-repeat fixed;
}

body.page-app #app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.hidden {
  display: none !important;
}

/* —— Login —— */
.page-login {
  min-height: 100vh;
  background: var(--cream) url("/static/bg-farol-barra.png") center bottom / cover no-repeat;
  position: relative;
}

.page-login::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(245, 240, 232, 0.94) 0%,
    rgba(245, 240, 232, 0.72) 40%,
    rgba(245, 240, 232, 0.45) 100%
  );
}

.brand-logo {
  display: block;
  height: auto;
  max-width: min(280px, 72vw);
}

.brand-mark {
  display: block;
  height: auto;
  max-width: 220px;
}

.login-brand-top {
  position: relative;
  z-index: 1;
  padding: 2rem 2.5rem 0.5rem;
}

.login-brand-top .brand-logo {
  max-width: 240px;
}

.login-card-wrap {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 120px);
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 2rem 2rem;
  text-align: center;
}

.login-card-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 0.35rem;
}

.login-card-logo .brand-logo {
  max-width: 260px;
}

.login-card h2 {
  margin: 0 0 0.35rem;
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 700;
}

.login-card .subtitle {
  color: var(--gold);
  font-size: 0.95rem;
  margin-bottom: 1.75rem;
}

.code-field {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid var(--cream-dark);
  border-radius: 8px;
  padding: 0 1rem;
  margin-bottom: 1rem;
  background: #fafafa;
}

.code-field svg {
  flex-shrink: 0;
  color: var(--text-muted);
}

.code-field input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.85rem 0;
  outline: none;
  letter-spacing: 0.15em;
}

.btn-primary {
  width: 100%;
  border: none;
  border-radius: 8px;
  background: var(--navy);
  color: var(--white);
  font-weight: 600;
  padding: 0.9rem 1rem;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover {
  background: var(--navy-deep);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.login-note {
  margin-top: 1.25rem;
  font-size: 0.8rem;
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.error-msg {
  color: #b42318;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

/* —— App shell —— */
.topbar {
  display: grid;
  grid-template-columns: 1fr minmax(200px, 420px) 1fr;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 2rem;
  background: var(--cream);
  border-bottom: 1px solid var(--cream-dark);
}

.topbar-rich {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(245, 240, 232, 0.9) 100%);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(184, 149, 106, 0.35);
  box-shadow: 0 8px 32px rgba(26, 39, 68, 0.07);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-brand {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.topbar-brand .brand-logo {
  max-width: 200px;
}

.search-wrap {
  position: relative;
}

.search-wrap svg {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-wrap input {
  width: 100%;
  border: 1px solid var(--cream-dark);
  border-radius: 999px;
  padding: 0.65rem 1rem 0.65rem 2.75rem;
  background: var(--white);
  outline: none;
}

.search-wrap input:focus {
  border-color: var(--gold);
}

.topbar-meta {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.topbar-meta .count {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-ghost {
  border: 1px solid var(--cream-dark);
  background: var(--white);
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
}

.btn-ghost:hover {
  border-color: var(--gold);
}

.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  flex: 1;
  width: 100%;
}

.main-content-bg {
  padding-top: 1.5rem;
}

.page-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
}

.page-title {
  font-family: var(--font-serif);
  font-size: 2.25rem;
  font-weight: 600;
  margin: 0 0 1.5rem;
}

.grid-houses {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.card-house {
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(26, 39, 68, 0.08);
  transition: transform 0.15s, box-shadow 0.15s;
  cursor: pointer;
  position: relative;
}

.card-house:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.card-house-media {
  position: relative;
}

.card-house img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
}

.card-house-body {
  padding: 1rem 1.1rem 1.1rem;
}

.card-house .badge-tipo {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 2;
  background: var(--navy);
  color: var(--white);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.35rem 0.6rem;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.card-house-body .card-id {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 0.25rem;
}

.card-house address {
  font-style: normal;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.35;
}

.tag-status {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 2;
  font-size: 0.72rem;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 0.25rem;
  max-width: calc(100% - 5rem);
  box-shadow: 0 2px 10px rgba(26, 39, 68, 0.15);
}

.tag-status.tag-disponivel,
.tag-status.tag-para-alugar,
.tag-status.tag-para-venda {
  background: rgba(232, 248, 237, 0.95);
  color: #1a6b3c;
  font-weight: 600;
  border: 1px solid rgba(46, 204, 113, 0.45);
}

.tag-status.tag-alugada,
.pill-alugada {
  background: rgba(255, 248, 220, 0.95);
  color: #8a6d00;
  border: 1px solid rgba(234, 179, 8, 0.45);
}

.pill-alugada .dot {
  background: #eab308;
}

.tag-status.tag-vendida,
.pill-vendida {
  background: rgba(254, 235, 235, 0.95);
  color: #9b1c1c;
  border: 1px solid rgba(239, 68, 68, 0.45);
}

.pill-vendida .dot {
  background: #ef4444;
}

.pill-para-alugar .dot,
.pill-para-venda .dot {
  background: #2ecc71;
}

.pill-status.pill-disponivel .dot {
  background: #2ecc71;
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  align-items: center;
}

/* —— Property detail —— */
.detail-header {
  background: var(--navy);
  color: var(--white);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.detail-header-rich {
  background: linear-gradient(135deg, var(--navy-deep) 0%, var(--navy) 55%, #243556 100%);
  border-bottom: 3px solid var(--gold);
  box-shadow: 0 12px 40px rgba(18, 28, 50, 0.35);
  position: sticky;
  top: 0;
  z-index: 25;
}

.detail-header-center {
  flex: 1;
  text-align: center;
  min-width: 200px;
}

.detail-header-id {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-light);
  margin-bottom: 0.2rem;
}

.detail-header a.back {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  opacity: 0.95;
}

.detail-header a.back:hover {
  opacity: 1;
  text-decoration: underline;
}

.detail-header h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 600;
  flex: 1;
  text-align: center;
}

.pill-status {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.pill-status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 2rem;
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem;
  flex: 1;
  width: 100%;
}

.section-title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  margin: 0 0 1rem;
  font-weight: 600;
}

.property-fields {
  margin-top: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sidebar-card {
  margin-top: 1rem;
  background: var(--white);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: 0 2px 12px rgba(26, 39, 68, 0.06);
  border: 1px solid rgba(184, 149, 106, 0.2);
}

.sidebar-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.sidebar-card-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--navy);
  display: block;
  margin-bottom: 0.35rem;
}

.sidebar-card-head .sidebar-card-title {
  margin-bottom: 0;
}

.address-display {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--navy);
}

.address-edit {
  margin-bottom: 0.5rem;
}

.btn-icon-edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--cream-dark);
  border-radius: 8px;
  background: var(--white);
  color: var(--gold);
  cursor: pointer;
  flex-shrink: 0;
}

.btn-icon-edit:hover {
  border-color: var(--gold);
  background: rgba(184, 149, 106, 0.1);
}

.btn-save-card {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
}

.field-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.field-select,
.field-input {
  font-size: 0.95rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: normal;
  color: var(--navy);
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--cream-dark);
  border-radius: 8px;
  background: var(--white);
}

.field-select:focus,
.field-input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(184, 149, 106, 0.2);
}

.detail-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sidebar-card[hidden],
.detail-panel[hidden] {
  display: none !important;
}

.detail-panel .detail-panel-title {
  margin: 0;
}

.detail-panel-venda {
  border-color: rgba(239, 68, 68, 0.25);
}

.detail-panel-title {
  margin: 0 0 0.75rem;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  color: var(--navy);
}

.panel-hint {
  margin: 0.5rem 0 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.btn-panel {
  width: 100%;
  margin-top: 0.5rem;
  justify-content: center;
}

.inline-doc-list {
  margin-bottom: 0.75rem;
}

.inline-doc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--cream-dark);
  font-size: 0.85rem;
}

.upload-zone-compact {
  margin-top: 0;
  padding: 0.75rem;
}

.upload-zone-compact input[type="file"] {
  margin-top: 0.35rem;
  font-size: 0.8rem;
}

.detail-sidebar .brand-block {
  margin-bottom: 1.25rem;
}

.detail-sidebar .brand-block .logo-text {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  letter-spacing: 0.12em;
  color: var(--gold);
}

.detail-sidebar .brand-block .tagline {
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.detail-photo {
  width: 100%;
  border-radius: var(--radius);
  aspect-ratio: 4/3;
  object-fit: cover;
  box-shadow: var(--shadow);
}

.stats-card {
  margin-top: 1rem;
  background: var(--white);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1rem;
  font-size: 0.9rem;
  box-shadow: 0 2px 12px rgba(26, 39, 68, 0.06);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stat-item svg {
  color: var(--gold);
  flex-shrink: 0;
}

.stat-item.full {
  grid-column: 1 / -1;
}

.doc-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
}

.doc-btn {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1.1rem;
  background: var(--white);
  border: 1px solid var(--cream-dark);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-height: 72px;
}

.doc-btn:hover {
  border-color: var(--gold);
  box-shadow: 0 4px 16px rgba(26, 39, 68, 0.08);
}

.doc-btn svg {
  color: var(--gold);
  flex-shrink: 0;
}

.doc-btn .label {
  font-weight: 600;
  font-size: 0.95rem;
}

.doc-btn .count {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.detail-footer {
  border-top: 1px solid var(--cream-dark);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 1100px;
  margin: 0 auto 2rem;
}

/* —— Modal —— */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(18, 28, 50, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.modal {
  background: var(--white);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--cream-dark);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.35rem;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
}

.file-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
}

.file-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--cream-dark);
}

.file-list a {
  color: var(--navy);
  font-weight: 500;
  word-break: break-all;
}

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

.upload-zone {
  border: 2px dashed var(--cream-dark);
  border-radius: 8px;
  padding: 1.25rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.upload-zone input {
  margin-top: 0.5rem;
}

.empty-files {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* —— Form modal (add house) —— */
.form-grid {
  display: grid;
  gap: 0.75rem;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  font-weight: 500;
}

.form-grid input,
.form-grid select {
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--cream-dark);
  border-radius: 6px;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.modal-wide {
  max-width: 920px;
}

.file-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.file-thumb {
  position: relative;
  border: 1px solid var(--cream-dark);
  border-radius: 8px;
  overflow: hidden;
  background: #fafafa;
  cursor: grab;
}

.file-thumb img,
.file-thumb video {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
}

.file-thumb-actions,
.file-row-actions {
  display: flex;
  gap: 0.25rem;
  padding: 0.4rem;
  flex-wrap: wrap;
}

a.btn-dl {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

.file-row {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--cream-dark);
}

.viewer-body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 50vh;
}

.viewer-media {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 8px;
}

.viewer-pdf {
  width: 100%;
  height: 70vh;
  border: none;
  border-radius: 8px;
}

.cover-drop {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
}

.cover-drop-active {
  outline: 3px dashed var(--gold);
  outline-offset: 4px;
}

.cover-hint {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  margin: 0;
  padding: 0.5rem;
  font-size: 0.75rem;
  text-align: center;
  color: var(--white);
  background: linear-gradient(transparent, rgba(26, 39, 68, 0.75));
}

.cover-hint-inline {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 1rem;
}

.modal-cover-drop {
  position: relative;
  margin-bottom: 1rem;
  padding: 0.5rem;
  border: 2px dashed var(--gold);
  border-radius: var(--radius);
  background: rgba(184, 149, 106, 0.08);
  text-align: center;
}

.modal-cover-drop.cover-drop-active {
  background: rgba(184, 149, 106, 0.2);
  box-shadow: 0 0 0 3px rgba(184, 149, 106, 0.35);
}

.modal-cover-preview {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.file-thumb-cover {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(184, 149, 106, 0.35);
}

.file-thumb-cover-slot.cover-drop-active {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.file-thumb-dragging {
  opacity: 0.55;
}

.cover-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  background: var(--gold);
  color: var(--white);
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .topbar-brand,
  .topbar-meta {
    justify-content: center;
    justify-self: center;
  }

  .detail-layout {
    grid-template-columns: 1fr;
  }

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

  .detail-header h1 {
    order: 3;
    width: 100%;
    text-align: left;
  }
}
