:root {
    /* --- NEO-SAAS COLOR SYSTEM (Slate & Indigo) --- */

    /* Light Mode */
    --bg-body: #f1f5f9;
    /* Slate 100 - Crisp background */
    --bg-surface: #ffffff;
    /* White cards */
    --bg-sidebar: #ffffff;
    /* White sidebar */
    --bg-header: #ffffff;
    /* White header */

    --text-primary: #0f172a;
    /* Slate 900 - Sharp text */
    --text-secondary: #475569;
    /* Slate 600 - DARKER FOR READABILITY (prev 500) */
    --text-tertiary: #64748b;
    /* Slate 500 */

    --border-color: #cbd5e1;
    /* Slate 300 - More visible borders */
    --border-subtle: #e2e8f0;
    /* Slate 200 */

    --brand-primary: #4f46e5;
    /* Indigo 600 */
    --brand-primary-hover: #4338ca;
    /* Indigo 700 */
    --brand-bg-subtle: #eef2ff;
    /* Indigo 50 */
    --brand-text: #4f46e5;
    /* Indigo 600 */

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 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);

    /* Dimensions */
    --sidebar-width: 260px;
    --sidebar-width-collapsed: 72px;
    --header-height: 70px;
}

/* Dark Mode Overrides */
/* Dark Mode Overrides (Hybrid with Bootstrap) */
[data-bs-theme="dark"] {
    --bg-body: #020617;
    /* Slate 950 */
    --bg-surface: #1e293b;
    /* Slate 800 */
    --bg-sidebar: #0f172a;
    /* Slate 900 */
    --bg-header: #0f172a;
    /* Slate 900 */

    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;

    --border-color: #334155;
    /* Slate 700 */
    --border-subtle: #1e293b;

    --brand-primary: #818cf8;
    --brand-bg-subtle: rgba(99, 102, 241, 0.2);

    /* Bootstrap Overrides */
    --bs-body-bg: var(--bg-body);
    --bs-body-color: var(--text-primary);

    /* Native Bootstrap Dark Mode Card Variables */
    --bs-card-bg: var(--bg-surface);
    --bs-card-border-color: var(--border-color);
    --bs-border-color: var(--border-color);
}

/* ... (Skipping unaffected lines) ... */

/* --- COMPONENT: CARD --- */
/* Minimal overrides, letting Bootstrap handle defaults mostly */
.card {
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
    /* Removed custom background/border to let Bootstrap variables take over */
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background: transparent;
    padding: 1.25rem 1.5rem;
    font-weight: 600;
}

/* --- LAYOUT: HEADER (TOP BAR) --- */
.app-header {
    position: fixed;
    top: 0;
    right: 0;
    left: var(--sidebar-width);
    /* Starts after sidebar */
    height: var(--header-height);
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 50;
    transition: all 0.3s ease;
    backdrop-filter: blur(8px);
    background-color: rgba(var(--bg-header), 0.9);
}

@media (max-width: 991px) {
    .app-header {
        left: 0 !important;
        padding: 0 1rem;
    }
}

.brand-section {
    display: none;
    /* Logo is now in Sidebar or Header starts without it? */
    /* If Sidebar is full height, Logo should be IN Sidebar */
}

/* --- LAYOUT: SIDEBAR --- */
.app-sidebar {
    position: fixed;
    top: 0;
    /* Full Height */
    bottom: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    transition: width 0.15s ease;
    /* Faster transition for stability */
    z-index: 60;
    overflow: hidden;
    /* Remove scroll from main sidebar, keep it in nav-scroll */
    padding: 0;
    scrollbar-width: none;
    display: flex;
    flex-direction: column;
}

/* Sidebar Logo Area */
.sidebar-logo {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.app-sidebar .nav-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 0;
}

/* Navigation Items */
.nav-item {
    padding: 0.25rem 1rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    transition: all 0.2s;
}

.nav-link i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
    color: var(--text-tertiary);
    transition: color 0.2s;
}

.nav-link:hover {
    background-color: var(--bg-body);
    color: var(--text-primary);
}

.nav-link:hover i {
    color: var(--brand-primary);
}

