:root {
    --bg: #fafaf8;
    --card: #ffffff;
    --border: #e8e6e1;
    --border-strong: #d6d3cc;
    --text: #1a202e;
    --muted: #71716f;
    --accent: #1a202e;
    --accent-hover: #000000;
    --accent-soft: #f0efeb;
    --danger: #c0392b;
    --danger-soft: #fdf0ee;
    --warning: #b45309;
    --warning-soft: #fef9ec;
    --success: #2e7d32;
    --success-soft: #f0f7f0;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(26,32,46,.04), 0 8px 24px rgba(26,32,46,.05);
}
* { box-sizing: border-box; }
html, body { overflow-x: hidden; max-width: 100vw; }
body {
    background: var(--bg);
    margin: 0;
    min-height: 100vh;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* ── Header fixo no topo ── */
.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 16px 20px;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 100;
}
/* Navegacao interna - barra propria abaixo do topbar (so paginas admin;
   o form do hospede usa o mesmo base.html e nao mostra links internos) */
.topbar-nav {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px 0;
}
.nav-pill {
    padding: 8px 18px;
    border-radius: 999px;
    background: #dbeafe;
    color: #1d4ed8;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background .15s, color .15s;
}
.nav-pill:hover { background: #bfdbfe; }
.nav-pill.is-active { background: #2563eb; color: #fff; }

.topbar-title {
    font-family: 'Helvetica Neue', 'Inter', -apple-system, sans-serif;
    font-weight: 700;
    font-size: 19px;
    letter-spacing: -0.02em;
    color: var(--text);
    margin: 0;
}

.page { max-width: 560px; width: 100%; margin: 0 auto; padding: 24px 18px 80px; }
.page-wide { max-width: 1160px; }
.page-medium { max-width: 860px; }
.page-login { max-width: 400px; }

/* ── Resumo da reserva ── */
.summary-block {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px 24px;
    margin-bottom: 28px;
}
.summary-row {
    display: flex;
    gap: 20px;
    padding: 10px 0;
}
.summary-row:first-child { padding-top: 0; }
.summary-row:last-child { padding-bottom: 0; }
.summary-row + .summary-row { border-top: 1px solid var(--border); }
.summary-item { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.summary-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    margin-bottom: 4px;
}
.summary-value { font-size: 15px; font-weight: 600; color: var(--text); }

/* ── Seletor de idioma ── */
.lang-toggle {
    display: flex;
    justify-content: flex-end;
    gap: 4px;
    margin-bottom: 18px;
}
.lang-btn {
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    padding: 5px 12px;
    cursor: pointer;
    transition: all .15s ease;
}
.lang-btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.lang-btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin-left: -1px; }
.lang-btn.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ── Introducao ── */
.intro-block { margin-bottom: 28px; }
.intro-title {
    font-family: 'Helvetica Neue', 'Inter', -apple-system, sans-serif;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0 0 8px;
}
.intro-text { font-size: 14px; line-height: 1.6; color: var(--muted); margin: 0; }
.intro-text + .intro-text { margin-top: 10px; }
.intro-text strong { color: var(--text); font-weight: 600; }

/* ── Formulario ── */
.form-block {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px 24px;
    margin-bottom: 16px;
}
.form-group { display: flex; flex-direction: column; margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }
label {
    margin-bottom: 7px;
    font-weight: 500;
    color: var(--muted);
    font-size: 13px;
}
input {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding: 13px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: inherit;
    color: var(--text);
    background: var(--card);
    transition: border-color .15s, box-shadow .15s;
}
input[type="file"] { padding: 0; border: none; }
input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(26,32,46,.08);
}
input::placeholder { color: #b9b7b1; }

/* ── Blocos de hospede ── */
.guest-section {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px 24px;
    margin-bottom: 16px;
    animation: slideIn .25s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.guest-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}
.guest-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--accent); color: #fff; font-size: 12px; font-weight: 700;
    flex-shrink: 0;
}
.guest-title { font-size: 15px; font-weight: 600; flex: 1; }
.remove-guest {
    background: none; border: none; color: var(--danger); cursor: pointer;
    font-size: 12px; font-weight: 600; font-family: inherit;
    padding: 6px 10px; border-radius: 6px; transition: background .15s;
}
.remove-guest:hover { background: var(--danger-soft); }

