:root {
    /* Brand / palette */
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-primary-light: #dbeafe;
    --color-sidebar-bg: #0f172a;
    --color-sidebar-hover: #1e293b;
    --color-sidebar-text: #cbd5e1;
    --color-sidebar-text-active: #ffffff;
    --color-surface: #ffffff;
    --color-bg: #f8fafc;
    --color-border: #e2e8f0;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-success: #16a34a;
    --color-danger: #dc2626;
    --color-warning: #d97706;
    --color-info: #0284c7;

    /* Typography scale */
    --fs-xs: 0.8125rem;
    --fs-sm: 0.875rem;
    --fs-base: 1rem;
    --fs-md: 1.05rem;
    --fs-lg: 1.25rem;
    --fs-xl: 1.5rem;
}

html, body {
    height: 100%;
    margin: 0;
    font-family: 'Segoe UI', Tahoma, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    color: var(--color-text);
}

.login-shell {
    min-height: 100%;
    display: flex;
}

.login-brand-panel {
    flex: 1 1 46%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 3rem 2.5rem;
    background: linear-gradient(135deg, var(--color-sidebar-bg), var(--color-primary-dark));
    color: #ffffff;
}

.login-brand-shapes {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.login-brand-shapes .shape {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
}

.login-brand-shapes .shape-1 { width: 380px; height: 380px; top: -140px; inset-inline-start: -120px; }
.login-brand-shapes .shape-2 { width: 260px; height: 260px; bottom: -100px; inset-inline-end: -80px; background: rgba(37, 99, 235, 0.25); }
.login-brand-shapes .shape-3 { width: 140px; height: 140px; top: 45%; inset-inline-end: 12%; background: rgba(255, 255, 255, 0.06); }

.login-brand-content {
    position: relative;
    z-index: 1;
    max-width: 380px;
    text-align: center;
}

.login-brand-mark {
    width: 56px;
    height: 56px;
    margin: 0 auto 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.login-brand-title {
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 0.6rem;
    letter-spacing: 0.01em;
}

.login-brand-tagline {
    font-size: var(--fs-md);
    color: rgba(255, 255, 255, 0.82);
    margin: 0;
}

.login-form-panel {
    flex: 1 1 54%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--color-bg);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--color-surface);
    border-radius: 16px;
    padding: 2.5rem 2.25rem;
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.1);
}

.login-card-header {
    margin-bottom: 1.75rem;
}

.login-card-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.25rem;
    color: var(--color-text);
}

.login-card-header p {
    margin: 0;
    color: var(--color-text-muted);
    font-size: var(--fs-sm);
}

.login-field {
    margin-bottom: 1.1rem;
}

.login-field .form-label {
    font-weight: 600;
    font-size: var(--fs-sm);
    color: var(--color-text);
}

.login-input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.login-input-icon {
    position: absolute;
    inset-inline-start: 12px;
    display: flex;
    color: var(--color-text-muted);
    pointer-events: none;
}

.login-input-group .form-control {
    height: 46px;
    border-radius: 8px;
    padding-inline-start: 2.5rem;
    padding-inline-end: 2.5rem;
}

.login-input-group .form-control:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 0.2rem var(--color-primary-light);
}

.login-toggle-visibility {
    position: absolute;
    inset-inline-end: 8px;
    display: flex;
    align-items: center;
    padding: 6px;
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    border-radius: 6px;
}

.login-toggle-visibility:hover {
    color: var(--color-text);
    background: var(--color-bg);
}

.login-error {
    margin-bottom: 1rem;
}

.login-submit {
    height: 46px;
    border-radius: 8px;
    font-weight: 600;
    margin-top: 0.35rem;
}

@media (max-width: 991.98px) {
    .login-shell { flex-direction: column; }
    .login-brand-panel {
        flex: 0 0 auto;
        min-height: 180px;
        padding: 2rem 1.5rem;
    }
    .login-brand-title { font-size: 1.5rem; margin-bottom: 0.25rem; }
    .login-brand-tagline { display: none; }
    .login-brand-mark { width: 44px; height: 44px; margin-bottom: 0.75rem; }
    .login-form-panel { flex: 1 1 auto; padding: 1.5rem 1rem 2.5rem; }
}

@media (max-width: 480px) {
    .login-card { padding: 2rem 1.5rem; box-shadow: none; }
    .login-brand-panel { min-height: 150px; }
}

