:root {
    --bg-color: #FDFCF0; /* Ivory / Off-white */
    --sidebar-bg: #002147; /* Deep Navy */
    --sidebar-hover: #003366;
    --sidebar-text: #E5E7EB;
    --sidebar-active: #C5A021; /* Rich Gold */
    
    --card-bg: #ffffff;
    --text-main: #002147;
    --text-muted: #64748b;
    
    --primary: #002147;
    --primary-hover: #003366;
    --accent: #C5A021;
    
    --success: #106b4d;
    --danger: #b91c1c;
    --warning: #d97706;
    
    --border: #e2e8f0;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px -2px rgba(0, 33, 71, 0.08);
    --shadow-lg: 0 12px 24px -4px rgba(0, 33, 71, 0.12);
    
    --radius-md: 10px;
    --radius-lg: 16px;
    
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    height: 100vh;
    margin: 0;
    overflow: hidden;
    background-image: radial-gradient(circle at 50% 50%, #ffffff 0%, #fdfcf0 100%);
}

h1, h2, h3, h4, .logo {
    font-family: 'Inter', sans-serif;
    letter-spacing: -0.02em;
}

/* Sidebar Root (Component Container) */
#sidebar-root {
    display: contents;
}

/* Sidebar */
.sidebar {
    width: 280px;
    height: 100vh;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    overflow: hidden;
}

.logo {
    padding: 32px 24px;
    font-size: 22px;
    font-weight: 800;
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.logo i {
    color: var(--sidebar-active);
    filter: drop-shadow(0 0 8px rgba(197, 160, 33, 0.4));
}

.nav-links {
    flex: 1;
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    min-height: 0; /* Ensures flex child can shrink to allow scrolling */
}

/* Custom Scrollbar for Sidebar */
.nav-links::-webkit-scrollbar {
    width: 8px; /* Increased from 5px for better visibility */
}
.nav-links::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}
.nav-links::-webkit-scrollbar-thumb {
    background: rgba(197, 160, 33, 0.3); /* Gold tint to match theme */
    border-radius: 10px;
    border: 2px solid var(--sidebar-bg); /* Padding effect */
}
.nav-links::-webkit-scrollbar-thumb:hover {
    background: var(--sidebar-active);
}
.nav-links:focus {
    outline: none; /* Remove focus ring but keep keyboard support */
}

.nav-links a {
    text-decoration: none;
    color: rgba(255, 255, 255, 0.6);
    padding: 14px 28px;
    display: flex;
    align-items: center;
    gap: 14px;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.25s ease;
    border-left: 4px solid transparent;
}

.nav-links a:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: white;
}

.nav-links a.active {
    background-color: rgba(197, 160, 33, 0.1);
    color: var(--sidebar-active);
    border-left: 4px solid var(--sidebar-active);
}

.nav-links a i {
    width: 20px;
    font-size: 18px;
    text-align: center;
}

.user-profile {
    padding: 24px;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-profile img {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 2px solid var(--sidebar-active);
}

.user-profile p {
    color: white;
    font-weight: 700;
    font-size: 14px;
}
.user-profile small {
    color: rgba(255, 255, 255, 0.5);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

.topbar {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    padding: 18px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--sidebar-bg);
}

.page-header, .page-content {
    padding: 0 40px;
}

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

.page-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--sidebar-bg);
}

.global-search {
    position: relative;
    width: 350px;
}

.global-search i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.global-search input {
    width: 100%;
    padding: 12px 18px 12px 46px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 14px;
    background: #ffffff;
    transition: all 0.3s ease;
}

.global-search input:focus {
    outline: none;
    border-color: var(--sidebar-active);
    box-shadow: 0 0 0 3px rgba(197, 160, 33, 0.1);
}

/* Cards & Stats */
.dashboard-cards {
    padding: 40px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 30px;
}

.card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 30px;
    border: 1px solid rgba(0, 33, 71, 0.05);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #f1f5f9;
}

.card-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--sidebar-bg);
}

.stat-card {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.clients-icon { background: rgba(0, 33, 71, 0.08); color: var(--sidebar-bg); }
.cases-icon { background: rgba(197, 160, 33, 0.1); color: var(--sidebar-active); }
.inv-icon { background: rgba(16, 107, 77, 0.08); color: var(--success); }

.stat-info h3 {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-info h2 {
    font-size: 32px;
    font-weight: 800;
    margin-top: 5px;
    color: var(--sidebar-bg);
}

.dashboard-grid {
    padding: 0 40px 40px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
}

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

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

/* Chart Containers */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--sidebar-bg);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--sidebar-bg);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 33, 71, 0.15);
}

