:root {
    /* Modern Color Palette (Managed via Layout) */
    --primary-hex: #0D121F;
    /* Redundant but kept for CSS-only tools */
    --primary: var(--primary-hex);
    --secondary: #C49B48;
    --sidebar-bg: var(--primary);
    --sidebar-item-active-bg: var(--secondary);
    --btn-primary-bg: var(--primary);
    --btn-primary-hover-bg: var(--primary-dark);
    --btn-secondary-bg: var(--secondary);
    --btn-secondary-hover-bg: var(--secondary-dark, #a37c35);
    --btn-danger-color: #ff4757;
    --btn-success-color: #2ed573;
    --btn-warning-color: #f39c12;
    --btn-info-color: #3498db;

    --bg-main: #f4f7f6;
    /* Light gray background */
    --bg-card: #ffffff;
    --text-main: #2d3436;
    --text-muted: #636e72;
    --border: #dfe6e9;

    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 10px 30px rgba(13, 18, 31, 0.1);
    --transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    --radius: 16px;

    --font-main: 'Poppins', 'IBM Plex Sans Arabic', sans-serif;
    --font-rtl: 'IBM Plex Sans Arabic', sans-serif;

    /* Button Unification Tokens */
    --btn-padding-y: 0.75rem;
    --btn-padding-x: 1.5rem;
    --btn-sm-padding-y: 0.5rem;
    --btn-sm-padding-x: 1rem;
    --btn-lg-padding-y: 1rem;
    --btn-lg-padding-x: 2rem;
    --btn-line-height: 1.25;
}

/* Page Loader */
.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-main);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2147483647;
    pointer-events: all;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.page-loader.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.loader-aurora {
    width: 60px;
    height: 60px;
    border: 3px solid transparent;
    border-top: 3px solid var(--primary);
    border-right: 3px solid var(--secondary);
    border-bottom: 3px solid var(--primary-light);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    position: relative;
}

.loader-aurora::after {
    content: '';
    position: absolute;
    top: 5px;
    left: 5px;
    right: 5px;
    bottom: 5px;
    border: 3px solid transparent;
    border-top: 3px solid var(--secondary);
    border-radius: 50%;
    animation: spin 1.5s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loader-text {
    font-weight: 600;
    color: var(--primary);
    letter-spacing: 2px;
    text-transform: uppercase;
    font-size: 0.8rem;
}

:lang(ar):not(i):not([class*="fa-"]) {
    font-family: var(--font-rtl) !important;
}

:lang(en):not(i):not([class*="fa-"]) {
    font-family: 'Poppins', sans-serif !important;
}

.arabic:not(i):not([class*="fa-"]) {
    font-family: var(--font-rtl) !important;
}

.english:not(i):not([class*="fa-"]) {
    font-family: 'Poppins', sans-serif !important;
}

[data-theme="dark"] {
    /* Colors */
    --text-main: #F1F5F9;           /* Softer white (Slate-50) */
    --text-muted: #94A3B8;          /* Muted slate (Slate-400) */
    --bg-main: #0F172A;             /* Slate Deep Navy (Slate-900) */
    --bg-card: #1E293B;             /* Slate Card Navy (Slate-800) */
    --border: #334155;              /* Subtle border (Slate-700) */
    --shadow-soft: 0 10px 40px rgba(0, 0, 0, 0.4);

    /* Primary Accent (Softer Gold for Eye Comfort) */
    --primary: var(--secondary);
    --secondary: var(--secondary);
    --primary-light: var(--brand-glow);
    --primary-dark: var(--secondary);
}

[data-theme="dark"] .sidebar {
    background-color: #0B1120; /* Deepest Slate for eye comfort */
    border-right: 1px solid var(--border);
}

[data-theme="dark"] .sidebar-header {
    border-bottom: 1px solid var(--border);
}

[data-theme="dark"] .sidebar-item:hover,
[data-theme="dark"] .sidebar-item.active {
    background-color: rgba(217, 176, 97, 0.15); /* Subtler gold highlight */
    color: var(--primary);
}

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

img {
    max-width: 100%;
    height: auto;
    display: block;
}

img[style*="object-fit: cover"],
img[style*="object-fit:cover"] {
    object-fit: contain !important;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-main);
    color: var(--text-main);
    transition: var(--transition);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    margin: 0;
    padding: 0;
}

