@import url("fonts.088810a74751.css");
/* ==========================================================================
   نظام التصميم — ملف واحد لكل الشاشات.
   الترتيب: الخطوط ← المتغيرات ← الأساس ← الهيكل ← المكونات ← الأنماط الخاصة ← الأدوات.
   لا تُكتب تنسيقات داخل القوالب؛ أضف المكوّن هنا ثم استخدمه.
   ========================================================================== */

/* ---------- الخطوط ---------- */

/* ---------- المتغيرات ---------- */
:root {
    /* الأسطح والحبر: أسطح بيضاء على خلفية باردة هادئة، وحبر كحلي */
    --bg: #f3f5fa;
    --surface: #ffffff;
    --surface-2: #f8f9fc;
    --surface-3: #edf0f6;
    --line: #e2e6ef;
    --line-strong: #c9d0de;
    --ink: #141a2e;
    --ink-2: #323a52;
    --muted: #646e86; /* أغمق قليلًا من السابق (#677189) ليبلغ تباين النص الثانوي على الخلفية الرمادية 4.5:1 */
    --faint: #9ba4b9;

    /* الهوية: الأزرق الملكي للفعل والتنقل، وذهبي شعار Together للدور والتنبيه */
    --brand: #2f55e4;
    --brand-strong: #2242c2;
    --brand-soft: #eaeffe;
    --brand-line: #c7d3fb;
    /* لون «الدور عليك / يحتاج انتباهك»: بنفسجي بجانب الأزرق. الذهبي يبقى في الشعار فقط. */
    --sun: #7450e0;
    --sun-strong: #5f3cc8;
    --sun-soft: #f1edfe;
    --sun-line: #d7cbfa;
    --sun-ink: #4b2ea6;
    --link: #2242c2;
    /* خلفية الزر الملوّن عند المرور أو الضغط (منفصلة عن --brand-strong لأن الأخير لون نص في الداكن) */
    --brand-press: #2242c2;
    --sun-press: #5f3cc8;

    /* الحالات */
    --ok: #16804d;      --ok-soft: #e4f6ec;    --ok-line: #b5e2c8;
    --warn: #a85d00;    --warn-soft: #fdf0d8;  --warn-line: #f3d59b;
    --bad: #c5352c;     --bad-soft: #fdebe9;   --bad-line: #f4c2bc;
    /* نص الإشعارات على الخلفيات الخافتة (أغمق من لون الحالة ليُقرأ) */
    --ok-ink: #0f5236;  --warn-ink: #6b3f00;  --bad-ink: #86241b;  --info-ink: #1d3f7d;
    --info: #0c7d92;    --info-soft: #e2f5f8;  --info-line: #b3e1e9;

    /* الشريط الجانبي: فاتح ليحمل الشعار كما هو */
    --side-bg: #ffffff;
    --side-ink: #323a52;
    --side-muted: #8791a8;
    --side-hover: #f1f3f9;
    --side-active: #eaeffe;
    --panel: #131b3a;
    --panel-ink: #c9d1ea;
    --panel-line: #2c3765;

    /* القياسات */
    --r-sm: 7px;
    --r: 10px;
    --r-lg: 14px;
    --r-xl: 18px;
    --shadow-1: 0 1px 2px rgba(20, 26, 46, 0.05);
    --shadow-2: 0 10px 28px -10px rgba(20, 26, 46, 0.22), 0 2px 6px rgba(20, 26, 46, 0.06);
    --shadow-3: 0 24px 60px -16px rgba(20, 26, 46, 0.38);
    --focus: 0 0 0 3px rgba(47, 85, 228, 0.25);
    --side-w: 248px;
    --top-h: 60px;
    --content-max: 1240px;
    --font: "Thmanyah Sans", "Segoe UI", Tahoma, sans-serif;
    /* العناوين بالخط نفسه بوزن أثقل؛ الخط المزخرف جعل الواجهة تبدو مطبوعة لا تطبيقًا */
    --font-display: "Thmanyah Sans", "Segoe UI", Tahoma, sans-serif;
    --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* ---------- المظهر الداكن ----------
   يُفعَّل بـ data-theme="dark" على <html>: يضعه الخادم عند اختيار «داكن» صراحة، ويضعه app/js/theme.js
   عند «تلقائي» إن كان الجهاز داكنًا. القيم هنا تستبدل المتغيرات فقط، والمكوّنات كلها تبنى عليها؛
   ما يحتاج قاعدة خاصة (الشعار وألوان المشاريع والمحرر) تحت المتغيرات مباشرة. للشاشة فقط: الطباعة تبقى فاتحة. */
@media screen {
    :root[data-theme="dark"] {
        color-scheme: dark;

        --bg: #0d111c;
        --surface: #151a28;
        --surface-2: #1a2030;
        --surface-3: #232a3d;
        --line: #283047;
        --line-strong: #37415c;
        --ink: #e7eaf3;
        --ink-2: #c2c8d8;
        --muted: #959eb5;
        --faint: #6b7592;

        --brand: #4f6ff0;
        --brand-strong: #a9b9ff;
        --brand-soft: #1c2646;
        --brand-line: #34477f;
        --brand-press: #6381f4;
        --sun: #7c5ce6;
        --sun-strong: #bba9ff;
        --sun-soft: #241d42;
        --sun-line: #473a86;
        --sun-ink: #cbbdff;
        --sun-press: #9076ee;
        --link: #8fa7ff;

        --ok: #2ea86a;      --ok-soft: #11291e;    --ok-line: #1f5239;
        --warn: #e0a03e;    --warn-soft: #2c2211;  --warn-line: #644819;
        --bad: #ef5d52;     --bad-soft: #34191b;   --bad-line: #74302c;
        --ok-ink: #9be3bd;  --warn-ink: #f6d08f;  --bad-ink: #ffb3ab;  --info-ink: #b7d4ff;
        --info: #38b4ca;    --info-soft: #0f272e;  --info-line: #1d5360;

        --side-bg: #151a28;
        --side-ink: #c2c8d8;
        --side-muted: #8a93ab;
        --side-hover: #1f2638;
        --side-active: #1c2646;
        --panel: #1b2452;
        --panel-ink: #c9d1ea;
        --panel-line: #34407b;

        --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow-2: 0 10px 28px -10px rgba(0, 0, 0, 0.65), 0 2px 6px rgba(0, 0, 0, 0.3);
        --shadow-3: 0 24px 60px -16px rgba(0, 0, 0, 0.75);
        --focus: 0 0 0 3px rgba(111, 141, 255, 0.35);

        /* محرر الملاحظات (Jodit) يقرأ ألوانه من متغيراته الخاصة */
        --jd-color-background-default: var(--surface);
        --jd-color-panel: var(--surface-2);
        --jd-color-border: var(--line-strong);
        --jd-color-separator: var(--line);
        --jd-color-text: var(--ink);
        --jd-color-dark: var(--ink);
        --jd-color-icon: var(--ink-2);
        --jd-color-text-icons: var(--ink-2);
        --jd-color-label: var(--muted);
        --jd-color-placeholder: var(--faint);
        --jd-color-background-button-hover: var(--surface-3);
        --jd-color-button-background-hover: var(--surface-3);
        --jd-color-background-light-gray: var(--surface-2);
        --jd-color-background-gray: var(--surface-3);
        --jd-color-background-active: var(--brand-soft);
        --jd-color-background-selection: var(--brand-soft);
    }
    /* الشعار مرسوم بحبر داكن لخلفية بيضاء: يُقلب سطوعه ويبقى لونه */
    :root[data-theme="dark"] :is(.brand-logo, .brand-mark, .auth__logo) { filter: invert(1) hue-rotate(180deg); }
    :root[data-theme="dark"] .sidebar { --side-muted: #8a93ab; }
    /* ألوان المشاريع والحالات: الخلفية الفاتحة تصبح مزيجًا خافتًا من اللون نفسه */
    :root[data-theme="dark"] :is(.status-pill, .status-dot, .board-col, .project-badge, .project-chip, .project-dot,
        .project-card, .project-head, .project-scope, .swatch, .file-icon) {
        --c-soft: color-mix(in srgb, var(--c) 22%, var(--surface));
    }
    :root[data-theme="dark"] :is(.file-icon, .project-card__mine, .project-card:hover .project-card__go) {
        color: color-mix(in srgb, var(--c) 55%, var(--ink));
    }
    :root[data-theme="dark"] :is(dialog.modal, dialog.dialog)::backdrop { background: rgba(0, 0, 0, 0.6); }
    :root[data-theme="dark"] :is(.ts-control, .ts-dropdown) { color: var(--ink); }
}

/* ---------- الأساس ---------- */
.is-theme-changing *, .is-theme-changing *::before, .is-theme-changing *::after { transition: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 600; line-height: 1.35; color: var(--ink); text-wrap: balance; }
h1 { font-size: 28px; font-weight: 800; line-height: 1.4; letter-spacing: -0.01em; }
h2 { font-size: 19px; font-weight: 700; }
h3 { font-size: 15.5px; font-family: var(--font); font-weight: 700; }
p { margin: 0; }
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--ink); }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
ul, ol { margin: 0; padding: 0; list-style: none; }
hr { border: 0; border-top: 1px solid var(--line); margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--brand-line); }
.num, time, .table td.num { font-variant-numeric: tabular-nums; }

.icon { width: 18px; height: 18px; flex: none; vertical-align: -0.2em; }
.icon--sm { width: 15px; height: 15px; }
.icon--lg { width: 22px; height: 22px; }
.icon--xl { width: 28px; height: 28px; }
/* الأسهم الاتجاهية تنقلب مع اتجاه الصفحة */
[dir="rtl"] .icon--flip { transform: scaleX(-1); }

.skip-link { position: absolute; inset-inline-start: 12px; top: -60px; z-index: 100; padding: 8px 14px; border-radius: var(--r); background: var(--ink); color: var(--bg); }
.skip-link:focus { top: 12px; color: var(--bg); }

