* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --gold: #CA9761;
  --gold-light: #DBB58A;
  --navy: #1C1D2E;
  --bg: #1C1D2E;
  --bg-elevated: #242536;
  --bg-card: #26273A;
  --border: #383A50;
  --text: #F4EFE3;
  --text-dim: #C9CBE0;
  --text-muted: #9497BE;
  --success: #4CAF7D;
  --warning: #E0A94C;
  --danger: #D0603F;
  --critical: #E06B7A;
  --radius: 10px;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
}

h1, h2, h3, h4, .serif {
  font-family: 'Playfair Display', serif;
  font-weight: 600;
  letter-spacing: 0.01em;
}

a { color: var(--gold); text-decoration: none; }

button {
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  transition: all 0.15s ease;
}

input, select, textarea {
  font-family: 'Inter', sans-serif;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
}

label {
  display: block;
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 5px;
  font-weight: 500;
}

.field { margin-bottom: 14px; }

.btn {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  color: #12142B;
}
.btn-primary:hover { filter: brightness(1.08); }

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-secondary:hover { border-color: var(--gold); color: var(--gold); }

.btn-danger {
  background: transparent;
  border: 1px solid var(--critical);
  color: var(--critical);
}
.btn-danger:hover { background: var(--critical); color: #fff; }

.btn-sm { padding: 6px 12px; font-size: 12.5px; }

/* ── Login ── */
.login-screen[hidden] { display: none; }
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 20%, #2A2C42 0%, var(--bg) 65%);
}

.login-card {
  width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.login-brand {
  text-align: center;
  margin-bottom: 32px;
}
.login-brand .crest {
  width: 64px; height: 64px;
  margin: 0 auto 14px;
  object-fit: contain;
  display: block;
}
.login-brand h1 { font-family: 'Inter', sans-serif; font-weight: 800; font-size: 24px; letter-spacing: 0.08em; color: var(--gold); }
.login-brand p { font-family: 'Inter', sans-serif; font-size: 11.5px; font-weight: 500; color: var(--text); margin-top: 6px; letter-spacing: 0.1em; text-transform: uppercase; }

.login-error {
  background: rgba(178,58,72,0.15);
  border: 1px solid var(--critical);
  color: #f0a3ab;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

/* ── App shell ── */
.app-shell[hidden] { display: none; }
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  --text: #F4EFE3;
  --text-dim: #C9CBE0;
  --text-muted: #9497BE;
  --border: rgba(202,151,97,0.2);
  --gold: #CA9761;
  width: 240px;
  background: var(--navy);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
}

.sidebar-brand {
  padding: 26px 22px 20px;
  border-bottom: 1px solid rgba(202,151,97,0.2);
}
.sidebar-brand .crest {
  width: 44px; height: 44px;
  object-fit: contain;
  display: block;
  margin-bottom: 10px;
}
.sidebar-brand h1 { font-family: 'Inter', sans-serif; font-weight: 800; font-size: 19px; letter-spacing: 0.07em; color: var(--gold); line-height: 1.25; }
.sidebar-brand p { font-family: 'Inter', sans-serif; font-size: 9.5px; font-weight: 500; color: var(--text); margin-top: 4px; letter-spacing: 0.09em; text-transform: uppercase; }

.nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 2px;
}
.nav-item:hover { background: rgba(202,151,97,0.08); color: var(--text); }
.nav-item.active { background: rgba(202,151,97,0.16); color: var(--gold); }
.nav-item svg { flex-shrink: 0; opacity: 0.85; }

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(202,151,97,0.2);
  font-size: 12px;
  color: var(--text-muted);
}
.sidebar-footer .user-name { color: var(--text); font-weight: 600; display: block; margin-bottom: 6px; }
.sidebar-footer button { background: none; color: var(--text-muted); font-size: 12px; padding: 0; text-decoration: underline; }
.sidebar-footer button:hover { color: var(--gold); }

.content-area { margin-left: 240px; flex: 1; display: flex; flex-direction: column; min-width: 0; }

