:root {
    --portal-sidebar-width: 278px;
    --portal-sidebar-bg: #111827;
    --portal-sidebar-muted: #94a3b8;
    --portal-border: #e5e7eb;
    --portal-surface: #ffffff;
    --portal-canvas: #f4f6f9;
    --portal-text: #182230;
    --portal-muted: #667085;
    --portal-primary: #155eef;
    --portal-radius: 14px;
    --portal-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 20px rgba(16, 24, 40, .04);
}

html, body { min-height: 100%; }
body { margin: 0; background: var(--portal-canvas); color: var(--portal-text); font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif; }
.min-w-0 { min-width: 0; }

.portal-shell { min-height: 100vh; }
.portal-sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 1040; width: var(--portal-sidebar-width);
    display: flex; flex-direction: column; background: var(--portal-sidebar-bg); color: #fff;
    border-right: 1px solid rgba(255,255,255,.06); overflow: hidden;
}
.portal-brand { height: 78px; padding: 14px 16px 14px 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(255,255,255,.08); }
.portal-brand-link { color: #fff; text-decoration: none; display: flex; align-items: center; gap: 12px; min-width: 0; }
.portal-brand-mark { width: 42px; height: 42px; flex: 0 0 42px; border-radius: 12px; display: grid; place-items: center; background: #fff; color: #111827; font-weight: 800; letter-spacing: -.04em; }
.portal-brand-text { display: flex; flex-direction: column; min-width: 0; }
.portal-brand-text strong { font-size: .98rem; white-space: nowrap; }
.portal-brand-text small { color: var(--portal-sidebar-muted); }
.portal-sidebar-close { color: #cbd5e1; }

.portal-nav { flex: 1; overflow-y: auto; padding: 18px 12px; scrollbar-width: thin; scrollbar-color: #334155 transparent; }
.portal-nav-section + .portal-nav-section { margin-top: 18px; }
.portal-nav-title { display: flex; align-items: center; gap: 8px; padding: 0 10px 7px; color: #64748b; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .075em; }
.portal-nav-items { display: grid; gap: 3px; }
.portal-nav-link { display: flex; align-items: center; gap: 11px; min-height: 42px; padding: 9px 11px; color: #cbd5e1; text-decoration: none; border-radius: 9px; font-size: .91rem; transition: background .15s ease, color .15s ease, transform .15s ease; }
.portal-nav-link i { width: 19px; text-align: center; font-size: 1.02rem; }
.portal-nav-link:hover { color: #fff; background: rgba(255,255,255,.07); }
.portal-nav-link.active { color: #fff; background: rgba(37,99,235,.92); box-shadow: inset 3px 0 0 #93c5fd; }
.portal-sidebar-footer { padding: 15px 20px 18px; border-top: 1px solid rgba(255,255,255,.08); color: #cbd5e1; font-size: .8rem; }
.portal-sidebar-footer strong { display: block; margin-top: 2px; color: #fff; }

.portal-main { min-height: 100vh; margin-left: var(--portal-sidebar-width); display: flex; flex-direction: column; }
.portal-topbar { position: sticky; top: 0; z-index: 1025; height: 78px; padding: 0 28px; display: flex; align-items: center; justify-content: space-between; gap: 20px; background: rgba(255,255,255,.95); backdrop-filter: blur(12px); border-bottom: 1px solid var(--portal-border); }
.portal-page-kicker { color: var(--portal-muted); font-size: .72rem; line-height: 1.2; text-transform: uppercase; letter-spacing: .075em; font-weight: 700; }
.portal-page-title { margin: 3px 0 0; font-size: 1.12rem; line-height: 1.25; font-weight: 700; }
.portal-menu-toggle { width: 42px; height: 42px; border: 1px solid var(--portal-border); background: #fff; }
.portal-context-btn { height: 42px; border: 1px solid var(--portal-border); background: #fff; color: #344054; font-size: .86rem; }
.portal-user-btn { min-height: 46px; display: flex; align-items: center; gap: 9px; border: 0; background: transparent; padding: 3px 6px; text-align: left; }
.portal-avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: #e8efff; color: var(--portal-primary); font-weight: 800; }
.portal-user-name { max-width: 190px; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-user-company { max-width: 190px; color: var(--portal-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-user-menu { min-width: 250px; }
.portal-dropdown-wide { min-width: 310px; max-height: 430px; overflow-y: auto; }

.portal-content { flex: 1; padding: 28px; }
.portal-footer { min-height: 52px; padding: 14px 28px; display: flex; justify-content: space-between; gap: 16px; align-items: center; color: var(--portal-muted); font-size: .78rem; border-top: 1px solid var(--portal-border); background: #fff; }
.portal-page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.portal-page-heading h2 { margin: 2px 0 6px; font-size: clamp(1.45rem, 2vw, 1.85rem); font-weight: 750; letter-spacing: -.02em; }
.portal-page-heading p { margin: 0; max-width: 820px; color: var(--portal-muted); }
.portal-eyebrow { display: block; color: var(--portal-primary); font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }

.portal-stat-card { height: 100%; min-height: 112px; padding: 20px; display: flex; align-items: center; gap: 14px; background: var(--portal-surface); border: 1px solid var(--portal-border); border-radius: var(--portal-radius); box-shadow: var(--portal-shadow); }
.portal-stat-icon { width: 48px; height: 48px; flex: 0 0 48px; display: grid; place-items: center; border-radius: 12px; background: #eef4ff; color: var(--portal-primary); font-size: 1.25rem; }
.portal-stat-card div:last-child { min-width: 0; display: flex; flex-direction: column; }
.portal-stat-card span { color: var(--portal-muted); font-size: .78rem; }
.portal-stat-card strong { margin-top: 2px; font-size: 1.08rem; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; }

.portal-panel { padding: 22px; background: var(--portal-surface); border: 1px solid var(--portal-border); border-radius: var(--portal-radius); box-shadow: var(--portal-shadow); }
.portal-panel-header { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 22px; }
.portal-panel-header h3 { margin: 3px 0 0; font-size: 1.05rem; font-weight: 720; }
.portal-migration-flow { display: flex; align-items: stretch; gap: 12px; }
.portal-migration-flow > i { align-self: center; color: #98a2b3; }
.portal-flow-step { flex: 1; min-width: 0; padding: 15px; display: flex; align-items: center; gap: 11px; border: 1px solid var(--portal-border); border-radius: 11px; background: #fafafa; }
.portal-flow-step > span { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; border-radius: 50%; background: #eaecf0; color: #475467; font-weight: 800; font-size: .78rem; }
.portal-flow-step div { min-width: 0; display: flex; flex-direction: column; }
.portal-flow-step strong { font-size: .88rem; }
.portal-flow-step small { color: var(--portal-muted); font-size: .73rem; }
.portal-flow-step.done { border-color: #abefc6; background: #f6fef9; }
.portal-flow-step.done > span { background: #dcfae6; color: #067647; }
.portal-flow-step.active { border-color: #b2ccff; background: #f5f8ff; }
.portal-flow-step.active > span { background: #d1e0ff; color: #1849a9; }

.portal-context-list { display: grid; gap: 8px; }
.portal-context-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; background: #f8fafc; color: #344054; font-size: .87rem; }
.portal-context-item i { color: var(--portal-primary); }
.portal-context-more { color: var(--portal-muted); font-size: .78rem; padding: 4px 10px; }
.portal-empty { padding: 22px 12px; text-align: center; color: var(--portal-muted); background: #f8fafc; border-radius: 10px; }
.portal-module-placeholder { min-height: 360px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.portal-placeholder-icon { width: 70px; height: 70px; display: grid; place-items: center; margin-bottom: 16px; border-radius: 18px; background: #fff4e5; color: #b54708; font-size: 1.8rem; }
.portal-module-placeholder h3 { font-size: 1.2rem; }
.portal-module-placeholder p { max-width: 620px; }

.portal-sidebar-backdrop { display: none; }

@media (max-width: 991.98px) {
    .portal-sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 20px 0 40px rgba(15,23,42,.18); }
    .portal-main { margin-left: 0; }
    .portal-sidebar-backdrop { position: fixed; inset: 0; z-index: 1035; background: rgba(15,23,42,.48); opacity: 0; pointer-events: none; display: block; transition: opacity .2s ease; }
    body.portal-sidebar-open { overflow: hidden; }
    body.portal-sidebar-open .portal-sidebar { transform: translateX(0); }
    body.portal-sidebar-open .portal-sidebar-backdrop { opacity: 1; pointer-events: auto; }
}

@media (max-width: 767.98px) {
    .portal-topbar { height: 68px; padding: 0 16px; }
    .portal-content { padding: 20px 15px; }
    .portal-footer { padding: 12px 16px; }
    .portal-migration-flow { flex-direction: column; }
    .portal-migration-flow > i { display: none; }
    .portal-panel { padding: 18px; }
}

/* Gate 03 - Empreendimentos e unidades */
.portal-card-header {
    padding: 1.15rem 1.35rem;
    border-bottom: 1px solid var(--portal-border, #e5e7eb);
}
.portal-card-body { padding: 1.35rem; }
.portal-context-box {
    display: grid;
    gap: .35rem;
    padding: .9rem 1rem;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: .75rem;
    color: #475569;
    font-size: .875rem;
}
.portal-context-box strong { color: #0f172a; font-size: 1rem; }
.portal-empty-state {
    min-height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    padding: 2rem;
    color: #64748b;
    text-align: center;
}
.portal-empty-state .bi { font-size: 1.4rem; }
.portal-table thead th {
    white-space: nowrap;
    background: #f8fafc;
    color: #64748b;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom-width: 1px;
}
.portal-table tbody td { border-color: #eef2f7; }
@media (max-width: 767.98px) {
    .portal-card-header { align-items: stretch !important; }
    .portal-card-header > .d-flex { width: 100%; }
    #filtroUnidades { flex: 1; }
}

/* Gate 04 - Tabela de preços */
#resultadoObservacoes {
    padding: .8rem 1rem;
    border-left: 3px solid var(--portal-primary, #2563eb);
    background: #f8fafc;
    border-radius: .5rem;
    color: #475569;
}

@media print {
    .portal-sidebar,
    .portal-topbar,
    .portal-footer,
    .portal-page-header,
    #tabelaPrecoAlert,
    #consultaLoading,
    #btnConsultar,
    #btnImprimir,
    #filtroTabela,
    #modalCondicoes,
    .portal-card.mb-4:first-of-type {
        display: none !important;
    }
    .portal-main { margin-left: 0 !important; }
    .portal-content { padding: 0 !important; background: #fff !important; }
    #resultadoTabelaPreco { display: block !important; }
    .portal-card { box-shadow: none !important; border: 1px solid #d0d5dd !important; }
    .table-responsive { overflow: visible !important; }
}

/* Gate 05 - Visitantes / relatórios */
.portal-migration-flow { overflow-x: auto; padding-bottom: 3px; }
.portal-migration-flow .portal-flow-step { min-width: 190px; }

/* Gate 08 v3 - Reserva orientada ao fluxo de negócio */
.reserva-page-heading { margin-bottom: 18px; }
.reserva-security-pill {
    max-width: 330px; display: flex; align-items: center; gap: 9px; padding: 10px 13px;
    border: 1px solid #abefc6; border-radius: 999px; background: #f6fef9; color: #067647;
    font-size: .78rem; font-weight: 650;
}
.reserva-tabs-wrap { display: flex; }
.reserva-tabs { gap: 6px; padding: 5px; border: 1px solid var(--portal-border); border-radius: 12px; background: #fff; box-shadow: var(--portal-shadow); }
.reserva-tabs .nav-link { border-radius: 8px; color: #475467; font-weight: 650; font-size: .88rem; }
.reserva-tabs .nav-link.active { background: #eef4ff; color: #1849a9; }
.reserva-workflow-panel, .reserva-cliente-panel { border: 1px solid var(--portal-border); }
.reserva-step-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.reserva-step-card { display: flex; align-items: flex-start; gap: 12px; padding: 15px; border: 1px solid #eaecf0; border-radius: 12px; background: #fcfcfd; }
.reserva-step-number { width: 30px; height: 30px; flex: 0 0 30px; display: grid; place-items: center; border-radius: 50%; background: #e8efff; color: var(--portal-primary); font-size: .78rem; font-weight: 800; }
.reserva-unidades-area { padding: 16px; border: 1px solid #eaecf0; border-radius: 12px; background: #fff; }
.reserva-unidades-select { min-height: 190px; }
.reserva-unidades-select option { padding: 7px 8px; border-radius: 5px; }
.reserva-cliente-card { display: flex; align-items: center; gap: 12px; min-height: 72px; padding: 13px; border: 1px solid #b2ccff; border-radius: 12px; background: #f5f8ff; }
.reserva-cliente-card.is-empty { border-color: #eaecf0; background: #fcfcfd; }
.reserva-cliente-icon { width: 40px; height: 40px; flex: 0 0 40px; display: grid; place-items: center; border-radius: 10px; background: #d1e0ff; color: #1849a9; }
.reserva-cliente-card.is-empty .reserva-cliente-icon { background: #f2f4f7; color: #667085; }
.reserva-cliente-card strong { display: block; overflow: hidden; text-overflow: ellipsis; }
#resumoDisponibilidade { color: #475467 !important; font-weight: 650; }
@media (max-width: 991.98px) {
    .reserva-step-grid { grid-template-columns: 1fr; }
    .reserva-security-pill { max-width: none; }
}
@media (max-width: 767.98px) {
    .reserva-page-heading { flex-direction: column; }
    .reserva-tabs-wrap { overflow-x: auto; padding-bottom: 4px; }
    .reserva-tabs { min-width: max-content; }
}

/* Gate 09 - Propostas */
#propostaPage .condicao-row td { vertical-align: middle; }
#propostaPage #reservaSelecionada strong { display:block; color:var(--bs-body-color); }
#propostaPage .portal-table td { vertical-align: middle; }
