:root {
    /* Brand Colors (Indigo-based, like the reference SaaS) */
    --primary: #6366f1;       /* Indigo 500 */
    --primary-dark: #4f46e5;  /* Indigo 600 */
    --primary-light: #e0e7ff; /* Indigo 100 */
    
    /* Neutrals */
    --white: #ffffff;
    --background: #f8fafc;    /* Very light gray-blue for body */
    --surface: #ffffff;
    
    /* Text Colors */
    --text-primary: #111827;  /* Gray 900 */
    --text-secondary: #6b7280;/* Gray 500 */
    --text-muted: #9ca3af;    /* Gray 400 */
    
    /* UI Elements */
    --border: #e5e7eb;        /* Gray 200 */
    --border-light: #f3f4f6;  /* Gray 100 */
    
    /* Status Colors */
    --danger: #ef4444;
    --success: #10b981;
    --success-light: #d1fae5;
    --success-text: #065f46;
    --warning: #f59e0b;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    
    /* Radius */
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 600;
}

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

/* Sidebar (White, Clean, SaaS style) */
.sidebar {
    width: 260px;
    background-color: var(--white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    z-index: 1000;
}

.sidebar-brand {
    padding: 24px 24px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.sidebar-brand i {
    font-size: 1.4rem;
}

.nav-section-title {
    padding: 16px 24px 8px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    color: var(--text-muted);
}

.sidebar .nav-link {
    color: var(--text-secondary);
    padding: 10px 24px;
    margin: 4px 16px;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
}

.sidebar .nav-link:hover {
    color: var(--text-primary);
    background-color: var(--border-light);
}

.sidebar .nav-link.active {
    color: var(--primary-dark);
    background-color: var(--primary-light);
    font-weight: 600;
}

.sidebar .nav-link i {
    font-size: 1.1rem;
    opacity: 0.8;
}

.sidebar .nav-link.active i {
    opacity: 1;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Topbar */
.topbar {
    background-color: var(--white);
    height: 70px;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 900;
}

.page-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.1rem;
    margin: 0;
}

/* Global Search / Project Selector in Topbar */
#project-selector-wrapper select {
    border-radius: 20px;
    border: 1px solid var(--border);
    padding: 6px 36px 6px 16px;
    font-size: 0.85rem;
    background-color: var(--border-light);
    color: var(--text-secondary);
    font-weight: 500;
}
#project-selector-wrapper select:focus {
    background-color: var(--white);
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

/* Status Indicator */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--border-light);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.status-dot.online { background-color: var(--success); }
.status-dot.offline { background-color: var(--text-muted); }

/* User Profile */
.btn-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 12px 4px 4px;
    border-radius: 30px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-primary);
    font-weight: 500;
    transition: background 0.2s;
}

.btn-profile:hover {
    background: var(--border-light);
}

.avatar-circle {
    width: 32px;
    height: 32px;
    background-color: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 600;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-profile::after { display: none; }

/* Content Area */
.content-area {
    padding: 32px;
    flex: 1;
}

/* Cards */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    background: var(--surface);
    margin-bottom: 24px;
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--border);
    padding: 20px 24px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.card-body {
    padding: 24px;
}

/* Tabs (SaaS Style) */
.nav-tabs {
    border-bottom: 1px solid var(--border);
    gap: 24px;
}
.nav-tabs .nav-link {
    border: none !important;
    border-bottom: 2px solid transparent !important;
    color: var(--text-secondary) !important;
    font-weight: 500;
    padding: 12px 0 !important;
    background: transparent !important;
    margin-bottom: -1px;
}
.nav-tabs .nav-link:hover {
    color: var(--text-primary) !important;
}
.nav-tabs .nav-link.active {
    color: var(--primary-dark) !important;
    border-bottom-color: var(--primary-dark) !important;
    font-weight: 600;
}

/* Forms */
.custom-input {
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    padding: 0.6rem 1rem;
    background-color: var(--white);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.2s;
}

.custom-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
    outline: none;
}

.form-label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 6px;
}

/* Buttons */
.btn {
    border-radius: var(--radius-md);
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
    color: var(--white);
}
.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}
.btn-outline-primary:hover {
    background-color: var(--primary-light);
    border-color: var(--primary-light);
    color: var(--primary-dark);
}

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

/* Tables */
.table-responsive {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.table {
    margin-bottom: 0;
}

.table th {
    background-color: var(--background);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 16px 20px;
    vertical-align: middle;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
    font-size: 0.95rem;
}
.table tbody tr:hover td {
    background-color: var(--background);
}

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

.bg-soft-success { background-color: var(--success-light); color: var(--success-text); }
.bg-soft-warning { background-color: #fef3c7; color: #92400e; }
.bg-soft-danger { background-color: #fee2e2; color: #991b1b; }
.bg-soft-secondary { background-color: var(--border-light); color: var(--text-secondary); }
.bg-soft-primary { background-color: var(--primary-light); color: var(--primary-dark); }

/* Dashboard Stat Cards */
.stat-card {
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 24px;
    background: var(--white);
    display: flex;
    flex-direction: column;
}
.stat-card-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 12px;
}
.stat-card-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.stat-card-trend {
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}
.stat-card-trend.up { color: var(--success); }
.stat-card-trend.down { color: var(--danger); }
.stat-card-trend span { color: var(--text-muted); font-weight: 400; margin-left: 4px; }

/* Dashboard Charts */
.chart-container {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

/* Login Modal */
.login-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
}

.brand-icon {
    width: 56px;
    height: 56px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
}

/* Modals */
.modal-content {
    border: none;
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
.modal-header {
    border-bottom: 1px solid var(--border);
}
.modal-footer {
    border-top: 1px solid var(--border);
    background-color: var(--background);
    border-bottom-left-radius: var(--radius-xl);
    border-bottom-right-radius: var(--radius-xl);
}

/* Mobile Sidebar Toggle */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -260px;
        height: 100vh;
        box-shadow: 4px 0 24px rgba(0,0,0,0.1);
    }
    .sidebar.show {
        left: 0;
    }
}

/* Force perfect circles for icon buttons */
.btn.rounded-circle {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.btn.btn-sm.rounded-circle {
    width: 32px;
    height: 32px;
    font-size: 14px;
}

.btn.btn-lg.rounded-circle {
    width: 48px;
    height: 48px;
    font-size: 20px;
}


/* Mobile topbar adjustments */
@media (max-width: 768px) {
    .topbar { padding: 0 16px; }
    #global-project-select { max-width: 200px !important; width: auto !important; font-size: 0.85rem !important; padding-left: 12px !important; padding-right: 30px !important; text-overflow: ellipsis !important; white-space: nowrap; overflow: hidden; }
}