/* ── Area de upload de documento ── */
.upload-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 20px 16px;
    cursor: pointer;
    text-align: center;
    transition: border-color .15s, background .15s;
    margin-bottom: 0;
}
.upload-zone:hover { border-color: var(--accent); background: var(--accent-soft); }
.upload-zone.has-file { border-style: solid; border-color: var(--success); background: var(--success-soft); }
.upload-zone input[type="file"] { display: none; }
.upload-preview svg { width: 120px; height: auto; display: block; }
.upload-preview img {
    max-width: 100%;
    max-height: 180px;
    border-radius: var(--radius-sm);
    display: block;
}
.upload-file-icon {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 10px 18px; border-radius: var(--radius-sm);
    background: var(--accent-soft); font-weight: 700; font-size: 13px; color: var(--accent);
}
.upload-hint { font-size: 12px; line-height: 1.55; color: var(--muted); font-weight: 400; }
.upload-hint strong { display: block; font-size: 13px; color: var(--text); margin-bottom: 2px; word-break: break-all; }

/* Botao "Remover arquivo" - aparece quando a zona tem arquivo anexado */
.file-remove {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 7px 16px;
    border-radius: 999px;
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}
.upload-zone.has-file .file-remove { display: inline-flex; }
.file-remove:hover { background: #f6d5d0; }
.file-remove-sub { font-weight: 400; font-size: 10px; opacity: .8; line-height: 1.3; }

/* Campos do carro do hospede */
.car-fields { display: flex; gap: 8px; flex-wrap: wrap; }
.car-fields input { min-width: 0; }
.car-modelo { flex: 2 1 160px; }
.car-cor, .car-placa { flex: 1 1 100px; }

.doc-feedback { font-size: 12px; margin-top: 6px; min-height: 16px; }
.doc-feedback-checking { color: var(--muted); font-style: italic; }
.doc-feedback-ok { color: var(--success); }
.doc-feedback-warning { color: var(--warning); }
.doc-feedback-error { color: var(--danger); }

/* ── Botoes e alertas ── */
.btn {
    display: inline-block; text-align: center; text-decoration: none;
    background: var(--accent-soft); color: var(--text);
    padding: 15px 24px; border: none; border-radius: var(--radius-sm);
    cursor: pointer; font-size: 15px; font-weight: 600; font-family: inherit;
    transition: background .15s, transform .1s, box-shadow .15s;
}
.btn:active { transform: scale(.98); }
.btn-primary {
    background: var(--accent); color: #fff; width: 100%;
    box-shadow: 0 2px 10px rgba(26,32,46,.18);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.btn-add {
    background: var(--card); color: var(--text);
    border: 1.5px dashed var(--border-strong);
    width: 100%; padding: 14px; margin-bottom: 16px;
}
.btn-add:hover { border-color: var(--accent); }
.actions { display: flex; gap: 10px; justify-content: center; margin-top: 24px; }
.alert {
    padding: 14px 16px; border-radius: var(--radius-sm);
    font-size: 14px; line-height: 1.5; margin-bottom: 16px;
}
.alert-error { background: var(--danger-soft); color: #8c2d21; border: 1px solid #f2c9c2; }
.loading { display: none; align-items: center; gap: 8px; justify-content: center; }
.btn.is-loading .btn-text { display: none; }
.btn.is-loading .loading { display: flex; }

/* ── Cadastro manual (layout cadastrador Homax) ── */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
}
.property-combobox { position: relative; }
.property-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 220px;
    overflow-y: auto;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    z-index: 50;
}
.property-dropdown.open { display: block; }
.property-option { padding: 9px 12px; font-size: 14px; cursor: pointer; }
.property-option:hover, .property-option.active { background: var(--accent-soft); }
.property-option-empty { color: var(--muted); cursor: default; }
.property-option-empty:hover { background: none; }
.field-error { display: none; color: var(--danger); font-size: 12px; margin-top: 6px; }
.field-error.show { display: block; }
.alert-success { background: var(--success-soft); color: #166534; border: 1px solid #bbf7d0; }

/* Hospede em linha: numero + nome + documento + remover */
.guest-row { display: flex; gap: 10px; align-items: end; }
.guest-row > .form-group { flex: 1; min-width: 0; }
.guest-row > .form-group.name-field { flex: 2; }
.guest-row > .remove-guest-wrap { flex: 0 0 66px; padding-bottom: 8px; }
.guest-num-wrap { display: flex; justify-content: center; padding-bottom: 10px; }

@media (max-width: 560px) {
    .form-row { grid-template-columns: 1fr; }
    .guest-row { flex-direction: column; align-items: stretch; }
    .guest-row > .form-group, .guest-row > .form-group.name-field { flex: 1; }
    .guest-num-wrap { justify-content: flex-start; padding-bottom: 0; }
    .remove-guest-wrap { padding-bottom: 0; align-self: flex-end; }
    .remove-guest-wrap:empty { display: none; }
}
.spinner {
    display: inline-block; width: 15px; height: 15px;
    border: 2px solid rgba(255,255,255,.35); border-top-color: #fff;
    border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Telas de sucesso/erro ── */
.page-title {
    font-family: 'Helvetica Neue', 'Inter', -apple-system, sans-serif;
    font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 8px;
}
.page-sub { color: var(--muted); font-size: 14px; margin: 0 0 4px; line-height: 1.5; }
.muted-text { color: var(--muted); font-size: 13px; line-height: 1.5; }
.card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 28px 24px; margin-bottom: 16px;
}
.center-card { margin-top: 40px; text-align: center; }
.modal-icon {
    width: 48px; height: 48px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.modal-icon.ok { background: var(--success-soft); color: var(--success); }
.modal-icon.err { background: var(--danger-soft); color: var(--danger); }

/* ── Dashboard (mapa de reservas) ── */
.dash-header {
    display: flex; align-items: flex-end; justify-content: space-between;
    flex-wrap: wrap; gap: 14px; margin-bottom: 14px;
}
.dash-header .page-title { margin-bottom: 2px; }
.dash-header .btn { width: auto; }
.dash-filters {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 10px 14px; box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.dash-filters .btn { width: auto; }
.dash-filters label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; font-weight: 500; margin: 0; }
.dash-filters input[type="date"], .dash-filters input[type="text"] {
    width: auto; min-width: 0; padding: 7px 10px; border: 1px solid var(--border-strong);
    border-radius: 8px; font-size: 13px; font-family: inherit;
}
.dash-filters input[type="text"] { width: 200px; flex: 1; }

/* Localizador com link para a reserva no Airbnb */
.dash-code {
    color: var(--text); font-weight: 700; text-decoration: none;
}

/* Nome do hospede com link para a pagina da reserva - sem hover visual */
.dash-guest-link { color: var(--text); text-decoration: none; }
.dash-guest-link:hover { color: var(--text); text-decoration: none; }

/* Variante sem seta/negrito - ID do anuncio na tela de imoveis */
.id-link {
    color: var(--text); text-decoration: none;
    border-bottom: 1.5px solid transparent; transition: border-color .15s, color .15s;
}
.id-link:hover { color: #1a56db; border-bottom-color: #1a56db; }

/* Cards de resumo */
.dash-stats {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 14px; margin-bottom: 20px;
}
.stat-card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 18px 20px; display: flex; flex-direction: column; gap: 4px;
}
.stat-num { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.stat-label { font-size: 12px; font-weight: 500; color: var(--muted); }

/* Tabela */
.dash-table-card { padding: 0; overflow: hidden; }
.dash-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dash-table thead th {
    text-align: left; padding: 12px 14px; font-weight: 600; font-size: 12px;
    color: var(--muted); background: #f8f7f4;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.dash-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.dash-table .col-center { text-align: center; }
.dash-table tbody tr:last-child td { border-bottom: none; }
.dash-table tbody tr { transition: background .12s; }
.dash-table tbody tr:hover { background: #f8fafc; }
.dash-empty { text-align: center; padding: 40px 16px !important; color: var(--muted); font-size: 14px; }

/* Badges de status */
.badge {
    display: inline-block; padding: 4px 11px; border-radius: 999px;
    font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge-ok     { background: var(--success-soft); color: var(--success); }
.badge-info   { background: #e8f0fe; color: #1a56db; }
.badge-warn   { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted  { background: var(--accent-soft); color: var(--muted); }

.btn-sm { padding: 7px 16px; font-size: 13px; }

/* No celular a tabela vira cards empilhados (label + valor por linha) */
@media (max-width: 900px) {
    .dash-stats { grid-template-columns: repeat(2, 1fr); }
    .dash-table-card { background: transparent; border: none; box-shadow: none; }
    .dash-table thead { display: none; }
    .dash-table tbody tr {
        display: block; background: var(--card); border: 1px solid var(--border);
        border-radius: var(--radius); box-shadow: var(--shadow);
        margin-bottom: 12px; padding: 8px 0;
    }
    .dash-table td {
        display: flex; justify-content: space-between; align-items: center;
        gap: 16px; border: none; padding: 7px 18px;
    }
    .dash-table td::before {
        content: attr(data-label); font-size: 11px; font-weight: 600;
        color: var(--muted); letter-spacing: 0.02em;
    }
    .dash-table td:last-child { justify-content: flex-end; padding-top: 10px; }
}
.section-title { font-size: 16px; font-weight: 700; margin: 0 0 14px; }

/* ── Admin de imoveis ── */
.imovel-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 16px;
}
.imovel-grid .form-group:nth-child(-n+2) { grid-column: span 2; }
.imovel-grid input { padding: 10px 12px; font-size: 14px; }
.imovel-card input { padding: 10px 12px; font-size: 14px; }
.imovel-form .btn-primary { width: auto; margin-top: 4px; }
@media (max-width: 700px) {
    .imovel-grid { grid-template-columns: 1fr 1fr; }
    .imovel-grid .form-group { grid-column: span 2 !important; }
    .imovel-grid .form-group:nth-child(n+3) { grid-column: span 1 !important; }
}
/* Headers ordenaveis da tabela de imoveis */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--text); }
.sort-arrow { font-size: 10px; }

/* Predio/unidade mais largo na tabela de imoveis */
.col-predio { min-width: 150px; white-space: nowrap; }

/* Toggle "sou estrangeiro" no bloco do CPF */
.foreign-toggle {
    display: flex; align-items: flex-start; gap: 8px;
    margin-top: 8px; font-size: 13px; color: var(--muted);
    font-weight: 500; cursor: pointer;
}
.foreign-toggle input[type="checkbox"] {
    width: auto; margin: 2px 0 0; accent-color: var(--accent); flex-shrink: 0;
}

/* Titulo do anuncio truncado na tabela de imoveis - tooltip no hover */
.col-titulo {
    display: inline-block;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

.dash-ext {
    color: var(--muted);
    text-decoration: none;
    font-size: 12px;
    margin-left: 4px;
}
.dash-ext:hover { color: var(--accent); }

/* Linha de edicao colapsavel na tabela-resumo de imoveis */
.edit-row > td {
    background: var(--accent-soft);
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-strong);
}
.edit-row[hidden] { display: none; }

.imovel-card-header {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 16px; padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.imovel-title { font-size: 15px; font-weight: 700; flex: 1; }
.flag-row {
    display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
    margin: 4px 0 16px;
}
.flag-item {
    display: flex; align-items: center; gap: 8px; margin: 0;
    font-size: 14px; color: var(--text); font-weight: 500; cursor: pointer;
}
.flag-item input[type="checkbox"] {
    width: 18px; height: 18px; accent-color: var(--accent); margin: 0;
}
.summary-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}
.summary-item { display: flex; flex-direction: column; gap: 4px; }
.summary-label { font-size: 12px; color: var(--muted); }
.summary-value { font-size: 14px; font-weight: 500; word-break: break-all; }
.payload-pre {
    background: #f8fafc; border: 1px solid var(--border); border-radius: 8px;
    padding: 14px; font-size: 12px; overflow-x: auto; white-space: pre-wrap;
}

/* ── Pagina da reserva - cards de hospede com thumbnails ── */
.guest-card-header {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 16px; padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.guest-card-name { font-size: 15px; font-weight: 700; flex: 1; }
.guest-card-body {
    display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap;
}
.guest-info {
    flex: 1; min-width: 220px;
    display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
.guest-media { display: flex; gap: 14px; flex-wrap: wrap; }
.media-item { display: flex; flex-direction: column; gap: 6px; }
.media-label {
    font-size: 11px; font-weight: 600; color: var(--muted);
    letter-spacing: 0.02em;
}
.doc-thumb {
    width: 140px; height: 95px; object-fit: cover;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    cursor: zoom-in; display: block; background: #f8f7f4;
    transition: box-shadow .15s;
}
.doc-thumb:hover { box-shadow: 0 0 0 3px rgba(26,32,46,.10); }
.doc-thumb-pdf, .doc-thumb-empty {
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px; color: var(--accent);
    text-decoration: none; cursor: pointer;
}
.doc-thumb-empty { color: var(--muted); cursor: default; }
.checkin-url { font-size: 12px; word-break: break-all; }

/* Link de check-in com botao copiar */
.copy-link {
    display: flex; align-items: flex-start; gap: 10px;
    background: #f8f7f4; border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 10px 12px;
}
.copy-link code {
    flex: 1; min-width: 0; font-size: 12.5px; line-height: 1.5;
    word-break: break-all; overflow-wrap: anywhere;
}
.btn-copy {
    flex-shrink: 0; padding: 5px 14px; border: 1px solid var(--border-strong);
    border-radius: 8px; background: var(--card); color: var(--text);
    font-size: 12px; font-weight: 600; font-family: inherit; cursor: pointer;
    transition: background .15s, border-color .15s;
}
.btn-copy:hover { border-color: var(--accent); }
.btn-copy.copied { background: var(--success-soft); color: var(--success); border-color: var(--success); }

.btn-danger {
    background: none; border: none; color: var(--danger);
    font-size: 12px; font-family: inherit; cursor: pointer;
    padding: 4px 8px; border-radius: 8px; margin-top: 10px;
}
.btn-danger:hover { background: var(--danger-soft); }

/* Lightbox - ampliacao do documento/foto */
.lightbox {
    display: none; position: fixed; inset: 0; z-index: 1000;
    background: rgba(10,12,18,.85); cursor: zoom-out;
    align-items: center; justify-content: center; padding: 24px;
}
.lightbox.open { display: flex; }
.lightbox img {
    max-width: 95vw; max-height: 92vh; border-radius: var(--radius-sm);
    box-shadow: 0 20px 60px rgba(0,0,0,.5); background: #fff;
}