.hamburger-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 38px; height: 38px;
  border-radius: 10px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.hamburger-btn:hover { border-color: var(--gold); color: var(--gold); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 90;
}
.sidebar-backdrop.is-open { display: block; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 62px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.topbar-search { position: relative; flex: 1; max-width: 420px; }
.topbar-search input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 13.5px;
  padding: 9px 14px;
}
.topbar-search input:focus { border-color: var(--gold); }

.busca-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.45);
  max-height: 360px;
  overflow-y: auto;
  z-index: 60;
}
.busca-dropdown.is-open { display: block; }
.busca-dropdown:not(.is-open) { display: none; }
.busca-group-label {
  padding: 8px 14px 4px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.busca-item { padding: 9px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 1px; }
.busca-item:hover { background: rgba(202,151,97,0.08); }
.busca-item .bi-label { font-size: 13.5px; color: var(--text); font-weight: 500; }
.busca-item .bi-sub { font-size: 11.5px; color: var(--text-muted); }
.busca-empty { padding: 14px; font-size: 13px; color: var(--text-muted); text-align: center; }

.topbar-notif { position: relative; }
.notif-bell {
  position: relative;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.notif-bell:hover { border-color: var(--gold); color: var(--gold); }
.notif-badge {
  position: absolute;
  top: -6px; right: -6px;
  background: var(--critical);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 100px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}
.notif-badge[hidden] { display: none; }

.notif-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 280px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.45);
  z-index: 60;
  padding: 8px;
}
.notif-dropdown.is-open { display: block; }
.notif-dropdown:not(.is-open) { display: none; }
.notif-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
}
.notif-row:hover { background: rgba(202,151,97,0.08); }
.notif-row .nr-label { font-size: 13px; color: var(--text); }
.notif-row .nr-count { font-size: 13px; color: var(--gold); font-weight: 700; margin-right: 10px; }
.notif-empty { padding: 16px; font-size: 13px; color: var(--text-muted); text-align: center; }

.main { flex: 1; padding: 32px 40px; max-width: 1400px; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 26px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h2 { font-size: 26px; color: var(--text); }
.page-header .sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ── Cards / grids ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.kpi-card .label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.kpi-card .value { font-family: 'Playfair Display', serif; font-size: 28px; color: var(--gold); }
.kpi-card .value.small { font-size: 22px; }
.kpi-card.alert .value { color: var(--danger); }
.kpi-card.ok .value { color: var(--success); }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
}
.card h3 { font-size: 16px; color: var(--gold); margin-bottom: 16px; }

/* ── Table ── */
.table-wrap { overflow-x: auto; box-shadow: inset -14px 0 10px -10px rgba(0,0,0,0.35); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 12px;
  border-bottom: 1px solid rgba(43,47,92,0.5);
  color: var(--text);
  white-space: nowrap;
}
tbody tr:hover { background: rgba(202,151,97,0.04); }
tbody tr:last-child td { border-bottom: none; }
.table-wrap { max-width: 100%; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge-gold { background: rgba(202,151,97,0.18); color: var(--gold); }
.badge-success { background: rgba(76,175,125,0.18); color: var(--success); }
.badge-warning { background: rgba(224,169,76,0.18); color: var(--warning); }
.badge-danger { background: rgba(208,96,63,0.18); color: var(--danger); }
.badge-critical { background: rgba(178,58,72,0.22); color: #f0a3ab; }
.badge-muted { background: rgba(118,122,156,0.18); color: var(--text-muted); }

.financeiro-group { padding: 0; overflow: hidden; }
.financeiro-group-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; cursor: pointer; user-select: none;
}
.financeiro-group-header:hover { background: rgba(255,255,255,0.02); }
.financeiro-group-summary { display: flex; align-items: center; gap: 10px; }
.financeiro-group-summary .chevron { display: inline-block; transition: transform 0.15s ease; color: var(--text-muted); }
.financeiro-group-header.is-open .chevron { transform: rotate(180deg); }
.financeiro-group-body { display: none; padding: 0 20px 16px; }
.financeiro-group-body.is-open { display: block; }

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  align-items: center;
}
.toolbar input[type=text], .toolbar input[type=search] { max-width: 280px; }
.toolbar .spacer { flex: 1; }

