/* ===================== Notifications page styles ===================== */
.notifications-container {
    max-width: 980px;
    margin: 0 auto;
    padding: 1rem;
}

.notifications-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding: 1rem 1.25rem;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.notifications-header h1 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.15rem;
}

.notifications-header .badge {
    background: var(--primary-bg, #e7f1ff);
    color: var(--primary);
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-size: 0.85rem;
    margin-inline-start: 0.5rem;
}

.mark-all-read-btn {
    padding: 0.45rem 1rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.mark-all-read-btn:disabled {
    opacity: .6;
    cursor: not-allowed;
}

.notifications-list {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.notification-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: var(--shadow);
    display: flex;
    gap: 1rem;
    transition: transform .18s ease, box-shadow .18s ease;
    position: relative;
    border-inline-start: 4px solid transparent;
}

notification-card.unread {
    background: linear-gradient(90deg, rgba(0, 123, 255, 0.03), var(--card-bg));
    border-inline-start-color: var(--primary);
}

.notification-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

.notification-icon-large {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: white;
    flex-shrink: 0;
}

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

.notification-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 .35rem 0;
    color: var(--text-color);
}

.notification-message {
    color: var(--text-muted);
    margin: 0 0 .6rem 0;
    line-height: 1.5;
}

.notification-meta {
    display: flex;
    gap: 1rem;
    font-size: .9rem;
    color: var(--text-muted);
    align-items: center;
}

.notification-actions {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}

.notification-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: var(--hover-bg);
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.notification-action-btn:hover {
    background: var(--primary);
    color: #fff;
}

.notification-link-btn {
    padding: .45rem .9rem;
    background: var(--primary);
    color: #fff;
    border-radius: 8px;
    display: inline-block;
    font-weight: 600;
    text-decoration: none;
}

/* color swatches for icons */
.color-primary {
    background: #007bff;
}

.color-success {
    background: #28a745;
}

.color-danger {
    background: #dc3545;
}

.color-warning {
    background: #ffc107;
    color: #333 !important;
}

.color-info {
    background: #17a2b8;
}

@media (max-width: 720px) {
    .notifications-container {
        padding: .5rem;
    }

    .notification-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .notification-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

/* End notifications styles */

/* Tasks list: smaller avatars scoped to the tasks table */
.tasks-table .avatars-group .avatar-sm {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tasks-table .avatars-group .avatar-sm img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.tasks-table .avatars-group .avatar-sm .avatar-initial {
    font-size: 16px;
    line-height: 44px;
}

@media (max-width: 576px) {
    .tasks-table .avatars-group .avatar-sm {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
    }

    .tasks-table .avatars-group .avatar-sm .avatar-initial {
        font-size: 14px;
        line-height: 36px;
    }
}

/* Center the avatars group inside its table cell (horizontal + vertical) */
.tasks-table td .avatars-group {
    display: flex;
    align-items: center;
    /* vertical centering within the row */
    justify-content: center;
    /* horizontal centering within the cell */
    gap: 0.5rem;
}

/* Ensure avatar-sm uses flex centering so initials/images are perfectly centered */
.tasks-table .avatars-group .avatar-sm {
    display: inline-flex;
    /* already set, reinforce for specificity */
    align-items: center;
    justify-content: center;
}

/* Tasks table polished rows */
.tasks-table .table {
    border-collapse: separate;
    border-spacing: 0 0.75rem;
}

/* Dashboard: Recent tasks - ensure assignee badges are single-line and truncate after 15 chars */
.dashboard-manager .card .table td:nth-child(2) .badge {
    display: inline-block;
    max-width: 15ch; /* approx. 15 characters */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

@media (max-width: 768px) {
    .dashboard-manager .card .table td:nth-child(2) .badge {
        max-width: 10ch;
    }
}

.tasks-table .table thead th {
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    padding: 0.75rem 1rem;
    border-bottom: none;
}

.tasks-table .table tbody tr {
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius);
    overflow: hidden;
}

.tasks-table .table tbody td {
    padding: 1rem;
    vertical-align: middle;
    border: none;
}

.tasks-table .badge {
    padding: 0.35rem 0.6rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
}

.priority-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
}

.tasks-table .table-hover tbody tr:hover {
    transform: translateY(-3px);
    transition: transform var(--transition);
}

/* small action buttons in table */
.tasks-table .btn-sm {
    padding: 0.35rem 0.5rem;
}

@media (max-width: 720px) {

    /* Mobile: keep table layout but allow horizontal scrolling instead of stacking rows */
    .tasks-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tasks-table .table {
        width: 100%;
        min-width: 720px;
        /* ensures columns remain readable; adjust as needed */
    }

    /* Prevent wrapping of important table cells so horizontal scroll is used */
    .tasks-table .table thead th,
    .tasks-table .table tbody td {
        white-space: nowrap;
    }

    /* Keep row display as table-row for consistent look */
    .tasks-table .table tbody tr {
        display: table-row;
        margin-bottom: 0;
    }
}

/* Avatars column sizing and overlap handling */
.tasks-table .table thead th:nth-child(5),
.tasks-table .table tbody td:nth-child(5) {
    width: 180px;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tasks-table .avatars-group {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    max-width: 220px;
    overflow: hidden;
}

.tasks-table .avatars-group .avatar-sm {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 50%;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    border: 2px solid var(--surface);
    /* overlap avatars slightly */
    margin-left: -12px;
    position: relative;
    z-index: 1;
}

.tasks-table .avatars-group .avatar-sm:first-child {
    margin-left: 0;
}

.tasks-table .avatars-group .avatar-sm img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover
}

/* Smaller sizes on narrow screens */
@media (max-width: 576px) {
    .tasks-table {
        overflow-x: auto;
    }

    .tasks-table .table {
        min-width: 640px;
    }

    .tasks-table .table thead th:nth-child(5),
    .tasks-table .table tbody td:nth-child(5) {
        width: 140px;
        max-width: 160px;
    }

    .tasks-table .avatars-group .avatar-sm {
        width: 36px;
        height: 36px;
        min-width: 36px;
        margin-left: -10px;
    }

    .tasks-table .avatars-group .avatar-sm:first-child {
        margin-left: 0;
    }
}

/* Ensure the +N avatar indicator remains visible and not clipped */
.tasks-table .avatars-group .avatar-sm:last-child {
    margin-right: 4px;
}

/* Templates card list: horizontal carousel and responsive preview tweaks */
.templates-card-list {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.5rem;
}

.templates-card-list::-webkit-scrollbar {
    height: 8px;
}

.templates-card-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.08);
    border-radius: 8px;
}

.template-card {
    flex: 0 0 220px;
    min-width: 180px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
}

.template-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-sm);
}

.template-card.active {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.template-card .tpl-name {
    font-weight: 700;
}

.template-card .tpl-desc {
    color: var(--text-tertiary);
    font-size: 0.95rem;
}

.template-card .tpl-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.template-card .tpl-preview-btn {
    background: transparent;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-weight: 600
}

/* Template preview area: make preview and detail stack on small screens */
/* Template preview area: responsive wrapping to avoid overflow */
#templatePreviewContainer {
    width: 100%;
}

#templatePreviewContainer>div {
    /* the inner flex container (inline-styled in template) */
    display: flex !important;
    gap: 1rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

#templatePreviewContainer #templateStagesList {
    flex: 1 1 260px;
    min-width: 200px;
}

/* Allow the stages list to shrink below its content width so the detail box doesn't push the container overflow when a template is selected */
#templatePreviewContainer>div>#templateStagesList {
    min-width: 0;
    flex: 1 1 auto;
}

#stageDetailBox {
    flex: 0 0 320px;
    max-width: 100%;
    box-sizing: border-box;
}

@media (max-width: 960px) {

    /* At medium widths, allow the detail box to move under the stages list to prevent horizontal overflow */
    #stageDetailBox {
        flex: 1 1 100%;
        border-left: none;
        border-top: 1px solid var(--border);
        padding-left: 0;
        padding-top: 0.75rem;
    }

    #templatePreviewContainer>div {
        gap: 0.5rem;
    }

    .template-card {
        flex: 0 0 200px;
    }
}

@media (max-width: 720px) {

    /* hide detailed side box entirely on small screens (modal available) */
    #stageDetailBox {
        display: none !important;
    }

    #templateStagesList {
        min-width: 220px;
    }

    .template-card {
        flex: 0 0 180px;
    }
}

/* Form action buttons: stack vertically on small screens */
.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    align-items: center;
}

@media (max-width: 720px) {
    .form-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        padding: 1rem 0 0 0 !important;
    }

    .form-actions .btn {
        width: 100%;
        min-width: 0 !important;
    }

    .form-actions .btn+.btn {
        margin-top: 0;
    }
}

/* Responsive rules for assignment rows in task edit form */
.assignment-row {
    display: flex;
    gap: 1rem;
    align-items: center;
    padding: 0.75rem;
    border-radius: var(--radius);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    flex-wrap: nowrap;
}

.assignment-row .assignment-left {
    flex: 1 1 auto;
    min-width: 0;
}

.assignment-row .assignment-status {
    flex: 0 0 180px;
    min-width: 140px;
}

.assignment-row .assignment-notes {
    flex: 0 0 220px;
    min-width: 160px;
}

@media (max-width: 720px) {
    .assignment-row {
        flex-wrap: wrap;
    }

    .assignment-row .assignment-left {
        flex: 1 1 100%;
    }

    .assignment-row .assignment-status,
    .assignment-row .assignment-notes {
        flex: 1 1 100%;
        min-width: 0;
    }

    .assignment-row .assignment-status select,
    .assignment-row .assignment-notes input {
        width: 100%;
    }
}

/* Ensure horizontal scroll appears only on intended containers */
.templates-card-list,
.tasks-table {
    -webkit-overflow-scrolling: touch;
}

/* Ensure sidebar scrolls naturally with page (no sticky/fixed positioning) */
.page-layout aside {
    position: relative !important;
    top: auto !important;
}

/* Force sidebar and its cards to normal document flow (override any sticky/fixed from other rules) */
.page-layout aside,
.page-layout aside .card,
.page-layout aside .card * {
    position: static !important;
    top: auto !important;
}

/* Page layout responsiveness: move sidebar under main content on small screens */
@media (max-width: 900px) {
    .page-layout {
        display: flex !important;
        flex-direction: column;
        gap: 0.75rem !important;
        align-items: stretch !important;
    }

    .page-layout main {
        order: 1;
        width: 100% !important;
        min-width: 0 !important;
    }

    .page-layout aside {
        order: 2;
        width: 100% !important;
        flex-shrink: 0 !important;
        position: relative !important;
    }

    .page-layout aside .card {
        margin: 0.5rem 0 !important;
        position: relative !important;
    }

    /* Ensure inner elements don't cause horizontal overflow */
    .page-layout main,
    .page-layout aside {
        overflow: visible;
        position: relative !important;
    }
}

@media (max-width: 480px) {
    .page-layout {
        gap: 0.5rem !important;
    }

    .page-layout aside .card {
        padding: 0.75rem !important;
        position: relative !important;
    }
}


/* =============================================================================
   🎨 سیستم مدیریت تسک - طراحی مدرن فارسی
   Ultra-Modern Persian RTL Design
   ============================================================================= */

/* فونت‌های فارسی */
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800;900&display=swap');

/* ============= متغیرهای CSS ============= */
:root {
    /* رنگ‌های اصلی */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

    /* Activity log type colors (used in activity_logs) */
    --type-task: #7c4dff;
    --type-file: #17a2b8;
    --type-attendance: #ffc107;
    --type-system: #ff6b6b;

    /* رنگ‌های وضعیت */
    --success: #10b981;
    --success-light: #d1fae5;
    --success-dark: #059669;
    --success-gradient: linear-gradient(135deg, #0ba360 0%, #3cba92 100%);

    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --warning-dark: #d97706;

    --danger: #ef4444;
    --danger-light: #fee2e2;
    --danger-dark: #dc2626;

    --info: #3b82f6;
    --info-light: #dbeafe;
    --info-dark: #2563eb;

    /* رنگ‌های خنثی */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --surface: #ffffff;
    --surface-hover: #f8fafc;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;

    --border: #e2e8f0;
    --border-light: #f1f5f9;
    /* input / form background (used by chat textarea and other inputs) */
    --input-bg: var(--bg-secondary);

    /* سایه‌ها */
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 2px 4px 0 rgba(0, 0, 0, 0.06);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.3);
    --shadow-colored: 0 10px 30px -5px rgba(99, 102, 241, 0.4);

    /* فاصله‌گذاری */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;

    /* گردی گوشه‌ها */
    --radius-sm: 0.5rem;
    --radius: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-2xl: 2rem;
    --radius-full: 9999px;

    /* انتقال */
    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);

    /* لایوت */
    --sidebar-width: 280px;

    .templates-card-list {
        display: flex;
        gap: 0.75rem;
        overflow-x: auto;
        padding: 0.5rem 0;
        margin-top: 0.5rem;
    }

    .template-card {
        min-width: 200px;
        max-width: 280px;
        background: linear-gradient(180deg, var(--bg-secondary), var(--bg-primary));
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 0.85rem;
        box-shadow: var(--shadow-sm);
        cursor: pointer;
        transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
        display: flex;
        flex-direction: column;
        gap: 0.4rem;
    }

    .template-card:hover {
        transform: translateY(-6px);
        box-shadow: var(--shadow-md);
        border-color: rgba(99, 102, 241, 0.25);
    }

    .template-card.active {
        box-shadow: var(--shadow-glow);
        border-color: var(--primary-light);
        outline: 3px solid rgba(99, 102, 241, 0.06);
    }

