/* ============================================================
   Imperio Crédito Fácil — Design System
   ============================================================ */

:root {
    --primary:    #2563eb;
    --primary-d:  #1d4ed8;
    --success:    #16a34a;
    --danger:     #dc2626;
    --warning:    #d97706;
    --purple:     #7c3aed;
    --teal:       #0d9488;
    --yellow:     #ca8a04;

    --bg:         #f1f5f9;
    --surface:    #ffffff;
    --border:     #e2e8f0;
    --text:       #0f172a;
    --text-muted: #64748b;

    --sidebar-w:  260px;
    --topbar-h:   56px;
    --radius:     10px;
    --shadow:     0 1px 4px rgba(0,0,0,.08);
    --shadow-md:  0 4px 16px rgba(0,0,0,.12);
}

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

html { font-size: 16px; }

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

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

/* ─── Layout ───────────────────────────────────────────────── */
.app-wrapper { display: flex; min-height: 100vh; }

/* ─── Sidebar ───────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: #0f172a;
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    transition: transform .25s ease;
}

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

.logo { display: flex; align-items: center; gap: 10px; }
.logo-mark {
    width: 34px; height: 34px;
    background: var(--primary);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 16px;
    flex-shrink: 0;
}
.logo-text strong { display: block; font-size: 15px; color: #fff; }
.logo-text small { font-size: 11px; color: #64748b; }

.sidebar-close { display: none; background: none; border: none; color: #94a3b8; font-size: 16px; cursor: pointer; padding: 6px; }

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

.nav-group { padding: 8px 0; }
.nav-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #475569;
    padding: 6px 16px;
    display: block;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: #94a3b8;
    font-size: 14px;
    border-left: 3px solid transparent;
    transition: all .15s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-item.active {
    background: rgba(37, 99, 235, .15);
    color: #fff;
    border-left-color: var(--primary);
}
.nav-icon { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    gap: 10px;
}
.user-avatar {
    width: 34px; height: 34px;
    background: var(--primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px; color: #fff;
    flex-shrink: 0;
}
.user-details { flex: 1; min-width: 0; }
.user-name { display: block; font-size: 13px; font-weight: 600; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: #64748b; }

.btn-logout {
    background: none; border: none; color: #64748b; font-size: 18px;
    cursor: pointer; padding: 4px; line-height: 1;
    transition: color .15s;
}
.btn-logout:hover { color: var(--danger); }

/* ─── Sidebar Overlay (mobile) ─────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 190;
}

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

/* ─── Topbar ────────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 12px;
    position: sticky; top: 0; z-index: 100;
}
.sidebar-toggle { display: none; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-muted); }
.topbar-title { font-weight: 600; font-size: 16px; flex: 1; }
.topbar-actions { display: flex; gap: 8px; }

/* ─── Page Content ──────────────────────────────────────────── */
.page-content { padding: 24px; flex: 1; }

