/* ===== AAPVB - Sistema de Cobrança ===== */
/* Reset e Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #16a34a;
    --primary-dark: #15803d;
    --primary-light: #22c55e;
    --primary-50: #f0fdf4;
    --primary-100: #dcfce7;
    --primary-200: #bbf7d0;
    --primary-700: #15803d;
    --primary-800: #166534;
    --primary-900: #14532d;
    --secondary: #064e3b;
    --accent: #f59e0b;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --success: #22c55e;
    --success-light: #f0fdf4;
    --info: #3b82f6;
    --info-light: #eff6ff;
    --dark: #1e293b;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --white: #ffffff;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --transition: all 0.2s ease;
    --sidebar-width: 260px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ===== LOGIN PAGE ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-900) 0%, var(--primary-dark) 50%, var(--primary) 100%);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: rgba(255,255,255,0.03);
    border-radius: 50%;
    top: -200px;
    right: -200px;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: rgba(255,255,255,0.02);
    border-radius: 50%;
    bottom: -100px;
    left: -100px;
}

.login-container {
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 420px;
    padding: 40px;
    position: relative;
    z-index: 1;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo .logo-icon {
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    box-shadow: 0 4px 14px rgba(22, 163, 74, 0.4);
}

.login-logo .logo-icon svg {
    width: 36px;
    height: 36px;
    fill: white;
}

.login-logo h1 {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary-dark);
    letter-spacing: -0.5px;
}

.login-logo p {
    color: var(--gray-500);
    font-size: 14px;
    margin-top: 4px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 15px;
    font-family: inherit;
    color: var(--gray-800);
    transition: var(--transition);
    background: var(--gray-50);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
}

.form-control::placeholder {
    color: var(--gray-400);
}

.form-control.is-invalid {
    border-color: var(--danger);
}

select.form-control {
    appearance: none;
    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='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

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

.input-icon-group {
    position: relative;
}

.input-icon-group .icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    pointer-events: none;
}

.input-icon-group .form-control {
    padding-left: 42px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 2px 8px rgba(22, 163, 74, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.4);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: var(--primary-dark);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-info {
    background: var(--info);
    color: white;
}

.btn-info:hover {
    background: #2563eb;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--gray-200);
    color: var(--gray-700);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-50);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn-block {
    width: 100%;
}

.btn-whatsapp {
    background: #25D366;
    color: white;
}

.btn-whatsapp:hover {
    background: #1da851;
}

/* ===== LAYOUT ===== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--primary-900) 0%, var(--primary-800) 100%);
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

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

.sidebar-header .s-logo {
    width: 42px;
    height: 42px;
    background: rgba(255,255,255,0.15);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-header .s-logo svg {
    width: 22px;
    height: 22px;
    fill: white;
}

.sidebar-header .s-info h2 {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
}

.sidebar-header .s-info span {
    font-size: 11px;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.4);
    padding: 0 12px;
    margin-bottom: 8px;
    font-weight: 600;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: rgba(255,255,255,0.7);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 2px;
}

.nav-link:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.nav-link.active {
    background: rgba(255,255,255,0.15);
    color: white;
    font-weight: 600;
}

.nav-link svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.8;
}

.nav-link.active svg {
    opacity: 1;
}

.nav-link .badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-user .avatar {
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.sidebar-user .user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user .user-info .name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user .user-info .role {
    font-size: 11px;
    opacity: 0.6;
}

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

/* ===== TOP BAR ===== */
.topbar {
    background: var(--white);
    padding: 16px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--gray-200);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-left h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900);
}

.topbar-left .breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--gray-500);
}

.topbar-left .breadcrumb a {
    color: var(--primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius);
    color: var(--gray-700);
}

.menu-toggle:hover {
    background: var(--gray-100);
}

.menu-toggle svg {
    width: 24px;
    height: 24px;
}

/* ===== PAGE CONTENT ===== */
.page-content {
    padding: 28px;
    flex: 1;
    max-width: 1400px;
    width: 100%;
}

/* ===== STATS CARDS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: var(--transition);
    border: 1px solid var(--gray-100);
}

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

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

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

.stat-card .stat-icon.green {
    background: var(--primary-100);
    color: var(--primary);
}

.stat-card .stat-icon.green svg { fill: var(--primary); }

.stat-card .stat-icon.blue {
    background: var(--info-light);
    color: var(--info);
}

.stat-card .stat-icon.blue svg { fill: var(--info); }

.stat-card .stat-icon.red {
    background: var(--danger-light);
    color: var(--danger);
}

.stat-card .stat-icon.red svg { fill: var(--danger); }

.stat-card .stat-icon.yellow {
    background: var(--warning-light);
    color: var(--warning);
}

.stat-card .stat-icon.yellow svg { fill: var(--warning); }

.stat-info h3 {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-500);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.stat-info .stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--gray-900);
    line-height: 1.1;
}

.stat-info .stat-sub {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 4px;
}

/* ===== CARD / PANEL ===== */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.card-header h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-900);
}

