:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #eef2ff;
    --danger: #b91c1c;
    --danger-light: #fef2f2;
    --success: #047857;
    --success-light: #ecfdf5;
    --warning: #92400e;
    --warning-light: #fef3c7;
    --bg: #f8f9ff;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #0b1c30;
    --muted: #5b6b84;
    --sidebar-bg: #ffffff;
    --sidebar-border: #e2e8f0;
    --sidebar-text: #475569;
    --sidebar-hover-bg: #f1f5f9;
    --sidebar-active-bg: #e0e7ff;
    --sidebar-active-text: #4338ca;
    --sidebar-width: 280px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, .05), 0 1px 2px rgba(15, 23, 42, .03);
    --shadow-md: 0 4px 6px rgba(15, 23, 42, .06), 0 2px 4px rgba(15, 23, 42, .04);
    --shadow-lg: 0 16px 30px rgba(15, 23, 42, .1), 0 6px 12px rgba(15, 23, 42, .04);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Cairo", "Tahoma", "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    font-weight: 700;
    letter-spacing: -.01em;
    color: var(--text);
}

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

/* ---- App shell / sidebar layout ---- */

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

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    border-left: 1px solid var(--sidebar-border);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 26px 22px;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -.01em;
    color: var(--text);
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-brand i {
    font-size: 18px;
    color: #fff;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), #6d5ff0);
    box-shadow: 0 4px 10px rgba(67, 56, 202, .45);
    flex-shrink: 0;
}

.brand-logo { height: 30px; width: auto; max-width: 170px; object-fit: contain; }

.sidebar-nav {
    flex: 1;
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sidebar-footer {
    padding: 14px;
    border-top: 1px solid var(--sidebar-border);
}

.app-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 14px 4px;
    font-size: 11px;
    color: var(--sidebar-text);
    direction: ltr;
}

.app-footer a { color: inherit; text-decoration: underline; }
.app-footer a:hover { color: var(--primary); }

.guest-footer {
    color: var(--muted);
    padding-top: 0;
}

.guest-footer a { color: var(--muted); }
.guest-footer a:hover { color: var(--primary); }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 14px;
    font-weight: 500;
    transition: background .15s, color .15s, box-shadow .15s;
}

.nav-item i { font-size: 17px; width: 20px; text-align: center; }

.nav-item:hover { background: var(--sidebar-hover-bg); color: var(--text); }

.nav-item.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    box-shadow: 0 6px 16px rgba(67, 56, 202, .3);
}

.nav-item.logout { color: var(--danger); }
.nav-item.logout:hover { background: var(--danger-light); color: var(--danger); }

.nav-group {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: 2px;
}

.nav-group > .nav-item { flex: 1; }

.nav-group-toggle {
    background: transparent;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    width: 34px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    position: absolute;
    top: 7px;
    right: 145px;
    height: 34px;
    width: 30px;
    z-index: 1;
}

.nav-group-toggle:hover { background: var(--sidebar-hover-bg); color: var(--text); }

.nav-group-toggle i { font-size: 13px; transition: transform .15s; }

.nav-group.open .nav-group-toggle { background: var(--sidebar-hover-bg); color: var(--text); }
.nav-group.open .nav-group-toggle i { transform: rotate(180deg); }

/* Flyout: opens beside the item, to its left, instead of pushing content down */
.nav-subitems {
    display: none;
    flex-direction: column;
    gap: 2px;
    position: absolute;
    top: 0;
    right: 100%;
    margin-right: 8px;
    min-width: 220px;
    background: var(--sidebar-bg);
    border: 1px solid var(--sidebar-border);
    border-radius: var(--radius-md);
    padding: 6px;
    box-shadow: var(--shadow-lg);
    z-index: 40;
}

.nav-group.open .nav-subitems { display: flex; }

.nav-subitems .nav-item {
    font-size: 13px;
    padding: 9px 14px;
    white-space: nowrap;
}

.nav-subitems .nav-item i { font-size: 14px; }

.main-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    box-shadow: 0 1px 0 rgba(32, 29, 43, .06);
    padding: 18px 32px;
    position: relative;
    z-index: 5;
}

.page-title { font-size: 21px; margin: 0; font-weight: 800; }

.user-menu { display: flex; align-items: center; gap: 10px; }

.user-role-badge {
    font-size: 12px;
    font-weight: 600;
    background: var(--primary-light);
    color: var(--primary);
    padding: 4px 12px;
    border-radius: 999px;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #6d5ff0);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 3px 8px rgba(67, 56, 202, .3);
}

.user-name { font-size: 14px; font-weight: 700; }

.content {
    flex: 1;
    max-width: 1120px;
    width: 100%;
    margin: 0 auto;
    padding: 28px 32px;
}

.content.guest {
    max-width: none;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    background:
        radial-gradient(circle at 15% 15%, rgba(67, 56, 202, .08), transparent 45%),
        radial-gradient(circle at 85% 85%, rgba(67, 56, 202, .06), transparent 45%),
        var(--bg);
}

.guest-body {
    flex: 1 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 28px;
}

.guest-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.guest-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 21px;
    font-weight: 800;
    color: var(--text);
}

.guest-brand i {
    font-size: 20px;
    color: #fff;
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), #6d5ff0);
    box-shadow: 0 6px 16px rgba(67, 56, 202, .35);
}

.guest-brand .brand-logo { height: 38px; }