/* ─── Alerts ────────────────────────────────────────────────── */
.alert {
    padding: 12px 16px; border-radius: var(--radius);
    margin-bottom: 16px; font-size: 14px;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.alert ul { list-style: disc; padding-left: 16px; }

/* ─── Cards ─────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
}
.card-header h3 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }
.card-body.p-0 { padding: 0; }
.card-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: #f8fafc;
    display: flex; justify-content: flex-end; gap: 8px;
}
.mt-4 { margin-top: 20px; }
.mb-4 { margin-bottom: 20px; }

/* ─── Stat Cards ────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 18px 20px;
    display: flex; align-items: center; gap: 14px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.stat-icon {
    font-size: 22px;
    flex-shrink: 0;
    width: 44px; height: 44px;
    border-radius: 10px;
    background: rgba(0,0,0,.04);
    display: flex; align-items: center; justify-content: center;
    color: inherit;
}
.stat-body { display: flex; flex-direction: column; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.stat-value { font-size: 22px; font-weight: 700; line-height: 1.2; }

.stat-blue   .stat-value { color: var(--primary); }
.stat-blue   .stat-icon  { background: #dbeafe; color: var(--primary); }
.stat-green  .stat-value { color: var(--success); }
.stat-green  .stat-icon  { background: #dcfce7; color: var(--success); }
.stat-orange .stat-value { color: var(--warning); }
.stat-orange .stat-icon  { background: #ffedd5; color: var(--warning); }
.stat-purple .stat-value { color: var(--purple); }
.stat-purple .stat-icon  { background: #ede9fe; color: var(--purple); }
.stat-teal   .stat-value { color: var(--teal); }
.stat-teal   .stat-icon  { background: #ccfbf1; color: var(--teal); }
.stat-red    .stat-value { color: var(--danger); }
.stat-red    .stat-icon  { background: #fee2e2; color: var(--danger); }
.stat-yellow .stat-value { color: var(--yellow); }
.stat-yellow .stat-icon  { background: #fef9c3; color: var(--yellow); }

/* ─── Section Header ────────────────────────────────────────── */
.section-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px;
}
.section-header h2 { font-size: 16px; font-weight: 600; }

/* ─── Tables ────────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
    text-align: left; padding: 10px 14px;
    background: #f8fafc; border-bottom: 1px solid var(--border);
    font-size: 11px; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .05em;
    white-space: nowrap;
}
.data-table td {
    padding: 12px 14px; border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f8fafc; }
.row-inactive { opacity: .55; }
.actions-cell { white-space: nowrap; display: flex; gap: 6px; }

/* ─── Card Table (mobile: tabela vira card) ──────────────────── */
/* Use class="data-table card-table" para ativar a conversão mobile */
@media (max-width: 680px) {
    .card-table thead { display: none; }
    .card-table tbody, .card-table tr, .card-table td {
        display: block; width: 100%;
    }
    .card-table tr {
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: 10px;
        padding: 12px 14px;
        background: var(--surface);
        box-shadow: var(--shadow);
    }
    .card-table tr:hover td { background: transparent; }
    .card-table tr:last-child td { border-bottom: none; }
    .card-table td {
        padding: 4px 0;
        border: none;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        font-size: 14px;
    }
    .card-table td[data-label]::before {
        content: attr(data-label);
        font-size: 11px;
        font-weight: 600;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: .04em;
        flex-shrink: 0;
        min-width: 100px;
    }
    .card-table td.td-main {
        font-size: 15px;
        font-weight: 600;
        padding-bottom: 8px;
        margin-bottom: 4px;
        border-bottom: 1px solid var(--border);
        justify-content: flex-start;
        flex-direction: column;
        align-items: flex-start;
    }
    .card-table td.td-main::before { display: none; }
    .card-table td.td-actions {
        justify-content: flex-end;
        padding-top: 8px;
        margin-top: 4px;
        border-top: 1px solid var(--border);
    }
    .card-table td.td-actions::before { display: none; }
    .row-inactive { opacity: .6; }
    .actions-cell { display: flex; }
}

