:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --secondary: #64748b;
    --accent: #0ea5e9;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --sidebar-width: 260px;
    --header-height: 70px;
    --glass: rgba(255, 255, 255, 0.7);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.5;
    /* overflow: hidden; REMOVED to avoid conflict with Bootstrap Modals */
}

/* Layout Structure */
.crm-wrapper {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.crm-sidebar {
    width: var(--sidebar-width);
    background: #0f172a;
    color: white;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    z-index: 100;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    background: rgba(0, 0, 0, 0.2);
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: -1px;
}

.logo-text span {
    color: var(--accent);
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 0.75rem;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: #94a3b8;
    text-decoration: none;
    border-radius: 0.5rem;
    margin-bottom: 0.25rem;
    transition: all 0.2s;
    cursor: pointer;
}

.nav-item i {
    width: 20px;
    margin-right: 0.75rem;
    font-size: 1.1rem;
}

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

.nav-item.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.sidebar-divider {
    font-size: 0.65rem;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.4);
    padding: 1.5rem 1.5rem 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Main Content */
.crm-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.crm-header {
    height: var(--header-height);
    background: var(--glass);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    z-index: 90;
}

.crm-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    background: var(--background);
}

/* Cards & Components */
.card-premium {
    background: var(--surface);
    border-radius: 1rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.card-premium:hover {
    box-shadow: var(--shadow-md);
}

.btn-premium {
    padding: 0.6rem 1.25rem;
    border-radius: 0.5rem;
    font-weight: 600;
    transition: all 0.2s;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

/* Utility Classes */
.glass-morphism {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.text-gradient {
    background: linear-gradient(to right, var(--primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

/* CRM Table Styling */
.table-premium {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0.5rem;
}

.table-premium th {
    padding: 1rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-muted);
}

.table-premium tbody tr {
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    border-radius: 0.5rem;
}

.table-premium td {
    padding: 1rem;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

/* Bootstrap Modal Overrides for CRM Stability */
.modal-backdrop {
    z-index: 1040 !important;
}

.modal {
    z-index: 1050 !important;
}

.modal-dialog {
    z-index: 1060 !important;
}

body.modal-open {
    overflow: hidden !important;
    padding-right: 0 !important;
}

/* Fix for dark screen freeze - ensure modal sits on top of everything */
#taskModal {
    background: rgba(0, 0, 0, 0.5);
    /* Handled by backdrop usually, but just in case */
}

/* Uppercase Requirement for better organization */
input:not([type="password"]):not([type="email"]):not(.no-uppercase),
textarea:not(.no-uppercase),
.form-control:not([type="password"]):not([type="email"]):not(.no-uppercase),
.form-control-minimal:not(.no-uppercase) {
    text-transform: uppercase;
}

::placeholder {
    text-transform: uppercase;
}