/* ---------- الهيكل العام ---------- */
.app { min-height: 100vh; }
.sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 40;
    width: var(--side-w);
    display: flex; flex-direction: column;
    background: var(--side-bg); color: var(--side-ink);
    border-inline-end: 1px solid var(--line);
}
.sidebar__brand { display: flex; align-items: center; height: 96px; padding: 16px 20px 10px; flex: none; }
.brand-logo { display: block; height: 64px; width: auto; max-width: 100%; object-fit: contain; }
.brand-mark { width: 36px; height: 36px; flex: none; display: block; object-fit: contain; }
.brand-fallback { font-family: var(--font); font-size: 17px; font-weight: 700; color: var(--ink); }
.brand-name { display: grid; min-width: 0; line-height: 1.3; }
.brand-name strong { font-family: var(--font); font-weight: 700; font-size: 15px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-name span { font-size: 11.5px; color: var(--side-muted); }

.sidebar__nav { flex: 1; overflow-y: auto; padding: 10px 12px 16px; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.nav-group + .nav-group { margin-top: 18px; }
.nav-group__label { padding: 0 12px 6px; font-size: 12px; font-weight: 500; color: var(--side-muted); }
.nav-item { display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 8px 12px; border-radius: var(--r); color: var(--side-ink); font-family: var(--font); font-size: 14.5px; font-weight: 500; transition: background .15s var(--ease), color .15s var(--ease); }
.nav-item .icon { color: var(--side-muted); transition: color .15s var(--ease); }
.nav-item:hover { background: var(--side-hover); color: var(--ink); }
.nav-item:hover .icon { color: var(--ink); }
.nav-item.is-active { background: var(--side-active); color: var(--brand-strong); font-weight: 700; }
.nav-item.is-active .icon { color: var(--brand); }


.nav-item__count { margin-inline-start: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--sun); color: #fff; font-size: 11.5px; font-weight: 700; line-height: 20px; text-align: center; font-variant-numeric: tabular-nums; }

.sidebar__foot { flex: none; padding: 10px 12px; border-top: 1px solid var(--line); }
.user-card { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; }
.user-card__me { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; border-radius: 8px; color: inherit; }
.user-card__me:hover { background: var(--side-hover); text-decoration: none; }
/* ملفي: الصورة مع زر تغييرها، ثم الحقول */
.profile-photo { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.profile-photo__text { display: grid; gap: 8px; min-width: 0; flex: 1 1 220px; }
.profile-photo__text p { color: var(--muted); font-size: 13px; }
.profile-photo__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.profile-photo__pick { position: relative; overflow: hidden; }
.profile-photo__pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.user-card__text { display: grid; min-width: 0; flex: 1; line-height: 1.35; }
.user-card__text strong { font-size: 13.5px; font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card__text span { font-size: 11.5px; color: var(--side-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card .icon-btn { color: var(--side-muted); }
.user-card .icon-btn:hover { background: var(--side-hover); color: var(--ink); }
/* مبدّل المظهر أسفل الشريط الجانبي: فاتح / داكن / تلقائي (يتبع الجهاز) */
.theme-switch { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; margin-bottom: 8px; padding: 3px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
.theme-switch button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-width: 0; min-height: 30px; padding: 4px 6px; border: 0; border-radius: 7px; background: transparent; color: var(--side-muted); font-size: 12.5px; font-weight: 600; cursor: pointer; transition: background .15s var(--ease), color .15s var(--ease); }
.theme-switch button:hover { color: var(--ink); }
.theme-switch button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.theme-switch button[aria-checked="true"] .icon { color: var(--brand); }
.theme-switch .icon { width: 14px; height: 14px; }

.main { margin-inline-start: var(--side-w); min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 30; display: none; align-items: center; gap: 10px; height: var(--top-h); padding-inline: 12px; background: var(--surface); border-bottom: 1px solid var(--line); }

.topbar .icon-btn { color: var(--ink); }

.content { width: 100%; max-width: var(--content-max); margin-inline: auto; padding: 36px 40px 72px; flex: 1; }
.content--narrow { max-width: 820px; }
.content > * + * { margin-top: 24px; }
.scrim { position: fixed; inset: 0; z-index: 35; border: 0; background: rgba(20, 26, 46, 0.45); opacity: 0; pointer-events: none; transition: opacity .2s var(--ease); }

@media (max-width: 1023px) {
    /* القائمة المغلقة خارج الشاشة ومخفية فعلًا: لا تظهر لو انزاحت الصفحة جانبيًا، ولا يصلها التنقل بالمفاتيح. */
    .sidebar { transform: translateX(100%); visibility: hidden; transition: transform .24s var(--ease), visibility 0s linear .24s; width: min(86vw, 300px); }
    .nav-open .sidebar { visibility: visible; transition: transform .24s var(--ease); }
    [dir="ltr"] .sidebar { transform: translateX(-100%); }
    /* الظل للقائمة المفتوحة فقط؛ وهي مغلقة كان ظلها يظهر على حافة الشاشة. */
    .nav-open .sidebar { transform: none; box-shadow: var(--shadow-3); }
    .nav-open .scrim { opacity: 1; pointer-events: auto; }
    .nav-open { overflow: hidden; }
    .main { margin-inline-start: 0; }
    .topbar { display: flex; }
    .content { padding: 20px 16px 56px; }
}

/* ---------- رأس الصفحة ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; }
.page-head__text { min-width: 0; flex: 1 1 320px; display: grid; gap: 4px; }
.page-head__text > p { color: var(--muted); max-width: 68ch; }
.page-head__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.back-link { display: inline-flex; align-items: center; gap: 5px; width: fit-content; margin-bottom: 4px; color: var(--muted); font-size: 13px; font-weight: 500; }
.back-link:hover { color: var(--ink); }
.eyebrow { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 500; }
.eyebrow .sep { color: var(--faint); }
/* رقم المهمة: يظهر مع عنوانها في كل الشاشات للتمييز والبحث (#12). */
.task-id { flex: none; color: var(--muted); font-size: 12.5px; font-weight: 600; white-space: nowrap; direction: ltr; unicode-bidi: isolate; }
.page-head__badges { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 6px; }

/* ---------- الأزرار ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    min-height: 38px; padding: 7px 14px;
    border: 1px solid var(--line-strong); border-radius: var(--r);
    background: var(--surface); color: var(--ink);
    font-size: 14px; font-weight: 600; line-height: 1.2; white-space: nowrap;
    cursor: pointer; user-select: none;
    transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease), transform .08s var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: var(--faint); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn .icon { width: 16px; height: 16px; }
.btn--primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-press); border-color: var(--brand-press); color: #fff; }
.btn--sun { background: var(--sun); border-color: var(--sun); color: #fff; }
.btn--sun:hover { background: var(--sun-press); border-color: var(--sun-press); color: #fff; }
.btn--danger { background: var(--surface); border-color: var(--bad-line); color: var(--bad); }
.btn--danger:hover { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.btn--ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn--ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn--sm { min-height: 32px; padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn--lg { min-height: 46px; padding: 10px 20px; font-size: 15px; }
.btn--block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn[aria-busy="true"] { cursor: progress; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; transition: background .15s var(--ease), color .15s var(--ease); }
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.btn-row form { display: contents; }
.link-more { display: inline-flex; align-items: center; gap: 4px; font-size: 13.5px; font-weight: 600; }

/* ---------- البطاقات ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 18px 22px 16px; border-bottom: 1px solid var(--line); }
.card__head > div:first-child { min-width: 0; }
.card__head p { color: var(--muted); font-size: 13px; }
/* رأس بطاقة بشعار (مساعد تمّ في إعدادات الذكاء الاصطناعي). */
.assistant-head { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 260px; }
.assistant-head > div { min-width: 0; }
.assistant-head__mark { flex: none; width: 40px; height: 40px; border-radius: var(--r); }
.card__body { padding: 20px; }
.card__body--flush { padding: 0; }
.card__foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.card--pad { padding: 20px; }
.card > .table-wrap:last-child, .card > .list:last-child { border-radius: 0 0 var(--r-lg) var(--r-lg); }
.stack { display: grid; gap: 20px; align-content: start; }
.stack--sm { gap: 10px; }
.stack--xs { gap: 4px; }
.grid { display: grid; gap: 20px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--main { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.grid--auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
@media (max-width: 1100px) { .grid--main { grid-template-columns: minmax(0, 1fr); } .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .grid--2, .grid--3 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 480px) { .grid--4 { grid-template-columns: minmax(0, 1fr); } }

/* ---------- الشارات ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; min-height: 22px; padding: 1px 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-3); color: var(--ink-2); font-size: 12px; font-weight: 600; line-height: 1.5; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge--plain::before { display: none; }
.badge--brand { background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand-strong); }
.badge--info { background: var(--info-soft); border-color: var(--info-line); color: var(--info); }
.badge--ok { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok); }
.badge--warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.badge--sun { background: var(--sun-soft); border-color: var(--sun-line); color: var(--sun-ink); }
.badge--bad { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 6px; background: var(--surface-3); color: var(--ink-2); font-size: 12px; font-weight: 500; white-space: nowrap; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.priority { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.priority .icon { width: 14px; height: 14px; }
.priority--low { color: var(--muted); }
.priority--high { color: var(--warn); }
.priority--urgent { color: var(--bad); }

/* ---------- الصورة الرمزية ---------- */
.avatar { display: inline-grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 50%; background: var(--surface-3); color: var(--ink-2); font-family: var(--font); font-size: 12px; font-weight: 700; line-height: 1; }
.avatar--sm { width: 24px; height: 24px; font-size: 10.5px; }
.avatar--lg { width: 40px; height: 40px; font-size: 15px; }
.avatar--xl { width: 88px; height: 88px; font-size: 30px; }
.avatar--photo { padding: 0; object-fit: cover; }


.person { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.person__text { display: grid; min-width: 0; line-height: 1.35; }
.person__text strong { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person__text span { color: var(--muted); font-size: 12px; }

/* ---------- الرسائل ---------- */
.toasts { position: fixed; z-index: 60; top: 16px; inset-inline-end: 16px; display: grid; gap: 8px; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-inline-start: 4px solid var(--info); border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow-2); font-size: 14px; font-weight: 500; animation: toast-in .28s var(--ease) both; }
.toast > .icon { margin-top: 2px; color: var(--info); }
.toast p { flex: 1; min-width: 0; }
.toast .icon-btn { width: 24px; height: 24px; margin: -1px; }
.toast--success { border-inline-start-color: var(--ok); } .toast--success > .icon { color: var(--ok); }
.toast--warning { border-inline-start-color: var(--sun); } .toast--warning > .icon { color: var(--warn); }
.toast--error { border-inline-start-color: var(--bad); } .toast--error > .icon { color: var(--bad); }
.toast.is-leaving { opacity: 0; transform: translateY(-6px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

.notice { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid var(--info-line); border-radius: var(--r); background: var(--info-soft); color: var(--info-ink); font-size: 14px; }
.notice > .icon { margin-top: 3px; flex: none; }
.notice > div { min-width: 0; flex: 1; }
.notice strong { font-weight: 600; }
.notice--warn { border-color: var(--warn-line); background: var(--warn-soft); color: var(--warn-ink); }
.notice--bad { border-color: var(--bad-line); background: var(--bad-soft); color: var(--bad-ink); }
.notice--ok { border-color: var(--ok-line); background: var(--ok-soft); color: var(--ok-ink); }
.notice--plain { border-color: var(--line); background: var(--surface-2); color: var(--ink-2); }

/* ---------- الحالة الفارغة ---------- */
.empty { display: grid; justify-items: center; gap: 6px; padding: 40px 20px; text-align: center; color: var(--muted); }
.empty__icon { display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 6px; border-radius: 50%; background: var(--surface-3); color: var(--faint); }
.empty strong { color: var(--ink); font-family: var(--font-display); font-weight: 600; font-size: 15px; }
.empty p { max-width: 44ch; font-size: 14px; }
.empty .btn { margin-top: 10px; }
.empty--sm { padding: 24px 16px; }

/* ---------- النماذج ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: grid; gap: 6px; align-content: start; min-width: 0; }
.field--full { grid-column: 1 / -1; }
.field > label, .field__label { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.field .req { color: var(--bad); margin-inline-start: 2px; }
.field .opt { color: var(--faint); font-weight: 400; font-size: 12px; margin-inline-start: 4px; }
.field__help { color: var(--muted); font-size: 12.5px; line-height: 1.55; }
.field__error { display: flex; gap: 5px; color: var(--bad); font-size: 13px; font-weight: 500; }
.field__error .icon { width: 15px; height: 15px; margin-top: 3px; }
@media (max-width: 760px) { .form-grid, .form-grid--3 { grid-template-columns: minmax(0, 1fr); } }

.form-control, .input,
.field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
.field select, .field textarea {
    width: 100%; min-height: 40px; padding: 8px 12px;
    border: 1px solid var(--line-strong); border-radius: var(--r);
    background: var(--surface); color: var(--ink);
    font-size: 14.5px; line-height: 1.5;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.form-control::placeholder, .input::placeholder { color: var(--faint); }
.form-control:hover, .input:hover { border-color: var(--faint); }
.form-control:focus, .input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
.form-control:disabled, .field input:disabled, .field select:disabled, .field textarea:disabled { background-color: var(--surface-3); color: var(--muted); cursor: not-allowed; }
textarea.form-control, .field textarea { min-height: 92px; resize: vertical; line-height: 1.7; }
select.form-control, .field select:not([multiple]) {
    appearance: none; padding-inline-end: 34px; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667380' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: left 11px center;
}
[dir="ltr"] select.form-control { background-position: right 11px center; }
select[multiple].form-control { min-height: 110px; padding: 6px; }
input[type="date"].form-control, input[type="number"].form-control, input[type="url"].form-control, input[type="email"].form-control { direction: ltr; text-align: right; }
.field.has-error .form-control, .form-control[aria-invalid="true"] { border-color: var(--bad); }
.field.has-error .form-control:focus { box-shadow: 0 0 0 3px rgba(179, 49, 42, 0.2); }
input[type="file"].form-control { padding: 6px; min-height: 44px; cursor: pointer; color: var(--muted); font-size: 13.5px; }
input[type="file"]::file-selector-button { margin-inline-end: 12px; padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface-2); color: var(--ink); font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; }
.file-input { position: relative; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 5px 6px; border: 1px dashed var(--line-strong); border-radius: var(--r); background: var(--surface-2); transition: border-color .15s var(--ease), background .15s var(--ease); }
.file-input:hover, .file-input:focus-within { border-color: var(--brand); background: var(--brand-soft); }
.file-input input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.file-input__name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13.5px; }
.file-input.has-file .file-input__name { color: var(--ink); font-weight: 500; }
.file-current { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }

/* مفتاح التبديل (لحقول نعم/لا) */
.switch { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track { position: relative; flex: none; width: 38px; height: 22px; margin-top: 1px; border-radius: 999px; background: var(--line-strong); transition: background .18s var(--ease); }
.switch__track::after { content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s var(--ease); }
.switch input:checked + .switch__track { background: var(--brand); }
.switch input:checked + .switch__track::after { transform: translateX(-16px); }
[dir="ltr"] .switch input:checked + .switch__track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch__text { display: grid; gap: 2px; min-width: 0; }
.switch__text strong { font-size: 14px; font-weight: 600; }
.switch__text span { color: var(--muted); font-size: 12.5px; line-height: 1.55; }

.form-section + .form-section { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); }
.form-section__head { margin-bottom: 16px; }
.form-section__head p { color: var(--muted); font-size: 13.5px; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.form-actions .spacer { flex: 1; }
.errorlist { margin: 0; padding: 0; list-style: none; color: var(--bad); font-size: 13px; font-weight: 500; }
.form-errors { margin-bottom: 16px; }
.inline-form { display: inline-flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }

/* شريط التصفية */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; padding: 14px 16px; }
.filters .field { flex: 1 1 160px; gap: 4px; }
.filters .field--grow { flex: 2 1 240px; }
.filters .field > label { font-size: 12px; color: var(--muted); font-weight: 500; }
.filters__actions { display: flex; gap: 8px; }
.search-input { position: relative; }
.search-input .icon { position: absolute; top: 50%; inset-inline-start: 12px; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.search-input .form-control, .field .search-input .form-control:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]) { padding-inline-start: 38px; }

/* تبويبات الفرز */
.tabs { display: flex; gap: 2px; overflow-x: auto; padding: 0 12px; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 12px 10px; color: var(--muted); font-size: 14px; font-weight: 600; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--brand-strong); }
.tab.is-active::after { content: ""; position: absolute; inset-inline: 8px; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0; background: var(--brand); }
.tab__count { min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--surface-3); color: var(--ink-2); font-size: 11.5px; line-height: 19px; text-align: center; font-variant-numeric: tabular-nums; }
.tab.is-active .tab__count { background: var(--brand-soft); color: var(--brand-strong); }
.segmented { display: inline-flex; padding: 3px; border-radius: var(--r); background: var(--surface-3); }
.segmented a, .segmented button { padding: 5px 12px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; }
.segmented .is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* ---------- الجداول ---------- */
.table-wrap { position: relative; width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); color: var(--muted); font-size: 12.5px; font-weight: 600; text-align: start; white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table .cell-main { display: grid; gap: 1px; min-width: 180px; }
.table .cell-main strong, .table .cell-main a { font-weight: 600; color: var(--ink); }
.table .cell-main a:hover { color: var(--brand); }
.table .cell-main span { color: var(--muted); font-size: 12.5px; }
.table .cell-actions { text-align: end; white-space: nowrap; }
.table .cell-actions .btn + .btn { margin-inline-start: 4px; }
.table td.num, .table th.num { text-align: end; }
.table--compact td { padding-block: 8px; }
.table tfoot td { background: var(--surface-2); font-weight: 600; border-top: 1px solid var(--line); border-bottom: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-line; overflow-wrap: anywhere; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.pagination__links { display: flex; gap: 6px; }

/* ---------- القوائم ---------- */
.list { display: grid; }
.list__item { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); color: inherit; transition: background .12s var(--ease); }
.list__item:last-child { border-bottom: 0; }
a.list__item:hover { background: var(--surface-2); color: inherit; }
.list__main { display: grid; gap: 1px; min-width: 0; flex: 1; }
.list__main strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list__main span { color: var(--muted); font-size: 13px; }
.list__meta { display: flex; align-items: center; gap: 10px; flex: none; color: var(--muted); font-size: 13px; }
.list__chev { color: var(--faint); }

/* بيانات وصفية (تسمية / قيمة) */
.meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 16px 20px; }
.meta--stack { grid-template-columns: minmax(0, 1fr); gap: 14px; }
.meta__item { display: grid; gap: 2px; min-width: 0; }
.meta__item dt, .meta__label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.meta__item dd, .meta__value { margin: 0; font-weight: 600; font-size: 14.5px; overflow-wrap: anywhere; }
dl { margin: 0; }

/* مؤشرات رقمية */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.stat { display: grid; gap: 4px; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-1); color: inherit; }
a.stat { transition: border-color .15s var(--ease), box-shadow .15s var(--ease), transform .15s var(--ease); }
a.stat:hover { border-color: var(--ink); color: inherit; }
.stat__label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 500; }
.stat__value { font-family: var(--font-display); font-size: 32px; font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.stat__value small { font-size: 14px; font-weight: 500; color: var(--muted); }
.stat__hint { color: var(--muted); font-size: 12.5px; }
.stat--warn .stat__value { color: var(--warn); }
.stat--bad .stat__value { color: var(--bad); }
.stat--ok .stat__value { color: var(--ok); }
.stat--sun { border-color: var(--sun); background: var(--sun-soft); }

.progress { height: 6px; overflow: hidden; border-radius: 999px; background: var(--surface-3); }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--brand); transition: width .5s var(--ease); }
.progress--ok > span { background: var(--ok); }
.progress--warn > span { background: var(--sun); }
.progress--bad > span { background: var(--bad); }
.meter { display: grid; gap: 6px; }
.meter__head { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; }
.meter__head strong { font-variant-numeric: tabular-nums; }
.ring { --value: 0; position: relative; display: grid; place-items: center; width: 108px; height: 108px; flex: none; border-radius: 50%; background: conic-gradient(var(--brand) calc(var(--value) * 1%), var(--surface-3) 0); }
.ring::before { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: var(--surface); }
.ring > div { position: relative; display: grid; justify-items: center; line-height: 1.2; }
.ring strong { font-family: var(--font-display); font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ring span { color: var(--muted); font-size: 11.5px; }
.distribution { display: flex; height: 10px; overflow: hidden; border-radius: 999px; background: var(--surface-3); }
.distribution > span { display: block; height: 100%; }
.legend { display: grid; gap: 8px; }
.legend__item { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.legend__dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.legend__item strong { margin-inline-start: auto; font-variant-numeric: tabular-nums; }

/* ---------- شريط الدور: توقيع النظام ----------
   يجيب في كل سجل عن سؤال واحد: «الخطوة التالية على من؟» */
.turn { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border: 1px solid var(--line); border-inline-start: 4px solid var(--line-strong); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-1); }
.turn__icon { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 50%; background: var(--surface-3); color: var(--muted); }
.turn__text { display: grid; gap: 1px; min-width: 0; flex: 1; }
.turn__label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.turn__text strong { font-family: var(--font-display); font-size: 16px; font-weight: 600; }
.turn__text p { color: var(--muted); font-size: 13.5px; }
.turn__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.turn__actions form { display: contents; }
.turn--mine { border-color: var(--sun-line); border-inline-start-color: var(--sun); background: var(--sun-soft); }

.turn--mine .turn__icon { background: var(--sun); color: #fff; }
.turn--mine .turn__label { color: var(--sun-ink); font-weight: 600; }
.turn--done { border-inline-start-color: var(--ok); }
.turn--done .turn__icon { background: var(--ok-soft); color: var(--ok); }
.turn--stopped { border-inline-start-color: var(--faint); }
@media (max-width: 640px) { .turn { flex-wrap: wrap; } .turn__actions { width: 100%; } .turn__actions .btn { flex: 1; } }

/* صف مهمة في القوائم */
.task-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px 16px; padding: 14px 20px; border-bottom: 1px solid var(--line); border-inline-start: 3px solid transparent; color: inherit; transition: background .12s var(--ease); }
.task-row:last-child { border-bottom: 0; }
.task-row:hover { background: var(--surface-2); color: inherit; }
.task-row--mine { border-inline-start-color: var(--sun); }
.task-row__title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.task-row__title strong { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-row__sub { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; color: var(--muted); font-size: 13px; }
.task-row__sub > span { display: inline-flex; align-items: center; gap: 5px; }
.task-row__sub .icon { width: 14px; height: 14px; }
.task-row__side { display: flex; align-items: center; gap: 12px; grid-row: span 2; }
.task-row__next { display: grid; gap: 1px; width: 230px; font-size: 12.5px; color: var(--muted); }
.task-row__next strong { color: var(--ink-2); font-size: 13px; font-weight: 600; }
.task-row--mine .task-row__next strong { color: var(--sun-ink); }
.is-overdue { color: var(--bad) !important; font-weight: 600; }
@media (max-width: 760px) {
    .task-row { grid-template-columns: minmax(0, 1fr); padding-inline: 16px; }
    .task-row__side { grid-row: auto; justify-content: space-between; }
    .task-row__next { width: auto; }
}

/* ---------- مسار المراحل ---------- */
.steps { display: grid; gap: 0; counter-reset: step; }
.step { position: relative; display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 14px; padding-bottom: 20px; }
.step:last-child { padding-bottom: 0; }
.step::before { content: ""; position: absolute; top: 32px; bottom: 0; inset-inline-start: 15px; width: 2px; background: var(--line); }
.step:last-child::before { display: none; }
.step__dot { position: relative; z-index: 1; display: grid; place-items: center; width: 32px; height: 32px; border: 2px solid var(--line-strong); border-radius: 50%; background: var(--surface); color: var(--muted); font-family: var(--font-display); font-size: 13px; font-weight: 600; }
.step__body { display: grid; gap: 4px; min-width: 0; padding-top: 3px; }
.step__head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.step__head h3 { font-size: 15.5px; font-family: var(--font); font-weight: 700; }
.step__meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 13px; }
.step__meta span { display: inline-flex; align-items: center; gap: 5px; }
.step__note { margin-top: 4px; padding: 8px 12px; border-radius: 8px; background: var(--surface-2); color: var(--ink-2); font-size: 13.5px; white-space: pre-line; }
.step--done .step__dot { border-color: var(--ok); background: var(--ok); color: #fff; }
.step--done::before { background: var(--ok-line); }
.step--current .step__dot { border-color: var(--sun); background: var(--sun); color: #fff; }
.step--current .step__head h3 { color: var(--ink); }
.step--waiting .step__head h3 { color: var(--muted); }
.step--returned .step__dot { border-color: var(--bad); color: var(--bad); }

/* ---------- قائمة التحقق داخل المهمة ---------- */
.checklist[aria-busy="true"] .checklist__items { opacity: .6; }
.checklist__items { display: grid; }
.checklist__item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.checklist__item:last-child { border-bottom: 0; }
.checklist__item > form { display: contents; }
.checklist__tick { display: grid; place-items: center; width: 24px; height: 24px; margin-top: 1px; padding: 0; border: 2px solid var(--line-strong); border-radius: 7px; background: var(--surface); color: transparent; cursor: pointer; transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease); }
button.checklist__tick { position: relative; }
button.checklist__tick::after { content: ""; position: absolute; inset: -9px; }
button.checklist__tick:hover { border-color: var(--brand); color: var(--brand-line); }
button.checklist__tick:focus-visible { outline: none; box-shadow: var(--focus); }
span.checklist__tick { cursor: default; opacity: .7; }
.checklist__item.is-done .checklist__tick { border-color: var(--ok); background: var(--ok); color: #fff; }
.checklist__body { display: grid; gap: 3px; min-width: 0; }
.checklist__title { color: var(--ink); font-size: 14.5px; line-height: 1.6; overflow-wrap: anywhere; }
.checklist__item.is-done .checklist__title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.checklist__meta { display: flex; flex-wrap: wrap; gap: 2px 14px; color: var(--muted); font-size: 12.5px; }
.checklist__meta > span { display: inline-flex; align-items: center; gap: 5px; }
.checklist__remove { color: var(--faint); opacity: 0; transition: opacity .15s var(--ease); }
.checklist__item:hover .checklist__remove, .checklist__remove:focus-visible { opacity: 1; }
.checklist__remove:hover { color: var(--bad); }
@media (hover: none) { .checklist__remove { opacity: 1; } }
.checklist__add { display: grid; gap: 6px; padding-top: 4px; }
.checklist__add-main { display: flex; align-items: flex-start; gap: 8px; }
.checklist__input.form-control { flex: 1; min-width: 0; height: 44px; min-height: 44px; resize: none; overflow-y: auto; line-height: 1.6; }
@media (max-width: 480px) { .checklist__add-main .btn span { display: none; } }

/* ---------- التحقق بخطوتين ---------- */
.setup-steps { display: grid; gap: 18px; counter-reset: setup; }
.setup-steps > li { position: relative; display: grid; gap: 6px; padding-inline-start: 40px; counter-increment: setup; }
.setup-steps > li::before { content: counter(setup); position: absolute; inset-inline-start: 0; top: 0; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 13.5px; }
.setup-steps > li > span { color: var(--muted); font-size: 13.5px; }
.qr-box { justify-self: start; padding: 8px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; line-height: 0; }
.qr-box svg { display: block; width: 175px; height: 175px; }
.secret-key { display: block; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-3); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 15px; letter-spacing: .06em; overflow-wrap: anywhere; }
.otp-input { font-size: 20px !important; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.backup-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 14px; border: 1px dashed var(--line-strong); border-radius: var(--r); background: var(--surface-2); }
.backup-codes li { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 15px; text-align: center; }

/* ---------- الإجازات ---------- */
.away-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 10px; }
.away { display: flex; align-items: center; gap: 10px; min-width: 0; }
.away__main { display: grid; min-width: 0; }
.away__main strong { overflow: hidden; font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.away__main > span { color: var(--muted); font-size: 12.5px; }

/* ---------- قواعد الأتمتة ---------- */
.rule-list { display: grid; }
.rule { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: 14px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.rule:last-child { border-bottom: 0; }
.rule__icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); }
.rule--off .rule__icon { background: var(--surface-3); color: var(--faint); }
.rule__main { display: grid; gap: 3px; min-width: 0; }
.rule__name { color: var(--ink); font-size: 15px; font-weight: 700; }
.rule--off .rule__name { color: var(--muted); }
.rule__flow { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; color: var(--ink-2); font-size: 13.5px; }
.rule__flow .icon { color: var(--faint); }
.rule__scope { color: var(--muted); font-size: 12.5px; }
.rule__side { display: flex; align-items: center; gap: 8px; }
@media (max-width: 640px) { .rule { grid-template-columns: auto minmax(0, 1fr); padding-inline: 16px; } .rule__side { grid-column: 2; justify-content: space-between; } }
.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 10px; }
.preset-card { display: grid; gap: 4px; padding: 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: inherit; }
.preset-card:hover { border-color: var(--brand-line); background: var(--brand-soft); color: inherit; }
.preset-card__icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--sun-soft); color: var(--sun-ink); }
.preset-card strong { font-size: 14px; font-weight: 700; }
.preset-card span:last-child { color: var(--muted); font-size: 12.5px; }

/* ---------- اختيار قالب في نموذج المهمة ---------- */
.template-picker { margin-bottom: 16px; }
.template-picker > summary .muted { font-weight: 400; }
.template-picker__list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 8px; }
.template-picker__item { display: grid; gap: 2px; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: inherit; }
.template-picker__item:hover { border-color: var(--brand-line); background: var(--brand-soft); color: inherit; }
.template-picker__item strong { font-size: 14px; font-weight: 600; }
.template-picker__item span { color: var(--muted); font-size: 12.5px; }

/* ---------- المهام الفرعية وترتيب التنفيذ ---------- */
.subtask-list { display: grid; gap: 6px; }
.subtask { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: inherit; transition: border-color .12s var(--ease), background .12s var(--ease); }
.subtask:hover { border-color: var(--brand-line); background: var(--surface-2); color: inherit; }
.subtask__state { display: grid; place-items: center; width: 24px; height: 24px; border: 2px solid var(--line-strong); border-radius: 50%; color: var(--muted); }
.subtask__state--done { border-color: var(--ok); background: var(--ok); color: #fff; }
.subtask__state--off { border-style: dashed; }
.subtask__main { display: grid; gap: 1px; min-width: 0; }
.subtask__main strong { overflow: hidden; font-weight: 600; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.subtask__main > span { color: var(--muted); font-size: 12.5px; }
@media (max-width: 480px) { .subtask { grid-template-columns: auto minmax(0, 1fr); } .subtask .badge { grid-column: 2; justify-self: start; } }
.subtask__state--late { border-color: var(--bad-line); background: var(--bad-soft); color: var(--bad); }
.digest-list { display: grid; gap: 6px; padding: 0 20px 16px; }
@media (max-width: 760px) { .digest-list { padding-inline: 15px; } }
.dep-list { display: grid; gap: 8px; }
.dep { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px; font-size: 13.5px; }
.dep > a { overflow-wrap: anywhere; font-weight: 600; }
.dep__icon { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--sun-soft); color: var(--sun-ink); }
.dep--done .dep__icon { background: var(--ok-soft); color: var(--ok); }
.dep--done > a { color: var(--muted); font-weight: 500; }
.dep__status { color: var(--muted); font-size: 12px; white-space: nowrap; }
.turn--waiting { border-inline-start-color: var(--sun); }
.turn--waiting .turn__icon { background: var(--sun-soft); color: var(--sun-ink); }
.time-meter { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }

/* ---------- الخط الزمني ---------- */
.timeline { display: grid; }
.timeline__item { position: relative; display: grid; grid-template-columns: 12px minmax(0, 1fr); gap: 14px; padding-bottom: 18px; }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__item::before { content: ""; position: absolute; top: 14px; bottom: -4px; inset-inline-start: 5px; width: 2px; background: var(--line); }
.timeline__item:last-child::before { display: none; }
.timeline__dot { position: relative; z-index: 1; width: 12px; height: 12px; margin-top: 6px; border: 2px solid var(--surface); border-radius: 50%; background: var(--line-strong); box-shadow: 0 0 0 1px var(--line-strong); }
.timeline__item--ok .timeline__dot { background: var(--ok); box-shadow: 0 0 0 1px var(--ok); }
.timeline__item--bad .timeline__dot { background: var(--bad); box-shadow: 0 0 0 1px var(--bad); }
.timeline__item--brand .timeline__dot { background: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.timeline__item--warn .timeline__dot { background: var(--sun); box-shadow: 0 0 0 1px var(--sun); }
.timeline__body { display: grid; gap: 2px; min-width: 0; }
.timeline__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; }
.timeline__head strong { font-weight: 600; font-size: 14px; }
.timeline__head time { color: var(--faint); font-size: 12.5px; }
.timeline__body p { color: var(--muted); font-size: 13px; }
.timeline__reason { margin-top: 4px; padding: 8px 12px; border-inline-start: 3px solid var(--bad-line); border-radius: 6px; background: var(--bad-soft); color: var(--bad-ink) !important; }

/* ---------- عناصر متفرقة ---------- */
.prose { color: var(--ink-2); line-height: 1.85; white-space: pre-line; overflow-wrap: anywhere; max-width: 78ch; }
.attachment { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); color: var(--ink); font-size: 13.5px; font-weight: 500; }
.attachment:hover { border-color: var(--brand-line); background: var(--brand-soft); color: var(--brand-strong); }
.attachment span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.divider-label { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.divider-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }
details.disclosure { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
details.disclosure > summary { display: flex; align-items: center; gap: 8px; padding: 10px 14px; cursor: pointer; color: var(--ink-2); font-size: 13.5px; font-weight: 600; list-style: none; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary .icon { transition: transform .18s var(--ease); color: var(--muted); }
details.disclosure[open] > summary .icon { transform: rotate(180deg); }
details.disclosure > div { padding: 4px 14px 14px; }
.kbd { padding: 1px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); font-size: 12px; }

.menu { position: relative; }
.menu__panel { position: absolute; z-index: 20; top: calc(100% + 6px); inset-inline-end: 0; min-width: 200px; padding: 6px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow-2); }
.menu__panel a, .menu__panel button { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--ink); font-size: 14px; font-weight: 500; text-align: start; cursor: pointer; }
.menu__panel a:hover, .menu__panel button:hover { background: var(--surface-3); }
.menu__panel .icon { color: var(--muted); }