/* Jalali picker visible input styles */
.jalali-picker-input {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border-radius: 0.6rem;
    border: 1px solid var(--border);
    background: var(--surface);
    font-family: 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
    font-size: 0.98rem;
    color: var(--text-primary);
    text-align: right;
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.jalali-picker-input:focus {
    outline: none;
    border-color: var(--primary-dark);
    box-shadow: 0 6px 20px rgba(99,102,241,0.12);
}

.jalali-picker-input[readonly] {
    cursor: pointer;
}

.jalali-picker-input { box-sizing: border-box; }

/* JalaliDatePicker popup overrides */
.jdp-container {
    font-family: 'Vazirmatn', Tahoma, Arial, sans-serif;
    direction: rtl;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem 0.75rem;
}

.jdp-container .jdp-day,
.jdp-container .jdp-day-name {
    font-weight: 600;
}

.jdp-container .jdp-day {
    padding: 0.35rem;
    border-radius: 0.45rem;
    transition: background var(--transition), color var(--transition);
}

.jdp-container .jdp-day.today,
.jdp-container .jdp-day.selected {
    background: var(--primary);
    color: #fff;
}

.jdp-container .jdp-footer {
    border-top: 1px solid var(--border);
    margin-top: 0.25rem;
    padding-top: 0.35rem;
    display: flex;
    justify-content: space-between;
}

.jdp-overlay {
    background: rgba(0, 0, 0, 0.35);
}

    .template-card .tpl-name {
        font-weight: 700;
        color: var(--text-primary);
    }

    .template-card .tpl-desc {
        font-size: 0.9rem;
        color: var(--text-secondary);
        line-height: 1.3;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    .template-card .tpl-meta {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 0.5rem;
        margin-top: 0.5rem;
    }

    .template-card .tpl-preview-btn {
        padding: 0.35rem 0.6rem;
        border-radius: 8px;
        border: none;
        background: var(--primary);
        color: #fff;
        font-weight: 600;
        cursor: pointer;
    }

    /* Modal for template preview */
    .modal-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(12, 18, 28, 0.55);
        display: none;
        align-items: center;
        justify-content: center;
        z-index: 9999;
        padding: 1rem;
    }

    .modal-backdrop.show {
        display: flex;
    }

    .template-modal {
        width: 100%;
        max-width: 900px;
        background: var(--bg-secondary);
        border-radius: 12px;
        box-shadow: var(--shadow-lg);
        padding: 1.25rem;
        transform: translateY(12px);
        opacity: 0;
        transition: transform var(--transition-slow), opacity var(--transition-slow);
    }

    .modal-backdrop.show .template-modal {
        transform: translateY(0);
        opacity: 1;
    }

    .template-modal .modal-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 1rem;
    }

    .template-modal .close-modal {
        background: transparent;
        border: none;
        font-size: 1.25rem;
        cursor: pointer;
    }

    .template-stages-grid {
        display: grid;
        gap: 0.75rem;
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        margin-top: 0.75rem;
    }

    .template-stage-card {
        padding: 0.65rem;
        border-radius: 8px;
        background: var(--bg-primary);
        border: 1px solid var(--border);
    }

    @media (max-width:720px) {
        .template-card {
            min-width: 160px;
        }

        .template-stages-grid {
            grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        }
    }

    /* small helpers */
    .btn-tab {
        padding: 0.35rem 0.8rem;
        border-radius: 10px;
        border: 1px solid var(--border);
        background: transparent;
        cursor: pointer;
    }

    .btn-tab.active {
        color: #fff;
        box-shadow: var(--shadow-sm);
        transform: translateY(-3px);
    }

    /* Variant styles for each tab type */
    .btn-tab--template.active {
        background: var(--primary-gradient);
        border-color: rgba(99, 102, 241, 0.25);
    }

    .btn-tab--manual.active {
        background: linear-gradient(135deg, #10b981 0%, #059669 100%);
        border-color: rgba(16, 185, 129, 0.25);
    }

    .btn-tab--single.active {
        background: linear-gradient(135deg, #06b6d4 0%, #0ea5b7 100%);
        border-color: rgba(6, 182, 212, 0.2);
    }

    /* Slightly larger, clearer tab appearance */
    .btn-tab {
        padding: 0.6rem 1.05rem;
        border-radius: 12px;
        font-weight: 700;
        font-size: 0.95rem;
    }

    /* Template card active emphasis */
    .template-card.active {
        box-shadow: var(--shadow-glow);
        border-color: var(--primary-dark);
        outline: 3px solid rgba(99, 102, 241, 0.06);
        transform: scale(1.03);
    }

    .template-card .tpl-name {
        font-size: 1.02rem;
    }

    .template-card .tpl-desc {
        font-size: 0.92rem;
    }

    /* Stage card selection */
    .stage-card {
        transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
        cursor: pointer;
    }

    .stage-card--active {
        box-shadow: 0 8px 24px rgba(16, 24, 40, 0.08);
        border-color: var(--primary);
        transform: translateY(-4px);
    }

    /* Manual stage active */
    .manual-stage-left {
        cursor: pointer;
    }

    .manual-stage-active {
        background: rgba(16, 185, 129, 0.06);
        border-radius: 6px;
        padding: 0.35rem;
    }

    /* Unified avatar styles used across templates
    - Use <div class="avatar avatar-sm"> or avatar-xl for sizing
    - If an <img class="avatar-img"> exists, it will fill the circle
    - Otherwise place a <span class="avatar-initial">X</span> inside
*/
    .avatar {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        overflow: hidden;
        color: #fff;
        font-weight: 700;
        background: var(--primary);
    }

    .avatar-img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }

    .avatar-initial {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100%;
        font-size: 1rem;
    }

    .avatar-sm {
        width: 40px;
        height: 40px;
    }

    .avatar-32 {
        width: 32px;
        height: 32px;
    }

    .avatar-xl {
        width: 84px;
        height: 84px;
        font-size: 1.1rem;
    }

    /* Additional avatar sizes for specific views */
    .avatar-lg {
        width: 96px;
        height: 96px;
        font-size: 1.15rem;
    }

    .avatar-xxl {
        width: 140px;
        height: 140px;
        font-size: 1.6rem;
    }

    /* Team member row in task details sidebar: prevent long names overflowing */
    .team-member-row {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        min-width: 0;
        overflow: hidden;
    }

    .team-member-row .avatar {
        flex-shrink: 0;
    }

    .team-member-row .member-info {
        flex: 1;
        min-width: 0;
        overflow: hidden;
    }

    .team-member-row .member-name {
        font-weight: 600;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .team-member-row .member-position {
        font-size: 0.82rem;
        color: var(--text-tertiary);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .team-member-row .badge {
        flex-shrink: 0;
    }

    /* On narrow screens ensure the sidebar card contents wrap gracefully */
    @media (max-width: 768px) {
        .team-member-row {
            gap: 0.5rem;
        }

        .team-member-row .member-name {
            font-size: 0.95rem;
        }
    }

    /* Size-specific initial font-sizes so the letter fills the circle visually */
    .avatar-sm .avatar-initial {
        font-size: 16px;
    }

    .avatar-32 .avatar-initial {
        font-size: 14px;
    }

    .avatar-xl .avatar-initial {
        font-size: 34px;
    }

    .avatar-lg .avatar-initial {
        font-size: 40px;
    }

    .avatar-xxl .avatar-initial {
        font-size: 64px;
    }

    /* Ensure initials are crisp and vertically centered */
    .avatar-initial {
        line-height: 1;
        font-weight: 700;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .avatar-fallback {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Small tweak so when image is present, it shows as circle */
    .avatar img.avatar-img {
        border-radius: 50%;
    }

    /* end Task Form UI */
    --topbar-height: 75px;
}

/* حالت تاریک */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --surface: #1e293b;
    --surface-hover: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --border: #334155;
    --border-light: #475569;
    /* ensure form inputs use dark background in dark mode */
    --input-bg: var(--bg-secondary);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    /* Badge / status color overrides for dark mode */
    --success-light: rgba(16,185,129,0.12);
    --success-dark: #34d399;
    --warning-light: rgba(245,158,11,0.12);
    --warning-dark: #f59e0b;
    --danger-light: rgba(239,68,68,0.12);
    --danger-dark: #f87171;
    --info-light: rgba(59,130,246,0.12);
    --info-dark: #60a5fa;
    --primary: #8b5cf6;
    --primary-dark: #7c3aed;
}

/* ============= ریست کلی ============= */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.9375rem;
    line-height: 1.7;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    direction: rtl;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    position: relative;
}

/* ============= تایپوگرافی ============= */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-primary);
}

h1 {
    font-size: 2.25rem;
}

h2 {
    font-size: 1.875rem;
}

h3 {
    font-size: 1.5rem;
}

h4 {
    font-size: 1.25rem;
}

h5 {
    font-size: 1.125rem;
}

h6 {
    font-size: 1rem;
}

p {
    margin-bottom: var(--space-md);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

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

/* استایل عمومی برای تصاویر داخل آواتارها */
.avatar-sm img,
.avatar-md img,
.avatar-lg img,
.avatar-xl img,
.user-avatar img,
.profile-avatar-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border-radius: 50%;
    display: block;
}

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

/* ============= لایوت ============= */
.layout {
    display: flex;
    min-height: 100vh;
    background: var(--bg-primary);
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    position: relative;
}

/* ============= سایدبار ============= */
/* Mobile Backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1400;
    /* Above topbar on mobile to dim everything */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

@media (max-width: 992px) {

    .sidebar.show~.sidebar-backdrop,
    .sidebar-backdrop.show {
        display: block;
        opacity: 1;
        pointer-events: auto;
    }
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-left: 1px solid var(--border);
    position: fixed;
    top: 0;
    right: 0;
    /* Use top+bottom instead of fixed 100vh to better handle mobile browser chrome
       (dynamic viewport) so the sidebar can resize when browser UI is shown/hidden */
    bottom: 0;
    height: auto;
    /* limit maximum height to viewport and avoid extra bottom-padding causing internal scrolling */
    max-height: calc(100dvh - 0px);
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.3s ease, var(--transition-slow);
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    padding-bottom: 0; /* remove extra bottom space */
}

/* Desktop: Sidebar همیشه نمایش */
@media (min-width: 993px) {
    .sidebar {
        transform: translateX(0);
    }
}

/* Mobile: Sidebar پنهان به صورت پیش‌فرض */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(100%);
        z-index: 1500;
        /* Ensure sidebar overlays topbar on mobile */
    }

    .sidebar.show {
        transform: translateX(0);
    }
}

/* Improve scrolling behaviour inside the fixed sidebar on touch devices
   when page/body scroll is locked (html.no-scroll / body.no-scroll). */
.sidebar {
    -webkit-overflow-scrolling: touch;
    touch-action: auto;
    overscroll-behavior: contain;
}

/* Ensure the sidebar still accepts touch/pointer events even if the page
   has a `no-scroll` helper that sets `touch-action: none` on html/body. */
html.no-scroll .sidebar,
body.no-scroll .sidebar {
    touch-action: auto !important;
    pointer-events: auto !important;
}

.sidebar.collapsed {
    width: 80px;
}


.sidebar.collapsed .sidebar-header {
    padding: var(--space-lg) var(--space-sm);
}

.sidebar.collapsed .sidebar-logo {
    justify-content: center;
}

.sidebar.collapsed .sidebar-logo h2 {
    display: none;
}

.sidebar.collapsed .sidebar-logo i {
    font-size: 2rem;
}

.sidebar.collapsed .sidebar-nav {
    padding: var(--space-md) var(--space-sm);
}

.sidebar.collapsed .sidebar-section-title {
    text-align: center;
    font-size: 0.5rem;
    padding: 0;
}

.sidebar.collapsed .sidebar-menu a {
    justify-content: center;
    padding: 0.875rem var(--space-sm);
}

.sidebar.collapsed .sidebar-menu span {
    display: none;
}

.sidebar.collapsed .sidebar-menu a i {
    font-size: 1.5rem;
}

.sidebar-header {
    /* reduce top/header padding to save vertical space */
    padding: var(--space-md);
    border-bottom: 1px solid var(--border);
    background: var(--primary-gradient);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.sidebar-logo i {
    font-size: 2.5rem;
    color: white;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.sidebar-logo h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Activity log badges */
.type-badge {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 999px;
    color: #fff;
    font-weight: 600;
    font-size: 0.85rem;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
}

.type-badge.type-task {
    background: var(--type-task);
}

.type-badge.type-file {
    background: var(--type-file);
}

.type-badge.type-attendance {
    background: var(--type-attendance);
    color: #222;
}

.type-badge.type-system {
    background: var(--type-system);
}

.type-badge.type-other {
    /* Make 'other' badges more readable (not pure white) */
    background: #eef2f7;
    color: #22303f;
}

/* Add explicit style for task_assignment (not present in older CSS) */
.type-badge.type-task_assignment {
    background: var(--type-task);
    color: #fff;
}

/* Avatar styles */
.avatar-xl,
.avatar-lg,
.avatar-md,
.avatar-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    overflow: hidden;
    color: #fff;
}

.avatar-xl {
    width: 84px;
    height: 84px;
    font-size: 28px;
}

.avatar-lg {
    width: 56px;
    height: 56px;
    font-size: 18px;
}

.avatar-md {
    width: 40px;
    height: 40px;
    font-size: 14px;
}

.avatar-sm {
    width: 36px;
    height: 36px;
    font-size: 13px;
}

/* Avatar gradients (rotating palette) */
.avatar-gradient-1 {
    background: linear-gradient(135deg, #7c4dff, #a78bfa);
}

.avatar-gradient-2 {
    background: linear-gradient(135deg, #4f46e5, #06b6d4);
}

.avatar-gradient-3 {
    background: linear-gradient(135deg, #06b6d4, #34d399);
}

.avatar-gradient-4 {
    background: linear-gradient(135deg, #f97316, #fb7185);
}

.avatar-gradient-5 {
    background: linear-gradient(135deg, #60a5fa, #7c3aed);
}

/* Stacked avatars in tasks list */
.avatars-group {
    display: flex;
    align-items: center;
    gap: -10px;
}

.avatars-group {
    display: flex;
    align-items: center;
}

.avatars-group .avatar-sm {
    margin-left: -10px;
    border: 2px solid var(--surface);
    box-shadow: var(--shadow-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.avatars-group .avatar-sm {
    z-index: 1
}

.avatars-group .avatar-sm:nth-child(1) {
    z-index: 5
}

.avatars-group .avatar-sm:nth-child(2) {
    z-index: 4
}

.avatars-group .avatar-sm:nth-child(3) {
    z-index: 3
}

.avatars-group .avatar-sm:nth-child(4) {
    z-index: 2
}

.avatars-group .avatar-sm:nth-child(5) {
    z-index: 1
}

.avatar-initial {
    color: #fff;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    display: inline-block;
}

.avatar-xl .avatar-initial {
    font-size: 32px;
    line-height: 84px;
}

.avatar-xl {
    color: #fff;
}

.avatar-sm {
    font-size: 13px;
    line-height: 36px;
}

/* =====================
     Profile page styles
     ===================== */
.profile-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-lg);
}

.profile-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: var(--space-lg);
    align-items: start;
}

.profile-forms {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.profile-card {
    position: sticky;
    top: calc(var(--topbar-height) + var(--space-sm));
    padding-bottom: var(--space-lg);
}

.profile-cover {
    height: 150px;
    border-radius: var(--radius);
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.12), rgba(124, 77, 255, 0.08));
    display: block;
    overflow: hidden;
    margin-bottom: calc(var(--space-md));
    position: relative;
}

.profile-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block
}

.profile-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    text-align: center;
    padding: var(--space-md) var(--space-md) 0 var(--space-md);
}

.profile-avatar-large {
    width: 110px;
    height: 110px;
    margin-top: -56px;
    border-radius: 50%;
    overflow: hidden;
    border: 4px solid var(--surface);
    box-shadow: var(--shadow-md);
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-header h2 {
    margin-top: 4px;
    font-size: 1.25rem
}

.profile-header p {
    color: var(--text-secondary);
    font-size: 0.95rem
}

.profile-actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: 6px
}

.profile-actions .btn {
    padding: 0.5rem 0.9rem;
    font-weight: 600
}

.profile-stats {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-md);
    justify-content: center
}

.profile-stats .stat {
    background: var(--bg-secondary);
    padding: 10px 14px;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    text-align: center;
    min-width: 90px
}

.profile-stats .stat h3 {
    margin: 0;
    font-size: 1.05rem
}

.profile-stats .stat p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.85rem
}

.profile-contact {
    padding: var(--space-md);
    border-top: 1px dashed var(--border);
    display: flex;
    flex-direction: column;
    gap: 6px
}

.profile-contact .line {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center
}

.profile-contact .line .label {
    color: var(--text-secondary);
    font-size: 0.9rem
}

.profile-contact .line .value {
    color: var(--text-primary);
    font-weight: 600
}

/* Cards inside main column should match site cards */
.profile-forms .card {
    overflow: visible
}

/* Responsive */
@media (max-width: 900px) {
    .profile-grid {
        grid-template-columns: 1fr;
    }

    .profile-card {
        position: relative;
        top: auto;
    }

    .profile-avatar-large {
        margin-top: -42px;
        width: 90px;
        height: 90px
    }
}

@media (max-width: 480px) {
    .profile-container {
        padding: var(--space-md)
    }

    .profile-header h2 {
        font-size: 1.05rem
    }

    .profile-header p {
        font-size: 0.85rem
    }
}

.avatars-group .avatar-sm img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* == Employees grid: make cards equal-height and content flow == */
.employees-grid {
    /* ensure each grid row will distribute available space so items can stretch */
    grid-auto-rows: 1fr;
    align-items: stretch;
}

.employee-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    /* let the card fill the grid cell */
}