/* RTL Support via dir attribute */
[dir="rtl"],
[dir="rtl"] body {
    font-family: var(--font-rtl);
    direction: rtl;
}

h2 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.02em;
}

[data-theme="dark"] h2 {
    color: var(--secondary);
}

.portal-title {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.025em;
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

.portal-subtitle {
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-bottom: 0;
}

[data-theme="dark"] .portal-title {
    color: var(--secondary);
}

/* Standard Page Hero Layout */
.page-hero,
.portal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    margin-bottom: 2.5rem;
}

.page-hero-info,
.portal-header-info {
    display: flex;
    flex-direction: column;
}

.page-hero-actions,
.portal-header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-inline-start: auto;
    margin-left: 0;
}

.container {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 0;
}

.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-soft);
    transition: var(--transition);
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-hover);
    border-color: var(--primary-light);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--btn-padding-y) var(--btn-padding-x);
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-family: inherit;
    line-height: var(--btn-line-height);
    transition: var(--transition);
    text-decoration: none;
    gap: 0.5rem;
    white-space: nowrap;
}

.btn-sm {
    padding: var(--btn-sm-padding-y) var(--btn-sm-padding-x);
    border-radius: 10px;
    font-size: 0.85rem;
}

.btn-lg {
    padding: var(--btn-lg-padding-y) var(--btn-lg-padding-x);
    border-radius: 14px;
    font-size: 1.1rem;
}

.btn-primary {
    background-color: var(--btn-primary-bg, var(--primary));
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(var(--primary-rgb, 13, 18, 31), 0.15);
}

.btn-primary:hover {
    background-color: var(--btn-primary-hover-bg, var(--primary-dark));
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(var(--primary-rgb, 13, 18, 31), 0.2);
}

.btn-secondary {
    background-color: transparent;
    color: var(--btn-secondary-bg, var(--secondary)) !important;
    border: 1.5px solid var(--btn-secondary-bg, var(--secondary));
    box-shadow: none;
}

.btn-secondary:hover {
    background: transparent;
    transform: translateY(-2px);
    box-shadow: none;
}

.btn-primary,
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    color: #ffffff !important;
}

.btn-secondary,
.btn-secondary:hover,
.btn-secondary:focus,
.btn-secondary:active {
    color: var(--btn-secondary-bg, var(--secondary)) !important;
}

.btn-danger,
.btn-danger:hover,
.btn-danger:focus,
.btn-danger:active {
    color: var(--btn-danger-color) !important;
}

.btn-success,
.btn-success:hover,
.btn-success:focus,
.btn-success:active {
    color: var(--btn-success-color) !important;
}

.btn-warning,
.btn-warning:hover,
.btn-warning:focus,
.btn-warning:active {
    color: var(--btn-warning-color) !important;
}

.btn-info,
.btn-info:hover,
.btn-info:focus,
.btn-info:active {
    color: var(--btn-info-color) !important;
}

.btn-primary i,
.btn-primary span,
.btn-secondary i,
.btn-secondary span,
.btn-danger i,
.btn-danger span,
.btn-success i,
.btn-success span,
.btn-warning i,
.btn-warning span,
.btn-info i,
.btn-info span,
.btn-primary *,
.btn-secondary *,
.btn-danger *,
.btn-success *,
.btn-warning *,
.btn-info * {
    color: inherit !important;
}

.btn-danger {
    background-color: transparent;
    color: var(--btn-danger-color);
    border: 1.5px solid var(--btn-danger-color);
    box-shadow: none;
}

.btn-danger:hover {
    background-color: transparent;
    transform: translateY(-2px);
    box-shadow: none;
}

.btn-success {
    background-color: transparent;
    color: var(--btn-success-color);
    border: 1.5px solid var(--btn-success-color);
    box-shadow: none;
}

.btn-success:hover {
    background-color: transparent;
    transform: translateY(-2px);
    box-shadow: none;
}

.btn-warning {
    background-color: transparent;
    color: var(--btn-warning-color);
    border: 1.5px solid var(--btn-warning-color);
    box-shadow: none;
}

.btn-warning:hover {
    background-color: transparent;
    transform: translateY(-2px);
    box-shadow: none;
}

.btn-info {
    background-color: transparent;
    color: var(--btn-info-color);
    border: 1.5px solid var(--btn-info-color);
    box-shadow: none;
}

.btn-info:hover {
    background-color: transparent;
    transform: translateY(-2px);
    box-shadow: none;
}