/* ---- Shared components ---- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 22px;
    box-shadow: var(--shadow-sm);
}

.card h3 { margin-top: 0; font-size: 17px; }

/* ---- Modern task form ---- */

.task-form-card {
    background: linear-gradient(180deg, var(--primary-light) 0%, var(--surface) 160px);
    border-color: #ded9fb;
}

.card-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.card-heading h3 { margin: 0; }

.card-heading-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.field-hint {
    margin: 2px 0 8px;
    font-size: 12.5px;
}

.checklist-builder {
    background: #faf9f7;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px;
}

.checklist-input-row {
    display: flex;
    gap: 8px;
}

.checklist-input-row input { flex: 1; background: #fff; }

.btn-icon {
    flex-shrink: 0;
    width: 42px;
    border: none;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 8px rgba(67, 56, 202, .25);
    transition: transform .12s, box-shadow .12s;
}

.btn-icon:hover { transform: translateY(-1px); box-shadow: 0 5px 12px rgba(67, 56, 202, .32); }

.checklist-items {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.checklist-items li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    font-size: 14px;
    animation: checklist-in .15s ease-out;
}

.checklist-items li span { display: flex; align-items: center; gap: 8px; }
.checklist-items li i { color: var(--primary); }

.checklist-remove {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    line-height: 1;
}

.checklist-remove:hover { color: var(--danger); }

@keyframes checklist-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.employee-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0;
}

.employee-chip {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 14px 6px 6px;
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    user-select: none;
    transition: background .15s, border-color .15s, color .15s;
    margin: 0;
}

.employee-chip input { display: none; }

.employee-chip .chip-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #6d5ff0);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

.employee-chip:hover { border-color: var(--primary); }

.employee-chip:has(input:checked) {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary-dark);
    font-weight: 700;
}

.task-submit-btn {
    margin-top: 22px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 15px;
    padding: 13px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    font-size: 13.5px;
}

th, td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    text-align: right;
    line-height: 1.4;
}

td .btn, td button {
    padding: 5px 12px;
    font-size: 12.5px;
    box-shadow: none;
}

th {
    background: #faf9f7;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
    padding: 9px 12px;
}

tbody tr { transition: background .1s; }
tbody tr:hover { background: #faf9f7; }
tbody tr:last-child td { border-bottom: none; }

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
}

.badge-active, .badge-completed { background: var(--success-light); color: var(--success); }
.badge-suspended, .badge-overdue { background: var(--danger-light); color: var(--danger); }
.badge-pending { background: var(--warning-light); color: var(--warning); }
.badge-in_progress { background: var(--primary-light); color: var(--primary); }

.badge-priority-high { background: var(--danger-light); color: var(--danger); }
.badge-priority-medium { background: var(--warning-light); color: var(--warning); }
.badge-priority-low { background: var(--success-light); color: var(--success); }

form.inline { display: inline; }

label { display: block; margin: 12px 0 5px; font-size: 13.5px; font-weight: 600; color: var(--muted); }

input[type=text], input[type=email], input[type=password], input[type=date], textarea, select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    transition: border-color .15s, box-shadow .15s;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 56, 202, .14);
}

button, .btn {
    display: inline-block;
    padding: 9px 18px;
    border: none;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    box-shadow: 0 3px 8px rgba(67, 56, 202, .22);
    transition: transform .12s, box-shadow .12s, background .12s;
}

button:hover, .btn:hover { transform: translateY(-1px); box-shadow: 0 5px 14px rgba(67, 56, 202, .3); }

button.danger { background: var(--danger); box-shadow: none; }
button.success { background: var(--success); box-shadow: none; }

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
    font-weight: 500;
}

.alert-error { background: var(--danger-light); color: var(--danger); }
.alert-success { background: var(--success-light); color: var(--success); }

.login-box {
    max-width: 380px;
    width: 100%;
}