.employee-card .card-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    /* allow body to grow so footer/actions can stick to bottom */
}

.employee-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    /* take remaining space so actions can be bottom-aligned */
}

.employee-actions {
    margin-top: auto;
    /* push actions to the bottom */
    display: flex;
    gap: .5rem;
}

/* Make long emails/contacts wrap cleanly instead of expanding the card height unpredictably */
.employee-contact {
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: normal;
}

/* Small tweak to ensure avatar initials remain vertically centered */
.avatar-xl .avatar-initial {
    display: inline-block;
    vertical-align: middle;
}

/* Employee stat boxes: force single-row, equal width */
.employee-stats {
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
    align-items: stretch;
    flex-wrap: nowrap;
    /* keep them on one row */
}

.employee-stats .stat {
    flex: 1 1 0%;
    /* equal width columns */
    min-width: 0;
    /* allow text to truncate/wrap inside */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: .6rem;
    border-radius: 10px;
    background: var(--bg-tertiary);
    text-align: center;
}

.employee-stats .stat-number {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
}

.employee-stats .stat-label {
    font-size: .8rem;
    color: var(--text-secondary);
}

/* On very small screens allow wrap to avoid overflow */
@media (max-width: 420px) {
    .employee-stats {
        flex-wrap: wrap;
    }
}

/* Ensure the header (name + avatar + status) area is consistent height so
   cards align even when names wrap. */
.employee-top {
    min-height: 130px;
}

/* Contact line: keep numbers and plus sign left-to-right and centered */
.contact-line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    direction: ltr;
}

.contact-text {
    color: var(--text-secondary);
    font-size: .92rem;
    word-break: break-word;
}

.contact-icon {
    color: var(--text-tertiary);
    font-size: 0.95rem;
}

@media (max-width: 520px) {
    .employee-top {
        min-height: 110px;
    }
}

/* Employee card hover */
.employee-card {
    transition: transform 180ms ease, box-shadow 180ms ease;
}

.employee-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-md);
}

/* Buttons inside cards */
.employee-card .btn {
    border-radius: 10px;
}


.sidebar-nav {
    /* use slightly smaller nav padding so sidebar content fits without extra scrolling */
    padding: var(--space-md);
}

.sidebar-section {
    /* reduce spacing between sections */
    margin-bottom: var(--space-md);
}

.sidebar-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-tertiary);
    margin-bottom: var(--space-md);
    padding-right: var(--space-md);
}

.sidebar-menu {
    list-style: none;
}

.sidebar-menu li {
    margin-bottom: var(--space-xs);
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 0.875rem var(--space-md);
    color: var(--text-secondary);
    border-radius: var(--radius-lg);
    transition: var(--transition);
    font-weight: 500;
    font-size: 0.9375rem;
    position: relative;
    overflow: hidden;
}

/* Activity logs table tweaks */
.table-wrapper {
    overflow-x: auto;
}

.activity-message {
    max-width: 60ch;
    word-break: break-word;
}

.activity-target {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Activity logs visual improvements */
.activity-logs .table thead th {
    /* stronger header surface so column labels are readable above badge buttons */
    background: linear-gradient(180deg, var(--bg-tertiary), #eef4fb) !important;
    color: var(--text-primary) !important;
    font-weight: 700;
    border-bottom: 1px solid var(--border) !important;
    padding: .65rem .75rem !important;
}

/* Make the Priority/Type header stand out more (3rd column) */
.activity-logs .table thead th:nth-child(3) {
    background: linear-gradient(180deg, #f0f4ff, #eef6ff) !important;
    box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.02) !important;
    border-radius: 8px !important;
}

.activity-logs .table tbody tr {
    background: transparent;
}

.activity-logs .log-summary-row {
    /* Use white rows with subtle border for good contrast */
    background: #ffffff !important;
    border-bottom: 1px solid var(--border) !important;
}

/* Keep alternating rows visually identical but ensure contrast */
.activity-logs .table tbody tr.log-summary-row:nth-child(even) {
    background: #ffffff !important;
}

.activity-logs .log-details-row {
    background: rgba(248, 250, 252, 0.98);
}

.activity-logs .type-badge {
    box-shadow: none;
}

/* Buttons in activity log: stronger contrast */
.activity-logs .btn {
    border-radius: 10px;
}

.activity-logs .btn-outline-light,
.activity-logs .btn-outline-secondary {
    /* Use a muted surface instead of white for contrast */
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    box-shadow: none;
}

.activity-logs .details-toggle {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
}

/* Avatar contrast */
.activity-logs .avatar {
    /* avoid pure white stops; use soft neutral gradient */
    background: linear-gradient(135deg, #eef3f8, #f1f5f9);
    color: var(--text-secondary);
}

/* Make badges slightly more saturated and solid for readability */
.activity-logs .type-badge.type-task {
    background: var(--type-task) !important;
    color: #fff !important;
    border: none !important;
    padding: 6px 10px !important;
    border-radius: 999px !important;
    font-weight: 700 !important;
}

.activity-logs .type-badge.type-file {
    background: var(--type-file) !important;
    color: #fff !important;
    padding: 6px 10px !important;
    border-radius: 999px !important;
    font-weight: 700 !important;
}

.activity-logs .type-badge.type-attendance {
    background: var(--type-attendance) !important;
    color: #111 !important;
    padding: 6px 10px !important;
    border-radius: 999px !important;
    font-weight: 700 !important;
}

.activity-logs .type-badge.type-system {
    background: var(--type-system) !important;
    color: #fff !important;
    box-shadow: 0 6px 18px rgba(255, 107, 107, 0.12) !important;
    padding: 6px 10px !important;
    border-radius: 999px !important;
    font-weight: 700 !important;
}

.activity-logs .type-badge.type-other {
    background: var(--text-secondary) !important;
    color: var(--bg-primary) !important;
    padding: 6px 10px !important;
    border-radius: 999px !important;
    font-weight: 700 !important;
}

/* Specific badge classes used in activity_logs template */
.activity-logs .badge-task {
    background: var(--primary-light) !important;
    color: var(--primary) !important;
    border: 1px solid rgba(99, 102, 241, 0.12) !important;
    padding: 6px 10px !important;
    border-radius: 8px !important;
    font-weight: 700 !important;
}

.activity-logs .badge-user {
    background: var(--success-light) !important;
    color: var(--success-dark) !important;
    border: 1px solid rgba(6, 95, 70, 0.06) !important;
    padding: 6px 10px !important;
    border-radius: 8px !important;
    font-weight: 700 !important;
}

.activity-logs .badge-user-empty,
.activity-logs .badge-file-empty,
.activity-logs .badge-generic {
    background: var(--bg-tertiary) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-light) !important;
    padding: 6px 10px !important;
    border-radius: 8px !important;
}

.activity-logs .badge-file {
    background: var(--info-light) !important;
    color: var(--info) !important;
    border: 1px solid rgba(59, 130, 246, 0.08) !important;
    padding: 6px 10px !important;
    border-radius: 8px !important;
}

/* Action badge spacing */
.activity-logs .action-badge {
    margin-left: 6px !important;
}

/* Status pill: base padding and rounded shape; background and color set inline from template for accurate mapping */
.activity-logs .status-pill {
    padding: 6px 10px !important;
    border-radius: 8px !important;
    font-size: .95rem !important;
    font-weight: 700 !important;
}

/* Avatar colors per log type */
.activity-logs .avatar.type-task {
    background: var(--type-task);
    color: #fff;
}

.activity-logs .avatar.type-file {
    background: var(--type-file);
    color: #fff;
}

.activity-logs .avatar.type-attendance {
    background: var(--type-attendance);
    color: #222;
}

.activity-logs .avatar.type-system {
    background: var(--type-system);
    color: #fff;
}

.activity-logs .avatar.type-other {
    background: #eef2f7;
    color: #123;
}

.activity-logs .avatar .avatar-initial {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-weight: 700;
}

.activity-logs .avatar img.avatar-img {
    display: block;
    width: 100%;
    height: 100%;
}

/* Action badges (color by action severity/type) */
/* Override action badges to be clear and saturated */
.activity-logs .action-badge {
    display: inline-block;
    padding: 6px 10px !important;
    border-radius: 999px !important;
    font-weight: 700 !important;
    font-size: 0.82rem !important;
    color: #fff !important;
    background: var(--border) !important;
    box-shadow: 0 6px 18px rgba(15,23,42,0.04) !important;
}

.activity-logs .action-badge.action-comment_added,
.activity-logs .action-badge.action-comment {
    background: #2563eb !important;
}

.activity-logs .action-badge.action-comment_deleted {
    background: #dc2626 !important;
}

.activity-logs .action-badge.action-stage_toggled,
.activity-logs .action-badge.action-assignment_stage {
    background: var(--type-task) !important;
}

.activity-logs .action-badge.action-upload {
    background: var(--type-file) !important;
}

.activity-logs .action-badge.action-create {
    background: #7c4dff !important;
}

.activity-logs .action-badge.action-assign {
    background: #0ea5a4 !important;
}

.activity-logs .action-badge.action-submit {
    background: #059669 !important;
}

.activity-logs .action-badge.action-security_review {
    background: #ef4444 !important;
}

.activity-logs .action-badge.action-backup {
    background: #475569 !important;
}

.activity-logs .action-badge.action-update {
    background: #0891b2 !important;
}

.activity-logs .action-badge.action-pass {
    background: #059669 !important;
}

.activity-logs .action-badge.action-other {
    background: #6b7280 !important;
    color: #fff !important;
}

/* Ensure table text is readable (override any inline styles that made text white) */
.activity-logs table,
.activity-logs table th,
.activity-logs table td {
    color: var(--text-primary) !important;
}

/* Message and target text should be dark and readable */
.activity-logs .activity-message,
.activity-logs .activity-message * {
    color: var(--text-primary) !important;
}

.activity-logs .activity-target a,
.activity-logs .activity-target a * {
    color: var(--primary) !important;
    font-weight: 600 !important;
}

/* View button: prominent primary gradient with white text */
/* Mild, non-intrusive primary for 'View' */
.activity-logs a.btn.btn-view,
.activity-logs .btn.btn-view {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark)) !important;
    color: #fff !important;
    border: none !important;
    box-shadow: 0 8px 26px rgba(99,102,241,0.18) !important;
    padding: .45rem .75rem !important;
    border-radius: 10px !important;
}

.activity-logs a.btn.btn-view:hover,
.activity-logs .btn.btn-view:hover {
    filter: brightness(1.02) !important;
}

/* Details button: muted but visible */
.activity-logs a.btn.btn-details,
.activity-logs .btn.btn-details {
    background: linear-gradient(180deg, #fbfdff, #f5f7fb) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border) !important;
    padding: .35rem .6rem !important;
    border-radius: 8px !important;
}

.activity-logs a.btn.btn-details:hover,
.activity-logs .btn.btn-details:hover {
    background: linear-gradient(180deg, #f1f5f9, #eef2f6) !important;
}

/* Disabled appearances */
.activity-logs .btn-view[disabled],
.activity-logs .btn-view:disabled,
.activity-logs .btn-details[disabled],
.activity-logs .btn-details:disabled {
    opacity: .6 !important;
    cursor: not-allowed !important;
}

/* Ensure action/type badges always show readable text */
.activity-logs .type-badge,
.activity-logs .action-badge {
    color: #fff !important;
}

/* Metadata pre block additional safety */
.activity-logs .log-meta {
    white-space: pre-wrap;
    background: var(--bg-tertiary) !important;
    padding: 8px !important;
    border-radius: 6px !important;
    border: 1px solid var(--border) !important;
    color: var(--text-primary) !important;
}

/* Buttons: avoid pure white even for outline variants */
.activity-logs .btn-outline-light,
.activity-logs .btn-outline-secondary {
    /* use tertiary surface to avoid pure white */
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border) !important;
}

.activity-logs .details-toggle {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
}

/* Ensure buttons inside activity-logs are clearly visible (no pure white) */
.activity-logs .btn,
.activity-logs .btn-sm {
    /* Use a slightly tinted surface for better contrast in the logs area */
    background: linear-gradient(180deg, #eef2ff, #f4f6ff) !important;
    color: var(--text-primary) !important;
    border: 1px solid rgba(227, 233, 255, 0.6) !important;
    box-shadow: 0 4px 18px rgba(99, 102, 241, 0.04) !important;
}

.activity-logs .btn[disabled],
.activity-logs .btn:disabled {
    background: var(--bg-tertiary) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-light) !important;
    opacity: 1 !important;
}

/* Badge light overrides inside activity logs: avoid white backgrounds */
.activity-logs .badge.badge-light,
.activity-logs .badge-light {
    /* avoid white badges inside activity logs */
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border) !important;
}

/* Pre / metadata block styling - avoid white */
.activity-logs pre {
    /* ensure pre blocks are not pure white (override inline if present) */
    background: var(--bg-tertiary) !important;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid var(--border) !important;
    color: var(--text-primary) !important;
}

/* Ensure header title and muted text are readable */
.activity-logs .page-header h1,
.activity-logs .page-header p,
.activity-logs .card-header h3 {
    color: var(--text-primary);
}

.activity-logs .text-muted {
    color: var(--text-secondary) !important;
}

/* Make the action/type area horizontally aligned and more compact */
.activity-logs .type-badge,
.activity-logs .action-badge {
    box-shadow: none;
}

/* Additional explicit badge colors for various log target types */
.activity-logs .type-badge.type-task_assignment {
    background: linear-gradient(135deg, #7c4dff, #9b6bff) !important;
    color: #fff !important;
}

.activity-logs .type-badge.type-report {
    background: #6f42c1 !important;
    color: #fff !important;
}

.activity-logs .type-badge.type-test {
    background: #10b981 !important;
    color: #fff !important;
}

.activity-logs .type-badge.type-backup {
    background: #64748b !important;
    color: #fff !important;
}

.activity-logs .type-badge.type-user {
    background: #0ea5a4 !important;
    color: #fff !important;
}

.activity-logs .type-badge.type-comment {
    background: #3b82f6 !important;
    color: #fff !important;
}

.activity-logs .type-badge.type-notification {
    background: #f97316 !important;
    color: #fff !important;
}

.activity-logs .type-badge.type-other {
    background: #cfe8ff !important;
    color: #08324a !important;
}


@media (max-width: 768px) {
    .activity-logs .activity-message {
        max-width: 40ch;
    }
}

.sidebar-menu a::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    background: var(--primary-gradient);
    transform: scaleY(0);
    transition: var(--transition);
}

.sidebar-menu a:hover {
    background: linear-gradient(to left, rgba(99, 102, 241, 0.1), transparent);
    color: var(--primary);
    /* transform: translateX(-4px); */
}

.sidebar-menu a:hover::before {
    transform: scaleY(1);
}

.sidebar-menu a.active {
    background: var(--primary-gradient);
    color: white;
    box-shadow: var(--shadow-colored);
    font-weight: 600;
}

.sidebar-menu a.active::before {
    display: none;
}

.sidebar-menu a i {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
    transition: var(--transition);
}

.sidebar-menu a:hover i {
    transform: scale(1.1);
}

.sidebar.collapsed .sidebar-menu a:hover {
    transform: translateX(0) scale(1.05);
}

/* ============= محتوای اصلی ============= */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: var(--transition-slow);
    width: 100%;
    overflow-x: hidden;
}

/* Desktop: با margin برای sidebar */
@media (min-width: 993px) {
    .main-content {
        margin-right: var(--sidebar-width);
    }

    .main-content.expanded {
        margin-right: 80px;
    }
}

/* Mobile: بدون margin، تمام عرض */
@media (max-width: 992px) {
    .main-content {
        margin-right: 0;
    }
}

