/* ============================================================
   CréditoFácil - CSS Principal
   Estilo Fintech Moderno — Versão Responsiva Corrigida
   ============================================================ */

/* ============================================================
   VARIÁVEIS CSS
   ============================================================ */
:root {
    --primary: #6C63FF;
    --primary-dark: #5a52d5;
    --primary-light: #8B85FF;
    --secondary: #FF6584;
    --success: #00C896;
    --warning: #FFB020;
    --danger: #FF4757;
    --info: #2196F3;
    --dark: #1A1A2E;
    --dark-2: #16213E;
    --dark-3: #0F3460;
    --gray: #6B7280;
    --gray-light: #F3F4F6;
    --gray-border: #E5E7EB;
    --white: #FFFFFF;
    --text: #1F2937;
    --text-light: #6B7280;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 20px;
    --transition: all 0.3s ease;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --sidebar-width: 260px;
}

/* ============================================================
   RESET E BASE
   ============================================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    color: var(--text);
    background: var(--gray-light);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover { color: var(--primary-dark); }
img { max-width: 100%; height: auto; display: block; }
ul { list-style: none; }

/* ============================================================
   TIPOGRAFIA
   ============================================================ */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.3;
    color: var(--dark);
}

h1 { font-size: clamp(1.6rem, 4vw, 2.8rem); }
h2 { font-size: clamp(1.4rem, 3vw, 2.2rem); }
h3 { font-size: clamp(1.1rem, 2.5vw, 1.6rem); }
h4 { font-size: 1.1rem; }
p { margin-bottom: 1rem; color: var(--text-light); }

/* ============================================================
   LAYOUT
   ============================================================ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    width: 100%;
}

.container-sm {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1.5rem;
    width: 100%;
}

.row { display: flex; flex-wrap: wrap; margin: 0 -0.75rem; }
.col { flex: 1; padding: 0 0.75rem; min-width: 0; }
.col-auto { flex: 0 0 auto; padding: 0 0.75rem; }

/* Grid */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }

/* Flex utilitários */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.align-center { align-items: center; }

/* Espaçamentos */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.p-4 { padding: 2rem; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.w-100 { width: 100%; }

/* ============================================================
   BOTÕES
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    font-family: var(--font);
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 15px rgba(108,99,255,0.4);
}
.btn-primary:hover {
    background: var(--primary-dark);
    color: #fff;
    box-shadow: 0 6px 20px rgba(108,99,255,0.5);
}

.btn-secondary { background: var(--secondary); color: #fff; box-shadow: 0 4px 15px rgba(255,101,132,0.4); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-info { background: var(--info); color: #fff; }
.btn-outline { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-outline-danger { background: transparent; border: 2px solid var(--danger); color: var(--danger); }
.btn-outline-danger:hover { background: var(--danger); color: #fff; }
.btn-outline-white { background: transparent; border: 2px solid #fff; color: #fff; }
.btn-outline-white:hover { background: #fff; color: var(--primary); }
.btn-white { background: #fff; color: var(--primary); }
.btn-white:hover { background: var(--gray-light); color: var(--primary-dark); }
.btn-dark { background: var(--dark); color: #fff; }
.btn-link { background: transparent; color: var(--primary); padding: 0; }

.btn-sm { padding: 0.5rem 1rem; font-size: 0.85rem; }
.btn-lg { padding: 1rem 2rem; font-size: 1.05rem; border-radius: var(--radius); }
.btn-xl { padding: 1.2rem 2.5rem; font-size: 1.15rem; border-radius: var(--radius); }
.btn-block { width: 100%; }
.btn-icon { padding: 0.6rem; border-radius: 50%; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
}

.card:hover { box-shadow: var(--shadow-lg); }

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.card-body { padding: 1.5rem; }

.card-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-border);
    background: var(--gray-light);
}

.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--dark);
    margin: 0;
    display: flex;
    align-items: center;
}

/* ============================================================
   FORMULÁRIOS
   ============================================================ */
.form-group { margin-bottom: 1.25rem; }

.form-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.4rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--gray-border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: var(--font);
    color: var(--text);
    background: var(--white);
    transition: var(--transition);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108,99,255,0.15);
}