.nav-link.active {
    background-color: var(--brand-bg-subtle);
    color: var(--brand-text);
}

.nav-link.active i {
    color: var(--brand-text);
}

/* Sidebar Group Label */
.nav-label {
    padding: 1.5rem 2rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-tertiary);
}

/* --- LAYOUT: MAIN CONTENT --- */
/* --- LAYOUT: MAIN CONTENT --- */
.app-main {
    margin-left: var(--sidebar-width);
    padding-top: var(--header-height);
    height: 100vh;
    /* Fill screen exactly */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Prevent body scroll relative to this */
    width: auto;
    background-color: var(--bs-body-bg);
}

/* Scrollable Area */
.app-content-scroll {
    overflow-y: auto;
    padding: 1.25rem 1.5rem;
    /* Reduced padding for cleaner look */
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.app-content-scroll::-webkit-scrollbar {
    width: 6px;
}

.app-content-scroll::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 4px;
}

/* Ensure content pushes footer down */
.app-main>.container-fluid {
    /* Legacy override if needed, but flex structure handles it */
    flex: 1;
}

/* --- COLLAPSED STATE (Desktop) --- */
body.sidebar-collapsed .app-sidebar {
    width: var(--sidebar-width-collapsed);
}

body.sidebar-collapsed .app-main {
    margin-left: var(--sidebar-width-collapsed);
}

body.sidebar-collapsed .app-header {
    left: var(--sidebar-width-collapsed);
}

body.sidebar-collapsed .brand-section {
    width: var(--sidebar-width-collapsed);
}

/* Hide text in sidebar when collapsed */
body.sidebar-collapsed .nav-link span,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .dropdown-text {
    opacity: 0;
    width: 0;
    display: none;
}

body.sidebar-collapsed .nav-link {
    justify-content: center;
    padding: 0.75rem 0;
}

body.sidebar-collapsed .nav-item {
    padding: 0.25rem 0.5rem;
}

/* --- ACTION BUTTONS (Header) --- */
.action-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.action-btn:hover {
    background: var(--bg-body);
    color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.notif-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ef4444;
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 0.65rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-header);
    font-weight: 700;
}

/* --- BOOTSTRAP OVERRIDES --- */
.form-control,
.form-select {
    background-color: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    color: var(--bs-body-color);
    padding: 0.6rem 1rem;
    border-radius: 8px;
}

.form-control:focus,
.form-select:focus {
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-bg-subtle);
}

.text-muted {
    color: var(--bs-secondary-color) !important;
}

/* --- MODAL (Logs) --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-window {
    width: 90%;
    max-width: 900px;
    height: 80vh;
    background: var(--bg-surface);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid var(--border-color);
}

.modal-overlay.active .modal-window {
    transform: scale(1);
}

@media (max-width: 991px) {
    .app-sidebar {
        transform: translateX(-100%);
    }

    .app-main {
        margin-left: 0 !important;
    }

    body.mobile-nav-active .app-sidebar {
        transform: translateX(0);
        width: var(--sidebar-width);
    }

    body.mobile-nav-active .app-main {
        filter: blur(4px);
        pointer-events: none;
    }
}

/* --- GLOBAL CALENDAR STYLES (Moved from Dashboard) --- */

/* Dashboard Calendar Premium Styling */
#calendar-card {
    background: var(--bs-card-bg);
    border-radius: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color);
    padding: 1.75rem;
    transition: all 0.3s ease;
    position: relative;
}

#calendar,
#fullCalendar {
    font-family: 'Inter', sans-serif;
    min-height: 400px;
}

/* Clean Borders & Grid */
.fc-scrollgrid {
    border-radius: 12px;
    border: none !important;
    overflow: hidden;
}

.fc-theme-standard td,
.fc-theme-standard th {
    border-color: rgba(0, 0, 0, 0.05) !important;
}

[data-bs-theme="dark"] .fc-theme-standard td,
[data-bs-theme="dark"] .fc-theme-standard th {
    border-color: rgba(255, 255, 255, 0.05) !important;
}

