@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --navy: #0f172a;
    --navy-soft: #1e293b;
    --orange: #f4a261;
    --coral: #e76f51;
    --teal: #2a9d8f;
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-muted: #f6f7f9;
    --muted: #94a3b8;
    --muted-2: #a9b3c0;
    --text: #475569;
    --border: #eef1f5;
    --border-2: #e8ecf1;
    --hover: #fcfcfd;
    --header-bg: rgba(255, 255, 255, 0.9);
    --nav-hover-bg: #f7f8fa;
    --row-border: #f4f6f9;
    --bar-track: #f1f4f8;
    --scrollbar: #e2e8f0;
    --modal-overlay: rgba(15, 23, 42, 0.4);
    --shadow: rgba(15, 23, 42, 0.08);
    --row-hot-bg: #fffaf5;
    --row-hot-hover: #fff5eb;
    --row-wait-bg: #fff8f8;
    --row-wait-hover: #fff1f1;
    --login-bg: #ffffff;
    --login-glow-1: rgba(244, 162, 97, 0.13);
    --login-glow-2: rgba(42, 157, 143, 0.1);
    --font: 'Inter', system-ui, sans-serif;
}

[data-theme="dark"] {
    --navy: #f1f5f9;
    --navy-soft: #e2e8f0;
    --bg: #0b1220;
    --surface: #111827;
    --surface-muted: #1a2436;
    --muted: #94a3b8;
    --muted-2: #7c8a9e;
    --text: #cbd5e1;
    --border: #1e293b;
    --border-2: #334155;
    --hover: #111b2e;
    --header-bg: rgba(11, 18, 32, 0.92);
    --nav-hover-bg: #1a2436;
    --row-border: #1e293b;
    --bar-track: #1e293b;
    --scrollbar: #334155;
    --modal-overlay: rgba(0, 0, 0, 0.62);
    --shadow: rgba(0, 0, 0, 0.35);
    --row-hot-bg: rgba(234, 88, 12, 0.1);
    --row-hot-hover: rgba(234, 88, 12, 0.15);
    --row-wait-bg: rgba(239, 68, 68, 0.1);
    --row-wait-hover: rgba(239, 68, 68, 0.15);
    --login-bg: #0b1220;
    --login-glow-1: rgba(244, 162, 97, 0.08);
    --login-glow-2: rgba(42, 157, 143, 0.06);
}

[data-theme="dark"] .score-badge {
    color: #f4a261;
    border-color: #3d2f24;
}