.form-control::placeholder { color: #9CA3AF; }
.form-control.is-invalid { border-color: var(--danger); }
.form-control.is-valid { border-color: var(--success); }

.form-text { font-size: 0.8rem; color: var(--text-light); margin-top: 0.3rem; line-height: 1.5; }
.invalid-feedback { font-size: 0.8rem; color: var(--danger); margin-top: 0.3rem; display: block; }
.valid-feedback { font-size: 0.8rem; color: var(--success); margin-top: 0.3rem; display: block; }

select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

textarea.form-control { resize: vertical; min-height: 100px; }

.input-group { display: flex; align-items: stretch; }
.input-group .form-control { border-radius: var(--radius-sm) 0 0 var(--radius-sm); flex: 1; min-width: 0; }
.input-group-append { display: flex; }
.input-group-append .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.input-prefix { position: relative; }
.input-prefix .form-control { padding-left: 3rem; }
.input-prefix-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray);
    pointer-events: none;
    z-index: 1;
}

/* ============================================================
   ALERTAS
   ============================================================ */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 0.95rem;
    border: 1px solid transparent;
    line-height: 1.5;
}

.alert-success { background: #D1FAE5; border-color: #6EE7B7; color: #065F46; }
.alert-danger { background: #FEE2E2; border-color: #FCA5A5; color: #991B1B; }
.alert-warning { background: #FEF3C7; border-color: #FCD34D; color: #92400E; }
.alert-info { background: #DBEAFE; border-color: #93C5FD; color: #1E40AF; }
.alert-icon { flex-shrink: 0; margin-top: 0.1rem; width: 20px; height: 20px; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.75rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-success { background: #D1FAE5; color: #065F46; }
.badge-danger { background: #FEE2E2; color: #991B1B; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-info { background: #DBEAFE; color: #1E40AF; }
.badge-secondary { background: #F3F4F6; color: #374151; }
.badge-primary { background: #EDE9FE; color: #5B21B6; }

/* ============================================================
   TABELAS
   ============================================================ */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    min-width: 500px;
}

.table th {
    padding: 0.9rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--gray-light);
    border-bottom: 2px solid var(--gray-border);
    white-space: nowrap;
}

.table td {
    padding: 1rem;
    border-bottom: 1px solid var(--gray-border);
    vertical-align: middle;
    color: var(--text);
}

.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(108,99,255,0.02); }
.table-striped tr:nth-child(even) td { background: var(--gray-light); }

/* ============================================================
   GRUPO DE BOTÕES
   ============================================================ */
.btn-group {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.btn-group .btn {
    /* Garante área de toque mínima de 44px para acessibilidade mobile */
    min-height: 36px;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: var(--transition);
}

.modal-overlay.active .modal { transform: scale(1); }
.modal-header { padding: 1.5rem; border-bottom: 1px solid var(--gray-border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 1.1rem; font-weight: 700; color: var(--dark); }
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--gray-border); display: flex; gap: 0.75rem; justify-content: flex-end; flex-wrap: wrap; }

/* ============================================================
   PAGINAÇÃO
   ============================================================ */
.pagination {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    background: var(--white);
    border: 1px solid var(--gray-border);
    transition: var(--transition);
    cursor: pointer;
    text-decoration: none;
}

.page-link:hover { border-color: var(--primary); color: var(--primary); }
.page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-link.disabled { opacity: 0.4; cursor: not-allowed; }

/* ============================================================
   SPINNER / LOADING
   ============================================================ */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   APP LAYOUT (ÁREA INTERNA)
   ============================================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--dark) 0%, var(--dark-2) 100%);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 200;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.3s ease;
    -webkit-overflow-scrolling: touch;
}

.sidebar-logo {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.sidebar-logo-icon {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 0.9rem;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-logo-text {
    font-size: 1rem;
    font-weight: 800;
    color: #fff;
    line-height: 1.2;
}

.sidebar-logo-sub {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.4);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.sidebar-nav-title {
    padding: 0.5rem 1.5rem;
    font-size: 0.7rem;
    font-weight: 700;
    color: rgba(255,255,255,0.3);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.25rem;
}

.sidebar-nav-item a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
    border-radius: 0;
}

.sidebar-nav-item a:hover {
    color: #fff;
    background: rgba(255,255,255,0.06);
}

.sidebar-nav-item a.active {
    color: #fff;
    background: rgba(108,99,255,0.2);
}

.sidebar-nav-item a.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

.nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.nav-icon svg { width: 18px; height: 18px; }

.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 50px;
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: #fff;
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar-user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-user-name { font-size: 0.85rem; font-weight: 600; color: #fff; }
.sidebar-user-role { font-size: 0.7rem; color: rgba(255,255,255,0.5); }

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

/* Topbar */
.topbar {
    background: var(--white);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 0 var(--gray-border);
    position: sticky;
    top: 0;
    z-index: 50;
    gap: 1rem;
}

.topbar-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.topbar-notif {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gray-light);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    color: var(--gray);
    border: none;
    flex-shrink: 0;
    text-decoration: none;
}

.topbar-notif:hover { background: var(--gray-border); color: var(--dark); }

.topbar-notif .badge-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid #fff;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--gray);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.hamburger:hover { background: var(--gray-light); color: var(--dark); }

/* Page Content */
.page-content {
    padding: 1.5rem;
    flex: 1;
}

.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.4rem; margin-bottom: 0.25rem; }

.breadcrumb {
    display: flex;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-light);
    flex-wrap: wrap;
}

.breadcrumb-item + .breadcrumb-item::before { content: '/'; }
.breadcrumb-item a { color: var(--primary); }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
}

.stat-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg { width: 24px; height: 24px; }

.stat-icon-primary { background: rgba(108,99,255,0.15); color: var(--primary); }
.stat-icon-success { background: rgba(0,200,150,0.15); color: var(--success); }
.stat-icon-warning { background: rgba(255,176,32,0.15); color: var(--warning); }
.stat-icon-danger { background: rgba(255,71,87,0.15); color: var(--danger); }
.stat-icon-info { background: rgba(33,150,243,0.15); color: var(--info); }

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--dark);
    line-height: 1;
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.82rem;
    color: var(--text-light);
    font-weight: 500;
}

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress {
    background: var(--gray-border);
    border-radius: 50px;
    height: 8px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: 50px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    transition: width 0.6s ease;
}