/* ============= نوار بالا ============= */
.topbar {
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-xl);
    position: sticky;
    top: 0;
    z-index: 1100;
    box-shadow: var(--shadow-sm);
    overflow: visible;
}

/* Global table cell padding to ensure content has breathing room across pages */
.table th,
.table td {
    padding: 12px 16px;
}

/* Dashboard employee - My Tasks card list */
.dashboard-employee .tasks-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.dashboard-employee .task-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    transition: transform .16s ease, box-shadow .16s ease;
}

.dashboard-employee .task-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.dashboard-employee .task-main {
    flex: 1 1 60%;
    text-align: right;
    min-width: 0;
}

.dashboard-employee .task-title {
    margin: 0 0 6px 0;
    font-size: 1.05rem;
}

.dashboard-employee .task-title a {
    color: var(--primary);
    font-weight: 700;
}

.dashboard-employee .task-desc {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.dashboard-employee .task-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 240px;
    justify-content: flex-end;
}

.dashboard-employee .task-badges {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.dashboard-employee .task-deadline {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-align: center;
}

.dashboard-employee .task-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.dashboard-employee .task-actions .btn {
    white-space: nowrap;
}

@media (max-width: 800px) {
    .dashboard-employee .task-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .dashboard-employee .task-meta {
        width: 100%;
        justify-content: space-between;
        margin-top: 0.5rem;
    }
}


.topbar-left {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.topbar-search {
    position: relative;
    width: 400px;
}

.topbar-search input {
    width: 100%;
    padding: 0.75rem 3rem 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    font-size: 0.875rem;
    transition: var(--transition);
    color: var(--text-primary);
    font-family: inherit;
}

.topbar-search input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.topbar-search i {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: 1rem;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex-shrink: 0;
}

.topbar-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.topbar-btn.mobile-toggle {
    display: none;
}

.topbar-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-colored);
}

.topbar-btn .badge {
    position: absolute;
    top: -4px;
    left: -4px;
    min-width: 20px;
    height: 20px;
    background: var(--danger);
    color: white;
    border-radius: var(--radius-full);
    font-size: 0.625rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--surface);
}

.theme-toggle {
    background: var(--bg-tertiary);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.25rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background: var(--primary);
    color: white;
    transform: rotate(180deg);
    box-shadow: var(--shadow-colored);
}

.user-menu {
    position: relative;
    z-index: 100;
}

.user-menu-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    position: relative;
    z-index: 101;
}

.user-menu-toggle:hover,
.user-menu-toggle:focus,
.user-menu-toggle:active {
    background: var(--surface-hover);
    box-shadow: var(--shadow);
    outline: none;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1rem;
    box-shadow: var(--shadow-colored);
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    overflow: hidden;
    flex-shrink: 0;
}

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

.page-header {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius-lg) + 0.25rem);
    padding: 1.25rem 1.5rem;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-header .page-header-left,
.page-header .page-header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.page-header .page-header-left h1 {
    margin: 0;
    font-size: 1.6rem;
}

.page-header .page-header-left p {
    margin: 0;
    color: var(--text-secondary);
}

@media (max-width: 992px) {
    .page-header {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .page-header .page-header-left,
    .page-header .page-header-right {
        justify-content: center;
    }
}

.user-info {
    text-align: right;
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.user-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    display: block;
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    display: block;
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.user-menu {
    position: relative;
}

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    left: 0;
    right: auto;
    min-width: 240px;
    max-width: calc(100vw - 2rem);
    /* background: var(--surface); */
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-slow);
    z-index: 10000;
    overflow: hidden;
    pointer-events: none;
}

.user-menu-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
    background: var(--surface);
}

.user-menu-dropdown ul {
    list-style: none;
    padding: var(--space-sm);
}

.user-menu-dropdown li a {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 0.875rem var(--space-lg);
    color: var(--text-secondary);
    border-radius: var(--radius-lg);
    transition: var(--transition);
    font-weight: 500;
    font-size: 0.9375rem;
}

.user-menu-dropdown li a:hover {
    /* Ensure good contrast on hover: light background + dark text */
    background: var(--surface-hover);
    color: var(--text-primary);
    transform: translateX(-2px);
}

.user-menu-dropdown li a i {
    font-size: 1.125rem;
}

.user-menu-dropdown li a i {
    width: 20px;
    text-align: center;
}

/* Notification Dropdown */
.topbar-btn-wrapper {
    position: relative;
}

.topbar-btn {
    position: relative;
}

.notification-dropdown {
    /* Inline styles handle visibility - keep only styling here */
    overflow: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.notification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border);
    /* background: var(--bg-tertiary); */
}

.notification-header h4 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

.notification-header .badge {
    /* background: var(--primary); */
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.notification-list {
    max-height: 350px;
    overflow-y: auto;
}

.notification-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    position: relative;
}

.notification-item:last-child {
    border-bottom: none;
}

.notification-item:hover {
    background: var(--bg-tertiary);
    /* transform: translateX(-4px); */
}

.notification-item.unread {
    background: linear-gradient(to left, transparent, rgba(99, 102, 241, 0.05));
    /* border-right: 3px solid var(--primary); */
}

.notification-item.unread:hover {
    background: linear-gradient(to left, transparent, rgba(99, 102, 241, 0.1));
}

.notification-close {
    position: absolute;
    top: 8px;
    left: 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    opacity: 0;
    z-index: 10;
}

.notification-item:hover .notification-close {
    opacity: 1;
}

.notification-close:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    transform: scale(1.1);
}

.notification-read-toggle {
    position: absolute;
    top: 8px;
    left: 36px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    opacity: 0;
    z-index: 10;
}

.notification-item:hover .notification-read-toggle {
    opacity: 1;
}

.notification-read-toggle:hover {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
    transform: scale(1.1);
}

.notification-item.unread .notification-read-toggle {
    color: var(--success);
}

.notification-item:not(.unread) .notification-read-toggle {
    color: var(--text-secondary);
}

.notification-item i.notification-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-gradient);
    color: white;
    border-radius: var(--radius-full);
    font-size: 1.125rem;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
}

.notification-item.unread i.notification-icon {
    animation: pulse-icon 2s ease-in-out infinite;
}

@keyframes pulse-icon {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

.notification-content {
    flex: 1;
}

.notification-content p {
    margin: 0 0 0.25rem 0;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.875rem;
}

.notification-content .time {
    color: var(--text-tertiary);
    font-size: 0.75rem;
}

.notification-footer {
    padding: var(--space-md);
    text-align: center;
    border-top: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.notification-footer a {
    color: var(--primary);
    font-weight: 600;
    font-size: 0.875rem;
    transition: var(--transition);
}

.notification-footer a:hover {
    color: var(--primary-dark);
}

/* ============= محتوا ============= */
.content {
    flex: 1;
    padding: var(--space-2xl);
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

.page-header {
    margin-bottom: var(--space-2xl);
}

.page-header h1 {
    font-size: 2rem;
    margin-bottom: var(--space-sm);
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    /* -webkit-text-fill-color: transparent; */
}

/* ============= کارت‌ها ============= */
.card-container {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow);
    transition: var(--transition);
    border: 1px solid var(--border);
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    padding: 0px;
}

.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow);
    transition: var(--transition);
    border: 1px solid var(--border);
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-lg);
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.card-body {
    color: var(--text-secondary);
}

/* ============= کارت‌های آمار ============= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-2xl);
    width: 100%;
    box-sizing: border-box;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    border: 1px solid var(--border);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100px;
    height: 100px;
    background: var(--primary-gradient);
    opacity: 0.05;
    border-radius: 50%;
    transform: translate(-30%, -30%);
}

.stat-card:hover {
    box-shadow: var(--shadow-xl);
    transform: translateY(-4px);
    border-color: var(--primary);
}

.stat-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    background: var(--primary-gradient);
    color: white;
    box-shadow: var(--shadow-colored);
}

.stat-icon.success {
    background: var(--success-gradient);
}

.stat-icon.warning {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.stat-icon.info {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: var(--space-sm);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

/* ============= دکمه‌ها ============= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.875rem;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: var(--shadow-colored);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-primary);
    border: 2px solid var(--border);
}

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

.btn-success {
    background: var(--success-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-danger {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    color: white;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1rem;
}

/* ============= فرم‌ها ============= */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    margin-bottom: var(--space-sm);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.form-control {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 0.9375rem;
    transition: var(--transition);
    font-family: inherit;
    direction: rtl;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.form-control::placeholder {
    color: var(--text-tertiary);
}

textarea.form-control {
    resize: vertical;
    min-height: 120px;
}

/* ============= بج‌ها ============= */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 0.32rem 0.6rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-primary {
    background: var(--primary-light, rgba(99, 102, 241, 0.15));
    color: var(--primary);
}

.badge-success {
    background: var(--success-light);
    color: var(--success-dark);
}

.badge-warning {
    background: var(--warning-light);
    color: var(--warning-dark);
}

.badge-danger {
    background: var(--danger-light);
    color: var(--danger-dark);
}

.badge-info {
    background: var(--info-light);
    color: var(--info-dark);
}

/* Priority Badges */
.badge-low {
    background: linear-gradient(135deg, #d4fc79 0%, #96e6a1 100%);
    color: #1e7e34;
    box-shadow: 0 2px 8px rgba(150, 230, 161, 0.3);
}

.badge-medium {
    background: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
    color: #004085;
    box-shadow: 0 2px 8px rgba(143, 211, 244, 0.3);
}

.badge-high {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    color: #856404;
    box-shadow: 0 2px 8px rgba(254, 225, 64, 0.3);
}

.badge-urgent {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(245, 87, 108, 0.4);
    animation: pulse-urgent 2s ease-in-out infinite;
}

@keyframes pulse-urgent {

    0%,
    100% {
        box-shadow: 0 2px 8px rgba(245, 87, 108, 0.4);
    }

    50% {
        box-shadow: 0 4px 16px rgba(245, 87, 108, 0.6);
    }
}

/* Status Badges */
.badge-pending {
    background: var(--warning-light);
    color: var(--warning-dark);
}

.badge-in_progress {
    background: var(--info-light);
    color: var(--info-dark);
}

.badge-submitted {
    background: var(--primary-light, rgba(99, 102, 241, 0.15));
    color: var(--primary);
}

.badge-completed {
    background: var(--success-light);
    color: var(--success-dark);
}

.badge-cancelled,
.badge-rejected {
    background: var(--danger-light);
    color: var(--danger-dark);
}

/* ======= Override for status cards (inline styles in templates) ======= */
/* Templates often include inline styles for `.card.status-card`; these rules
   force them to follow theme variables so dark/light themes stay consistent. */
.card.status-card {
    background: var(--surface) !important;
    color: var(--text-primary) !important;
    box-shadow: 0 8px 24px rgba(2, 6, 23, 0.06) !important;
    margin: 10px !important;
    padding: 12px !important;
    border-radius: 14px !important;
}
.card.status-card .card-title {
    color: var(--text-primary) !important;
}
.card.status-card .card-title i {
    color: var(--text-tertiary) !important;
}
.status-card .quick-select-large {
    border: 1px solid var(--border) !important;
    background: var(--surface) !important;
    color: var(--text-primary) !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04) !important;
}
.status-card .quick-select-small {
    border: 1px solid var(--border) !important;
    background: var(--surface) !important;
    color: var(--text-primary) !important;
}
.btn-complete {
    background: linear-gradient(135deg, var(--success) 0%, var(--success-dark) 100%) !important;
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.08) !important;
}


/* ============= جداول ============= */
.table-wrapper {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* جلوگیری از اسکرول افقی غیرضروری */
    scrollbar-width: thin;
}

.table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
    table-layout: fixed;
    /* جلوگیری از overflow در hover */
    transform: translateZ(0);
    text-align: center !important;
}

.table thead {
    background: var(--bg-tertiary);
}

.table th {
    padding: 1rem 1.5rem;
    text-align: right;
    font-weight: 700;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    text-align: center !important;
}

/* عرض ثابت برای ستون‌های جدول تسک‌ها */
.table th:nth-child(1) {
    width: 35%;
}

/* تسک */
.table th:nth-child(2) {
    width: 12%;
}

/* اولویت */
.table th:nth-child(3) {
    width: 15%;
}

/* مهلت */
.table th:nth-child(4) {
    width: 12%;
}

/* وضعیت */
.table th:nth-child(5) {
    width: 13%;
}

/* اختصاص یافته به */
.table th:nth-child(6) {
    width: 13%;
}

/* عملیات */

.table td {
    padding: 1rem 1.5rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    text-align: center !important;
    vertical-align: middle;
}

/* استایل برای ستون تسک */
.table .task-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-width: 100%;
}

.table .task-info h4 {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table .task-info p {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--text-tertiary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table tr:hover {
    background: var(--surface-hover);
}

.table tr:last-child td {
    border-bottom: none;
}

/* دکمه‌های عملیات در جدول */
.table td .btn-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    margin-left: 0.25rem;
    margin-bottom: 0.25rem;
}

.table td .btn-sm span {
    display: inline;
}

/* استایل برای گروه آواتارها */
.avatars-group {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* ============= الرت‌ها و توست‌ها ============= */
#toast-container {
    position: fixed;
    top: 90px;
    left: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    /* max-width: 400px; */
}

.alert {
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    margin-bottom: var(--space-lg);
    border-right: 4px solid;
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    font-size: 0.9375rem;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }

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

.alert-dismissible {
    position: relative;
    padding-left: 3rem;
}

.alert-close {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.6;
    transition: var(--transition);
}

.alert-close:hover {
    opacity: 1;
}

.alert-success {
    background: var(--success-light);
    border-color: var(--success);
    color: var(--success-dark);
}

.alert-warning {
    background: var(--warning-light);
    border-color: var(--warning);
    color: var(--warning-dark);
}

.alert-danger {
    background: var(--danger-light);
    border-color: var(--danger);
    color: var(--danger-dark);
}

.alert-info {
    background: var(--info-light);
    border-color: var(--info);
    color: var(--info-dark);
}

/* ============= صفحه لاگین ============= */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-gradient);
    position: relative;
    overflow: hidden;
}

.auth-page::before {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    top: -250px;
    left: -250px;
}

.auth-page::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    bottom: -200px;
    right: -200px;
}

.auth-card {
    width: 100%;
    max-width: 480px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-2xl);
    padding: var(--space-3xl);
    box-shadow: 0 35px 60px -15px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.4);
    position: relative;
    z-index: 1;
}

.auth-header {
    text-align: center;
    margin-bottom: var(--space-2xl);
}

.auth-logo {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--space-lg);
    background: white;
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    background: var(--primary-gradient);
    color: white;
    box-shadow: var(--shadow-xl);
}

.auth-header h1 {
    font-size: 2rem;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.auth-form .btn-primary {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    margin-top: var(--space-lg);
}

/* ============= صفحه حضور و غیاب ============= */
.filter-group {
    width: 100%;
}

.filter-group .form-control {
    width: 100%;
}

.employee-cell {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    min-width: 180px;
}

/* Ensure employee name alignment is consistent (RTL) in attendance lists */
.employee-cell {
    direction: rtl !important;
    justify-content: flex-start !important;
}

.employee-cell span {
    display: block;
    text-align: right !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Active task title shown under 'در حال کار' in attendance page */
.active-task-title {
    margin-top: 0.25rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    max-width: 28rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 768px) {
    .active-task-title {
        max-width: 14rem;
    }
}

/* Custom tooltip for active task link to avoid native browser tooltip positioning */
.active-task-title { position: relative; }
.active-task-title .active-task-link { color: inherit; text-decoration: underline; }
.active-task-title .active-task-link::after {
    content: attr(data-full);
    display: none;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(100% + 10px);
    background: rgba(0,0,0,0.85);
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    white-space: nowrap;
    z-index: 1400;
    box-shadow: 0 8px 24px rgba(2,6,23,0.6);
}
.active-task-title .active-task-link::before {
    content: '';
    display: none;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(100% + 4px);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid rgba(0,0,0,0.85);
    z-index: 1401;
}
.active-task-title .active-task-link:hover::after,
.active-task-title .active-task-link:focus::after,
.active-task-title .active-task-link:hover::before,
.active-task-title .active-task-link:focus::before {
    display: block;
}

@media (max-width: 480px) {
    .active-task-title .active-task-link::after { bottom: calc(100% + 6px); font-size: 0.8rem; }
}

/* استایل‌های آواتار */
.avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary) !important;
    font-size: 0.875rem;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
}

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

