:root {
    --brand-primary: #103A71;
    --brand-action: #2F80ED;
    --brand-success: #00C48C;
    --brand-ai: #6C5CE7;
    --text-primary: #3C4658;
    --text-light: #8B95A5;
    --background: #F4F6F8;
    --surface: #FFFFFF;
    --border: #E2E8F0;
    --sidebar-bg: #103A71;
    --sidebar-hover: #1A4D8A;
    --danger: #DC2626;
    --warning: #F59E0B;
    --info: #2F80ED;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --shadow-sm: 0 1px 2px rgba(16,58,113,0.06);
    --shadow-md: 0 4px 12px rgba(16,58,113,0.08);
    --shadow-lg: 0 8px 24px rgba(16,58,113,0.12);
    --transition-fast: 150ms;
    --transition-normal: 250ms;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: "Manrope", "Inter", "Segoe UI", Arial, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app-layout { display: flex; }

.sidebar {
    width: 250px;
    min-height: 100vh;
    background: var(--sidebar-bg);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo { width: 36px; height: 36px; }
.sidebar-brand { font-size: 18px; font-weight: 700; color: #FFFFFF; }

.sidebar-nav {
    list-style: none;
    padding: 12px 0;
    flex: 1;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: all var(--transition-fast);
    font-size: 14px;
    font-weight: 500;
}

.sidebar-nav li a:hover,
.sidebar-nav li a.active {
    background: var(--sidebar-hover);
    color: white;
}

.sidebar-nav li a.disabled {
    opacity: 0.35;
    pointer-events: none;
    cursor: default;
}

.sidebar-nav li a i { width: 20px; text-align: center; }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav-avatar { width: 18px; height: 18px; border-radius: 50%; object-fit: cover; vertical-align: middle; margin-right: 2px; }

.nav-divider {
    padding: 20px 20px 8px;
    color: rgba(255,255,255,0.4);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info { display: flex; align-items: center; gap: 8px; color: rgba(255,255,255,0.7); font-size: 13px; }
.btn-logout { color: #ef4444; text-decoration: none; }

.main-content {
    margin-left: 250px;
    flex: 1;
    padding: 24px 32px;
    min-height: 100vh;
}

.main-content-full {
    flex: 1;
    padding: 0;
    min-height: 100vh;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h1 { font-size: 24px; font-weight: 700; color: var(--brand-primary); }
.page-header h1 i { color: var(--brand-action); margin-right: 8px; }
.page-header p { color: var(--text-light); margin-top: 4px; }

.btn {
    font-family: "Manrope", "Inter", "Segoe UI", Arial, sans-serif;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary { background: var(--brand-action); color: white; }
.btn-primary:hover { background: var(--brand-primary); }
.btn-success { background: var(--brand-success); color: white; font-weight: 600; border-radius: var(--radius-sm); }
.btn-danger { background: var(--danger); color: white; }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

.card {
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 16px;
}

.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 13px; color: var(--text-primary); }
.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    transition: border-color 0.2s;
}
.form-control:focus { outline: none; border-color: var(--brand-action); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.table th, .table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.table th { background: #f8fafc; font-weight: 600; color: var(--text-light); text-transform: uppercase; font-size: 11px; letter-spacing: 0.5px; }
.table tr:hover { background: #f8fafc; }

.status { padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.status.active { background: #dcfce7; color: #166534; }
.status.inactive { background: #fef2f2; color: #991b1b; }
.status.pending { background: #fef9c3; color: #854d0e; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    background: #e2e8f0;
    color: #475569;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.empty-state i { color: #cbd5e1; margin-bottom: 16px; }
.empty-state h3 { margin-bottom: 8px; color: var(--text-primary); }

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.dashboard-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    text-decoration: none;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.dashboard-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }

.card-icon i { font-size: 32px; color: var(--brand-action); }
.card-body h3 { font-size: 16px; margin-bottom: 4px; }
.card-body p { font-size: 13px; color: var(--text-light); }

.dashboard-widgets {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 16px;
}

.widget {
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.widget-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.widget-header h3 { font-size: 14px; font-weight: 600; }
.widget-body { padding: 16px; }

.kpi-value { font-size: 32px; font-weight: 700; color: var(--brand-action); text-align: center; }
.kpi-label { text-align: center; color: var(--text-light); font-size: 12px; margin-top: 4px; }

.widget-chart { width: 100%; height: 200px; }

.widget-table-wrapper { overflow-x: auto; }
.widget-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.widget-table th, .widget-table td { padding: 6px 8px; border: 1px solid var(--border); text-align: left; }
.widget-table th { background: #f8fafc; font-weight: 600; }

.chat-layout { display: flex; height: calc(100vh - 48px); gap: 0; margin: -24px -32px; }
.chat-sidebar {
    width: 300px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}
.chat-sidebar-header { padding: 20px; border-bottom: 1px solid var(--border); }
.chat-sidebar-header h2 { font-size: 16px; margin: 0; }
.chat-avatar-sidebar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.chat-avatar-sidebar-consultor {
    width: 40px; height: 40px; border-radius: 50%;
    background: linear-gradient(135deg, #0f172a, #1e293b);
    display: flex; align-items: center; justify-content: center;
    color: white; font-weight: 700; font-size: 18px;
    flex-shrink: 0; box-shadow: 0 2px 8px rgba(15,23,42,0.15);
}
.chat-history { flex: 1; overflow-y: auto; padding: 8px; }
.chat-session-item { padding: 12px; cursor: pointer; border-radius: var(--radius); margin-bottom: 4px; }
.chat-session-item:hover { background: var(--background); }
.session-title { font-size: 13px; font-weight: 500; }
.session-meta { font-size: 11px; color: var(--text-light); margin-top: 4px; }
.chat-main { flex: 1; display: flex; flex-direction: column; }
.chat-messages { flex: 1; overflow-y: auto; padding: 24px; }
.chat-welcome { text-align: center; padding: 60px 20px; max-width: 480px; margin: 0 auto; }
.chat-welcome i { color: var(--brand-action); }
.chat-welcome h2 { margin: 16px 0 4px; font-size: 22px; }
.chat-avatar-welcome { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; border: 3px solid var(--brand-action); }
.chat-avatar-welcome-consultor {
    width: 88px; height: 88px; border-radius: 50%;
    background: linear-gradient(135deg, #0f172a, #1e293b);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 20px;
    box-shadow: 0 4px 16px rgba(15,23,42,0.2);
}
.chat-avatar-welcome-consultor span {
    color: white; font-weight: 700; font-size: 36px;
}
.suggested-questions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 24px; }
.suggestion-chip {
    padding: 8px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}
.suggestion-chip:hover { background: var(--text-primary); color: white; border-color: var(--text-primary); }
.chat-input-area { padding: 16px 24px; border-top: 1px solid var(--border); background: var(--surface); }
.chat-input-wrapper { display: flex; gap: 8px; align-items: flex-end; }
.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 14px;
    resize: none;
    max-height: 120px;
    background: var(--surface);
}
.chat-input:focus { outline: none; border-color: var(--text-primary); }
.btn-send {
    width: 44px; height: 44px;
    border-radius: 12px;
    border: none;
    background: var(--text-primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}
.chat-footer { display: flex; justify-content: space-between; margin-top: 8px; font-size: 11px; color: var(--text-light); }
.message { margin-bottom: 16px; display: flex; align-items: flex-start; gap: 8px; }
.message.user { justify-content: flex-end; }
.message.user .bubble { background: var(--brand-action); color: white; }
.message.assistant .bubble { background: var(--background); }
.chat-avatar-msg {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, #0f172a, #1e293b);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; margin-top: 4px; box-shadow: 0 2px 8px rgba(15,23,42,0.12);
}
.chat-avatar-msg span { color: white; font-weight: 700; font-size: 15px; }
.bubble {
    max-width: 75%;
    padding: 14px 18px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.6;
}
.message.assistant .bubble {
    background: #ffffff;
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(15,23,42,0.06);
}
.message.user .bubble {
    background: #0f172a;
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant.error .bubble {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.message.assistant.thinking .bubble {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: var(--brand-primary);
}

.analice-response {
    line-height: 1.7;
    font-size: 14px;
}

.analice-response br {
    margin-bottom: 4px;
}

.analice-response strong {
    color: var(--brand-primary);
}

.analice-recommendations {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.analice-recommendations ul {
    margin-top: 6px;
    padding-left: 20px;
}

.analice-recommendations li {
    margin-bottom: 6px;
    font-size: 13px;
    line-height: 1.5;
}

.analice-section-title {
    font-size: 13px;
    color: var(--brand-ai);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.analice-data-table {
    margin-top: 12px;
    max-height: 300px;
    overflow-y: auto;
}

.analice-data-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.analice-data-table th {
    padding: 6px 8px;
    border: 1px solid var(--border);
    background: var(--brand-primary);
    color: white;
    font-weight: 600;
    text-align: left;
    position: sticky;
    top: 0;
}

.analice-data-table td {
    padding: 6px 8px;
    border: 1px solid var(--border);
}

.analice-data-table tr:hover td {
    background: #f8fafc;
}

.analice-data-table .more-rows {
    text-align: center;
    padding: 8px;
    color: var(--text-light);
    font-style: italic;
}

.analice-footer-signature {
    margin-top: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--text-light);
}

.analice-feedback {
    display: flex;
    gap: 4px;
}

.analice-feedback button {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.2s;
}

.analice-feedback button:hover {
    background: var(--border);
}

.analice-feedback button.btn-pdf {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 6px;
}

.analice-feedback button.btn-pdf:hover {
    background: var(--text-primary);
    color: white;
    border-color: var(--text-primary);
}

.analice-feedback button.btn-pdf:disabled {
    opacity: 0.6;
    cursor: wait;
}

.analice-kpis {
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-light);
}

.welcome-subtitle {
    color: var(--text-light);
    font-size: 14px;
    margin-top: 8px;
    line-height: 1.5;
}

.welcome-depth-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.depth-label {
    font-size: 12px;
    color: var(--text-light);
    margin-right: 4px;
}

.depth-btn {
    padding: 6px 16px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
    color: var(--text-primary);
}

.depth-btn:hover {
    border-color: var(--brand-ai);
    color: var(--brand-ai);
}

.depth-btn.active {
    background: var(--brand-ai);
    color: white;
    border-color: var(--brand-ai);
}

.catalog-layout { display: flex; gap: 24px; }
.catalog-nav { width: 200px; flex-shrink: 0; }
.catalog-tab {
    width: 100%;
    padding: 12px 16px;
    text-align: left;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    border-radius: var(--radius);
    margin-bottom: 4px;
    transition: all 0.2s;
}
.catalog-tab:hover, .catalog-tab.active { background: var(--brand-action); color: white; }
.catalog-content { flex: 1; }
.tab-content { display: none; }
.tab-content.active { display: block; }
.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    padding: 8px 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
}
.search-bar input { border: none; flex: 1; font-size: 14px; }
.search-bar input:focus { outline: none; }
.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.catalog-item { background: var(--surface); padding: 16px; border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.catalog-item h4 { font-size: 14px; margin-bottom: 4px; }
.catalog-item p { font-size: 12px; color: var(--text-light); }
.catalog-list > div { background: var(--surface); padding: 16px; border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 8px; }

.insight-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 12px;
    border-left: 4px solid var(--border);
}
.insight-card.severity-critico { border-left-color: var(--danger); }
.insight-card.severity-alto { border-left-color: #f97316; }
.insight-card.severity-medio { border-left-color: var(--warning); }
.insight-card.severity-baixo { border-left-color: var(--info); }
.insight-card.unread { background: #f0f7ff; }

.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; }
.alert-danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #103A71 0%, #1A4D8A 50%, #2F80ED 100%);
    padding: 20px;
}

.auth-card {
    background: white;
    border-radius: 20px;
    padding: 48px 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 25px 80px rgba(16,58,113,0.3);
}

.auth-header { text-align: center; margin-bottom: 36px; }
.auth-logo { width: 48px; height: 48px; margin-bottom: 16px; }
.auth-header h1 { font-size: 26px; font-weight: 700; color: var(--text-primary); margin-bottom: 6px; letter-spacing: -0.5px; }
.auth-header p { color: var(--text-light); font-size: 14px; }
.auth-powered { font-size: 11px; color: var(--text-light); margin-bottom: 12px; }

.auth-form .form-group { margin-bottom: 20px; }
.auth-form .form-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}
.auth-form .form-group label i { font-size: 14px; color: var(--text-light); }
.auth-form .form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #f8fafc;
}
.auth-form .form-control::placeholder { color: #94a3b8; }
.auth-form .form-control:focus {
    outline: none;
    border-color: var(--brand-action);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
    background: white;
}

.auth-form .form-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    font-size: 13px;
}
.auth-form .form-options label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-light);
    cursor: pointer;
}
.auth-form .form-options label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--brand-action);
}
.auth-form .form-options a {
    color: var(--brand-action);
    text-decoration: none;
    font-weight: 500;
}
.auth-form .form-options a:hover { text-decoration: underline; }

.auth-form .btn-primary {
    width: 100%;
    padding: 14px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}
.auth-form .btn-primary:hover {
    background: var(--brand-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}

.auth-card .alert { margin-bottom: 20px; }

.reports-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.report-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px; }
.report-card h3 { font-size: 16px; margin: 8px 0; }
.report-card p { font-size: 13px; color: var(--text-light); margin-bottom: 12px; }

.report-meta { display: flex; gap: 12px; font-size: 12px; color: var(--text-light); margin-bottom: 12px; }

.perfis-layout { display: flex; gap: 24px; }
.perfis-list { width: 300px; flex-shrink: 0; }
.perfil-card { background: var(--surface); padding: 16px; border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 8px; cursor: pointer; }
.perfil-card:hover { border: 1px solid var(--brand-action); }
.permissoes-panel { flex: 1; }

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 24px;
    border-radius: var(--radius);
    color: white;
    font-size: 14px;
    font-weight: 500;
    z-index: 9999;
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.toast-success { background: var(--brand-success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

.detail-list dt { font-size: 12px; color: var(--text-light); margin-bottom: 2px; }
.detail-list dd { font-size: 14px; font-weight: 500; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }

.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 24px; }

.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-info { background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; }

.insights-filters { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; }
.insights-filters select { padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; }

.insight-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.severity-badge { padding: 2px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; text-transform: uppercase; }
.badge-critico { background: #fef2f2; color: #991b1b; }
.badge-alto { background: #fff7ed; color: #9a3412; }
.badge-medio { background: #fef9c3; color: #854d0e; }
.badge-baixo { background: #e0f2fe; color: #075985; }
.badge-warning { background: #fef9c3; color: #854d0e; }
.badge-new { background: var(--brand-action); color: white; padding: 2px 8px; border-radius: 12px; font-size: 10px; font-weight: 700; text-transform: uppercase; }
.insight-date { font-size: 12px; color: var(--text-light); }
.insight-title { font-size: 15px; margin-bottom: 4px; }
.insight-desc { font-size: 13px; color: var(--text-light); margin-bottom: 8px; }
.insight-variacao { font-size: 13px; font-weight: 600; padding: 4px 8px; border-radius: 4px; display: inline-block; margin-bottom: 8px; }
.insight-variacao.negative { background: #fef2f2; color: #991b1b; }
.insight-variacao.positive { background: #dcfce7; color: #166534; }
.insight-recomendacoes { background: #f8fafc; padding: 12px; border-radius: var(--radius); margin: 8px 0; font-size: 13px; }
.insight-recomendacoes ul { margin-top: 4px; padding-left: 20px; }
.insight-recomendacoes li { margin-bottom: 4px; }
.insight-actions { display: flex; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }

.sql-detail pre { max-height: 200px; overflow-x: auto; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* === Permission Matrix === */
.perm-matrix {
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.perm-matrix-header {
    display: grid;
    grid-template-columns: 220px repeat(3, 1fr);
    background: var(--sidebar-bg);
    color: white;
    font-weight: 600;
    font-size: 13px;
}

.perm-matrix-header > div {
    padding: 16px;
}

.perm-perfil-col {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.perm-perfil-nome {
    text-transform: capitalize;
    font-size: 14px;
}

.perm-perfil-usuarios {
    font-size: 11px;
    opacity: 0.7;
    font-weight: 400;
}

.perm-grupo-label {
    padding: 10px 16px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-light);
    background: var(--background);
    border-bottom: 1px solid var(--border);
    font-weight: 700;
}

.perm-row {
    display: grid;
    grid-template-columns: 220px repeat(3, 1fr);
    border-bottom: 1px solid var(--border);
    transition: background var(--transition-fast);
}

.perm-row:last-child {
    border-bottom: none;
}

.perm-row:hover {
    background: #f8fafc;
}

.perm-func-col {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-right: 1px solid var(--border);
}

.perm-func-nome {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.perm-func-key {
    font-size: 11px;
    color: var(--text-light);
}

.perm-acoes {
    padding: 12px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.perm-check {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-primary);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background var(--transition-fast);
}

.perm-check:hover {
    background: #eef2ff;
}

.perm-check input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--brand-action);
    cursor: pointer;
}

.perm-check.perm-readonly {
    opacity: 0.6;
    cursor: default;
}

.perm-check.perm-readonly input[type="checkbox"] {
    cursor: default;
    accent-color: #94a3b8;
}

.perm-check.perm-readonly:hover {
    background: transparent;
}

.perm-footer {
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
}

@media (max-width: 900px) {
    .perm-matrix-header,
    .perm-row {
        grid-template-columns: 1fr;
    }

    .perm-func-col {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
}

/* === QBE Query Builder === */
.qbe-container { max-width: 100%; }
.qbe-config { background: var(--surface); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); padding: 20px; margin-bottom: 16px; }
.qbe-row { margin-bottom: 16px; }
.qbe-row:last-child { margin-bottom: 0; }
.qbe-label { display: block; font-weight: 600; font-size: 13px; color: var(--text-primary); margin-bottom: 6px; }
.qbe-fields-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 6px; }
.qbe-fields-grid label { display: flex; align-items: center; gap: 4px; font-size: 13px; cursor: pointer; padding: 4px 8px; border-radius: 4px; transition: background 0.15s; }
.qbe-fields-grid label:hover { background: #f1f5f9; }
.qbe-fields-grid input[type="checkbox"] { accent-color: var(--brand-action); }
.qbe-filters-list > div { background: #f8fafc; border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 6px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.qbe-filters-list select { min-width: 140px; }
.qbe-filters-list input[type="text"] { flex: 1; min-width: 100px; }
.qbe-order-list > div { background: #f8fafc; border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 6px; display: flex; gap: 8px; align-items: center; }
.qbe-order-list select { min-width: 140px; }
.qbe-actions { display: flex; gap: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.qbe-sql-preview { background: #1e293b; color: #e2e8f0; border-radius: var(--radius-md); padding: 16px; margin-bottom: 16px; overflow-x: auto; }
.qbe-sql-preview pre { margin: 0; font-size: 13px; line-height: 1.5; }
.qbe-sql-preview code { white-space: pre-wrap; }
.qbe-result-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 13px; color: var(--text-light); }
.qbe-result-table-wrapper { overflow-x: auto; max-height: 500px; overflow-y: auto; border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
.qbe-result-table-wrapper .table { font-size: 12px; }
.qbe-result-table-wrapper .table th { position: sticky; top: 0; z-index: 1; white-space: nowrap; }
.qbe-loading { text-align: center; padding: 40px; color: var(--text-light); display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 14px; }
.qbe-field-empty { font-size: 12px; color: var(--text-light); font-style: italic; }
.qbe-btn-remove { border: none; background: none; cursor: pointer; color: var(--danger); font-size: 16px; line-height: 1; padding: 2px 6px; border-radius: 4px; }
.qbe-btn-remove:hover { background: #fef2f2; }
.qbe-connector { font-size: 11px; font-weight: 700; text-transform: uppercase; padding: 2px 8px; border-radius: 4px; cursor: pointer; user-select: none; transition: all 0.15s; }
.qbe-connector:hover { opacity: 0.8; }
.qbe-connector { background: #e2e8f0; color: #475569; }
.qbe-connector.qbe-connector-or { background: #fef9c3; color: #854d0e; }
.qbe-filters-list > .qbe-field-empty, .qbe-order-list > .qbe-field-empty,
.qbe-filters-list > .qbe-hint { background: none; padding: 0; margin-bottom: 0; display: block; }
.qbe-hint { font-size: 11px; color: var(--text-light); margin-top: 4px; }
.qbe-filter-values { display: flex; gap: 8px; align-items: center; flex: 1; min-width: 160px; }
.qbe-filter-values .form-control { flex: 1; min-width: 100px; }
.qbe-and { font-size: 12px; color: var(--text-light); }
.qbe-lgpd { font-size: 9px; font-weight: 700; padding: 1px 4px; border-radius: 3px; background: #fef3c7; color: #92400e; margin-left: 4px; }
.qbe-pagination { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.qbe-pagination .btn-sm[disabled] { opacity: 0.4; cursor: default; pointer-events: none; }
.qbe-pagination .btn-sm:not(.btn-primary) { background: var(--surface); border: 1px solid var(--border); color: var(--text-primary); }
.qbe-pagination .btn-sm:not(.btn-primary):hover { background: #f1f5f9; }

@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar span, .sidebar .sidebar-brand, .sidebar .nav-divider span { display: none; }
    .sidebar-nav li a { justify-content: center; padding: 12px; }
    .sidebar-nav li a i { margin: 0; }
    .sidebar-nav li a .nav-icon { margin: 0; }
    .sidebar-footer .user-info span { display: none; }
    .main-content { margin-left: 60px; padding: 16px; }
    .dashboard-widgets { grid-template-columns: 1fr !important; }
    .chat-sidebar { display: none; }
    .catalog-layout { flex-direction: column; }
    .catalog-nav { width: 100%; display: flex; gap: 4px; overflow-x: auto; }
    .qbe-filters-list select, .qbe-order-list select { min-width: 0; flex: 1 1 45%; }
    .qbe-filter-values { flex-basis: 100%; }
    .qbe-actions { flex-wrap: wrap; }
    .perfis-layout { flex-direction: column; }
    .perfis-list { width: 100%; }
}