/* Column Headers */
.fc-col-header-cell {
    background: var(--bg-surface);
    padding: 15px 0;
    border-bottom: 2px solid var(--border-color) !important;
}

.fc-col-header-cell-cushion {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 700;
    color: var(--bs-secondary-color) !important;
    opacity: 0.7;
    text-decoration: none !important;
}

/* Day Numbers */
.fc-daygrid-day-number {
    font-size: 0.95rem;
    font-weight: 600;
    padding: 10px 15px !important;
    color: var(--bs-body-color) !important;
    opacity: 0.9;
    text-decoration: none !important;
}

/* Today Highlight */
.fc-day-today {
    background: rgba(99, 102, 241, 0.03) !important;
}

.fc-day-today .fc-daygrid-day-number {
    color: #6366f1 !important;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 35px;
    height: 35px;
    margin: 5px;
    padding: 0 !important;
}

/* Event Styles (Gradient look) */
.event-collection {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    border: none !important;
    box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.2);
}

.event-payment {
    background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%) !important;
    border: none !important;
    box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.2);
}

.fc-event {
    border-radius: 10px !important;
    padding: 4px 8px !important;
    font-size: 0.75rem !important;
    margin: 2px 4px !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.fc-event:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

/* Selected Date Glow */
.fc-day-selected {
    background: rgba(99, 102, 241, 0.05) !important;
    position: relative;
}

.fc-day-selected::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: #6366f1;
    box-shadow: 0 -2px 10px rgba(99, 102, 241, 0.5);
}

/* Buttons & Toolbar Refinement */
.fc-toolbar-title {
    font-size: 1.15rem !important;
    font-weight: 700;
    color: var(--bs-body-color) !important;
    letter-spacing: -0.5px;
}

.fc-button {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--bs-body-color) !important;
    padding: 8px 16px !important;
    font-weight: 600 !important;
    font-size: 0.8rem !important;
    border-radius: 12px !important;
    transition: all 0.2s ease !important;
}

.fc-button:hover:not(:disabled) {
    background: var(--border-color) !important;
    border-color: var(--border-color) !important;
}

/* Event Status Variations */
.fc-event.event-completed {
    font-weight: 700 !important;
    opacity: 1 !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
}

.fc-event.event-pending {
    opacity: 0.5 !important;
    border: 1px dashed rgba(0, 0, 0, 0.3) !important;
    filter: saturate(0.8);
}

.fc-event.event-overdue {
    font-weight: 800 !important;
    box-shadow: 0 0 10px rgba(243, 156, 18, 0.4) !important;
    border: 2px solid #fff !important;
}

[data-bs-theme="dark"] .fc-event.event-overdue {
    border-color: #333 !important;
}

/* Daily Summary Indicator in Day Cell */
.day-finance-summary {
    font-size: 0.65rem;
    padding: 2px 4px;
    border-radius: 4px;
    margin-top: 2px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: rgba(0, 0, 0, 0.02);
}

