:root {
    --primary: #1A365D; /* Navy Blue */
    --primary-light: #2B6CB0; /* Light Blue */
    --secondary: #4A5568; /* Grey */
    --background: #F7FAFC; /* White/Grey */
    --surface: #FFFFFF;
    --text-main: #2D3748;
    --text-muted: #718096;
    --border: #E2E8F0;
    
    --success: #38A169;
    --warning: #DD6B20;
    --danger: #E53E3E;
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.05);
    
    --radius-md: 8px;
    --radius-lg: 12px;
}

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

body {
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.5;
}

/* Authentication Overlay */
#auth-overlay, #user-detail-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(26, 54, 93, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(10px);
}

#auth-overlay.hidden, #user-detail-overlay.hidden {
    display: none !important;
}

.auth-modal {
    background: var(--surface);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.auth-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
}

.auth-modal h2 {
    color: var(--primary);
    margin-bottom: 8px;
}

.auth-modal p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

.auth-modal input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.auth-modal input:focus {
    border-color: var(--primary-light);
}

.auth-modal button {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.auth-modal button:hover {
    background: var(--primary-light);
}

.error-text {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 12px;
    height: 20px;
}

/* App Layout */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

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

.sidebar-logo {
    width: 40px;
    height: 40px;
}

.brand h1 {
    font-size: 1.1rem;
    color: var(--primary);
    font-weight: 700;
}

.brand span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.sidebar-nav {
    padding: 24px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--secondary);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    font-size: 1rem;
}

.nav-item i {
    width: 20px;
    text-align: center;
}

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

.nav-item.active {
    background: var(--primary);
    color: white;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.text-danger {
    color: var(--danger) !important;
}

.text-danger:hover {
    background: #FFF5F5 !important;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 32px;
    background: var(--background);
}

/* Topbar */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.topbar-left h2 {
    color: var(--primary);
    font-weight: 600;
}

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

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(56, 161, 105, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(56, 161, 105, 0); }
    100% { box-shadow: 0 0 0 0 rgba(56, 161, 105, 0); }
}

.btn-primary {
    background: var(--primary-light);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

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

.icon-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--secondary);
    cursor: pointer;
    transition: all 0.2s;
}

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

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 16px;
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

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

.bg-blue-light { background: #EBF8FF; }
.text-blue { color: #3182CE; }
.bg-green-light { background: #F0FFF4; }
.text-green { color: #38A169; }
.bg-orange-light { background: #FFFAF0; }
.text-orange { color: #DD6B20; }
.bg-purple-light { background: #FAF5FF; }
.text-purple { color: #805AD5; }

.stat-details {
    display: flex;
    flex-direction: column;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

.stat-value {
    color: var(--primary);
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 4px;
}

/* Tab Content */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Tables */
.table-container {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
}

.mt-4 { margin-top: 24px; }

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

.table-header h3 {
    color: var(--primary);
    font-size: 1.1rem;
    font-weight: 600;
}

.search-box {
    position: relative;
    width: 300px;
}

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

.search-box input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.9rem;
    outline: none;
    background: var(--background);
    transition: border-color 0.2s;
}

.search-box input:focus {
    border-color: var(--primary-light);
    background: var(--surface);
}

.table-responsive {
    overflow-x: auto;
}

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

th {
    background: var(--background);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 24px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
    font-size: 0.9rem;
    vertical-align: middle;
}

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

tr:hover td {
    background: #F8FAFC;
}

/* User Cell */
.user-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-light);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    color: var(--primary);
}

.user-company {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Badges */
.badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-green { background: #F0FFF4; color: #38A169; }
.badge-blue { background: #EBF8FF; color: #3182CE; }

.health-score {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.85rem;
}

/* Download Button */
.btn-download {
    background: transparent;
    color: var(--primary-light);
    border: 1px solid var(--primary-light);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-download:hover {
    background: var(--primary-light);
    color: white;
}

.text-center { text-align: center; }
.loading-text { color: var(--text-muted); font-style: italic; }

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--primary);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 1000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* Mobile Responsiveness */
.mobile-only {
    display: none;
}

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

@media (max-width: 768px) {
    .app-container {
        position: relative;
    }
    
    .sidebar {
        position: absolute;
        left: -260px;
        height: 100%;
        transition: left 0.3s ease;
        box-shadow: var(--shadow-lg);
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .mobile-only {
        display: flex;
    }
    
    .topbar-left {
        display: flex;
        align-items: center;
        gap: 12px;
    }
    
    .main-content {
        padding: 16px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .topbar-right {
        width: 100%;
        justify-content: space-between;
    }
    
    .table-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .search-box {
        width: 100%;
    }
}

/* User Detail Modal */
.user-modal-card {
    background: var(--surface);
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: slideUp 0.3s ease-out;
}

.hidden {
    display: none !important;
}


/* --- User Detail Modal Styles --- */
#user-detail-overlay {
    z-index: 1000;
}

.user-modal-card {
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--surface);
    padding: 30px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    position: relative;
}

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

.modal-header h2 {
    margin: 0;
}

#close-modal-btn {
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0 10px;
}

#close-modal-btn:hover {
    color: var(--text-color);
}

.user-profile-section {
    display: flex;
    gap: 20px;
    padding: 20px;
    background: var(--background);
    border-radius: 12px;
    margin-bottom: 24px;
    align-items: center;
}

#modal-user-avatar {
    width: 80px;
    height: 80px;
    font-size: 2rem;
    flex-shrink: 0;
}

.user-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    flex-grow: 1;
}

.detail-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.detail-value {
    color: var(--text-color);
    word-break: break-word;
}

#modal-user-name {
    font-weight: 600;
    font-size: 1.1rem;
}

#modal-user-company {
    font-weight: 500;
}

#modal-user-wallet {
    font-weight: 600;
    color: var(--success);
    font-size: 1.1rem;
}

.modal-table-container {
    box-shadow: none;
    border: 1px solid var(--border);
    margin-top: 10px;
}

/* Mobile Responsiveness for Modal */
@media (max-width: 768px) {
    .user-modal-card {
        width: 95%;
        padding: 20px 15px;
    }
    
    .user-profile-section {
        flex-direction: column;
        text-align: center;
        gap: 15px;
        padding: 15px;
    }
    
    .user-details-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    #modal-user-avatar {
        margin: 0 auto;
    }
}