.progress-bar-success { background: linear-gradient(90deg, var(--success), #00E6AD); }
.progress-bar-warning { background: linear-gradient(90deg, var(--warning), #FFD060); }
.progress-bar-danger { background: linear-gradient(90deg, var(--danger), #FF7A8A); }

/* ============================================================
   DIVIDER / EMPTY STATE / TOOLTIP
   ============================================================ */
.divider { border: none; border-top: 1px solid var(--gray-border); margin: 1.5rem 0; }

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-light);
}

.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.4; }
.empty-state h3 { font-size: 1.05rem; color: var(--text-light); margin-bottom: 0.5rem; }

.tooltip-wrapper { position: relative; display: inline-block; }

.tooltip-text {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--dark);
    color: #fff;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 100;
    pointer-events: none;
}

.tooltip-wrapper:hover .tooltip-text { opacity: 1; visibility: visible; }

/* ============================================================
   OVERLAY MOBILE SIDEBAR
   ============================================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 150;
    -webkit-tap-highlight-color: transparent;
}

.sidebar-overlay.active { display: block; }

/* ============================================================
   ANIMAÇÕES
   ============================================================ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.animate-fade { animation: fadeIn 0.4s ease forwards; }
.animate-slide { animation: slideIn 0.4s ease forwards; }

/* ============================================================
   SCROLLBAR CUSTOMIZADA
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--gray-light); }
::-webkit-scrollbar-thumb { background: var(--gray-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray); }

/* ============================================================
   RESPONSIVIDADE — TABLET (≤1024px)
   ============================================================ */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   RESPONSIVIDADE — MOBILE (≤768px)
   ============================================================ */
@media (max-width: 768px) {
    /* Sidebar mobile: oculta por padrão, desliza ao abrir */
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0,0,0,0.3);
    }

    /* Main content ocupa tudo */
    .main-content { margin-left: 0; }

    /* Hamburger visível */
    .hamburger { display: flex; }

    /* Grids viram 1 coluna */
    .grid-2,
    .grid-3,
    .grid-4 { grid-template-columns: 1fr; }

    /* Padding reduzido */
    .page-content { padding: 1rem; }
    .topbar { padding: 0.75rem 1rem; }

    /* Ocultar elementos não essenciais no mobile */
    .d-sm-none { display: none !important; }

    /* Tabelas */
    .table th, .table td { padding: 0.75rem 0.6rem; font-size: 0.85rem; }

    /* Cards */
    .card-body { padding: 1.25rem; }
    .card-header { padding: 1rem 1.25rem; }

    /* Stat cards */
    .stat-card { padding: 1.25rem; gap: 0.75rem; }
    .stat-value { font-size: 1.3rem; }
}