[data-bs-theme="dark"] .day-finance-summary {
    background: rgba(255, 255, 255, 0.02);
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.summary-realized {
    color: #27ae60;
    font-weight: 700;
}

.summary-expected {
    color: rgba(39, 174, 96, 1);
}

.summary-payment {
    color: rgba(231, 76, 60, 1);
    font-weight: 500;
}

.fc-button-active {
    background: #6366f1 !important;
    border-color: #6366f1 !important;
    color: white !important;
}

/* Full Screen Button */
.btn-fullscreen {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 50px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-fullscreen:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 15px rgba(79, 70, 229, 0.4);
    color: white;
}

/* Premium Modal Styling */
.modal-backdrop {
    background-color: rgba(15, 23, 42, 0.5) !important;
    backdrop-filter: blur(12px) !important;
    /* Enable Blur */
    -webkit-backdrop-filter: blur(12px) !important;
    z-index: 1050;
}

.modal {
    z-index: 1060;
}

/* Custom Centered Modal */
.modal-premium-dialog {
    max-width: 1600px;
    /* Limit width on large screens */
    width: 95vw;
    height: 90vh;
    margin: auto;
    /* Center vertically/horizontally */
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-premium-content {
    width: 100%;
    height: 100%;
    border-radius: 24px;
    background: var(--bs-body-bg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    /* Deep shadow */
    border: 1px solid rgba(255, 255, 255, 0.05);
    /* Subtle border for glass feel */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 1070;
}

/* Dark mode border adjustment */
[data-bs-theme="dark"] .modal-premium-content {
    border-color: rgba(255, 255, 255, 0.1);
}

.modal-premium-header {
    background: var(--bg-surface);
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-premium-body {
    flex: 1;
    display: flex;
    overflow: hidden;
    background: var(--bg-body);
    position: relative;
}

/* Sidebar in Modal */
.analytics-sidebar {
    width: 320px;
    background: var(--bs-card-bg);
    /* Use card bg for sidebar contrast */
    border-right: 1px solid var(--border-color);
    padding: 2rem;
    overflow-y: auto;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.calendar-area {
    flex: 1;
    padding: 2rem;
    overflow: hidden;
}

/* Analytics Cards in Sidebar */
.analytics-card {
    padding: 1.25rem;
    border-radius: 16px;
    background: var(--bs-body-bg);
    border: 1px solid var(--border-color);
    transition: transform 0.2s;
}

.analytics-card.inactive {
    opacity: 0.5;
    filter: grayscale(1);
}

.analytics-title {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
}

.analytics-amount {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

@media (max-width: 991px) {
    .modal-premium-body {
        flex-direction: column;
    }

    .analytics-sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 1rem;
        flex-direction: row;
        overflow-x: auto;
    }

    .calendar-area {
        padding: 1rem;
    }

    .analytics-card {
        min-width: 200px;
    }
}

/* --- GUEST MODE (Blur Effect) --- */
.guest-blurred {
    filter: blur(5px);
    pointer-events: none;
    /* Disable clicking */
    user-select: none;
    /* Disable selection */
    opacity: 0.6;
    /* Dim it slightly */
    transition: all 0.5s ease;
}

.guest-blurred * {
    pointer-events: none !important;
}

/* --- UTILITIES --- */
.glass-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    border-radius: 16px;
    position: relative;
    background-color: var(--bs-card-bg, #fff);
    transition: all 0.3s ease;
}

/* Ensure table inside glass-card without padding goes full width */
.glass-card .table-responsive {
    border-radius: 16px;
}

.glass-card .table {
    margin-bottom: 0;
}

.glass-card .table th:first-child,
.glass-card .table td:first-child {
    padding-left: 1.5rem;
}

.glass-card .table th:last-child,
.glass-card .table td:last-child {
    padding-right: 1.5rem;
}

/* --- COMPONENT: SWEETALERT2 PREMIUM --- */
.premium-swal-container {
    backdrop-filter: blur(8px) !important;
    background-color: rgba(0, 0, 0, 0.4) !important;
    z-index: 10000 !important;
}

.premium-swal-popup {
    border-radius: 24px !important;
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5) !important;
    padding: 2.5rem !important;
    font-family: 'Inter', sans-serif !important;
}

[data-bs-theme="dark"] .premium-swal-popup {
    background: var(--bg-sidebar) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

.premium-swal-title {
    color: var(--text-primary) !important;
    font-weight: 700 !important;
    font-size: 1.5rem !important;
    margin-bottom: 0.75rem !important;
}

.premium-swal-html {
    color: var(--text-secondary) !important;
    font-size: 1rem !important;
    line-height: 1.6 !important;
}

.premium-confirm-btn {
    border-radius: 12px !important;
    padding: 12px 28px !important;
    font-weight: 600 !important;
    font-size: 0.95rem !important;
    transition: all 0.2s !important;
    margin: 5px !important;
}

.premium-cancel-btn {
    border-radius: 12px !important;
    padding: 12px 28px !important;
    font-weight: 600 !important;
    font-size: 0.95rem !important;
    transition: all 0.2s !important;
    background-color: var(--bg-body) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-color) !important;
    margin: 5px !important;
}

.premium-cancel-btn:hover {
    background-color: var(--border-subtle) !important;
}