.avatar-sm i {
    font-size: 0.875rem;
}

/* آواتار متوسط */
.avatar-md {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.125rem;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
}

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

.avatar-md i {
    font-size: 1.125rem;
}

/* آواتار بزرگ */
.avatar-lg {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 2rem;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
}

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

.avatar-lg i {
    font-size: 2rem;
}

/* آواتار خیلی بزرگ */
.avatar-xl {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 3rem;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
    border: 3px solid var(--border);
}

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

.avatar-xl i {
    font-size: 3rem;
}

.empty-state {
    padding: var(--space-3xl) var(--space-lg);
    text-align: center;
}

.empty-state i {
    font-size: 3rem;
    color: var(--text-tertiary);
    opacity: 0.3;
    margin-bottom: var(--space-lg);
}

.empty-state p {
    color: var(--text-tertiary);
    margin: 0;
}

/* ============= ریسپانسیو ============= */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-right: 0;
    }

    .topbar {
        padding: 0 var(--space-md);
    }

    .topbar-left {
        gap: var(--space-sm);
        flex-shrink: 0;
    }

    .topbar-right {
        gap: var(--space-sm);
        flex-shrink: 0;
    }

    .topbar-search {
        display: none;
    }

    #sidebarToggle {
        display: none;
    }

    .topbar-btn.mobile-toggle {
        display: flex;
    }

    .topbar-btn,
    .theme-toggle {
        width: 40px;
        height: 40px;
        font-size: 1.125rem;
        flex-shrink: 0;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }

    .topbar-btn:active,
    .theme-toggle:active {
        transform: scale(0.9);
    }

    .user-menu {
        z-index: 1300;
    }

    .user-menu-toggle {
        padding: 0.375rem 0.75rem;
        gap: var(--space-sm);
        z-index: 1301;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
        touch-action: manipulation;
        -webkit-user-select: none;
        user-select: none;
    }

    .user-menu-toggle:active {
        transform: scale(0.95);
    }

    .user-avatar {
        width: 36px;
        height: 36px;
        font-size: 0.875rem;
    }

    .user-info {
        display: none;
    }

    .user-menu-toggle i {
        margin: 0;
    }

    .notification-dropdown {
        width: calc(100vw - 2rem);
        max-width: 324px;
        left: var(--space-sm);
        right: auto;
        min-width: unset;
        transform: translateY(0);
    }

    .user-menu-dropdown {
        left: var(--space-sm);
        right: auto;
        min-width: 200px;
        max-width: calc(100vw - 2rem);
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .content {
        padding: var(--space-lg);
    }
}

/* ============= اسکرول‌بار ============= */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* ============= یوتیلیتی‌ها ============= */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-muted {
    color: var(--text-tertiary);
}

.mt-1 {
    margin-top: var(--space-sm);
}

.mt-2 {
    margin-top: var(--space-md);
}

.mt-3 {
    margin-top: var(--space-lg);
}

.mb-1 {
    margin-bottom: var(--space-sm);
}

.mb-2 {
    margin-bottom: var(--space-md);
}

.mb-3 {
    margin-bottom: var(--space-lg);
}

.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-1 {
    gap: var(--space-sm);
}

.gap-2 {
    gap: var(--space-md);
}

.gap-3 {
    gap: var(--space-lg);
}

/* ============= صفحه پروفایل ============= */
.profile-container {
    max-width: 1200px;
    margin: 0 auto;
}

.profile-grid {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: var(--space-2xl);
    align-items: start;
}

.profile-forms {
    display: flex;
    flex-direction: column;
    gap: var(--space-2xl);
}

.profile-card {
    position: sticky;
    top: var(--space-2xl);
}

.profile-header {
    text-align: center;
    padding: var(--space-2xl);
    background: var(--primary-gradient);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    position: relative;
    overflow: hidden;
}

.profile-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.5;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

.profile-avatar-large {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--space-lg);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 1;
    overflow: hidden;
}

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

.profile-avatar-large i {
    font-size: 3rem;
    color: var(--primary);
}

.profile-header h2 {
    color: white;
    font-size: 1.75rem;
    font-weight: 800;
    margin-bottom: var(--space-sm);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 1;
}

.profile-header p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.1rem;
    margin-bottom: var(--space-md);
    position: relative;
    z-index: 1;
}

.profile-header .badge {
    background: white;
    color: var(--primary);
    padding: 0.5rem 1.5rem;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 0.875rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 1;
}

.profile-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    border-top: 1px solid var(--border);
}

.profile-stats .stat {
    padding: var(--space-xl);
    text-align: center;
    border-left: 1px solid var(--border);
    transition: var(--transition);
}

.profile-stats .stat:last-child {
    border-left: none;
}

.profile-stats .stat:hover {
    background: var(--bg-tertiary);
    transform: translateY(-2px);
}

.profile-stats .stat h3 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: var(--space-sm);
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.profile-stats .stat p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.profile-grid .card {
    border-radius: var(--radius-xl);
    overflow: hidden;
}

.profile-grid .card-header {
    background: var(--primary-gradient);
    color: white;
    padding: var(--space-xl);
    border-bottom: none;
}

.profile-grid .card-header h3 {
    color: white;
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
}

.profile-grid .form-group {
    margin-bottom: var(--space-xl);
}

.profile-grid .form-group label {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
    display: block;
    font-size: 0.9375rem;
}

.profile-grid .form-control {
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.875rem 1.25rem;
    font-size: 1rem;
    transition: var(--transition);
}

.profile-grid .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
    outline: none;
}

.profile-grid .form-control:disabled {
    background: var(--bg-tertiary);
    cursor: not-allowed;
}

.profile-grid .form-text {
    font-size: 0.8125rem;
    color: var(--text-tertiary);
    margin-top: var(--space-sm);
}

.profile-grid .btn {
    padding: 0.875rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-lg);
    gap: var(--space-sm);
}

.profile-grid .btn-primary {
    background: var(--primary-gradient);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.profile-grid .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.profile-grid .btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}

.profile-grid .btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}

@media (max-width: 992px) {
    .profile-grid {
        grid-template-columns: 1fr;
        gap: var(--space-xl);
    }

    .profile-card {
        position: static;
    }
}

/* ============= Filters Card ============= */
.filters-card {
    margin-bottom: var(--space-2xl);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.filters-card .card-header {
    background: var(--primary-gradient);
    color: white;
    padding: var(--space-md) var(--space-lg);
    /* reduced padding to lower header height */
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.filters-card .card-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.filters-card .card-body {
    padding: var(--space-lg);
    /* slightly reduced to make the filter card shorter */
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-lg);
    align-items: end;
}

.filter-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.filter-item label {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.filter-item label i {
    color: var(--primary);
    font-size: 0.875rem;
}

.filter-item .form-control {
    width: 100%;
}

.filter-actions {
    display: flex;
    gap: var(--space-md);
    align-items: center;
}

.filter-actions .btn {
    flex: 1;
    min-width: 120px;
}

/* Make selected/active filter buttons clearly visible (avoid turning fully white)
   Keeps a subtle surface background, visible border and primary-tinted outline */
.filter-actions .btn:focus,
.filter-actions .btn:active,
.filter-actions .btn.active {
    background: var(--surface-hover);
    color: var(--text-primary);
    border-color: rgba(99, 102, 241, 0.18);
    /* faint primary tint */
    box-shadow: 0 4px 12px rgba(16, 24, 40, 0.06);
    transform: translateY(-2px);
}

/* Ensure dark theme keeps contrast */
[data-theme="dark"] .filter-actions .btn:focus,
[data-theme="dark"] .filter-actions .btn:active,
[data-theme="dark"] .filter-actions .btn.active {
    background: var(--surface-hover);
    color: var(--text-primary);
    border-color: rgba(99, 102, 241, 0.12);
}

/* ============= Pagination Styles ============= */
.pagination {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-lg);
    margin: var(--space-2xl) auto;
    padding: var(--space-lg);
    width: 100%;
    max-width: 1200px;
}

.pagination-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-weight: 500;
    width: 100%;
    text-align: center;
}

.pagination-info i {
    color: var(--primary);
}

.pagination-pages {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.pagination-pages a,
.pagination-pages span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    height: 42px;
    padding: 0 var(--space-md);
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.9375rem;
    transition: var(--transition);
    text-decoration: none;
    border: 2px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
}

.pagination-pages a:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-colored);
}

.pagination-pages span.current {
    background: var(--primary-gradient);
    color: white;
    box-shadow: var(--shadow-colored);
    border-color: var(--primary);
}

.pagination-prev,
.pagination-next {
    min-width: auto !important;
    padding: 0 var(--space-md) !important;
    gap: var(--space-sm);
}

.pagination-prev.disabled,
.pagination-next.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.pagination-pages .pagination-ellipsis {
    color: var(--text-tertiary);
    background: transparent;
    border: none;
    font-weight: 700;
    cursor: default;
}


/* ============= Responsive Styles ============= */

/* ==================== DESKTOP & LARGE SCREENS ==================== */
@media (max-width: 1400px) {
    .container {
        max-width: 1200px;
    }
}

/* ==================== LAPTOP & SMALL DESKTOP ==================== */
@media (max-width: 1200px) {
    :root {
        --sidebar-width: 260px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .analytics-grid {
        grid-template-columns: 1fr;
    }

    .content {
        padding: var(--space-xl);
    }

    .task-detail-grid {
        grid-template-columns: 1fr 300px;
    }
}

/* ==================== TABLET LANDSCAPE ==================== */
@media (max-width: 992px) {

    /* Topbar Adjustments */
    .topbar {
        padding: 0 var(--space-lg);
        position: fixed;
        /* Fix topbar on mobile to avoid sticky quirks */
        right: 0;
        left: 0;
        top: 0;
        width: 100%;
    }

    .topbar-search {
        width: 200px;
    }

    .mobile-toggle {
        display: flex !important;
    }

    #sidebarToggle {
        display: none !important;
    }

    /* Content */
    .content {
        padding: var(--space-lg);
        padding-top: calc(var(--topbar-height) + var(--space-lg));
        /* Prevent content under fixed topbar */
    }

    /* Stats Grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-lg);
    }

    /* Page Header */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-lg);
    }

    .page-header-left,
    .page-header-right {
        width: 100%;
    }

    .page-header-right {
        display: flex;
        gap: var(--space-md);
    }

    .page-header-right .btn {
        flex: 1;
    }

    /* Tables */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: var(--radius);
        box-shadow: var(--shadow-sm);
    }

    .table {
        min-width: 800px;
    }

    /* Task Detail Grid */
    .task-detail-grid {
        grid-template-columns: 1fr;
        gap: var(--space-xl);
    }

    .task-sidebar {
        order: -1;
    }

    /* Filters */
    .filters-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ==================== TABLET PORTRAIT ==================== */
