:root {
    --cor-primaria: #a7198f;
    --cor-primaria-escura: #810077;
    --cor-primaria-clara: #f7d8f3;
    --cor-destaque: #c623cd;
    --cor-fundo: #fbf7fb;
    --cor-borda: #ead8e8;
    --cor-texto: #2f2030;
    --cor-erro: #b91c1c;
    --cor-sucesso: #15803d;
}

* { box-sizing: border-box; }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body {
    margin: 0;
    font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    background: var(--cor-fundo);
    color: var(--cor-texto);
}

a { color: var(--cor-primaria); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 3px solid rgba(167, 25, 143, 0.35);
    outline-offset: 2px;
}
button:disabled, input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; }

.topbar {
    background: var(--cor-primaria-escura);
}
.topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 12px 16px;
    color: white;
}
.topbar nav { display: flex; gap: 14px; flex: 1; flex-wrap: wrap; align-items: center; }
.topbar nav a { color: #fce7fa; }
.header-account { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.topbar-date { color: #fce7fa; font-size: 0.9rem; white-space: nowrap; }
.topbar-version { color: #f4b9ee; font-size: 0.8rem; white-space: nowrap; text-decoration: none; }
.topbar-version:hover, .topbar-version:focus-visible { color: #fff; text-decoration: underline; }
.user-menu { margin-left: 0; }
.avatar { width: 34px; height: 34px; padding: 0; border: 1px solid #c623cd; border-radius: 50%; background: #f7d8f3; color: #810077; font-weight: 700; }
.avatar:hover { background: #edb9e7; }
.user-dropdown { right: 0; left: auto; min-width: 210px; }
.user-dropdown .user-name { color: #fff; font-weight: 700; border-bottom: 1px solid rgba(255,255,255,.25); }

.dropdown { position: relative; }
.dropdown-toggle {
    background: none;
    border: none;
    color: #fce7fa;
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    padding: 0;
}
.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 10px;
    background: var(--cor-primaria-escura);
    border-radius: 6px;
    min-width: 160px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    z-index: 10;
    overflow: hidden;
}
.dropdown.aberto .dropdown-menu { display: block; }
.dropdown-menu a {
    display: block;
    padding: 8px 14px;
    color: #fce7fa;
}
.dropdown-menu a:hover { background: var(--cor-primaria); text-decoration: none; }
.dropdown-form { margin: 0; }
.dropdown-form button {
    width: 100%;
    padding: 8px 14px;
    border: 0;
    background: transparent;
    color: #fce7fa;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.dropdown-form button:hover { background: var(--cor-primaria); }

.container {
    max-width: 1100px;
    margin: 24px auto;
    padding: 0 16px 40px;
}

.card {
    background: white;
    border: 1px solid var(--cor-borda);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.btn {
    display: inline-block;
    background: var(--cor-primaria);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}
.btn:hover { background: var(--cor-primaria-escura); text-decoration: none; color: white; }
.btn-secundario { background: #6b7280; }
.btn-secundario:hover { background: #4b5563; }
.btn-perigo { background: var(--cor-erro); }
.btn-perigo:hover { background: #7f1d1d; }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}
th, td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--cor-borda);
    font-size: 0.92rem;
}
th { background: #f8edf7; }
.currency-cell { text-align: right !important; white-space: nowrap; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.relatorio-identificacao { row-gap: 0; }
.relatorio-identificacao p { margin: 3px 0; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group.span-2 { grid-column: span 2; }
.span-3 { grid-column: 1 / -1; }
.form-section-heading {
    grid-column: 1 / -1;
    margin: 12px 0 0;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--cor-borda);
    color: var(--cor-primaria-escura);
}
.form-section-heading:first-child { margin-top: 0; }
.dashboard-resumo p { margin: 0 0 10px; }
.dashboard-resumo p:last-child { margin-bottom: 0; }
label { font-size: 0.85rem; font-weight: 600; color: #374151; }
input, select, textarea {
    padding: 8px 10px;
    border: 1px solid var(--cor-borda);
    border-radius: 6px;
    font-size: 0.92rem;
    font-family: inherit;
}
textarea { resize: vertical; }

.checkbox-inline { flex-direction: row; align-items: center; gap: 8px; }

.alert {
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}
.alert-sucesso { background: #dcfce7; color: var(--cor-sucesso); border: 1px solid #bbf7d0; }
.alert-erro { background: #fee2e2; color: var(--cor-erro); border: 1px solid #fecaca; }
.alert-info { background: #fce7f8; color: #810077; border: 1px solid #f2b8e8; }

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}
.badge-pendente { background: #fef3c7; color: #92400e; }
.badge-em-digitacao, .badge-em_digitacao { background: transparent; color: #374151; }
.badge-aguarda-pagamento, .badge-aguarda_pagamento { background: #fef3c7; color: #92400e; }
.badge-pago { background: #dcfce7; color: #166534; }
.badge-vencido { background: #fee2e2; color: #991b1b; }
.badge-ativo { background: #f7d8f3; color: #810077; }
.badge-encerrado { background: #e5e7eb; color: #374151; }

.auth-box {
    max-width: 380px;
    margin: 80px auto;
}
.auth-box.card {
    border-top: 4px solid var(--cor-primaria);
    box-shadow: 0 12px 32px rgba(129, 0, 119, 0.12);
}
.auth-box h1 { color: var(--cor-primaria-escura); }
.auth-field-gap { margin-top: 12px; }
.auth-submit { width: 100%; margin-top: 16px; }
.auth-footer { margin: 16px 0 0; text-align: center; }
.auth-version { margin: 16px 0 0; text-align: center; color: #6b7280; font-size: 0.85rem; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.filter-bar { display: flex; gap: 8px; margin: 0 0 16px; }
.filter-link { border: 1px solid var(--cor-borda); border-radius: 999px; padding: 6px 12px; font-size: 0.88rem; color: var(--cor-texto); background: white; }
.competencia-bar { align-items: center; }
.competencia-intervalo { align-items: end; flex-wrap: wrap; }
.competencia-intervalo .form-group { margin: 0; }
.filter-link:hover, .filter-link.ativo { background: var(--cor-primaria); color: white; border-color: var(--cor-primaria); text-decoration: none; }
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; margin: 8px 0 20px; color: #4b5563; font-size: 0.88rem; }
.status-cell { width: 36px; text-align: center; padding-left: 12px; padding-right: 6px; }
.status-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }
.status-dot-green { background: #86efac; }
.status-dot-gray { background: #9ca3af; }
.valuation-dot { display: inline-flex; width: 16px; height: 16px; margin-left: 5px; align-items: center; justify-content: center; border: 1px solid #c623cd; border-radius: 50%; background: #f7d8f3; color: #810077; font-size: 10px; font-weight: 800; line-height: 1; vertical-align: middle; cursor: help; }
.lease-action-dot { display: inline-flex; width: 24px; height: 24px; align-items: center; justify-content: center; border: 1px solid #c623cd; border-radius: 50%; background: #f7d8f3; color: #810077; vertical-align: middle; }
.lease-action-dot:hover, .lease-action-dot:focus-visible { background: #edb9e7; color: #680060; text-decoration: none; outline: 2px solid #a7198f; outline-offset: 2px; }
.lease-action-dot svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.delete-action-dot { display: inline-flex; width: 24px; height: 24px; padding: 0; align-items: center; justify-content: center; appearance: none; -webkit-appearance: none; border: 1px solid #ef4444 !important; border-radius: 50%; background-color: #fee2e2 !important; color: #dc2626 !important; cursor: pointer; vertical-align: middle; }
.delete-action-dot:hover, .delete-action-dot:focus-visible { background-color: #fecaca !important; color: #991b1b !important; outline: 2px solid #dc2626; outline-offset: 2px; }
.delete-action-dot svg { display: block; width: 14px; height: 14px; fill: none; stroke: #dc2626 !important; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.prioridade-baixa { background: #86efac; }
.prioridade-media { background: #facc15; }
.prioridade-alta { background: #f87171; }
.whatsapp-link { color: #15803d; font-weight: 600; white-space: nowrap; }

.total-box {
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--cor-primaria-escura);
}

.foto-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
.page-subtitle { margin: 4px 0 0; color: #4b5563; }
.history-month { margin-top: 24px; }
.history-month > h2 { color: var(--cor-primaria-escura); border-bottom: 1px solid var(--cor-borda); padding-bottom: 7px; }
.history-entry { padding: 0; overflow: hidden; }
.history-entry-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 18px; background: #fcf8fb; border-bottom: 1px solid var(--cor-borda); }
.history-entry-header > div:first-child { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; }
.history-entry table th:first-child,
.history-entry table td:first-child { padding-left: 18px; }
.history-entry table th:last-child,
.history-entry table td:last-child { padding-right: 18px; }
.foto-grid img {
    width: 140px;
    height: 100px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--cor-borda);
}
.album-ambiente { overflow: hidden; }
.album-ambiente-header { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 16px; }
.album-ambiente-header h2 { margin: 0; }
.album-upload { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.album-file-input { max-width: 310px; }
.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.foto-card { position: relative; min-width: 0; padding: 6px; border: 1px solid var(--cor-borda); border-radius: 10px; background: #fcf8fb; }
.foto-card img, .album-grid img { display: block; width: 100%; height: 150px; object-fit: cover; border: 0; border-radius: 7px; }
.foto-card-legenda { margin: 8px 4px 2px; overflow: hidden; color: #4b5563; font-size: 0.9rem; text-overflow: ellipsis; white-space: nowrap; }
.foto-card form { position: absolute; top: 10px; right: 10px; padding: 3px; border-radius: 50%; background: rgba(255, 255, 255, 0.92); }
.album-vazio { margin: 0; color: #6b7280; }

.documentos-upload { display: grid; grid-template-columns: minmax(240px, 1fr) minmax(240px, 1fr) auto; gap: 12px; align-items: end; margin-top: 24px; }
.documentos-upload .form-group { min-width: 0; }
.documentos-upload input { width: 100%; }
.label-hint { color: #6b7280; font-size: 0.85em; font-weight: 400; }
.documentos-lista { list-style: none; margin: 0; padding: 0; }
.documentos-lista li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--cor-borda); }
.section-title { margin-top: 24px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.form-submit { margin-top: 18px; }
.form-subcard { grid-column: 1 / -1; margin: 8px 0; padding: 18px; border: 1px solid var(--cor-borda); border-radius: 10px; background: #fcf8fb; }
.form-subcard legend { padding: 0 8px; color: var(--cor-primaria-escura); font-size: 1.1rem; font-weight: 700; }
.form-subcard-hint { margin: 0 0 16px; color: #6b7280; }
.resource-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 18px; }
.form-section-gap { margin-top: 14px; }
.button-section-gap { margin-top: 10px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.compact-form { gap: 6px; align-items: center; }
.section-form { margin-bottom: 18px; }
.input-short { width: 70px; }
.input-medium { width: 100px; }
.inspection-thumbnail { width: 80px; height: 60px; object-fit: cover; border-radius: 4px; }
.changelog-content { white-space: pre-wrap; line-height: 1.7; }
.report-toolbar { margin-bottom: 16px; display: flex; gap: 10px; }
.report-title-row { display: flex; justify-content: space-between; gap: 24px; align-items: baseline; }
.report-title-row h1 { margin: 0; }
.report-title-row h1:last-child { text-align: right; }
.text-right { text-align: right; }
.report-footer { text-align: right; color: #6b7280; font-size: 12px; margin: 18px 0; }
.signature-primary { margin-top: 60px; }
.signature-secondary { margin-top: 40px; }
.contract-sheet { font-size: 10.5pt; line-height: 1.45; }
.contract-sheet h1 { margin: 0 0 12mm; text-align: center; font-size: 12pt; font-weight: 500; text-decoration: underline; }
.contract-sheet h2 { margin: 7mm 0 3mm; text-align: center; font-size: 10.5pt; font-weight: 500; }
.contract-sheet p { margin: 0 0 3.5mm; text-align: justify; }
.contract-summary { width: 100%; margin-bottom: 8mm; border-collapse: collapse; table-layout: fixed; }
.contract-summary td { padding: 1px 6px; border: 1px solid #333; vertical-align: top; }
.contract-date { margin-top: 8mm !important; text-align: center !important; }
.contract-signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 20mm; margin-top: 22mm; text-align: center; }
.contract-signatures p, .contract-representative { text-align: center; }
.contract-inspection { break-before: page; page-break-before: always; }
.contract-inspection h1 { margin-bottom: 8mm; }
.contract-inspection-table { width: 100%; border-collapse: collapse; font-size: 9.5pt; }
.contract-inspection-table th, .contract-inspection-table td { padding: 4px 6px; border: 1px solid #333; text-align: left; vertical-align: top; }
.contract-sheet h2, .contract-summary, .contract-inspection-table tr, .contract-signatures { break-inside: avoid; page-break-inside: avoid; }
.read-only input:disabled,
.read-only select:disabled,
.read-only textarea:disabled { color: var(--cor-texto); background: #fcf8fb; opacity: 1; }
@media (max-width: 760px) {
    .topbar-inner { flex-wrap: wrap; gap: 12px; }
    .topbar nav { order: 3; flex-basis: 100%; }
    .header-account { margin-left: auto; }
    .page-header { flex-wrap: wrap; align-items: flex-start; }
    .album-ambiente-header, .album-upload { align-items: stretch; flex-direction: column; }
    .album-file-input, .album-upload .btn { width: 100%; max-width: none; }
    .history-entry-header { align-items: flex-start; flex-direction: column; }
    .filter-bar { flex-wrap: wrap; }
    .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
    .form-group.span-2 { grid-column: auto; }
    table { display: block; overflow-x: auto; white-space: nowrap; }
    .documentos-lista li { flex-wrap: wrap; }
}

@media (max-width: 600px) {
    .documentos-upload { grid-template-columns: 1fr; align-items: stretch; }
}

@media print {
    @page { size: A4; margin: 14mm 15mm 15mm; }
    .topbar, .no-print { display: none !important; }
    .container { margin: 0; max-width: 100%; }
    table { display: table; overflow: visible; white-space: normal; }
    .contract-print::before {
        content: "";
        position: fixed;
        inset: 0;
        border: 1px solid var(--cor-borda);
        border-radius: 8px;
        pointer-events: none;
    }
    .contract-print .container { padding: 5mm 6mm; }
    .contract-print .contract-sheet {
        margin: 0;
        padding: 0;
        border: 0;
        font-size: 10pt;
    }
}
