:root {
    --bg-navy: #090e1a;
    --sidebar-bg: #0d1527;
    --card-bg: rgba(15, 23, 42, 0.75);
    --card-border: rgba(0, 210, 255, 0.18);
    --primary-cyan: #00D2FF;
    --primary-blue: #0072FF;
    --primary-cobalt: #0059FF;
    --accent-orange: #FF6B00;
    --accent-gold: #FF8C00;
    --text-white: #f8fafc;
    --text-muted: #94a3b8;
    --success-green: #10b981;
    --danger-red: #ef4444;
    --warning-yellow: #f59e0b;
    --font-main: 'Outfit', 'Poppins', -apple-system, sans-serif;
    
    --grad-primary: linear-gradient(135deg, #00D2FF 0%, #0072FF 50%, #0047FF 100%);
    --grad-orange: linear-gradient(135deg, #FF4500 0%, #FF8C00 50%, #FFC700 100%);
    --grad-brand: linear-gradient(135deg, #00D2FF 0%, #0059FF 50%, #FF6B00 100%);
    --grad-text: linear-gradient(135deg, #FFFFFF 30%, #00D2FF 70%, #FF8C00 100%);
    --grad-card: linear-gradient(145deg, rgba(13, 21, 39, 0.85) 0%, rgba(20, 31, 56, 0.7) 100%);
    --shadow-glow: 0 4px 20px -2px rgba(0, 210, 255, 0.35);
    --shadow-orange: 0 4px 20px -2px rgba(255, 107, 0, 0.35);
}

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

body {
    font-family: var(--font-main);
    background: radial-gradient(circle at 10% 20%, #0c1833 0%, #060b17 90%);
    background-attachment: fixed;
    color: var(--text-white);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #00D2FF 0%, #FF6B00 100%);
    border-radius: 4px;
}

/* Sidebar */
.sas-sidebar {
    width: 290px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    flex-shrink: 0;
    backdrop-filter: blur(12px);
}

.sas-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
    padding: 8px 12px;
    background: rgba(0, 210, 255, 0.05);
    border: 1px solid rgba(0, 210, 255, 0.15);
    border-radius: 12px;
}

.sas-brand img {
    max-height: 38px;
    max-width: 130px;
    object-fit: contain;
}

.sas-brand-title {
    font-size: 1.2rem;
    font-weight: 800;
    background: var(--grad-text);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.sas-brand-badge {
    background: var(--grad-orange);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 6px;
    text-transform: uppercase;
    box-shadow: 0 2px 8px rgba(255, 107, 0, 0.4);
}

.sas-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.sas-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    border: 1px solid transparent;
}

.sas-nav-item:hover {
    background: rgba(0, 210, 255, 0.08);
    color: var(--text-white);
    border-color: rgba(0, 210, 255, 0.2);
    transform: translateX(4px);
}

.sas-nav-item.active {
    background: var(--grad-brand);
    color: var(--text-white);
    font-weight: 700;
    box-shadow: var(--shadow-glow);
    border: none;
}

.sas-user-info {
    border-top: 1px solid var(--card-border);
    padding-top: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sas-user-details h4 {
    font-size: 0.9rem;
    font-weight: 600;
}

.sas-user-details p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Main Content */
.sas-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sas-header {
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--card-border);
    padding: 20px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sas-header-title {
    font-size: 1.5rem;
    font-weight: 700;
}

.sas-header-actions {
    display: flex;
    gap: 12px;
}

.sas-content {
    padding: 32px;
}

/* KPI Grid - 30 KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.kpi-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary-cobalt);
}

.kpi-card.accent-orange::before { background: var(--accent-orange); }
.kpi-card.accent-green::before { background: var(--success-green); }
.kpi-card.accent-red::before { background: var(--danger-red); }
.kpi-card.accent-yellow::before { background: var(--warning-yellow); }

.kpi-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-white);
    margin-bottom: 4px;
}

.kpi-subtext {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Charts Section */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 32px;
}

.chart-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 24px;
}

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

.chart-title {
    font-size: 1.1rem;
    font-weight: 600;
}

canvas.sas-chart {
    width: 100% !important;
    height: 260px !important;
}

/* Tables */
.table-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 32px;
    overflow-x: auto;
}

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

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

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

.sas-table th {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
}

.sas-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.badge {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.badge-success {
    background: #16a34a !important;
    color: #ffffff !important;
    border: 1px solid #22c55e !important;
    box-shadow: 0 0 8px rgba(22, 163, 74, 0.4);
}

.badge-danger {
    background: #dc2626 !important;
    color: #ffffff !important;
    border: 1px solid #ef4444 !important;
    box-shadow: 0 0 8px rgba(220, 38, 38, 0.4);
}

.badge-warning {
    background: #d97706 !important;
    color: #ffffff !important;
    border: 1px solid #f59e0b !important;
    box-shadow: 0 0 8px rgba(217, 119, 6, 0.4);
}

.badge-info {
    background: #2563eb !important;
    color: #ffffff !important;
    border: 1px solid #60a5fa !important;
}

/* Buttons & Inputs */
.btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

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

.btn-primary {
    background: var(--accent-blue);
    color: #ffffff;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-secondary.active, .main-fin-filter.active {
    background: var(--accent-blue) !important;
    color: #ffffff !important;
    border-color: #60a5fa !important;
    box-shadow: 0 0 10px rgba(37, 99, 235, 0.5);
}

.btn-success {
    background: #16a34a !important;
    color: #ffffff !important;
}

.btn-warning {
    background: #d97706 !important;
    color: #ffffff !important;
}

.btn-danger {
    background: #dc2626 !important;
    color: #ffffff !important;
}

.sas-input, .sas-select {
    width: 100%;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.sas-input:focus, .sas-select:focus {
    border-color: var(--accent-blue);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 99999;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    width: 600px;
    max-width: 95vw;
    padding: 24px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7);
}

/* Force User Finance Modal to be wide, clear and high contrast */
#user-finance-modal .modal-card,
.modal-card.modal-finance-wide {
    width: 95vw !important;
    max-width: 1350px !important;
    max-height: 92vh !important;
    padding: 28px !important;
    background: #0f172a !important;
    border: 2px solid #334155 !important;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.85) !important;
}

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

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: #f8fafc;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* ========================================================
   RESPONSIVE & MOBILE STYLES (SAS & FINANCE MODAL)
   ======================================================== */
.desktop-only-table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.mobile-only-cards {
    display: none;
}

.sas-tabs-scroll {
    display: flex;
    gap: 8px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
    align-items: center;
}

.sas-invoice-card {
    background: #111c35;
    border: 1px solid rgba(0, 210, 255, 0.2);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.sas-invoice-card:hover {
    border-color: rgba(0, 210, 255, 0.45);
}

@media (max-width: 768px) {
    .desktop-only-table {
        display: none !important;
    }
    
    .mobile-only-cards {
        display: flex !important;
        flex-direction: column;
        gap: 10px;
    }

    #user-finance-modal .modal-card,
    .modal-card.modal-finance-wide {
        width: 98vw !important;
        max-width: 100% !important;
        padding: 14px 10px !important;
        border-radius: 12px !important;
        max-height: 95vh !important;
        margin: 0 auto !important;
    }

    .modal-header h3 {
        font-size: 1.02rem !important;
    }

    .sas-tabs-scroll {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        padding-bottom: 8px !important;
        gap: 6px !important;
        -webkit-overflow-scrolling: touch;
    }

    .sas-tabs-scroll button {
        flex-shrink: 0 !important;
        font-size: 0.78rem !important;
        padding: 6px 10px !important;
    }

    .sas-modal-kpi-grid {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    .sas-main {
        padding: 12px !important;
    }

    .sas-table {
        font-size: 0.8rem !important;
    }

    .modal-footer {
        flex-direction: column !important;
        gap: 8px !important;
    }

    .modal-footer button {
        width: 100% !important;
    }
}

@media (max-width: 900px) {
    .mobile-only-inline {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
    }

    .sas-sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        height: 100vh !important;
        z-index: 100000 !important;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 0 25px rgba(0, 0, 0, 0.85);
        background: #090e1a !important;
    }

    .sas-sidebar.mobile-open {
        transform: translateX(0) !important;
    }

    .sas-main {
        width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
        flex: 1 !important;
    }

    .sas-header-title {
        font-size: 1.15rem !important;
    }
}

/* Filiais Modal Card & Grid Styles */
.filiais-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 14px;
    margin-top: 14px;
}
@media (max-width: 600px) {
    .filiais-grid {
        grid-template-columns: 1fr !important;
    }
}
.filial-card {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(0, 210, 255, 0.2);
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.2s ease;
}
.filial-card:hover {
    border-color: rgba(0, 210, 255, 0.5);
    box-shadow: 0 4px 16px rgba(0, 210, 255, 0.15);
    transform: translateY(-2px);
}
.filial-card.inadimplente {
    border-left: 4px solid #ef4444;
}
.filial-card.em-dia {
    border-left: 4px solid #10b981;
}




button.kpi-card{text-align:left;font:inherit;color:inherit;cursor:pointer;width:100%}button.kpi-card:hover,button.kpi-card:focus-visible{outline:2px solid #53d9db;outline-offset:2px}.bi-details{box-sizing:border-box;width:min(1000px,94vw);max-height:88vh;border:1px solid #375468;border-radius:18px;background:#101f30;color:#e3efff;padding:24px}.bi-details::backdrop{background:#000a}.bi-details h2{font-size:20px;overflow-wrap:anywhere}.bi-details-scroll{overflow:auto}.bi-details table{border-collapse:collapse;width:100%;font-size:14px}.bi-details td,.bi-details th{padding:12px;text-align:left;border-bottom:1px solid #375468;max-width:280px;overflow-wrap:anywhere}.bi-details button{padding:10px 18px;margin:6px;border:1px solid #375468;border-radius:8px;background:#1a3549;color:white}#bi-data-origin{color:#9dc6dd;padding:0 4px}