@media (max-width: 768px) {

    /* FORCE RESPONSIVE - NO HORIZONTAL SCROLL */
    * {
        max-width: 100vw !important;
    }

    html,
    body {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
    }

    .layout,
    .main-content,
    .content,
    .topbar,
    .card,
    .stats-grid,
    .stat-card {
        max-width: 100% !important;
        width: 100% !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }

    /* CSS Variables */
    :root {
        --topbar-height: 65px;
        --space-xs: 0.25rem;
        --space-sm: 0.5rem;
        --space-md: 0.75rem;
        --space-lg: 1rem;
        --space-xl: 1.25rem;
        --space-2xl: 1.5rem;
        --space-3xl: 2rem;
    }

    /* Topbar */
    .topbar {
        padding: 0 var(--space-md) !important;
        height: var(--topbar-height) !important;
        position: fixed !important;
        right: 0;
        left: 0;
        top: 0;
        width: 100%;
    }

    .topbar-brand h2 {
        font-size: 1rem;
    }

    .topbar-search {
        display: none;
    }

    .topbar-actions {
        gap: var(--space-sm);
    }

    .topbar-btn,
    .theme-toggle,
    .user-menu-toggle {
        min-width: 44px !important;
        min-height: 44px !important;
        padding: var(--space-sm) !important;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(99, 102, 241, 0.1);
    }

    .user-menu-toggle {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: var(--space-xs) !important;
    }

    .user-avatar {
        width: 36px !important;
        height: 36px !important;
        font-size: 0.875rem !important;
        flex-shrink: 0;
    }

    .notification-btn,
    .user-menu-toggle {
        padding: var(--space-sm);
    }

    .user-info {
        display: none;
    }

    .notification-dropdown {
        width: calc(100vw - 2rem);
        max-width: 380px;
        /* left: var(--space-sm); */
        left: auto !important;
        right: auto;
        min-width: unset;
        transform: translateY(0);
    }

    /* Mobile: position notification dropdown as a fixed panel under topbar
       so it won't be clipped on short screens and remains scrollable. */
    .notification-dropdown {
        position: fixed !important;
        top: var(--topbar-height);
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
        width: calc(100vw - 2rem) !important;
        max-width: 380px !important;
        border-radius: 10px;
        box-shadow: 0 12px 40px rgba(0,0,0,0.18);
        z-index: 2000;
        overflow: hidden;
        display: block;
        opacity: 1;
        visibility: visible;
        background: var(--surface);
        box-sizing: border-box;
        /* ensure it doesn't overflow due to padding/border */
        margin: 0 auto;
    }

    .notification-dropdown .notification-list {
        max-height: calc(100dvh - var(--topbar-height) - 110px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Stronger containment to prevent any inner content or RTL margins
       from pushing the dropdown past the left edge on small screens */
    .notification-dropdown {
        padding-left: 0 !important;
        padding-right: 0 !important;
        direction: ltr !important;
        overflow: visible;
    }

    .notification-dropdown .notification-list {
        padding-left: 0.2rem !important;
        padding-right: 0.2rem !important;
    }

    .notification-dropdown .notification-item {
        margin-inline-start: 0 !important;
        margin-inline-end: 0 !important;
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
        box-sizing: border-box !important;
    }

    /* ensure topbar doesn't clip the fixed dropdown */
    .topbar {
        overflow: visible !important;
    }

    .notification-dropdown.show {
        transform: translateY(0);
    }

    .user-menu-dropdown {
        left: var(--space-sm);
        right: auto;
        min-width: 200px;
        max-width: calc(100vw - 2rem);
        transform: translateY(-10px);
    }

    .user-menu-dropdown.show {
        transform: translateY(0);
    }

    /* Content */
    .content {
        padding: var(--space-md);
        padding-top: calc(var(--topbar-height) + var(--space-md));
    }

    /* Page Header */
    .page-header {
        margin-bottom: var(--space-lg) !important;
        gap: var(--space-md) !important;
        padding: var(--space-md) !important;
        text-align: center;
    }

    .page-header h1 {
        font-size: 1.5rem !important;
        margin-bottom: var(--space-sm) !important;
        line-height: 1.3;
    }

    .page-header p {
        font-size: 0.875rem !important;
        margin: 0 !important;
    }

    .page-header-right .btn {
        width: 100%;
    }

    /* Stats Grid */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: var(--space-md) !important;
        padding: 0;
    }

    .stat-card {
        padding: var(--space-lg) !important;
        margin: 0 !important;
    }

    .stat-icon {
        width: 48px !important;
        height: 48px !important;
        font-size: 1.5rem !important;
    }

    .stat-value {
        font-size: 2rem !important;
        margin-top: var(--space-md);
    }

    .stat-label {
        font-size: 0.875rem !important;
    }

    .stat-card h3 {
        font-size: 1.75rem;
    }

    /* Cards */
    .card {
        margin-bottom: var(--space-lg) !important;
        border-radius: var(--radius) !important;
        overflow: hidden;
    }

    .card-header {
        padding: var(--space-md) !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: var(--space-md) !important;
    }

    .card-header h3,
    .card-title {
        font-size: 1.125rem !important;
        margin: 0 !important;
    }

    .card-header .btn {
        width: 100% !important;
        justify-content: center;
    }

    .card-body {
        padding: var(--space-md) !important;
        overflow-x: auto;
    }

    .card-actions {
        width: 100%;
    }

    /* Empty States */
    .text-center {
        padding: var(--space-lg) var(--space-md) !important;
    }

    .text-center i.fas {
        font-size: 2rem !important;
        margin-bottom: 0.75rem !important;
    }

    .text-center p {
        font-size: 0.875rem !important;
        margin: 0.5rem 0 !important;
    }

    .text-center .btn {
        width: 100% !important;
        max-width: 300px;
        margin-top: var(--space-md) !important;
    }

    /* Filters */
    .filters-grid {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }

    .filter-actions {
        flex-direction: column;
        gap: var(--space-sm);
        margin-top: var(--space-md);
    }

    .filter-actions .btn {
        width: 100%;
    }

    /* Attendance Page */
    .filter-group {
        width: 100% !important;
        max-width: 100% !important;
    }

    .filter-group .form-control {
        width: 100% !important;
        font-size: 1rem !important;
    }

    .employee-cell {
        min-width: 150px !important;
        gap: var(--space-sm) !important;
    }

    .avatar-sm {
        width: 28px !important;
        height: 28px !important;
        font-size: 0.75rem !important;
    }

    .empty-state {
        padding: var(--space-2xl) var(--space-md) !important;
    }

    .empty-state i {
        font-size: 2.5rem !important;
    }

    /* Employees Grid */
    .employees-grid {
        grid-template-columns: 1fr !important;
        gap: var(--space-md) !important;
    }

    /* Tables */
    .table-wrapper {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        margin: 0 calc(var(--space-md) * -1);
    }

    .table {
        font-size: 0.8125rem !important;
        min-width: 800px;
        margin: 0;
    }

    .table td,
    .table th {
        padding: var(--space-sm) var(--space-md) !important;
    }

    .table th {
        font-size: 0.75rem !important;
        position: sticky;
        top: 0;
        background: var(--surface);
        z-index: 10;
        white-space: nowrap;
    }

    .table td {
        vertical-align: middle;
    }

    /* حفظ عرض ثابت ستون‌ها در موبایل */
    .table td:first-child {
        max-width: 280px;
    }

    .table .task-info h4,
    .table .task-info p {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .table td .badge {
        font-size: 0.7rem !important;
        padding: 0.25rem 0.5rem !important;
        white-space: nowrap;
    }

    .table .btn-sm {
        padding: 0.375rem 0.75rem !important;
        font-size: 0.75rem !important;
        min-width: auto !important;
    }

    .table .btn-sm i {
        margin: 0 !important;
    }

    .table .btn-sm span {
        display: none;
    }

    /* Pagination */
    .pagination {
        gap: var(--space-md);
        padding: var(--space-md);
        margin: var(--space-xl) auto;
    }

    .pagination-info {
        font-size: 0.875rem;
    }

    .pagination-pages {
        gap: var(--space-xs);
    }

    .pagination-pages a,
    .pagination-pages span {
        min-width: 38px;
        height: 38px;
        font-size: 0.875rem;
        padding: 0 var(--space-sm);
    }

    /* Task Details */
    .task-detail-grid {
        gap: var(--space-lg);
    }

    .comment-item {
        padding: var(--space-md);
        flex-direction: column;
        gap: var(--space-sm);
    }

    .comment-avatar {
        width: 2rem;
        height: 2rem;
    }

    .comment-header {
        flex-wrap: wrap;
        font-size: 0.875rem;
    }

    .team-member {
        flex-wrap: wrap;
        padding: var(--space-md);
    }

    .member-avatar {
        width: 2.5rem;
        height: 2.5rem;
    }

    .member-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: var(--space-sm);
    }

    /* Forms */
    .form-group {
        margin-bottom: var(--space-md);
    }

    .form-control,
    .form-select {
        font-size: 1rem;
        /* Prevent zoom on iOS */
        padding: var(--space-md);
    }

    textarea.form-control {
        min-height: 120px;
    }

    /* Buttons */
    .btn {
        padding: var(--space-md) var(--space-lg);
        font-size: 0.9375rem;
    }

    .btn-sm {
        padding: var(--space-sm) var(--space-md);
        font-size: 0.875rem;
    }
}

/* ==================== MOBILE LARGE ==================== */
@media (max-width: 576px) {

    /* Further reduce spacing */
    :root {
        --space-md: 0.625rem;
        --space-lg: 0.875rem;
        --space-xl: 1rem;
        --space-2xl: 1.25rem;
    }

    .content {
        padding: var(--space-sm) !important;
        padding-top: calc(var(--topbar-height) + var(--space-sm)) !important;
    }

    .page-header {
        padding: var(--space-sm) !important;
        margin-bottom: var(--space-md) !important;
    }

    .page-header h1 {
        font-size: 1.25rem !important;
    }

    .page-header p {
        font-size: 0.8125rem !important;
    }

    /* Stats */
    .stats-grid {
        gap: var(--space-sm) !important;
    }

    .stat-card {
        padding: var(--space-md) !important;
    }

    .stat-icon {
        width: 40px !important;
        height: 40px !important;
        font-size: 1.25rem !important;
    }

    .stat-value {
        font-size: 1.75rem !important;
        margin-top: var(--space-sm) !important;
    }

    .stat-label {
        font-size: 0.8125rem !important;
    }

    .stat-card h3 {
        font-size: 1.5rem;
    }

    /* Cards */
    .card {
        margin-bottom: var(--space-md) !important;
    }

    .card-header,
    .card-body {
        padding: var(--space-md) !important;
    }

    .card-title {
        font-size: 1rem !important;
    }

    /* Tables */
    .table {
        font-size: 0.75rem !important;
        min-width: 700px;
    }

    .table td,
    .table th {
        padding: var(--space-xs) var(--space-sm) !important;
    }

    .table td:first-child {
        max-width: 200px;
    }

    .table .task-info h4 {
        font-size: 0.875rem;
    }

    .table .task-info p {
        font-size: 0.75rem;
    }

    .table td .badge {
        font-size: 0.65rem !important;
        padding: 0.2rem 0.4rem !important;
    }

    /* Attendance */
    .employee-cell {
        min-width: 120px !important;
        gap: var(--space-xs) !important;
    }

    .avatar-sm {
        width: 24px !important;
        height: 24px !important;
        font-size: 0.7rem !important;
    }

    .filter-group .form-control {
        font-size: 0.9375rem !important;
    }

    /* Empty States */
    .text-center i.fas {
        font-size: 1.75rem !important;
    }

    .text-center p {
        font-size: 0.8125rem !important;
    }

    /* Smaller buttons */
    .btn {
        padding: var(--space-sm) var(--space-md) !important;
        font-size: 0.875rem !important;
    }

    .btn-sm {
        padding: 0.375rem var(--space-sm) !important;
        font-size: 0.75rem !important;
    }

    /* Pagination - hide more numbers */
    .pagination-pages a:not(.pagination-prev):not(.pagination-next):nth-child(n+3):nth-last-child(n+3) {
        display: none;
    }

    .pagination-pages a,
    .pagination-pages span {
        min-width: 36px;
        height: 36px;
        font-size: 0.8125rem;
    }

    /* Task Details */
    .comment-avatar {
        width: 1.75rem;
        height: 1.75rem;
    }

    .member-avatar {
        width: 2rem;
        height: 2rem;
    }

    .file-item {
        padding: var(--space-sm);
        font-size: 0.875rem;
    }

    /* Table */
    .table {
        font-size: 0.8125rem;
    }

    .table td,
    .table th {
        padding: var(--space-xs) var(--space-sm);
        white-space: nowrap;
    }

    .employee-cell {
        min-width: 140px;
    }

    /* Employee Grid */
    .employee-card {
        padding: var(--space-md);
    }

    .employee-stats {
        gap: var(--space-xs) !important;
        padding: var(--space-sm) !important;
    }

    /* Modals */
    .modal-content {
        margin: var(--space-sm);
        border-radius: var(--radius);
    }
}

/* ==================== MOBILE SMALL ==================== */
@media (max-width: 400px) {

    /* Topbar */
    .topbar-brand h2 {
        font-size: 0.875rem !important;
    }

    .topbar-right {
        gap: var(--space-xs) !important;
    }

    .topbar-btn,
    .theme-toggle {
        width: 38px !important;
        height: 38px !important;
        font-size: 1rem !important;
    }

    /* Page Header */
    .page-header {
        padding: var(--space-xs) !important;
    }

    .page-header h1 {
        font-size: 1.125rem !important;
    }

    .page-header p {
        font-size: 0.75rem !important;
    }

    /* Stats */
    .stats-grid {
        gap: var(--space-xs) !important;
    }

    .stat-card {
        padding: var(--space-sm) var(--space-md) !important;
    }

    .stat-icon {
        width: 36px !important;
        height: 36px !important;
        font-size: 1.125rem !important;
    }

    .stat-value {
        font-size: 1.5rem !important;
    }

    .stat-label {
        font-size: 0.75rem !important;
    }

    /* Cards */
    .card {
        margin-bottom: var(--space-sm) !important;
        padding: 0 !important;
    }

    .card-header,
    .card-body {
        padding: var(--space-sm) !important;
    }

    .card-title {
        font-size: 0.9375rem !important;
    }

    /* Tables */
    .table {
        font-size: 0.7rem !important;
        min-width: 650px;
    }

    .table td,
    .table th {
        padding: 0.25rem 0.375rem !important;
    }

    .table td:first-child {
        max-width: 150px;
    }

    .table .task-info h4 {
        font-size: 0.8125rem;
    }

    .table .task-info p {
        font-size: 0.7rem;
    }

    /* Buttons */
    .btn {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.8125rem !important;
        gap: 0.25rem !important;
    }

    .btn-sm {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.7rem !important;
    }

    /* Pagination */
    .pagination-info {
        font-size: 0.75rem !important;
    }

    .pagination-pages a,
    .pagination-pages span {
        min-width: 32px !important;
        height: 32px !important;
        font-size: 0.7rem !important;
        padding: 0 0.25rem !important;
    }

    /* Empty States */
    .text-center {
        padding: var(--space-md) var(--space-sm) !important;
    }

    .text-center i.fas,
    .empty-state i {
        font-size: 1.5rem !important;
    }

    .text-center p,
    .empty-state p {
        font-size: 0.75rem !important;
    }

    /* Attendance */
    .employee-cell {
        min-width: 100px !important;
        font-size: 0.75rem !important;
    }

    .employee-cell span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .avatar-sm {
        width: 20px !important;
        height: 20px !important;
        font-size: 0.625rem !important;
    }

    .filter-group .form-control {
        font-size: 0.875rem !important;
        padding: var(--space-sm) !important;
    }
}

/* ==================== LANDSCAPE MODE FIX ==================== */
@media (max-height: 600px) and (orientation: landscape) {
    .sidebar {
        overflow-y: auto;
    }

    .notification-dropdown,
    .user-menu-dropdown {
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* ==================== PRINT STYLES ==================== */
@media print {

    .sidebar,
    .topbar,
    .page-header-right,
    .filter-actions,
    .pagination,
    .btn,
    .card-actions {
        display: none !important;
    }

    .main-content {
        margin: 0 !important;
    }

    .content {
        padding: 0 !important;
    }

    .card {
        break-inside: avoid;
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}


/* =============================================================================
   📋 Task Details Page Styles
   ============================================================================= */

/* Back Button */
.btn-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    transition: var(--transition);
    cursor: pointer;
    text-decoration: none;
    margin-left: var(--space-md);
}

.btn-back:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateX(3px);
}

/* Task Detail Grid Layout */
.task-detail-grid {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: var(--space-xl);
    margin-top: var(--space-xl);
}

/* Task detail specific stats grid (cards at top of task details) */
.task-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-md);
    margin-bottom: 2rem;
}

/* Prefer two columns on medium screens so layout becomes 2x2 instead of 3+1 */
@media (max-width: 1200px) {
    .task-stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 768px) {
    .task-stats-grid {
        grid-template-columns: 1fr !important;
    }
}

.task-main {
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
}

.task-sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

/* Comments Section */
.comment-form {
    padding-bottom: var(--space-lg);
    margin-bottom: var(--space-lg);
    border-bottom: 1px solid var(--border);
}

.comment-form textarea {
    resize: vertical;
    min-height: 100px;
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    margin-top: var(--space-lg);
}

.comment-item {
    display: flex;
    gap: var(--space-md);
    padding: var(--space-lg);
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    transition: var(--transition);
}

.comment-item:hover {
    background: var(--surface-hover);
    box-shadow: var(--shadow-sm);
}

.comment-avatar {
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius-full);
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    overflow: hidden;
}

.comment-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.comment-content {
    flex: 1;
}

.comment-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
    flex-wrap: wrap;
}

.comment-header strong {
    color: var(--text-primary);
    font-weight: 600;
}

.comment-time {
    color: var(--text-tertiary);
    font-size: 0.875rem;
    margin-right: auto;
}

.comment-content p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

/* Keep comment text right-aligned in RTL layout */
[dir="rtl"] .comment-content p {
    text-align: right;
    direction: rtl;
}

/* Ensure avatar & header align properly when used in RTL context */
[dir="rtl"] .comment-item {
    flex-direction: row-reverse; /* avatar on the right */
}
[dir="rtl"] .comment-header { /* place time and actions correctly */
    justify-content: flex-start;
}

/* Upload Form */
.upload-form {
    padding-bottom: var(--space-lg);
    margin-bottom: var(--space-lg);
    border-bottom: 1px solid var(--border);
}

.form-control-file {
    display: block;
    width: 100%;
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    transition: var(--transition);
    cursor: pointer;
}

.form-control-file:hover {
    border-color: var(--primary);
    background: var(--surface-hover);
}

.form-text {
    display: block;
    margin-top: var(--space-sm);
    color: var(--text-tertiary);
    font-size: 0.875rem;
}

/* Files List */
.files-list {
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border);
}

.files-list h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-md);
}

.file-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    margin-bottom: var(--space-sm);
    transition: var(--transition);
}

.file-item:hover {
    background: var(--surface-hover);
    box-shadow: var(--shadow-sm);
}

.file-item i {
    color: var(--primary);
    font-size: 1.25rem;
}

.file-item span {
    flex: 1;
    color: var(--text-primary);
    font-weight: 500;
}

/* Info Items */
.info-item {
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--border);
}

.info-item:last-child {
    border-bottom: none;
}

.info-item label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-xs);
}

.info-item label i {
    color: var(--primary);
}

.info-item p {
    color: var(--text-primary);
    font-weight: 500;
    margin: 0;
}

/* Team Members */
.team-member {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    margin-bottom: var(--space-md);
    transition: var(--transition);
}

.team-member:hover {
    background: var(--surface-hover);
    box-shadow: var(--shadow-sm);
}

.member-avatar {
    flex-shrink: 0;
    width: 3rem;
    height: 3rem;
    border-radius: var(--radius-full);
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
    overflow: hidden;
}

