:root {
    /* Brand & Color Palette */
    --cpg-primary: #1a508b;
    --cpg-primary-hover: #133d6b;
    --cpg-secondary: #334155;
    --cpg-accent: #2563eb;
    --cpg-accent-hover: #1d4ed8;

    /* Backgrounds - Sober, Elegant, High-Contrast */
    --bg-body: #edf2f7;
    --bg-card: #ffffff;
    --bg-subtle: #f8fafc;
    --bg-muted: #f1f5f9;

    /* Typography */
    --text-main: #1e293b;
    --text-heading: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;

    /* Borders & Shadows */
    --border-color: #e2e8f0;
    --border-input: #cbd5e1;
    --border-focus: #1a508b;
    --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
    --shadow-card: 0 1px 3px 0 rgba(15, 23, 42, 0.05), 0 2px 5px -1px rgba(15, 23, 42, 0.03);
    --shadow-hover: 0 4px 10px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
    --shadow-elevated: 0 15px 30px -5px rgba(15, 35, 60, 0.1), 0 1px 3px rgba(0, 0, 0, 0.05);

    /* Layout */
    --sidebar-width: 275px;
    --sidebar-bg: #111c2a;
    --sidebar-active: #1a508b;
}

/* ==========================================================================
   Base & Typography
   ========================================================================== */
html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Cairo', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-heading);
    font-weight: 700;
    line-height: 1.35;
}

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

a {
    color: var(--cpg-primary);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--cpg-primary-hover);
}

/* ==========================================================================
   Sidebar Navigation
   ========================================================================== */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    background: linear-gradient(180deg, #132238 0%, #0d1624 100%);
    color: #ffffff;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    border-inline-end: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
}

.sidebar .brand-box {
    padding: 1.25rem 1rem 1rem;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logo-container {
    width: 68px;
    height: 68px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    padding: 8px;
    transition: transform 0.3s ease;
}

.sidebar-logo-container:hover {
    transform: scale(1.05);
}

.sidebar-logo {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.sidebar .user-info {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 0.65rem;
    padding: 0.85rem 1rem;
    margin: 1.25rem 0.75rem;
    backdrop-filter: blur(5px);
}

.sidebar .menu-category {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #94a3b8;
    text-transform: uppercase;
    padding: 0 1rem;
    margin-top: 1.25rem;
    margin-bottom: 0.4rem;
}

.nav-link {
    color: #cbd5e1;
    padding: 0.65rem 1rem;
    display: flex;
    align-items: center;
    border-radius: 0.5rem;
    margin: 3px 10px;
    font-size: 0.925rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-link:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.08);
    transform: translateX(-2px);
}

.nav-link.active {
    color: #ffffff;
    background: linear-gradient(90deg, #1a508b 0%, #2563eb 100%);
    box-shadow: 0 3px 8px rgba(37, 99, 235, 0.35);
    font-weight: 600;
}

.nav-link i {
    width: 22px;
    text-align: center;
    font-size: 1rem;
    margin-inline-end: 10px;
    opacity: 0.85;
}

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

/* ==========================================================================
   Main Content Layout
   ========================================================================== */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 24px 32px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 100vh;
}

@media (max-width: 991.98px) {
    .sidebar {
        margin-left: calc(-1 * var(--sidebar-width));
    }

    .sidebar.active {
        margin-left: 0;
    }

    .main-content {
        margin-left: 0;
        padding: 16px 20px;
    }
}

/* RTL Support */
[dir="rtl"] .sidebar {
    right: 0;
    left: auto;
    border-inline-end: none;
    border-inline-start: 1px solid rgba(255, 255, 255, 0.08);
}

[dir="rtl"] .main-content {
    margin-right: var(--sidebar-width);
    margin-left: 0;
}

@media (max-width: 991.98px) {
    [dir="rtl"] .sidebar {
        margin-right: calc(-1 * var(--sidebar-width));
        margin-left: 0;
    }

    [dir="rtl"] .sidebar.active {
        margin-right: 0;
    }

    [dir="rtl"] .main-content {
        margin-right: 0;
    }
}

[dir="rtl"] .nav-link:hover {
    transform: translateX(2px);
}

/* ==========================================================================
   Cards & Surfaces
   ========================================================================== */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-card);
    border-radius: 0.75rem;
    overflow: hidden;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

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