[data-theme="dark"] .metric-trend--up { color: #4ade80; background: rgba(22, 163, 74, 0.15); }
[data-theme="dark"] .metric-trend--down { color: #f87171; background: rgba(185, 28, 28, 0.15); }
[data-theme="dark"] .metric-trend--flat { background: #1e293b; }

[data-theme="dark"] .lead-badge--hot { color: #fdba74; background: rgba(234, 88, 12, 0.2); border-color: rgba(251, 146, 60, 0.35); }
[data-theme="dark"] .lead-badge--score { color: #5eead4; background: rgba(20, 184, 166, 0.15); border-color: rgba(45, 212, 191, 0.3); }
[data-theme="dark"] .lead-badge--wait { color: #fca5a5; background: rgba(239, 68, 68, 0.15); border-color: rgba(248, 113, 113, 0.3); }

[data-theme="dark"] .credit-pill--hot { border-color: #4a3524; color: #f4a261; }
[data-theme="dark"] .alert--success { color: #86efac; background: rgba(22, 163, 74, 0.12); border-color: rgba(34, 197, 94, 0.25); }
[data-theme="dark"] .alert--error { color: #fca5a5; background: rgba(185, 28, 28, 0.12); border-color: rgba(239, 68, 68, 0.25); }
[data-theme="dark"] .alert--error code { background: rgba(0, 0, 0, 0.25); }

[data-theme="dark"] .btn-primary { background: #e2e8f0; color: #0f172a; }
[data-theme="dark"] .btn-primary:hover { background: #f8fafc; color: #0f172a; }

[data-theme="dark"] .copy-button { background: #e2e8f0; color: #0f172a; }

[data-theme="dark"] .litepicker {
    --litepicker-container-months-color-bg: #111827;
    --litepicker-container-months-box-shadow-color: rgba(0, 0, 0, 0.4);
    --litepicker-month-header-color: #e2e8f0;
    --litepicker-button-prev-month-color: #94a3b8;
    --litepicker-button-next-month-color: #94a3b8;
    --litepicker-day-color: #cbd5e1;
    --litepicker-day-color-hover: #f4a261;
    --litepicker-is-today-color: #f4a261;
    --litepicker-is-in-range-color: #1a2436;
    --litepicker-is-start-color-bg: #f4a261;
    --litepicker-is-end-color-bg: #f4a261;
    --litepicker-button-apply-color-bg: #e2e8f0;
    --litepicker-button-apply-color: #0f172a;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--navy-soft);
    font-family: var(--font);
    font-feature-settings: 'tnum' 1;
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

a { color: var(--navy); text-decoration: none; }
a:hover { color: var(--coral); }

::-webkit-scrollbar { height: 6px; width: 6px; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 6px; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

/* Header */
.header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--header-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 16px 28px;
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.header-logo { height: 32px; width: auto; display: block; }

.header-tag {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--muted);
    letter-spacing: -0.01em;
}

.header-spacer { flex: 1; }

.header-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: wrap;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    padding: 8px 10px;
    border-radius: 7px;
    transition: background 0.15s, color 0.15s;
}

.nav-link:hover { color: var(--navy); background: var(--nav-hover-bg); }

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--border-2);
    border-radius: 8px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.theme-toggle:hover {
    border-color: #cbd5e1;
    color: var(--navy);
    background: var(--nav-hover-bg);
}

.theme-icon { display: block; }

.theme-icon--sun { display: none; }

[data-theme="dark"] .theme-icon--moon { display: none; }
[data-theme="dark"] .theme-icon--sun { display: block; }

.login-theme {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 30;
}

.header-divider { width: 1px; height: 20px; background: var(--border); margin: 0 10px; }

.nav-link svg { flex-shrink: 0; }

.header-user {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-size: 13px;
    font-weight: 500;
    color: var(--navy-soft);
}

.user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 999px;
    border: 1px solid var(--border-2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10.5px;
    font-weight: 600;
    color: #64748b;
}

/* Main */
.main-content {
    max-width: 1280px;
    margin: 0 auto;
    padding: 44px 28px 72px;
    display: flex;
    flex-direction: column;
    gap: 44px;
    flex: 1;
    width: 100%;
}

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
}

.page-title {
    margin: 0;
    font-size: 30px;
    font-weight: 600;
    letter-spacing: -0.03em;
    color: var(--navy);
}

.page-subtitle {
    margin: 8px 0 0;
    font-size: 14px;
    color: var(--muted);
}

.date-btn {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: 9px;
    padding: 10px 14px;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    color: var(--navy-soft);
    cursor: pointer;
    min-height: 42px;
    transition: border-color 0.15s;
}

.date-btn:hover { border-color: #cbd5e1; }

.date-btn input {
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--navy-soft);
    cursor: pointer;
    width: 180px;
    padding: 0;
}

.date-btn input:focus { outline: none; }

.page-head-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.date-btn--static { cursor: default; }

.range-toggle {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--muted);
    padding: 10px 2px;
    border-bottom: 1px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}

.range-toggle:hover {
    color: var(--navy);
    border-bottom-color: var(--border-2);
}

/* Metrics strip */
.metrics-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.metric-cell {
    padding: 24px 28px;
    border-right: 1px solid var(--border);
}

.metric-cell:first-child { padding-left: 0; }
.metric-cell:last-child { border-right: none; padding-right: 0; }

.metric-label {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.11em;
    text-transform: uppercase;
    color: var(--muted-2);
}

.metric-value {
    margin-top: 12px;
    font-size: 34px;
    font-weight: 600;
    letter-spacing: -0.035em;
    line-height: 1;
    color: var(--navy);
}

.metric-value-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.metric-value-row .metric-value { margin-top: 0; }

.metric-trend {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: -0.01em;
    padding: 3px 8px;
    border-radius: 999px;
}

.metric-trend--up { color: #15803d; background: #ecfdf3; }
.metric-trend--down { color: #b91c1c; background: #fef2f2; }
.metric-trend--flat { color: var(--muted); background: #f1f5f9; }

/* Leads section */
.leads-section { display: flex; flex-direction: column; gap: 18px; }

.leads-toolbar {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.status-tabs {
    display: flex;
    gap: 22px;
    align-items: center;
}

.status-tab {
    background: none;
    border: none;
    border-bottom: 1.5px solid transparent;
    padding: 0 0 10px;
    color: var(--muted);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: -0.01em;
    cursor: pointer;
    display: inline-flex;
    gap: 7px;
    align-items: baseline;
    text-decoration: none;
    transition: color 0.15s, border-color 0.15s;
}

.status-tab:hover { color: var(--navy-soft); }

.status-tab.active {
    color: var(--navy);
    font-weight: 600;
    border-bottom-color: var(--navy);
}

.status-tab .tab-num { color: var(--muted-2); font-weight: 500; }

.search-box {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 9px;
    border-bottom: 1px solid var(--border);
    padding: 8px 2px;
    min-width: 230px;
    max-width: 320px;
    margin-left: auto;
}

.search-box svg { flex-shrink: 0; }

.search-box input {
    flex: 1;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: 13px;
    color: var(--navy);
    background: transparent;
    min-width: 0;
}

.search-box input::placeholder { color: var(--muted-2); }

.btn-export {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 0;
    padding: 9px 13px;
    border: 1px solid var(--border-2);
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--navy-soft);
    text-decoration: none;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.btn-export:hover {
    border-color: #cbd5e1;
    color: var(--navy);
    background: var(--hover);
}

.table-wrap { overflow-x: auto; margin: 0 -4px; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1080px;
}

.data-table th {
    text-align: left;
    padding: 0 16px 12px 4px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted-2);
    border-bottom: 1px solid var(--border-2);
}

.data-table th.th-right { text-align: right; padding: 0 4px 12px 16px; }

.data-table td {
    padding: 18px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--row-border);
    vertical-align: middle;
}

.data-table td.td-score { padding-left: 4px; }
.data-table td.td-date { color: var(--muted); white-space: nowrap; }
.data-table td.td-actions { text-align: right; white-space: nowrap; padding-right: 4px; }

.data-table tbody tr:hover { background: var(--hover); }
.data-table tbody tr:last-child td { border-bottom: none; }

.data-table tbody tr.hidden-row { display: none; }

.data-table tbody tr.row-hot { background: var(--row-hot-bg); }
.data-table tbody tr.row-hot:hover { background: var(--row-hot-hover); }
.data-table tbody tr.row-waiting { background: var(--row-wait-bg); }
.data-table tbody tr.row-waiting:hover { background: var(--row-wait-hover); }

.lead-link { font-size: 14px; font-weight: 500; color: var(--navy); }
.lead-link:hover { color: var(--coral); }

.lead-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.lead-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.lead-badge--hot {
    color: #c2410c;
    background: #ffedd5;
    border: 1px solid #fed7aa;
}

.lead-badge--score {
    color: #0f766e;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
}

.lead-badge--wait {
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.cell-last-sim {
    max-width: 220px;
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--muted);
}

.score-display {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
}

.score-display.zero { color: var(--muted-2); font-weight: 600; }

.score-dot {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    flex-shrink: 0;
}

.score-dot.high { background: var(--coral); }
.score-dot.medium { background: var(--orange); }
.score-dot.low { background: #cbd5e1; }
.score-dot.zero { background: transparent; border: 1px solid #cbd5e1; }

.assessor-text { color: var(--text); }
.assessor-empty { color: var(--muted-2); font-style: normal; }

.wa-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    white-space: nowrap;
}

.wa-link:hover { color: var(--teal); }

.btn-ai {
    background: none;
    border: none;
    padding: 5px;
    cursor: pointer;
    display: inline-flex;
    border-radius: 7px;
    transition: background 0.15s;
}

.btn-ai:hover { background: #f5f1fe; }

.action-group {
    display: inline-flex;
    gap: 6px;
    justify-content: flex-end;
}

.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1px solid var(--border-2);
    border-radius: 8px;
    padding: 8px 12px;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    min-height: 36px;
    text-decoration: none;
    transition: border-color 0.15s, color 0.15s;
}

.btn-action--atender { color: var(--navy-soft); }
.btn-action--atender:hover { border-color: var(--teal); color: #22867a; }

.btn-action--arquivar { color: var(--muted); }
.btn-action--arquivar:hover { border-color: #cbd5e1; color: var(--text); }

.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12.5px;
    color: var(--muted-2);
    padding-top: 4px;
}

.empty-cell {
    text-align: center;
    padding: 32px 16px !important;
    color: var(--muted);
}

/* Analytics */
.analytics-section { display: flex; flex-direction: column; gap: 26px; }

.analytics-head {
    display: flex;
    align-items: center;
    gap: 14px;
}

.analytics-head span {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.11em;
    text-transform: uppercase;
    color: var(--muted-2);
}

.analytics-head .line { flex: 1; height: 1px; background: var(--border); }

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 40px 48px;
}

.analytics-card {
    min-width: 0;
    padding: 8px 4px 0;
}

.analytics-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--navy);
}

.analytics-empty {
    margin: 20px 0 0;
    font-size: 13px;
    color: var(--muted-2);
}

.bar-list { margin-top: 20px; display: flex; flex-direction: column; gap: 16px; }

.bar-row {
    display: grid;
    grid-template-columns: minmax(120px, 38%) 1fr minmax(40px, auto);
    align-items: center;
    gap: 16px;
    font-size: 13px;
}

.bar-label {
    color: var(--text);
    line-height: 1.35;
    word-break: break-word;
}

.bar-value {
    color: var(--muted);
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.bar-track { height: 2px; background: var(--bar-track); display: block; }

.bar-fill { display: block; height: 100%; }

.vbar-chart {
    margin-top: 22px;
    display: flex;
    align-items: flex-end;
    gap: 22px;
    height: 132px;
    padding-bottom: 24px;
    position: relative;
    border-bottom: 1px solid var(--border);
}

.vbar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    height: 100%;
    position: relative;
}

.vbar-value { font-size: 11.5px; color: #64748b; }

.vbar-bar { width: 100%; max-width: 34px; min-height: 4px; }

.vbar-label {
    font-size: 11px;
    color: var(--muted);
    position: absolute;
    bottom: -20px;
    white-space: nowrap;
}

.donut-row { margin-top: 22px; display: flex; gap: 34px; flex-wrap: wrap; }

.donut-wrap { display: flex; align-items: center; gap: 14px; }

.donut-chart { width: 78px; height: 78px; flex-shrink: 0; }

.donut-chart .donut-bg { stroke: var(--bar-track); }
.donut-chart .donut-label { fill: var(--navy); }

.line-chart-axis { stroke: var(--border); }
.line-chart-line { stroke: var(--navy); }
.line-chart-dot { fill: var(--coral); }

.donut-legend {
    display: flex;
    flex-direction: column;
    gap: 7px;
    font-size: 12px;
}

.donut-title { font-weight: 600; font-size: 12.5px; color: var(--navy); }

.donut-item {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--text);
}

.donut-item.muted { color: var(--muted); }

.donut-item i {
    width: 7px;
    height: 2px;
    display: inline-block;
    font-style: normal;
}

.line-chart {
    width: 100%;
    height: 132px;
    margin-top: 20px;
    display: block;
}

.line-chart-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--muted-2);
    margin-top: 8px;
}

/* Footer */
.site-footer {
    padding-top: 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 12px;
    color: var(--muted-2);
}

.site-footer img { height: 18px; opacity: 0.7; }

.error {
    background: #fef2f2;
    color: #b91c1c;
    padding: 12px 16px;
    border: 1px solid #fecaca;
    border-radius: 8px;
    font-size: 14px;
}

/* AI Modal */
.ai-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    inset: 0;
    background: var(--modal-overlay);
    backdrop-filter: blur(4px);
    padding: 20px;
    align-items: center;
    justify-content: center;
}

.ai-modal.is-open {
    display: flex;
}

.ai-modal-content {
    background: var(--surface);
    margin: 8vh auto 0;
    padding: 28px;
    width: 100%;
    max-width: 560px;
    border-radius: 16px;
    position: relative;
    box-shadow: 0 12px 40px var(--shadow);
    border: 1px solid var(--border-2);
}

.ai-modal-close {
    position: absolute;
    top: 16px;
    right: 18px;
    font-size: 22px;
    color: var(--muted);
    cursor: pointer;
    line-height: 1;
    border: none;
    background: none;
}

.ai-modal h4 {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 600;
    color: var(--navy);
}

#ai-message-output {
    width: 100%;
    min-height: 140px;
    padding: 14px;
    margin-bottom: 14px;
    border: 1px solid var(--border-2);
    border-radius: 8px;
    font-family: var(--font);
    font-size: 14px;
    background: var(--surface-muted);
    resize: vertical;
}

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

.copy-button,
.whatsapp-action-button {
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    font-family: var(--font);
    text-decoration: none;
}

.copy-button { background: var(--navy); color: #fff; }
.copy-button:disabled { opacity: 0.4; cursor: not-allowed; }

.whatsapp-action-button { background: #16a34a; color: #fff; display: none; }

.loading-indicator {
    text-align: center;
    padding: 16px;
    font-size: 14px;
    color: var(--muted);
}

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(700px 400px at 50% 0%, var(--login-glow-1), transparent 65%),
        radial-gradient(620px 380px at 50% 100%, var(--login-glow-2), transparent 65%),
        var(--login-bg);
}

.login-wrap { width: 100%; max-width: 340px; }

.login-logo {
    height: 44px;
    width: auto;
    display: block;
    margin: 0 auto 34px;
}

.login-tagline {
    margin: 0 0 34px;
    font-size: 13px;
    color: var(--muted);
    text-align: center;
}

.field-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted-2);
    margin-bottom: 8px;
}

.field-line {
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border-2);
    padding: 10px 2px;
}

.field-line + .field-label { margin-top: 26px; }

.field-line input {
    flex: 1;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: 14.5px;
    color: var(--navy);
    background: transparent;
    padding: 4px 0;
    min-height: 30px;
}

.btn-login {
    width: 100%;
    margin-top: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    background: var(--navy);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 14px;
    font-family: inherit;
    font-size: 14.5px;
    font-weight: 500;
    cursor: pointer;
    min-height: 50px;
    transition: background 0.15s;
}

.btn-login:hover { background: var(--navy-soft); }

.login-error {
    margin: 22px 0 0;
    font-size: 12px;
    color: #b91c1c;
    text-align: center;
    padding: 10px;
    background: #fef2f2;
    border-radius: 8px;
}

.login-hint {
    margin: 22px 0 0;
    font-size: 12px;
    color: var(--muted-2);
    text-align: center;
}

/* Detail page */
.detail-main {
    max-width: 960px;
    margin: 0 auto;
    padding: 44px 28px 72px;
    display: flex;
    flex-direction: column;
    gap: 44px;
    width: 100%;
}

.detail-hero {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: wrap;
}

.detail-hero h1 {
    margin: 0;
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.03em;
    color: var(--navy);
}

.detail-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.score-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    font-weight: 500;
    color: #c2482c;
    border: 1px solid #f6d9d0;
    border-radius: 999px;
    padding: 4px 11px;
}

.detail-meta {
    margin: 9px 0 0;
    font-size: 13.5px;
    color: var(--muted);
}

.detail-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--navy);
    color: #fff;
    border: none;
    border-radius: 9px;
    padding: 11px 16px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    min-height: 44px;
    text-decoration: none;
    transition: background 0.15s;
}

.btn-primary:hover { background: var(--navy-soft); color: #fff; }

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: 1px solid var(--border-2);
    color: #64748b;
    border-radius: 9px;
    padding: 11px 16px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    min-height: 44px;
    text-decoration: none;
    transition: border-color 0.15s, color 0.15s;
}

.btn-secondary:hover { border-color: #cbd5e1; color: var(--navy-soft); }

.detail-grid {
    margin-top: 30px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1px;
    background: var(--border);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.detail-grid-cell {
    background: var(--surface);
    padding: 20px 22px;
}

.detail-grid-cell:first-child { padding-left: 0; }
.detail-grid-cell:last-child { padding-right: 0; }

.detail-grid-label {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted-2);
}

.detail-grid-value {
    margin-top: 8px;
    font-size: 14px;
    color: var(--navy-soft);
}

.credit-pills {
    margin-top: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.credit-pill {
    border-radius: 999px;
    padding: 7px 14px;
    font-size: 13px;
}

.credit-pill--hot {
    border: 1px solid #f2d9c2;
    color: #b26a22;
}

.credit-pill--muted {
    border: 1px solid var(--border);
    color: #64748b;
}

.hist-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 460px;
    margin-top: 16px;
}

.hist-table th {
    text-align: left;
    padding: 0 16px 11px 0;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted-2);
    border-bottom: 1px solid var(--border-2);
}

.hist-table th:last-child { padding-right: 0; padding-left: 16px; }

.hist-table td {
    padding: 15px 16px 15px 0;
    font-size: 13.5px;
    border-bottom: 1px solid var(--row-border);
}

.hist-table td:first-child { font-size: 13px; color: var(--muted); }
.hist-table td:last-child { padding-left: 16px; color: var(--text); }

.hist-table tr:last-child td { border-bottom: none; }

.alert {
    padding: 12px 14px;
    border-radius: 9px;
    font-size: 13.5px;
    margin-bottom: 8px;
}

.alert--success {
    color: #166534;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
}

.alert--error {
    color: #991b1b;
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.alert--error code {
    font-size: 12px;
    background: rgba(255, 255, 255, 0.6);
    padding: 1px 5px;
    border-radius: 4px;
}

.notes-form {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.notes-form textarea {
    width: 100%;
    min-height: 110px;
    resize: vertical;
    border: 1px solid var(--border-2);
    border-radius: 10px;
    padding: 14px 16px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    color: var(--navy);
    background: var(--surface);
    transition: border-color 0.15s;
}

.notes-form textarea:focus {
    outline: none;
    border-color: #94a3b8;
}

.notes-form-actions {
    display: flex;
    justify-content: flex-end;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
}

.back-link:hover { color: var(--navy); }

@media (max-width: 900px) {
    .metrics-strip { grid-template-columns: repeat(2, 1fr); }
    .metric-cell { border-right: none; border-bottom: 1px solid var(--border); padding: 20px 16px; }
    .metric-cell:nth-child(odd) { padding-right: 16px; }
    .metric-cell:first-child { padding-left: 16px; }
    .metric-cell:last-child { padding-right: 16px; }
    .analytics-grid { grid-template-columns: 1fr; gap: 28px; }
}

@media (max-width: 767px) {
    body { overflow-x: hidden; }

    .header-inner {
        padding: 10px 12px;
        gap: 8px;
        flex-wrap: nowrap;
    }

    .header-logo { height: 26px; }

    .header-tag {
        display: none;
    }

    .header-nav {
        gap: 0;
        flex-wrap: nowrap;
    }

    .nav-link {
        padding: 8px;
        min-width: 36px;
        justify-content: center;
    }

    .nav-link-text {
        display: none;
    }

    .header-divider { display: none; }

    .header-user-name { display: none; }

    .back-link-text { display: none; }

    .back-link {
        padding: 8px;
        min-width: 40px;
        justify-content: center;
    }

    .main-content,
    .detail-main {
        padding: 20px 12px calc(48px + env(safe-area-inset-bottom));
        gap: 28px;
    }

    .page-head {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
    }

    .page-title { font-size: 22px; }

    .page-subtitle {
        font-size: 13px;
        line-height: 1.45;
    }

    .page-head-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .date-btn {
        width: 100%;
        justify-content: flex-start;
    }

    .date-btn input {
        width: 100%;
        min-width: 0;
        font-size: 16px; /* evita zoom iOS */
    }

    .range-toggle {
        align-self: flex-start;
        padding: 4px 0;
    }

    .metrics-strip {
        grid-template-columns: 1fr 1fr;
        margin: 0 -12px;
        width: calc(100% + 24px);
    }

    .metric-cell {
        padding: 16px 12px;
    }

    .metric-value {
        font-size: 26px;
    }

    .leads-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .status-tabs {
        gap: 14px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 2px;
        margin: 0 -12px;
        padding-left: 12px;
        padding-right: 12px;
    }

    .status-tab {
        white-space: nowrap;
        flex-shrink: 0;
        font-size: 13px;
    }

    .search-box {
        max-width: 100%;
        margin-left: 0;
        width: 100%;
        min-width: 0;
    }

    .search-box input {
        font-size: 16px;
    }

    .btn-export {
        width: 100%;
        justify-content: center;
        min-height: 44px;
    }

    /* Leads: tabela vira cards */
    .table-wrap {
        margin: 0;
        overflow: visible;
    }

    .data-table {
        min-width: 0;
        display: block;
        width: 100%;
    }

    .data-table thead {
        display: none;
    }

    .data-table tbody {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .data-table tbody tr {
        display: block;
        border: 1px solid var(--border-2);
        border-radius: 12px;
        padding: 12px 14px;
        background: var(--surface);
    }

    .data-table tbody tr.row-hot,
    .data-table tbody tr.row-waiting {
        border-left-width: 3px;
    }

    .data-table tbody tr.row-hot {
        border-left-color: #f4a261;
    }

    .data-table tbody tr.row-waiting {
        border-left-color: #f87171;
    }

    .data-table tbody tr:hover {
        background: var(--surface);
    }

    .data-table td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 12px;
        padding: 8px 0;
        border-bottom: 1px solid var(--row-border);
        font-size: 13px;
        text-align: right;
        white-space: normal;
    }

    .data-table td:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }

    .data-table td:first-child {
        padding-top: 0;
    }

    .data-table td::before {
        content: attr(data-label);
        flex-shrink: 0;
        font-size: 10.5px;
        font-weight: 600;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--muted-2);
        text-align: left;
        padding-top: 2px;
    }

    .data-table td.td-score,
    .data-table td.td-date,
    .data-table td.td-actions {
        padding-left: 0;
        padding-right: 0;
        text-align: right;
    }

    .data-table td.td-actions {
        white-space: normal;
    }

    .data-table .action-group {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        width: 100%;
        max-width: 180px;
        margin-left: auto;
    }

    .data-table .btn-action {
        justify-content: center;
        min-height: 40px;
        width: 100%;
    }

    .cell-last-sim {
        max-width: none;
        word-break: break-word;
    }

    .wa-link {
        word-break: break-all;
        justify-content: flex-end;
    }

    .lead-link {
        font-size: 15px;
    }

    .table-footer {
        font-size: 12px;
    }

    /* Detalhe do lead */
    .detail-hero {
        flex-direction: column;
        gap: 16px;
    }

    .detail-hero h1 {
        font-size: 22px;
        word-break: break-word;
    }

    .detail-actions {
        width: 100%;
        flex-direction: column;
    }

    .detail-actions .btn-primary,
    .detail-actions .btn-secondary {
        width: 100%;
        justify-content: center;
    }

    .detail-grid {
        margin-top: 20px;
        grid-template-columns: 1fr 1fr;
    }

    .detail-grid-cell {
        padding: 14px 12px;
        min-width: 0;
    }

    .detail-grid-value {
        font-size: 13px;
        word-break: break-word;
    }

    .notes-form textarea {
        font-size: 16px;
        min-height: 120px;
    }

    .notes-form-actions {
        width: 100%;
    }

    .notes-form-actions .btn-secondary {
        width: 100%;
        justify-content: center;
    }

    .hist-table {
        min-width: 0;
        font-size: 12px;
    }

    .hist-table th,
    .hist-table td {
        padding: 10px 8px;
    }

    .credit-pills {
        gap: 8px;
    }

    /* Analytics */
    .analytics-section {
        gap: 20px;
    }

    .donut-row {
        flex-direction: column;
        align-items: stretch;
        gap: 20px;
    }

    .site-footer {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 8px;
    }

    /* Login */
    .login-page {
        align-items: flex-start;
        padding: 48px 16px 32px;
        min-height: 100dvh;
    }

    .login-theme {
        top: 12px;
        right: 12px;
    }

    .field-line input {
        font-size: 16px;
    }

    .btn-login {
        min-height: 48px;
    }

    /* Modal IA */
    .ai-modal-content {
        margin: 0;
        padding: 20px 16px;
        border-radius: 16px 16px 0 0;
        max-height: 90dvh;
        overflow-y: auto;
        width: 100%;
        align-self: flex-end;
    }

    #ai-message-output {
        font-size: 16px;
        min-height: 120px;
    }

    .ai-modal-actions {
        flex-direction: column;
    }

    .copy-button,
    .whatsapp-action-button {
        width: 100%;
        text-align: center;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

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

    .admin-input,
    .admin-select {
        font-size: 16px;
    }

    .users-table {
        min-width: 640px;
    }
}

@media (max-width: 380px) {
    .metrics-strip {
        grid-template-columns: 1fr;
    }

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

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

/* Users admin */
.users-main { max-width: 960px; }

.panel-card {
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.panel-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--navy);
}

.panel-card-count {
    margin-left: 4px;
    font-size: 12px;
    font-weight: 500;
    color: var(--muted-2);
}

.panel-card-desc {
    margin: 10px 0 0;
    font-size: 13px;
    color: var(--muted);
}

.admin-form { margin-top: 22px; }

.admin-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px 28px;
}