.member-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.member-info {
    flex: 1;
    min-width: 0;
}

.member-info h4 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 var(--space-xs) 0;
}

.member-info p {
    font-size: 0.8125rem;
    color: var(--text-tertiary);
    margin: 0 0 var(--space-xs) 0;
}

.member-actions {
    display: flex;
    gap: var(--space-sm);
    flex-shrink: 0;
}

/* Status Form */
.status-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* Badge Sizes */
.badge-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}


/* =============================================================================
   ⏰ Attendance Sessions Styles
   ============================================================================= */

/* Attendance Summary Section */
.attendance-summary {
    padding: var(--space-lg);
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    border-radius: var(--radius-lg);
    color: white;
}

.attendance-summary h4 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.attendance-summary h4 i {
    font-size: 1.5rem;
}

/* Sessions List */
.sessions-list {
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 2px solid var(--border);
}

.sessions-list h5 {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    color: var(--text-secondary);
    font-weight: 600;
}

.sessions-list .table {
    box-shadow: var(--shadow-sm);
}

.sessions-list .table thead {
    background: var(--bg-tertiary);
}

.sessions-list .table thead th {
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    font-size: 0.8125rem;
    letter-spacing: 0.05em;
}

.sessions-list .table tbody tr {
    transition: var(--transition);
}

.sessions-list .table tbody tr:hover {
    background: var(--surface-hover);
    box-shadow: inset 3px 0 0 var(--primary);
}

/* Active Session Highlight */
.sessions-list .table tbody tr[style*="success-light"] {
    background: var(--success-light) !important;
    border-right: 3px solid var(--success);
}

/* Session Status Icons */
.sessions-list .fa-sign-in-alt {
    color: var(--success);
    margin-left: var(--space-xs);
}

.sessions-list .fa-sign-out-alt {
    color: var(--danger);
    margin-left: var(--space-xs);
}

/* Duration Display */
#active-duration {
    display: inline-block;
    font-family: 'Courier New', monospace;
    background: rgba(255, 255, 255, 0.2);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius);
    font-weight: bold;
}

/* Responsive Attendance */
@media (max-width: 768px) {
    .attendance-summary>div {
        flex-direction: column !important;
        gap: var(--space-md);
    }

    .attendance-summary h4 {
        font-size: 1rem;
    }

    .attendance-summary h4 span {
        font-size: 1.25em !important;
    }

    .sessions-list .table {
        font-size: 0.875rem;
    }

    .sessions-list .table th,
    .sessions-list .table td {
        padding: 0.5rem 0.375rem;
    }
}

/* Attendance Action Buttons */
.attendance-action-btn {
    min-width: 150px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.attendance-action-btn:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.attendance-action-btn:disabled {
    opacity: 0.8;
    cursor: not-allowed;
}

.attendance-action-btn i {
    flex-shrink: 0;
    width: 16px;
    text-align: center;
}

.attendance-action-btn span {
    flex-shrink: 0;
}


/* =============================================================================
   📋 Task Selection Modal (for Clock-In)
   ============================================================================= */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-primary);
    font-size: 1.25rem;
}

.modal-header h3 i {
    color: var(--primary);
}

.btn-close {
    width: 2rem;
    height: 2rem;
    border: none;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.btn-close:hover {
    background: var(--danger);
    color: white;
    transform: rotate(90deg);
}

.modal-body {
    padding: var(--space-lg);
    overflow-y: auto;
    flex: 1;
}

.tasks-list-modal {
    max-height: 50vh;
    overflow-y: auto;
    padding: 2px;
    /* Prevent cut-off on hover */
}

.task-items {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.task-item-modal {
    padding: var(--space-lg);
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: var(--space-md);
    margin: 0;
    /* Remove any default margins */
}

.task-item-modal:hover {
    background: var(--surface-hover);
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
}

.task-item-modal.selected {
    background: var(--primary-light);
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.task-item-modal.selected * {
    color: white !important;
}

.task-item-modal.selected .task-check-icon {
    display: inline !important;
    animation: checkPulse 0.3s ease;
}

@keyframes checkPulse {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.task-info {
    flex: 1;
}

.task-info h4 {
    margin: 0 0 var(--space-xs) 0;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
}

.task-info p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.task-meta {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    align-items: flex-start;
}

.task-meta small {
    display: flex;
    align-items: center;
    gap: 4px;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-md);
    padding: var(--space-lg);
    border-top: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.modal-footer .btn {
    min-width: 170px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.modal-footer .btn:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.modal-footer .btn:disabled {
    opacity: 0.8;
    cursor: not-allowed;
}

.modal-footer .btn i {
    flex-shrink: 0;
    width: 16px;
    text-align: center;
}

.modal-footer .btn span {
    flex-shrink: 0;
}

/* Responsive Modal */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }

    .modal-header {
        padding: var(--space-md);
    }

    .modal-header h3 {
        font-size: 1.1rem;
    }

    .modal-body {
        padding: var(--space-md);
    }

    .modal-footer {
        padding: var(--space-md);
        flex-wrap: wrap;
    }

    .modal-footer .btn {
        flex: 1;
        min-width: auto;
    }

    .task-item-modal {
        flex-direction: column;
        padding: var(--space-md);
    }

    .task-meta {
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
    }
}

/* ==================== Profile page styles (moved from templates/profile.html) ==================== */
.profile-container {
    width: 100%;
    margin: 0 auto;
}

.profile-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
}

@media (max-width: 900px) {
    .profile-grid {
        grid-template-columns: 1fr;
    }
}

/* Slight card adjustments for profile only (keeps global card rules intact) */
.card.profile-card {
    border-radius: 14px;
    overflow: hidden;
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
}

.profile-card .profile-avatar-large {
    display: flex;
    justify-content: center;
}

.avatar-xl {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-gradient-1,
.avatar-gradient-2 {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    font-size: 45px;
    color: #fff;
}

.avatar-gradient-1 {
    background: linear-gradient(135deg, #4e73df, #1cc88a);
}

.avatar-gradient-2 {
    background: linear-gradient(135deg, #6f42c1, #e83e8c);
}

.profile-stats {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    text-align: center;
}

.profile-stats .stat h3 {
    margin: 0;
    font-size: 22px;
}

.profile-stats .stat p {
    margin: 0;
    font-size: 13px;
    color: var(--text-muted);
}

.profile-contact .line {
    display: flex;
    justify-content: space-between;
    margin: 6px 0;
}

.profile-contact .label {
    font-weight: 700;
    color: var(--text-muted);
}

.profile-header {
    padding: 0;
}

.profile-cover {
    height: 140px;
    width: 100%;
    background-size: cover;
    background-position: center;
}

.profile-header .card-body {
    padding: 20px;
}

.avatar-lg {
    width: 85px;
    height: 85px;
    border-radius: 50%;
    object-fit: cover;
}

.profile-forms .card {
    margin-top: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.btn {
    border-radius: 10px;
}

/* Table padding and colors (light, non-breaking change) */
.table th,
.table td {
    padding: 12px 16px;
}

/* Profile-specific badge coloring to match theme */
.profile-card .badge-primary {
    background: var(--primary);
    color: #fff;
}

.profile-card .badge-secondary {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

/* Ensure profile form controls play nicely with theme */
.profile-forms .form-control {
    background: var(--bg);
}

@media (max-width: 520px) {
    .avatar-xl {
        width: 88px;
        height: 88px;
        font-size: 36px;
    }

    .avatar-lg {
        width: 60px;
        height: 60px;
    }

    .profile-stats {
        gap: 8px;
    }
}

/* Ensure cover is visually behind the header content and buttons are clickable */
.profile-header {
    position: relative;
}

.profile-cover {
    z-index: 1;
}

.profile-header .card-body {
    position: relative;
    z-index: 3;
}

.profile-header .ml-auto .btn {
    position: relative;
    z-index: 4;
    pointer-events: auto;
}

/* Make sure buttons are visible on top of any cover gradients */
.profile-header .btn {
    color: var(--text-primary);
}


/* End profile page styles */

/* ==================== Employee dashboard styles (scoped) ==================== */
.dashboard-employee .table-wrapper {
    overflow-x: auto;
}

.dashboard-employee .table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: transparent;
}

.dashboard-employee .table th,
.dashboard-employee .table td {
    padding: 12px 16px;
    vertical-align: middle;
}

.dashboard-employee .table thead th {
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.02), rgba(0, 0, 0, 0.01));
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-weight: 600;
}

.dashboard-employee .table tbody tr {
    transition: background 0.12s ease, transform 0.12s ease;
}

.dashboard-employee .table tbody tr:hover {
    background: rgba(99, 102, 241, 0.04);
    transform: translateY(-1px);
}

.dashboard-employee .table tbody tr td:first-child {
    font-weight: 700;
    width: 48px;
    text-align: center;
}

.dashboard-employee .table .badge {
    padding: 6px 8px;
    font-size: 0.8rem;
    border-radius: 8px;
}

.dashboard-employee .table .text-muted {
    color: var(--text-secondary);
}

.dashboard-employee .table td .fa {
    margin-left: 0.5rem;
}

/* Sessions table specific tweaks */
.dashboard-employee .sessions-list .table thead th {
    text-align: right;
}

.dashboard-employee .sessions-list .table td {
    white-space: nowrap;
}

/* Tasks table responsive */
@media (max-width: 768px) {
    .dashboard-employee .table thead {
        display: none;
    }

    .dashboard-employee .table tbody tr {
        display: block;
        margin-bottom: 12px;
        border-radius: 10px;
        background: var(--bg-secondary);
        padding: 12px;
    }

    .dashboard-employee .table tbody tr td {
        display: flex;
        justify-content: space-between;
        padding: 6px 8px;
        border: none;
    }

    /* Make rows horizontally scrollable if a cell (like 'assigned to') is too wide
       and ensure avatars / long names are truncated instead of overflowing. */
    .dashboard-employee .table-wrapper {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .dashboard-employee .table tbody tr {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .dashboard-employee .table tbody tr td {
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Specifically constrain the 'assigned to' cell's inner group (avatars/names)
       to avoid pushing the layout. Adjust selector if your markup differs. */
    .dashboard-employee .table tbody tr td .avatars-group,
    .dashboard-employee .table tbody tr td .assigned-to,
    .dashboard-employee .table tbody tr td .assignee {
        max-width: 140px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        display: inline-block;
        vertical-align: middle;
    }

    .dashboard-employee .table tbody tr td .avatar-sm {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Make sure long text inside cells can wrap where appropriate (fallback)
       while still keeping the row scrollable horizontally when needed. */
    .dashboard-employee .table tbody tr td .task-title,
    .dashboard-employee .table tbody tr td .task-desc {
        max-width: calc(100vw - 220px);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        display: inline-block;
        vertical-align: middle;
    }

    /* On mobile: hide the compact avatars group and show stacked assignee names */
    .avatars-group {
        display: none !important;
    }

    /* Dashboard (manager) - make the 'تخصیص به' column stack badges vertically */
    .dashboard-manager .table tbody tr td:nth-child(2) {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.25rem !important;
        align-items: flex-start !important;
    }

    .dashboard-manager .table tbody tr td:nth-child(2) .badge {
        display: inline-block !important;
        white-space: normal !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: calc(100vw - 140px) !important;
    }

    /* Tasks page - stack 'تخصیص به' column (5th column) vertically */
    .tasks-page .table tbody tr td:nth-child(5),
    .tasks-table .table tbody tr td:nth-child(5) {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.25rem !important;
        align-items: flex-start !important;
    }

    .tasks-page .table tbody tr td:nth-child(5) .avatar,
    .tasks-page .table tbody tr td:nth-child(5) .avatar-sm,
    .tasks-page .table tbody tr td:nth-child(5) .badge {
        display: inline-block !important;
        margin: 0 !important;
    }

    .assignee-names-mobile {
        display: block;
        margin-top: 0.5rem;
    }

    .assignee-names-mobile .assignee-name {
        font-size: 0.875rem;
        color: var(--text-primary);
        padding: 2px 8px;
        line-height: 1.2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Hide the names block on larger screens (desktop) via default rule below */
}

/* Modal & task list moved from template (scoped) */
.dashboard-employee .modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 1rem;
}

.dashboard-employee .modal-content {
    background: var(--bg);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

.dashboard-employee .modal-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.15rem;
}

.dashboard-employee .btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dashboard-employee .btn-close:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
    border-radius: 50%;
}

.dashboard-employee .modal-body {
    padding: 1.25rem;
    flex: 1;
    overflow-y: auto;
}

.dashboard-employee .modal-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    background: var(--bg-tertiary);
}

.dashboard-employee .tasks-list-modal {
    min-height: 200px;
}

.dashboard-employee .task-items {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.dashboard-employee .task-item-modal {
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg);
}

.dashboard-employee .task-item-modal:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.03);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
}

.dashboard-employee .task-item-modal.selected {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.04);
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.06);
}

.dashboard-employee .task-info h4 {
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    font-size: 1.05rem;
}

.dashboard-employee .task-info p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.dashboard-employee .task-meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.dashboard-employee .task-check-icon {
    margin-left: 0.5rem;
    font-size: 1.1rem;
    display: none;
}

@media (max-width: 768px) {
    .dashboard-employee .modal-content {
        margin: 1rem;
        max-height: 80vh;
    }

    .dashboard-employee .modal-header h3 {
        font-size: 1.05rem;
    }

    .dashboard-employee .task-item-modal {
        padding: 0.75rem;
    }

    .dashboard-employee .modal-footer {
        flex-direction: column-reverse;
    }

    .dashboard-employee .modal-footer .btn {
        width: 100%;
    }
}

/* End employee dashboard styles */

/* ==================== Manager dashboard styles (scoped) ==================== */
.dashboard-manager .stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: var(--space-md);
}

.dashboard-manager .stat-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 18px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.dashboard-manager .stat-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-md);
}

.dashboard-manager .stat-card .stat-card-header {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.dashboard-manager .stat-card .stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.9), rgba(124, 77, 255, 0.9));
    box-shadow: none;
}

.dashboard-manager .stat-card .stat-icon.success {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.9), rgba(34, 197, 94, 0.9));
}

.dashboard-manager .stat-card .stat-icon.warning {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.95), rgba(255, 159, 67, 0.9));
    color: #222;
}

.dashboard-manager .stat-card .stat-icon.info {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.9), rgba(14, 165, 233, 0.9));
}

.dashboard-manager .stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    margin-top: 6px;
}

.dashboard-manager .stat-label {
    color: var(--text-secondary);
    margin-top: 4px;
    font-size: 0.95rem;
}

/* Cards inside manager dashboard: slightly larger header/body padding, scoped */
.dashboard-manager .card {
    border-radius: 12px;
    overflow: hidden;
}

.dashboard-manager .card .card-header {
    padding: 14px 18px;
}

.dashboard-manager .card .card-body {
    padding: 16px 18px;
}

.dashboard-manager .card .btn {
    border-radius: 8px;
}

.dashboard-manager .table-wrapper {
    overflow-x: auto;
}

.dashboard-manager .table th,
.dashboard-manager .table td {
    padding: 12px 14px;
}

.dashboard-manager .table thead th {
    background: transparent;
    border-bottom: 1px solid var(--border);
}

@media (max-width: 992px) {
    .dashboard-manager .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 520px) {
    .dashboard-manager .stats-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-manager .stat-card {
        display: flex;
        gap: 12px;
        align-items: center;
        text-align: left;
    }

    .dashboard-manager .stat-card .stat-card-header {
        margin: 0;
    }
}

/* End manager dashboard styles */

/* page-header actions spacing for manager dashboard */
.dashboard-manager .page-header-actions {
    margin-top: 8px;
}