.login-box.card { box-shadow: var(--shadow-lg); border-color: #efece7; }

.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 18px;
    margin-bottom: 22px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.stat-card .stat-label { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.stat-card .stat-value { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.stat-card .stat-sub { font-size: 12px; color: var(--muted); margin-top: 6px; }

.stat-card-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    flex-shrink: 0;
}

/*
 * بطاقة إحصائيات مُجمَّعة (بديل .stat-row عند وجود عدة أرقام مرتبطة بصفحة واحدة —
 * مثل صفحة المهام والمستندات) — كل الأرقام داخل بطاقة واحدة بدل بطاقة منفصلة لكل رقم.
 */
.stat-group {
    display: flex;
    flex-wrap: wrap;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.stat-group-item {
    flex: 1 1 170px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-inline-end: 1px solid var(--border);
}

.stat-group-item:last-child { border-inline-end: none; }

.stat-group-item .stat-card-icon { width: 38px; height: 38px; font-size: 17px; }
.stat-group-item .stat-label { margin-bottom: 4px; }
.stat-group-item .stat-value { font-size: 22px; }

@media (max-width: 720px) {
    .stat-group-item {
        flex: 1 1 100%;
        border-inline-end: none;
        border-block-end: 1px solid var(--border);
    }
    .stat-group-item:last-child { border-block-end: none; }
}

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

/* ---- Dashboard toolbar ---- */

.dashboard-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}

.dashboard-welcome {
    position: relative;
    overflow: hidden;
    min-height: 136px;
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    background: linear-gradient(115deg, #fff 55%, #f1f3ff);
}

.dashboard-welcome::after {
    content: '';
    position: absolute;
    left: -56px;
    bottom: -80px;
    width: 190px;
    height: 190px;
    border-radius: 50%;
    background: rgba(199, 210, 254, .42);
    filter: blur(22px);
}

.dashboard-welcome > div { position: relative; z-index: 1; }
.dashboard-welcome h2 { margin: 7px 0 4px; font-size: 27px; }
.dashboard-welcome p { margin: 0; color: var(--muted); font-size: 14px; }
.dashboard-eyebrow {
    display: inline-flex;
    padding: 3px 10px;
    border-radius: 999px;
    color: var(--primary-dark);
    background: var(--primary-light);
    font-size: 11px;
    font-weight: 700;
}

.dashboard-toolbar .customize-panel {
    margin-bottom: 0;
    min-width: 0;
    padding: 0;
    overflow: hidden;
    border-radius: var(--radius-md);
}

.dashboard-toolbar .customize-panel summary {
    height: 52px;
    padding: 0 16px;
    white-space: nowrap;
}

.dashboard-toolbar .customize-panel[open] { min-width: min(100%, 420px); }
.dashboard-toolbar .customize-panel[open] form { padding: 0 16px 16px; }

.btn-outline {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0 16px;
    height: 52px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-outline.active { background: var(--primary-light); border-color: var(--primary); color: var(--primary-dark); }

/* ---- Dashboard grid: one unified, user-orderable grid of cards ---- */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
    align-items: start;
}

.dashboard-grid > .dash-wide { grid-column: span 2; }
.dashboard-grid > .dash-full { grid-column: 1 / -1; }
.dashboard-grid .card { margin-bottom: 0; }
.dash-widget { min-width: 0; }

.dash-widget .stat-row { margin-bottom: 0; }
.dashboard-grid .stat-card { padding: 16px 18px; }
.dashboard-grid .stat-card .stat-label { margin-bottom: 5px; }
.dashboard-grid .stat-card .stat-value { font-size: 26px; line-height: 1.15; }
.dashboard-grid .stat-card .stat-sub { margin-top: 5px; }
.dashboard-grid .stat-card-icon { width: 38px; height: 38px; font-size: 17px; }
.dashboard-statistics-card {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    padding: 18px;
}

.dashboard-statistics-card .card-heading { margin-bottom: 12px; }
.dashboard-statistics-card .card-heading-icon { width: 34px; height: 34px; font-size: 16px; }
.dashboard-statistics-card .stat-group {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    border: 0;
    border-radius: 0;
    overflow: visible;
}
.dashboard-statistics-card .stat-group-item {
    min-width: 0;
    padding: 8px;
    gap: 7px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.dashboard-statistics-card .stat-card-icon {
    width: 28px;
    height: 28px;
    font-size: 13px;
}
.dashboard-statistics-card .stat-label { margin-bottom: 2px; font-size: 11px; }
.dashboard-statistics-card .stat-value { font-size: 21px; line-height: 1; }

/* Small data cards used by the task and document overview pages. */
.compact-statistics-card {
    width: 230px;
    padding: 18px;
}

.compact-statistics-card .card-heading { margin-bottom: 12px; }
.compact-statistics-card .card-heading-icon { width: 34px; height: 34px; font-size: 16px; }
.compact-statistics-card .stat-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    border: 0;
    border-radius: 0;
    overflow: visible;
}

.compact-statistics-card .stat-group-item {
    min-width: 0;
    padding: 8px;
    gap: 7px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.compact-statistics-card .stat-card-icon { width: 28px; height: 28px; font-size: 13px; }
.compact-statistics-card .stat-label { margin-bottom: 2px; font-size: 11px; }
.compact-statistics-card .stat-value { font-size: 21px; line-height: 1; }
.task-statistics-card { aspect-ratio: 1; }

.overview-row {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    margin-bottom: 24px;
}

.overview-row > .card { margin-bottom: 0; }
.overview-row > .compact-statistics-card { flex: 0 0 230px; }
.quick-access-card { flex: 1; }

@media (max-width: 768px) {
    .overview-row { flex-direction: column; }
    .overview-row > .compact-statistics-card { flex-basis: auto; }
}

.tasks-split-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    align-items: start;
}

.tasks-split-row > .card { margin-bottom: 0; }

@media (max-width: 900px) {
    .tasks-split-row { grid-template-columns: 1fr; }
}

.tabs-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 18px;
}

.tabs-bar-buttons { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.tabs-bar-action { flex-shrink: 0; padding: 8px 14px; font-size: 12.5px; }

.tab-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    background: transparent;
    box-shadow: none;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
    transform: none;
}

.tab-btn:hover { background: transparent; color: var(--text); transform: none; box-shadow: none; }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

@media (max-width: 640px) {
    .tabs-bar { flex-wrap: wrap; }
    .tabs-bar-buttons { overflow-x: auto; flex-wrap: nowrap; }
    .tab-btn { white-space: nowrap; }
}

/* شريط إحصائيات مضغوط بسطر واحد — بديل البطاقة المربعة عندما لا يوجد بجانبها
   بطاقة أخرى تشاركها الصف (مثل صفحة المهام بعد حذف "الوصول السريع"). */
.task-stats-bar { padding-bottom: 14px; }
.task-stats-bar .card-heading { margin-bottom: 10px; }
.task-stats-bar .card-heading-icon { width: 30px; height: 30px; font-size: 14px; }
.task-stats-bar .card-heading h3 { font-size: 14px; }

.stat-group-slim {
    flex-wrap: nowrap;
    overflow-x: auto;
}

.stat-group-slim .stat-group-item {
    flex: 1 1 0;
    min-width: 92px;
    padding: 10px 14px;
    gap: 8px;
}

.stat-group-slim .stat-card-icon { width: 28px; height: 28px; font-size: 13px; flex-shrink: 0; }
.stat-group-slim .stat-label {
    font-size: 10px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.stat-group-slim .stat-value { font-size: 17px; }
.stat-group-slim .stat-group-item > div:last-child { min-width: 0; }

@media (max-width: 640px) {
    .compact-statistics-card { width: 100%; }
}

@media (max-width: 640px) {
    .dash-widget[data-key] { grid-column: 1 / -1 !important; }
    .dashboard-statistics-card { aspect-ratio: auto; min-height: 250px; }
}

.dashboard-grid.reorder-mode .dash-widget[data-key] {
    cursor: grab;
    outline: 2px dashed var(--border);
    outline-offset: 3px;
    border-radius: var(--radius-lg);
}

.dashboard-grid.reorder-mode .dash-widget[data-key]:hover { outline-color: var(--primary); }
.dash-widget.dragging { opacity: .4; }
.dash-widget.drag-over { outline: 2px dashed var(--primary) !important; }

.dash-widget { position: relative; }

.dash-resize-handle {
    display: none;
    position: absolute;
    top: 50%;
    left: -11px;
    transform: translateY(-50%);
    width: 22px;
    height: 42px;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    color: var(--muted);
    cursor: ew-resize;
    z-index: 6;
    touch-action: none;
}

.dashboard-grid.reorder-mode .dash-widget[data-key] .dash-resize-handle { display: flex; }
.dash-resize-handle:hover,
.dash-resize-handle.resizing {
    color: var(--primary);
    border-color: var(--primary);
}

@media (max-width: 640px) {
    .dash-resize-handle { display: none !important; }
}

.quick-actions-card { height: 100%; }
.quick-action-links { display: flex; flex-wrap: wrap; gap: 10px; }

.calendar-card { padding: 20px; }

.calendar-heading { position: relative; }

.calendar-nav {
    margin-inline-start: auto;
    display: flex;
    gap: 2px;
}

.calendar-nav a {
    width: 26px;
    height: 26px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 13px;
}

.calendar-nav a:hover { background: var(--sidebar-hover-bg); color: var(--primary); }

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    text-align: center;
}

.calendar-day-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    padding-bottom: 6px;
}

.calendar-cell {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 12.5px;
    border-radius: var(--radius-sm);
    color: var(--text);
}

.calendar-cell.empty { visibility: hidden; }

.calendar-cell.today {
    background: linear-gradient(135deg, var(--primary), #5b4fe0);
    color: #fff;
    font-weight: 700;
}

.calendar-dots { display: flex; gap: 2px; height: 5px; }

.calendar-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--primary);
}