.btn-minimal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: var(--btn-sm-padding-y) var(--btn-sm-padding-x);
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: var(--transition);
    font-size: 0.9rem;
    font-weight: 500;
    line-height: var(--btn-line-height);
}

.btn-minimal:hover {
    background: var(--bg-main);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}

.icon-btn-minimal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0;
}

.icon-btn-minimal:hover {
    background: var(--bg-main);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
}

[data-theme="dark"] .btn-minimal,
[data-theme="dark"] .icon-btn-minimal {
    background: var(--bg-card) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

[data-theme="dark"] .btn-minimal:hover,
[data-theme="dark"] .icon-btn-minimal:hover {
    background: rgba(217, 176, 97, 0.1) !important;
    border-color: var(--primary) !important;
}

.btn-premium {
    position: relative;
    overflow: hidden;
}

.btn-premium::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    transform: rotate(45deg);
    transition: 0.5s;
    opacity: 0;
}

.btn-premium:hover::after {
    left: 100%;
    opacity: 1;
}

/* Global Form Elements */
.portal-input {
    width: 100%;
    padding: 0.75rem 1.25rem;
    background: var(--bg-main);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.portal-input,
.portal-input-premium,
.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="month"],
input[type="file"],
select,
textarea {
    width: 100%;
    min-height: 36px;
    padding: 0.4rem 0.65rem;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    color: var(--text-main);
    font: inherit;
    line-height: 1.35;
    transition: var(--transition);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
}

.portal-input::placeholder,
.portal-input-premium::placeholder,
.form-control::placeholder,
input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
    opacity: 1;
}

.portal-input:focus,
.portal-input-premium:focus,
.form-control:focus,
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(var(--primary-rgb, 13, 18, 31), 0.1);
}

.portal-input[readonly],
.portal-input-premium[readonly],
.form-control[readonly],
input[readonly],
textarea[readonly] {
    background: rgba(0, 0, 0, 0.03);
    cursor: not-allowed;
}

.portal-input:disabled,
.portal-input-premium:disabled,
.form-control:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.75;
    cursor: not-allowed;
}

.portal-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-card);
    box-shadow: 0 0 0 4px rgba(var(--primary-rgb, 13, 18, 31), 0.1), inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

input[type="month"].portal-input {
    min-height: 44px;
    cursor: pointer;
}

.portal-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.portal-help-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

[data-theme="dark"] .portal-input {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.05);
}

/* Main Layout with Sidebar */
.app-container {
    display: flex;
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

/* Minimal Grid System */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -15px;
    margin-left: -15px;
}

[class*="col-"] {
    position: relative;
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
    box-sizing: border-box;
}

.col-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
.col-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
.col-3 { flex: 0 0 25%; max-width: 25%; }
.col-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
.col-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
.col-6 { flex: 0 0 50%; max-width: 50%; }
.col-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
.col-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
.col-9 { flex: 0 0 75%; max-width: 75%; }
.col-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
.col-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
.col-12 { flex: 0 0 100%; max-width: 100%; }

@media (min-width: 769px) {
    .col-md-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
    .col-md-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
    .col-md-3 { flex: 0 0 25%; max-width: 25%; }
    .col-md-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
    .col-md-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
    .col-md-6 { flex: 0 0 50%; max-width: 50%; }
    .col-md-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
    .col-md-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
    .col-md-9 { flex: 0 0 75%; max-width: 75%; }
    .col-md-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
    .col-md-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
    .col-md-12 { flex: 0 0 100%; max-width: 100%; }
}

.portal-empty-grid-state {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 240px;
    padding: 2rem;
}

.portal-empty-grid-state-inner {
    width: 100%;
    max-width: 520px;
    border: 1px dashed rgba(var(--primary-rgb, 13, 18, 31), 0.18);
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(var(--primary-rgb, 13, 18, 31), 0.04), rgba(var(--secondary-rgb, 196, 155, 72), 0.04));
    box-shadow: var(--shadow-soft);
    padding: 2.25rem 1.75rem;
    text-align: center;
}

.portal-empty-grid-state-icon {
    width: 72px;
    height: 72px;
    border-radius: 22px;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--primary-rgb, 13, 18, 31), 0.08);
    color: var(--primary);
    font-size: 1.85rem;
}

.portal-empty-grid-state-title {
    margin: 0 0 0.5rem;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-main);
}

.portal-empty-grid-state-text {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.8;
    font-size: 0.95rem;
}

