﻿:root {
  --bg: #f3f7f6;
  --card: #ffffff;
  --ink: #133239;
  --muted: #5f767d;
  --primary: #0f8b8d;
  --secondary: #f4a261;
  --danger: #d1495b;
  --ok: #2a9d8f;
  --shadow: 0 20px 50px rgba(17, 35, 41, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Outfit", sans-serif;
  color: var(--ink);
  background: linear-gradient(140deg, #eef4f2 0%, #f8fcfb 45%, #fff8f3 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

.bg-shape {
  position: fixed;
  border-radius: 50%;
  filter: blur(3px);
  z-index: -1;
}

.bg-1 {
  width: 340px;
  height: 340px;
  background: radial-gradient(circle, rgba(15, 139, 141, 0.2), transparent 70%);
  top: -100px;
  right: -80px;
}

.bg-2 {
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, rgba(244, 162, 97, 0.2), transparent 70%);
  bottom: -160px;
  left: -120px;
}

.topbar {
  padding: 20px clamp(18px, 3vw, 34px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar h1 {
  margin: 0;
  font-weight: 800;
  letter-spacing: 0.4px;
}

.eyebrow {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
  padding: 0 clamp(14px, 3vw, 30px) 30px;
}

.side-nav {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(19, 50, 57, 0.07);
  box-shadow: var(--shadow);
  border-radius: 24px;
  padding: 14px;
  height: fit-content;
  position: sticky;
  top: 16px;
  display: grid;
  gap: 8px;
}

.nav-btn {
  border: 0;
  padding: 12px 14px;
  border-radius: 12px;
  text-align: left;
  font-weight: 600;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  transition: 220ms ease;
}

.nav-btn:hover {
  background: rgba(15, 139, 141, 0.1);
}

.nav-btn.active {
  background: linear-gradient(110deg, var(--primary), #3ca4a6);
  color: #fff;
}

.content {
  display: grid;
}

.tab {
  display: none;
  animation: reveal 260ms ease both;
}

.tab.active {
  display: block;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

h2 {
  margin: 8px 0 16px;
}

h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.panel {
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(19, 50, 57, 0.07);
  padding: 16px;
  margin-bottom: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

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

.field label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.inline-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.icon-btn {
  width: 40px;
  min-width: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.contract-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-note {
  padding: 10px 12px;
  border-radius: 12px;
  background: #f3f9f9;
  border: 1px solid #d9e8e8;
  color: var(--muted);
  font-size: 0.9rem;
}

#clienteFiadorDialog {
  width: min(760px, 94vw);
}

#clienteFiadorDialog h3 {
  margin-bottom: 14px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #ced8da;
  background: #fff;
}

input:focus,
select:focus {
  outline: 2px solid rgba(15, 139, 141, 0.25);
  border-color: var(--primary);
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
}

.btn.primary {
  background: linear-gradient(110deg, var(--primary), #3ca4a6);
  color: #fff;
}

.btn.ghost {
  background: #eef4f2;
  color: var(--ink);
}

.btn.danger {
  background: #ffe8eb;
  color: var(--danger);
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.dashboard-cards {
  display: block;
  margin-bottom: 14px;
}

.help-cards {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card {
  background: var(--card);
  border-radius: 16px;
  padding: 14px;
  border: 1px solid rgba(19, 50, 57, 0.07);
  box-shadow: var(--shadow);
}

.card .label {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.card .value {
  margin: 4px 0 0;
  font-size: 1.4rem;
  font-weight: 700;
}

.card .value.tiny {
  font-size: 0.88rem;
  line-height: 1.4;
  font-weight: 500;
}

.table-wrap {
  overflow-x: auto;
  max-height: 460px;
}

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

th,
td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid #e6ecee;
  font-size: 0.92rem;
}

th {
  color: var(--muted);
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fbfb;
}

tbody tr:nth-child(even) {
  background: #fbfdfd;
}

tbody tr:hover {
  background: #f0f6f6;
}

td:last-child {
  white-space: nowrap;
}

.contract-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.row-menu {
  position: relative;
  display: inline-block;
}

.row-menu > summary {
  list-style: none;
}

.row-menu > summary::-webkit-details-marker {
  display: none;
}

.row-menu[open] > summary {
  background: #dfeaea;
}

.row-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 180px;
  z-index: 5;
  background: #ffffff;
  border: 1px solid #d8e2e4;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(18, 42, 49, 0.18);
  padding: 6px;
  display: grid;
  gap: 6px;
}

.row-menu-list .btn {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
}

.status {
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  display: inline-block;
}

.status.status-ok {
  background: #daf5f0;
  color: #116b60;
}

.status.status-warn {
  background: #fff4e4;
  color: #8f5a12;
}

.status.status-bad {
  background: #fde5e8;
  color: #8f2235;
}

.chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  min-height: 210px;
  padding-top: 6px;
}

.bar-wrap {
  flex: 1;
  text-align: center;
}

.bar {
  width: 100%;
  border-radius: 10px 10px 4px 4px;
  background: linear-gradient(180deg, #f4a261, #e76f51);
  min-height: 2px;
}

.bar-label {
  margin-top: 7px;
  font-size: 0.78rem;
  color: var(--muted);
}

.dashboard-finance-head {
  display: grid;
  grid-template-columns: 2.2fr 1fr 1.1fr;
  gap: 14px;
  margin-bottom: 14px;
}
.dashboard-title-box,
.dashboard-period-box,
.dashboard-totals-box {
  border: 1px solid #d7e3e8;
  background: linear-gradient(180deg, #ffffff 0%, #f9fcfd 100%);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 8px 20px rgba(15, 35, 45, 0.06);
}
.dashboard-title-box h3 {
  margin: 0 0 10px;
  font-size: 1.45rem;
  line-height: 1.2;
}
.dashboard-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.dash-pill {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  border-radius: 999px;
  padding: 6px 11px;
  border: 1px solid #9eb0b7;
}
.dash-pill-delay {
  background: #fff3cd;
  color: #9a3412;
}
.dash-pill-ok {
  background: #dbeafe;
  color: #1d4ed8;
}
.dashboard-period-box {
  display: grid;
  align-content: center;
  gap: 8px;
}
.dashboard-period-box strong {
  display: block;
  font-size: 1.05rem;
}
.dashboard-period-box span {
  color: #c1121f;
}
.dashboard-totals-box {
  display: grid;
  gap: 8px;
}
.dash-total {
  border-radius: 10px;
  padding: 8px 10px;
  border: 1px solid transparent;
}
.dash-total small {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}
.dash-total b {
  display: block;
  font-size: 1.55rem;
  line-height: 1.1;
}
.dash-total-receber {
  background: #e8f8ee;
  border-color: #71d39a;
  color: #047857;
}
.dash-total-pagar {
  background: #fde8e8;
  border-color: #f8a4a4;
  color: #b91c1c;
}
.dashboard-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.dash-kpi {
  border: 1px solid #dbe5e8;
  background: #fff;
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 8px 20px rgba(15, 35, 45, 0.05);
}
.dash-kpi p {
  margin: 0;
  color: #51646d;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.dash-kpi strong {
  display: block;
  margin-top: 6px;
  font-size: 1.45rem;
  line-height: 1.1;
}
.dashboard-monthly-grid {
  display: grid;
  gap: 14px;
}
.dashboard-bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}
.dashboard-block {
  border: 1px solid #d8e2e5;
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(15, 35, 45, 0.07);
}
.dashboard-block-title {
  margin: 0;
  padding: 10px 12px;
  color: #fff;
  font-weight: 800;
  font-size: 0.98rem;
  text-transform: uppercase;
}
.dashboard-block-green { background: #16a34a; }
.dashboard-block-blue { background: #0f5ea8; }
.dashboard-block-orange { background: #ed8936; }
.dashboard-block-red { background: #c1121f; }
.dashboard-block-teal { background: #147d8a; }
.dashboard-block .table-wrap {
  max-height: 240px;
  margin: 0;
}
.dashboard-block table {
  min-width: 100%;
}
.dashboard-block tbody tr:nth-child(even) {
  background: #fffdf0;
}

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.client-tools {
  align-items: center;
  margin-bottom: 10px;
}
.locador-tools,
.contrato-tools,
.vistoria-tools,
.pagamento-tools {
  align-items: center;
  margin-bottom: 10px;
}
.imovel-tools {
  align-items: center;
  margin-bottom: 10px;
}

.client-tools input[type="search"] {
  flex: 1.4;
  min-width: 240px;
}
.locador-tools input[type="search"],
.contrato-tools input[type="search"],
.vistoria-tools input[type="search"],
.pagamento-tools input[type="search"] {
  flex: 1.4;
  min-width: 240px;
}
.imovel-tools input[type="search"] {
  flex: 1.4;
  min-width: 240px;
}

.client-tools select {
  flex: 0.8;
  min-width: 165px;
}
.locador-tools select,
.contrato-tools select,
.vistoria-tools select,
.pagamento-tools select {
  flex: 0.8;
  min-width: 165px;
}
.imovel-tools select {
  flex: 0.8;
  min-width: 165px;
}

.list-info {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

dialog {
  width: min(900px, 92vw);
  border: none;
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(13, 30, 35, 0.45);
}

.dialog-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

#documentText {
  max-height: 62vh;
  overflow: auto;
  white-space: pre-wrap;
  background: #fff;
  border: 1px solid #d7dfe2;
  border-radius: 8px;
  padding: 28px 34px;
  font-family: "Times New Roman", Georgia, serif;
  font-size: 0.96rem;
  line-height: 1.65;
  text-align: justify;
  color: #102b31;
}

#documentText.doc-html {
  white-space: normal;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Calibri", sans-serif;
  font-size: 12px;
  line-height: 1.6;
  color: #000;
}

.contract-view {
  max-width: 900px;
  margin: 0 auto;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Calibri", sans-serif;
  font-size: 12px;
  line-height: 1.6;
  color: #000;
  padding: 30px 28px 42px;
}

.contract-quadro {
  font-family: inherit;
  font-size: 12px;
  color: #000;
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
}

.contract-quadro,
.contract-quadro th,
.contract-quadro td {
  border: 1px solid #000;
}

.contract-quadro caption {
  caption-side: top;
  text-align: center;
  font-weight: 700;
  margin-bottom: 10px;
  line-height: 1.35;
}
.contract-title-main {
  display: block;
  font-size: 18px;
  letter-spacing: 0.02em;
}
.contract-title-sub {
  display: block;
  font-size: 12px;
  font-weight: 500;
  margin-top: 4px;
  text-transform: none;
}

.contract-quadro th {
  background: #f3f4f6;
  text-align: left;
  padding: 4px 8px;
  line-height: 1.25;
  font-weight: 700;
  color: #000;
  position: static;
  top: auto;
  z-index: auto;
}

.contract-quadro td {
  padding: 3px 8px;
  line-height: 1.25;
  white-space: normal;
}

.contract-quadro .section-header {
  background: #e5e7eb;
  text-align: center;
  font-weight: 700;
  text-transform: uppercase;
}

.contract-section {
  margin-top: 16px;
}

.contract-section-title {
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.contract-block {
  margin-bottom: 8px;
  font-size: 12px;
}

.contract-block p {
  margin: 0 0 8px;
  text-align: justify;
  font-size: 12px;
}

.contract-signatures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  margin-top: 32px;
}

.contract-signature-line {
  margin-top: 40px;
  text-align: center;
  font-size: 12px;
}

.contract-signature-line span {
  display: block;
  border-top: 1px solid #000;
  padding-top: 4px;
}

#documentTitle {
  text-align: center;
}

.doc-area {
  min-height: 220px;
  width: 100%;
  border: 1px solid #ced8da;
  border-radius: 12px;
  padding: 12px;
  line-height: 1.4;
  resize: vertical;
}

.doc-area.compact {
  min-height: 110px;
}

.row-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 2fr auto;
  gap: 8px;
  margin-bottom: 8px;
}

.row-grid .btn {
  padding: 8px 10px;
}

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

  .side-nav {
    position: static;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
  }

  .nav-btn {
    text-align: center;
    font-size: 0.9rem;
  }

  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-finance-head {
    grid-template-columns: 1fr;
  }

  .dashboard-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .dashboard-bottom-grid {
    grid-template-columns: 1fr;
  }

  .help-cards {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 640px) {
  .side-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cards,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-kpi-grid {
    grid-template-columns: 1fr;
  }

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

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .contract-meta {
    flex-direction: column;
    gap: 6px;
  }

  .contract-signatures {
    grid-template-columns: 1fr;
    gap: 14px;
  }
}

@media print {
  body * {
    visibility: hidden;
  }

  dialog[open],
  dialog[open] * {
    visibility: visible;
  }

  dialog[open] {
    position: absolute;
    inset: 0;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    box-shadow: none;
    border-radius: 0;
  }

  .dialog-actions {
    display: none;
  }
}
.sync-status {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid transparent;
}
.sync-status.is-local {
  color: #475467;
  background: #f2f4f7;
  border-color: #d0d5dd;
}
.sync-status.is-syncing {
  color: #b54708;
  background: #fffaeb;
  border-color: #fedf89;
}
.sync-status.is-online {
  color: #027a48;
  background: #ecfdf3;
  border-color: #abefc6;
}
.sync-status.is-offline {
  color: #b42318;
  background: #fef3f2;
  border-color: #fecdca;
}