.card-body {
    padding: 24px;
}

.card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-100);
    background: var(--gray-50);
}

/* ===== TABLE ===== */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead th {
    background: var(--gray-50);
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
}

.table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 14px;
    color: var(--gray-700);
    vertical-align: middle;
}

.table tbody tr:hover {
    background: var(--gray-50);
}

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

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    gap: 4px;
}

.badge-success {
    background: var(--success-light);
    color: var(--primary-700);
}

.badge-danger {
    background: var(--danger-light);
    color: var(--danger);
}

.badge-warning {
    background: var(--warning-light);
    color: #b45309;
}

.badge-info {
    background: var(--info-light);
    color: var(--info);
}

.badge-secondary {
    background: var(--gray-100);
    color: var(--gray-600);
}

.badge-dot::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.badge-success.badge-dot::before { background: var(--success); }
.badge-danger.badge-dot::before { background: var(--danger); }
.badge-warning.badge-dot::before { background: var(--warning); }
.badge-info.badge-dot::before { background: var(--info); }

/* ===== ALERT ===== */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background: var(--success-light);
    color: var(--primary-800);
    border: 1px solid var(--primary-200);
}

.alert-danger {
    background: var(--danger-light);
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: var(--warning-light);
    color: #92400e;
    border: 1px solid #fde68a;
}

.alert-info {
    background: var(--info-light);
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* ===== FORM GRID ===== */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.form-row-3 {
    grid-template-columns: repeat(3, 1fr);
}

.form-row-2 {
    grid-template-columns: repeat(2, 1fr);
}

/* ===== FILTERS ===== */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.filters-bar .form-control {
    max-width: 200px;
    padding: 10px 14px;
    font-size: 13px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-600);
    white-space: nowrap;
}

/* ===== PAGINATION ===== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 20px;
}

.pagination a, .pagination span {
    padding: 8px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-600);
    border: 1px solid var(--gray-200);
    transition: var(--transition);
}

.pagination a:hover {
    background: var(--primary-50);
    border-color: var(--primary);
    color: var(--primary);
}

.pagination .active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-400);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 18px;
    color: var(--gray-600);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    max-width: 400px;
    margin: 0 auto;
}

/* ===== ACTIONS ===== */
.actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    background: var(--white);
    color: var(--gray-600);
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-50);
}

.btn-icon.danger:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: var(--danger-light);
}

.btn-icon svg {
    width: 16px;
    height: 16px;
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal-overlay.show {
    display: flex;
}

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

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--gray-400);
    border-radius: var(--radius);
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-100);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ===== MONTH GRID ===== */
.month-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.month-card {
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.month-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.month-card.current {
    border-color: var(--primary);
    background: var(--primary-50);
}

.month-card .month-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 4px;
}

.month-card .month-status {
    font-size: 12px;
    color: var(--gray-500);
}