.portal-empty-grid-state-actions {
    margin-top: 1.25rem;
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.sidebar {
    position: relative;
    width: 240px;
    background-color: var(--sidebar-bg, var(--primary));
    color: white;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    flex-shrink: 0;
}

.sidebar-collapse-btn {
    position: absolute;
    top: 2.25rem;
    right: -22px;
    width: 44px;
    height: 44px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    color: var(--text-muted);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    z-index: 99999;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transition: var(--transition);
}

[dir="rtl"] .sidebar-collapse-btn {
    right: auto;
    left: -22px;
}

.sidebar-collapse-btn:hover {
    color: var(--secondary);
    border-color: var(--secondary);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    transform: scale(1.1);
}

.sidebar-collapse-btn i {
    transition: transform 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.sidebar-collapse-btn i {
    transform: none;
}

[dir="rtl"] .sidebar-collapse-btn i {
    transform: scaleX(-1);
}

.sidebar.collapsed .sidebar-collapse-btn i {
    transform: rotate(180deg);
}

.sidebar.collapsed[dir="rtl"] .sidebar-collapse-btn i,
[dir="rtl"] .sidebar.collapsed .sidebar-collapse-btn i {
    transform: scaleX(-1) rotate(180deg);
}

.sidebar.collapsed .sidebar-collapse-btn {
    right: -22px;
}

[dir="rtl"] .sidebar.collapsed .sidebar-collapse-btn {
    right: auto;
    left: -22px;
}

.sidebar-header {
    padding: 1rem;
    /* Minimal padding for a lean look */
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: center;
}

.sidebar-header a {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    width: 100%;
}

.sidebar-header img {
    max-height: 64px;
    /* Significantly bigger logo */
    width: auto;
    display: block;
    transition: var(--transition);
}

.sidebar-header:hover img {
    transform: scale(1.05);
}

/* Account Switcher in Sidebar (Refined) */
.account-switcher-sidebar {
    padding: 1.25rem 1.25rem;
    position: relative;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.active-account-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.active-account-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--secondary);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.account-visual {
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--secondary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    transition: var(--transition);
}

.account-visual.global-mode {
    background: var(--secondary);
    color: white !important;
    box-shadow: 0 0 15px rgba(196, 155, 72, 0.4);
}

.account-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.active-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.01em;
}

.view-mode {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

.toggle-caret {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.3);
    transition: var(--transition);
}

.active-account-card:hover .toggle-caret {
    color: var(--secondary);
    transform: rotate(180deg);
}

/* Dropdown Menu */
.account-dropdown-menu {
    position: absolute;
    top: calc(100% + 5px);
    left: 1.5rem;
    right: 1.5rem;
    background: var(--primary-light);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: var(--transition);
    overflow: hidden;
    padding: 0.5rem;
}

.account-dropdown-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.account-item {
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    color: rgba(255, 255, 255, 0.8);
}

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

.account-item.active {
    background: rgba(196, 155, 72, 0.1);
    color: var(--secondary);
}

.item-icon {
    font-size: 0.6rem;
    opacity: 0.4;
}

.account-item.active .item-icon {
    color: var(--secondary);
    opacity: 1;
}

.item-name {
    font-size: 0.85rem;
    font-weight: 500;
}

.sidebar-menu {
    flex-grow: 1;
    padding: 1.5rem 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.sidebar-menu::-webkit-scrollbar {
    width: 6px;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.sidebar-item {
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: var(--transition);
    font-weight: 500;
}

.sidebar-item:hover,
.sidebar-item.active {
    background-color: var(--sidebar-item-active-bg, var(--secondary));
    color: white !important;
    font-weight: 600;
}

.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.page-container {
    padding: 2rem 5%;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

header {
    background: transparent;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: var(--transition);
    margin: 0;
    padding: 0;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 5%;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.menu-toggle {
    display: none; /* Hidden on desktop */
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    color: var(--text-main);
    cursor: pointer;
    transition: var(--transition);
}

.menu-toggle:hover {
    color: var(--primary);
    background: var(--bg-main);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.1);
}

/* Header Controls & Profile */
.controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.notifications-wrapper {
    position: relative;
}

.header-view-mode-toggle-host {
    display: flex;
    align-items: center;
}

.header-view-mode-toggle-group {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.header-view-toggle-btn {
    position: relative;
    flex: 0 0 auto;
}

.header-view-toggle-btn i {
    font-size: 1rem;
}

.header-view-toggle-btn.active {
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb, 13, 18, 31), 0.1);
}

.header-view-toggle-btn.active:hover {
    background: var(--bg-main);
    border-color: var(--primary);
}

.header-view-toggle-btn:focus-visible {
    outline: 2px solid rgba(var(--primary-rgb, 13, 18, 31), 0.2);
    outline-offset: 2px;
}

.theme-switcher-premium {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.35rem;
    border-radius: 12px;
    border: 1.5px solid var(--border);
    gap: 0.25rem;
    transition: var(--transition);
}

.theme-btn-premium {
    min-width: 42px;
    height: 42px;
    padding: 0 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    background: var(--bg-card);
    color: var(--text-main);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.92rem;
    font-weight: 600;
    box-shadow: none;
}

.theme-btn-premium i {
    font-size: 1.05rem;
}

/* Universal Section Toggle Premium */
.section-toggle-premium {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(var(--primary-rgb), 0.05);
    border: 1px solid var(--border);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.85rem;
}

.section-toggle-premium:hover {
    background: rgba(var(--primary-rgb), 0.1);
    border-color: var(--primary-light);
    color: var(--primary);
    transform: scale(1.05);
}

.section-toggle-premium.collapsed i {
    transform: rotate(180deg);
}

.section-toggle-premium i {
    transition: transform 0.3s ease;
}

.premium-card-section {
    transition: max-height 0.4s ease-out, opacity 0.3s ease, margin 0.3s ease;
    overflow: hidden;
    max-height: 2000px;
    opacity: 1;
}

.premium-card-section.collapsed {
    max-height: 0;
    opacity: 0;
    margin: 0 !important;
    pointer-events: none;
}

.theme-btn-premium:hover {
    color: var(--primary);
    background: var(--bg-main);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb, 13, 18, 31), 0.1);
}

.theme-btn-premium.active {
    background: var(--bg-card);
    color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .theme-switcher-premium {
    background: rgba(0, 0, 0, 0.2);
}

.notification-bell {
    width: 42px;
    height: 42px;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-main);
    transition: var(--transition);
    position: relative;
    font-size: 1.1rem;
}

.notification-bell:hover {
    background: var(--bg-main);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb, 13, 18, 31), 0.1);
}

.unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 10px;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-card);
}

.unread-badge.active {
    display: flex;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-height: 48px;
    padding: 0.4rem 1rem 0.4rem 0.45rem;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.user-profile:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb, 13, 18, 31), 0.1);
    transform: translateY(-2px);
}

.profile-avatar-container {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--bg-main);
    flex: 0 0 auto;
}

.profile-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.user-profile-avatar,
.admin-profile-avatar,
.organisation-profile-user-avatar,
.profile-avatar,
.kanban-user-avatar img,
.profile-avatar-container img {
    border-radius: 50%;
}

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

.profile-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}

.profile-chevron {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-left: 0.5rem;
}

@media (max-width: 768px) {
    .profile-avatar-container {
        width: 30px;
        height: 30px;
    }
}

[data-theme="dark"] .notification-bell,
[data-theme="dark"] .user-profile {
    background: var(--bg-card);
    border-color: var(--border);
}

[data-theme="dark"] .user-profile:hover {
    background: var(--primary-dark);
}

/* Dropdowns */
.notifications-dropdown,
.profile-dropdown {
    position: absolute;
    top: calc(100% + 15px);
    right: 0;
    width: 320px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-hover);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    z-index: 1000;
    overflow: hidden;
    transition: var(--transition);
}

.profile-dropdown {
    width: 240px;
}

.notifications-dropdown.active,
.profile-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

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

.notice-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-main);
}

.notice-header h4 {
    font-size: 0.9rem;
    font-weight: 700;
    margin: 0;
}

.notice-list {
    max-height: 400px;
    overflow-y: auto;
}

.notice-item {
    padding: 1rem 1.25rem;
    display: flex;
    gap: 1rem;
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
    border-bottom: 1px solid var(--border);
}

.notice-item:hover {
    background: var(--bg-main);
}

.notice-item.unread {
    background: rgba(13, 110, 253, 0.05);
}

.notice-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.notice-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.notice-title {
    font-size: 0.85rem;
    font-weight: 600;
}