.calendar-dot-event { background: var(--warning); }
.calendar-cell.today .calendar-dot { background: #fff; }

.calendar-upcoming {
    list-style: none;
    margin: 16px 0 0;
    padding: 14px 0 0;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.calendar-upcoming li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
}

.calendar-upcoming-date {
    color: var(--muted);
    font-weight: 700;
    flex-shrink: 0;
    min-width: 32px;
}

.calendar-upcoming li a { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calendar-upcoming li a:hover { color: var(--primary); }

.calendar-upcoming-event {
    color: var(--warning);
    display: flex;
    align-items: center;
    gap: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calendar-upcoming-delete { margin-inline-start: auto; }

.calendar-upcoming-delete button {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 11px;
    padding: 2px;
}

.calendar-upcoming-delete button:hover { color: var(--danger); }

.calendar-add {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.calendar-add summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 6px;
    list-style: none;
}

.calendar-add summary::-webkit-details-marker { display: none; }
.calendar-add form { margin-top: 10px; }

@media (max-width: 640px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .dashboard-grid > .dash-wide { grid-column: span 1; }
}

/* ---- Customization panel ---- */

.customize-panel summary {
    cursor: pointer;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    list-style: none;
}

.customize-panel summary::-webkit-details-marker { display: none; }

.customize-panel form { margin-top: 16px; }

.widget-options {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

.widget-option {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--text);
    margin: 0;
}

.widget-option input { width: auto; }

/* ---- Task detail ---- */

.task-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.task-header h3 { margin: 0; font-size: 19px; }

.task-badges { display: flex; gap: 6px; }

.task-description {
    color: var(--text);
    line-height: 1.8;
    margin: 16px 0;
}

.task-meta-label { color: var(--text); font-weight: 700; }

.task-status-form label { margin-top: 4px; }

/* ---- Task detail: single unified card, details/status to the side ---- */

.task-detail-card { padding: 26px; }

.task-detail-top {
    display: flex;
    gap: 24px;
    padding-bottom: 22px;
    margin-bottom: 22px;
    border-bottom: 1px solid var(--border);
}

.task-detail-main { flex: 1; min-width: 0; }

.task-detail-side {
    flex: 0 0 250px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-inline-start: 22px;
    border-inline-start: 1px solid var(--border);
}

.task-meta-list { display: flex; flex-direction: column; gap: 10px; }
.task-meta-list > div { display: flex; flex-direction: column; gap: 2px; }
.task-meta-list .task-meta-label { font-size: 11px; font-weight: 700; color: var(--muted); }
.task-meta-list strong { font-size: 13px; color: var(--text); }

.task-side-actions { display: flex; gap: 8px; }
.task-side-actions .btn, .task-side-actions button { flex: 1; text-align: center; justify-content: center; display: flex; align-items: center; gap: 6px; }

.task-detail-section { padding-top: 22px; border-top: 1px solid var(--border); }
.task-detail-section:first-of-type { padding-top: 0; border-top: 0; }
.task-detail-section h4 { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; font-size: 14px; }
.task-detail-section h4 i { color: var(--primary); }

.task-detail-inline-section { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); }
.task-detail-inline-section h4 { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 14px; }
.task-detail-inline-section h4 i { color: var(--primary); }

.task-feed { display: flex; flex-direction: column; gap: 12px; margin-bottom: 6px; }
.task-feed-item { display: flex; gap: 10px; align-items: flex-start; }
.task-feed-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 50%;
    background: #f1f5f9;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}
.task-feed-item.is-comment .task-feed-icon { background: var(--primary-light); color: var(--primary); }
.task-feed-body { flex: 1; min-width: 0; }
.task-feed-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 3px; font-size: 12px; }
.task-feed-author { font-weight: 700; font-size: 13px; }
.task-feed-note { color: var(--muted); }
.task-feed-date { color: var(--muted); font-size: 11px; margin-inline-start: auto; }
.task-feed-text { font-size: 13.5px; line-height: 1.7; color: var(--text); }

@media (max-width: 768px) {
    .task-detail-card { padding: 18px; }
    .task-detail-top { flex-direction: column; }
    .task-detail-side {
        border-inline-start: 0;
        padding-inline-start: 0;
        border-top: 1px solid var(--border);
        padding-top: 18px;
    }
}

/* ---- Task checklist (detail page) ---- */

.task-checklist {
    list-style: none;
    margin: 0 0 14px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.checklist-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #faf9f7;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 11px 14px;
    cursor: pointer;
    font-size: 14px;
    text-align: right;
    color: var(--text);
    box-shadow: none;
    transition: border-color .12s, background .12s;
}

.checklist-toggle:hover { border-color: var(--primary); background: #fff; transform: none; box-shadow: none; }
.checklist-toggle i { font-size: 16px; color: var(--muted); flex-shrink: 0; }

.checklist-toggle.done { background: var(--success-light); }
.checklist-toggle.done i { color: var(--success); }
.checklist-toggle.done span { color: var(--muted); text-decoration: line-through; }

.checklist-add-form {
    display: flex;
    gap: 8px;
}

.checklist-add-form input { flex: 1; }

/* ---- Comments ---- */

.comment-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.comment-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 13px 15px;
}

.comment-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 12px;
}

