:root {
  --ink: #151515;
  --muted: #6b706d;
  --line: #dedbd3;
  --paper: #f7f4ed;
  --white: #fffefa;
  --gold: #b98945;
  --green: #24453a;
  --blue: #29465f;
  --rose: #8a4e45;
  --shadow: 0 18px 48px rgba(22, 24, 20, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.login-required { display: block; }
body.login-required .sidebar,
body.login-required .app-shell { display: none; }
body.login-required .platform-watermark { display: block; }

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at top, #3c3c3c, #111 58%);
}
body.login-required .login-screen { display: grid !important; }
.login-card {
  width: min(440px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px;
  background: var(--white);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.login-card img {
  width: 220px;
  max-width: 100%;
  justify-self: center;
  border-radius: 8px;
}

.platform-watermark {
  grid-column: 1 / -1;
  padding: 18px 24px 24px;
  text-align: center;
  color: rgba(21, 21, 21, 0.5);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  background: transparent;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  display: flex;
  flex-direction: column;
  background: #162720;
  color: var(--white);
}

.brand { display: flex; gap: 14px; align-items: center; margin-bottom: 30px; }
.brand-logo {
  width: 54px;
  height: 54px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.22);
}
.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.24);
  background: var(--gold);
  color: #111;
  font-weight: 900;
  border-radius: 8px;
}
.brand strong { display: block; font-size: 18px; }
.brand span, .side-note span { color: rgba(255,255,255,.68); font-size: 13px; }

.nav { display: grid; gap: 8px; }
.nav-item {
  width: 100%;
  border: 0;
  padding: 13px 14px;
  border-radius: 8px;
  text-align: left;
  color: rgba(255,255,255,.78);
  background: transparent;
}
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.12); color: var(--white); }

.side-note {
  margin-top: auto;
  padding: 16px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 8px;
  background: rgba(255,255,255,.08);
}
.side-note strong { display: block; margin-top: 6px; font-size: 20px; }
.logout-button {
  width: 100%;
  min-height: 42px;
  margin-top: 14px;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 8px;
  background: rgba(255,255,255,.1);
  color: var(--white);
  font-weight: 900;
}
.logout-button:hover {
  background: rgba(185, 137, 69, .28);
}

.app-shell { min-width: 0; padding: 24px; }

.hero {
  position: relative;
  min-height: 300px;
  overflow: hidden;
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.hero img { width: 100%; height: 100%; min-height: 300px; object-fit: cover; display: block; }
.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(8,16,13,.82), rgba(8,16,13,.42) 44%, rgba(8,16,13,.05));
}
.hero-content {
  position: absolute;
  left: 34px;
  bottom: 34px;
  width: min(620px, calc(100% - 68px));
  color: var(--white);
}
.hero-content p, .eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 12px;
  font-weight: 800;
  color: var(--gold);
}
.hero-content h1 { margin: 0; font-size: clamp(42px, 7vw, 76px); line-height: .92; letter-spacing: 0; }
.hero-logo {
  width: min(280px, 70vw);
  max-height: 110px;
  object-fit: cover;
  object-position: center;
  border-radius: 8px;
  margin: 4px 0 12px;
  opacity: .92;
}
.hero-content span { display: block; margin-top: 14px; max-width: 520px; color: rgba(255,255,255,.82); font-size: 17px; }

.view { display: none; padding-top: 28px; }
.view.active { display: block; }

.topbar { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
h2, h3 { margin: 0; }
h2 { font-size: 34px; }
h3 { font-size: 19px; }

.primary-action, .secondary-action, .danger-action {
  border: 0;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  font-weight: 800;
}
.primary-action { background: var(--green); color: var(--white); }
.secondary-action { background: #ece4d8; color: var(--ink); }
.danger-action { background: #f1dedb; color: #762a22; }
.action-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: end; }
.link-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.settings-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.instagram-link {
  display: inline-flex;
  margin-top: 12px;
  color: var(--white);
  font-weight: 800;
}

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.metrics article, .panel, .property-card, .match-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 26px rgba(22,24,20,.06);
}
.metrics article { padding: 18px; }
.metrics span, .panel-heading span, .property-meta, .muted { color: var(--muted); font-size: 13px; }
.metrics strong { display: block; margin-top: 10px; font-size: 24px; }

.split-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr); gap: 16px; }
.panel { padding: 18px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }

.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.form-grid.dense { grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; max-height: 78vh; overflow: auto; }
label { display: grid; gap: 7px; font-size: 13px; font-weight: 800; color: #333; }
input, textarea, select {
  width: 100%;
  min-height: 43px;
  border: 1px solid #d2cec3;
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
  color: var(--ink);
}
textarea { resize: vertical; }
.wide { grid-column: 1 / -1; }

.property-grid, .catalog-grid, .broker-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.catalog-grid { margin-bottom: 18px; }
.property-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.property-card {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.property-photo {
  flex: 0 0 174px;
  height: 174px;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #29465f, #b98945);
  display: grid;
  place-items: center;
  color: var(--white);
  font-weight: 900;
}
.property-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.property-body {
  position: relative;
  z-index: 1;
  padding: 15px;
  background: var(--white);
}
.property-body h3 { margin-bottom: 8px; }
.property-price { color: var(--green); font-size: 20px; font-weight: 900; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 0; }
.chip { padding: 6px 9px; border-radius: 999px; background: #eee8de; color: #3c3a35; font-size: 12px; font-weight: 800; }
.card-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.card-actions button {
  width: 100%;
  min-height: 42px;
  padding: 0 10px;
  white-space: normal;
  line-height: 1.15;
}
.table-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.table-actions button {
  min-height: 36px;
  padding: 0 12px;
}
.public-about { margin: 8px 0 20px; }
.upload-status {
  min-height: 22px;
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
}
.inline-copy {
  margin-left: 8px;
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: #ece4d8;
  color: var(--ink);
  font-weight: 900;
}
.cover-picker {
  display: grid;
  gap: 12px;
}
.cover-picker:empty {
  display: none;
}
.cover-picker-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}
.cover-picker-heading span {
  color: var(--muted);
  font-size: 13px;
}
.cover-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 10px;
}
.cover-choice {
  position: relative;
  min-height: 160px;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--white);
  display: grid;
  grid-template-rows: 1fr auto;
}
.cover-choice.is-selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(185, 137, 69, .18);
}
.cover-choice img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}
.cover-choice-button {
  min-height: 40px;
  border: 0;
  background: #f2eadf;
  color: var(--ink);
  padding: 9px;
  font-size: 12px;
  font-weight: 900;
}
.cover-choice.is-selected .cover-choice-button {
  background: #ead9b9;
}
.mission-section {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 26px 0 6px;
}
.mission-card {
  min-height: 260px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  padding: 24px;
  border-radius: 8px;
  border: 1px solid rgba(185, 137, 69, .34);
  background:
    linear-gradient(145deg, rgba(185, 137, 69, .22), rgba(36, 69, 58, .94) 42%, #173027),
    var(--green);
  color: var(--white);
  box-shadow: 0 16px 40px rgba(22, 24, 20, .12);
}
.mission-card span {
  width: fit-content;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(185, 137, 69, .28);
  color: #f5dfb6;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}
.mission-card h3 {
  margin: 0;
  font-size: 24px;
  line-height: 1.08;
}
.mission-card p {
  margin: 0;
  color: rgba(255, 254, 250, .84);
  line-height: 1.55;
}
.image-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(113, 37, 31, .94);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(0,0,0,.22);
}
.public-about .broker-grid { margin-top: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.broker-card {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 16px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 8px 26px rgba(22,24,20,.06);
}
.broker-card img {
  width: 112px;
  height: 132px;
  border-radius: 8px;
  object-fit: cover;
  object-position: center top;
  background: #eee8de;
}
.broker-card h3 { margin-bottom: 4px; }
.broker-card strong { display: block; color: var(--green); margin-bottom: 6px; }
.broker-card p { margin: 6px 0 0; }

.timeline, .schedule-board, .match-list, .finance-results, .saved-contracts, .finance-ledger { display: grid; gap: 12px; }
.timeline-item, .visit-card, .finance-card, .commission-result { border-left: 4px solid var(--gold); padding: 14px; background: #fffaf1; border-radius: 8px; }
.visit-card { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; background: var(--white); border: 1px solid var(--line); }
.availability-notice { color: var(--rose); font-weight: 900; min-height: 20px; }
.section-title { margin: 24px 0 12px; }
.recurrence-box {
  display: grid;
  grid-template-columns: minmax(220px, 1.1fr) repeat(2, minmax(170px, .7fr));
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(36, 69, 58, .2);
  border-radius: 8px;
  background: #f7f0e6;
  align-items: end;
}
.check-line {
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--white);
  border: 1px solid var(--line);
}
.check-line input {
  width: auto;
  min-height: auto;
  accent-color: var(--green);
}
.rent-helper {
  margin-top: -8px;
  padding: 0 4px;
}
.calendar-toolbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.calendar-toolbar strong { text-align: center; text-transform: capitalize; font-size: 20px; }
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}
.calendar-head {
  padding: 10px;
  border-radius: 8px;
  background: #ece4d8;
  font-weight: 900;
  text-align: center;
}
.calendar-day {
  min-height: 132px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  display: grid;
  align-content: start;
  gap: 6px;
}
.calendar-day.muted-day { opacity: .48; }
.calendar-event {
  display: block;
  padding: 5px 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.25;
}
.visit-event { background: #e8f1ff; color: #1f4f82; }
.block-event { background: #fff0ed; color: #8a3328; }
.overdue-card { border-color: #e4b3ac; background: #fff8f6; }

.match-card { padding: 16px; display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; }
.match-score { width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; background: var(--green); color: var(--white); font-weight: 900; }

.contract-layout { display: grid; grid-template-columns: minmax(360px, .8fr) minmax(0, 1.2fr); gap: 18px; align-items: start; }
.contract-preview {
  background: #fff;
  min-height: 78vh;
  padding: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  line-height: 1.62;
  outline: none;
}
.contract-preview:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(185,137,69,.18), var(--shadow); }
.contract-preview h1 { text-align: center; font-size: 20px; margin: 0 0 28px; }
.contract-preview h2 { font-size: 16px; margin-top: 22px; }
.contract-preview p { text-align: justify; }
.signature-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 28px; margin-top: 46px; }
.signature-line { border-top: 1px solid #222; padding-top: 8px; text-align: center; }
.footer-print { margin-top: 40px; padding-top: 16px; border-top: 1px solid #ddd; text-align: center; color: var(--muted); font-weight: 800; }
.edit-warning {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid #ddc897;
  border-radius: 8px;
  background: #fff7df;
  color: #675027;
  font-weight: 800;
}
.edit-warning.saved { border-color: #b6d0bd; background: #eef8f0; color: #295c39; }
.edit-warning.unsaved { border-color: #e4b3ac; background: #fff1ef; color: #7a2e25; }
.saved-card {
  padding: 16px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
}
.responsive-table { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; }
th { background: #f0eadf; font-size: 12px; text-transform: uppercase; }
.modal {
  width: min(960px, calc(100% - 28px));
  border: 0;
  border-radius: 8px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(0,0,0,.58); }
.modal-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.gallery-item, .gallery-lock {
  border: 0;
  min-height: 190px;
  border-radius: 8px;
  overflow: hidden;
  background: #ece4d8;
}
.gallery-item {
  position: relative;
  border: 2px solid transparent;
}
.gallery-item.is-cover {
  border-color: var(--gold);
}
.gallery-item img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.cover-action {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: rgba(22, 39, 32, .9);
  color: var(--white);
  font-weight: 900;
  box-shadow: 0 8px 22px rgba(0,0,0,.22);
}
.gallery-item.is-cover .cover-action {
  background: rgba(185, 137, 69, .94);
  color: #16120b;
}
.gallery-lock {
  display: grid;
  place-items: center;
  padding: 20px;
  color: var(--white);
  background: linear-gradient(135deg, rgba(36,69,58,.94), rgba(21,21,21,.92));
  text-align: center;
}
.gallery-lock strong { font-size: 32px; }
.lead-modal { width: min(460px, calc(100% - 28px)); }
.lead-modal form { display: grid; gap: 14px; }

.rate-editor { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.rate-editor label { font-size: 12px; }
.finance-results { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.finance-card { background: var(--white); border: 1px solid var(--line); border-left-color: var(--blue); }
.finance-card strong { display: block; font-size: 22px; margin: 8px 0; }

.empty-state {
  padding: 24px;
  border: 1px dashed #c8c1b2;
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255,255,255,.55);
}
.empty-state strong { display: block; color: var(--ink); margin-bottom: 6px; }

@media (max-width: 1100px) {
  body { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .side-note { display: none; }
  .metrics, .property-grid, .catalog-grid, .finance-results, .mission-section { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split-layout, .contract-layout { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .app-shell, .sidebar { padding: 16px; }
  .nav, .metrics, .property-grid, .property-grid.compact, .catalog-grid, .broker-grid, .public-about .broker-grid, .form-grid, .form-grid.dense, .rate-editor, .finance-results, .recurrence-box, .mission-section { grid-template-columns: 1fr; }
  .topbar, .match-card, .visit-card { display: grid; }
  .hero-content { left: 20px; bottom: 22px; width: calc(100% - 40px); }
  h2 { font-size: 28px; }
  .contract-preview { padding: 24px; }
  .signature-grid { grid-template-columns: 1fr; }
  .calendar-grid { grid-template-columns: 1fr; }
  .calendar-head { display: none; }
  .calendar-toolbar { grid-template-columns: 1fr; }
  .gallery-grid { grid-template-columns: 1fr; }
  .broker-card { grid-template-columns: 88px 1fr; }
  .broker-card img { width: 88px; height: 108px; }
  .platform-watermark { padding: 16px 12px 22px; }
}

body.client-mode {
  grid-template-columns: 1fr;
  background: var(--white);
}
body.client-mode .login-screen { display: none !important; }
body.client-mode .sidebar,
body.client-mode .internal-only,
body.client-mode .view:not(#search) {
  display: none !important;
}
body.client-mode #search {
  display: block !important;
}
body.client-mode .internal-only {
  display: none !important;
}
body.client-mode .app-shell {
  padding: 0 24px 32px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}
body.client-mode .hero {
  margin-top: 24px;
}
body.client-mode .hero-content p {
  visibility: hidden;
}
body.client-mode .hero-content p::after {
  content: "Catálogo selecionado";
  visibility: visible;
  display: block;
}
body.client-mode .hero-content span {
  visibility: hidden;
}
body.client-mode .hero-content span::after {
  content: "Encontre imóveis disponíveis e solicite à WILFER IMÓVEIS as melhores opções para o seu perfil.";
  visibility: visible;
  display: block;
}
body.client-mode .catalog-grid .property-card {
  display: flex;
  flex-direction: column;
}
body.client-mode .catalog-grid .property-photo {
  height: clamp(180px, 24vw, 260px);
  min-height: 0;
  flex-basis: auto;
  aspect-ratio: 16 / 9;
}
body.client-mode .property-price {
  font-size: 24px;
}
body.login-required .login-screen {
  display: grid !important;
}

@media print {
  body { display: block; background: #fff; }
  .sidebar, .hero, .topbar, #contractForm, .view:not(#contracts), .edit-warning, .platform-watermark { display: none !important; }
  .app-shell { padding: 0; }
  #contracts { display: block !important; padding: 0; }
  .contract-layout { display: block; }
  .contract-preview { border: 0; box-shadow: none; padding: 18mm; min-height: auto; }
  .contract-preview::after {
    content: "WILFER IMÓVEIS";
    position: fixed;
    bottom: 8mm;
    left: 0;
    right: 0;
    text-align: center;
    font-weight: 800;
    color: #777;
  }
}