.btn-primary:hover {
    background: #003366;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 33, 71, 0.25);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary-action {
    background: linear-gradient(135deg, var(--sidebar-active) 0%, #a3841a 100%);
    color: var(--sidebar-bg);
    font-weight: 700;
    padding: 12px 28px;
    border-radius: 30px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 15px rgba(197, 160, 33, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary-action:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 25px rgba(197, 160, 33, 0.45);
    background: linear-gradient(135deg, #d4af37 0%, var(--sidebar-active) 100%);
}

.btn-primary-action:active {
    transform: translateY(-1px);
}

.btn-primary-action i {
    font-size: 18px;
}

/* Modernized Settings Layout */
.settings-layout {
    display: flex;
    gap: 30px;
    margin-top: 20px;
    align-items: flex-start;
}

.settings-sidebar {
    width: 280px;
    background: white;
    padding: 15px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 100px;
}

.settings-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #64748b;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.2s;
    cursor: pointer;
    border: 1px solid transparent;
    margin-bottom: 5px;
}

.settings-nav-item:hover {
    background: #f8fafc;
    color: var(--primary);
}

.settings-nav-item.active {
    background: rgba(0, 33, 71, 0.05);
    color: var(--sidebar-bg);
    font-weight: 700;
    border: 1px solid rgba(0, 33, 71, 0.1);
}

.settings-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.settings-section-card {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    display: none; /* Hidden by default, shown when active */
}

.settings-active {
    display: block !important;
}

.settings-section-header {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f1f5f9;
}

.settings-section-header h2 {
    font-size: 20px;
    color: var(--sidebar-bg);
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-primary { background: var(--sidebar-bg); }
.btn-accent { background: var(--sidebar-active); color: var(--sidebar-bg); }
.btn-accent:hover { background: #d4af37; color: white; }

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

.btn-outline {
    background: transparent;
    color: var(--sidebar-bg);
    border: 1.5px solid var(--sidebar-bg);
}

.btn-outline:hover {
    background: var(--sidebar-bg);
    color: white;
}

/* Tables */
.table-container {
    overflow-x: auto;
    border-radius: 12px;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th {
    text-align: left;
    padding: 16px 20px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 700;
    background: #f8fafc;
    border-bottom: 2px solid var(--border);
}

td {
    padding: 20px;
    font-size: 14px;
    color: var(--text-main);
    border-bottom: 1px solid var(--border);
}

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

tbody tr:hover {
    background-color: #fcfcf3;
}

.badge {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.bg-paid { background: #dcfce3; color: #166534; }
.bg-unpaid { background: #fee2e2; color: #991b1b; }
.bg-pending { background: #fef3c7; color: #92400e; }
.bg-open { background: #e0f2fe; color: #075985; }

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 33, 71, 0.7);
    backdrop-filter: blur(8px);
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-content {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    padding: 40px;
    width: 100%;
    max-width: 650px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.close-modal {
    position: absolute;
    right: 24px;
    top: 24px;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
}

.close-modal:hover {
    color: var(--danger);
}

.modal-content h2 {
    color: var(--sidebar-bg);
    margin-bottom: 24px;
    font-size: 24px;
    font-weight: 700;
}

/* Forms */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

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

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    border-radius: 10px;
    padding: 12px 16px;
    border: 1.5px solid #e2e8f0;
    font-size: 14px;
    color: var(--text-main);
    background: #f8fafc;
    transition: all 0.3s ease;
}

.form-control:focus {
    background: white;
    border-color: var(--sidebar-active);
    outline: none;
    box-shadow: 0 0 0 4px rgba(197, 160, 33, 0.08);
}

/* Utility */
.z-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: -285px !important;
        top: 0;
        z-index: 2000;
        box-shadow: 10px 0 30px rgba(0,0,0,0.3);
    }
    
    .sidebar.active {
        left: 0 !important;
    }
    
    .main-content {
        padding: 20px;
        width: 100vw !important;
        flex: none;
        margin-left: 0 !important;
    }
    
    .menu-toggle {
        display: flex;
    }
    
    .sidebar.active .mobile-close {
        display: block !important;
    }
    
    .topbar {
        padding-top: 10px;
    }
    
    .topbar h1 {
        font-size: 20px;
    }
    
    .dashboard-cards {
        grid-template-columns: 1fr;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .global-search {
        display: none;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .card-header .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 15px;
    }
    
    .topbar h1 {
        font-size: 18px;
    }
}