.comment-author { font-weight: 700; font-size: 13px; }

.comment-date { color: var(--muted); margin-inline-start: auto; }

.comment-text { font-size: 14px; line-height: 1.6; }

/*
 * الجوال: قائمة سفلية ثابتة (الرئيسية / المهام / المستندات / المزيد)، والقائمة
 * الجانبية الكاملة (نفس .sidebar) تتحول إلى قائمة منزلقة من الأسفل تُفتح بزر "المزيد".
 */
.mobile-bottom-nav { display: none; }
.mobile-menu-backdrop { display: none; }
.sidebar-mobile-close {
    display: none;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    margin-inline-start: auto;
    border: none;
    border-radius: 8px;
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-text);
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .app-shell { flex-direction: column; }
    .content { padding: 18px 16px calc(84px + env(safe-area-inset-bottom, 0px)); }
    .form-grid-2 { grid-template-columns: 1fr; }

    .sidebar {
        position: fixed;
        inset: 0;
        z-index: 70;
        width: 100%;
        height: 100%;
        flex-direction: column;
        border: none;
        overflow-y: auto;
        transform: translateY(100%);
        transition: transform .25s ease;
    }

    .sidebar.mobile-open { transform: translateY(0); }

    .sidebar-mobile-close { display: flex; }
    .sidebar-nav { flex-direction: column; padding: 16px; }

    .nav-group { display: block; }
    .nav-group-toggle { position: static; height: auto; width: 34px; }
    .nav-subitems {
        position: static;
        display: none;
        min-width: 0;
        margin: 4px 0 6px;
        padding: 0;
        border: 0;
        box-shadow: none;
        background: transparent;
    }
    .nav-group.open .nav-subitems { display: flex; flex-direction: column; }

    .mobile-menu-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 65;
        background: rgba(15, 23, 42, .35);
    }
    .mobile-menu-backdrop.visible { display: block; }

    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        inset-inline: 0;
        z-index: 60;
        justify-content: space-around;
        background: var(--surface);
        border-top: 1px solid var(--border);
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
        box-shadow: 0 -2px 10px rgba(15, 23, 42, .06);
    }

    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 3px;
        flex: 1;
        padding: 6px 4px;
        border: none;
        background: transparent;
        color: var(--muted);
        font-size: 10px;
        font-weight: 700;
    }
    .mobile-nav-item i { font-size: 19px; }
    .mobile-nav-item.active { color: var(--primary); }
}

/* ---- Stamps / signatures (shared grid used by both) ---- */

.stamp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
}

.stamp-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
    background: #faf9f7;
}

.stamp-item img {
    max-width: 100%;
    max-height: 90px;
    object-fit: contain;
    background: #fff;
    border-radius: var(--radius-sm);
    padding: 6px;
}

.stamp-item span { font-size: 13px; font-weight: 600; }