.filter-pills { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.pill {
  padding: 7px 16px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.pill:hover { border-color: var(--gold); }
.pill.active { background: var(--gold); color: #12142B; border-color: var(--gold); font-weight: 600; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(6,7,20,0.7);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
  z-index: 100;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 640px;
  padding: 28px 30px;
}
.modal h3 { color: var(--gold); font-size: 19px; margin-bottom: 20px; }
.modal .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.modal .grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 34px; margin-bottom: 12px; opacity: 0.4; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 22px; }
.tab {
  padding: 10px 18px;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--gold); border-bottom-color: var(--gold); }

.detail-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; flex-wrap: wrap; gap: 14px; }
.detail-title h2 { font-size: 24px; }
.detail-title .sub { color: var(--text-muted); font-size: 13.5px; margin-top: 4px; }

.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.info-item .label { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.info-item .value { font-size: 14.5px; color: var(--text); }

.progress-bar { height: 8px; background: var(--bg-elevated); border-radius: 100px; overflow: hidden; margin-top: 8px; }
.progress-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-light)); }

.timeline-list { position: relative; padding-left: 22px; }
.timeline-list::before { content: ''; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 1.5px; background: var(--border); }
.timeline-item { position: relative; padding-bottom: 20px; }
.timeline-item::before { content: ''; position: absolute; left: -22px; top: 4px; width: 9px; height: 9px; border-radius: 50%; background: var(--gold); }
.timeline-item .tl-date { font-size: 11.5px; color: var(--text-muted); margin-bottom: 3px; }
.timeline-item .tl-desc { font-size: 13.5px; color: var(--text); }

.renov-columns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.renov-col h4 { font-size: 13px; color: var(--gold); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.renov-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 8px; padding: 14px; margin-bottom: 12px; font-size: 13px; }
.renov-card .rc-loc { font-weight: 600; color: var(--text); margin-bottom: 2px; }
.renov-card .rc-imovel { color: var(--text-muted); font-size: 12px; margin-bottom: 8px; }
.renov-card .rc-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.renov-card textarea { margin-top: 8px; font-size: 12.5px; min-height: 50px; }

.link-btn { background: none; color: var(--gold); padding: 0; font-size: 13px; text-decoration: underline; }

.doc-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.doc-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  gap: 10px;
  flex-wrap: wrap;
}
.doc-row .doc-info { display: flex; flex-direction: column; gap: 2px; }
.doc-row .doc-name { color: var(--text); font-weight: 500; }
.doc-row .doc-meta { color: var(--text-muted); font-size: 11.5px; }
.doc-row .doc-actions { display: flex; gap: 8px; align-items: center; }
.doc-upload-row { display: flex; gap: 10px; align-items: center; margin-bottom: 4px; flex-wrap: wrap; }
.doc-upload-row input[type=file] { flex: 1; min-width: 200px; padding: 8px; }

.msg-preview { max-width: 340px; white-space: normal; font-size: 12.5px; color: var(--text-dim); }

@media (max-width: 900px) {
  .main { padding: 24px 20px; }
  .topbar { padding: 0 16px; }
  .renov-columns { grid-template-columns: 1fr; }
  .modal .grid2, .modal .grid3 { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .hamburger-btn { display: flex; }
  .sidebar {
    width: 240px;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 100;
  }
  .sidebar.is-open { transform: translateX(0); }
  .content-area { margin-left: 0; }
  .topbar-search { max-width: none; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .table-wrap { overflow-x: auto; box-shadow: inset -14px 0 10px -10px rgba(0,0,0,0.35); }
}

@media (max-width: 460px) {
  .kpi-grid { grid-template-columns: 1fr; }
}