.page {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--color-sidebar-bg);
    color: var(--color-sidebar-text-active);
    padding: 1rem 0;
    transition: margin-inline-start 0.25s ease, transform 0.25s ease;
}

.nav-brand {
    font-size: var(--fs-lg);
    font-weight: bold;
    padding: 0 1rem 1rem 1rem;
    color: var(--color-sidebar-text-active);
}

.nav-section-title {
    color: #94a3b8;
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.75rem 1rem 0.25rem 1rem;
}

.sidebar .nav-link {
    color: var(--color-sidebar-text);
    font-size: var(--fs-base);
    padding: 0.55rem 1rem;
    margin: 0.1rem 0.5rem;
    border-radius: 6px;
    display: block;
    text-decoration: none;
}

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

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

.sidebar .nav-link.disabled {
    color: #64748b;
    cursor: default;
}

.page.sidebar-collapsed .sidebar {
    margin-inline-start: -240px;
}

.sidebar-toggle-btn {
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    width: 36px;
    height: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
}

.sidebar-toggle-btn span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--color-text);
    border-radius: 1px;
}

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

.sidebar-backdrop {
    display: none;
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        inset-inline-start: 0;
        bottom: 0;
        z-index: 2000;
        margin-inline-start: 0;
        transform: translateX(0);
    }

    .page.sidebar-collapsed .sidebar {
        margin-inline-start: 0;
        transform: translateX(-100%);
    }

    [dir="rtl"] .page.sidebar-collapsed .sidebar {
        /* translateX is a physical transform (doesn't follow inset-inline-*),
           so the slide-out direction needs an explicit RTL flip here. */
        transform: translateX(100%);
    }

    .page:not(.sidebar-collapsed) .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        z-index: 1999;
    }
}

main {
    flex: 1;
    background: var(--color-bg);
    font-size: var(--fs-base);
}

.top-row {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.content {
    padding-top: 1.5rem;
}

.lang-toggle {
    display: flex;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    overflow: hidden;
}

.lang-toggle a {
    padding: 0.35rem 0.7rem;
    font-size: var(--fs-sm);
    font-weight: 600;
    text-decoration: none;
    color: var(--color-text-muted);
    background: var(--color-surface);
}

.lang-toggle a.active {
    background: var(--color-primary);
    color: #ffffff;
}

.lang-toggle a:hover:not(.active) {
    background: var(--color-bg);
}

.login-lang-toggle {
    position: fixed;
    top: 16px;
    inset-inline-end: 16px;
}

.notif-btn {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--fs-sm);
}
.notif-btn .badge {
    font-size: var(--fs-xs);
}
.notif-wrapper {
    position: relative;
}
.notif-popup {
    position: absolute;
    top: calc(100% + 6px);
    inset-inline-start: 0;
    width: 380px;
    max-width: 90vw;
    max-height: 400px;
    overflow-y: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.15);
    z-index: 2500;
}
.notif-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg);
    border-radius: 8px 8px 0 0;
}
.notif-popup-close {
    cursor: pointer;
    font-size: var(--fs-lg);
    color: var(--color-text-muted);
}
.popup {
    background-color: var(--color-surface);
    z-index: 1000;
    position: absolute; /* or absolute if inside a positioned parent */
    width: 85%;
    box-shadow: 0px 0px 10px 0px rgba(15, 23, 42, 0.35);
    border-radius: 10px;
    padding: 10px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.popupscale {
    z-index: 9999;
    position: fixed;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.45);
    top: 0px;
    left: 0px;
}

/* Bootstrap readability/brand overrides */
.btn-sm, .form-control-sm, .form-select-sm {
    font-size: var(--fs-sm);
}

small, .small {
    font-size: 0.92em;
}

.table {
    font-size: var(--fs-base);
}

.table thead th {
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    border-bottom-width: 1px;
}

.card {
    border-color: var(--color-border);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

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

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

.form-control:focus, .form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 0.2rem var(--color-primary-light);
}

/* Note: .page is a default (row) flex container, so the browser already
   reverses its child order under dir="rtl" per the flexbox spec - the
   sidebar automatically ends up on the inline-start (right, in RTL) edge
   with no extra CSS needed. Do NOT add an explicit row-reverse override
   here - it would cancel that automatic mirroring instead of reinforcing it. */