/* Ensure all cards inside manager dashboard have comfortable inner padding */
.dashboard-manager .card .card-body {
    padding: 18px;
}

.dashboard-manager .card .card-header {
    padding: 14px 18px;
}


/* ==================== Profile: card inner spacing (scoped) ==================== */
/* Increase inner padding for any card inside the profile page only. This
   is intentionally scoped under .profile-container so other pages keep their
   original spacing. */
.profile-container .card .card-body {
    padding: 20px 24px;
}

.profile-container .card .card-header {
    padding: 14px 24px;
}

@media (max-width: 520px) {
    .profile-container .card .card-body {
        padding: 12px 16px;
    }

    .profile-container .card .card-header {
        padding: 10px 16px;
    }
}

/* Progress bar (used in analytics and other tables) */
.progress {
    height: 12px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 999px;
    overflow: hidden;
    display: block;
    direction: ltr;
}

.progress-bar {
    height: 100%;
    width: 0;
    /* default to 0, will be set inline or via JS */
    min-width: 2px;
    /* keep a sliver visible even at 0% in some browsers */
    background: linear-gradient(90deg, var(--primary, #6366f1), #2b8cff);
    box-shadow: 0 2px 8px rgba(43, 140, 255, 0.14) inset;
    transition: width 0.4s ease, background 0.3s ease;
    border-radius: 999px;
    /* round ends */
    display: block;
}

/* Scoped styles for My Tasks page cards and boxes */
.tasks-page {
    /* max-width: 1100px; */
    margin: 0 auto;
    /* padding: 0 1rem 2rem; */
}

.tasks-page .card {
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: visible;
    margin-bottom: 1rem;
}

.tasks-page .card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
}

.tasks-page .card-body {
    padding: 1.25rem;
}

.tasks-page .filters-card .filters-form .filters-grid {
    gap: 1rem;
}

.tasks-page .empty-state {
    padding: 2rem;
}

.tasks-page .table-wrapper {
    padding: 0.25rem;
}

/* Make sure responsive small table rows still have inner padding */
@media (max-width: 720px) {
    .tasks-page .table-wrapper {
        padding: 0;
    }

    .tasks-page .card-body {
        padding: 0.75rem;
    }
}

/* ===================== Stage Management Styles ===================== */

/* Unified Stage List - Manager View */
.unified-stage-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.employee-stage-item {
    padding: 1rem;
    background: var(--bg-primary, #ffffff);
    border-radius: var(--radius, 8px);
    border: 1px solid var(--border, #e5e7eb);
    transition: all 0.2s ease;
}

.employee-stage-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

[data-theme="dark"] .employee-stage-item {
    background: var(--bg-secondary, #1f2937);
    border-color: var(--border, #374151);
}

.employee-checks-grid {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

/* Stage Section Container */
.stage-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--bg-tertiary, #f9fafb);
    border-radius: var(--radius-lg, 12px);
    transition: background 0.2s ease;
}

[data-theme="dark"] .stage-section {
    background: var(--bg-secondary, #1f2937);
}

/* Stage Comments Section */
.stage-comments-section {
    border-top: 1px solid var(--border, #e5e7eb);
    padding-top: 1rem;
    margin-top: 1rem;
}

[data-theme="dark"] .stage-comments-section {
    border-top-color: var(--border, #374151);
}

.stage-comments-section h5 {
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Stage Checkbox Styling */
.stage-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--success, #10b981);
    transition: transform 0.2s ease;
}

.stage-checkbox:hover {
    transform: scale(1.1);
}

.stage-checkbox:checked {
    animation: checkboxPulse 0.3s ease;
}

@keyframes checkboxPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }
}

/* Checkbox Wrapper */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-wrapper span {
    font-size: 0.75rem;
    color: var(--text-tertiary, #6b7280);
    font-weight: 500;
}

/* Stage Comment Form */
.stage-comment-form {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.stage-comment-form input[type="text"] {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: var(--radius, 8px);
    background: var(--bg-primary, #ffffff);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.stage-comment-form input[type="text"]:focus {
    outline: none;
    border-color: var(--primary, #6366f1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

[data-theme="dark"] .stage-comment-form input[type="text"] {
    background: var(--bg-secondary, #374151);
    border-color: var(--border, #4b5563);
    color: var(--text-primary);
}

.stage-comment-form button {
    padding: 0.5rem 1rem;
    white-space: nowrap;
}

/* RTL Support for Stages */
[dir="rtl"] .unified-stage-list,
[dir="rtl"] .employee-checks-grid,
[dir="rtl"] .stage-comment-form {
    direction: rtl;
}

[dir="rtl"] .stage-comments-section {
    border-right: 1px solid var(--border);
    border-left: none;
}

[dir="rtl"] .employee-stage-item {
    text-align: right;
}

/* Avatar in Stage Items */
.employee-stage-item .avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-bg, #e7f1ff);
    color: var(--primary, #6366f1);
    font-size: 0.875rem;
}

.employee-stage-item .avatar-sm img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Stage Order Badge */
.stage-section h4 span {
    background: var(--primary, #6366f1);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.875rem;
}

/* Checked Info Display */
[data-checked-info] {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-tertiary, #6b7280);
    line-height: 1.6;
}

[data-checked-info] div {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 0.25rem;
}

[data-checked-info] i {
    width: 14px;
    color: var(--success, #10b981);
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .unified-stage-list {
        grid-template-columns: 1fr;
    }

    .stage-section {
        padding: 1rem;
    }

    .stage-comment-form {
        flex-direction: column;
    }

    .stage-comment-form button {
        width: 100%;
    }
}

/* Dark Theme Enhancements */
[data-theme="dark"] .stage-checkbox {
    filter: brightness(1.2);
}

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

/* Animation for Stage Completion */
.stage-checkbox:checked+span {
    color: var(--success, #10b981);
    font-weight: 600;
}

/* Loading State for Forms */
.stage-comment-form button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.stage-comment-form button:disabled i {
    animation: spin 1s linear infinite;
}

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

    to {
        transform: rotate(360deg);
    }
}

/* Topbar notification dropdown (light + dark mode) */
.notification-dropdown {
    display: none;
    /* initial hidden, JS toggles inline styles */
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    color: #111827;
    min-width: 300px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
}

.notification-dropdown.show {
    display: block !important;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Notification content elements */
.notification-dropdown .notification-header,
.notification-dropdown .notification-footer {
    padding: 0.75rem 1rem;
    background: transparent;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.notification-dropdown .notification-list {
    max-height: 480px;
    overflow-y: auto;
    padding: 0.5rem 0.5rem;
}

.notification-dropdown .notification-item {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 0.65rem 0.75rem;
    border-bottom: 1px dashed rgba(0, 0, 0, 0.03);
}

.notification-dropdown .notification-item:last-child {
    border-bottom: 0;
}

.notification-dropdown .notification-item.unread {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.04), transparent);
}

.notification-dropdown .notification-icon {
    font-size: 1.05rem;
}

.notification-dropdown .notification-content {
    color: inherit;
}

/* Dark theme overrides when html[data-theme="dark"] is set */
html[data-theme="dark"] .notification-dropdown {
    background: #0f1724;
    /* dark surface */
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: #e6eef8;
    box-shadow: 0 10px 30px rgba(2, 6, 23, 0.6);
}

html[data-theme="dark"] .notification-dropdown .notification-header,
html[data-theme="dark"] .notification-dropdown .notification-footer {
    border-bottom-color: rgba(255, 255, 255, 0.03);
}

html[data-theme="dark"] .notification-dropdown .notification-item {
    border-bottom-color: rgba(255, 255, 255, 0.02);
}

html[data-theme="dark"] .notification-dropdown .notification-item.unread {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.06), transparent);
}

/* Activity logs: ensure dark theme overrides inline white backgrounds and table surfaces */
html[data-theme="dark"] .card-container.activity-logs,
html[data-theme="dark"] .card-container.activity-logs .card-body,
html[data-theme="dark"] .activity-logs .table-wrapper,
html[data-theme="dark"] .activity-logs .table-wrapper .table,
html[data-theme="dark"] .activity-logs .table tbody tr,
html[data-theme="dark"] .activity-logs .table thead th,
html[data-theme="dark"] .activity-logs .table td,
html[data-theme="dark"] .activity-logs .table th {
    background: transparent !important;
    color: var(--text-primary) !important;
}

html[data-theme="dark"] .card-container.activity-logs {
    background: var(--surface) !important;
    border: 1px solid rgba(255,255,255,0.04) !important;
    box-shadow: 0 8px 24px rgba(2,6,23,0.6) !important;
}

html[data-theme="dark"] .activity-logs .table-wrapper {
    background: var(--surface) !important;
    border: 1px solid rgba(255,255,255,0.04) !important;
}

html[data-theme="dark"] .activity-logs .log-summary-row td {
    border-color: rgba(255,255,255,0.03) !important;
}

/* Avatars in activity logs: ensure visible on dark background */
html[data-theme="dark"] .activity-logs .avatar {
    background: rgba(255,255,255,0.02) !important;
    color: var(--text-primary) !important;
    border: 1px solid rgba(255,255,255,0.03) !important;
}

/* Adjust activity-log specific badges for dark mode */
html[data-theme="dark"] .activity-logs .type-badge,
html[data-theme="dark"] .activity-logs .action-badge,
html[data-theme="dark"] .activity-logs .badge-task,
html[data-theme="dark"] .activity-logs .badge-user,
html[data-theme="dark"] .activity-logs .badge-file,
html[data-theme="dark"] .activity-logs .badge-generic {
    background: rgba(255,255,255,0.03) !important;
    color: var(--text-primary) !important;
    border: 1px solid rgba(255,255,255,0.04) !important;
}

/* Status pill in metadata: make sure text is readable when inline bg is light */
html[data-theme="dark"] .activity-logs .status-pill {
    color: var(--text-primary) !important;
}

/* Ensure 'Details' / secondary buttons are muted in dark mode (not bright white) */
html[data-theme="dark"] .activity-logs a.btn.btn-details,
html[data-theme="dark"] .activity-logs .btn.btn-details,
html[data-theme="dark"] .activity-logs .details-toggle,
html[data-theme="dark"] .activity-logs .btn-outline-secondary,
html[data-theme="dark"] .activity-logs .btn-outline-light {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border: 1px solid rgba(255,255,255,0.05) !important;
    box-shadow: none !important;
}

/* Also ensure log-details-row background isn't bright */
html[data-theme="dark"] .activity-logs .log-details-row {
    background: transparent !important;
}


/* Ensure avatars remain perfectly square and circular across breakpoints.
   Some views define multiple conflicting avatar sizes; this small override
   enforces a 1:1 aspect ratio and prevents stretching into an oval on phones. */
.avatar, .avatar-sm, .avatar-md, .avatar-lg, .avatar-xl {
    box-sizing: border-box;
    aspect-ratio: 1 / 1;
    height: auto;
}

@media (max-width: 720px) {
    .avatar, .avatar-sm, .avatar-md, .avatar-lg, .avatar-xl {
        width: 40px !important;
        aspect-ratio: 1 / 1 !important;
        height: auto !important;
    }

    .avatar-img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        display: block !important;
    }
}

/* Pagination component styles (used by various templates) */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.pagination .pagination-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.pagination .pagination-pages {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.pagination a,
.pagination .page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-primary);
    text-decoration: none;
    min-width: 38px;
}

.pagination .current {
    padding: 0.45rem 0.75rem;
    background: var(--primary);
    color: #fff;
    border-radius: 8px;
    border: 1px solid var(--primary);
}

.pagination .pagination-prev,
.pagination .pagination-next {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.3rem 0.5rem;
    border-radius: 6px;
    color: var(--text-secondary);
}

.pagination .pagination-prev.disabled,
.pagination .pagination-next.disabled,
.pagination .page-item.disabled .page-link {
    opacity: 0.55;
    pointer-events: none;
}

.pagination .pagination-ellipsis {
    padding: 0.35rem 0.6rem;
    color: var(--text-secondary);
}

.pagination ul.pagination {
    display: flex;
    gap: 0.35rem;
    list-style: none;
    padding: 0;
    margin: 0;
}

.pagination ul.pagination .page-item .page-link:hover {
    background: var(--surface-hover);
}

@media (max-width: 720px) {
    .pagination {
        justify-content: center;
    }
    .pagination .pagination-info {
        display: none;
    }
}

/* Support for Bootstrap-style unordered pagination lists (used by activity_logs.html) */
ul.pagination {
    display: flex !important;
    gap: 0.35rem;
    list-style: none !important;
    padding: 0 !important;
    margin: 20px !important;
    align-items: center;
    justify-content: center;
}

ul.pagination li.page-item {
    display: inline-block;
}

ul.pagination li.page-item .page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-primary);
    text-decoration: none;
    min-width: 38px;
}

ul.pagination li.page-item.active .page-link {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

ul.pagination li.page-item.disabled .page-link {
    opacity: 0.55;
    pointer-events: none;
}

ul.pagination li.page-item .page-link:hover {
    background: var(--surface-hover);
}

/* Strong enforcement: force pagination items inline in case other rules cascade */
ul.pagination {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.4rem !important;
    list-style: none !important;
    padding: 0 !important;
    margin: 20px !important;
}

/* Login page dark-mode fixes ------------------------------------------------- */
html[data-theme="dark"] .auth-page {
    background: linear-gradient(135deg, rgba(99,102,241,0.12), rgba(139,92,246,0.06));
}

html[data-theme="dark"] .auth-card {
    background: var(--surface) !important;
    color: var(--text-primary) !important;
    box-shadow: 0 18px 50px rgba(2,6,23,0.55) !important;
    border: 1px solid rgba(255,255,255,0.04) !important;
}

html[data-theme="dark"] .auth-header h1,
html[data-theme="dark"] .auth-header p,
html[data-theme="dark"] .auth-header .auth-logo {
    color: var(--text-primary) !important;
}

/* Form controls on login */
html[data-theme="dark"] .auth-form .form-control {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border: 1px solid rgba(255,255,255,0.06) !important;
    box-shadow: none !important;
}

html[data-theme="dark"] .auth-form .form-control::placeholder {
    color: var(--text-tertiary) !important;
    opacity: 1;
}

html[data-theme="dark"] .auth-form .form-group label,
html[data-theme="dark"] .auth-form .form-label {
    color: var(--text-secondary) !important;
}

/* Alerts on login page */
html[data-theme="dark"] .auth-card .alert {
    background: rgba(255,255,255,0.03) !important;
    color: var(--text-primary) !important;
    border: 1px solid rgba(255,255,255,0.04) !important;
}

/* Primary button: keep gradient but ensure contrast in dark */
html[data-theme="dark"] .auth-card .btn-primary {
    color: #fff !important;
    box-shadow: 0 8px 30px rgba(99,102,241,0.16) !important;
}

/* Make the small remember checkbox label more visible in dark */
html[data-theme="dark"] .auth-card .form-group input[type="checkbox"] + label {
    color: var(--text-secondary) !important;
}

/* Ensure icon color inside auth-logo is visible */
html[data-theme="dark"] .auth-logo i {
    color: var(--primary) !important;
}

/* Fallback: if theme cookie missing, allow prefers-color-scheme to influence card */
@media (prefers-color-scheme: dark) {
    .auth-card:not([data-theme]) {
        background: var(--surface) !important;
    }
}


ul.pagination li,
ul.pagination li.page-item {
    display: inline-flex !important;
    flex: 0 0 auto !important;
    margin: 0 !important;
    vertical-align: middle !important;
}

/* Ensure the page-link boxes don't expand full width */
ul.pagination li.page-item .page-link {
    white-space: nowrap !important;
    width: auto !important;
    min-width: 36px !important;
    padding: 0.35rem 0.65rem !important;
}