dialog.dialog { width: min(480px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: var(--r-xl); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-3); }
dialog.dialog::backdrop { background: rgba(8, 20, 26, 0.5); }
dialog.dialog[open] { animation: dialog-in .22s var(--ease); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.dialog__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 0; }
.dialog__head p { margin-top: 4px; color: var(--muted); font-size: 14px; }
.dialog__body { padding: 18px 22px 4px; display: grid; gap: 16px; }
.dialog__foot { display: flex; justify-content: flex-start; gap: 8px; padding: 18px 22px 22px; }

/* بطاقات الإعدادات */
.tile { display: flex; align-items: flex-start; gap: 14px; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); color: inherit; box-shadow: var(--shadow-1); transition: border-color .15s var(--ease), box-shadow .15s var(--ease), transform .15s var(--ease); }
.tile:hover { border-color: var(--brand); color: inherit; }
.tile__icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: var(--r); background: var(--sun-soft); color: var(--sun-ink); }
.tile__text { display: grid; gap: 2px; min-width: 0; }
.tile__text strong { font-family: var(--font-display); font-weight: 600; font-size: 15px; }
.tile__text span { color: var(--muted); font-size: 13px; line-height: 1.55; }

/* منشئ المراحل داخل نموذج المهمة */
.stage-builder { display: grid; gap: 10px; }
.stage-card { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 14px; align-items: start; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface-2); }
.stage-card__num { display: grid; place-items: center; width: 32px; height: 32px; margin-top: 24px; border-radius: 50%; background: var(--brand); color: #fff; font-family: var(--font-display); font-size: 13px; font-weight: 600; }
.stage-card__fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.stage-card__controls { display: flex; gap: 2px; margin-top: 24px; }
@media (max-width: 640px) {
    .stage-card { grid-template-columns: 32px minmax(0, 1fr); }
    .stage-card__fields { grid-template-columns: minmax(0, 1fr); }
    .stage-card__controls { grid-column: 1 / -1; margin-top: 0; justify-content: flex-end; }
}

/* مساعد الصياغة */
.assist { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 14px; border: 1px dashed var(--brand-line); border-radius: var(--r); background: var(--brand-soft); color: var(--brand-strong); font-size: 13.5px; }
.assist p { flex: 1 1 260px; min-width: 0; }
.assist__status { flex-basis: 100%; font-size: 13px; font-weight: 500; }
.assist__status:empty { display: none; }
.assist__status.error { color: var(--bad); }
.time-converter { display: grid; gap: 6px; margin-top: 8px; }
.time-converter label { font-size: 12.5px; color: var(--muted); font-weight: 500; }

/* شبكة الأيام (التقارير اليومية) */
.day-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.day { display: grid; gap: 6px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: inherit; transition: border-color .15s var(--ease), box-shadow .15s var(--ease); }
a.day:hover { border-color: var(--ink); color: inherit; }
.day__date { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.day__date strong { font-family: var(--font-display); font-weight: 600; font-size: 14px; }
.day__date span { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.day__meta { color: var(--muted); font-size: 12.5px; }
.day--today { border-color: var(--sun); background: var(--sun-soft); }
.day--off { background: var(--surface-2); color: var(--muted); }
.day--missing { border-color: var(--bad-line); background: var(--bad-soft); }
.day--done { border-color: var(--ok-line); }

/* ---------- التقييم والأداء (الفترات، التقييمات، الاعتراضات، قوالب المؤشرات، تقرير الأهداف) ---------- */
/* ملخص الدرجة: حلقة + كيف تكوّنت الدرجة */
.score-summary { display: flex; align-items: center; gap: 20px 28px; flex-wrap: wrap; }
.score-summary__text { display: grid; gap: 12px; flex: 1 1 260px; min-width: 0; }
.score-summary__text > p { color: var(--muted); font-size: 13.5px; max-width: 60ch; }
.ring--lg { width: 132px; height: 132px; }
.ring--lg::before { inset: 12px; }
.ring--lg strong { font-size: 28px; }
.sum-list { display: grid; gap: 6px; max-width: 400px; font-size: 14px; }
.sum-list > div { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.sum-list dt { color: var(--muted); }
.sum-list dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; direction: ltr; }
.sum-list__total { margin-top: 2px; padding-top: 8px; border-top: 1px solid var(--line); }
.sum-list__total dt { color: var(--ink); font-weight: 600; }
.sum-list__total dd { font-family: var(--font-display); font-size: 16px; }
/* شريط تحقيق صغير داخل خلية جدول */
.kpi-progress { display: grid; gap: 5px; min-width: 110px; max-width: 180px; }
.kpi-progress strong { font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.value-pair { white-space: nowrap; font-variant-numeric: tabular-nums; }
.value-pair strong { font-weight: 600; font-size: 14.5px; }
.value-pair span { color: var(--muted); font-size: 12.5px; }
/* صف تفصيل يتبع صفًا في الجدول (مثل تفصيل حساب المهام اليومية) */
.table tr.has-detail td { border-bottom: 0; }
.table tr.table__detail:hover { background: transparent; }
.table tr.table__detail td { padding-top: 0; padding-bottom: 14px; }
.breakdown { display: grid; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
.breakdown__title { display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.breakdown .meta { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px 16px; }
.breakdown .meta__item dd { font-size: 14px; }
.breakdown details > summary { cursor: pointer; color: var(--bad); font-size: 13px; font-weight: 600; width: fit-content; }
.breakdown details .tags { margin-top: 8px; }
/* خانة التحديد في الجداول */
.table .cell-check { width: 44px; padding-inline-end: 0; }
.check { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); cursor: pointer; vertical-align: middle; }
/* رقم قابل للنقر داخل جدول */
.num-link { display: inline-block; min-width: 30px; padding: 2px 8px; border-radius: 6px; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }
.num-link:hover { background: var(--brand-soft); }
.num-link--bad { color: var(--bad); }
.num-link--bad:hover { background: var(--bad-soft); color: var(--bad); }
.tag--code { direction: ltr; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 11.5px; }
/* سجل نصي (اعتراض، استثناء): عنوان وحالة ثم نص ثم بيانات */
.entry { display: grid; gap: 8px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.entry:last-child { border-bottom: 0; }
.entry__head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.entry__head h3 { font-size: 14.5px; }
.entry__head .spacer { flex: 1; }
.entry__text { color: var(--ink-2); font-size: 14px; line-height: 1.8; white-space: pre-line; overflow-wrap: anywhere; max-width: 78ch; }
.entry__label { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.entry__meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 12.5px; }
.entry__meta span { display: inline-flex; align-items: center; gap: 5px; }
.points { font-family: var(--font-display); font-weight: 600; font-variant-numeric: tabular-nums; direction: ltr; white-space: nowrap; }
.points--plus { color: var(--ok); }
.points--minus { color: var(--bad); }
/* شريط إجراءات التحديد الجماعي */
.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); color: var(--muted); font-size: 13px; }
.bulk-bar .spacer { flex: 1; }
.card__head .meter { width: min(220px, 100%); }
/* عمود بطاقات يحوي جداول عريضة: يمنع الجدول من توسيع العمود خارج الشاشة */
.stack--fit { grid-template-columns: minmax(0, 1fr); }
/* تصفية بحقول كثيرة: شبكة متساوية بدل صف مرن */
.filters--grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); align-items: end; }
.filters--grid .filters__actions { align-self: end; }
.menu__panel form { display: contents; }
.menu__sep { height: 1px; margin: 6px 4px; background: var(--line); }
.menu__panel .menu__danger { color: var(--bad); }
/* في الشاشات الصغيرة تنتقل أزرار رأس الصفحة إلى بداية السطر، فتُفتح القائمة باتجاه الداخل */
@media (max-width: 760px) { .page-head__actions .menu__panel { inset-inline: 0 auto; } }

/* ---------- صفحة الدخول ---------- */
.auth { min-height: 100vh; display: grid; align-content: center; justify-items: center; gap: 28px; padding: 40px 20px; background: var(--bg); }
.auth__logo { display: block; width: min(260px, 70vw); height: auto; }
.auth__card { width: min(400px, 100%); display: grid; gap: 20px; padding: 32px; border: 1px solid var(--line); border-radius: var(--r-xl); background: var(--surface); }
.auth__card h1 { font-size: 26px; }
.auth__card .lead { color: var(--muted); margin-top: 4px; }
.auth__foot { color: var(--faint); font-size: 12.5px; letter-spacing: .04em; }
.password-field { position: relative; }
.auth__card form { gap: 18px; }
.auth__card .field { gap: 8px; }
.auth__card .form-control { min-height: 46px; padding-inline: 14px; font-size: 15px; }
/* الحقول لاتينية المحتوى (dir=ltr) لكنها تُحاذى مع التسميات العربية */
.auth__card .form-control[dir="ltr"] { text-align: right; }
.auth__card .btn { margin-top: 6px; }
/* الزر في الطرف الأيسر فعليًا؛ الحشو فيزيائي لأن اتجاه الحقل ltr */
.password-field .form-control { padding-left: 48px; }
.password-field .icon-btn { position: absolute; top: 50%; left: 5px; transform: translateY(-50%); }
@media (max-width: 480px) { .auth__card { padding: 24px 20px; } }

/* ---------- صفحات الأخطاء ---------- */
.error-page { min-height: 100vh; display: grid; align-content: center; justify-items: center; gap: 10px; padding: 32px 20px; text-align: center; }
.error-page__code { font-family: var(--font-display); font-size: 64px; font-weight: 700; line-height: 1; color: var(--sun); }
.error-page p { max-width: 46ch; color: var(--muted); }
.error-page .btn { margin-top: 14px; }

/* ---------- Tom Select (القوائم القابلة للبحث) ---------- */
.ts-wrapper { min-height: 40px; }
.ts-wrapper.form-control { padding: 0; border: 0; background: none; box-shadow: none !important; }
.ts-control { min-height: 40px; padding: 6px 12px !important; border: 1px solid var(--line-strong) !important; border-radius: var(--r) !important; background: var(--surface) !important; font-size: 14.5px; line-height: 1.5; box-shadow: none !important; gap: 4px; }
.ts-wrapper.single .ts-control { padding-inline-end: 34px !important; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667380' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") !important; background-repeat: no-repeat !important; background-position: left 11px center !important; }
.ts-wrapper.single .ts-control::after { display: none !important; }
.ts-wrapper.focus .ts-control { border-color: var(--ink) !important; box-shadow: var(--focus) !important; }
.ts-wrapper.disabled .ts-control { background-color: var(--surface-3) !important; opacity: 1 !important; cursor: not-allowed; }
.ts-wrapper.disabled .ts-control .remove { display: none; }
.ts-control input { font: inherit !important; color: var(--ink) !important; }
.ts-control input::placeholder { color: var(--faint); }
.ts-wrapper.multi .ts-control > .item { margin: 0; padding: 2px 8px !important; border: 1px solid var(--brand-line) !important; border-radius: 6px !important; background: var(--brand-soft) !important; color: var(--brand-strong) !important; font-size: 13px; font-weight: 600; text-shadow: none !important; box-shadow: none !important; background-image: none !important; }
.ts-wrapper.plugin-remove_button .item .remove { border: 0 !important; margin-inline-start: 4px; padding: 0 4px !important; color: inherit; font-size: 15px; }
.ts-wrapper.plugin-remove_button .item .remove:hover { background: transparent; color: var(--bad); }
.ts-dropdown { margin-top: 6px; border: 1px solid var(--line) !important; border-radius: var(--r) !important; background: var(--surface); box-shadow: var(--shadow-2) !important; font-size: 14px; overflow: hidden; z-index: 50; }
.ts-dropdown .option, .ts-dropdown .no-results { padding: 8px 12px; }
.ts-dropdown .active { background: var(--brand-soft); color: var(--brand-strong); }
.ts-dropdown .no-results { color: var(--muted); }

/* ---------- قوائم الإدارة والإعدادات (الموظفون، سجل التدقيق) ---------- */
/* صف فاصل يجمع صفوف الجدول تحت عنوان واحد (مثل اليوم في سجل التدقيق) */
.table .table__group th { padding: 7px 16px; border-bottom: 1px solid var(--line); background: var(--surface-3); color: var(--ink-2); font-family: var(--font-display); font-size: 12.5px; font-weight: 600; }
.table .table__group:hover { background: none; }
.table--log td { vertical-align: top; }
.table--log .log-time { width: 1%; color: var(--muted); font-weight: 500; white-space: nowrap; }
.table--log .log-text { min-width: 260px; }
.table--log .log-text p { color: var(--ink-2); overflow-wrap: anywhere; }
/* تفاصيل هادئة داخل صف: رابط صغير يفتح البيانات الإضافية دون إطار */
details.disclosure--quiet { margin-top: 4px; border: 0; background: none; }
details.disclosure--quiet > summary { display: inline-flex; gap: 4px; padding: 0; color: var(--muted); font-size: 12.5px; font-weight: 500; }
details.disclosure--quiet > summary:hover { color: var(--brand); }
details.disclosure--quiet > div { margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); max-width: 560px; }
/* أزواج مفتاح/قيمة مضغوطة */
.kv { display: grid; gap: 4px; font-size: 13px; }
.kv > div { display: grid; grid-template-columns: minmax(90px, 160px) minmax(0, 1fr); gap: 12px; }
.kv dt { color: var(--muted); text-align: start; overflow-wrap: anywhere; }
[dir="rtl"] .kv dt[dir="ltr"] { text-align: right; }
.kv dd { margin: 0; color: var(--ink-2); overflow-wrap: anywhere; }
.form-note { margin-top: 18px; }
/* اسم الشخص كرابط داخل الجدول */
.person-link { display: inline-flex; color: inherit; }
.person-link:hover { color: inherit; }
.person-link:hover .person__text strong { color: var(--brand); }
/* حالة ربط الموظف بحساب دخول */
.account { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 13.5px; font-weight: 500; }
.account .icon { color: var(--ok); }
.account--none { color: var(--muted); font-weight: 400; }
.account--none .icon { color: var(--faint); }

/* ---------- التقارير اليومية ومركز المتابعة ---------- */
/* مهمة داخل تقرير يوم: نص المهمة ثم شريط المراجعة */
.report-tasks { display: grid; }
.report-task { display: grid; gap: 10px; padding: 18px 20px; border-bottom: 1px solid var(--line); scroll-margin-top: 80px; }
.report-task:last-child { border-bottom: 0; }
.report-task:target { background: var(--sun-soft); }
.report-task__head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.report-task__head h3 { flex: 1 1 200px; min-width: 0; font-size: 15.5px; overflow-wrap: anywhere; }
.report-task .step__note { margin-top: 0; }
.report-task .task-row__sub a { display: inline-flex; align-items: center; gap: 5px; font-weight: 500; }
/* شريط المراجعة: نماذج صغيرة متجاورة يحفظ كلٌّ منها قيمة واحدة */
.review-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 18px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
.review-bar form { display: flex; align-items: flex-end; gap: 6px; flex: 1 1 230px; min-width: 0; }
.review-bar .field { flex: 1; gap: 4px; }
.review-bar .field > label { color: var(--muted); font-size: 12px; font-weight: 500; }
.review-bar__more { min-height: 38px; margin-inline-start: auto; }
/* شبكة الأيام بعرض أوسع لصفحة أيام الفترة */
.day-grid--roomy { grid-template-columns: repeat(auto-fill, minmax(172px, 1fr)); }
@media (max-width: 520px) { .day-grid--roomy { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } .day-grid--roomy .day { padding: 10px; } }
.day-grid--roomy .day { align-content: start; }
.day__status { display: flex; }
.day--missing .day__meta { color: var(--bad-ink); }
/* جدول صفوفه أشخاص: الاسم لا يُقتطع في الشاشات الضيقة */
.table--people .person { min-width: 150px; }
/* عدّاد صغير داخل خلية جدول */
.meter--inline { min-width: 120px; max-width: 180px; gap: 4px; font-size: 13.5px; }

/* ---------- أدوات صغيرة ---------- */
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.row--top { align-items: flex-start; }
.grow { flex: 1; min-width: 0; }
.mt-0 { margin-top: 0 !important; }
.text-ok { color: var(--ok); } .text-bad { color: var(--bad); } .text-warn { color: var(--warn); } .text-brand { color: var(--brand); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.hide-sm { }
@media (max-width: 760px) { .hide-sm { display: none !important; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
    .sidebar, .sidebar * { transition: none !important; }
}
@media print {
    .sidebar, .topbar, .toasts, .page-head__actions, .scrim, .no-print { display: none !important; }
    .main { margin: 0; } .content { padding: 0; max-width: none; }
    body { background: #fff; } .card { box-shadow: none; }
}

/* ---------- أدوار الخطوط ----------
   السيريف للعناوين والأرقام البارزة فقط؛ العناصر الصغيرة تبقى بخط الواجهة لتظل واضحة. */
.step__dot, .stage-card__num, .day__date strong, .tile__text strong, .empty strong, .tab { font-family: var(--font); }
.step__dot, .stage-card__num, .tile__text strong, .empty strong, .day__date strong { font-weight: 700; }
.turn__text strong { font-family: var(--font-display); font-size: 21px; font-weight: 700; line-height: 1.5; }
.turn { padding: 18px 22px; gap: 16px; }
.turn__icon { width: 46px; height: 46px; }
.task-row__title strong { font-weight: 700; font-size: 15px; }

/* ---------- لوحة الترحيب في الصفحة الرئيسية: سطح أسود مصمت ---------- */
.hero-band { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 24px 32px; padding: 30px 32px; border-radius: var(--r-xl); background: var(--panel); color: var(--panel-ink); }
.hero-band__text { display: grid; gap: 6px; min-width: 0; flex: 1 1 340px; }
.hero-band__date { color: var(--sun); font-size: 13.5px; font-weight: 500; }
.hero-band h1 { color: #fff; font-size: clamp(28px, 3.2vw, 38px); line-height: 1.35; }
.hero-band__text p { color: var(--panel-ink); font-size: 15.5px; max-width: 56ch; }
.hero-band__text p strong { color: #fff; }
.hero-band__side { display: grid; gap: 14px; justify-items: end; }
.hero-band__facts { display: flex; border: 1px solid var(--panel-line); border-radius: var(--r-lg); overflow: hidden; }
.hero-fact { display: grid; min-width: 112px; padding: 10px 18px; color: var(--panel-ink); border-inline-start: 1px solid var(--panel-line); transition: background .15s var(--ease); }
.hero-fact:first-child { border-inline-start: 0; }
a.hero-fact:hover { background: #2b2728; color: #fff; }
.hero-fact strong { font-family: var(--font-display); font-size: 28px; font-weight: 700; line-height: 1.25; color: #fff; font-variant-numeric: tabular-nums; }
.hero-fact span { font-size: 12.5px; }
.hero-fact--sun strong { color: var(--sun); }
.hero-fact--bad strong { color: #f0a097; }
@media (max-width: 760px) { .hero-band { padding: 22px 20px; } .hero-band__side { justify-items: stretch; width: 100%; } .hero-fact { flex: 1; min-width: 0; padding-inline: 12px; } }
/* ---------- لوحة المهام: الحالات، الأعمدة، البطاقات ---------- */
.content--wide { max-width: none; }
.status-pill--gray, .status-dot--gray, .board-col--gray { --c: #7a7570; --c-soft: #efedea; }
.status-pill--blue, .status-dot--blue, .board-col--blue { --c: #2f5aa8; --c-soft: #e9effa; }
.status-pill--teal, .status-dot--teal, .board-col--teal { --c: #0f8a9d; --c-soft: #e2f3f6; }
.status-pill--green, .status-dot--green, .board-col--green { --c: #2a8a3e; --c-soft: #e6f3ea; }
.status-pill--gold, .status-dot--gold, .board-col--gold { --c: #a8842f; --c-soft: #f7f0de; }
.status-pill--orange, .status-dot--orange, .board-col--orange { --c: #cc5a10; --c-soft: #fcebdc; }
.status-pill--red, .status-dot--red, .board-col--red { --c: #b3312a; --c-soft: #fbe9e7; }
.status-pill--purple, .status-dot--purple, .board-col--purple { --c: #7c4bb8; --c-soft: #f0e9f9; }
.status-dot { display: inline-block; width: 9px; height: 9px; flex: none; border-radius: 50%; background: var(--c, var(--faint)); }
.status-pill { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 2px 10px 2px 9px; border: 0; border-radius: 6px; background: var(--c-soft, var(--surface-3)); color: var(--ink); font-size: 12.5px; font-weight: 600; line-height: 1.5; white-space: nowrap; }
.status-pill::before { content: ""; width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--c, var(--faint)); }
button.status-pill { cursor: pointer; }
button.status-pill:hover { box-shadow: inset 0 0 0 1px var(--c); }
button.status-pill .icon { width: 13px; height: 13px; color: var(--muted); }

.view-switch { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.view-switch a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 6px; color: var(--muted); font-size: 13.5px; font-weight: 600; white-space: nowrap; }
.view-switch a:hover { color: var(--ink); }
.view-switch a.is-active { background: var(--brand); color: #fff; }
.view-switch .icon { width: 15px; height: 15px; }
.view-switch a.is-active .icon { color: #fff; }

.task-toolbar { display: grid; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.task-toolbar .tabs { padding-inline: 8px; }
.task-toolbar .filters { padding: 12px 14px; }
.task-toolbar .filters .field { flex: 1 1 140px; }
.task-toolbar .filters .field--grow { flex: 2 1 220px; }

.board-wrap { margin-inline: -40px; padding-inline: 40px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; }
.board { display: flex; align-items: flex-start; gap: 12px; width: max-content; min-width: 100%; padding-bottom: 12px; }
.board-col { display: flex; flex-direction: column; flex: 0 0 288px; width: 288px; max-height: max(360px, calc(100vh - 292px)); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface-3); }
.board-col__head { display: flex; align-items: center; gap: 8px; min-height: 46px; padding: 8px 6px 8px 12px; }
.board-col__head h2 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font); font-size: 14px; font-weight: 700; }
.board-col__count { padding: 0 7px; border-radius: 999px; background: var(--surface); color: var(--ink-2); font-size: 12px; font-weight: 600; line-height: 20px; }
.board-col.is-over .board-col__count { background: var(--bad-soft); color: var(--bad); }
.board-col__head .spacer { flex: 1; }
.board-col__head .icon-btn { width: 28px; height: 28px; border-radius: 7px; }
.board-col__head .icon-btn:hover { background: var(--surface); }
.board-col__grip { display: inline-grid; place-items: center; width: 16px; margin-inline-start: -6px; color: var(--faint); cursor: grab; }
.board-col__grip .icon { width: 14px; height: 14px; }
.board-col__body { display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 72px; padding: 2px 8px 8px; overflow-y: auto; scrollbar-width: thin; }
.board-col__empty { display: grid; place-items: center; min-height: 64px; border: 1px dashed var(--line-strong); border-radius: var(--r); color: var(--faint); font-size: 12.5px; }
.board-col__body > .board-card ~ .board-col__empty, .board-col__body.has-cards > .board-col__empty { display: none; }
.board-col__foot { display: grid; gap: 2px; padding: 0 8px 8px; }
.board-col__foot a { display: flex; align-items: center; gap: 6px; padding: 7px 8px; border-radius: 7px; color: var(--muted); font-size: 13px; font-weight: 600; }
.board-col__foot a:hover { background: var(--surface); color: var(--ink); }
.board-col__foot .icon { width: 15px; height: 15px; }
.board-col.is-target { border-color: var(--brand); background: var(--brand-soft); }
.board-col.is-blocked { opacity: .45; }
.board-col.is-collapsed { flex-basis: 46px; width: 46px; cursor: pointer; }
.board-col.is-collapsed .board-col__head { flex-direction: column; align-items: center; gap: 10px; padding: 12px 0; }
.board-col.is-collapsed .board-col__head h2 { writing-mode: vertical-rl; overflow: visible; }
.board-col.is-collapsed .board-col__grip, .board-col.is-collapsed .spacer, .board-col.is-collapsed .menu, .board-col.is-collapsed .board-col__foot, .board-col.is-collapsed .board-col__limit { display: none; }
.board-col.is-collapsed .board-col__body { padding: 0; min-height: 120px; }
.board-col.is-collapsed .board-col__body > * { display: none; }
.board-col__limit { color: var(--muted); font-size: 12px; }
.board-add { display: flex; align-items: center; justify-content: center; gap: 6px; flex: 0 0 200px; min-height: 46px; border: 1px dashed var(--line-strong); border-radius: var(--r-lg); color: var(--muted); font-size: 13.5px; font-weight: 600; }
.board-add:hover { border-color: var(--brand); color: var(--brand-strong); background: var(--surface); }

.board-card { position: relative; display: grid; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); cursor: grab; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.board-card:hover { border-color: var(--line-strong); }
.board-card:focus-within { border-color: var(--brand); }
.board-card--mine { box-shadow: inset 3px 0 0 var(--sun); }
[dir="rtl"] .board-card--mine { box-shadow: inset -3px 0 0 var(--sun); }
.board-card__top { display: flex; align-items: flex-start; gap: 6px; }
.board-card__title { flex: 1; min-width: 0; color: var(--ink); font-size: 14px; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
.board-card__title:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.board-card__more { width: 26px; height: 26px; margin: -3px -6px -3px 0; border-radius: 6px; opacity: 0; }
[dir="rtl"] .board-card__more { margin: -3px 0 -3px -6px; }
.board-card:hover .board-card__more, .board-card__more:focus-visible, .board-card__more[aria-expanded="true"] { opacity: 1; }
.board-card__tags { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.board-card__tags .tag { max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-size: 11.5px; }
.board-card__tags .tag b { color: var(--muted); font-weight: 500; }
.board-card__tags .priority { font-size: 12px; }
.board-card__stage { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
.board-card__stage span { display: flex; align-items: center; gap: 5px; }
.board-card__stage .icon { width: 13px; height: 13px; }
.board-card__stage .progress { height: 4px; }
.board-card__turn { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 6px; background: var(--sun-soft); color: var(--sun-ink); font-size: 12px; font-weight: 600; }
.board-card__turn .icon { width: 13px; height: 13px; flex: none; }
.board-card__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12.5px; }
.board-card__foot .due { display: inline-flex; align-items: center; gap: 5px; }
.board-card__foot .icon { width: 13px; height: 13px; }
.board-card__people { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.board-card__people span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-card.is-ghost { border-style: dashed; border-color: var(--line-strong); background: transparent; }
.board-card.is-ghost > * { visibility: hidden; }
.board-card.is-drag { cursor: grabbing; border-color: var(--brand); box-shadow: var(--shadow-2); }
.board-card.is-saving { opacity: .6; }
.board-card[hidden] { display: none; }
.board-pop { position: fixed; z-index: 70; top: 0; left: 0; min-width: 220px; max-width: min(300px, calc(100vw - 16px)); max-height: min(420px, 70vh); overflow-y: auto; padding: 6px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow-2); }
.board-pop a, .board-pop button { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--ink); font-size: 14px; font-weight: 500; text-align: start; cursor: pointer; }
.board-pop a:hover, .board-pop button:hover:not(:disabled), .board-pop a:focus-visible, .board-pop button:focus-visible { background: var(--surface-3); outline: none; }
.board-pop .icon { width: 16px; height: 16px; color: var(--muted); }
.board-col.is-ghost-col { opacity: .4; }
body.is-dragging { cursor: grabbing; user-select: none; -webkit-user-select: none; }
.board-pop__label { padding: 6px 10px 4px; color: var(--muted); font-size: 12px; font-weight: 600; }
.board-pop button[aria-current="true"] { background: var(--surface-3); }
.board-pop button:disabled { opacity: .45; cursor: not-allowed; }

.table--tasks td { padding-block: 10px; }
.table--tasks .cell-main { min-width: 240px; }
.table--tasks .row-turn { display: grid; gap: 0; font-size: 12.5px; color: var(--muted); }
.table--tasks .row-turn strong { color: var(--ink-2); font-weight: 600; }
.table--tasks tr.is-mine td:first-child { box-shadow: inset -3px 0 0 var(--sun); }
.table--tasks .person { min-width: 130px; }

.drag-handle { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; color: var(--faint); cursor: grab; }
.drag-handle:hover { background: var(--surface-3); color: var(--ink); }
.table tr.is-ghost { background: var(--sun-soft); }
.color-swatches { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- تقرير المهام ---------- */
.chart-card .card__body { display: grid; gap: 14px; }
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(96px, 30%) minmax(0, 1fr) auto; align-items: center; gap: 12px; font-size: 13.5px; }
.bar-row__label { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--ink-2); font-weight: 500; }
.bar-row__label span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row__track { display: flex; gap: 2px; height: 10px; }
.bar-row__track i { display: block; height: 100%; min-width: 3px; border-radius: 4px; background: var(--brand); }
.bar-row__track i.seg-open { background: var(--brand); }
.bar-row__track i.seg-overdue { background: var(--bad); }
.bar-row__track i.seg-done { background: var(--ok); }
.bar-row__track i[style*="width: 0%"] { display: none; }
.bar-row__value { min-width: 34px; color: var(--ink); font-weight: 600; text-align: end; font-variant-numeric: tabular-nums; }
.bar-row__value small { color: var(--muted); font-weight: 500; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: 12.5px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--ink-2); }
.legend i.seg-open { background: var(--brand); } .legend i.seg-overdue { background: var(--bad); } .legend i.seg-done { background: var(--ok); }
.legend i.seg-created { background: var(--brand); } .legend i.seg-closed { background: var(--sun); }
.columns-chart { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); align-items: end; gap: 10px; height: 190px; padding-top: 18px; border-bottom: 1px solid var(--line-strong); }
.columns-chart__group { position: relative; display: flex; align-items: flex-end; justify-content: center; gap: 2px; height: 100%; }
.columns-chart__group i { position: relative; display: block; width: min(18px, 38%); min-height: 2px; border-radius: 4px 4px 0 0; background: var(--brand); }
.columns-chart__group i.seg-closed { background: var(--sun); }
.columns-chart__group i b { position: absolute; bottom: calc(100% + 2px); inset-inline: -8px; color: var(--ink-2); font-size: 11px; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }
.columns-chart__axis { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 10px; color: var(--muted); font-size: 11.5px; text-align: center; font-variant-numeric: tabular-nums; }

@media (max-width: 1023px) {
    .board-wrap { margin-inline: -16px; padding-inline: 16px; scroll-snap-type: x proximity; scroll-padding-inline: 16px; }
    .board-col { flex-basis: min(300px, 84vw); width: min(300px, 84vw); max-height: none; scroll-snap-align: start; }
    .board-col__body { overflow-y: visible; }
    .board-card__more { opacity: 1; }
    .bar-row { grid-template-columns: minmax(84px, 38%) minmax(0, 1fr) auto; gap: 8px; }
}.bar-row { grid-template-columns: minmax(84px, 150px) minmax(0, 1fr) auto; }
.columns-chart__group i, .bar-row__track i, .legend i { font-style: normal; }
.columns-chart__group i[style*="height: 0%"] { min-height: 0; }
.stats .stat { align-content: start; }
.board-col { flex-basis: 276px; width: 276px; }/* اختيار لون الحالة: أزرار دائرية بدل قائمة أسماء */
#id_color { display: flex; flex-wrap: wrap; gap: 8px; }
#id_color label { position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px 6px 10px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--ink-2); font-size: 13px; font-weight: 500; cursor: pointer; }
#id_color label::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
#id_color input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
#id_color label:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); color: var(--ink); font-weight: 600; }
#id_color label:has(input:focus-visible) { box-shadow: var(--focus); }
#id_color label:has(input[value="gray"]) { --c: #7a7570; } #id_color label:has(input[value="blue"]) { --c: #2f5aa8; }
#id_color label:has(input[value="teal"]) { --c: #0f8a9d; } #id_color label:has(input[value="green"]) { --c: #2a8a3e; }
#id_color label:has(input[value="gold"]) { --c: #a8842f; } #id_color label:has(input[value="orange"]) { --c: #cc5a10; }
#id_color label:has(input[value="red"]) { --c: #b3312a; } #id_color label:has(input[value="purple"]) { --c: #7c4bb8; }
/* ---------- النوافذ المنبثقة للنماذج ---------- */
dialog.modal { width: min(880px, calc(100vw - 24px)); max-width: none; max-height: calc(100dvh - 32px); padding: 0; border: 0; border-radius: var(--r-xl); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-3); overflow: hidden; }
dialog.modal[open] { display: flex; flex-direction: column; animation: dialog-in .22s var(--ease); }
dialog.modal::backdrop { background: rgba(20, 26, 46, 0.5); animation: fade-in .2s var(--ease); }
@keyframes fade-in { from { opacity: 0; } }
.modal__content { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.modal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex: none; padding: 18px 22px 16px; border-bottom: 1px solid var(--line); }
.modal__head h2 { font-size: 20px; font-weight: 800; }
.modal__head p { margin-top: 2px; color: var(--muted); font-size: 13.5px; max-width: 64ch; }
.modal__form { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.modal__body { flex: 1; min-height: 0; overflow-y: auto; padding: 22px; overscroll-behavior: contain; }
.modal__foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; flex: none; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--surface-2); }
.modal__loading { display: grid; place-items: center; min-height: 220px; color: var(--muted); font-size: 14px; }
.modal__error { margin-bottom: 16px; }
@media (max-width: 640px) {
    dialog.modal { width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; }
    .modal__head, .modal__body, .modal__foot { padding-inline: 16px; }
}

/* ---------- الإشارات إلى الأعضاء وتفاصيل قراءة الرسائل ---------- */
.chat-suggest .chat-suggest__item { min-height: 44px; }
.chat .chat-suggest { max-height: min(300px, calc(var(--vvh, 100dvh) * .5)); }
.chat-suggest__person { display: grid; flex: 1; min-width: 0; gap: 2px; }
.chat-suggest__caption { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
.chat-user-mention { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; margin-inline: 1px; padding-inline: 7px; border: 1px solid var(--brand-line); border-radius: 6px; background: var(--surface); color: var(--brand-strong); font-size: 13px; font-weight: 600; line-height: 1.7; vertical-align: middle; unicode-bidi: isolate; }
.chat-user-mention > .icon { flex: none; }
.chat-user-mention__name { min-width: 0; overflow-wrap: anywhere; white-space: normal; }
.chat-user-mention.is-me { border-color: var(--sun-line); background: var(--sun-soft); color: var(--sun-ink); }
.chat-user-mention__me { flex: none; padding-inline-start: 5px; border-inline-start: 1px solid var(--sun-line); font-size: 11px; font-weight: 700; }
dialog.chat-message-details { width: min(520px, calc(100vw - 24px)); }
.chat-message-details .modal__body { display: grid; align-content: start; gap: 20px; }
.chat-read-summary { display: grid; gap: 6px; }
.chat-read-summary p { color: var(--muted); font-size: 13px; }
.chat-read-summary strong { color: var(--ink); font-size: 18px; }
.chat-read-group__title { display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 13px; font-weight: 700; }
.chat-readers { list-style: none; padding: 0; margin: 6px 0 0; }
.chat-reader { display: flex; align-items: flex-start; gap: 10px; padding-block: 12px; border-bottom: 1px solid var(--line); }
.chat-reader:last-child { border-bottom: 0; }
.chat-reader__text { display: grid; gap: 3px; min-width: 0; overflow-wrap: anywhere; }
.chat-reader__text strong { color: var(--ink); font-size: 14px; font-weight: 600; }
.chat-reader__text span, .chat-reader__text small, .chat-reader__text time { color: var(--muted); font-size: 12.5px; }
@media (max-width: 640px) {
    dialog.chat-message-details { width: 100vw; }
    .chat-message-details .modal__head .icon-btn { width: 44px; height: 44px; }
    .chat-message-details .modal__foot { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
    .chat-message-details .modal__foot .btn { min-height: 44px; }
}

/* ---------- السلاسة: حركات قصيرة عند التفاعل ---------- */
/* المتصفحات الداعمة لانتقال الصفحات تستخدمه بدل هذه الحركة (أسفل الملف). */
@supports not (view-transition-name: none) { .content > * { animation: rise-in .22s var(--ease) backwards; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(6px); } }
.card, .stat, .tile, .board-card, .board-col, .task-toolbar { transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background-color .15s var(--ease); }
.board-card:hover { box-shadow: 0 4px 12px -6px rgba(20, 26, 46, 0.22); }
.board-col { border-top: 3px solid var(--c, var(--line-strong)); }
.board-col.is-collapsed .board-col__head { border-top: 0; }
.ts-wrapper.focus .ts-control { border-color: var(--brand) !important; }
.ts-dropdown .option { cursor: pointer; }
.ts-dropdown .option.selected { font-weight: 600; }
.filters .ts-control { font-size: 14px; }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}.filters__toggle { display: none; }
@media (max-width: 760px) {
    .filters--collapsible .filters__toggle { display: inline-flex; }
    .filters--collapsible .field--grow { flex: 1 1 0; }
    .filters--collapsible:not(.is-open) .field:not(.field--grow), .filters--collapsible:not(.is-open) .filters__actions { display: none; }
}div#id_color, div#id_color.form-control { min-height: 0; padding: 0; border: 0; background: none; box-shadow: none; }
.board-side { display: grid; gap: 12px; align-content: start; flex: 0 0 232px; width: 232px; }
.board-side .board-add { flex: none; }
.board-hidden { display: grid; gap: 10px; padding: 12px; border: 1px dashed var(--line-strong); border-radius: var(--r-lg); background: var(--surface); }
.board-hidden h2 { display: flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 700; color: var(--ink-2); }
.board-hidden h2 .icon { width: 15px; height: 15px; color: var(--muted); }
.board-hidden ul { display: grid; gap: 2px; }
.board-hidden li { display: flex; align-items: center; gap: 8px; min-height: 34px; font-size: 13.5px; }
.board-hidden__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.board-hidden .board-col__count { background: var(--surface-3); }
.board-hidden li form { display: contents; }
.board-hidden li .btn { min-height: 28px; padding: 2px 8px; color: var(--brand-strong); }
.board-hidden p { color: var(--muted); font-size: 12px; line-height: 1.6; }
@media (max-width: 1023px) { .board-side { flex-basis: min(260px, 78vw); width: min(260px, 78vw); scroll-snap-align: start; } }.topbar__spacer { flex: 1; }

/* ==========================================================================
   العملاء والأنشطة المجدولة والتقويم
   ========================================================================== */
.section-head { display: grid; gap: 2px; }
.section-head p { color: var(--muted); font-size: 13.5px; }
.meta__item--wide { grid-column: 1 / -1; }
.link-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; font-weight: 500; }
.link-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.inline-check { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; font-size: 13.5px; font-weight: 500; color: var(--ink-2); cursor: pointer; }
.cal-toggle { flex: 1 1 220px; justify-content: end; }

/* نموذج المهمة: الموعد والتكرار */
.schedule-note { display: flex; align-items: center; gap: 6px; }
.schedule-note .icon { color: var(--brand); }
.repeat-grid { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
.repeat-grid:not(:has(.field:not([hidden]))) { display: none; }
@media (max-width: 760px) { .repeat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; } }

/* بطاقة اللوحة: العميل والموعد */
.board-card__client { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; color: var(--ink-2); font-size: 12.5px; font-weight: 500; }
.board-card__client > span { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.board-card__client > span > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-card__client .icon { width: 13px; height: 13px; color: var(--muted); }

/* مواعيد مختصرة (الرئيسية، صفحة العميل) */
.appt__time { display: grid; flex: none; min-width: 52px; padding: 4px 8px; border-radius: var(--r-sm); background: var(--brand-soft); color: var(--brand-strong); font-weight: 700; font-size: 14px; line-height: 1.3; text-align: center; }
.appt__time small { color: var(--muted); font-weight: 500; font-size: 11.5px; }
.appt .badge, .appt .status-pill { flex: none; }
@media (max-width: 520px) { .appt .badge, .appt .status-pill { display: none; } }

/* سجل أنشطة العميل */
.history { display: grid; margin: 0; padding: 0; list-style: none; }
.history__item { display: grid; gap: 8px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.history__item:last-child { border-bottom: 0; }
.history__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.history__head a { color: var(--ink); }
.history__head a:hover { color: var(--brand); }
.history__meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 12.5px; }
.history__meta span { display: inline-flex; align-items: center; gap: 5px; }
.activity-report { grid-template-columns: minmax(0, 1fr); gap: 10px; }
.activity-report dd { font-weight: 500; font-size: 14px; }

/* التقويم */
.cal-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.cal-bar__nav { display: flex; align-items: center; gap: 6px; min-width: 0; }
.cal-bar__title { margin-inline-start: 6px; font-size: 17px; font-weight: 700; white-space: nowrap; }
.cal { display: grid; gap: 12px; }
.cal-note { text-align: center; }
.cal-grid { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.cal-grid__head, .cal-grid__body { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-grid__head { border-bottom: 1px solid var(--line); background: var(--surface-2); }
.cal-grid__head > div { padding: 8px 10px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.cal-day { display: flex; flex-direction: column; gap: 4px; min-width: 0; min-height: 118px; padding: 6px; border-bottom: 1px solid var(--line); border-inline-start: 1px solid var(--line); }
.cal-day:nth-child(7n + 1) { border-inline-start: 0; }
.cal-grid__body > .cal-day:nth-last-child(-n + 7) { border-bottom: 0; }
.cal-day.is-outside { background: var(--surface-2); }
.cal-day.is-outside .cal-day__num { color: var(--faint); }
.cal-day__head { display: flex; align-items: center; gap: 6px; padding: 0 2px; }
.cal-day__num { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 4px; border-radius: 999px; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.cal-day.is-today .cal-day__num { background: var(--brand); color: #fff; }
.cal-day__name { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.cal-day__list { display: grid; gap: 3px; align-content: start; flex: 1; min-height: 24px; }
.cal-day__more { padding: 0 4px; color: var(--muted); font-size: 12px; font-weight: 600; }
.cal-day__more:hover { color: var(--brand); }
.cal-grid--week .cal-day { min-height: 340px; }
.cal-item { display: flex; align-items: flex-start; gap: 6px; min-width: 0; padding: 3px 6px; border-radius: 6px; border-inline-start: 3px solid var(--c, var(--line-strong)); background: var(--c-soft, var(--surface-3)); color: var(--ink); font-size: 12.5px; line-height: 1.45; }
.cal-item:hover { color: var(--ink); box-shadow: inset 0 0 0 1px var(--c, var(--line-strong)); }
.cal-item:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.cal-item--due { background: var(--surface); border-inline-start-style: dashed; }
.cal-item[data-movable] { cursor: grab; }
.cal-item.is-overdue .cal-item__time { color: var(--bad); }
.cal-item__time { flex: none; color: var(--ink-2); font-weight: 700; }
.cal-item__time .icon { color: var(--muted); }
.cal-item__text { display: grid; gap: 2px; min-width: 0; }
.cal-item__title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.cal-item__sub { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.cal-grid--week .cal-item { flex-direction: column; gap: 2px; padding: 6px 8px; }
.cal-grid--week .cal-item__title { white-space: normal; overflow-wrap: anywhere; }
.cal-grid--week .cal-item .status-pill { justify-self: start; min-height: 20px; padding: 0 8px; font-size: 11.5px; background: var(--surface); }
.cal-item.is-ghost { opacity: .45; }
.cal-item.is-drag { box-shadow: var(--shadow-2); }
.cal-item.is-saving { opacity: .6; }
.cal-agenda { display: none; gap: 10px; }
.cal--day .cal-agenda { display: grid; }
.cal--day .cal-agenda__main strong, .cal--day .cal-agenda__main span { white-space: normal; overflow-wrap: anywhere; }
@media (max-width: 760px), (hover: none) { .cal-drag-hint { display: none; } }
.cal-agenda__day { display: grid; gap: 8px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.cal-agenda__day.is-today { border-color: var(--brand-line); }
.cal-agenda__day h3 { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14.5px; font-weight: 700; }
.cal-agenda__list { display: grid; gap: 6px; }
.cal-agenda__item { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 8px 10px; border-radius: var(--r); border-inline-start: 3px solid var(--c, var(--line-strong)); background: var(--surface-2); color: var(--ink); }
.cal-agenda__item:hover { color: var(--ink); background: var(--c-soft, var(--surface-3)); }
.cal-agenda__time { display: grid; flex: none; min-width: 46px; font-weight: 700; font-size: 14px; line-height: 1.3; text-align: center; }
.cal-agenda__time small { color: var(--muted); font-weight: 500; font-size: 11.5px; }
.cal-agenda__main { display: grid; gap: 1px; flex: 1; min-width: 0; }
.cal-agenda__main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 14px; }
.cal-agenda__main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12.5px; }
.cal-agenda__item .status-pill { flex: none; }
@media (max-width: 1023px) { .cal-grid--week .cal-day { min-height: 240px; } .cal-grid--week .cal-item .status-pill { display: none; } }
@media (max-width: 760px) {
    .cal-grid { display: none; }
    .cal-agenda { display: grid; }
    .cal-bar__title { font-size: 15.5px; }
    .cal-agenda__item .status-pill { max-width: 38%; overflow: hidden; text-overflow: ellipsis; }
}

/* ---------- لوحة اليوم ---------- */
.home-head { align-items: center; }
.sidebar .sidebar__close { display: none; }
.nav-group:not([open]) > .nav-item, .home-disclosure:not([open]) > :not(summary), .home-upcoming:not([open]) > :not(summary) { display: none; }
.home-search-button kbd { padding: 1px 5px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); font-size: 12px; }
dialog.home-search { width: min(480px, calc(100% - 24px)); margin: auto; }
.home-search .dialog__body { gap: 10px; padding-block-end: 16px; }
.home-search__results { display: grid; max-height: min(48dvh, 360px); overflow-y: auto; overscroll-behavior: contain; }
.home-search__results h3 { padding: 6px 10px; color: var(--muted); font-size: 13px; }
.home-search__results a { display: flex; gap: 8px; align-items: center; min-height: 44px; padding: 5px 10px; color: var(--ink); overflow-wrap: anywhere; }
.home-search__results a:is(:hover, :focus-visible) { background: var(--brand-soft); color: var(--brand-strong); outline-offset: -2px; }
.home-search__results [data-task-search] { color: var(--link); }
dialog.home-search { width: min(560px, calc(100% - 24px)); }
.home-search .search-input { width: 100%; }
.home-search__results { max-height: min(60dvh, 480px); }
.home-search__remote { display: grid; gap: 4px; padding-block-end: 6px; border-block-end: 1px solid var(--line); margin-block-end: 6px; }
.home-search__results a.home-search__item { align-items: flex-start; padding-block: 8px; }
.home-search__item > .icon { flex: none; margin-top: 3px; color: var(--muted); }
.home-search__item > span { display: grid; gap: 1px; min-width: 0; }
.home-search__item strong { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.home-search__item small { overflow: hidden; color: var(--muted); font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
.home-search__results a.home-search__more { min-height: 36px; color: var(--link); font-size: 13px; }
.home-search[aria-busy="true"] .search-input .icon { color: var(--brand); }
.home-search__hint { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; color: var(--faint); font-size: 12px; }
.home-search__hint kbd, .sidebar__search kbd { padding: 1px 5px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); font-family: inherit; font-size: 11.5px; }
@media (pointer: coarse) { .home-search__hint { display: none; } }
.sidebar__search { display: flex; align-items: center; gap: 8px; margin: 0 12px 8px; min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); color: var(--muted); font: inherit; font-size: 13.5px; cursor: pointer; }
.sidebar__search:hover { border-color: var(--line-strong); color: var(--ink); }
.sidebar__search:focus-visible { outline: none; box-shadow: var(--focus); }
.sidebar__search span { flex: 1; text-align: start; }
.home-upcoming > summary { display: flex; align-items: center; justify-content: space-between; list-style: none; padding: 10px 20px; min-height: 44px; color: var(--link); font-weight: 600; cursor: pointer; }
.home-upcoming > summary::-webkit-details-marker { display: none; }
.home-upcoming[open] > summary .icon { transform: rotate(180deg); }
.home-head .eyebrow { color: var(--muted); }
.home-page h1 { font-size: clamp(26px, 3vw, 34px); }
.home-workspace { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; gap: 18px; }
.home-workspace > *, .home-history > * { min-width: 0; }
.home-page .card__head { padding: 15px 20px; gap: 6px 12px; }
.home-page .card__head p { margin-block-start: 3px; }
.home-page .link-more { min-height: 36px; }
.home-count { display: inline-grid; place-items: center; min-width: 24px; padding-inline: 5px; border-radius: var(--r-sm); background: var(--surface-3); color: var(--ink-2); font-size: 14px; font-weight: 700; }
.home-total { color: var(--brand-strong); font-size: 32px; line-height: 1; font-weight: 700; }
.home-group + .home-group { border-top: 1px solid var(--line); }
.home-group__title { display: flex; align-items: center; gap: 8px; padding: 12px 20px 2px; color: var(--muted); font-size: 12.5px; font-weight: 700; }
.home-group__title .num { color: var(--faint); font-weight: 600; }
.home-group--bad .home-group__title { color: var(--bad); }
.home-next { padding: 20px; display: grid; gap: 9px; justify-items: start; background: var(--surface-2); border-inline-start: 3px solid var(--brand); }
.home-next:last-child { border-end-end-radius: var(--r-lg); }
.home-next__meta, .home-deadline { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.home-next__meta { gap: 6px 16px; color: var(--muted); font-size: 13px; }
.home-deadline { font-weight: 600; }
.home-next h3 { font-size: clamp(20px, 2.1vw, 26px); overflow-wrap: anywhere; text-wrap: pretty; }
.home-next p { color: var(--ink-2); }
.home-next .btn { margin-block-start: 5px; }
.home-agenda { gap: 16px; }
.home-list .list__main strong, .home-list .list__main span { white-space: normal; overflow-wrap: anywhere; }
.home-list .list__item { min-height: 55px; padding: 12px 20px; }
.home-list .list__main { gap: 4px; }
.home-list .list__chev { width: 16px; flex: none; }
.home-due, .home-score { color: var(--muted); font-size: 13px; text-align: end; }
.home-score { display: grid; }
.home-score strong { color: var(--ink); }
.home-page .text-bad { color: var(--bad); }
.home-quiet { display: flex; align-items: center; gap: 9px; padding: 20px; color: var(--muted); }
.home-quiet .icon { color: var(--ok); flex: none; }
.home-totals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-block-end: 1px solid var(--line); }
.home-totals a { display: grid; grid-template-columns: 1fr auto; gap: 4px; align-items: center; padding: 14px 20px; color: var(--ink-2); }
.home-totals a + a { border-inline-start: 1px solid var(--line); }
.home-totals a > span { display: flex; align-items: center; gap: 6px; grid-column: 1 / -1; font-size: 14px; font-weight: 600; }
.home-totals strong { font-size: 32px; line-height: 1.25; }
.home-totals a > .icon { color: var(--muted); }
.home-totals a.has-overdue { color: var(--bad); }
.home-totals a.has-pending { color: var(--sun-ink); }
.home-totals a:is(:hover, :focus-visible), .home-task-links a:is(:hover, :focus-visible) { background: var(--surface-2); }
.home-review-action { border-block-end: 1px solid var(--line); padding-block: 12px; }
.home-action { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; }
.home-action small { color: var(--muted); }
@media (hover: hover) {
    .home-action:not(:hover):not(:focus-within) small { visibility: hidden; }
}
.home-foot-link { margin: 0 20px 12px; }
.home-task-links { display: flex; flex-wrap: wrap; align-items: center; gap: 0 16px; padding: 8px 18px; border-block: 1px solid var(--line); }
.home-task-links > strong { margin-inline-end: auto; }
.home-task-links small { margin-inline-start: 6px; color: var(--muted); font-size: 13px; font-weight: 400; }
.home-task-links a { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; }
.home-disclosure { scroll-margin-block-start: calc(var(--top-h) + 12px); }
.home-disclosure > summary { list-style: none; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 14px; min-height: 58px; padding: 12px 18px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); cursor: pointer; }
.home-disclosure > summary::-webkit-details-marker { display: none; }
.home-disclosure > summary > span:first-child { display: flex; align-items: center; gap: 9px; font-size: 16px; }
.home-disclosure > summary > span:first-child .icon { color: var(--muted); }
.home-disclosure__hint { color: var(--muted); font-size: 13px; }
.home-disclosure > summary > .icon { margin-inline-start: auto; }
.home-disclosure[open] > summary > .icon { transform: rotate(180deg); }
.home-disclosure > .list { border: 1px solid var(--line); background: var(--surface); }
.home-history { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; margin-block-start: 14px; }
.home-rate { display: grid; gap: 4px; }
.home-rate > div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; }
.home-rate progress { width: 100%; height: 8px; accent-color: var(--brand); }
.home-period-form { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 10px; padding: 16px 20px; border-block-end: 1px solid var(--line); }
.home-period-form .field { min-width: 0; flex: 1 1 130px; }
.home-period-form .field--grow { flex-basis: 100%; }
@media (max-width: 1023px) {
    .sidebar .sidebar__close { display: inline-flex; position: absolute; inset-block-start: 12px; inset-inline-end: 10px; }
    .home-head .home-search-button, .topbar .home-search-button kbd { display: none; }
    .topbar .home-search-button { min-height: 44px; padding-inline: 8px; background: transparent; border: 0; }
}
@media (max-width: 760px) {
    .home-workspace, .home-history { grid-template-columns: minmax(0, 1fr); gap: 14px; }
    .home-page .card__head, .home-list .list__item, .home-next, .home-quiet, .home-page .card__body { padding-inline: 15px; }
    .home-page .card__head { padding-block: 10px; }
    .home-page .link-more { min-height: 44px; }
    .home-page :is(a, button, summary, input, select) { scroll-margin-block: calc(var(--top-h) + 8px) calc(var(--tabbar-h) + 8px); }
    .home-due { max-width: 76px; }
    .home-task-links { padding-inline: 10px; gap: 0 12px; }
    .home-disclosure__hint { flex: 1 1 auto; }
    .home-disclosure > summary { column-gap: 8px; padding-inline: 12px; }
    .home-totals a { padding: 10px 15px; }
    .home-page .home-head .page-head__actions { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
    .home-page .home-head .page-head__actions > .btn:not(.home-search-button) { flex: 0 0 auto; min-height: 44px; border-radius: var(--r); }
}
/* ---------- القائمة المفردة: حجم ثابت والبحث داخل القائمة المنسدلة ---------- */
.ts-wrapper.single .ts-control { flex-wrap: nowrap; cursor: pointer; }
.ts-wrapper.single .ts-control > .item { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ts-wrapper.single .ts-control > input { min-width: 0 !important; cursor: pointer; }
.ts-wrapper.single.has-items .ts-control > input { flex: 0 0 0 !important; width: 0 !important; opacity: 0; }
.ts-dropdown .dropdown-input-wrap { padding: 8px; border-bottom: 1px solid var(--line); background: var(--surface); }
.ts-dropdown .dropdown-input { display: block; width: 100%; min-height: 36px; padding: 6px 10px !important; border: 1px solid var(--line-strong) !important; border-radius: var(--r-sm) !important; background: var(--surface-2) !important; color: var(--ink); font: inherit; font-size: 14px; box-shadow: none !important; outline: none; }
.ts-dropdown .dropdown-input:focus { border-color: var(--brand) !important; box-shadow: var(--focus) !important; }
.ts-dropdown .dropdown-input::placeholder { color: var(--faint); }
.ts-wrapper.ts-no-search .dropdown-input-wrap { position: absolute; width: 1px; height: 1px; padding: 0; border: 0; overflow: hidden; opacity: 0; pointer-events: none; }
.ts-dropdown .ts-dropdown-content { max-height: 260px; padding: 4px; scrollbar-width: thin; }
.ts-dropdown .option { border-radius: var(--r-sm); }
/* ==========================================================================
   الهاتف واللمس والتطبيق المثبّت (PWA)
   كل تعديلات الشاشات الصغيرة واللمس هنا. لا شيء في هذا القسم يغيّر الواجهة فوق 1023px
   (عدا لون خلفية html المطابق لـ body، ودعوة التثبيت في صفحة الإعدادات عند إمكان التثبيت).
   ترتيب الطبقات: المحتوى ← الشريط العلوي 30 ← الشريط السفلي 32 ← دعوة التثبيت 33 ← الغطاء 35
   ← القائمة الجانبية 40 ← المحادثة بملء الشاشة 45 ← التنبيهات 60 ← لوحة الإشعارات والقوائم 70 ← النوافذ (الطبقة العليا).
   ========================================================================== */
:root {
    --tabbar-h: 0px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --topbar-h: calc(var(--top-h) + var(--safe-top));
}
/* الخلفية نفسها خلف الصفحة كلها: لا وميض أبيض عند السحب أو قبل رسم الصفحة. */
html { background: var(--bg); }

/* ---------- الشريط العلوي (يظهر تحت 1024px) ---------- */
.topbar { height: var(--topbar-h); padding-top: var(--safe-top); padding-left: max(12px, var(--safe-left)); padding-right: max(12px, var(--safe-right)); gap: 6px; }
.topbar__brand { display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px; }
.topbar .brand-mark { width: 32px; height: 32px; }
.topbar__title { display: grid; min-width: 0; }
.topbar__title > span, .topbar__title > strong { overflow: hidden; color: var(--ink); font-size: 16.5px; font-weight: 700; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.topbar__title > span ~ span, .topbar__title > span ~ strong { display: none; }
.topbar__back .icon { width: 24px; height: 24px; }
.has-topbar-back .topbar__brand { display: none; }

/* ---------- الشريط السفلي ---------- */
.tabbar { display: none; }

/* ---------- دعوة التثبيت ---------- */
.install-banner { position: fixed; z-index: 33; inset-inline: 12px; bottom: calc(var(--tabbar-h) + 12px); display: flex; align-items: flex-start; gap: 12px; padding: 14px 14px 12px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-3); animation: sheet-rise .28s var(--ease) both; }
.install-banner__icon { width: 44px; height: 44px; flex: none; border: 1px solid var(--line); border-radius: 11px; }
.install-banner__text { display: grid; flex: 1; gap: 4px; min-width: 0; }
.install-banner__text strong { font-size: 15px; font-weight: 700; }
.install-banner__text p { color: var(--muted); font-size: 13.5px; }
.install-banner__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.install-banner__close { margin: -8px -8px 0 0; }
[dir="rtl"] .install-banner__close { margin: -8px 0 0 -8px; }
@media (min-width: 761px) { .install-banner { inset-inline: auto 24px; bottom: 24px; width: 380px; } }
.install-steps { display: grid; gap: 10px; }
.install-steps li { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: 14px; }
.install-steps__key { display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 9px; background: var(--brand-soft); color: var(--brand); }
.install-steps--compact { gap: 6px; margin-top: 2px; }
.install-steps--compact li { font-size: 13.5px; }
.install-steps--compact .install-steps__key { width: 28px; height: 28px; border-radius: 8px; }
.install-steps--compact .install-steps__key .icon { width: 16px; height: 16px; }
@keyframes sheet-rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes sheet-in { from { transform: translateY(100%); } }

/* ---------- صفحة عدم الاتصال وصفحات الأخطاء ---------- */
.offline-page { gap: 12px; padding: calc(32px + var(--safe-top)) 24px calc(32px + var(--safe-bottom)); }
.offline-page__mark { width: 72px; height: 72px; margin-bottom: 4px; }
.offline-page__icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--surface-3); color: var(--muted); }
.offline-page h1 { font-size: 24px; }
.error-page__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 14px; }
.error-page .error-page__actions .btn { margin-top: 0; }

/* ---------- اللمس: لا تأخير للنقر، ولا عناصر تظهر بالتمرير فوقها فقط ---------- */
a, button, input, select, textarea, label, summary, [role="button"] { touch-action: manipulation; }
@media (hover: none) {
    .board-card__more { opacity: 1; }
}

/* ---------- الأجهزة اللوحية والهواتف (تحت 1024px): أهداف لمس 44px ---------- */
@media (max-width: 1023px) {
    html { -webkit-tap-highlight-color: transparent; }
    /* القائمة الجانبية المنزلقة: نص ثانوي بتباين كافٍ على الأبيض */
    .sidebar { --side-muted: #69738b; padding-top: var(--safe-top); padding-bottom: var(--safe-bottom); }
    .sidebar__nav { overscroll-behavior: contain; }
    .nav-item { min-height: 46px; }
    .sidebar .sidebar__foot .user-card .icon-btn { width: 44px; height: 44px; }
    .theme-switch button { min-height: 40px; font-size: 13.5px; }

    .icon-btn { width: 44px; height: 44px; }
    .btn, .btn--sm { min-height: 44px; }
    .btn--sm { padding-inline: 12px; font-size: 13.5px; }
    .tab { min-height: 46px; }
    .view-switch a { min-height: 44px; }
    .segmented a, .segmented button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; }
    details.disclosure > summary { min-height: 44px; }
    /* ضغطة مطوّلة على البطاقة تبدأ السحب، لا قائمة الرابط في iOS */
    .board-card, .board-card a { -webkit-touch-callout: none; }
    .link-more { min-height: 44px; }
    .back-link { min-height: 36px; }
    .drag-handle { width: 44px; height: 44px; }
    .check { width: 20px; height: 20px; }
    .menu__panel a, .menu__panel button, .board-pop a, .board-pop button { min-height: 44px; }
    .ts-dropdown .option { display: flex; align-items: center; min-height: 44px; }
    .ts-wrapper.multi .ts-control > .item { min-height: 32px; }
    .ts-wrapper.plugin-remove_button .item .remove { display: inline-grid; place-items: center; min-width: 32px; align-self: stretch; }
    /* عناصر صغيرة بصريًا: منطقة لمس أوسع بلا تغيير في الشكل */
    button.status-pill, .num-link, .ts-wrapper.plugin-remove_button .item .remove, .board-col__head .icon-btn, .board-card__more { position: relative; }
    button.status-pill::after, .num-link::after, .ts-wrapper.plugin-remove_button .item .remove::after, .board-col__head .icon-btn::after, .board-card__more::after { content: ""; position: absolute; inset: -10px -4px; }
    .board-col__head .icon-btn { width: 36px; height: 36px; }
    .board-card__more { width: 34px; height: 34px; margin: -6px -8px -6px 0; }
    [dir="rtl"] .board-card__more { margin: -6px 0 -6px -8px; }
    .toast .icon-btn { width: 40px; height: 40px; margin: -9px -8px -9px -10px; }

    /* ضغطة مرئية بدل وميض المتصفح الرمادي */
    .btn:active { background-color: var(--surface-3); }
    .btn--primary:active { background-color: var(--brand-press); }
    .icon-btn:active { background: var(--surface-3); color: var(--ink); }
    .nav-item:active, a.list__item:active, .task-row:active, .table tbody tr:active, .tab:active, .notif-row:active,
    .ann-item:active, .bell__item:active, .cal-agenda__item:active, .menu__panel a:active, .menu__panel button:active,
    .board-pop a:active, .board-pop button:active { background-color: var(--surface-3); }
    .board-card:active, a.tile:active, a.kpi:active, a.stat:active, a.day:active { border-color: var(--brand-line); background-color: var(--surface-2); }

    /* الحقول والقوائم المنسدلة المرتفعة قليلًا لتناسب الإصبع */
    .form-control, .input, .field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]), .field select, .ts-control, .ts-wrapper { min-height: 44px; }
    .menu__panel { max-width: calc(100vw - 24px); }
}

/* ---------- الهاتف (حتى 760px) ---------- */
@media (max-width: 760px) {
    :root { --top-h: 56px; }
    .has-tabbar { --tabbar-h: calc(58px + var(--safe-bottom)); }

    /* الشريط العلوي نحيف: رجوع أو الشعار، ثم اسم القسم. القائمة والجرس انتقلا إلى الشريط السفلي. */
    .has-tabbar .topbar__menu, .topbar .bell__btn { display: none; }
    /* لوحة الإشعارات السفلية تعيش داخل الشريط العلوي (سياق طبقات 30): نرفعه فوق الشريط السفلي ما دامت مفتوحة. */
    .bell-open .topbar { z-index: 50; }
    .has-topbar-back .page-head .back-link { display: none; }

    .tabbar { position: fixed; z-index: 32; inset-inline: 0; bottom: 0; display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; height: var(--tabbar-h); padding: 0 max(4px, var(--safe-right)) var(--safe-bottom) max(4px, var(--safe-left)); border-top: 1px solid var(--line); background: var(--surface); }
    .tabbar__item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 0; height: 58px; padding: 6px 2px 5px; border: 0; background: none; color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 600; line-height: 1.2; cursor: pointer; -webkit-tap-highlight-color: transparent; }
    .tabbar__item:hover { color: var(--ink); }
    .tabbar__icon { position: relative; display: grid; place-items: center; width: 56px; height: 30px; border-radius: 999px; transition: background-color .15s var(--ease); }
    .tabbar__icon .icon { width: 22px; height: 22px; }
    .tabbar__label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .tabbar__item.is-active, .tabbar__item[aria-expanded="true"] { color: var(--brand-strong); }
    .tabbar__item.is-active .tabbar__icon, .tabbar__item[aria-expanded="true"] .tabbar__icon { background: var(--brand-soft); }
    /* الصفحة الحالية من أقسام «المزيد»: يُبرز زر المزيد. */
    .tabbar:not(:has(.is-active)) .tabbar__more { color: var(--brand-strong); }
    .tabbar__item:active .tabbar__icon { background: var(--surface-3); }
    .tabbar__item:focus-visible { outline-offset: -4px; }
    .tabbar__count { position: absolute; top: -3px; inset-inline-end: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--sun); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px var(--surface); }
    /* يختفي مع لوحة المفاتيح، وداخل المحادثة المفتوحة بملء الشاشة. */
    .kb-open .tabbar, .kb-open .install-banner, body:has(.chat.is-thread-open) .tabbar { display: none; }
    .has-tabbar .content:not(.chat-content) { padding-bottom: calc(var(--tabbar-h) + 28px); }
    .has-tabbar .content:has(.btn--fab) { padding-bottom: calc(var(--tabbar-h) + 96px); }

    /* الإجراء الرئيسي في صفحات المهام يطفو فوق الشريط السفلي */
    .btn--fab { position: fixed; z-index: 31; bottom: calc(var(--tabbar-h) + 14px); inset-inline-end: max(16px, var(--safe-left)); min-height: 52px; padding: 10px 20px; border-radius: 999px; box-shadow: var(--shadow-2); font-size: 15px; }
    .kb-open .btn--fab { display: none; }

    /* التنبيهات أسفل الشاشة فوق الشريط السفلي، قريبة من الإبهام */
    .toasts { top: auto; bottom: calc(var(--tabbar-h) + 12px); inset-inline: 12px; width: auto; }
    body:not(.has-tabbar) .toasts { bottom: calc(12px + var(--safe-bottom)); }
    .has-install-banner .toasts { bottom: calc(var(--tabbar-h) + 150px); }
    .toast { animation-name: sheet-rise; }
    .toast.is-leaving { transform: translateY(8px); }

    /* الكثافة والخطوط */
    .content { padding-top: 18px; padding-inline: max(16px, var(--safe-left)) max(16px, var(--safe-right)); }
    .content > * + * { margin-top: 18px; }
    h1 { font-size: 24px; }
    .page-head { gap: 12px; }
    .page-head__actions { width: 100%; }
    .page-head__actions > .view-switch { flex: 1 1 100%; overflow-x: auto; scrollbar-width: none; }
    .page-head__actions > .view-switch::-webkit-scrollbar { display: none; }
    .view-switch a { flex: 1 0 auto; justify-content: center; }
    .card__head { padding: 14px 16px 12px; }
    .card__body { padding: 16px; }
    .card__foot { padding: 12px 16px; }
    .card--pad { padding: 16px; }
    .list__item { padding-inline: 16px; }
    .pagination { padding-inline: 12px; }
    .pagination__links { flex: 1; justify-content: flex-end; }
    .small { font-size: 13px; }
    .muted.small, .field__help { font-size: 12.5px; }

    /* الحقول: 16px تمنع iOS من تكبير الصفحة عند التركيز */
    .form-control, .input,
    .field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
    .field select, .field textarea, .ts-control, .filters .ts-control, .ts-dropdown .dropdown-input,
    .auth__card .form-control, .search-input .form-control { font-size: 16px; }
    .ts-dropdown { font-size: 15px; }
    /* حقول التاريخ والوقت الأصلية لها عرض أدنى داخلي في متصفحات الهاتف: تبقى ضمن عمودها */
    input[type="date"], input[type="time"], input[type="datetime-local"], input[type="month"] { min-width: 0; max-width: 100%; }
    .filters .field { min-width: 0; }
    .form-actions .btn--primary, .auth__card .btn--primary { flex: 1 1 auto; }
    .filters { padding: 12px; }
    .filters__actions { flex: 1 1 100%; }
    .filters__actions .btn { flex: 1; }
    .filters--collapsible:not(.is-open) .filters__actions { display: none; }

    /* التقويم: عنوان المدة في سطر مستقل فلا يدفع الصفحة للخارج */
    .cal-bar { padding: 10px 12px; }
    .cal-bar__nav { flex-wrap: wrap; flex: 1 1 100%; }
    .cal-bar__title { order: -1; flex: 1 1 100%; margin: 0 0 2px; white-space: normal; }
    .cal-bar .segmented { margin-inline-start: auto; }

    /* عنوان السطر في الجداول المكدّسة هدف لمس كامل الارتفاع */
    .table--stack td:first-child .cell-main > a { display: block; margin-block: -9px; padding-block: 9px; }

    /* القوائم المنبثقة لا تخرج من الشاشة */
    .menu__panel { min-width: min(220px, calc(100vw - 32px)); }
    .ts-dropdown .ts-dropdown-content { max-height: min(260px, 40vh); }

    /* النوافذ الصغيرة تصبح لوحة سفلية */
    dialog.dialog { width: 100%; max-width: 100%; margin: auto 0 0; max-height: calc(var(--app-vvh, 100dvh) - 24px); overflow-y: auto; border-radius: var(--r-xl) var(--r-xl) 0 0; padding-bottom: var(--safe-bottom); animation: sheet-in .26s var(--ease); }
    .dialog__head { padding: 18px 16px 0; }
    .dialog__body { padding: 16px 16px 4px; }
    .dialog__foot { flex-wrap: wrap; padding: 16px; }
    .dialog__foot .btn, .modal__foot .btn { flex: 1 1 auto; }
}

dialog.modal:focus { outline: none; }

/* النوافذ المنبثقة للنماذج بملء الشاشة على الهاتف: تتبع الجزء المرئي فوق لوحة المفاتيح */
@media (max-width: 640px) {
    dialog.modal { position: fixed; top: var(--app-vvt, 0px); bottom: auto; margin: 0; height: var(--app-vvh, 100dvh); max-height: none; animation: sheet-in .26s var(--ease); }
    .modal__head { padding-top: calc(14px + var(--safe-top)); padding-inline: max(16px, var(--safe-left)) max(16px, var(--safe-right)); }
    .modal__head h2 { font-size: 18px; }
    .modal__head .icon-btn { margin: -6px -8px 0 0; }
    [dir="rtl"] .modal__head .icon-btn { margin: -6px 0 0 -8px; }
    .modal__body { padding: 16px; }
    .modal__foot { padding: 12px 16px calc(12px + var(--safe-bottom)); }
    .kb-open .modal__foot { padding-bottom: 10px; }

    /* ---------- الجداول الرئيسية تصبح بطاقات مكدّسة ----------
       الخلية الأولى عنوان السطر، والبقية «التسمية: القيمة» من data-label. */
    .table-wrap:has(> .table--stack) { overflow-x: visible; }
    .table--stack, .table--stack tbody { display: block; width: 100%; }
    .table--stack thead { display: none; }
    /* عمودان من «التسمية فوق القيمة» مثل بطاقة بيانات؛ العنوان والإجراءات بعرض البطاقة. */
    .table--stack tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
    .table--stack tbody tr:last-child { border-bottom: 0; }
    .table--stack td { display: block; grid-column: 1 / -1; min-width: 0; padding: 0; border: 0; text-align: start; }
    .table--stack td.num { text-align: start; }
    .table--stack td[data-label] { display: grid; grid-column: auto; align-content: start; justify-items: start; gap: 2px; font-size: 14px; white-space: normal; overflow-wrap: anywhere; }
    .table--stack td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; font-weight: 500; line-height: 1.4; }
    .table--stack td[data-label] > * { min-width: 0; max-width: 100%; }
    .table--stack td:empty { display: none; }
    .table--stack td.cell-actions { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 8px; }
    .table--stack td.cell-actions .btn + .btn { margin-inline-start: 0; }
    .table--stack .cell-main { min-width: 0; }
    .table--stack .cell-main strong, .table--stack .cell-main a { font-size: 15px; overflow-wrap: anywhere; }
    .table--stack .person, .table--stack .person-link { min-width: 0; max-width: 100%; }
    .table--stack .person__text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .table--stack .cell-check { width: auto; }
    .table--stack tr.table__group { display: block; padding: 0; }
    .table--stack tr.table__group th { display: block; }
    .table--tasks.table--stack tr.is-mine { box-shadow: inset -3px 0 0 var(--sun); }
    [dir="ltr"] .table--tasks.table--stack tr.is-mine { box-shadow: inset 3px 0 0 var(--sun); }
    .table--tasks.table--stack tr.is-mine td:first-child { box-shadow: none; }

    /* الجداول العريضة فعلًا (أوراق التقييم) تبقى بتمرير أفقي ظاهر */
    .table-wrap:not(:has(> .table--stack)) { overscroll-behavior-x: contain; scrollbar-width: thin; background:
        linear-gradient(to left, var(--surface) 30%, transparent) right center / 24px 100% no-repeat local,
        linear-gradient(to right, var(--surface) 30%, transparent) left center / 24px 100% no-repeat local,
        radial-gradient(farthest-side at 100% 50%, rgba(20, 26, 46, .14), transparent) right center / 10px 100% no-repeat scroll,
        radial-gradient(farthest-side at 0 50%, rgba(20, 26, 46, .14), transparent) left center / 10px 100% no-repeat scroll; }
}

/* ==========================================================================
   المشاريع: الشارة، المبدّل، البطاقات، وصفحة المشروع
   ========================================================================== */
.project-badge, .project-chip, .project-dot, .project-card, .project-head, .swatch, .project-scope {
    --c: #2f55e4; --c-soft: #eaeffe;
}
.project-badge--blue, .project-chip--blue, .project-dot--blue, .project-card--blue, .project-head--blue, .swatch--blue { --c: #2f55e4; --c-soft: #eaeffe; }
.project-badge--teal, .project-chip--teal, .project-dot--teal, .project-card--teal, .project-head--teal, .swatch--teal { --c: #0f8a9d; --c-soft: #e2f3f6; }
.project-badge--green, .project-chip--green, .project-dot--green, .project-card--green, .project-head--green, .swatch--green { --c: #2a8a3e; --c-soft: #e6f3ea; }
.project-badge--purple, .project-chip--purple, .project-dot--purple, .project-card--purple, .project-head--purple, .swatch--purple { --c: #7450e0; --c-soft: #f1edfe; }
.project-badge--orange, .project-chip--orange, .project-dot--orange, .project-card--orange, .project-head--orange, .swatch--orange { --c: #d4600f; --c-soft: #fcebdc; }
.project-badge--red, .project-chip--red, .project-dot--red, .project-card--red, .project-head--red, .swatch--red { --c: #c5352c; --c-soft: #fdebe9; }
.project-badge--gold, .project-chip--gold, .project-dot--gold, .project-card--gold, .project-head--gold, .swatch--gold { --c: #a8842f; --c-soft: #f7f0de; }
.project-badge--gray, .project-chip--gray, .project-dot--gray, .project-card--gray, .project-head--gray, .swatch--gray { --c: #646e86; --c-soft: #edf0f6; }

.project-badge {
    display: inline-grid; place-items: center; flex: none;
    width: 26px; height: 26px; border-radius: 7px;
    background: var(--c); color: #fff;
    font-size: 11px; font-weight: 800; line-height: 1; letter-spacing: .02em; direction: ltr;
}
.project-badge--sm { width: 20px; height: 20px; border-radius: 6px; font-size: 9.5px; }
.project-badge--lg { width: 40px; height: 40px; border-radius: 10px; font-size: 14px; }
.project-badge--xl { width: 52px; height: 52px; border-radius: 13px; font-size: 18px; }
.project-badge--all { background: var(--surface-3); color: var(--ink-2); }
.project-badge .icon { width: 15px; height: 15px; }
.project-badge--lg .icon { width: 20px; height: 20px; }

/* المبدّل في الشريط الجانبي */
.project-switch { margin: 0 12px 6px; flex: none; }
.project-switch__btn {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r);
    background: var(--surface-2); color: var(--ink); text-align: start; cursor: pointer;
    font: inherit;
    transition: border-color .15s var(--ease), background .15s var(--ease);
}
.project-switch__btn:hover, .project-switch__btn[aria-expanded="true"] { border-color: var(--brand-line); background: var(--brand-soft); }
.project-switch__text { display: grid; min-width: 0; flex: 1; line-height: 1.3; }
.project-switch__text small { color: var(--side-muted); font-size: 11px; font-weight: 500; }
.project-switch__text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.project-switch__chev { color: var(--faint); transform: rotate(-90deg); }
.project-switch .menu__panel { inset-inline: 0; min-width: 0; max-height: min(420px, 70vh); overflow-y: auto; }
.project-switch .menu__panel button[aria-current="true"] { background: var(--brand-soft); color: var(--brand-strong); }
.project-switch .menu__panel .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-switch__mine { color: var(--muted); font-size: 11px; font-weight: 500; }

/* شريحة «داخل مشروع» في رأس الصفحات */
.project-scope {
    display: inline-flex; align-items: center; gap: 8px; justify-self: start;
    padding: 3px 10px 3px 4px; border: 1px solid var(--line); border-radius: 999px;
    background: var(--surface); font-size: 13px; color: var(--ink-2);
}
.project-scope a { font-weight: 700; color: var(--ink); }
.project-scope__clear { display: inline-grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; }
.project-scope__clear:hover { background: var(--surface-3); color: var(--ink); }

/* اسم المشروع بنقطة لونه (في الجداول والبطاقات) */
.project-dot { display: inline-flex; align-items: center; gap: 7px; max-width: 100%; color: var(--ink-2); font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-dot::before { content: ""; width: 8px; height: 8px; flex: none; border-radius: 3px; background: var(--c); }
.project-dot--none { color: var(--muted); font-weight: 500; }
.project-dot--none::before { background: var(--line-strong); }
a.project-dot:hover { color: var(--ink); }

/* شبكة المشاريع */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.project-card {
    position: relative; display: flex; flex-direction: column; gap: 14px;
    padding: 18px 18px 14px; border: 1px solid var(--line); border-top: 3px solid var(--c);
    border-radius: var(--r-lg); background: var(--surface); color: inherit; box-shadow: var(--shadow-1);
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease), transform .15s var(--ease);
}
.project-card:hover { box-shadow: var(--shadow-2); transform: translateY(-1px); color: inherit; }
.project-card.is-current { box-shadow: 0 0 0 2px var(--c-soft), var(--shadow-1); }
.project-card--general { border-top-color: var(--line-strong); }
.project-card__link { position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.project-card__head { display: flex; align-items: center; gap: 12px; }
.project-card__title { display: grid; min-width: 0; flex: 1; line-height: 1.35; }
.project-card__title h2 { font-size: 17px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-card__title span { color: var(--muted); font-size: 13px; }
.project-card__mine { color: var(--c); font-weight: 700; }
.project-card__desc { color: var(--ink-2); font-size: 13.5px; line-height: 1.6; }
.project-card__stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); gap: 6px; margin: 0; }
.project-card__stats > div { display: grid; gap: 2px; padding: 8px 10px; border-radius: var(--r-sm); background: var(--surface-2); }
.project-card__stats dt { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-card__stats dd { margin: 0; font-size: 19px; font-weight: 800; line-height: 1.2; }
.project-card__stats .is-bad dd { color: var(--bad); }
.project-card__foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); }
.project-card__go { color: var(--faint); }
.project-card:hover .project-card__go { color: var(--c); }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack .avatar + .avatar { margin-inline-start: -7px; }
.avatar--more { background: var(--surface-3); color: var(--muted); font-size: 10px; }

/* صفحة المشروع */
.project-head__title { display: flex; align-items: center; gap: 14px; }
.project-head__title h1 { line-height: 1.2; }
.project-head__title p { color: var(--muted); font-size: 13.5px; }
.project-head__desc { color: var(--ink-2); max-width: 72ch; }
.project-head .page-head__actions form { display: contents; }
.project-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin-top: -6px; border-bottom: 1px solid var(--line); }
.project-tabs::-webkit-scrollbar { display: none; }
.project-tabs a {
    display: inline-flex; align-items: center; gap: 7px; flex: none;
    padding: 10px 12px; margin-bottom: -1px; border-bottom: 2px solid transparent;
    color: var(--muted); font-size: 14px; font-weight: 600; white-space: nowrap;
}
.project-tabs a:hover { color: var(--ink); }
.project-tabs a.is-active { color: var(--ink); border-bottom-color: var(--brand); }
.project-tabs .icon { width: 16px; height: 16px; }
.stat--link { transition: border-color .15s var(--ease), box-shadow .15s var(--ease); }
.stat--link:hover { border-color: var(--brand-line); box-shadow: var(--shadow-2); color: inherit; }
.team-list { list-style: none; margin: 0; padding: 6px 0; }
.team-list li { display: flex; align-items: center; gap: 10px; padding: 9px 20px; }
.team-list__name { display: grid; flex: 1; min-width: 0; line-height: 1.35; }
.team-list__name strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-list__name span { color: var(--muted); font-size: 12px; }
.team-list__nums { display: inline-flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); }
.team-list__nums > * { display: inline-flex; align-items: center; gap: 3px; }
.team-list__nums a { color: var(--ink-2); }
.team-list__nums a:hover { color: var(--brand); }
.team-list__nums .icon { color: var(--faint); }
.team-list__nums .is-overdue, .team-list__nums .is-overdue .icon { color: var(--bad); }
.tag--link { color: var(--ink-2); }
.tag--link:hover { background: var(--brand-soft); color: var(--brand-strong); }
.btn--icon { width: 38px; padding: 0; }

/* ألوان المشروع في نموذج المشروع */
.swatch-field { border: 0; padding: 0; margin: 0; }
.swatch-field legend, fieldset.field > legend { margin-bottom: 6px; padding: 0; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { position: relative; display: inline-grid; place-items: center; width: 34px; height: 34px; cursor: pointer; }
.swatch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.swatch__dot { width: 28px; height: 28px; border-radius: 9px; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08); transition: transform .12s var(--ease), box-shadow .12s var(--ease); }
.swatch:hover .swatch__dot { transform: scale(1.06); }
.swatch input:checked + .swatch__dot { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }
.swatch input:focus-visible + .swatch__dot { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c), var(--focus); }

/* ==========================================================================
   أرشيف الوثائق
   ========================================================================== */
.file-icon {
    --c: #646e86; --c-soft: #edf0f6;
    position: relative; display: inline-grid; place-items: center; flex: none;
    width: 38px; height: 42px; border-radius: 8px;
    background: var(--c-soft); color: var(--c);
}
.file-icon .icon { width: 18px; height: 18px; margin-top: -8px; }
.file-icon small { position: absolute; bottom: 4px; inset-inline: 0; text-align: center; font-size: 8.5px; font-weight: 800; letter-spacing: .03em; line-height: 1; direction: ltr; }
.file-icon--pdf { --c: #c5352c; --c-soft: #fdebe9; }
.file-icon--image { --c: #0f8a9d; --c-soft: #e2f3f6; }
.file-icon--word { --c: #2f55e4; --c-soft: #eaeffe; }
.file-icon--sheet { --c: #16804d; --c-soft: #e4f6ec; }
.file-icon--slides { --c: #d4600f; --c-soft: #fcebdc; }
.file-icon--audio { --c: #7450e0; --c-soft: #f1edfe; }
.file-icon--video { --c: #b5307a; --c-soft: #fbe8f2; }
.file-icon--archive { --c: #8a6a1f; --c-soft: #f7f0de; }
.file-icon--lg { width: 56px; height: 64px; border-radius: 11px; }
.file-icon--lg .icon { width: 26px; height: 26px; margin-top: -10px; }
.file-icon--lg small { bottom: 7px; font-size: 10.5px; }
.file-icon--xl { width: 76px; height: 88px; border-radius: 14px; }
.file-icon--xl .icon { width: 34px; height: 34px; margin-top: -14px; }
.file-icon--xl small { bottom: 10px; font-size: 13px; }

.inbox-banner {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px; border: 1px solid var(--sun-line); border-radius: var(--r-lg);
    background: var(--sun-soft); color: var(--ink);
}
.inbox-banner:hover { color: var(--ink); border-color: var(--sun); }
.inbox-banner__icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 10px; background: var(--sun); color: #fff; }
.inbox-banner__text { display: grid; flex: 1; min-width: 0; line-height: 1.4; }
.inbox-banner__text span { color: var(--sun-ink); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.project-chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 1px 6px; scrollbar-width: thin; }
.project-chip {
    display: inline-flex; align-items: center; gap: 7px; flex: none;
    padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px;
    background: var(--surface); color: var(--ink-2); font-size: 13.5px; font-weight: 600; white-space: nowrap;
    transition: border-color .15s var(--ease), background .15s var(--ease);
}
.project-chip i { width: 9px; height: 9px; border-radius: 3px; background: var(--c); }
.project-chip .num { color: var(--muted); font-weight: 500; font-size: 12.5px; }
.project-chip:hover { border-color: var(--line-strong); color: var(--ink); }
.project-chip.is-active { border-color: var(--c); background: var(--c-soft); color: var(--ink); }
.project-chip.is-active .num { color: var(--ink-2); }
.project-chip .icon { width: 14px; height: 14px; color: var(--muted); }

.archive-toolbar .view-switch { align-self: flex-end; }
.archive-view a { padding: 7px 9px; }
.filter-chip { display: inline-flex; align-items: center; gap: 8px; align-self: start; padding: 4px 12px 4px 4px; border: 1px solid var(--brand-line); border-radius: 999px; background: var(--brand-soft); font-size: 13.5px; }
.filter-chip .icon-btn { width: 26px; height: 26px; }

.doc-table td { vertical-align: middle; }
.doc-name { display: flex; align-items: center; gap: 12px; min-width: 0; color: inherit; }
.doc-name:hover strong { color: var(--brand-strong); }
.doc-name .cell-main { min-width: 0; }
.doc-name .cell-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 42ch; }
.doc-name .cell-main span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46ch; unicode-bidi: plaintext; }
.doc-source { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 13px; white-space: nowrap; }
.doc-source .icon { color: var(--muted); }
.doc-source__link { display: block; color: var(--muted); font-size: 12.5px; max-width: 28ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.doc-source__link:hover { color: var(--brand-strong); }

.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 14px; }
.doc-card { display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); color: inherit; box-shadow: var(--shadow-1); transition: border-color .15s var(--ease), box-shadow .15s var(--ease), transform .15s var(--ease); }
.doc-card:hover { border-color: var(--brand-line); box-shadow: var(--shadow-2); transform: translateY(-1px); color: inherit; }
.doc-card__thumb { display: grid; place-items: center; aspect-ratio: 4 / 3; overflow: hidden; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.doc-card__thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc-card__body { display: grid; gap: 4px; padding: 10px 12px 12px; min-width: 0; }
.doc-card__body strong { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 14px; line-height: 1.45; min-height: 2.9em; }
.doc-card__meta { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-card__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; min-width: 0; }
.doc-card__foot .project-dot { font-size: 12.5px; }

.doc-head__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.doc-preview { overflow: hidden; }
.doc-preview img { display: block; width: 100%; max-height: 72vh; object-fit: contain; background: var(--surface-2); }
.doc-preview iframe { display: block; width: 100%; height: 78vh; border: 0; background: var(--surface-2); }
.doc-preview video { display: block; width: 100%; max-height: 72vh; background: #000; }
.doc-preview__media { display: flex; align-items: center; gap: 18px; padding: 28px 24px; }
.doc-preview__media audio { flex: 1; min-width: 0; }
.doc-preview__none { display: grid; justify-items: center; gap: 8px; padding: 48px 24px; text-align: center; }
.doc-preview__none strong { font-size: 16px; overflow-wrap: anywhere; }
.doc-preview__none span { color: var(--muted); font-size: 13.5px; margin-bottom: 8px; }
.doc-origin .card__body { display: flex; gap: 12px; align-items: flex-start; }
.doc-origin__icon { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 9px; background: var(--brand-soft); color: var(--brand); }
.doc-origin p { font-size: 13.5px; margin-top: 2px; }
.doc-file-name { overflow-wrap: anywhere; }
.doc-item .file-icon { width: 34px; height: 38px; }

/* منطقة الإفلات للرفع */
.dropzone {
    position: relative; display: grid; justify-items: center; gap: 4px;
    margin-bottom: 18px; padding: 26px 18px; border: 2px dashed var(--line-strong); border-radius: var(--r-lg);
    background: var(--surface-2); text-align: center; cursor: pointer;
    transition: border-color .15s var(--ease), background .15s var(--ease);
}
.dropzone:hover, .dropzone:focus-within, .dropzone.is-over { border-color: var(--brand); background: var(--brand-soft); }
.dropzone__input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dropzone__icon { color: var(--brand); margin-bottom: 4px; }
.dropzone > span:not(.dropzone__icon) { color: var(--muted); font-size: 13px; }
.dropzone.has-files { padding: 12px; justify-items: stretch; text-align: start; }
.dropzone.has-files > .dropzone__icon, .dropzone.has-files > strong, .dropzone.has-files > span { display: none; }
.dropzone__files { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.dropzone__files li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); font-size: 13.5px; }
.dropzone__files li .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropzone__files li small { color: var(--muted); }
.dropzone__files li.is-bad { border-color: var(--bad-line); background: var(--bad-soft); }
.dropzone__files li.is-bad small { color: var(--bad); }
.dropzone__files .dropzone__more { justify-content: center; color: var(--brand-strong); font-weight: 600; border-style: dashed; }
.file-summary { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
.file-summary div { display: grid; min-width: 0; }
.file-summary strong { overflow-wrap: anywhere; }
.file-summary span { color: var(--muted); font-size: 13px; }

/* بطاقات الاختيار (من يرى الوثيقة) */
fieldset.field { border: 0; padding: 0; margin: 0; min-inline-size: 0; }
.choice-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.choice-card { position: relative; display: block; cursor: pointer; }
.choice-card input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice-card__body { display: grid; justify-items: start; gap: 2px; height: 100%; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); transition: border-color .15s var(--ease), background .15s var(--ease); }
.choice-card__body .icon { color: var(--muted); margin-bottom: 2px; }
.choice-card__body strong { font-size: 13.5px; }
.choice-card__body small { color: var(--muted); font-size: 12px; }
.choice-card:hover .choice-card__body { border-color: var(--faint); }
.choice-card input:checked + .choice-card__body { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.choice-card input:checked + .choice-card__body .icon { color: var(--brand); }
.choice-card input:focus-visible + .choice-card__body { box-shadow: var(--focus); }

/* صندوق الملفات المشاركة */
.inbox-files { list-style: none; margin: 0; padding: 0; }
.inbox-file { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.inbox-file:last-child { border-bottom: 0; }
.inbox-file__check input { width: 18px; height: 18px; accent-color: var(--brand); }
.inbox-file__thumb { width: 56px; height: 56px; flex: none; border-radius: 10px; object-fit: cover; background: var(--surface-2); }
.inbox-file__main { display: grid; gap: 4px; flex: 1; min-width: 0; }
.inbox-file__main > span { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.form-section__title { font-size: 17px; font-weight: 800; margin-bottom: 14px; }
.form-actions--sticky { position: sticky; bottom: 0; z-index: 5; margin-top: 0; padding: 12px 0; border-top: 0; background: linear-gradient(to top, var(--bg) 70%, transparent); }
@media (max-width: 1023px) { .has-tabbar .form-actions--sticky { bottom: var(--tabbar-h, 64px); } }
@media (max-width: 760px) {
    .doc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .project-grid { grid-template-columns: minmax(0, 1fr); }
    .doc-name .cell-main strong, .doc-name .cell-main span { max-width: 60vw; }
    .doc-preview iframe { height: 64vh; }
    .inbox-file { padding: 12px 14px; }
}
@media (max-width: 520px) {
    .choice-cards { grid-template-columns: minmax(0, 1fr); }
    .choice-card__body { grid-template-columns: auto 1fr; align-items: center; column-gap: 8px; }
    .choice-card__body .icon { grid-row: span 2; margin: 0; }
    .choice-card__body small { grid-column: 2; }
}


/* ==========================================================================
   الانتقال بين الصفحات: شريط تقدّم فوري عند كل ضغطة، وانتقال ناعم يُبقي
   الشريط الجانبي والعلوي والسفلي ثابتة (مهم في التطبيق المثبّت حيث لا مؤشر تحميل للمتصفح).
   ========================================================================== */
.nav-progress {
    position: fixed; z-index: 100; inset-inline: 0; top: 0;
    height: 3px; pointer-events: none; opacity: 0;
    transition: opacity .25s var(--ease) .1s;
}
.nav-progress span {
    display: block; height: 100%;
    background: linear-gradient(to left, var(--brand), var(--sun));
    box-shadow: 0 0 10px rgba(47, 85, 228, .5);
    transform: scaleX(0); transform-origin: right;
}
[dir="ltr"] .nav-progress span { transform-origin: left; background: linear-gradient(to right, var(--brand), var(--sun)); }
.nav-progress.is-active { opacity: 1; transition: none; }
.nav-progress.is-active span { animation: nav-progress 12s cubic-bezier(.08, .7, .2, 1) forwards; }
@keyframes nav-progress {
    0% { transform: scaleX(0); }
    2% { transform: scaleX(.28); }
    15% { transform: scaleX(.62); }
    45% { transform: scaleX(.82); }
    100% { transform: scaleX(.94); }
}
@supports (padding: env(safe-area-inset-top)) { .nav-progress { top: env(safe-area-inset-top); } }
/* الصفحة القديمة تخفت قليلًا إن طال التحميل، فيعرف المستخدم أن ضغطته وصلت. */
html.is-navigating .content { opacity: .6; transition: opacity .2s var(--ease) .3s; }
html.is-navigating .content * { pointer-events: none; }
/* العنصر المضغوط يبقى مضغوطًا حتى تظهر الصفحة الجديدة. */
.nav-item.is-pressed, .tabbar__item.is-pressed .tabbar__icon, a.list__item.is-pressed, .task-row.is-pressed,
.table tbody tr:has(.is-pressed), .menu__panel .is-pressed { background-color: var(--surface-3); }
.btn.is-pressed { background-color: var(--surface-3); }
.btn--primary.is-pressed { background-color: var(--brand-press); }
.board-card.is-pressed, a.stat.is-pressed, a.kpi.is-pressed, a.tile.is-pressed, .doc-card.is-pressed, .project-card:has(.is-pressed) { border-color: var(--brand-line); background-color: var(--surface-2); }

@view-transition { navigation: auto; }
@media (min-width: 1024px) { .sidebar { view-transition-name: app-sidebar; } }
.topbar { view-transition-name: app-topbar; }
.tabbar { view-transition-name: app-tabbar; }

/* الجوال: الصفحة لا تتحرك جانبيًا أبدًا. أي عنصر أعرض من الشاشة يُقص بدل أن يجعل الصفحة كلها
   قابلة للسحب يمينًا ويسارًا (فتظهر القائمة المخفية ويتعثر التمرير العمودي). */
@media (max-width: 1023px) {
    /* hidden على html فقط (ينتقل إلى نافذة العرض)؛ على body يكسر الشريط العلوي اللاصق في المتصفحات القديمة. */
    html { overflow-x: hidden; }
    @supports (overflow: clip) { html, body { overflow-x: clip; } }
    html, body { overscroll-behavior-x: none; }
    .main { min-width: 0; max-width: 100vw; }
    .content { min-width: 0; }
    .content img, .content video, .content iframe { max-width: 100%; }
    .content pre, .content code { white-space: pre-wrap; overflow-wrap: anywhere; }
    .prose, .msg__text, .meta__item dd, .cell-main, .task-row__title strong { overflow-wrap: anywhere; }
}
::view-transition-group(*) { animation-duration: .2s; animation-timing-function: var(--ease); }
::view-transition-old(root) { animation: vt-out .12s ease-out both; }
::view-transition-new(root) { animation: vt-in .22s var(--ease) both; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) {
    @view-transition { navigation: none; }
    .nav-progress.is-active span { animation: none; transform: scaleX(.7); }
}

/* ==========================================================================
   الهاتف: تلميع القوائم والأرقام والفلاتر
   ========================================================================== */
.filters__count {
    display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
    border-radius: 999px; background: var(--brand); color: #fff; font-size: 11.5px; font-weight: 700; line-height: 1;
}
.filters__toggle[aria-expanded="true"] { border-color: var(--brand-line); background: var(--brand-soft); color: var(--brand-strong); }

@media (max-width: 760px) {
    /* كل نماذج التصفية تُطوى خلف زر «تصفية» يحمل عدد الفلاتر المفعّلة. */
    .filters .filters__toggle { display: inline-flex; }
    .filters .field--grow { flex: 1 1 0; }
    .filters:not(.is-open) .field:not(.field--grow), .filters:not(.is-open) .filters__actions, .filters:not(.is-open) .view-switch:not(.archive-view) { display: none; }
    /* بحث فقط: الحقل بعرض كامل، وزر «مسح» يظهر بجانبه عند وجود نص. */
    .filters--simple .filters__actions { display: flex !important; flex: 0 0 auto; }
    .filters--simple .filters__actions .btn:not(.btn--ghost) { display: none; }
    .filters--simple .filters__actions:not(:has(.btn--ghost)) { display: none !important; }
    .filters:not(:has(.field--grow)) .filters__toggle { flex: 1 1 100%; justify-content: center; }
    .filters.is-open { row-gap: 12px; }
    .filters.is-open .field:not(.field--grow) { flex: 1 1 calc(50% - 6px); }
    .filters.is-open .field:has(.ts-wrapper), .filters.is-open .field:has(select[data-select]) { flex-basis: 100%; }

    /* بطاقات الأرقام: عمودان مضغوطان بدل بطاقة تملأ الشاشة لكل رقم. */
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .stats > .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
    .stat { gap: 2px; padding: 12px 14px; border-radius: var(--r); }
    .stat__label { font-size: 12.5px; line-height: 1.35; }
    .stat__label .icon { width: 14px; height: 14px; flex: none; }
    .stat__value { font-size: 24px; }
    .stat__hint { font-size: 11.5px; line-height: 1.45; }
    .kpi__value { font-size: 22px; }
    .kpi__label { font-size: 12.5px; }

    .page-head__text > p { font-size: 14px; line-height: 1.6; }
    .page-head__actions { gap: 8px; }
    .page-head__actions > .btn:not(.btn--fab), .page-head__actions > a.btn:not(.btn--fab) { flex: 1 1 auto; }
    .page-head__actions > .btn--icon, .page-head__actions > .menu { flex: none; }
    /* ثلاثة إجراءات فأكثر: صف واحد يُسحب أفقيًا بدل أسطر غير متساوية. */
    .page-head__actions:has(> :nth-child(3)) { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; margin-inline: -16px; padding: 2px 16px; }
    .page-head__actions:has(> :nth-child(3))::-webkit-scrollbar { display: none; }
    .page-head__actions:has(> :nth-child(3)) > *, .page-head__actions:has(> :nth-child(3)) > .btn:not(.btn--fab) { flex: 0 0 auto; }
    .page-head__actions:has(> :nth-child(3)) .btn:not(.btn--fab) { min-height: 40px; padding-inline: 14px; border-radius: 999px; }
    .page-head__actions:has(> :nth-child(3)) form { display: flex; }
    .card__head h2 { font-size: 17px; }
    .card__head p { font-size: 12.5px; }
}

@media (max-width: 640px) {
    /* ---------- صف الجدول في الهاتف: العنوان والإجراء في سطر، والتفاصيل تحتهما في شبكة مضغوطة ---------- */
    .table--stack tbody tr { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 14px; padding: 12px 16px; }
    .table--stack tbody tr > td { order: 3; }
    .table--stack tbody tr > td.cell-check { order: 0; flex: none; padding-top: 2px; }
    .table--stack tbody tr > td:not([data-label]):not(.cell-actions):not(.cell-check) { order: 1; flex: 1 1 0; min-width: 0; }
    .table--stack tbody tr > td.cell-actions { order: 2; flex: none; display: flex; flex-wrap: nowrap; gap: 6px; margin-inline-start: auto; }
    /* كسر سطر بعد العنوان وإجراءاته: التفاصيل تبدأ دائمًا في سطر جديد. */
    .table--stack tbody tr::after { content: ""; order: 2; flex: 0 0 100%; height: 0; margin-top: -8px; }
    .table--stack tbody tr > td[data-label] { flex: 1 1 calc(50% - 7px); min-width: 0; gap: 1px; font-size: 13.5px; }
    .table--stack td[data-label]::before { font-size: 11.5px; letter-spacing: .01em; }
    /* شارة الحالة وحدها لا تحتاج تسمية فوقها. */
    .table--stack td[data-label]:has(> .badge:only-child)::before, .table--stack td[data-label]:has(> .status-pill:only-child)::before { display: none; }
    /* وتصعد إلى سطر العنوان بجانب الإجراء بدل أن تأخذ سطرًا كاملًا. */
    .table--stack tbody tr > td[data-label]:has(> .badge:only-child), .table--stack tbody tr > td[data-label]:has(> .status-pill:only-child) { order: 2; flex: none; align-self: center; }
    .table--stack td.cell-actions .btn { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
    .table--stack td.cell-actions .btn--ghost { padding-inline: 8px; }
    .table--stack td.cell-actions form { display: contents; }
    .table--stack .cell-main { display: grid; gap: 1px; }
    .table--stack .cell-main > span { font-size: 12.5px; color: var(--muted); }
    .table--stack .person { gap: 8px; }
    .table--stack td:first-child .person .avatar, .table--stack td:first-child .avatar { width: 34px; height: 34px; font-size: 12.5px; }
    .table--stack tbody tr:has(td:first-child a):active { background: var(--surface-2); }

    /* ---------- سجل التدقيق: الوقت والشخص والعملية في سطر، والوصف تحته ---------- */
    .table--log, .table--log tbody { display: block; width: 100%; }
    .table--log thead { display: none; }
    .table-wrap:has(> .table--log) { overflow-x: visible; }
    .table--log tbody tr { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 4px 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
    .table--log tbody tr > td { padding: 0; border: 0; min-width: 0; }
    .table--log .log-time { grid-column: 1; font-size: 13px; }
    .table--log tbody tr > td:nth-child(2) { grid-column: 2; overflow: hidden; }
    .table--log tbody tr > td:nth-child(2) .person { min-width: 0; }
    .table--log tbody tr > td:nth-child(3) { grid-column: 3; }
    .table--log tbody tr > td:nth-child(4) { grid-column: 1 / -1; color: var(--muted); font-size: 12.5px; white-space: normal; }
    .table--log .log-text { grid-column: 1 / -1; min-width: 0; font-size: 13.5px; }
    .table--log .log-text:not(:has(p:not(:empty))):not(:has(details)) { display: none; }
    .table--log tr.table__group { display: block; padding: 0; }
    .table--log tr.table__group th { display: block; padding: 10px 16px; }
}


/* ==========================================================================
   نموذج بخطوات (معالج إضافة المهمة)
   ========================================================================== */
.is-wizard [data-wizard-step]:not(.is-current) { display: none; }
.is-wizard [data-wizard-step].is-current { animation: wizard-in .2s var(--ease); }
.is-wizard .form-section + .form-section { margin-top: 0; padding-top: 0; border-top: 0; }
@keyframes wizard-in { from { opacity: 0; transform: translateX(-10px); } }
[dir="ltr"] .is-wizard [data-wizard-step].is-current { animation-name: wizard-in-ltr; }
@keyframes wizard-in-ltr { from { opacity: 0; transform: translateX(10px); } }

.wizard {
    display: flex; gap: 4px; flex: none; margin: 0; padding: 12px 22px; list-style: none;
    border-bottom: 1px solid var(--line); background: var(--surface);
    overflow-x: auto; scrollbar-width: none;
}
.wizard::-webkit-scrollbar { display: none; }
.wizard[hidden] { display: none; }
.card .wizard { margin: -4px -4px 18px; padding: 0 0 14px; }
.wizard li { display: flex; flex: 1 1 0; min-width: 0; }
.wizard li + li::before { content: ""; align-self: center; flex: 1 1 12px; min-width: 8px; max-width: 40px; height: 2px; margin-inline-end: 4px; border-radius: 2px; background: var(--line); }
.wizard li:has(.is-done) + li::before, .wizard li:has(.is-current) + li::before { background: var(--line); }
.wizard li:has(.is-done) + li::before { background: var(--brand-line); }
.wizard__step {
    display: inline-flex; align-items: center; gap: 8px; min-width: 0; padding: 4px 8px 4px 4px;
    border: 0; border-radius: 999px; background: transparent; color: var(--muted);
    font: inherit; font-size: 13.5px; font-weight: 600; white-space: nowrap; cursor: pointer;
    transition: background .15s var(--ease), color .15s var(--ease);
}
[dir="rtl"] .wizard__step { padding: 4px 4px 4px 8px; }
.wizard__step:hover:not(:disabled) { background: var(--surface-3); color: var(--ink); }
.wizard__step:disabled { cursor: default; opacity: .6; }
.wizard__num {
    display: inline-grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 50%;
    border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--muted);
    font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums;
    transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}
.wizard__label { overflow: hidden; text-overflow: ellipsis; }
.wizard__step.is-done { color: var(--ink-2); }
.wizard__step.is-done .wizard__num { border-color: var(--brand-line); background: var(--brand-soft); color: var(--brand-strong); }
.wizard__step.is-current { color: var(--ink); }
.wizard__step.is-current .wizard__num { border-color: var(--brand); background: var(--brand); color: #fff; box-shadow: 0 0 0 4px var(--brand-soft); }

.wizard__foot [data-wizard-next], .wizard__foot [data-wizard-submit] { min-width: 132px; }
.wizard__count { margin-inline: auto; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.modal__foot.wizard__foot { justify-content: flex-start; }
.wizard__foot [data-dialog-close], .wizard__foot > a.btn--ghost { order: -1; margin-inline-end: auto; }
.wizard__foot:has(.wizard__count:not([hidden])) [data-dialog-close], .wizard__foot:has(.wizard__count:not([hidden])) > a.btn--ghost { margin-inline-end: 0; }
.wizard__more { margin-top: 18px; }
.wizard__more > .form-grid { margin-top: 12px; }

@media (max-width: 640px) {
    .wizard { gap: 2px; padding: 10px 16px; }
    /* في الهاتف: الأرقام فقط، واسم الخطوة الحالية بجانب رقمها. */
    .wizard__step:not(.is-current) .wizard__label { display: none; }
    .wizard__step { padding: 2px; }
    [dir="rtl"] .wizard__step { padding: 2px 2px 2px 8px; }
    .wizard__step:not(.is-current) { padding: 2px; }
    .wizard li { flex: 0 1 auto; }
    .wizard li:has(.is-current) { flex: 1 1 auto; }
    .wizard__count { display: none; }
    .wizard__foot .btn { flex: 1 1 auto; min-width: 0; }
    .wizard__foot [data-dialog-close], .wizard__foot > a.btn--ghost { flex: 0 0 auto; }
}


/* ==========================================================================
   كلمة المرور المؤقتة وشاشة صلاحيات الموظف
   ========================================================================== */
.pw-reset { display: grid; gap: 16px; }
.pw-reset__who, .access-who { display: flex; align-items: center; gap: 12px; }
.pw-reset__who div, .access-who div { display: grid; line-height: 1.4; min-width: 0; }
.pw-reset__who span, .access-who span { color: var(--muted); font-size: 13px; }
.pw-generate { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 16px; border: 1px solid var(--brand-line); border-radius: var(--r-lg); background: var(--brand-soft); }
.pw-generate__text { display: grid; gap: 2px; flex: 1 1 240px; }
.pw-generate__text span { color: var(--ink-2); font-size: 13px; }
.pw-reset__manual { margin-top: 12px; }
.pw-result { display: grid; gap: 16px; }
.pw-result__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.pw-result__item { display: grid; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
.pw-result__item > span { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.pw-result__value { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pw-result__value code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.pw-result__password { font-size: 19px !important; letter-spacing: .04em; color: var(--brand-strong); }
.pw-result__message { font-size: 14px; line-height: 1.7; background: var(--surface-2); }
.btn.is-copied { border-color: var(--ok); background: var(--ok); color: #fff; }
.divider-label { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12.5px; }
.divider-label::before, .divider-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.access-form { display: grid; gap: 4px; }
.access-form > .notice { margin: 8px 0; }
.access-section { display: grid; gap: 14px; padding: 18px 0; border-top: 1px solid var(--line); }
.access-who + .access-section, .access-who + .notice + .access-section { border-top: 0; padding-top: 14px; }
.access-section h3 { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 800; }
.access-section h3 .icon { color: var(--brand); }
.access-presets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.access-preset { display: grid; gap: 2px; align-content: start; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); color: var(--ink); font: inherit; text-align: start; cursor: pointer; transition: border-color .15s var(--ease), background .15s var(--ease); }
.access-preset strong { font-size: 14px; }
.access-preset span { color: var(--muted); font-size: 12px; line-height: 1.45; }
.access-preset:hover { border-color: var(--faint); }
.access-preset.is-active { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.choice-cards--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.access-tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px; background: var(--surface-3); color: var(--ink-2); font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.access-tag:hover { background: var(--brand-soft); color: var(--brand-strong); }
.access-tag--admin { background: var(--sun-soft); color: var(--sun-ink); }
.access-tag--lead, .access-tag--manager { background: var(--brand-soft); color: var(--brand-strong); }
.access-tag--custom { background: var(--warn-soft); color: var(--warn); }
.access-tag--assistant { margin-inline-start: 4px; background: var(--ok-soft); color: var(--ok); }
.access-projects { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; max-width: 26ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 760px) {
    .access-presets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pw-result__grid { grid-template-columns: minmax(0, 1fr); }
    .pw-generate .btn { flex: 1 1 100%; }
}
@media (max-width: 520px) {
    .choice-cards--2 { grid-template-columns: minmax(0, 1fr); }
}
.access-projects--warn { color: var(--warn); font-weight: 600; }


/* ==========================================================================
   قائمة الموظفين
   ========================================================================== */
.tab--attn .tab__count { background: var(--warn-soft); color: var(--warn); }
.table--people td { vertical-align: middle; }
.table--people tr.is-muted .emp__name, .table--people tr.is-muted .emp .avatar { opacity: .6; }
.emp { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.emp .avatar { width: 38px; height: 38px; font-size: 13px; }
.emp__text { display: grid; gap: 1px; min-width: 0; line-height: 1.4; }
.emp__name { color: var(--ink); font-size: 14.5px; font-weight: 700; }
a.emp__name:hover { color: var(--brand-strong); }
.emp__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; color: var(--ink-2); font-size: 12.5px; }
.emp__meta .badge { font-size: 11px; }
.emp__sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34ch; }
.emp-projects { display: flex; flex-wrap: nowrap; align-items: center; gap: 4px 10px; max-width: 280px; }
.table--people td:nth-child(2), .table--people td:nth-child(5) { white-space: nowrap; }
.emp-projects .project-dot { max-width: 130px; }
.emp-projects .tag { cursor: help; }
.emp-warn { display: inline-flex; align-items: center; gap: 5px; color: var(--warn); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.table--people .cell-actions { width: 1%; }
.table--people .menu__panel { min-width: 210px; }

@media (max-width: 640px) {
    /* الهاتف: الاسم والدور بعرض البطاقة مع زر الإجراءات، والتفاصيل تحتها في عمودين. */
    .table--people .emp { min-width: 0; }
    .table--people .emp__sub { max-width: 100%; }
    .table--people td.cell-actions { width: auto; }
    .table--people td.cell-actions .icon-btn { width: 40px; height: 40px; }
    .emp-projects { max-width: 100%; }
}

/* القائمة المنسدلة العائمة (initMenus): موضع ثابت على الشاشة فوق أي حاوية تقص المحتوى. */
.menu__panel.is-floating { position: fixed; inset: auto; z-index: 80; max-height: min(420px, calc(100vh - 16px)); overflow-y: auto; }

/* الإملاء الصوتي (dictation.js): زر ميكروفون داخل حقل الكتابة. */
.dictate { position: relative; display: block; }
.dictate > input, .dictate > textarea { padding-inline-end: 42px; }
.dictate__btn { position: absolute; top: 50%; inset-inline-end: 6px; display: grid; place-items: center; width: 30px; height: 30px; margin-top: -15px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.dictate--area .dictate__btn { top: 6px; margin-top: 0; }
.dictate__btn:hover { background: var(--surface-3); color: var(--ink); }
.dictate__btn:focus-visible { outline: none; box-shadow: var(--focus); }
.dictate__btn.is-listening { background: var(--bad); color: #fff; animation: dictate-pulse 1.4s ease-in-out infinite; }
.dictate > .is-dictating { border-color: var(--bad); }
.dictate-hint { position: absolute; top: 100%; inset-inline-end: 0; z-index: 5; margin-top: 4px; padding: 4px 10px; border-radius: 8px; background: var(--ink); color: var(--surface); font-size: 12px; white-space: nowrap; }
@keyframes dictate-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(197, 53, 44, .45); } 50% { box-shadow: 0 0 0 6px rgba(197, 53, 44, 0); } }
@media (prefers-reduced-motion: reduce) { .dictate__btn.is-listening { animation: none; } }
@media (hover: none) { .dictate__btn { width: 36px; height: 36px; margin-top: -18px; } .dictate--area .dictate__btn { margin-top: 0; } }

/* الحافظة الشهرية: جدول قابل للتمرير على الجوال ونسخة ورقية مستقلة. */
.attendance-matrix { font-size: 12px; }
.attendance-matrix th, .attendance-matrix td { padding: 8px 6px; text-align: center; min-width: 26px; }
.attendance-matrix th:first-child { min-width: 160px; text-align: start; }
.attendance-matrix th small { display: block; color: var(--muted); font-weight: 400; }
.attendance-signatures { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 20px; }
@media print {
    body:has(.attendance-register) .sidebar, body:has(.attendance-register) .topbar,
    body:has(.attendance-register) .bottom-nav, body:has(.attendance-register) .page-head,
    body:has(.attendance-register) .attendance-filters, body:has(.attendance-register) .notice,
    body:has(.attendance-register) .attendance-print { display: none !important; }
    body:has(.attendance-register) .shell, body:has(.attendance-register) .content { display: block; margin: 0; padding: 0; }
    .attendance-register { box-shadow: none; border: 0; }
    .attendance-register .table-wrap { overflow: visible; }
    .attendance-matrix { width: 100%; font-size: 9px; }
    .attendance-matrix th, .attendance-matrix td { min-width: 0; padding: 5px 2px; border: 1px solid var(--line); }
    .attendance-matrix th:first-child { min-width: 0; width: 120px; }
    .attendance-matrix tr { break-inside: avoid; }
    @page { size: A4 landscape; margin: 10mm; }
}

/* متابعة يوم واحد: بطاقة مختصرة لكل موظف بأوقات واضحة. */
.attendance-day-head { display:flex; align-items:center; justify-content:space-between; gap:16px; padding:24px; flex-wrap:wrap; }
.attendance-day-head h2 { margin-block:4px 8px; }
.attendance-day-head p { margin:0; }
.attendance-day-tabs { padding-inline:20px; border-block-end:1px solid var(--line); }
.attendance-people { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; padding:20px; }
.attendance-person { min-width:0; border:1px solid var(--line); border-inline-start:3px solid var(--line); border-radius:var(--r); padding:16px; }
.attendance-person--present { border-inline-start-color:var(--ok); }
.attendance-person--late { border-inline-start-color:var(--warn); }
.attendance-person__identity { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.attendance-person__identity > div { flex:1; min-width:100px; overflow-wrap:anywhere; }
.attendance-person__identity strong,.attendance-person__identity .muted { display:block; }
.attendance-person__times { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; padding-block:16px; margin:12px 0; border-block:1px solid var(--line); }
.attendance-person__times dt { color:var(--muted); font-size:12px; }
.attendance-person__times dd { margin:6px 0 0; font-size:22px; font-weight:700; font-variant-numeric:tabular-nums; }
@media(max-width:760px) { .attendance-people { grid-template-columns:minmax(0,1fr); padding:12px; } .attendance-day-head { padding:16px; } .attendance-day-stats { grid-template-columns:repeat(2,minmax(0,1fr)); } }

/* استبيانات العملاء: إنشاء داخل المنصة، وإجابة مستقلة ومريحة على الهاتف. */
.survey-question-row { display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:16px; }
.survey-question-row > div { min-width:0; }
.survey-question-row h3 { margin-block:4px; overflow-wrap:anywhere; }
.survey-results { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:24px; }
.survey-result,.survey-response,.survey-invitation { min-width:0; border:1px solid var(--line); border-radius:var(--r); padding:20px; }
.survey-distribution { display:grid; grid-template-columns:minmax(30px,1fr) minmax(0,3fr) 32px; align-items:center; gap:12px; margin-block:10px; }
.survey-distribution meter { width:100%; accent-color:var(--brand); }
.survey-answers { display:grid; gap:16px; margin-block:20px; }
.survey-answers dt { color:var(--muted); font-size:13px; }
.survey-answers dd { margin:6px 0 0; white-space:normal; overflow-wrap:anywhere; }
.survey-invitation { display:grid; gap:12px; }
.survey-public { max-width:740px; margin-inline:auto; padding:32px 20px; }
.survey-public__brand { display:flex; align-items:center; justify-content:space-between; gap:20px; margin-block-end:24px; color:var(--muted); font-size:13px; }
.survey-public__brand img { width:130px; height:auto; }
.survey-public__intro { border-block-end:1px solid var(--line); padding-block-end:20px; margin-block-end:28px; }
.survey-public h1 { font-size:28px; line-height:1.5; margin-block:16px 8px; overflow-wrap:anywhere; }
.survey-public__form { gap:28px; }
.survey-answer { border:0; margin:0; padding:0; min-width:0; }
.survey-answer legend { font-weight:700; margin-block-end:10px; overflow-wrap:anywhere; }
.survey-options { display:grid; gap:10px; }
.survey-options--rating { grid-template-columns:repeat(5,minmax(0,1fr)); }
.survey-option { display:flex; align-items:center; justify-content:center; gap:10px; padding:12px; min-height:48px; border:1px solid var(--line); border-radius:var(--r); cursor:pointer; overflow-wrap:anywhere; }
.survey-option:has(input:checked) { border-color:var(--brand); background:var(--surface-2); color:var(--brand); }
.survey-option:has(input:focus-visible) { box-shadow:var(--focus); }
.survey-option input { accent-color:var(--brand); flex-shrink:0; }
.survey-public__success { text-align:center; padding-block:32px; }
.survey-public__success > .icon { color:var(--ok); }
.survey-public__footer { text-align:center; padding:24px; color:var(--muted); font-size:13px; }
@media(max-width:760px) { .survey-results { grid-template-columns:minmax(0,1fr); } .survey-public { padding:20px 12px; } .survey-public .card--pad { padding:20px; } .survey-option { padding:10px 6px; gap:5px; } .survey-public h1 { font-size:24px; } }

.survey-public,.survey-question-row,.survey-result,.survey-response { overflow-wrap:anywhere; }
.note-text { overflow-wrap: anywhere; white-space: pre-wrap; }
.form-grid:has([data-note-editor]):not(:has(select[name="visibility"] option[value="selected"]:checked)) .field:has([name="readers"]) { display: none; }
.note-compose { border: 1px solid var(--line-strong); border-radius: var(--r); overflow: hidden; }
.note-tools { background: var(--surface-2); border-bottom: 1px solid var(--line); padding: .5rem; }
.note-canvas { min-height: 16rem; padding: 1rem; line-height: 1.9; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-canvas:focus { outline: 2px solid var(--brand); outline-offset: -2px; }
.note-canvas ul { list-style: disc; padding-inline-start: 1.6rem; }
.note-compose [hidden], [data-note-form] [hidden] { display:none !important; }
.note-sheet input[name="title"] { font-size: 1.25rem; font-weight: 600; }
.note-library { display: grid; grid-template-columns: repeat(auto-fill,minmax(min(100%,16rem),1fr)); gap: 1rem; }
.note-preview { display: flex; flex-direction: column; gap: .6rem; color: var(--ink); overflow-wrap: anywhere; }
.note-preview:hover { border-color: var(--brand); }
.note-preview p { color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.note-preview > :last-child { margin-top: auto; }
.note-text:has(table), [data-note-editor] { min-width: 0; overflow-x: auto; }
.note-text img, [data-note-editor] .jodit-wysiwyg img { max-width: 100%; height: auto; }
.note-text table, [data-note-editor] .jodit-wysiwyg table { border-collapse: collapse; }
.note-text td,.note-text th,[data-note-editor] .jodit-wysiwyg td,[data-note-editor] .jodit-wysiwyg th { border: 1px solid var(--line-strong); padding: .45rem; min-width: 2rem; }
.note-text ul { list-style: disc; padding-inline-start: 1.5rem; }
.note-text ol { list-style: decimal; padding-inline-start: 1.5rem; }
[data-note-editor] .jodit-wysiwyg { font-family: inherit; line-height: 1.8; }

.share-destinations { display: flex; flex-wrap: wrap; gap: .75rem; }
.share-destinations > a { flex: 1 1 14rem; }
.share-excerpt { white-space: pre-wrap; overflow-wrap: anywhere; }

.word-reader { display: block; margin: 0; background: var(--surface); color: var(--ink); }
.word-reader main { max-width: 56rem; margin: auto; padding: clamp(1rem, 4vw, 3rem); }
.word-reader p { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.8; }
.word-reader__heading { font-weight: 700; font-size: 1.2em; }
.word-reader img { max-width: 100%; height: auto; }
.word-reader__table { max-width: 100%; overflow: auto; }
.word-reader table { border-collapse: collapse; width: 100%; }
.word-reader td { border: 1px solid var(--line); padding: .4rem; vertical-align: top; }

.archive-share { position: relative; }
.archive-share summary { list-style: none; cursor: pointer; }
.archive-share summary::-webkit-details-marker { display: none; }
.archive-share__panel { display: grid; gap: .5rem; width: min(20rem, 78vw); margin-block-start: .4rem; }

dialog.modal:has(.archive-move) { width: min(42rem, calc(100vw - 1rem)); height: auto; }
.move-browser { display: grid; gap: .7rem; }
.move-browser[hidden], .move-target[hidden] { display: none; }
.move-browser__crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem; color: var(--muted); }
.move-browser__crumbs button { border: 0; background: transparent; color: var(--brand); cursor: pointer; padding: .3rem; font: inherit; }
.move-browser__crumbs [aria-current] { color: var(--ink); font-weight: 700; }
.move-browser__list { height: clamp(8rem, 32dvh, 19rem); overflow-y: auto; overscroll-behavior: contain; border-block: 1px solid var(--line); }
.move-browser__row { position: relative; display: grid; width: 100%; min-height: 44px; align-content: center; gap: .2rem; padding: .65rem .7rem; padding-inline-end: 2.25rem; text-align: start; font: inherit; color: var(--ink); background: transparent; border: 0; border-bottom: 1px solid var(--line); cursor: pointer; overflow-wrap: anywhere; }
.move-browser__row::after { content: "‹"; position: absolute; inset-inline-end: .8rem; inset-block-start: .45rem; font-size: 1.3rem; color: var(--muted); }
.move-browser__row:hover, .move-browser__row:focus-visible { background: var(--surface-2); }
.move-browser__row small, .move-target small { color: var(--muted); }
.move-browser__list > p { padding: .7rem; }
.archive-move .field__help { margin-top: .65rem; }
.move-target { flex: 1 1 12rem; min-width: 0; display: grid; gap: .2rem; overflow-wrap: anywhere; }
@media (max-width: 640px) { .archive-move .modal__foot { flex-wrap: nowrap; } }

.move-browser__list:has(> p:only-child) { height: auto; min-height: 3.5rem; }
@media (max-width: 640px) {
    dialog.modal:has(.archive-move) { inset: auto 0 0; width: 100%; max-height: var(--app-vvh, 100dvh); border-radius: var(--r-xl) var(--r-xl) 0 0; }
}

.sidebar__nav .nav-group + .nav-group { margin-top: .45rem; }
.sidebar__nav summary.nav-group__label { display: flex; justify-content: space-between; align-items: center; min-height: 36px; padding: .35rem .75rem; list-style: none; cursor: pointer; }
.sidebar__nav summary.nav-group__label::-webkit-details-marker { display: none; }
.sidebar__nav .nav-group[open] > summary .icon { transform: rotate(-90deg); }
.sidebar__nav summary.nav-group__label:hover { color: var(--ink); background: var(--surface-2); border-radius: var(--r); }
@media (max-width: 1023px) { .sidebar__nav summary.nav-group__label { min-height: 44px; } }

.archive-favorite[aria-pressed="true"] { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-line); }
.archive-favorite-mark { display: inline-flex; vertical-align: middle; color: var(--warn); }
.pdf-reader { display: flex; flex-direction: column; height: 100dvh; margin: 0; background: var(--surface-2); }
.pdf-reader nav { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .35rem; padding: .5rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.pdf-reader input { width: 4rem; padding: .35rem; text-align: center; }
.pdf-reader #pdf-sheet { flex: 1; min-height: 0; overflow: auto; padding: .5rem; text-align: center; }
.pdf-reader canvas { height: auto; background: white; }
.pdf-reader pre { white-space: pre-wrap; text-align: start; padding: 1rem; font: inherit; }
.pdf-reader #status:not(:empty), .pdf-reader #failed { padding: .5rem; text-align: center; }
.doc-card__actions { border-top: 1px solid var(--line); padding-inline: .5rem; }

/* ==========================================================================
   الاجتماعات: القائمة، شاشة التسجيل، المحضر (الملخص والمهام والتفريغ).
   ========================================================================== */
.meeting-row__icon { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); }
.meeting-row .badge { flex: none; }
.meeting-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.meeting-meta > span { display: inline-flex; align-items: center; gap: 5px; }
.meeting-pending { align-items: center; }
.spinner { flex: none; width: 18px; height: 18px; border: 2px solid var(--line-strong); border-top-color: var(--brand); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.meeting-text p { line-height: 1.9; overflow-wrap: anywhere; }
.meeting-points { display: grid; gap: 10px; margin: 0; padding-inline-start: 40px; line-height: 1.8; }
.meeting-points li::marker { color: var(--brand); font-weight: 700; }
.meeting-task { align-items: flex-start; }
.meeting-task .list__main strong { white-space: normal; }
.meeting-task .list__main > span { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.meeting-task .list__main .meeting-task__desc { color: var(--ink-2); font-size: 14px; line-height: 1.7; }
.meeting-task .btn { flex: none; }
.meeting-audio { display: block; width: 100%; }
.transcript { display: grid; gap: 2px; margin: 0; padding-block: 10px; padding-inline: 12px; list-style: none; }
.transcript__line { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; padding: 8px; border-radius: var(--r); }
.transcript__line:hover { background: var(--surface-2); }
.transcript__time { align-self: start; min-width: 52px; min-height: 30px; padding: 4px 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--brand); font: inherit; font-size: 13px; cursor: pointer; }
.transcript__time:hover { border-color: var(--brand-line); background: var(--brand-soft); }
.transcript__body { min-width: 0; }
.transcript__body strong { font-size: 13px; color: var(--ink-2); }
.transcript__body p { line-height: 1.8; overflow-wrap: anywhere; }

.recorder { display: grid; justify-items: center; gap: 14px; padding: 32px 22px; text-align: center; }
.recorder__status { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 600; }
.recorder__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--faint); }
.recorder[data-state="recording"] .recorder__status { color: var(--bad); }
.recorder[data-state="recording"] .recorder__dot { background: var(--bad); animation: dictate-pulse 1.6s var(--ease) infinite; }
.recorder[data-state="paused"] .recorder__dot { background: var(--warn); }
.recorder__clock { font-size: 56px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.recorder__meter { width: min(280px, 100%); height: 8px; overflow: hidden; border-radius: 999px; background: var(--surface-3); }
.recorder__meter span { display: block; width: 100%; height: 100%; background: var(--ok); transform: scaleX(var(--level, 0)); transform-origin: right center; transition: transform .08s linear; }
.recorder__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.recorder .notice { width: 100%; text-align: start; }

@media (max-width: 760px) {
    .recorder__clock { font-size: 44px; }
    .recorder__actions { width: 100%; }
    .recorder__actions .btn { flex: 1 1 140px; }
    .meeting-task { flex-wrap: wrap; }
    .meeting-task .btn { width: 100%; justify-content: center; }
    .meeting-points { padding-inline-start: 28px; }
}
@media (prefers-reduced-motion: reduce) {
    .spinner, .recorder[data-state="recording"] .recorder__dot { animation: none; }
}

/* الاجتماعات المرئية في صفحة الاجتماعات: الجاري يبرز بنقطة حمراء نابضة. */
.room-row__icon { background: var(--info-soft); color: var(--info); }
.room-row.is-live .room-row__icon { background: var(--bad-soft); color: var(--bad); }
.room-row__main { color: inherit; text-decoration: none; }
.room-row__main:hover strong { color: var(--brand-strong); }
.room-row__live { display: inline-flex; align-items: center; gap: 5px; color: var(--bad); font-weight: 700; }
.room-row__live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.room-row .btn { flex: none; }
@media (max-width: 760px) {
    .room-row { flex-wrap: wrap; }
    .room-row .btn { margin-inline-start: 52px; }
}