/* ===== DASHBOARD GRIDS ===== */
.dash-grid-2fr1fr {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.dash-grid-1fr1fr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

/* ===== CHART AREA ===== */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

.chart-wrapper {
    position: relative;
    width: 100%;
    min-height: 200px;
    max-height: 320px;
}

.chart-wrapper canvas {
    width: 100% !important;
}

/* ===== ADMIN PAGE GRIDS (inline grids) ===== */
.admin-grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.admin-grid-3col {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

/* ===== RESPONSIVE ===== */

/* Prevent horizontal overflow globally */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

@media (max-width: 1200px) {
    .dash-grid-2fr1fr {
        grid-template-columns: 1.5fr 1fr;
        gap: 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .hide-tablet {
        display: none;
    }
}

@media (max-width: 1024px) {
    .form-row-3 {
        grid-template-columns: repeat(2, 1fr);
    }

    .dash-grid-2fr1fr {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .dash-grid-1fr1fr {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .admin-grid-2col {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .admin-grid-3col {
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }

    .stat-info .stat-value {
        font-size: 24px;
    }

    .page-content {
        padding: 20px;
    }
}

@media (max-width: 768px) {
    /* ── Force NO horizontal scroll ─────────────────────── */
    .page-content *,
    .topbar * {
        max-width: 100%;
        box-sizing: border-box;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }

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

    .main-content {
        margin-left: 0;
        width: 100vw;
        max-width: 100vw;
        overflow-x: hidden;
    }

    .menu-toggle {
        display: block;
    }

    .page-content {
        padding: 12px;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
        box-sizing: border-box;
    }

    .topbar {
        padding: 10px 12px;
    }

    .topbar-left h1 {
        font-size: 15px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 160px;
    }

    .topbar-right {
        gap: 8px;
    }

    .topbar-right .text-muted {
        display: none;
    }

    .topbar-right .btn {
        padding: 6px 10px;
        font-size: 12px;
        gap: 4px;
    }

    .topbar-right .btn svg {
        width: 14px;
        height: 14px;
    }

    /* ── Stats Grid ─────────────────────────────────────── */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        margin-bottom: 16px;
    }

    .stat-card {
        padding: 12px;
        gap: 10px;
        flex-direction: column;
        align-items: flex-start;
    }

    .stat-card .stat-icon {
        width: 32px;
        height: 32px;
    }

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

    .stat-info h3 {
        font-size: 10px;
        margin-bottom: 2px;
    }

    .stat-info .stat-value {
        font-size: 18px;
        word-break: break-all;
    }

    .stat-info .stat-sub {
        font-size: 10px;
    }

    /* ── Cards ──────────────────────────────────────────── */
    .card {
        border-radius: var(--radius);
        margin-bottom: 12px;
        overflow: hidden;
    }

    .card-header {
        padding: 12px 14px;
    }

    .card-header h2 {
        font-size: 14px;
        word-break: break-word;
    }

    .card-body {
        padding: 12px 14px;
        overflow-x: hidden;
    }

    .card-footer {
        padding: 12px 14px;
    }

    /* ── Forms ──────────────────────────────────────────── */
    .form-row, .form-row-2, .form-row-3 {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }

    .form-group {
        margin-bottom: 12px;
    }

    .form-group label {
        font-size: 12px;
        margin-bottom: 4px;
    }

    .form-control {
        padding: 10px 12px;
        font-size: 14px;
        width: 100%;
        box-sizing: border-box;
    }

    .filters-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .filters-bar .form-control {
        max-width: 100% !important;
        width: 100% !important;
    }

    .filter-group {
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        width: 100%;
    }

    .input-icon-group {
        max-width: 100% !important;
        flex: 1 1 100% !important;
    }

    /* ── Tables — Card Layout on Mobile ────────────────── */
    .table-responsive {
        margin: 0;
        padding: 0;
        overflow-x: hidden;
    }

    .table {
        width: 100%;
        table-layout: fixed;
    }

    .table thead th,
    .table tbody td {
        padding: 8px 6px;
        font-size: 12px;
        word-break: break-word;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .table thead th {
        white-space: nowrap;
        font-size: 10px;
    }

    /* Hide less important table columns on mobile */
    .table .hide-mobile,
    .hide-mobile {
        display: none !important;
    }

    /* ── Buttons ────────────────────────────────────────── */
    .login-container {
        padding: 24px 20px;
    }

    .login-logo h1 {
        font-size: 22px;
    }

    .login-logo .logo-icon {
        width: 56px;
        height: 56px;
    }

    .btn {
        padding: 9px 14px;
        font-size: 13px;
        white-space: nowrap;
    }

    .btn-sm {
        padding: 6px 10px;
        font-size: 12px;
    }

    .btn-lg {
        padding: 12px 20px;
        font-size: 14px;
    }

    .btn-icon {
        width: 28px;
        height: 28px;
        flex-shrink: 0;
    }

    .btn-icon svg {
        width: 13px;
        height: 13px;
    }

    .actions {
        display: flex;
        flex-wrap: wrap;
        gap: 3px;
        max-width: 100%;
    }

    /* Hide text on very compact action buttons */
    .table .btn .btn-text {
        display: none;
    }

    /* ── Alerts & Badges ───────────────────────────────── */
    .alert {
        padding: 10px 12px;
        font-size: 13px;
        word-break: break-word;
    }

    .badge {
        font-size: 11px;
        padding: 3px 8px;
        white-space: nowrap;
    }

    /* ── Pagination ────────────────────────────────────── */
    .pagination {
        flex-wrap: wrap;
        gap: 3px;
    }

    .pagination a, .pagination span {
        padding: 6px 10px;
        font-size: 12px;
    }

    /* ── Month Grid ────────────────────────────────────── */
    .month-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .month-card {
        padding: 10px 6px;
    }

    .month-card .month-name {
        font-size: 12px;
    }

    .month-card .month-status {
        font-size: 10px;
    }

    /* ── Profile ───────────────────────────────────────── */
    .profile-header {
        flex-direction: column;
        text-align: center;
        padding: 20px 16px;
    }

    .profile-avatar {
        width: 60px;
        height: 60px;
        font-size: 24px;
    }

    .profile-info h2 {
        font-size: 18px;
    }

    /* ── Cobranca Items ────────────────────────────────── */
    .cobranca-item {
        padding: 12px 0;
        gap: 8px;
        flex-wrap: nowrap;
    }

    .cobranca-info {
        min-width: 0;
        flex: 1;
        overflow: hidden;
    }

    .cobranca-info h4 {
        font-size: 13px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .cobranca-info span {
        font-size: 12px;
    }

    .cobranca-valor {
        font-size: 14px;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* ── Empty State ───────────────────────────────────── */
    .empty-state {
        padding: 40px 16px;
    }

    .empty-state svg {
        width: 48px;
        height: 48px;
    }

    .empty-state h3 {
        font-size: 16px;
    }

    /* ── Modal ─────────────────────────────────────────── */
    .modal {
        max-width: calc(100vw - 24px);
        max-height: 85vh;
    }

    .modal-header {
        padding: 14px 16px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        padding: 12px 16px;
    }

    /* ── Dashboard Grids ───────────────────────────────── */
    .dash-grid-2fr1fr,
    .dash-grid-1fr1fr {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 12px;
    }

    .admin-grid-2col,
    .admin-grid-3col {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* ── Chart ─────────────────────────────────────────── */
    .chart-wrapper {
        height: 200px !important;
        min-height: 150px;
    }

    canvas {
        max-height: 200px !important;
        height: auto !important;
    }

    /* ── Cobranca Lists ────────────────────────────────── */
    .card-body[style*="max-height"] {
        max-height: 250px !important;
    }

    /* ── Cobrancas Grid ────────────────────────────────── */
    .cobrancas-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    /* ── Compact Filters ───────────────────────────────── */
    .filters-bar .filter-group {
        width: 100%;
    }

    .filters-bar .filter-group select.form-control {
        max-width: 100%;
    }

    .filters-bar input[type="text"] {
        max-width: 100% !important;
    }

    /* ── Override Any Inline Grids ──────────────────────── */
    [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    /* ── D-flex utility fix ─────────────────────────────── */
    .d-flex {
        flex-wrap: wrap !important;
    }

    .d-flex.justify-between {
        gap: 8px;
    }

    /* ── General text overflow prevention ──────────────── */
    h1, h2, h3, h4, h5, h6, p, span, a, td, th, label, div {
        overflow-wrap: break-word;
        word-wrap: break-word;
    }

    /* ── Prevent any element from being wider than screen ─ */
    img, svg, video, canvas, iframe {
        max-width: 100%;
        height: auto;
    }

    /* ── Form row inside inline styles fix ─────────────── */
    [style*="form-row"] {
        display: grid !important;
        grid-template-columns: 1fr !important;
    }

    /* Grid span overrides */
    [style*="grid-column:span"],
    [style*="grid-column: span"] {
        grid-column: span 1 !important;
    }
}

@media (max-width: 380px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }

    .stat-card {
        padding: 10px;
    }

    .stat-info .stat-value {
        font-size: 16px;
    }

    .stat-info h3 {
        font-size: 9px;
    }

    .page-content {
        padding: 8px;
    }

    .card-body {
        padding: 10px;
    }

    .card-header {
        padding: 10px;
    }

    .topbar-left h1 {
        font-size: 14px;
        max-width: 120px;
    }

    .month-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .table thead th,
    .table tbody td {
        padding: 6px 4px;
        font-size: 11px;
    }

    .actions .btn-icon {
        width: 26px;
        height: 26px;
    }

    .cobranca-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .cobranca-valor {
        align-self: flex-end;
    }

    .btn {
        padding: 8px 12px;
        font-size: 12px;
    }
}

/* ===== UTILITIES ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-info { color: var(--info); }
.text-muted { color: var(--gray-500); }
.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }
.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-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.w-100 { width: 100%; }

/* ===== LOADING ===== */
.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* ===== PROFILE CARD ===== */
.profile-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
    flex-shrink: 0;
}

.profile-info h2 {
    font-size: 22px;
    font-weight: 700;
}

.profile-info p {
    opacity: 0.85;
    font-size: 14px;
}

/* ===== COBRANCAS GRID (Associado) ===== */
.cobrancas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

/* ===== COBRANCA STATUS LIST ===== */
.cobranca-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid var(--gray-100);
    gap: 12px;
    flex-wrap: wrap;
}

.cobranca-item:last-child {
    border-bottom: none;
}

.cobranca-info {
    flex: 1;
    min-width: 0;
}

.cobranca-info h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
}

.cobranca-info span {
    font-size: 13px;
    color: var(--gray-500);
}

.cobranca-valor {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-900);
}