/* ─── Buttons ───────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: 7px;
    font-size: 14px; font-weight: 500; cursor: pointer;
    border: 1.5px solid transparent;
    transition: all .15s; white-space: nowrap; line-height: 1.4;
    text-decoration: none !important;
}
.btn:hover { opacity: .88; }
.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; }

.btn-primary        { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover  { background: var(--primary-d); }
.btn-outline        { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover  { background: #f1f5f9; }
.btn-danger-outline { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger-outline:hover { background: #fee2e2; }

/* ─── Badges ────────────────────────────────────────────────── */
.badge {
    display: inline-block; padding: 3px 8px;
    border-radius: 99px; font-size: 11px; font-weight: 600;
}
.badge-green   { background: #dcfce7; color: #166534; }
.badge-gray    { background: #f1f5f9; color: #64748b; }
.badge-active  { background: #dbeafe; color: #1e40af; }
.badge-paid    { background: #dcfce7; color: #166534; }
.badge-partial { background: #fef9c3; color: #854d0e; }
.badge-overdue { background: #fee2e2; color: #991b1b; }

/* ─── Forms ─────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--text); }
.form-group input,
.form-group select,
.form-group textarea {
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: 7px;
    font-size: 14px; color: var(--text);
    background: #fff;
    transition: border-color .15s;
    width: 100%;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.form-check { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 14px; }
.form-check input { width: auto; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-full   { grid-column: 1 / -1; }

/* ─── Settings rows ──────────────────────────────────────────── */
.settings-row {
    display: flex; flex-wrap: wrap; align-items: flex-start;
    gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }
.settings-label { width: 180px; flex-shrink: 0; }
.settings-label strong { display: block; font-size: 14px; }
.settings-label small { color: var(--text-muted); }
.settings-fields { display: flex; flex-wrap: wrap; gap: 12px; flex: 1; }
.settings-fields .form-group { flex: 1; min-width: 110px; margin: 0; }

/* ─── Toggle label ─────────────────────────────────────────── */
.toggle-label { display: flex; align-items: center; gap: 8px; cursor: pointer; }

/* ─── Client cards ─────────────────────────────────────────── */
.client-cards { display: flex; flex-direction: column; gap: 8px; }
.client-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex; align-items: center; gap: 12px;
    transition: border-color .15s, box-shadow .15s;
    cursor: pointer; text-decoration: none !important; color: var(--text);
}
.client-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.client-overdue { border-color: var(--danger) !important; }

.client-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff; font-weight: 700; font-size: 16px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.client-details { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.client-details strong { font-size: 14px; }
.client-status { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.amount-sm { font-size: 13px; font-weight: 600; color: var(--primary); }

/* ─── Contract block ─────────────────────────────────────────── */
.contract-block {
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
}
.contract-block:last-child { border-bottom: none; }
.contract-block-overdue { background: #fff5f5; }

.contract-block-header { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; }
.contract-block-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.contract-block-values {
    display: flex; flex-wrap: wrap; gap: 16px;
}
.contract-block-values div { display: flex; flex-direction: column; }
.contract-block-values small { font-size: 11px; color: var(--text-muted); }
.contract-block-values strong { font-size: 14px; }
.contract-block-footer { margin-top: 12px; }

.payment-history { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.payment-row {
    display: flex; gap: 12px; flex-wrap: wrap;
    font-size: 13px; padding: 3px 0;
}

/* ─── Dashboard grid ─────────────────────────────────────────── */
.dashboard-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.contract-list { padding: 8px 0; }
.contract-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px; gap: 8px;
    border-bottom: 1px solid var(--border);
}
.contract-item:last-child { border-bottom: none; }
.contract-item.overdue { background: #fff5f5; }
.contract-info { display: flex; flex-direction: column; flex: 1; }
.contract-info strong { font-size: 14px; }
.contract-values { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.amount { font-weight: 600; font-size: 14px; }
.due-date { font-size: 13px; color: var(--text-muted); }

.empty-state {
    text-align: center; padding: 48px 20px; color: var(--text-muted);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { margin-bottom: 16px; }
.empty-state-sm { padding: 20px 16px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* ─── Client info grid ───────────────────────────────────────── */
.client-info-grid {
    display: flex; flex-wrap: wrap; gap: 16px;
}
.info-item { display: flex; flex-direction: column; gap: 2px; min-width: 160px; }
.info-label { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; }
.info-value { font-size: 14px; }

/* ─── Calc display ───────────────────────────────────────────── */
.calc-display {
    padding: 9px 12px;
    border: 1.5px dashed var(--border);
    border-radius: 7px;
    font-size: 14px; color: var(--text-muted);
    background: #f8fafc;
}
.calc-active { color: var(--success); font-weight: 700; border-color: var(--success); background: #f0fdf4; }

/* ─── Modal ──────────────────────────────────────────────────── */
.modal { display: none; position: fixed; inset: 0; z-index: 500; align-items: center; justify-content: center; }
.modal.active { display: flex; }
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.modal-box {
    position: relative; background: var(--surface);
    border-radius: 12px; width: 90%; max-width: 520px; max-height: 90vh;
    overflow-y: auto; box-shadow: var(--shadow-md); z-index: 1;
}
.modal-header {
    padding: 16px 20px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 20px; }
.modal-footer {
    padding: 14px 20px; border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 8px;
}

/* ─── Calendar ───────────────────────────────────────────────── */
.calendar-nav {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.calendar-nav h3 { font-size: 16px; font-weight: 600; text-transform: capitalize; }

.calendar-grid {
    display: grid; grid-template-columns: repeat(7, 1fr);
    border-left: 1px solid var(--border);
    border-top: 1px solid var(--border);
}
.cal-weekday {
    padding: 8px; text-align: center;
    font-size: 11px; font-weight: 600; color: var(--text-muted);
    background: #f8fafc; border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.cal-day {
    min-height: 80px; padding: 6px;
    border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.cal-empty { background: #fafafa; }
.cal-date { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 3px; }
.cal-today .cal-date { color: var(--primary); font-weight: 700; }
.cal-today { background: #eff6ff; }
.cal-has-events { background: #f0fdf4; }
.cal-overdue { background: #fff5f5; }

.cal-event {
    display: block; font-size: 10px; padding: 2px 4px;
    border-radius: 3px; margin-bottom: 2px; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; text-decoration: none !important;
}
.cal-event-active { background: #bfdbfe; color: #1e40af; }
.cal-event-overdue { background: #fecaca; color: #991b1b; }
.cal-more { font-size: 10px; color: var(--text-muted); }

.cal-legend { display: flex; gap: 16px; padding: 12px 4px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.legend-dot { width: 12px; height: 12px; border-radius: 3px; }
.legend-active  { background: #bfdbfe; }
.legend-overdue { background: #fecaca; }
.legend-today   { background: #eff6ff; border: 1px solid var(--primary); }

/* ─── Filter form ────────────────────────────────────────────── */
.filter-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filter-form .form-group { margin: 0; }

.filter-bar { margin-bottom: 16px; display: flex; flex-wrap: wrap; gap: 8px; }
.filter-group { display: flex; flex-wrap: wrap; gap: 6px; }

/* ─── Status summary ──────────────────────────────────────────── */
.status-summary { display: flex; gap: 20px; flex-wrap: wrap; }
.status-item { display: flex; align-items: center; gap: 8px; }
.status-count { font-size: 24px; font-weight: 700; }

/* ─── Content Grid ───────────────────────────────────────────── */
.content-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ─── Pagination ─────────────────────────────────────────────── */
.pagination-wrapper { margin-top: 16px; display: flex; justify-content: center; }

/* ─── Text utilities ─────────────────────────────────────────── */
.text-muted  { color: var(--text-muted); }
.text-green  { color: var(--success); }
.text-red    { color: var(--danger); }
.text-orange { color: var(--warning); }
.text-purple { color: var(--purple); }
.text-blue   { color: var(--primary); }

/* ─── Visibility helpers ─────────────────────────────────────── */
.hide-on-mobile  { display: block; }
.hide-on-desktop { display: none; }

@media (max-width: 680px) {
    .hide-on-mobile  { display: none !important; }
    .hide-on-desktop { display: flex !important; flex-direction: column; }
}

/* ─── Empty state with FA icon ───────────────────────────────── */
.empty-icon-fa { font-size: 42px; color: #cbd5e1; display: block; margin-bottom: 12px; }

/* ─── Input with icon ────────────────────────────────────────── */
.input-icon { position: relative; }
.input-icon i {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); font-size: 14px; pointer-events: none;
}
.input-icon input { padding-left: 36px; }

/* ─── Login logo ─────────────────────────────────────────────── */
.login-logo {
    width: 64px; height: 64px; margin: 0 auto 14px;
    background: rgba(255,255,255,.12); border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    font-size: 30px; color: #fff;
}
.login-logo i { color: #fff; }

/* ─── Login ──────────────────────────────────────────────────── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-container { width: 100%; max-width: 420px; padding: 20px; }
.login-card {
    background: var(--surface); border-radius: 14px;
    box-shadow: var(--shadow-md); overflow: hidden;
}
.login-header {
    background: #0f172a; color: #fff;
    padding: 32px 32px 24px; text-align: center;
}
.login-logo { font-size: 48px; margin-bottom: 8px; }
.login-header h1 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.login-header p { font-size: 13px; color: #94a3b8; }
.login-form { padding: 28px 32px; }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    .sidebar-close { display: block; }
    .sidebar-toggle { display: block; }
    .main-content { margin-left: 0; }

    /* Colunas menos importantes em telas menores — tabelas normais */
    .hide-mobile { display: none !important; }

    .stats-grid { grid-template-columns: 1fr 1fr; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .content-grid { grid-template-columns: 1fr; }
    .form-grid-2 { grid-template-columns: 1fr; }
    .settings-label { width: 100%; }
    .settings-fields { flex-direction: column; }
    .settings-fields .form-group { min-width: unset; }
    .calendar-grid { font-size: 11px; }
    .cal-day { min-height: 50px; padding: 3px; }
}

@media (max-width: 680px) {
    /* Tabela admin painel */
    .data-table:not(.card-table) { min-width: 500px; }
    .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

@media (max-width: 480px) {
    .page-content { padding: 12px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .stat-card { padding: 12px; gap: 10px; }
    .stat-icon { font-size: 22px; }
    .stat-value { font-size: 18px; }
    .card-body { padding: 14px; }
    .login-form { padding: 20px; }
    .login-header { padding: 24px 20px 20px; }
    .contract-block { padding: 12px; }
    .cal-event { display: none; }
    .cal-has-events .cal-date, .cal-overdue .cal-date { font-weight: 700; }
}

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

/* ─── Pagination ─────────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; justify-content: center; padding: 16px 0; flex-wrap: wrap; }
.page-btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 34px; height: 34px; padding: 0 10px;
    border: 1px solid var(--border); border-radius: 6px;
    font-size: 13px; color: var(--text); text-decoration: none;
    transition: all .15s; background: var(--surface);
}
.page-btn:hover:not(.page-disabled):not(.page-active) {
    border-color: var(--primary); color: var(--primary);
}
.page-active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.page-disabled { color: var(--text-muted); cursor: default; }

/* ─── Danger button ──────────────────────────────────────────── */
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }

/* ─── Filter bar ─────────────────────────────────────────────── */
.filter-toggle { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.geo-filter { display: flex; flex-direction: column; gap: 8px; }
.geo-filter .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.range-label { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* ─── Accordion tabs ─────────────────────────────────────────── */
.acc-tab { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; }
.acc-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 13px 16px; cursor: pointer; background: var(--surface);
    user-select: none; gap: 8px;
}
.acc-header:hover { filter: brightness(.97); }
.acc-header h4 { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; margin: 0; }
.acc-header .badge-count { border-radius: 99px; font-size: 11px; padding: 2px 8px; font-weight: 700; }
.acc-header .acc-toggle { transition: transform .2s; flex-shrink: 0; }
.acc-header.open .acc-toggle { transform: rotate(180deg); }
.acc-body { display: none; border-top: 1px solid var(--border); }
.acc-body.open { display: block; }

/* Colored header variants */
.acc-header-overdue  { background: #fef2f2; color: #b91c1c; border-bottom: 1px solid #fecaca; }
.acc-header-overdue  .badge-count { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.acc-header-overdue  .acc-toggle  { color: #b91c1c; }

.acc-header-today    { background: #fff7ed; color: #c2410c; border-bottom: 1px solid #fed7aa; }
.acc-header-today    .badge-count { background: #ffedd5; color: #c2410c; border: 1px solid #fdba74; }
.acc-header-today    .acc-toggle  { color: #c2410c; }

.acc-header-tomorrow { background: #eff6ff; color: #1d4ed8; border-bottom: 1px solid #bfdbfe; }
.acc-header-tomorrow .badge-count { background: #dbeafe; color: #1d4ed8; border: 1px solid #93c5fd; }
.acc-header-tomorrow .acc-toggle  { color: #1d4ed8; }

.acc-header-active   { background: #f0fdf4; color: #15803d; border-bottom: 1px solid #bbf7d0; }
.acc-header-active   .badge-count { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.acc-header-active   .acc-toggle  { color: #15803d; }

.acc-header-inactive { background: var(--surface); color: var(--text-muted); }
.acc-header-inactive .badge-count { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }
.acc-header-inactive .acc-toggle  { color: var(--text-muted); }
.acc-installment {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
    gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.acc-installment:last-child { border-bottom: none; }
.acc-installment-info { display: flex; flex-direction: column; gap: 2px; }
.acc-installment-info strong { font-size: 14px; }
.acc-installment-info small { font-size: 12px; color: var(--text-muted); }
.acc-installment-actions { display: flex; gap: 6px; align-items: center; }
.whatsapp-btn { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; background: #25d366; color: #fff; border-radius: 6px; font-size: 12px; font-weight: 600; text-decoration: none; transition: background .15s; }
.whatsapp-btn:hover { background: #1ebe5a; }
.whatsapp-btn-disabled { background: #9ca3af !important; cursor: not-allowed; opacity: 0.65; pointer-events: none; }

/* ─── Installment date grid ──────────────────────────────────── */
.installment-dates { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.installment-date-row { display: flex; align-items: center; gap: 10px; }
.installment-date-row label { font-size: 12px; color: var(--text-muted); min-width: 80px; }

/* ─── Map (Leaflet) ──────────────────────────────────────────── */
.map-container { border-radius: var(--radius); overflow: hidden; }
.map-label { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; color: var(--text-muted); }
#map { height: 320px; width: 100%; border-radius: var(--radius); border: 1px solid var(--border); }

/* ─── Font Size Widget ───────────────────────────────────────── */
.font-sizer {
    position: fixed; bottom: 20px; right: 20px; z-index: 900;
    display: flex; align-items: center; gap: 6px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 99px; padding: 5px 12px;
    box-shadow: var(--shadow-md);
}
.font-sizer button {
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); font-size: 12px; padding: 2px 4px;
    transition: color .15s; line-height: 1;
}
.font-sizer button:hover { color: var(--primary); }
.font-size-label { font-size: 12px; font-weight: 600; color: var(--text-muted); min-width: 28px; text-align: center; }

/* ─── KYC Status Bar ─────────────────────────────────────────── */
.kyc-bar {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 12px 16px; background: var(--bg);
    border-radius: var(--radius); margin-bottom: 16px;
    border: 1px solid var(--border);
}
.kyc-bar .kyc-info { flex: 1; min-width: 160px; }
.kyc-bar .kyc-info strong { display: block; font-size: 13px; }
.kyc-bar .kyc-info small { color: var(--text-muted); font-size: 12px; }

/* ─── Document list ──────────────────────────────────────────── */
.doc-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.doc-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; background: var(--bg);
    border-radius: 8px; font-size: 13px;
}
.doc-item i { color: var(--primary); }
.doc-item a { color: var(--primary); font-weight: 500; flex: 1; }
.doc-item span { color: var(--text-muted); font-size: 11px; }