.admin-field--wide { grid-column: 1 / -1; }

.admin-input,
.admin-select {
    width: 100%;
    border: 1px solid var(--border-2);
    border-radius: 9px;
    padding: 11px 14px;
    font-family: inherit;
    font-size: 14px;
    color: var(--navy);
    background: var(--surface);
    transition: border-color 0.15s;
}

.admin-input:focus,
.admin-select:focus {
    outline: none;
    border-color: #94a3b8;
}

.field-hint {
    margin: 7px 0 0;
    font-size: 12px;
    color: var(--muted-2);
    line-height: 1.4;
}

.field-optional {
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    color: var(--muted-2);
}

.admin-form-actions {
    margin-top: 26px;
    display: flex;
    justify-content: flex-start;
}

.users-table { min-width: 800px; }

.user-name {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--navy);
}

.user-email {
    display: block;
    margin-top: 3px;
    font-size: 12px;
    color: var(--muted);
}

.ref-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12.5px;
    color: var(--navy-soft);
    background: var(--surface-muted);
    border: 1px solid var(--border-2);
    border-radius: 6px;
    padding: 3px 8px;
}

.role-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.role-badge--admin {
    color: var(--navy);
    background: var(--surface-muted);
    border: 1px solid var(--border-2);
}

.role-badge--assessor {
    color: #b26a22;
    background: rgba(244, 162, 97, 0.12);
    border: 1px solid rgba(244, 162, 97, 0.35);
}

