/* ==========================================================================
   AR Consórcios e Investimentos — Design System
   Sumário: 1 Tokens · 2 Base · 3 Layout · 4 Componentes · 5 Telas · 6 Utilitários
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */
:root {
    color-scheme: light;

    /* Marca: azul-marinho + azul de ação + dourado do logotipo */
    --navy-950: #0a1120;
    --navy-900: #0f172a;
    --navy-800: #17223b;
    --gold: #d4b06a;
    --gold-soft: rgba(212, 176, 106, 0.16);

    --primary: #2457d6;
    --primary-hover: #1c46b0;
    --primary-light: rgba(36, 87, 214, 0.1);
    --primary-bg: rgba(36, 87, 214, 0.06);
    --primary-gradient: linear-gradient(135deg, #2457d6 0%, #4f46e5 100%);
    --accent: #4f46e5;

    --bg-body: #f3f5fa;
    --bg-card: #ffffff;
    --bg-secondary: #f7f9fc;
    --bg-sidebar: var(--navy-900);
    --hover-bg: #f1f5fb;

    --text-dark: #0f172a;
    --text-primary: #1e293b;
    --text-secondary: #5b6779;
    --text-light: #8a96a8;
    --text-white: #ffffff;
    --text-sidebar: #c3cddd;

    --success: #047857;
    --success-bg: rgba(4, 120, 87, 0.1);
    --warning: #b45309;
    --warning-bg: rgba(180, 83, 9, 0.11);
    --danger: #c81e1e;
    --danger-bg: rgba(200, 30, 30, 0.09);
    --info: #0369a1;
    --info-bg: rgba(3, 105, 161, 0.1);
    --whatsapp: #128c4b;

    --border-color: #e3e8f0;
    --border-strong: #cdd5e1;
    --border-radius: 14px;
    --border-radius-sm: 10px;
    --border-radius-lg: 20px;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px -2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 8px 24px -6px rgba(15, 23, 42, 0.12);
    --shadow-lg: 0 24px 48px -12px rgba(15, 23, 42, 0.25);
    --ring: 0 0 0 3px rgba(36, 87, 214, 0.28);

    --sidebar-width: 264px;
    --header-height: 68px;
    --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
    --transition: all 0.18s var(--ease);
    --transition-slow: all 0.3s var(--ease);
}

/* 2. Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scrollbar-gutter: stable;
}

body {
    font-family: var(--font);
    font-size: 0.9375rem;
    line-height: 1.55;
    color: var(--text-primary);
    background: var(--bg-body);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
body.modal-open { overflow: hidden; }

h1, h2, h3, h4 { color: var(--text-dark); line-height: 1.25; text-wrap: balance; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
img, svg, canvas { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 0.9em; }

/* Foco sempre visível para quem navega pelo teclado */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
::selection { background: rgba(36, 87, 214, 0.2); }

/* Valores monetários alinham dígito a dígito */
.table, .stat-info h4, .money, .money-input, [data-mask="money"] { font-variant-numeric: tabular-nums; }

.skip-link {
    position: fixed; top: -60px; left: 16px; z-index: 5000;
    padding: 10px 16px; border-radius: var(--border-radius-sm);
    background: var(--navy-900); color: #fff; font-weight: 600;
    transition: top 0.15s;
}
.skip-link:focus { top: 12px; color: #fff; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* 3. Layout ---------------------------------------------------------------- */
.app-layout { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 1000;
    width: var(--sidebar-width);
    display: flex; flex-direction: column;
    background: linear-gradient(180deg, var(--navy-900) 0%, var(--navy-950) 100%);
    color: var(--text-sidebar);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    transition: transform 0.28s var(--ease);
}

.sidebar-header { padding: 22px 20px 18px; border-bottom: 1px solid rgba(255, 255, 255, 0.07); }
.sidebar-header .logo { display: flex; align-items: center; gap: 12px; color: #fff; }
.logo-icon {
    width: 42px; height: 42px; flex-shrink: 0;
    display: grid; place-items: center;
    border-radius: 12px; font-size: 18px; color: var(--navy-900);
    background: linear-gradient(135deg, #ecd6a4 0%, var(--gold) 100%);
    box-shadow: 0 6px 16px -6px rgba(212, 176, 106, 0.7);
}
.logo-text { font-size: 0.9375rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; color: #fff; }
.logo-sub { margin-top: 2px; font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); }

.sidebar-nav { flex: 1; padding: 14px 12px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.15) transparent; }
.nav-section { padding: 18px 12px 6px; }
.nav-section-title { font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: #6b7a93; }

.nav-item {
    position: relative;
    display: flex; align-items: center; gap: 12px;
    width: 100%; min-height: 42px; padding: 9px 12px; margin-bottom: 2px;
    border: 0; border-radius: var(--border-radius-sm); background: transparent;
    font-size: 0.875rem; font-weight: 500; text-align: left; color: var(--text-sidebar);
    cursor: pointer; transition: var(--transition);
}
.nav-item:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.nav-item.active { background: rgba(255, 255, 255, 0.1); color: #fff; font-weight: 600; }
.nav-item.active::before {
    content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px;
    border-radius: 0 3px 3px 0; background: var(--gold);
}
.nav-item:focus-visible { outline-color: var(--gold); }
.nav-icon { width: 20px; text-align: center; font-size: 0.9375rem; opacity: 0.85; }
.nav-item.active .nav-icon { color: var(--gold); opacity: 1; }
.nav-badge { margin-left: auto; padding: 2px 8px; border-radius: 999px; font-size: 0.625rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; background: var(--gold-soft); color: var(--gold); }
.nav-item-danger { color: #fca5a5; }
.nav-item-danger:hover { background: rgba(239, 68, 68, 0.14); color: #fecaca; }

.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255, 255, 255, 0.07); }
.sidebar-user { display: flex; align-items: center; gap: 12px; padding: 8px 10px 10px; }
.user-avatar {
    width: 36px; height: 36px; flex-shrink: 0; display: grid; place-items: center;
    border-radius: 50%; font-size: 0.875rem; font-weight: 700; color: #fff;
    background: var(--primary-gradient);
}
.user-info { min-width: 0; }
.user-name { font-size: 0.8125rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.6875rem; color: #7f8ba1; }

.sidebar-scrim { display: none; }

.main-content { flex: 1; min-width: 0; margin-left: var(--sidebar-width); display: flex; flex-direction: column; transition: margin-left 0.28s var(--ease); }
body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
body.sidebar-collapsed .main-content { margin-left: 0; }

.main-header {
    position: sticky; top: 0; z-index: 900;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    min-height: var(--header-height); padding: 12px 28px;
    background: rgba(255, 255, 255, 0.86);
    -webkit-backdrop-filter: saturate(180%) blur(14px); backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border-color);
}
.header-content { display: flex; align-items: center; gap: 14px; min-width: 0; }
.header-text { min-width: 0; }
.page-title { font-size: 1.125rem; font-weight: 700; letter-spacing: -0.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-subtitle { font-size: 0.75rem; color: var(--text-secondary); }
.header-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.page-content { flex: 1; width: 100%; max-width: 1640px; padding: 26px 28px 44px; }

/* 4. Componentes ----------------------------------------------------------- */

/* Cartões */
.card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--border-radius); box-shadow: var(--shadow-sm); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--border-color); }
.card-header h3 { display: flex; align-items: center; gap: 10px; font-size: 0.9375rem; font-weight: 650; }
.card-header h3 > i { color: var(--primary); }
.card-body { padding: 20px; }
.card-body.flush { padding: 0; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--border-color); background: var(--bg-secondary); border-radius: 0 0 var(--border-radius) var(--border-radius); }
.card-link { display: block; color: inherit; transition: var(--transition); }
.card-link:hover { color: inherit; transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }

/* Indicadores */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { display: flex; align-items: center; gap: 14px; padding: 18px 20px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--border-radius); box-shadow: var(--shadow-sm); transition: var(--transition); }
.stat-icon { width: 46px; height: 46px; flex-shrink: 0; display: grid; place-items: center; border-radius: 12px; font-size: 1.125rem; }
.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.yellow { background: var(--gold-soft); color: #9a6c12; }
.stat-icon.red { background: var(--danger-bg); color: var(--danger); }
.stat-info { min-width: 0; }
.stat-info h4 { font-size: 1.375rem; font-weight: 750; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.stat-info p { font-size: 0.8125rem; color: var(--text-secondary); }
.stat-trend { display: inline-flex; align-items: center; gap: 4px; margin-top: 2px; font-size: 0.75rem; font-weight: 650; }
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }
/* Painel: ícone em cima, número com a largura toda (valores em R$ não quebram) */
.stats-grid--kpi .stat-card { flex-direction: column; align-items: flex-start; gap: 12px; }
.stats-grid--kpi .stat-icon { width: 40px; height: 40px; font-size: 1rem; }
.stats-grid--kpi .stat-info { width: 100%; }
.stats-grid--kpi .stat-info h4 { font-size: clamp(1.125rem, 1.55vw, 1.5rem); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Formulários */
.form-group { margin-bottom: 16px; }
.form-group label, .form-label { display: block; margin-bottom: 6px; font-size: 0.8125rem; font-weight: 600; color: var(--text-primary); }
.form-hint { margin-top: 6px; font-size: 0.75rem; color: var(--text-secondary); }
.form-control {
    width: 100%; min-height: 42px; padding: 9px 13px;
    background: #fff; border: 1px solid var(--border-strong); border-radius: var(--border-radius-sm);
    font-size: 0.9375rem; color: var(--text-dark);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:hover { border-color: #aab4c4; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.form-control::placeholder { color: var(--text-light); }
.form-control:disabled { background: var(--bg-secondary); color: var(--text-light); cursor: not-allowed; }
textarea.form-control { min-height: 88px; resize: vertical; line-height: 1.5; }
select.form-control {
    appearance: none; padding-right: 38px; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%235b6779' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center;
}
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.form-row .span-2 { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.form-section { margin-top: 22px; border-left: 3px solid var(--gold); }
.form-section > .card-header { background: var(--bg-secondary); border-radius: 0 var(--border-radius) 0 0; }

.input-group { position: relative; }
.input-group .form-control { padding-right: 46px; }
.input-addon {
    position: absolute; top: 50%; right: 4px; transform: translateY(-50%);
    width: 38px; height: 34px; display: grid; place-items: center;
    border: 0; border-radius: 8px; background: transparent; color: var(--text-secondary); cursor: pointer;
}
.input-addon:hover { background: var(--hover-bg); color: var(--text-dark); }

/* Interruptor */
.form-switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; }
.form-switch input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-slider { position: relative; width: 46px; height: 26px; flex-shrink: 0; border-radius: 999px; background: #cbd5e1; transition: background 0.2s; }
.switch-slider::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.2s var(--ease); }
.form-switch input:checked + .switch-slider { background: var(--success); }
.form-switch input:checked + .switch-slider::after { transform: translateX(20px); }
.form-switch input:focus-visible + .switch-slider { box-shadow: var(--ring); }
.switch-card { display: flex; align-items: center; gap: 14px; padding: 16px; border: 1px solid var(--border-color); border-radius: var(--border-radius-sm); background: var(--bg-secondary); cursor: pointer; }
.switch-card strong { display: block; font-size: 0.875rem; }
.switch-card small { display: block; margin-top: 2px; font-size: 0.75rem; color: var(--text-secondary); }

/* Botões */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 40px; padding: 9px 18px;
    border: 1px solid transparent; border-radius: var(--border-radius-sm);
    font-size: 0.875rem; font-weight: 600; line-height: 1.2; white-space: nowrap;
    cursor: pointer; user-select: none; transition: var(--transition);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(36, 87, 214, 0.3); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #036349; color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #a51616; color: #fff; }
.btn-whatsapp { background: var(--whatsapp); color: #fff; }
.btn-whatsapp:hover:not(:disabled) { background: #0e733d; color: #fff; }
.btn-outline { background: #fff; border-color: var(--border-strong); color: var(--text-primary); }
.btn-outline:hover:not(:disabled) { background: var(--hover-bg); border-color: #aab4c4; color: var(--text-dark); }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 0.8125rem; border-radius: 8px; }
.btn-lg { min-height: 48px; padding: 12px 26px; font-size: 1rem; }
.btn-icon { width: 40px; padding: 0; }
.btn-sm.btn-icon { width: 34px; }
.btn-block { width: 100%; }
.btn-group { display: flex; gap: 6px; }

/* Tabelas */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table th { padding: 11px 16px; background: var(--bg-secondary); border-bottom: 1px solid var(--border-color); font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; text-align: left; white-space: nowrap; color: var(--text-secondary); }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background 0.12s; }
.table tbody tr:hover { background: var(--hover-bg); }
.table tr[data-href] { cursor: pointer; }
.table .text-right { text-align: right; }
.table .text-center { text-align: center; }
.table-toolbar-search { width: min(280px, 100%); }

.empty-state { padding: 44px 20px; text-align: center; color: var(--text-secondary); }
.empty-state i { display: block; margin-bottom: 12px; font-size: 2.25rem; color: var(--border-strong); }
.empty-state.ok i { color: var(--success); }

/* Etiquetas */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 650; line-height: 1.5; white-space: nowrap; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-muted { background: #eef1f6; color: var(--text-secondary); }
select.badge { appearance: auto; border: 0; cursor: pointer; font-family: inherit; padding-right: 4px; }
select.badge option { background: #fff; color: #000; }

/* Alertas em linha */
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; margin-bottom: 20px; border-radius: var(--border-radius-sm); border: 1px solid transparent; font-size: 0.875rem; font-weight: 500; }
.alert i { margin-top: 3px; }
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-danger { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-info { background: #f0f9ff; border-color: #bae6fd; color: #075985; }

/* Avisos flutuantes */
.toast-region { position: fixed; top: 18px; right: 18px; z-index: 6000; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 36px)); pointer-events: none; }
.toast {
    display: flex; align-items: flex-start; gap: 10px; padding: 13px 16px;
    background: #fff; border: 1px solid var(--border-color); border-left: 4px solid var(--info);
    border-radius: var(--border-radius-sm); box-shadow: var(--shadow-md);
    font-size: 0.875rem; font-weight: 500; color: var(--text-dark);
    pointer-events: auto; cursor: pointer; animation: toastIn 0.28s var(--ease);
}
.toast i { margin-top: 3px; color: var(--info); }
.toast-success { border-left-color: var(--success); } .toast-success i { color: var(--success); }
.toast-danger { border-left-color: var(--danger); } .toast-danger i { color: var(--danger); }
.toast-warning { border-left-color: var(--warning); } .toast-warning i { color: var(--warning); }
.toast.leaving { opacity: 0; transform: translateX(16px); transition: opacity 0.22s, transform 0.22s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } }

/* Modais */
.modal-overlay {
    position: fixed; inset: 0; z-index: 3000;
    display: flex; align-items: center; justify-content: center; padding: 20px;
    background: rgba(10, 17, 32, 0.55);
    -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
    opacity: 0; visibility: hidden; transition: opacity 0.2s, visibility 0.2s;
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal, .modal-content {
    width: 100%; max-width: 520px; max-height: calc(100dvh - 40px);
    display: flex; flex-direction: column;
    background: #fff; border-radius: var(--border-radius-lg); box-shadow: var(--shadow-lg);
    transform: translateY(12px) scale(0.98); transition: transform 0.25s var(--ease);
}
.modal-overlay.active .modal, .modal-overlay.active .modal-content { transform: none; }
.modal-sm { max-width: 440px; } .modal-lg { max-width: 640px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border-color); }
.modal-header h3 { display: flex; align-items: center; gap: 10px; font-size: 1.0625rem; font-weight: 700; }
.modal-close { width: 34px; height: 34px; flex-shrink: 0; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; font-size: 1.375rem; line-height: 1; color: var(--text-secondary); cursor: pointer; transition: var(--transition); }
.modal-close:hover { background: var(--hover-bg); color: var(--text-dark); }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; padding: 16px 22px; border-top: 1px solid var(--border-color); background: var(--bg-secondary); border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg); }
.modal-footer.between { justify-content: space-between; }

.dialog { padding: 30px 28px 24px; text-align: center; }
.dialog-icon { width: 60px; height: 60px; margin: 0 auto 16px; display: grid; place-items: center; border-radius: 50%; font-size: 1.5rem; background: var(--primary-light); color: var(--primary); }
[data-tone="danger"] .dialog-icon, .dialog-icon.danger { background: var(--danger-bg); color: var(--danger); }
.dialog h2 { margin-bottom: 8px; font-size: 1.125rem; }
.dialog p { color: var(--text-secondary); line-height: 1.6; }
.dialog .dialog-subject { margin: 6px 0; font-size: 1.0625rem; font-weight: 700; color: var(--text-dark); overflow-wrap: anywhere; }
.dialog-actions { display: flex; justify-content: center; gap: 12px; margin-top: 24px; }
.dialog-actions .btn { min-width: 124px; }

/* Carregando */
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 5. Telas ----------------------------------------------------------------- */

/* Login */
.login-page {
    min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px;
    background:
        radial-gradient(900px 500px at 12% -10%, rgba(36, 87, 214, 0.35), transparent 60%),
        radial-gradient(700px 480px at 100% 110%, rgba(212, 176, 106, 0.2), transparent 60%),
        linear-gradient(160deg, var(--navy-900) 0%, var(--navy-950) 100%);
}
.login-container { width: 100%; max-width: 420px; }
.login-card { padding: 38px 34px 32px; background: rgba(255, 255, 255, 0.98); border-radius: var(--border-radius-lg); box-shadow: var(--shadow-lg); }
.login-logo { margin-bottom: 28px; text-align: center; }
.login-logo .logo-icon { width: 60px; height: 60px; margin: 0 auto 16px; border-radius: 18px; font-size: 1.625rem; }
.login-logo h1 { font-size: 1.25rem; font-weight: 750; letter-spacing: -0.02em; }
.login-logo p { margin-top: 4px; font-size: 0.875rem; color: var(--text-secondary); }
.login-form .form-control { min-height: 48px; }
.btn-login { width: 100%; min-height: 50px; margin-top: 8px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; border: 0; border-radius: var(--border-radius-sm); background: var(--primary); color: #fff; font-size: 1rem; font-weight: 650; cursor: pointer; transition: var(--transition); }
.btn-login:hover:not(:disabled) { background: var(--primary-hover); }
.btn-login:disabled { opacity: 0.7; cursor: wait; }
.login-secure { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 20px; font-size: 0.75rem; color: var(--text-secondary); }
.login-footer { margin-top: 22px; text-align: center; font-size: 0.75rem; color: rgba(255, 255, 255, 0.45); }

/* Painel */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.section-gap { margin-top: 24px; }

.pipeline-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.pipeline-step { --tone: var(--primary); padding: 16px 14px; text-align: center; border-radius: var(--border-radius-sm); border: 1px solid var(--border-color); background: var(--bg-secondary); border-top: 3px solid var(--tone); }
.pipeline-step > i { margin-bottom: 8px; font-size: 1.125rem; color: var(--tone); }
.pipeline-step .label { font-size: 0.75rem; font-weight: 600; color: var(--text-secondary); }
.pipeline-step .count { font-size: 1.625rem; font-weight: 800; letter-spacing: -0.02em; color: var(--text-dark); font-variant-numeric: tabular-nums; }
.pipeline-step .value { min-height: 1.2em; font-size: 0.6875rem; color: var(--text-secondary); }
.pipeline-step.is-empty { opacity: 0.6; }

.contact-list { max-height: 440px; overflow-y: auto; }
.contact-group { --tone: var(--success); display: flex; align-items: center; gap: 6px; padding: 7px 16px; border-bottom: 1px solid var(--border-color); background: color-mix(in srgb, var(--tone) 7%, #fff); font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--tone); }
.contact-item { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--border-color); cursor: pointer; transition: background 0.12s; }
.contact-item:hover { background: var(--hover-bg); }
.contact-avatar { width: 34px; height: 34px; flex-shrink: 0; display: grid; place-items: center; border-radius: 50%; font-size: 0.8125rem; background: color-mix(in srgb, var(--tone) 12%, #fff); color: var(--tone); }
.contact-main { flex: 1; min-width: 0; }
.contact-main strong { display: block; font-size: 0.8125rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-main small { font-size: 0.6875rem; color: var(--text-secondary); }
.contact-side { text-align: right; }
.contact-side small { display: block; font-size: 0.6875rem; font-weight: 600; }

.progress { display: flex; align-items: center; gap: 8px; }
.progress-track { flex: 1; max-width: 120px; height: 8px; border-radius: 999px; background: #e6ebf2; overflow: hidden; }
.progress-fill { height: 100%; border-radius: inherit; background: var(--tone, var(--primary)); }
.progress-value { font-size: 0.75rem; font-weight: 650; color: var(--tone, var(--primary)); }
.rank { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-size: 0.75rem; font-weight: 700; background: #eef1f6; color: var(--text-secondary); }
.rank-1 { background: #fdf0c8; color: #8a6207; } .rank-2 { background: #e8ecf1; color: #4b5563; } .rank-3 { background: #f6dfcb; color: #8a4b12; }

.shortcut { padding: 34px 24px; text-align: center; }
.shortcut i { margin-bottom: 14px; font-size: 2.5rem; }
.shortcut h3 { margin-bottom: 4px; }
.shortcut p { color: var(--text-secondary); font-size: 0.875rem; }

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

/* Proposta: formulário à esquerda, resumo à direita */
.orcamento-layout.split-mode { display: grid; grid-template-columns: 450px 1fr; gap: 24px; align-items: start; height: calc(100dvh - var(--header-height) - 62px); }
.orcamento-layout.split-mode .orcamento-left,
.orcamento-layout.split-mode .orcamento-right { height: 100%; overflow-y: auto; padding-right: 6px; scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }
.orcamento-layout.split-mode .orcamento-left .form-row { grid-template-columns: 1fr; gap: 8px; }
.orcamento-layout.split-mode .orcamento-left .form-row.split-2-cols { grid-template-columns: 1fr 1fr; }
.orcamento-layout.split-mode .orcamento-left .form-group { margin-bottom: 10px; }
.orcamento-layout.split-mode .orcamento-left .form-group label { margin-bottom: 4px; }
.orcamento-layout.split-mode #resultadoCalculo { display: flex; flex-direction: column; }

/* Proposta: visualização */
.proposta-view-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.proposta-view-grid .proposta-details-list { margin-bottom: 0; }
.timeline-item { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border-color); }
.timeline-item:last-child { border-bottom: 0; }
.timeline-icon { width: 34px; height: 34px; flex-shrink: 0; display: grid; place-items: center; border-radius: 50%; font-size: 0.8125rem; background: var(--primary-light); color: var(--primary); }
.timeline-body { flex: 1; min-width: 0; }
.timeline-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.timeline-head strong { font-size: 0.8125rem; }
.timeline-head span { font-size: 0.6875rem; color: var(--text-secondary); }
.timeline-body p { margin: 3px 0 6px; font-size: 0.8125rem; line-height: 1.5; color: var(--text-secondary); overflow-wrap: anywhere; }
a.pipeline-step { display: block; color: inherit; transition: var(--transition); }
a.pipeline-step:hover { transform: translateY(-2px); box-shadow: var(--shadow); opacity: 1; }
a.contact-item { text-decoration: none; }

/* 6. Utilitários ----------------------------------------------------------- */
.text-right { text-align: right; } .text-center { text-align: center; }
.text-muted { color: var(--text-secondary); } .text-success { color: var(--success); }
.text-danger { color: var(--danger); } .text-primary { color: var(--primary); }
.fw-bold { font-weight: 700; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; } .align-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-2 { gap: 16px; } .w-full { width: 100%; } .narrow { max-width: 720px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Responsivo */
@media (max-width: 1100px) {
    .orcamento-layout.split-mode { display: block; height: auto; }
    .orcamento-layout.split-mode .orcamento-left,
    .orcamento-layout.split-mode .orcamento-right { height: auto; overflow: visible; padding-right: 0; }
    .orcamento-layout.split-mode .orcamento-left { margin-bottom: 24px; }
    .grid-2, .proposta-view-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    body.sidebar-open .sidebar { transform: none; }
    body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
    body.sidebar-open { overflow: hidden; }
    .sidebar-scrim { display: block; position: fixed; inset: 0; z-index: 950; border: 0; background: rgba(10, 17, 32, 0.5); opacity: 0; visibility: hidden; transition: opacity 0.25s, visibility 0.25s; }
    body.sidebar-open .sidebar-scrim { opacity: 1; visibility: visible; }
    .main-content { margin-left: 0; }
    .main-header { padding: 10px 16px; }
    .page-content { padding: 18px 16px 36px; }
    .page-title { font-size: 1rem; }
}

@media (max-width: 640px) {
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .pipeline-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .pipeline-step { padding: 12px 6px; }
    .pipeline-step .count { font-size: 1.25rem; }
    .stat-card { flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px; }
    .stat-info h4 { font-size: 1.0625rem; }
    .form-row { grid-template-columns: 1fr; }
    .form-row .span-2 { grid-column: auto; }
    .header-actions .btn span { display: none; }
    .card-header, .card-body { padding-left: 16px; padding-right: 16px; }
    .modal-overlay { padding: 0; align-items: flex-end; }
    .modal, .modal-content { max-width: none; max-height: 92dvh; border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0; }
    .modal-footer { border-radius: 0; }
    .modal-footer .btn, .form-actions .btn, .dialog-actions .btn { flex: 1; }
    .login-card { padding: 30px 22px 26px; }
    .toast-region { top: auto; bottom: 16px; right: 16px; left: 16px; width: auto; }
}

@media print {
    .sidebar, .main-header, .header-actions, .btn, .toast-region, .modal-overlay, .sidebar-scrim { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .page-content { padding: 0; max-width: none; }
    body { background: #fff; }
    .card { box-shadow: none; break-inside: avoid; }
}