.stamp-item-actions { display: flex; gap: 6px; }
.stamp-item-actions .btn, .stamp-item-actions button { padding: 5px 12px; font-size: 12.5px; box-shadow: none; }

/* ---- Document view / print ---- */

.document-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.document-sheet {
    display: flex;
    flex-direction: column;
    direction: rtl;
    background: var(--surface);
    background-size: cover;
    background-position: top center;
    background-repeat: no-repeat;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    box-sizing: border-box;
    width: 210mm;
    max-width: 100%;
    aspect-ratio: 210 / 297;
    padding: 20mm;
    margin: 0 auto;
}

.document-body {
    direction: rtl;
    text-align: right;
    font-size: 14.5px;
    line-height: 1.8;
    color: var(--text);
}

.document-body table { margin: 12px 0; }

.rich-editor-wrap { margin-bottom: 4px; }

.rich-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.rich-editor-toolbar button {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
}

.rich-editor-toolbar button:hover { background: var(--border); }

.rich-editor-sep {
    width: 1px;
    align-self: stretch;
    margin: 2px 4px;
    background: var(--border);
}

.rich-editor-fontsize {
    height: 32px;
    padding: 0 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
}

.rich-editor {
    min-height: 320px;
    max-height: 600px;
    overflow-y: auto;
    box-sizing: border-box;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.rich-editor:focus { outline: 2px solid var(--primary); outline-offset: -2px; }

.document-signoff {
    display: flex;
    direction: ltr;
    align-items: flex-end;
    gap: 30px;
    margin-top: auto;
    padding-top: 60px;
}

/* يسار: الختم يوضع أسفل نص المنصب/الاسم والتوقيع (عمود واحد على يسار الصفحة) */
.document-signoff-align-left {
    flex-direction: column;
    align-items: flex-start;
}

/* وسط: الختم يوضع بجوار نص المنصب/الاسم مباشرة */
.document-signoff-align-center {
    flex-direction: row;
    justify-content: flex-start;
}

/* يمين: الختم يوضع بجوار النص لكن باتجاه أقصى يمين الصفحة */
.document-signoff-align-right {
    flex-direction: row;
    justify-content: space-between;
}

.document-signoff-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
}

.document-signoff-text {
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.7;
}

.document-signoff-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.document-signoff-item img { max-height: 80px; max-width: 160px; object-fit: contain; }
.document-signoff-item span { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ---- Modern Arabic Enterprise Portal (Stitch reference adaptation) ---- */

body { background: var(--bg); color: var(--text); }

.sidebar {
    box-shadow: 0 1px 8px rgba(15, 23, 42, .04);
}

.sidebar-brand {
    min-height: 80px;
    padding: 18px 24px;
    gap: 10px;
}

.sidebar-brand i {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--primary);
    box-shadow: 0 4px 10px rgba(79, 70, 229, .2);
}

.sidebar-nav { padding: 16px; gap: 6px; }

.nav-item {
    border-radius: 12px;
    padding: 10px 14px;
    font-weight: 600;
}

.nav-item.active {
    box-shadow: none;
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
}

.nav-group-toggle { color: var(--sidebar-text); }

.nav-subitems {
    background: #fff;
    border-color: var(--border);
    box-shadow: var(--shadow-md);
}