[data-theme="dark"] .role-badge--assessor {
    color: #f4a261;
    background: rgba(244, 162, 97, 0.12);
    border-color: rgba(244, 162, 97, 0.3);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
}

.status-pill--on {
    color: #15803d;
    background: #ecfdf3;
}

.status-pill--off {
    color: #b91c1c;
    background: #fef2f2;
}

.status-pill--novo {
    color: #b45309;
    background: #fff7ed;
}

.status-pill--atendido {
    color: #15803d;
    background: #ecfdf3;
}

.status-pill--arquivado {
    color: #64748b;
    background: #f1f5f9;
}

[data-theme="dark"] .status-pill--on { color: #4ade80; background: rgba(22, 163, 74, 0.15); }
[data-theme="dark"] .status-pill--off { color: #f87171; background: rgba(185, 28, 28, 0.15); }
[data-theme="dark"] .status-pill--novo { color: #fdba74; background: rgba(234, 88, 12, 0.15); }
[data-theme="dark"] .status-pill--atendido { color: #4ade80; background: rgba(22, 163, 74, 0.15); }
[data-theme="dark"] .status-pill--arquivado { color: #94a3b8; background: #1e293b; }

.cell-link { max-width: 280px; }

.sim-link {
    font-size: 12px;
    color: var(--muted);
    word-break: break-all;
    line-height: 1.45;
}

.sim-link:hover { color: var(--coral); }