/* ============================================================
   RESPONSIVIDADE — MOBILE PEQUENO (≤480px)
   ============================================================ */
@media (max-width: 480px) {
    .btn-lg { padding: 0.85rem 1.5rem; font-size: 0.95rem; }
    .btn-xl { padding: 1rem 1.75rem; font-size: 1rem; }

    .stat-card { flex-direction: column; text-align: center; padding: 1.25rem 1rem; }
    .stat-icon { margin: 0 auto; }

    .page-content { padding: 0.75rem; }
    .page-header h1 { font-size: 1.2rem; }

    .card-body { padding: 1rem; }
    .card-header { padding: 0.875rem 1rem; }

    .topbar { padding: 0.6rem 0.75rem; }
    .topbar-title { font-size: 0.95rem; }
    .topbar-actions { gap: 0.5rem; }

    .topbar-notif { width: 36px; height: 36px; }

    .modal { border-radius: var(--radius-sm); }
    .modal-header, .modal-body, .modal-footer { padding: 1rem; }

    h1 { font-size: 1.4rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.1rem; }
}

/* ============================================================
   RESPONSIVIDADE — TELAS MUITO PEQUENAS (≤360px)
   ============================================================ */
@media (max-width: 360px) {
    :root { font-size: 14px; }
    .page-content { padding: 0.5rem; }
    .btn { padding: 0.65rem 1.1rem; font-size: 0.875rem; }
}

/* ============================================================
   MELHORIAS GLOBAIS DE ACESSIBILIDADE MOBILE
   ============================================================ */

/* Previne zoom automático em inputs no iOS (fonte mínima 16px) */
@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    input[type="search"],
    input[type="date"],
    textarea,
    select {
        font-size: 16px;
    }

    /* Área de toque mínima para botões (WCAG 2.5.5) */
    .btn {
        min-height: 44px;
    }

    .btn-sm {
        min-height: 36px;
    }

    /* Evitar overflow horizontal global */
    body {
        overflow-x: hidden;
    }

    /* Melhorar legibilidade de tabelas em scroll horizontal */
    .table-responsive {
        border: 1px solid var(--gray-border);
        border-radius: var(--radius-sm);
    }
}

/* Garantir que grids com colunas customizadas também colem no mobile */
@media (max-width: 768px) {
    [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
}