.notice-msg {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.notice-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Profile Menu Items */
.profile-dropdown {
    padding: 0.5rem;
}

.dropdown-item {
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-main);
    border-radius: 10px;
    font-size: 0.9rem;
    transition: var(--transition);
}

.dropdown-item:hover {
    background: var(--bg-main);
    color: var(--primary);
}

.dropdown-item i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
    color: var(--text-muted);
    transition: var(--transition);
}

.dropdown-item:hover i {
    color: var(--primary);
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 0.4rem 0.5rem;
}

.dropdown-item.logout {
    color: #ff4757 !important;
}

.dropdown-item.logout i {
    color: #ff4757 !important;
}

.dropdown-item.logout:hover {
    background: #fff5f5;
}

[data-theme="dark"] .dropdown-item.logout:hover {
    background: rgba(255, 71, 87, 0.1);
}

/* Sidebar Collapsed State (Desktop) */
.sidebar.collapsed {
    width: 68px;
}

.sidebar.collapsed .sidebar-header {
    padding: 1rem 0;
}

.sidebar.collapsed .sidebar-header img {
    margin-top: 0.5rem;
    max-width: 40px;
    height: auto;
    object-fit: contain;
}

.sidebar.collapsed .sidebar-item span {
    display: none;
    opacity: 0;
    width: 0;
}

.sidebar.collapsed .sidebar-item {
    justify-content: center;
    padding: 1rem;
}

.sidebar.collapsed .sidebar-item i {
    font-size: 1.25rem;
    margin: 0;
}

.sidebar.collapsed .account-switcher-sidebar {
    padding: 1rem 0.5rem;
    display: flex;
    justify-content: center;
}

.sidebar.collapsed .active-account-card {
    padding: 0.5rem;
    justify-content: center;
    border-radius: 10px;
}

.sidebar.collapsed .account-info,
.sidebar.collapsed .toggle-caret {
    display: none;
}

.sidebar.collapsed .account-visual {
    margin: 0;
}

@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: -240px;
        top: 0;
        bottom: 0;
        z-index: 1200;
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.1);
    }

    [dir="rtl"] .sidebar {
        left: auto;
        right: -240px;
    }

    .sidebar.active {
        left: 0;
    }

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

    .sidebar-collapse-btn {
        display: none !important;
        top: 1.25rem;
        right: -22px;
    }

    [dir="rtl"] .sidebar-collapse-btn {
        right: auto;
        left: -22px;
    }

    .sidebar.active .sidebar-collapse-btn {
        display: flex !important;
    }

    [dir="rtl"] .sidebar.active .sidebar-collapse-btn {
        right: auto;
        left: -22px;
    }

    body.sidebar-mobile-active .menu-toggle {
        display: none !important;
    }

    .main-content {
        width: 100%;
    }

    .menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: var(--bg-card);
        border: 1.5px solid var(--border);
        border-radius: 10px;
        color: var(--text-main);
    }

    .profile-info {
        display: none;
    }

    .user-profile {
        padding: 0.4rem;
    }
}

@media (max-width: 768px) {
    .page-container {
        padding: 1.5rem 1rem;
    }

    .portal-title {
        font-size: 1.75rem;
        margin-bottom: 0.5rem;
        font-weight: 800;
        letter-spacing: -0.02em;
        color: var(--text-main);
        display: flex;
        align-items: center;
        gap: 0.75rem;
    }

    .portal-subtitle {
        font-size: 0.85rem;
        margin-top: 0;
    }

    .card {
        padding: 1.25rem;
    }

    /* Standard Mobile Stacking Rules */
    /* Force all grid-like columns to full width */
    [class*="col-"],
    .grid-col,
    .flex-col {
        width: 100% !important;
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    /* Ensure titles/descriptions stack above actions */
    .header-flex,
    .page-hero,
    .portal-header,
    .dashboard-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1.25rem !important;
    }

    .header-actions,
    .page-hero-actions,
    .portal-header-actions,
    .dashboard-header-actions,
    .header-actions-group {
        width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    /* All buttons in actions/filters/headers become full-width */
    .header-actions .btn,
    .page-hero-actions .btn,
    .portal-header-actions .btn,
    .dashboard-header-actions .btn,
    .filter-actions .btn,
    .filter-section .btn,
    .btn-group .btn {
        width: 100% !important;
        display: flex !important;
        justify-content: center !important;
    }

    /* Inputs and selects in filters become full-width */
    .filter-item {
        width: 100% !important;
        flex: 0 0 100% !important;
        margin-left: 0 !important;
    }

    .filter-item select,
    .filter-item input,
    .filter-item .premium-input {
        width: 100% !important;
    }
}

@media (max-width: 480px) {
    .page-container {
        padding: 1rem 0.75rem;
    }

    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
        width: 100%;
        justify-content: center;
    }
}