.card-header {
    background-color: var(--bg-subtle);
    border-bottom: 1px solid var(--border-color);
    padding: 0.9rem 1.25rem;
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

/* ==========================================================================
   Data Tables
   ========================================================================== */
.table-responsive {
    border-radius: 0.75rem;
}

.table {
    margin-bottom: 0;
    border-color: var(--border-color);
}

.table thead th {
    background-color: var(--bg-muted);
    border-bottom: 2px solid var(--border-input);
    color: #334155;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 0.85rem 1rem;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.table tbody td {
    padding: 0.85rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 0.925rem;
}

.table tbody tr {
    transition: background-color 0.15s ease;
}

.table tbody tr:hover {
    background-color: var(--bg-subtle);
}

/* ==========================================================================
   Form Controls & Inputs
   ========================================================================== */
.form-label {
    color: #334155;
    font-weight: 600;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
}

.form-control,
.form-select {
    border: 1px solid var(--border-input);
    border-radius: 0.5rem;
    padding: 0.55rem 0.85rem;
    font-size: 0.95rem;
    color: var(--text-main);
    background-color: #ffffff;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--cpg-primary);
    box-shadow: 0 0 0 3px rgba(26, 80, 139, 0.15);
    outline: 0;
}

.form-control:read-only,
.form-control:disabled {
    background-color: var(--bg-muted);
    color: var(--text-muted);
    border-color: var(--border-color);
    cursor: not-allowed;
}

.input-group-text {
    background-color: var(--bg-subtle);
    border-color: var(--border-input);
    color: var(--text-muted);
}

/* Input group RTL radius alignment */
[dir="rtl"] .input-group > :first-child {
    border-top-right-radius: 0.5rem;
    border-bottom-right-radius: 0.5rem;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

[dir="rtl"] .input-group > :last-child {
    border-top-left-radius: 0.5rem;
    border-bottom-left-radius: 0.5rem;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

[dir="rtl"] .input-group > :not(:first-child):not(:last-child) {
    border-radius: 0;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
    font-weight: 600;
    border-radius: 0.5rem;
    padding: 0.5rem 1.15rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-primary {
    background-color: var(--cpg-primary);
    border-color: var(--cpg-primary);
    color: #ffffff;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--cpg-primary-hover);
    border-color: var(--cpg-primary-hover);
    color: #ffffff;
    box-shadow: 0 3px 8px rgba(26, 80, 139, 0.28);
    transform: translateY(-1px);
}

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

.btn-outline-secondary {
    border-color: var(--border-input);
    color: #475569;
    background-color: #ffffff;
}

.btn-outline-secondary:hover {
    background-color: var(--bg-muted);
    color: #1e293b;
    border-color: #94a3b8;
}

/* ==========================================================================
   LOGIN PAGE - Executive, Sober & Professional
   ========================================================================== */
.login-page-container {
    width: 100%;
    min-height: 100vh;
}

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1rem;
    position: relative;
    background: 
        radial-gradient(circle at 50% 12%, rgba(26, 80, 139, 0.08) 0%, transparent 45%),
        radial-gradient(circle at 10% 85%, rgba(37, 99, 235, 0.05) 0%, transparent 40%),
        linear-gradient(135deg, #eaf0f6 0%, #edf2f7 50%, #e6eef5 100%);
    overflow: hidden;
}

/* Subtle background accent grid lines */
.login-container::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        linear-gradient(rgba(26, 80, 139, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(26, 80, 139, 0.03) 1px, transparent 1px);
    background-size: 32px 32px;
    pointer-events: none;
}

.login-card {
    width: 100%;
    max-width: 440px;
    background: #ffffff;
    border-radius: 1.15rem;
    border: 1px solid rgba(226, 232, 240, 0.95);
    box-shadow: 
        0 20px 45px -12px rgba(15, 35, 65, 0.12),
        0 2px 6px -1px rgba(15, 35, 65, 0.04),
        0 0 0 1px rgba(255, 255, 255, 0.9) inset;
    padding: 2.4rem 2.2rem;
    position: relative;
    z-index: 1;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Top corporate accent stripe */
.login-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    border-radius: 1.15rem 1.15rem 0 0;
    background: linear-gradient(90deg, #1a508b 0%, #2563eb 50%, #0284c7 100%);
}

.login-logo-wrapper {
    width: 96px;
    height: 96px;
    margin: 0 auto 1.35rem;
    background: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(26, 80, 139, 0.16);
    border: 3px solid #f8fafc;
    padding: 10px;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.login-logo-wrapper:hover {
    transform: scale(1.05);
}

.login-logo {
    width: 68px;
    height: 68px;
    object-fit: contain;
}

.login-company-tag {
    font-size: 0.85rem;
    font-weight: 700;
    color: #475569;
    letter-spacing: 0.3px;
    margin-bottom: 0.35rem;
}

.login-title {
    color: var(--cpg-primary);
    font-weight: 800;
    font-size: 1.45rem;
    margin-bottom: 0.25rem;
    line-height: 1.3;
}

.login-subtitle {
    color: #64748b;
    font-size: 0.825rem;
    margin-bottom: 1.5rem;
}

.login-badge {
    display: inline-flex;
    align-items: center;
    background-color: #f0f7ff;
    color: var(--cpg-primary);
    border: 1px solid #d0e3f8;
    border-radius: 20px;
    padding: 0.3rem 0.95rem;
    font-size: 0.775rem;
    font-weight: 600;
}

.login-input-group {
    border-radius: 0.5rem;
}

/* Seamless RTL input group for login */
[dir="rtl"] .login-input-group .input-group-text {
    background-color: #f8fafc;
    border: 1px solid #cbd5e1;
    border-left: 0;
    color: #64748b;
    padding: 0.65rem 0.95rem;
    font-size: 0.95rem;
    border-top-right-radius: 0.5rem;
    border-bottom-right-radius: 0.5rem;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

[dir="rtl"] .login-input-group .form-control:not(:last-child) {
    border: 1px solid #cbd5e1;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
    padding: 0.65rem 0.95rem;
    font-size: 0.95rem;
}

[dir="rtl"] .login-input-group .form-control:last-child {
    border: 1px solid #cbd5e1;
    border-right: 0;
    border-top-left-radius: 0.5rem;
    border-bottom-left-radius: 0.5rem;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    padding: 0.65rem 0.95rem;
    font-size: 0.95rem;
}

[dir="rtl"] .login-input-group .btn-toggle-pw {
    background-color: #f8fafc;
    border: 1px solid #cbd5e1;
    border-right: 0;
    color: #64748b;
    padding: 0.65rem 0.95rem;
    font-size: 0.95rem;
    border-top-left-radius: 0.5rem;
    border-bottom-left-radius: 0.5rem;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    transition: all 0.2s ease;
}

[dir="rtl"] .login-input-group .form-control:focus {
    border-color: var(--cpg-primary);
    box-shadow: 0 0 0 3px rgba(26, 80, 139, 0.15);
    z-index: 3;
}

.btn-toggle-pw:hover,
.btn-toggle-pw:focus {
    background-color: #e2e8f0;
    color: #1e293b;
    border-color: #94a3b8;
}

.login-btn-submit {
    background: linear-gradient(135deg, #1a508b 0%, #1e62ad 100%);
    border: none;
    color: #ffffff;
    font-weight: 700;
    font-size: 1.05rem;
    padding: 0.8rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(26, 80, 139, 0.28);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.login-btn-submit:hover {
    background: linear-gradient(135deg, #133d6b 0%, #1a508b 100%);
    box-shadow: 0 6px 18px rgba(26, 80, 139, 0.38);
    transform: translateY(-1px);
    color: #ffffff;
}

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

.login-btn-reset {
    border: 1px solid var(--border-input);
    color: #64748b;
    background: #ffffff;
    font-weight: 600;
    padding: 0.65rem 1.25rem;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

.login-btn-reset:hover {
    background: #f8fafc;
    color: #334155;
    border-color: #94a3b8;
}

.login-alert {
    border-radius: 0.6rem;
    font-size: 0.875rem;
    padding: 0.85rem 1rem;
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    animation: loginAlertFadeIn 0.3s ease;
}

@keyframes loginAlertFadeIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-footer-info {
    margin-top: 1.85rem;
    padding-top: 1.35rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: #64748b;
    font-size: 0.8rem;
    line-height: 1.6;
}

.login-security-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.775rem;
    color: #047857;
    background-color: #ecfdf5;
    border: 1px solid #a7f3d0;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
    margin-bottom: 0.75rem;
}