:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --text: #14213d;
    --muted: #64748b;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --accent: #f59e0b;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #ca8a04;
    --border: #e2e8f0;
    --shadow: 0 18px 45px rgba(15, 23, 42, .08);
    --radius: 18px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    scroll-behavior: smooth;
}
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-weight: 500;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; max-width: 100%; }

.app-shell {
    display: flex;
    min-height: 100vh;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}
.sidebar {
    width: 282px;
    max-width: 282px;
    background: #0f172a;
    color: #e2e8f0;
    padding: 22px;
    position: fixed;
    inset: 0 auto 0 0;
    overflow-y: auto;
    z-index: 20;
}
.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 10px 8px 22px;
    border-bottom: 1px solid rgba(226,232,240,.14);
    margin-bottom: 18px;
}
.brand-mark {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: linear-gradient(135deg, #0f766e, #14b8a6);
    box-shadow: 0 12px 28px rgba(20,184,166,.25);
    font-size: 24px;
}
.brand strong { display: block; font-size: 18px; font-weight: 700; }
.brand span { display: block; color: #94a3b8; font-size: 13px; margin-top: 2px; }
.menu { display: grid; gap: 6px; }
.menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: 13px;
    color: #cbd5e1;
    font-weight: 650;
}
.menu a:hover, .menu a.active { background: rgba(20,184,166,.15); color: #fff; }

.main {
    margin-left: 282px;
    width: calc(100% - 282px);
    max-width: calc(100% - 282px);
    flex: 0 0 auto;
    padding: 24px;
    min-width: 0;
    overflow-x: hidden;
}
.topbar {
    width: 100%;
    max-width: 100%;
    min-height: 64px;
    background: rgba(255,255,255,.86);
    backdrop-filter: blur(14px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    margin-bottom: 22px;
    position: sticky;
    top: 14px;
    z-index: 10;
}
.topbar span { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.menu-toggle { display: none; border: 0; background: var(--primary); color: #fff; border-radius: 12px; width: 42px; height: 42px; }

.page-title { max-width: 100%; margin: 0 0 18px; display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.page-title h1 { margin: 0; font-size: clamp(24px, 4vw, 34px); letter-spacing: -0.04em; font-weight: 700; }
.page-title p { margin: 6px 0 0; color: var(--muted); }

.grid { display: grid; gap: 16px; width: 100%; max-width: 100%; min-width: 0; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.card {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
}
.card h2, .card h3 { margin: 0 0 12px; font-weight: 700; letter-spacing: -0.03em; }
.metric { display: flex; flex-direction: column; gap: 6px; }
.metric span { color: var(--muted); font-size: 14px; }
.metric strong { font-size: 28px; font-weight: 700; letter-spacing: -0.04em; }
.metric small { color: var(--muted); }

.form { display: grid; gap: 14px; width: 100%; max-width: 100%; min-width: 0; }
.form-row { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; max-width: 100%; min-width: 0; }
label { min-width: 0; display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 650; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 13px;
    padding: 11px 12px;
    color: var(--text);
    background: #fff;
    outline: none;
}
textarea { min-height: 96px; resize: vertical; }
img, svg, video, canvas, iframe { max-width: 100%; height: auto; }
p, td, th { overflow-wrap: anywhere; }
input:focus, select:focus, textarea:focus { border-color: #14b8a6; box-shadow: 0 0 0 4px rgba(20,184,166,.12); }

.btn {
    border: 0;
    border-radius: 13px;
    padding: 11px 14px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 700;
    min-height: 42px;
    background: var(--primary);
    color: #fff;
    transition: transform .2s ease, opacity .2s ease;
}
.btn:hover { transform: translateY(-1px); opacity: .94; }
.btn-outline { background: #fff; color: var(--primary); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); }
.btn-warning { background: var(--warning); }
.btn-small { padding: 8px 10px; min-height: 34px; border-radius: 10px; font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; max-width: 100%; min-width: 0; }

.table-wrap {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: 16px;
}
table { width: 100%; border-collapse: collapse; min-width: 720px; background: #fff; }
th, td { padding: 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; background: #f8fafc; }
tr:last-child td { border-bottom: 0; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 9px; font-size: 12px; font-weight: 700; }
.badge.success { background: #dcfce7; color: #166534; }
.badge.warning { background: #fef3c7; color: #92400e; }
.badge.danger { background: #fee2e2; color: #991b1b; }
.badge.info { background: #dbeafe; color: #1e40af; }
.badge.muted { background: #e2e8f0; color: #475569; }

.toast { padding: 13px 16px; border-radius: 14px; margin-bottom: 14px; border: 1px solid var(--border); background: #fff; box-shadow: var(--shadow); }
.toast.success { border-color: #86efac; background: #f0fdf4; }
.toast.error { border-color: #fecaca; background: #fef2f2; }
.toast.warning { border-color: #fde68a; background: #fffbeb; }

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at top left, rgba(20,184,166,.28), transparent 34%),
        linear-gradient(135deg, #0f172a, #115e59);
}
.login-card { width: min(100%, 420px); background: #fff; border-radius: 24px; padding: 28px; box-shadow: 0 30px 80px rgba(2,6,23,.28); }
.login-card .brand-mark { margin-bottom: 14px; }
.login-card h1 { margin: 0 0 8px; font-size: 28px; font-weight: 700; letter-spacing: -0.04em; }
.login-card p { color: var(--muted); margin: 0 0 20px; }

.print-header { display: none; }
@media print {
    body { background: #fff; }
    .sidebar, .topbar, .no-print, .btn { display: none !important; }
    .main { margin: 0; padding: 0; }
    .card { box-shadow: none; border: 1px solid #ddd; }
    .print-header { display: block; margin-bottom: 16px; }
}

.landing-body { background: #f8fafc; width: 100%; max-width: 100%; overflow-x: hidden; }
.landing-hero {
    min-height: 92vh;
    display: grid;
    align-items: center;
    padding: 32px 20px;
    background: linear-gradient(135deg, #0f172a, #0f766e);
    color: #fff;
}
.landing-container { width: min(1120px, 100%); max-width: 100%; margin: 0 auto; }
.landing-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 54px; gap: 20px; flex-wrap: wrap; max-width: 100%; }
.landing-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 28px; align-items: center; max-width: 100%; min-width: 0; }
.landing-hero h1 { font-size: clamp(36px, 7vw, 66px); line-height: .98; letter-spacing: -0.06em; margin: 0 0 18px; font-weight: 700; }
.landing-hero p { color: #ccfbf1; font-size: 18px; line-height: 1.6; }
.landing-section { padding: 72px 20px; }
.landing-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; max-width: 100%; min-width: 0; }
.lead-card { background: #fff; border-radius: 24px; padding: 22px; box-shadow: var(--shadow); border: 1px solid var(--border); }

@media (max-width: 1050px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .landing-grid, .landing-cards { grid-template-columns: 1fr; }
}
@media (max-width: 780px) {
    .sidebar { transform: translateX(-105%); transition: transform .22s ease; }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .main { margin-left: 0; width: 100%; max-width: 100%; padding: 14px; }
    .topbar { top: 8px; border-radius: 16px; }
    .menu-toggle { display: inline-grid; place-items: center; }
    .grid-2, .grid-3, .grid-4, .form-row { grid-template-columns: 1fr; }
    .page-title { align-items: stretch; }
    .page-title .actions, .page-title .btn { width: 100%; }
    .actions .btn { flex: 1 1 140px; }
    .card { padding: 15px; }
    table { min-width: 640px; }
}


/* Correção final anti-estouro lateral */
.grid > *,
.form-row > *,
.card > *,
.landing-grid > *,
.landing-cards > * {
    min-width: 0;
    max-width: 100%;
}

body:not(.sidebar-open) .sidebar {
    max-width: 282px;
}

@media (max-width: 780px) {
    .app-shell,
    .main,
    .topbar,
    .page-title,
    .grid,
    .card,
    .form,
    .form-row,
    .landing-container,
    .landing-grid,
    .landing-cards {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .sidebar {
        width: min(282px, 88vw);
        max-width: 88vw;
    }

    .topbar {
        gap: 10px;
    }

    .topbar .btn {
        padding: 9px 11px;
        min-height: 38px;
        border-radius: 11px;
        white-space: nowrap;
    }

    .table-wrap {
        overflow-x: auto;
    }

    .table-wrap table {
        min-width: 620px;
    }
}


/* Ajuste definitivo: desktop sem barra lateral em dashboard/relatórios e botões legíveis */
html,
body,
.app-shell,
.main {
    overflow-x: hidden !important;
}

.btn,
.btn *,
button,
button *,
.menu a,
.menu a *,
.badge,
.badge * {
    overflow-wrap: normal !important;
    word-break: normal !important;
    white-space: nowrap !important;
}

.page-actions,
.actions {
    flex-wrap: wrap;
}

.metric-phone {
    font-size: clamp(18px, 2.2vw, 28px);
    overflow-wrap: normal !important;
    word-break: normal !important;
    white-space: nowrap !important;
}

.dashboard-panels,
.report-panels {
    align-items: start;
}

.dashboard-panels .card,
.report-panels .card,
.leads-card {
    overflow: hidden;
}

/* Listas compactas substituem tabelas largas nas telas resumidas */
.info-list {
    display: grid;
    gap: 10px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.info-row {
    display: grid;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
}

.info-row-head,
.info-row-main,
.info-row-values {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.info-row-head {
    justify-content: space-between;
}

.info-row-main {
    flex-direction: column;
    align-items: flex-start;
}

.info-row-values {
    flex-wrap: wrap;
}

.info-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.info-title {
    display: block;
    max-width: 100%;
    min-width: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    overflow-wrap: anywhere;
}

.info-sub {
    display: block;
    max-width: 100%;
    min-width: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.info-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 30px;
    padding: 6px 9px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    background: #f8fafc;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.info-empty {
    color: var(--muted);
    padding: 14px;
    border: 1px dashed var(--border);
    border-radius: 14px;
    background: #fff;
}

/* Leads: botões não quebram e tabela não força rolagem no desktop */
.leads-table-wrap {
    overflow-x: hidden;
}

.leads-table {
    width: 100%;
    min-width: 0 !important;
    max-width: 100%;
    table-layout: fixed;
}

.leads-table th,
.leads-table td {
    padding: 10px 8px;
    font-size: 13px;
    overflow-wrap: anywhere;
}

.leads-table th:nth-child(1),
.leads-table td:nth-child(1) { width: 102px; }
.leads-table th:nth-child(2),
.leads-table td:nth-child(2) { width: 14%; }
.leads-table th:nth-child(3),
.leads-table td:nth-child(3) { width: 15%; }
.leads-table th:nth-child(4),
.leads-table td:nth-child(4) { width: 14%; }
.leads-table th:nth-child(5),
.leads-table td:nth-child(5) { width: auto; }
.leads-table th:nth-child(6),
.leads-table td:nth-child(6) { width: 110px; }
.leads-table th:nth-child(7),
.leads-table td:nth-child(7) { width: 112px; }

.lead-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    width: 100%;
    min-width: 0;
    align-items: stretch;
}

.lead-actions .btn {
    width: 100%;
    min-height: 31px;
    padding: 7px 8px;
    font-size: 12px;
    line-height: 1;
    white-space: nowrap !important;
}

@media (max-width: 1180px) {
    .dashboard-panels,
    .report-panels {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 780px) {
    .main {
        padding-left: 12px;
        padding-right: 12px;
    }

    .page-title > .btn,
    .page-title .actions,
    .page-actions,
    .page-actions .btn {
        width: 100%;
    }

    .info-row-head,
    .info-row-values {
        align-items: flex-start;
    }

    .info-row-head {
        flex-direction: column;
    }

    .metric strong {
        font-size: 24px;
    }

    .metric-phone {
        font-size: 18px;
    }

    .leads-table-wrap {
        overflow-x: auto;
    }

    .leads-table {
        min-width: 860px !important;
        table-layout: auto;
    }
}

/* HOTFIX FINAL 12/06/2026
   Remove a barra horizontal dos cards do Dashboard/Relatórios mesmo em arquivos PHP antigos
   que ainda usam tabela dentro de cards em duas colunas. */
@media (min-width: 781px) {
    .main .grid-2 > .card > .table-wrap,
    .main .grid-2 > .card .table-wrap,
    .dashboard-panels .table-wrap,
    .report-panels .table-wrap {
        overflow-x: hidden !important;
        max-width: 100% !important;
    }

    .main .grid-2 > .card > .table-wrap table,
    .main .grid-2 > .card .table-wrap table,
    .dashboard-panels table,
    .report-panels table {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        table-layout: fixed !important;
    }

    .main .grid-2 > .card > .table-wrap th,
    .main .grid-2 > .card > .table-wrap td,
    .main .grid-2 > .card .table-wrap th,
    .main .grid-2 > .card .table-wrap td,
    .dashboard-panels th,
    .dashboard-panels td,
    .report-panels th,
    .report-panels td {
        padding: 10px 8px !important;
        font-size: 12px !important;
        line-height: 1.3 !important;
        white-space: normal !important;
        overflow-wrap: break-word !important;
        word-break: normal !important;
        vertical-align: top;
    }

    .main .grid-2 > .card > .table-wrap .btn,
    .main .grid-2 > .card .table-wrap .btn,
    .dashboard-panels .btn,
    .report-panels .btn,
    .lead-actions .btn {
        white-space: nowrap !important;
        word-break: keep-all !important;
        overflow-wrap: normal !important;
    }
}

/* Patch 13/06/2026: ícone oficial e Destinos sem rolagem lateral */
.destinos-card {
    overflow: hidden;
}

.destinos-list {
    display: grid;
    gap: 10px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.destino-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
}

.destino-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    max-width: 100%;
}

.destino-icon {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(15,118,110,.13), rgba(245,158,11,.16));
    font-size: 21px;
}

.destino-texto {
    display: grid;
    gap: 3px;
    min-width: 0;
    max-width: 100%;
}

.destino-texto strong,
.destino-texto span,
.destino-texto small {
    display: block;
    max-width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
}

.destino-texto strong {
    color: var(--text);
    font-size: 15px;
    font-weight: 700;
}

.destino-texto span,
.destino-texto small {
    color: var(--muted);
    line-height: 1.35;
}

.destino-texto small {
    font-size: 12px;
}

.destino-status,
.destino-actions {
    min-width: 0;
}

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

.destino-actions .btn {
    white-space: nowrap !important;
    min-width: 0;
}

@media (max-width: 980px) {
    .destino-item {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .destino-status,
    .destino-actions {
        width: 100%;
    }

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

    .destino-actions .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .destino-main {
        align-items: flex-start;
    }

    .destino-actions {
        grid-template-columns: 1fr;
    }
}

/* Patch 13/06/2026-2: Pacotes sem rolagem lateral no desktop e mobile */
.pacotes-card {
    overflow: hidden;
}

.pacotes-list {
    display: grid;
    gap: 10px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.pacote-item {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) auto auto auto;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
}

.pacote-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    max-width: 100%;
}

.pacote-icon {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(15,118,110,.13), rgba(245,158,11,.16));
    font-size: 21px;
}

.pacote-texto {
    display: grid;
    gap: 3px;
    min-width: 0;
    max-width: 100%;
}

.pacote-texto strong,
.pacote-texto span,
.pacote-texto small {
    display: block;
    max-width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
}

.pacote-texto strong {
    color: var(--text);
    font-size: 15px;
    font-weight: 700;
}

.pacote-texto span,
.pacote-texto small {
    color: var(--muted);
    line-height: 1.35;
}

.pacote-texto small {
    font-size: 12px;
}

.pacote-meta,
.pacote-status,
.pacote-actions {
    min-width: 0;
}

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

.pacote-actions .btn,
.pacote-meta .info-chip {
    white-space: nowrap !important;
    min-width: 0;
}

@media (max-width: 1180px) {
    .pacote-item {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .pacote-main {
        grid-column: 1 / -1;
    }

    .pacote-meta,
    .pacote-status,
    .pacote-actions {
        width: 100%;
    }

    .pacote-actions {
        justify-content: flex-end;
    }
}

@media (max-width: 780px) {
    .pacote-item {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .pacote-main {
        align-items: flex-start;
    }

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

    .pacote-meta .info-chip {
        width: 100%;
        justify-content: center;
    }

    .pacote-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .pacote-actions .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .pacote-meta,
    .pacote-actions {
        grid-template-columns: 1fr;
    }
}