/* Premium Toast Notifications */
.alert-fixed-container {
    position: fixed;
    top: 2rem;
    left: 2rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    pointer-events: none;
}

.alert {
    min-width: 320px;
    max-width: 450px;
    padding: 1rem 1.5rem;
    border-radius: 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: 0 15px 35px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-main);
    font-weight: 500;
    pointer-events: all;
    animation: toastSlideIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transition: all 0.4s ease;
}

.alert i {
    font-size: 1.25rem;
}

.alert-success {
    border-left: 5px solid #2ed573;
}
.alert-success i { color: #2ed573; }

.alert-error {
    border-left: 5px solid #ff4757;
}
.alert-error i { color: #ff4757; }

.offline-status-bar {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2147483000;
    width: min(720px, calc(100vw - 2rem));
    display: flex;
    align-items: flex-start;
    gap: 0.9rem;
    padding: 0.95rem 1rem;
    border-radius: 18px;
    border: 1px solid rgba(var(--primary-rgb, 13, 18, 31), 0.12);
    background: linear-gradient(135deg, rgba(var(--primary-rgb, 13, 18, 31), 0.96), rgba(14, 22, 38, 0.96));
    color: #ffffff;
    box-shadow: 0 20px 40px rgba(13, 18, 31, 0.25);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.offline-status-bar i {
    margin-top: 0.1rem;
    font-size: 1.05rem;
    color: #f5c96a;
    flex: 0 0 auto;
}

.offline-status-copy {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.offline-status-copy strong {
    font-size: 0.95rem;
    line-height: 1.35;
}

.offline-status-copy span {
    font-size: 0.88rem;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.82);
}

body.portal-offline .status-indicator.online,
body.portal-offline .status-indicator.offline {
    background: #f39c12;
    box-shadow: 0 0 0 4px rgba(243, 156, 18, 0.18);
}

@keyframes toastSlideIn {
    from { transform: translateX(-100%) scale(0.8); opacity: 0; }
    to { transform: translateX(0) scale(1); opacity: 1; }
}

[dir="rtl"] .alert {
    text-align: right;
}

[dir="rtl"] .alert-fixed-container .alert {
    align-self: flex-start;
}

[data-theme="dark"] .alert {
    background: #1e293b;
    border-color: rgba(255,255,255,0.1);
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}

/* Shared Response Messages */
.response-message {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 1.1rem;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-main);
    box-shadow: var(--shadow-soft);
}

.response-message-compact {
    padding: 0.75rem 0.9rem;
    border-radius: 14px;
    gap: 0.85rem;
}

.response-message-icon {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    background: rgba(var(--primary-rgb, 13, 18, 31), 0.08);
    color: var(--primary);
}

.response-message-success .response-message-icon {
    background: rgba(46, 213, 115, 0.12);
    color: #2ed573;
}

.response-message-warning .response-message-icon {
    background: rgba(243, 156, 18, 0.12);
    color: #f39c12;
}

.response-message-error .response-message-icon {
    background: rgba(255, 71, 87, 0.12);
    color: #ff4757;
}

.response-message-technical .response-message-icon {
    background: rgba(52, 152, 219, 0.12);
    color: #3498db;
}

.response-message-body {
    min-width: 0;
    flex: 1;
}

.response-message-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.35rem;
}

.response-message-heading strong {
    font-size: 0.98rem;
    line-height: 1.35;
}

.response-message-text {
    font-size: 0.92rem;
    line-height: 1.7;
    color: var(--text-main);
}

.response-message-details {
    margin-top: 0.45rem;
    font-size: 0.84rem;
    line-height: 1.65;
    color: var(--text-muted);
}

.response-message-actions {
    margin-top: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.response-message-close {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    flex: 0 0 auto;
    padding: 0.1rem;
}

.response-message-close:hover {
    color: var(--text-main);
}

@media (max-width: 576px) {
    .response-message {
        padding: 0.9rem;
        border-radius: 14px;
    }

    .response-message-icon {
        width: 38px;
        height: 38px;
        border-radius: 12px;
    }
}