@media (min-width: 769px) {
    /* المهام/المستندات: عنصر رئيسي + زر سهم بجانبه بنفس الصف، والقائمة الفرعية
       تُطوى/تُفتح تحتهما (نفس آلية اللمس بالجوال) بدل أن تكون ظاهرة دائماً. */
    .nav-group {
        display: flex;
        flex-wrap: wrap;
        align-items: stretch;
        gap: 2px;
    }
    .nav-group-toggle {
        position: static;
        height: auto;
        width: 34px;
    }
    .nav-subitems {
        position: static;
        display: none;
        flex-basis: 100%;
        width: 100%;
        min-width: 0;
        margin: 2px 0 5px;
        padding: 2px 14px 2px 0;
        gap: 2px;
        background: transparent;
        border: 0;
        box-shadow: none;
    }
    .nav-group.open .nav-subitems { display: flex; flex-direction: column; }
    .nav-subitems .nav-item {
        min-height: 34px;
        padding: 7px 36px 7px 12px;
        font-size: 11px;
        color: var(--muted);
        border-radius: 9px;
    }
    .nav-subitems .nav-item i { font-size: 12px; }
    .nav-subitems .nav-item:hover { background: #f8fafc; color: var(--primary-dark); }
    .nav-subitems .nav-item.active { background: transparent; color: var(--primary-dark); }
}

.topbar {
    min-height: 80px;
    padding: 18px 32px;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
    box-shadow: none;
}

.page-title { font-size: 24px; }
.page-context { display: flex; flex-direction: column; gap: 3px; }
.page-breadcrumb { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 600; }
.page-breadcrumb i { font-size: 9px; color: #94a3b8; }
.page-breadcrumb strong { color: #475569; }
.global-search {
    display: flex;
    align-items: center;
    gap: 8px;
    width: min(360px, 32vw);
    padding: 0 12px;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #f8fafc;
    color: var(--muted);
}
.global-search:focus-within { border-color: #a5b4fc; background: #fff; box-shadow: 0 0 0 3px rgba(99, 102, 241, .1); }
.global-search input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 12px; }
.global-search input:focus { box-shadow: none; }
.user-menu { gap: 12px; }
.user-role-badge { background: var(--primary-light); color: var(--primary-dark); }
.user-avatar { background: var(--primary); box-shadow: none; }

.content {
    max-width: none;
    padding: 32px;
}

.card {
    border-color: var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-bottom: 24px;
}

.card-heading { margin-bottom: 18px; }
.card-heading h3 { font-size: 18px; }
.card-heading-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--primary-light);
    color: var(--primary);
}

.dashboard-toolbar {
    padding: 16px 20px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.dashboard-toolbar .customize-panel {
    border: 0;
    box-shadow: none;
    background: transparent;
}

.dashboard-toolbar .customize-panel summary,
.btn-outline {
    height: 40px;
    border-radius: 10px;
    font-size: 13px;
}

.btn-outline {
    padding: 0 14px;
    background: var(--primary-light);
    border-color: transparent;
    color: var(--primary-dark);
}

.dashboard-grid { gap: 24px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.dashboard-grid .card { margin-bottom: 0; }
.quick-actions-card { background: #fff; }
.quick-action-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.quick-action-tile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    background: #fff;
    transition: .15s ease;
}
.quick-action-tile:hover { border-color: #c7d2fe; background: #f8faff; color: var(--primary-dark); transform: translateY(-1px); }
.quick-action-tile > i { display: grid; place-items: center; flex: 0 0 34px; width: 34px; height: 34px; border-radius: 10px; background: var(--primary-light); color: var(--primary); font-size: 16px; }
.quick-action-tile span { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.quick-action-tile strong { font-size: 12px; }
.quick-action-tile small { color: var(--muted); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.document-quick-actions { min-width: min(520px, 100%); }
.section-action-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-action-header .card-heading { margin-bottom: 0; }
.section-count { padding: 5px 10px; border-radius: 99px; background: #f1f5f9; color: var(--muted); font-size: 11px; font-weight: 700; white-space: nowrap; }
.employee-create-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; align-items: end; gap: 12px; }
.employee-create-form label { display: block; margin-bottom: 6px; }
.employee-create-form input { width: 100%; margin: 0; }
.employee-create-form button { min-height: 42px; white-space: nowrap; }
.employee-profile-card { border-color: #c7d2fe; background: linear-gradient(105deg, #fff, #f8faff); }
.employee-profile-content { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.employee-profile-avatar { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: var(--primary); color: #fff; font-size: 18px; font-weight: 800; }
.employee-profile-content > div:nth-child(2) { display: flex; flex-direction: column; gap: 2px; margin-inline-end: auto; }
.employee-profile-content span:not(.badge), .employee-profile-content small { color: var(--muted); font-size: 12px; }
.profile-close { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: #f1f5f9; color: var(--muted); }
.btn-secondary { background: #f1f5f9; color: #475569; }
.btn-secondary:hover { background: #e2e8f0; color: #0f172a; }
.dashboard-progress { margin-top: 16px; padding-top: 14px; border-top: 1px solid #f1f5f9; }
.dashboard-progress > div:first-child { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; color: var(--muted); font-size: 11px; font-weight: 700; }
.dashboard-progress strong { color: var(--primary-dark); }
.progress-track { height: 6px; overflow: hidden; background: #e2e8f0; border-radius: 99px; }
.progress-track span { display: block; height: 100%; background: var(--primary); border-radius: inherit; }

.stat-card,
.stat-group-item {
    border-color: var(--border);
    box-shadow: none;
}

.stat-card { border-radius: var(--radius-lg); }
.stat-card-icon { border-radius: 10px; background: var(--primary-light); color: var(--primary); }

.compact-statistics-card,
.dashboard-statistics-card {
    box-shadow: var(--shadow-sm);
}

table { font-size: 13px; }
th, td { border-bottom-color: #f1f5f9; padding: 14px 16px; }
th { background: #f8fafc; color: #475569; font-size: 12px; text-transform: none; }
tbody tr:hover { background: #f8fafc; }

.badge {
    padding: 3px 10px;
    border: 1px solid transparent;
    font-size: 11px;
}
.badge-active, .badge-completed { border-color: #a7f3d0; }
.badge-suspended, .badge-overdue { border-color: #fecaca; }
.badge-pending { border-color: #fde68a; }
.badge-in_progress { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }

.table-filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px; margin: 0 0 8px; border: 1px solid #eef2f7; border-radius: 12px; background: #f8fafc; }
.filter-search { display: flex; align-items: center; gap: 8px; flex: 1 1 210px; min-width: 0; padding: 0 10px; height: 40px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; color: var(--muted); }
.filter-search input { min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; font: inherit; font-size: 12px; }
.filter-search input:focus { box-shadow: none; }
.table-filters select { width: auto; min-width: 130px; min-height: 40px; margin: 0; background: #fff; font-size: 12px; }
.btn-filter { min-height: 40px; padding: 7px 13px; font-size: 12px; }
.filter-reset { padding: 7px 4px; font-size: 12px; font-weight: 700; }
.table-filter-result { margin: 10px 0 12px; color: var(--muted); font-size: 11px; font-weight: 600; }

.search-result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.search-result-grid section { padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: #fbfdff; }
.search-result-grid h4 { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 14px; }
.search-result-grid h4 span { margin-inline-start: auto; padding: 2px 7px; border-radius: 99px; background: var(--primary-light); color: var(--primary-dark); font-size: 11px; }
.search-result-item { display: flex; flex-direction: column; gap: 2px; padding: 9px 0; border-top: 1px solid #eef2f7; color: var(--text); }
.search-result-item:hover strong { color: var(--primary); }
.search-result-item small { color: var(--muted); font-size: 11px; }
.table-row-action { display: inline-grid; place-items: center; width: 28px; height: 28px; margin-inline-start: 6px; border-radius: 8px; color: var(--muted); background: #f1f5f9; vertical-align: middle; }
.table-row-action:hover { color: var(--primary-dark); background: var(--primary-light); }

.workspace-backdrop { position: fixed; inset: 0; z-index: 45; background: rgba(15, 23, 42, .28); backdrop-filter: blur(2px); }
.workspace-preview { position: fixed; inset: 0  auto 0 0; z-index: 50; width: min(520px, 100vw); overflow-y: auto; padding: 28px; background: #fff; box-shadow: -14px 0 36px rgba(15, 23, 42, .16); }
.workspace-preview-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.workspace-preview h2 { margin: 20px 0 12px; font-size: 21px; line-height: 1.55; }
.task-preview > p { margin: 0 0 20px; color: #475569; line-height: 1.9; }
.preview-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 20px 0; }
.preview-meta div { display: flex; flex-direction: column; gap: 3px; padding: 11px; border-radius: 10px; background: #f8fafc; }
.preview-meta small { color: var(--muted); font-size: 10px; }
.preview-meta strong { font-size: 12px; }
.workspace-preview-open { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 24px; }
.document-preview-sheet { max-height: calc(100vh - 210px); overflow: auto; padding: 22px; border: 1px solid var(--border); background: #fff; box-shadow: 0 1px 5px rgba(15, 23, 42, .06); font-size: 13px; line-height: 1.8; }
.document-preview-sheet img { max-width: 100%; height: auto; }

label { color: #334155; font-size: 12px; }
input[type=text], input[type=email], input[type=password], input[type=date], textarea, select {
    min-height: 42px;
    border-color: #cbd5e1;
    border-radius: 8px;
    padding: 9px 12px;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .15);
}

button, .btn {
    background: var(--primary);
    border-radius: 8px;
    box-shadow: none;
    padding: 9px 16px;
}

button:hover, .btn:hover {
    background: var(--primary-dark);
    box-shadow: none;
    transform: none;
}

.task-form-card { background: #fff; border-color: var(--border); }
.task-meta, .checklist-builder, .stamp-item { background: #f8fafc; }
.calendar-card { background: #fff; }
.calendar-cell { border-radius: 10px; }
.calendar-cell.today { background: var(--primary); }

@media (max-width: 768px) {
    .content { padding: 20px 16px calc(84px + env(safe-area-inset-bottom, 0px)); }
    .topbar { min-height: 64px; padding: 12px 16px; flex-wrap: wrap; gap: 12px; }
    .page-title { font-size: 19px; }
    .page-breadcrumb { display: none; }
    .global-search { order: 3; width: 100%; height: 40px; }
    .quick-action-links { grid-template-columns: 1fr; }
    .section-action-header { align-items: flex-start; }
    .employee-create-form { grid-template-columns: 1fr; }
    .dashboard-toolbar { padding: 12px; }
    .table-filters { align-items: stretch; }
    .filter-search, .table-filters select, .btn-filter { flex: 1 1 100%; width: 100%; }
    .filter-reset { text-align: center; }
    .employee-profile-content > div:nth-child(2) { flex: 1 1 140px; }
    .document-sheet { width: 100%; aspect-ratio: auto; padding: 24px 18px; border-radius: 12px; }
    .document-body table { min-width: 0; }
    .document-toolbar > div:last-child { display: flex; flex-wrap: wrap; gap: 8px; }
    .document-toolbar .btn { flex: 1; text-align: center; }
    .task-meta { grid-template-columns: 1fr; }
    .task-status-form > div { flex-wrap: wrap; }
    .task-status-form select, .task-status-form button { width: 100%; }
    .card { padding: 18px; }
    .card:has(table) { overflow-x: auto; }
    table { min-width: 620px; }
    .workspace-preview { width: 100%; padding: 20px 16px; }
    .document-preview-sheet { max-height: calc(100vh - 180px); padding: 16px; }
}

/* بدون هذا، يترك أغلب المتصفحات هامشاً افتراضياً حول الورقة المطبوعة (عادة
   ١-٢سم) حتى لو كانت خلفية القالب مصمَّمة لتغطية الصفحة بالكامل. */
@page {
    size: A4;
    margin: 0;
}

@media print {
    /* الصفحة المطبوعة (A4) قد تحسب أضيق من 768px حسب هوامش الطابعة، فتُفعّل
       بالخطأ قواعد @media (max-width: 768px) الخاصة بشريط الجوال السفلي والقائمة
       المنزلقة — نلغيها هنا صراحة بدل الاعتماد على عدم تطابق العرض. */
    .sidebar,
    .topbar,
    .document-toolbar,
    .customize-panel,
    .app-footer,
    .mobile-bottom-nav,
    .mobile-menu-backdrop { display: none !important; }
    .content { padding: 0 !important; max-width: none; }
    .document-sheet {
        box-shadow: none;
        border: none;
        width: 210mm;
        min-height: 297mm;
        margin: 0;
        /* الحشوة تبقى كما هي على الشاشة (20mm) — تُبعد النص عن حافة الورقة،
           بينما الخلفية نفسها تمتد لحافة الصندوق بالكامل افتراضياً
           (background-origin: padding-box) بلا حاجة لإزالة الحشوة. */
    }
}
