@font-face {
    font-family: 'Vazir';
    src: url('fonts/Vazirmatn-Regular.woff2') format('woff2');
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: 'Vazir';
    src: url('fonts/Vazirmatn-Medium.woff2') format('woff2');
    font-weight: 500;
    font-display: swap;
}
@font-face {
    font-family: 'Vazir';
    src: url('fonts/Vazirmatn-Bold.woff2') format('woff2');
    font-weight: 700;
    font-display: swap;
}

:root {
    /* =====================================================================
       Design tokens (DS-0) — world-class foundation.
       Spec: docs/DESIGN-SYSTEM.md §18. Non-breaking: legacy aliases kept.
       Layered neutrals (Linear/Vercel), lime brand + blue action accent,
       hairline borders over shadows, 4px grid, spring motion, Lucide icons.
       ===================================================================== */

    /* ===== LAYERED NEUTRALS (dark = default) ===== */
    --bg-app: #0e0f11;          /* deepest; under everything */
    --bg-surface: #171717;      /* main body (= legacy --bg) */
    --bg-raised: #1f1f1f;       /* sidebar/header/composer (= legacy --bg2) */
    --bg-card: #242424;         /* solid cards (= legacy --card-solid) */
    --bg-overlay: #2b2b2b;      /* over cards; ghost button (= legacy --surface-raised) */
    --bg-hover: #333333;        /* hover state */
    --bg-active: #3a3a3a;       /* active/pressed state */
    --card: rgba(255, 255, 255, 0.05);  /* translucent card fill (kept for existing rules) */

    /* ===== BORDERS — depth via hairline, not shadow (Linear technique) ===== */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.16);
    --border-accent: rgba(158, 209, 25, 0.50);
    --card-border: rgba(255, 255, 255, 0.13);   /* legacy alias (slightly stronger) */
    --track: rgba(255, 255, 255, 0.1);

    /* ===== TEXT — all WCAG AA+ on --bg-surface ===== */
    --text: #f5f6f7;
    --text-secondary: #b2b8be;
    --text-tertiary: #8b9098;
    --text-disabled: #5c6166;
    --on-accent: #0f1a00;       /* dark text on lime */
    --on-blue: #ffffff;         /* text on blue accent */
    --muted: #b2b2b2;           /* legacy alias of --text-secondary */
    --muted2: #8c8c8c;          /* legacy alias of --text-tertiary */

    /* ===== BRAND — lime = identity (the "یار/helper") ===== */
    --brand: #76b900;
    --brand-2: #9ed119;
    --brand-soft: #bde85a;
    --grad-brand: linear-gradient(135deg, #76b900 0%, #9ed119 100%);

    /* ===== CONSORTIUM accents (فاز ۰، docs/CONSORTIUM-UPGRADE-PLAN.md) ===== */
    --accent-portfolio: #a78bfa;    /* پرتفو/مایلستون/ریسک */
    --accent-interface: #22d3ee;    /* رابط‌ها (ICD) */
    --accent-consortium: #f472b6;   /* لایهٔ بین‌سازمانی (Gateway/Hub) */

    /* ===== ACCENT — blue = action (mentions, links, focus, read receipts) ===== */
    --accent: #3b82f6;
    --accent-soft: #60a5fa;
    --accent2: #9ed119;         /* legacy alias (brand-2) — kept for existing gradient rules */

    /* ===== SEMANTIC STATUS ===== */
    --status-done: #3ddc84;
    --status-doing: #fbbf24;
    --status-todo: #7a7a7a;
    --status-blocked: #f87171;
    --status-overdue: #ef4444;
    --danger: #f87171;
    --warning: #f59e0b;
    --success: #3ddc84;
    --info: #3b82f6;
    --rag-red: #f87171;
    --rag-amber: #fbbf24;
    --rag-green: #3ddc84;
    /* legacy aliases */
    --todo: #7a7a7a;
    --doing: #fbbf24;
    --done: #3ddc84;
    --progress-low: #f59e0b;

    /* ===== SENDER PALETTE (chat) — hash(uid) % 8, Telegram algorithm ===== */
    --c-sender-0: #ff6b6b;
    --c-sender-1: #ffb168;
    --c-sender-2: #f2c94c;
    --c-sender-3: #6ee7a8;
    --c-sender-4: #5fd3c4;
    --c-sender-5: #6ba8ff;
    --c-sender-6: #b084ff;
    --c-sender-7: #ff8fcb;

    /* ===== RADIUS — modern larger scale (Material 3 / iOS) ===== */
    --r-xs: 4px;
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 20px;
    --r-2xl: 28px;
    --r-pill: 999px;
    /* legacy aliases (existing rules use these) — map onto the new scale */
    --r: 20px;            /* legacy --r-lg-xl → keep 20 for detail-hero etc. */

    /* ===== SPACING (4px grid) ===== */
    --sp-0: 2px;
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-7: 32px;

    /* ===== TYPE SCALE (1.25 ratio, Vazirmatn) ===== */
    --fs-2xs: 11px;
    --fs-xs: 12px;
    --fs-sm: 13px;
    --fs-base: 15px;
    --fs-lg: 17px;
    --fs-xl: 20px;
    --fs-2xl: 24px;
    --fs-3xl: 30px;

    /* ===== ELEVATION — layered shadows reserved for true overlays ===== */
    --elev-0: none;
    --elev-1: 0 1px 2px rgba(0, 0, 0, 0.30);
    --elev-2: 0 4px 12px rgba(0, 0, 0, 0.35);
    --elev-3: 0 12px 32px rgba(0, 0, 0, 0.45);
    --elev-4: 0 24px 60px rgba(0, 0, 0, 0.55);
    --shadow: 0 14px 36px rgba(0, 0, 0, 0.55);   /* legacy alias of --elev-3/4 */
    --surface-raised: #2b2b2b;                   /* legacy alias of --bg-overlay */

    /* ===== MOTION — spring physics, short durations ===== */
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-in: cubic-bezier(0.4, 0, 1, 1);
    --dur-instant: 80ms;
    --dur-fast: 150ms;
    --dur-base: 200ms;
    --dur-slow: 300ms;
    --dur-spring: 400ms;

    /* ===== AVATARS ===== */
    --av-xs: 20px;
    --av-sm: 24px;
    --av-md: 32px;
    --av-lg: 44px;
    --av-xl: 52px;
    --av-2xl: 72px;

    /* ===== LAYOUT (responsive — DS-6 / D0 sets data-layout) ===== */
    --sidebar-w: 240px;
    --sidebar-w-collapsed: 56px;
    --detail-w: 360px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
    margin: 0; padding: 0;
    background: var(--bg-app);   /* DS-1: deepest layer shows at overscroll glow */
    color: var(--text);
    font-family: 'Vazir', system-ui, sans-serif;
    font-size: var(--fs-base);
    line-height: 1.7;
    overscroll-behavior: none;
    -webkit-user-select: none; user-select: none;
}
body {
    background:
        radial-gradient(1100px 560px at 92% -12%, rgba(118, 185, 0, 0.12), transparent 60%),
        var(--bg-surface);
    min-height: 100vh;
}
#app { padding: 0 16px 120px; max-width: 900px; margin: 0 auto; }

/* ---------- Header ---------- */
.appbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 12px;
    padding: calc(env(safe-area-inset-top, 0px) + 16px) 0 14px;
    margin-bottom: 6px;
    background: linear-gradient(180deg, var(--bg-surface) 55%, rgba(15,18,38,0.0));
}
.appbar .brand { display: flex; align-items: center; gap: 11px; flex: 1; min-width: 0; }
.appbar .logo {
    width: 42px; height: 42px; border-radius: var(--r-md); flex-shrink: 0;
    background: var(--grad-brand);
    display: grid; place-items: center; box-shadow: 0 6px 18px rgba(118,185,0,0.38);
}
.appbar h1 { font-size: var(--fs-xl); font-weight: 700; margin: 0; }
.appbar .sub { font-size: var(--fs-xs); color: var(--muted); margin-top: -2px; }
.iconbtn {
    width: 42px; height: 42px; border-radius: var(--r-md); border: 1px solid var(--border);
    background: var(--card); color: var(--text-secondary); display: grid; place-items: center;
    cursor: pointer; flex-shrink: 0; transition: background var(--dur-fast) var(--ease-out),
        border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out),
        transform var(--dur-instant) var(--ease-out);
}
.iconbtn:hover { background: var(--bg-hover); border-color: var(--border-strong); color: var(--text); }
.iconbtn:active { transform: scale(.92); background: var(--bg-active); }
.back-row .iconbtn { color: var(--text); }

/* ---------- Stat row ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 6px 0 18px; }
.stat {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-md);
    padding: 13px 12px; text-align: center;
}
.stat .num { font-size: var(--fs-2xl); font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat .lbl { font-size: var(--fs-xs); color: var(--muted); }
.stat.a .num { color: var(--brand-soft); }
.stat.b .num { color: var(--status-done); }
.stat.c .num { color: var(--status-doing); }

/* ---------- Section title ---------- */
.section-title { display: flex; align-items: center; gap: 8px; margin: var(--sp-5) 0 12px; }
.section-title h2 { font-size: var(--fs-base); font-weight: 700; margin: 0; }
.section-title .count { font-size: var(--fs-xs); color: var(--muted); background: var(--card);
    border: 1px solid var(--card-border); padding: 1px 9px; border-radius: 20px; }
.section-title .line { flex: 1; height: 1px; background: var(--card-border); }

/* ---------- Now-working list ---------- */
.now-list { display: flex; flex-direction: column; gap: 9px; }
.now-item {
    display: flex; align-items: center; gap: 11px; padding: 11px 13px;
    background: var(--card); border: 1px solid var(--card-border); border-radius: var(--r-md);
    border-right: 4px solid var(--doing);
}
.now-item .pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--doing);
    box-shadow: 0 0 0 0 rgba(255,176,46,0.6); animation: pulse 1.8s infinite; flex-shrink: 0; }
@keyframes pulse { 70% { box-shadow: 0 0 0 9px rgba(255,176,46,0); } 100% { box-shadow: 0 0 0 0 rgba(255,176,46,0); } }
.now-item .nm { font-weight: 500; }
.now-item .tx { color: var(--muted); font-size: var(--fs-sm); }
.empty { text-align: center; color: var(--muted2); padding: 26px 10px; font-size: var(--fs-sm); }

/* ---------- Project cards ---------- */
.proj-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 620px) { .proj-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 840px) { .proj-grid { grid-template-columns: repeat(3, 1fr); } }
.proj-card {
    position: relative; overflow: hidden; cursor: pointer;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-xl);
    padding: 16px; display: flex; gap: 14px; align-items: center;
    transition: transform var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out),
        border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.proj-card:active { transform: scale(.985); background: var(--bg-hover); }
@media (hover: hover) {
    .proj-card:hover { background: var(--bg-hover); border-color: var(--border-strong); box-shadow: var(--elev-1); transform: translateY(-1px); }
}
.proj-card .accent { position: absolute; inset: 0 auto 0 0; width: 5px; }
.proj-card .info { flex: 1; min-width: 0; }
.proj-card .info h3 { margin: 0 0 3px; font-size: var(--fs-lg); font-weight: 700;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj-card .info .d { color: var(--muted); font-size: var(--fs-sm); margin-bottom: 10px;
    display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.proj-card .meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.avatars { display: flex; flex-direction: row-reverse; }
.avatars .av { margin-right: -8px; border: 2px solid var(--card-solid); }
.avatars .more { background: var(--card-solid); color: var(--muted); }
.chip-mini { font-size: var(--fs-xs); color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }

/* ---------- Avatars ---------- */
.av { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
    font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0; }
.av.lg { width: 52px; height: 52px; font-size: 18px; }

/* ---------- Donut ---------- */
.donut { position: relative; flex-shrink: 0; }
.donut .pct { position: absolute; inset: 0; display: grid; place-items: center;
    font-weight: 700; font-size: 15px; line-height: 1; font-variant-numeric: tabular-nums; }
.donut.lg .pct { font-size: 26px; }

/* ---------- Project detail ---------- */
.detail-hero {
    background: var(--card); border: 1px solid var(--card-border); border-radius: var(--r);
    padding: 18px; display: flex; gap: 18px; align-items: center; margin-bottom: 8px;
}
.detail-hero .htext { flex: 1; min-width: 0; }
.detail-hero h2 { margin: 0 0 4px; font-size: var(--fs-xl); font-weight: 700; }
.detail-hero .hd { color: var(--muted); font-size: var(--fs-sm); margin-bottom: 12px; }
.breakdown { display: flex; gap: 8px; flex-wrap: wrap; }
.bk { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm);
    background: var(--card); border: 1px solid var(--card-border); padding: 4px 10px; border-radius: 20px; }
.dot { width: 9px; height: 9px; border-radius: 50%; }

/* member cards */
.mem-card {
    display: flex; align-items: center; gap: 13px; padding: 13px;
    background: var(--card); border: 1px solid var(--card-border); border-radius: var(--r-md); margin-bottom: var(--sp-2);
    cursor: pointer; transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), transform var(--dur-instant) var(--ease-out);
}
.mem-card:active { transform: scale(.99); background: rgba(255,255,255,0.08); }
.mem-card.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.mem-card .mtext { flex: 1; min-width: 0; }
.mem-card .mtext .mn { font-weight: 500; font-size: var(--fs-base); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mem-card .mtext .mr { color: var(--muted); font-size: var(--fs-xs); }
.bar { height: 7px; border-radius: 10px; background: var(--track); overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; border-radius: 10px; transition: width .5s ease; }
.mem-card .mstat { color: var(--muted); font-size: var(--fs-xs); margin-top: 5px; }

/* tasks */
.task {
    display: flex; align-items: center; gap: 11px; padding: 12px 13px;
    background: var(--card); border: 1px solid var(--card-border); border-radius: var(--r-md); margin-bottom: 9px;
}
.task .tt { flex: 1; min-width: 0; }
.task .tt .tn { font-weight: 500; font-size: var(--fs-base); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task.done .tt .tn { text-decoration: line-through; color: var(--muted); }
.task .tt .ts { font-size: var(--fs-xs); color: var(--muted); display: flex; gap: 8px; align-items: center; margin-top: 2px; flex-wrap: wrap; }
/* ===== D5.4: multi-select (Shift/Ctrl-click) + bulk-action bar ===== */
.task.ms-sel { border-color: var(--brand-soft); background: rgba(118, 185, 0, 0.10); }
.ms-bar {
    position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 22px); transform: translateX(-50%);
    z-index: 45; display: flex; align-items: center; gap: 12px; padding: 9px 14px; border-radius: var(--r-lg);
    background: var(--bg-overlay); border: 1px solid var(--border-strong); box-shadow: var(--elev-2);
}
.ms-bar .ms-count { font-size: var(--fs-sm); font-weight: 700; white-space: nowrap; }
.ms-bar .ms-acts { display: flex; gap: 6px; }
.status-chip {
    font-size: var(--fs-xs); font-weight: 700; padding: 7px 12px; border-radius: var(--r-pill); cursor: pointer;
    border: 1px solid transparent; white-space: nowrap;
    transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), transform var(--dur-instant) var(--ease-out);
    min-height: 34px; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
}
.status-chip:active { transform: scale(.93); }
.status-chip.todo { color: var(--muted); background: rgba(107,115,155,0.16); }
.status-chip.doing { color: var(--doing); background: rgba(255,176,46,0.16); }
.status-chip.done { color: var(--done); background: rgba(46,207,134,0.16); }
.weight-dots { display: inline-flex; gap: 2px; }
.weight-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted2); }
.weight-dots i.on { background: var(--accent2); }

.del-x { color: var(--muted2); width: 38px; height: 38px; display: grid; place-items: center;
    border-radius: 10px; cursor: pointer; flex-shrink: 0; }
.del-x:active { background: rgba(255,93,108,0.18); color: var(--danger); }

/* ---------- Buttons ---------- */
.btn {
    border: none; border-radius: var(--r-md); padding: 13px 16px; font-family: inherit; font-size: var(--fs-base);
    font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    transition: transform var(--dur-instant) var(--ease-out), background var(--dur-fast) var(--ease-out),
        box-shadow var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out); color: #fff;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--grad-brand); box-shadow: 0 8px 20px rgba(118,185,0,0.30); }
.btn.ghost { background: var(--bg-card); border: 1px solid var(--border); color: var(--text); }
.btn.block { width: 100%; }
.btn.danger { background: rgba(255,93,108,0.15); color: var(--danger); }
.row-btns { display: flex; gap: 10px; margin: 14px 0; }

/* ---------- FAB ---------- */
.fab {
    position: fixed; bottom: calc(env(safe-area-inset-bottom, 0px) + 22px); left: 22px; z-index: 30;
    width: 58px; height: 58px; border-radius: 19px; border: none;
    background: var(--grad-brand);
    box-shadow: var(--elev-3); cursor: pointer; display: grid; place-items: center;
    transition: transform var(--dur-fast) var(--ease-spring);
}
.fab:active { transform: scale(.9) rotate(90deg); }

/* ---------- Modal / bottom sheet ---------- */
.modal-bg {
    position: fixed; inset: 0; z-index: 50; background: rgba(5,7,18,0.6);
    backdrop-filter: blur(3px); display: flex; align-items: flex-end; justify-content: center;
    animation: fade var(--dur-base) var(--ease-out);
}
@keyframes fade { from { opacity: 0; } }
.sheet {
    width: 100%; max-width: 560px; background: var(--bg-raised);
    border-radius: 28px 28px 0 0; border: 1px solid var(--border); border-bottom: none;
    padding: 10px 18px calc(env(safe-area-inset-bottom, 0px) + 22px);
    max-height: 90vh; overflow-y: auto; animation: slideup var(--dur-base) var(--ease-spring);
}
@keyframes slideup { from { transform: translateY(100%); } }
.sheet .grip { width: 48px; height: 5px; border-radius: 10px; background: var(--border-strong); margin: 6px auto 14px; }
.sheet h3 { margin: 0 0 16px; font-size: var(--fs-lg); font-weight: 700; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: var(--fs-sm); color: var(--muted); margin-bottom: 7px; font-weight: 500; }
.field input, .field textarea, .field select {
    width: 100%; background: var(--bg-surface); border: 1px solid var(--border); color: var(--text);
    border-radius: var(--r-sm); padding: 13px 14px; font-family: inherit; font-size: var(--fs-base); outline: none;
    transition: border var(--dur-fast) var(--ease-out); -webkit-user-select: text; user-select: text;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--brand); }
.field textarea { resize: none; min-height: 64px; }
.color-row { display: flex; gap: 10px; flex-wrap: wrap; }
.color-dot { width: 34px; height: 34px; border-radius: 50%; cursor: pointer; border: 3px solid transparent; transition: transform var(--dur-fast) var(--ease-spring), border-color var(--dur-fast); }
.color-dot.sel { border-color: #fff; transform: scale(1.12); }
.seg { display: flex; gap: 8px; }
.seg .opt {
    flex: 1; text-align: center; padding: 11px; border-radius: var(--r-sm); cursor: pointer; font-weight: 700; font-size: var(--fs-sm);
    background: var(--bg-surface); border: 1px solid var(--border); color: var(--muted);
    transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.seg .opt.sel.todo { color: var(--muted); border-color: var(--todo); background: rgba(107,115,155,0.12); }
.seg .opt.sel.doing { color: var(--doing); border-color: var(--doing); background: rgba(255,176,46,0.12); }
.seg .opt.sel.done { color: var(--done); border-color: var(--done); background: rgba(46,207,134,0.12); }
.wsel { display: flex; gap: 8px; }
.wsel .wb { flex: 1; padding: 10px; text-align: center; border-radius: var(--r-sm); cursor: pointer;
    background: var(--bg-surface); border: 1px solid var(--border); color: var(--muted); font-weight: 700;
    transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out); }
.wsel .wb.sel { background: rgba(56,189,248,0.14); border-color: var(--accent2); color: var(--accent2); }

/* ---------- Toast ---------- */
.toast {
    position: fixed; bottom: 110px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: var(--bg-overlay); color: var(--text); padding: 11px 20px; border-radius: var(--r-md); font-size: var(--fs-sm);
    box-shadow: var(--elev-3); opacity: 0; pointer-events: none;
    transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-spring); z-index: 99;
    border: 1px solid var(--border);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.back-row { display: flex; align-items: center; gap: 8px; padding: calc(env(safe-area-inset-top,0px) + 14px) 0 10px; }
.back-row .t { font-size: 17px; font-weight: 700; flex: 1; }
.back-row .iconbtn { color: var(--text); }

.fade-in { animation: fadeIn var(--dur-slow) var(--ease-out); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } }

/* ---------- DS-2: skeleton loaders (shimmer) + list stagger ---------- */
.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-overlay) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer var(--dur-slow) infinite linear;
    border-radius: var(--r-sm);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
/* staggered list entrance: add .stagger to a parent, children fade-up with delay = index*30ms (capped 6) */
.stagger > * { opacity: 0; animation: fadeIn var(--dur-slow) var(--ease-out) forwards; }
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 30ms; }
.stagger > *:nth-child(3) { animation-delay: 60ms; }
.stagger > *:nth-child(4) { animation-delay: 90ms; }
.stagger > *:nth-child(5) { animation-delay: 120ms; }
.stagger > *:nth-child(6) { animation-delay: 150ms; }
.stagger > *:nth-child(n+7) { animation-delay: 180ms; }

textarea.backup-box { width:100%; height:140px; font-family: monospace; font-size: var(--fs-xs); direction:ltr;
    background: var(--bg); color: var(--muted); border:1px solid var(--card-border); border-radius: var(--r-sm); padding:10px;
    -webkit-user-select: text; user-select: text; }

/* ---------- Server mode: login ---------- */
.login-wrap { min-height: 88vh; display: flex; align-items: center; justify-content: center; padding: 20px 0; }
.login-card { width: 100%; max-width: 380px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--r-xl); padding: 26px 22px; box-shadow: var(--elev-3); }
.login-card h2 { margin: 14px 0 18px; font-size: var(--fs-xl); text-align: center; }
.login-card .logo.lg { width: 58px; height: 58px; border-radius: 17px; margin: 0 auto 4px;
    display: grid; place-items: center; background: var(--grad-brand);
    box-shadow: 0 6px 18px rgba(118,185,0,0.40); }

/* allow typing/selection inside inputs everywhere */
input, textarea, select { -webkit-user-select: text; user-select: text; }

/* ---------- Jalali date picker ---------- */
.jdate { display: flex; gap: 8px; }
.jdate select { flex: 1; }
.field .jdate select {
    width: 100%; padding: 11px 8px; border-radius: var(--r-sm); background: var(--bg);
    color: var(--text); border: 1px solid var(--card-border); font-family: inherit; font-size: var(--fs-base);
}

/* ---------- duration input ---------- */
.dur-row { display: flex; gap: 12px; }
.dur { flex: 1; display: flex; align-items: center; gap: 8px; }
.dur input, .dur select {
    flex: 1; padding: 11px; border-radius: var(--r-sm); background: var(--bg); color: var(--text);
    border: 1px solid var(--card-border); font-family: inherit; font-size: var(--fs-base); text-align: center;
}
.dur span { color: var(--muted); font-size: var(--fs-sm); }

/* ---------- reports ---------- */
.rep-box { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--r);
    padding: 16px; margin: 14px 0; }
.rep-total { background: rgba(56,189,248,0.12); border: 1px solid rgba(56,189,248,0.3); color: var(--text);
    border-radius: var(--r-md); padding: 12px 16px; margin: 10px 0; font-size: var(--fs-base); }
.rep-total b { color: var(--accent2); font-size: var(--fs-lg); font-variant-numeric: tabular-nums; }

/* ---------- membership checklist ---------- */
.check-row { display: flex; align-items: center; gap: 10px; padding: 9px 4px; cursor: pointer;
    border-bottom: 1px solid var(--card-border); }
.check-row input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }
.check-row .av { flex: 0 0 auto; }

/* ---------- Motion: reduced-motion + sheet exit ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .now-item .pulse { animation: none; }
}
.modal-bg.closing { animation: fade var(--dur-fast) var(--ease-in) reverse forwards; }
.sheet.closing { animation: slideup var(--dur-base) var(--ease-in) reverse forwards; }

/* ---------- UX P3: draggable sheet (half ⇄ full, Linear side-panel analog) ---------- */
.drag-sheet { max-height: none; }
.drag-sheet.half { height: 60vh; }
.drag-sheet.full { height: 94vh; }
.drag-sheet.half, .drag-sheet.full {
    transition: height var(--dur-base) var(--ease-spring);
    overflow-y: auto;
}
.drag-sheet.dragging { transition: none; }   /* follow finger 1:1 while dragging */
.drag-grip {
    display: flex; align-items: center; justify-content: center;
    height: 28px; cursor: grab; touch-action: none; user-select: none;
}
.drag-grip:active { cursor: grabbing; }
.drag-grip i { width: 44px; height: 5px; border-radius: 10px; background: var(--border-strong); display: block; }
@media (prefers-reduced-motion: reduce) { .drag-sheet.half, .drag-sheet.full { transition: none; } }

/* task detail (P3) — comment thread + activity timeline inside the sheet */
.td-section { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--border); }
.td-section-h { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.td-section-h h3 { margin: 0; font-size: var(--fs-base); font-weight: 700; color: var(--text-secondary); }
.td-section-h .count { font-size: var(--fs-2xs); color: var(--text-tertiary); background: var(--bg-overlay); padding: 1px 7px; border-radius: var(--r-pill); }
.td-comment { display: flex; gap: 9px; margin-bottom: 10px; }
.td-comment .tdc-body { flex: 1; min-width: 0; }
.td-comment .tdc-name { font-size: var(--fs-sm); font-weight: 700; }
.td-comment .tdc-text { font-size: var(--fs-sm); color: var(--text); line-height: 1.6; word-break: break-word; background: var(--bg-overlay); padding: 8px 12px; border-radius: var(--r-md); margin-top: 2px; }
.td-comment .tdc-time { font-size: var(--fs-2xs); color: var(--text-tertiary); margin-top: 3px; }
.td-actrow { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: var(--fs-2xs); color: var(--text-tertiary); }
.td-actrow .tda-ic { width: 16px; flex: none; text-align: center; opacity: .7; }
.td-actrow .tda-who { color: var(--text-secondary); font-weight: 600; }
.td-composer { display: flex; gap: 8px; align-items: flex-end; margin-top: 8px; }
.td-composer textarea { flex: 1; min-height: 38px; max-height: 100px; resize: none; padding: 9px 12px; border-radius: var(--r-md); background: var(--bg-surface); border: 1px solid var(--border); color: var(--text); font: inherit; font-size: var(--fs-sm); }
.td-composer textarea:focus { outline: none; border-color: var(--brand); }


/* ---------- Focus visibility (keyboard / switch access) — brand ring ---------- */
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: inherit; }
.field input:focus-visible, .field textarea:focus-visible, .field select:focus-visible {
    box-shadow: 0 0 0 3px rgba(118,185,0,0.30);
}

/* Let content text be selected/copied; chrome (buttons/cards) stays non-selectable */
.tn, .mn, .nm, .tx, .hd, .d, .mr, .mstat, .ts, .bk, .empty {
    -webkit-user-select: text; user-select: text;
}

/* =========================================================
   CHAT (Phase 2)
   ========================================================= */
/* unread badge on the appbar chat icon */
.chat-btn { position: relative; }
.chat-badge {
    position: absolute; top: 2px; inset-inline-end: 2px; min-width: 16px; height: 16px;
    padding: 0 4px; border-radius: 9px; background: var(--danger); color: var(--bg-app);
    font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
    box-shadow: 0 0 0 2px var(--bg); display: none;
}

/* rooms list */
.chat-list { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.chat-row {
    display: flex; align-items: center; gap: 11px; padding: 11px 12px;
    border-radius: var(--r-md); cursor: pointer; transition: background .15s;
}
.chat-row:active { background: var(--card); }
.chat-ava {
    width: 44px; height: 44px; flex: none; border-radius: 50%; background: var(--surface-raised);
    display: grid; place-items: center; font-size: 20px;
}
.chat-meta { flex: 1; min-width: 0; }
.chat-name { font-weight: 600; font-size: var(--fs-base); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-prev { font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.chat-side { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex: none; }
.chat-when { font-size: 11px; color: var(--muted2); }
.chat-row-more { background: none; border: none; color: var(--muted2); font-size: 18px; line-height: 1; cursor: pointer; padding: 2px 4px; border-radius: 6px; }
.chat-row-more:active { background: var(--card); }
.chat-unread { min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; background: var(--accent); color: var(--bg-app); font-size: 11px; font-weight: 700; line-height: 19px; text-align: center; }

/* conversation — fixed full-screen, below modals (z 50), above FAB (z 30) */
.chat-room { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; background: var(--bg); }
.chat-head {
    display: flex; align-items: center; gap: 8px; padding: 10px 10px;
    padding-top: calc(env(safe-area-inset-top, 0px) + 10px);
    background: var(--bg2); border-bottom: 1px solid var(--card-border); flex: none;
}
.chat-htitle { flex: 1; min-width: 0; font-weight: 700; font-size: var(--fs-lg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 7px; }
.chat-msg { display: flex; flex-direction: column; max-width: 82%; }
.chat-msg.mine { align-self: flex-start; align-items: flex-start; }     /* RTL: my messages on the start (right) */
.chat-msg.theirs { align-self: flex-end; align-items: flex-end; }
.chat-sender { font-size: 11px; color: var(--accent-soft); margin: 0 6px 2px; font-weight: 600; }
.chat-bubble {
    position: relative; padding: 8px 12px 7px; border-radius: 18px; font-size: var(--fs-base);
    line-height: 1.55; color: var(--text); word-break: break-word;
    background: var(--bg-overlay);
    -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;   /* long-press opens the action menu instead of native selection */
}
/* DS-4: tailless bubbles (Telegram 2022 / WhatsApp 2025-26 direction).
   Group corners are asymmetric via logical properties so RTL auto-mirrors.
   g-single = all 18px; g-first = bottom-edge corner shrinks; g-mid = both;
   g-last = top-edge corner shrinks. */
.chat-msg.g-first .chat-bubble { border-end-start-radius: 6px; border-end-end-radius: 6px; }
.chat-msg.g-mid   .chat-bubble { border-block-end-radius: 6px; }
.chat-msg.g-last  .chat-bubble { border-start-start-radius: 6px; border-start-end-radius: 6px; }
.chat-msg.mine .chat-bubble { background: var(--brand); }
.chat-msg.pending .chat-bubble { opacity: .65; }
.chat-msg.failed .chat-bubble { background: rgba(255,93,108,.18); border: 1px solid var(--danger); }
.chat-time { display: inline-block; margin-inline-start: 8px; font-size: 10px; color: var(--muted2); vertical-align: bottom; }
.chat-msg.mine .chat-time { color: rgba(255,255,255,.7); }
.chat-fail { display: inline-block; margin-inline-start: 8px; font-size: 11px; color: var(--danger); cursor: pointer; font-weight: 600; }
.chat-rcpt { display: inline-block; margin-inline-start: 4px; font-size: 11px; font-weight: 700; vertical-align: bottom; color: rgba(0,0,0,.4); letter-spacing: -2px; }
.chat-rcpt.seen { color: var(--accent); }   /* DS-4: seen = blue action accent (was #1565ff hardcoded) */
.chat-deleted { font-style: italic; color: var(--muted2); }
/* reply quote inside a bubble */
.chat-quote { display: block; margin: -1px 0 5px; padding: 4px 8px; border-inline-start: 3px solid var(--accent); border-radius: 6px; background: rgba(0,0,0,.16); font-size: 12px; line-height: 1.4; cursor: pointer; max-width: 100%; }
.chat-msg.mine .chat-quote { background: rgba(0,0,0,.13); border-inline-start-color: rgba(0,0,0,.4); }
.chat-quote-who { display: block; font-weight: 700; color: var(--accent); font-size: 11.5px; }
.chat-msg.mine .chat-quote-who { color: rgba(0,0,0,.7); }
.chat-quote-text { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-msg.mine .chat-quote-text { color: rgba(0,0,0,.6); }
.chat-quote-missing { color: var(--muted2); font-style: italic; }
.chat-edited { display: inline-block; margin-inline-start: 8px; font-size: 10px; color: var(--muted2); font-style: italic; }
.chat-msg.mine .chat-edited { color: rgba(0,0,0,.5); }
.chat-flash { animation: chatFlash 1.2s ease; }
@keyframes chatFlash { 0%,100% { background: transparent; } 25% { background: rgba(142,208,17,.18); } }
/* reply/edit context banner above the composer */
.chat-ctxbanner { padding: 0 10px; }
.ctx-bar { display: flex; align-items: center; gap: 9px; padding: 7px 10px; background: var(--surface-raised); border-inline-start: 3px solid var(--accent); border-radius: 9px; margin-bottom: 6px; }
.ctx-ic { font-size: 15px; color: var(--accent); }
.ctx-body { flex: 1; min-width: 0; }
.ctx-title { font-size: 12.5px; font-weight: 700; color: var(--accent); }
.ctx-snip { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctx-x { background: none; border: none; color: var(--muted); font-size: 16px; cursor: pointer; padding: 2px 6px; line-height: 1; }
.chat-composer {
    display: flex; align-items: flex-end; gap: 8px; padding: 9px 11px;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 9px);
    background: var(--bg2); border-top: 1px solid var(--card-border); flex: none;
}
.chat-composer textarea {
    flex: 1; min-width: 0; min-height: 42px; max-height: 144px; padding: 9px 15px; border-radius: 21px;
    background: var(--card-solid); border: 1px solid var(--card-border); color: var(--text);
    font-family: inherit; font-size: var(--fs-base); line-height: 1.5;   /* multi-line composer: paste keeps newlines (single-line <input> truncated them) */
    resize: none; overflow-y: auto;
}
.chat-composer textarea:focus { outline: none; border-color: var(--accent); }
.chat-send {
    width: 42px; height: 42px; flex: none; border: none; border-radius: 50%;
    background: var(--accent); color: #fff; display: grid; place-items: center; cursor: pointer;
}
.chat-send:active { transform: scale(.92); }
.chat-send svg { transform: scaleX(-1); }   /* point the paper-plane toward the start in RTL */
.chat-typing { padding: 2px 16px 4px; font-size: 12px; color: var(--accent-soft); background: var(--bg); flex: none; }
.chat-picklist { max-height: 50vh; overflow-y: auto; }
/* media attachments */
.chat-attach { width: 40px; height: 42px; flex: none; border: none; background: transparent; color: #c2c2c2; display: grid; place-items: center; cursor: pointer; }
.chat-attach:active { transform: scale(.9); }
.chat-img { max-width: 220px; max-height: 280px; min-height: 56px; border-radius: 12px; display: block; cursor: pointer; background: var(--surface-raised); object-fit: cover; }
.chat-cap { margin-top: 5px; }
.chat-file { display: flex; align-items: center; gap: 10px; min-width: 170px; cursor: pointer; padding: 2px 0; }
.cf-ic { font-size: 26px; flex: none; }
.cf-meta { display: flex; flex-direction: column; min-width: 0; }
.cf-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 190px; }
.cf-size { font-size: 11px; color: var(--muted2); margin-top: 1px; }
.chat-lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.92); display: grid; place-items: center; padding: 16px; }
.chat-lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
/* voice messages (P3.6): play button + amplitude waveform + duration; colors inherit from the bubble (white on mine) */
.chat-voice { display: flex; align-items: center; gap: 9px; min-width: 172px; padding: 2px 0; }
.cv-play { width: 34px; height: 34px; flex: none; border: none; border-radius: 50%; background: rgba(127,127,127,.20); color: currentColor; font-size: 13px; line-height: 1; display: grid; place-items: center; cursor: pointer; }
.chat-msg.mine .cv-play { background: rgba(255,255,255,.22); }
.cv-play:active { transform: scale(.92); }
.cv-wave { flex: 1; display: flex; align-items: center; gap: 2px; height: 28px; min-width: 92px; }
.cv-wave span { flex: 1; min-width: 2px; border-radius: 2px; background: currentColor; opacity: .5; }
.cv-dur { flex: none; font-size: 11px; color: var(--muted2); font-variant-numeric: tabular-nums; }
.chat-msg.mine .cv-dur { color: rgba(255,255,255,.8); }
/* recording bar: swapped into the composer while a voice note is being captured */
.voice-rec { flex: 1; display: flex; align-items: center; gap: 9px; min-width: 0; height: 42px; padding: 0 15px; border-radius: 21px; background: var(--card-solid); border: 1px solid var(--card-border); }
.voice-dot { width: 11px; height: 11px; flex: none; border-radius: 50%; background: var(--danger); animation: vrecpulse 1s ease-in-out infinite; }
.voice-time { flex: none; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.voice-hint { flex: 1; min-width: 0; font-size: 12px; color: var(--muted2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cv-cancel { color: var(--danger) !important; }
@keyframes vrecpulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
/* avatars: the <img> fills the existing .av / .chat-ava circle */
.av { overflow: hidden; }
.chat-ava { overflow: hidden; }
.av-img, .av img, .chat-ava img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
/* audit log (admin) */
.audit-list { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.audit-row { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--r-md); padding: 11px 13px; }
.au-act { font-weight: 600; font-size: var(--fs-sm); }
.au-meta { font-size: 12px; color: var(--muted); margin-top: 2px; word-break: break-word; }
.au-time { font-size: 11px; color: var(--muted2); margin-top: 4px; direction: ltr; text-align: start; }

/* ===== bottom tab bar — primary navigation (mobile) ===== */
.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
    display: flex; justify-content: space-around; align-items: stretch;
    padding: 7px 6px calc(env(safe-area-inset-bottom, 0px) + 8px);
    /* solid (not backdrop-filter) + own compositor layer: a translucent/blurred fixed bar
       re-rasterized on navigation caused a one-frame vertical jump on some WebViews */
    background: var(--bg-raised); border-top: 1px solid var(--border);
    max-width: 900px; margin: 0 auto; transform: translateZ(0);
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px 0 3px; color: var(--text-tertiary); position: relative; cursor: pointer;
    transition: color var(--dur-fast) var(--ease-out); }
.tab svg { width: 23px; height: 23px; }
.tab .tl { font-size: 10.5px; font-weight: 600; }
.tab:active { transform: scale(.94); }
.tab.active { color: var(--brand-soft); }
.tab.active::before { content: ""; position: absolute; top: 0; width: 26px; height: 3px;
    border-radius: 0 0 4px 4px; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.tab .dot { position: absolute; top: 3px; right: 50%; margin-right: 7px; min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 9px; background: var(--danger); color: var(--bg-app); font-size: 10px; font-weight: 700;
    display: grid; place-items: center; border: 2px solid var(--bg2); }
.fab.lifted { bottom: calc(env(safe-area-inset-bottom, 0px) + 80px); }

/* ===== profile tab ===== */
.profile-card { display: flex; align-items: center; gap: 13px; background: var(--card-solid);
    border: 1px solid var(--card-border); border-radius: var(--r-md); padding: 14px; margin: 6px 0 4px; }
.profile-card .av { width: 56px; height: 56px; font-size: 19px; }
.profile-card .pc-info { flex: 1; min-width: 0; }
.profile-card .pc-name { font-weight: 700; font-size: var(--fs-lg); }
.profile-card .pc-role { color: var(--muted); font-size: var(--fs-sm); }
.menu-list { display: flex; flex-direction: column; gap: 8px; }
.menu-row { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--card-border);
    border-radius: var(--r-sm); padding: 12px 14px; cursor: pointer;
    transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), transform var(--dur-instant) var(--ease-out); }
.menu-row:active { transform: scale(.99); background: rgba(255,255,255,0.09); }
.menu-row .mr-ic { font-size: 18px; flex: none; }
.menu-row .mr-label { flex: 1; font-weight: 500; }
.menu-row .mr-chev { color: var(--muted2); font-size: 20px; transform: scaleX(-1); }

/* ===== UX P1: Inbox (Linear-style actionable notifications) ===== */
.empty-icn { color: var(--text-tertiary); opacity: .5; margin-bottom: 8px; }
.inbox-row {
    display: flex; align-items: center; gap: 12px; padding: 13px 14px;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-md); margin-bottom: 8px;
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), transform var(--dur-instant) var(--ease-out);
}
.inbox-row:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.inbox-row:active { transform: scale(.99); }
.inbox-row.unread { border-inline-start: 3px solid var(--brand); background: rgba(118,185,0,0.04); }
.inbox-dot {
    width: 32px; height: 32px; flex: none; border-radius: var(--r-pill);
    display: grid; place-items: center;
    background: var(--bg-overlay); color: var(--text-secondary);
}
.inbox-dot.bad { background: rgba(248,113,113,0.16); color: var(--danger); }
.inbox-dot.warn { background: rgba(245,158,11,0.16); color: var(--warning); }
.inbox-dot.accent { background: rgba(118,185,0,0.16); color: var(--brand-soft); }
.inbox-dot.info { background: rgba(59,130,246,0.16); color: var(--accent-soft); }
.inbox-body { flex: 1; min-width: 0; }
.inbox-text { font-weight: 500; font-size: var(--fs-base); color: var(--text); line-height: 1.5; }
.inbox-row:not(.unread) .inbox-text { color: var(--text-secondary); font-weight: 400; }
.inbox-meta { font-size: var(--fs-2xs); color: var(--text-tertiary); margin-top: 3px; }
.inbox-kind { font-weight: 600; }
.inbox-kind.bad { color: var(--danger); }
.inbox-kind.warn { color: var(--warning); }
.inbox-kind.accent { color: var(--brand-soft); }
.inbox-kind.info { color: var(--accent-soft); }
.inbox-kind.muted { color: var(--text-tertiary); }

/* ===== Critical Path (CPM) view ===== */
.cpm-bottleneck { background: rgba(255,93,108,.12); border: 1px solid var(--danger); border-radius: var(--r-md);
    padding: 13px 15px; margin: 10px 0 4px; }
.cpm-bottleneck.done { background: rgba(46,207,134,.12); border-color: var(--done); }
.cpm-bn-head { font-weight: 800; color: var(--danger); font-size: var(--fs-base); }
.cpm-bn-extra { font-weight: 500; color: var(--muted); font-size: var(--fs-xs); }
.cpm-bn-task { margin-top: 6px; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cpm-bn-who { margin-top: 7px; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: var(--fs-sm); }
.cpm-bn-who .av { width: 26px; height: 26px; font-size: 11px; }

.cpm-chain { display: flex; flex-direction: column; align-items: stretch; }
.cpm-node { display: flex; gap: 11px; align-items: stretch; background: var(--card); border: 1px solid var(--card-border);
    border-radius: var(--r-sm); padding: 10px 12px; border-right: 4px solid var(--accent); }
.cpm-node.done { opacity: .62; border-right-color: var(--done); }
.cpm-node.bottleneck { border-color: var(--danger); border-right-color: var(--danger); background: rgba(255,93,108,.10);
    box-shadow: 0 0 0 1px var(--danger) inset; }
.cpm-days { flex: none; width: 62px; font-size: 11px; color: var(--muted2); display: flex; flex-direction: column;
    align-items: center; justify-content: center; font-variant-numeric: tabular-nums; line-height: 1.3; }
.cpm-days span { opacity: .6; }
.cpm-body { flex: 1; min-width: 0; }
.cpm-title { font-weight: 700; }
.cpm-meta { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-top: 4px; }
.cpm-dur { font-size: var(--fs-xs); color: var(--accent-soft); background: var(--card); border: 1px solid var(--card-border);
    padding: 1px 8px; border-radius: 20px; }
.cpm-who { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: var(--fs-sm); }
.cpm-who .av { width: 24px; height: 24px; font-size: 10px; }
.cpm-noone { color: var(--danger); font-size: var(--fs-sm); }
.cpm-conn { width: 2px; height: 14px; background: var(--card-border); margin: 2px 0 2px 31px; align-self: flex-start; }
.status-chip.sm { padding: 0 8px; font-size: 10px; }

.cpm-res { display: flex; flex-direction: column; gap: 9px; }
.cpm-resrow { display: grid; grid-template-columns: 1fr; gap: 5px; background: var(--card); border: 1px solid var(--card-border);
    border-radius: var(--r-sm); padding: 9px 12px; }
.cpm-res-who { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.cpm-res-who .av { width: 26px; height: 26px; font-size: 11px; }
.cpm-spof { font-size: 10px; font-weight: 700; color: var(--bg-app); background: var(--danger); padding: 1px 7px; border-radius: 20px; }
.cpm-res-bar { height: 7px; border-radius: 4px; background: var(--track); overflow: hidden; }
.cpm-res-bar > i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg,var(--accent),var(--accent2)); }
.cpm-res-num { font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
/* task-sheet predecessor picker (CPM dependency entry) */
.dep-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.dep-chip { padding: 6px 12px; border: 1px solid var(--card-border); border-radius: var(--r-pill); background: var(--card);
    color: var(--muted); cursor: pointer; font-size: var(--fs-sm);
    transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), transform var(--dur-instant) var(--ease-out); }
.dep-chip.sel { background: var(--brand); color: var(--on-accent); border-color: var(--brand); }
.dep-chip:active { transform: scale(.95); }

/* ===== Critical-path Gantt ===== */
.gantt-legend { display: flex; gap: 14px; justify-content: flex-end; margin: 2px 0 8px; font-size: var(--fs-xs); color: var(--muted); }
.gantt-legend .lg { display: inline-flex; align-items: center; }
.gantt-legend .lg::before { content: ''; display: inline-block; width: 13px; height: 9px; border-radius: 2px; margin-inline-end: 5px; }
.gantt-legend .lg.crit::before { background: var(--danger); }
.gantt-legend .lg.slack::before { background: repeating-linear-gradient(90deg, var(--muted2) 0 3px, transparent 3px 6px); }
.gantt-legend .lg.done::before { background: var(--done); opacity: .5; }
.gantt { direction: ltr; background: var(--card); border: 1px solid var(--card-border); border-radius: var(--r-md); padding: 8px 10px 10px; overflow: hidden; }
.gantt-ruler { display: flex; height: 16px; margin-bottom: 4px; }
.gantt-ruler .grow-track { position: relative; }
.gtick { position: absolute; top: 0; transform: translateX(-50%); font-size: 9px; color: var(--muted2); font-variant-numeric: tabular-nums; }
.gantt-rows { position: relative; }
.gantt-row { display: flex; align-items: center; height: 44px; }
.grow-label { width: 104px; flex: none; display: flex; align-items: center; gap: 6px; direction: rtl; padding-inline-end: 8px; overflow: hidden; }
.grow-label .av { width: 20px; height: 20px; font-size: 9px; }
.grow-title { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grow-title.crit { color: var(--accent-soft); font-weight: 600; }
.grow-track { position: relative; flex: 1; height: 100%; }
.gbar { position: absolute; top: 50%; transform: translateY(-50%); height: 22px; min-width: 16px; border-radius: 6px;
    background: var(--surface-raised); display: flex; align-items: center; justify-content: center; z-index: 2; box-shadow: 0 1px 3px rgba(0,0,0,.35); }
.gbar.crit { background: linear-gradient(180deg, #ff8088, var(--danger)); }
.gbar.done { opacity: .42; }
.gbar.bn { outline: 2px solid var(--danger); outline-offset: 1px; animation: gbnpulse 1.3s ease-in-out infinite; }
@keyframes gbnpulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(248,113,113,.55); } 50% { box-shadow: 0 0 0 6px rgba(248,113,113,0); } }
.gbar-lbl { font-size: 9px; color: #fff; opacity: .92; font-variant-numeric: tabular-nums; }
.gslack { position: absolute; top: 50%; transform: translateY(-50%); height: 10px; border-radius: 4px; z-index: 1; opacity: .5;
    background: repeating-linear-gradient(90deg, var(--muted2) 0 3px, transparent 3px 6px); }
.gms { position: absolute; top: 50%; width: 14px; height: 14px; transform: translate(-50%, -50%) rotate(45deg); background: var(--doing); z-index: 2; border-radius: 2px; }
.gms.crit { background: var(--danger); }
.gantt-arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; overflow: visible; }

/* ===== Brand lime as background → dark foreground (the "یار" identity, AA 14:1) ===== */
.btn.primary { color: var(--on-accent); box-shadow: 0 8px 20px rgba(118,185,0,0.30); }
.fab { box-shadow: var(--elev-3); }
.fab svg path { stroke: var(--on-accent); }
.appbar .logo, .login-card .logo.lg { box-shadow: 0 6px 18px rgba(118,185,0,0.38); }
.appbar .logo svg path, .login-card .logo.lg svg path { stroke: var(--on-accent); }
.chat-unread, .chat-send, .dep-chip.sel { color: var(--on-accent); }
.chat-msg.mine .chat-bubble { color: var(--on-accent); }          /* cascades to the voice waveform (currentColor) too */
.chat-msg.mine .chat-sender { color: rgba(0,0,0,.6); }
.chat-msg.mine .chat-time { color: rgba(0,0,0,.55); }
.chat-msg.mine .cv-dur { color: rgba(0,0,0,.6); }
.chat-msg.mine .cv-play { background: rgba(0,0,0,.16); }

/* ============================================================
   پروژه‌یار — برگه‌های جدید: اشراف، حقوق، هرکس‌کجا، بلاکر، تایمر
   ============================================================ */
:root { --bad: #f87171; --warn: #fbbf24; --ok: #3ddc84; }

/* quick destinations on the manager home */
.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(74px, 1fr)); gap: 10px; margin: 6px 0 14px; }
.quick { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 14px 6px;
    border: 1px solid var(--card-border); border-radius: var(--r-md); background: var(--card);
    color: var(--text); cursor: pointer; transition: transform .12s, border-color .2s, background .2s; text-align: center; }
.quick:active { transform: scale(.96); }
.quick .qi { font-size: 22px; line-height: 1; }
.quick .ql { font-weight: 700; font-size: 13px; }
.quick .qs { font-size: 10.5px; color: var(--muted2); }
.q-watch { background: linear-gradient(160deg, rgba(248,113,113,.14), var(--card)); }
.q-board { background: linear-gradient(160deg, rgba(118,185,0,.14), var(--card)); }
.q-pay   { background: linear-gradient(160deg, rgba(251,191,36,.14), var(--card)); }

/* exception card (oversight headline) */
.ex-card { display: flex; align-items: stretch; gap: 10px; background: var(--card); border: 1px solid var(--card-border);
    border-radius: var(--r-md); padding: 10px 12px 10px 10px; margin-bottom: 8px; cursor: pointer; transition: border-color .2s, transform .1s; }
.ex-card:active { transform: scale(.99); }
.ex-side { width: 4px; border-radius: 4px; flex: none; }
.ex-body { flex: 1; min-width: 0; }
.ex-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ex-title { font-weight: 700; font-size: 14px; }
.ex-sub { font-size: 12px; color: var(--muted); margin: 1px 0 6px; }
.rchips { display: flex; flex-wrap: wrap; gap: 5px; }
.rchip { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; white-space: nowrap;
    background: rgba(255,255,255,.06); border: 1px solid var(--card-border); }
.rchip.bad  { color: var(--bad);  border-color: rgba(248,113,113,.4); background: rgba(248,113,113,.1); }
.rchip.warn { color: var(--warn); border-color: rgba(251,191,36,.4); background: rgba(251,191,36,.1); }
.rchip.info { color: var(--accent2); border-color: rgba(118,185,0,.4); background: rgba(118,185,0,.1); }
.disc-tag { font-size: 10.5px; color: var(--muted); padding: 2px 7px; border-radius: 999px; background: rgba(255,255,255,.05); border: 1px solid var(--card-border); }

/* project RAG roll-up */
.rag-strip { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.rag-card { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--r-md); padding: 10px 12px; cursor: pointer; }
.rag-top { display: flex; align-items: center; gap: 7px; }
.rag-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.rag-name { font-weight: 700; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rag-pct { font-size: 11.5px; color: var(--muted); margin: 2px 0 6px; }
.rag-counts { display: flex; flex-wrap: wrap; gap: 5px; }
.rag-counts .mini { font-size: 10.5px; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: rgba(255,255,255,.06); }
.mini.bad { color: var(--bad); } .mini.warn { color: var(--warn); } .mini.ok { color: var(--ok); }
.rag-drift { margin-top: 6px; font-size: 11px; font-weight: 600; }
.rag-drift.neg { color: var(--bad); } .rag-drift.pos { color: var(--ok); }

/* who's-on-what board */
.who-card { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--card-border);
    border-radius: var(--r-md); padding: 10px 12px; margin-bottom: 8px; }
.who-body { flex: 1; min-width: 0; }
.who-top { display: flex; align-items: center; gap: 8px; }
.who-name { font-weight: 700; font-size: 14px; }
.who-task { font-size: 13px; margin: 3px 0; display: flex; align-items: center; gap: 6px; }
.who-task.idle, .who-task.muted { color: var(--muted2); font-style: italic; }
.who-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.who-proj { color: var(--muted); font-size: 12px; }
.who-meta { font-size: 11.5px; color: var(--muted2); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* earnings widget (member) */
.earn-card { display: flex; align-items: center; justify-content: space-between; gap: 12px;
    background: linear-gradient(150deg, rgba(118,185,0,.16), var(--card)); border: 1px solid rgba(118,185,0,.3);
    border-radius: var(--r-md); padding: 14px 16px; margin: 4px 0 10px; }
.earn-cap { font-size: 12px; color: var(--muted); }
.earn-amt { font-size: 22px; font-weight: 800; color: var(--accent2); }
.earn-r { font-size: 12.5px; color: var(--muted); text-align: left; }

/* payroll */
.pay-note { font-size: 12px; color: var(--muted); margin: 0 2px 10px; }
.pay-card { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--r-md); padding: 11px 13px; margin-bottom: 8px; }
.pay-head { display: flex; align-items: center; gap: 8px; }
.pay-name { font-weight: 700; font-size: 14px; }
.pay-math { font-size: 12.5px; color: var(--muted); margin: 4px 0; direction: rtl; }
.pay-math b { color: var(--text); } .pay-final { color: var(--accent2); font-weight: 700; }
.pay-amount { font-size: 18px; font-weight: 800; color: var(--accent2); }
.pay-total { display: flex; align-items: center; justify-content: space-between; background: var(--card-solid);
    border: 1px solid var(--card-border); border-radius: var(--r-md); padding: 14px 16px; margin-top: 6px; font-size: 15px; }
.pay-total b { font-size: 20px; color: var(--accent2); }

/* blockers (task sheet) */
.blk-row { display: flex; align-items: center; gap: 8px; background: rgba(248,113,113,.08); border: 1px solid rgba(248,113,113,.25);
    border-radius: var(--r-sm); padding: 8px 10px; margin-bottom: 6px; }
.blk-info { flex: 1; min-width: 0; }
.blk-desc { font-size: 13px; font-weight: 600; }
.blk-on { font-size: 11.5px; color: var(--muted); }
.blk-add { display: flex; gap: 6px; align-items: stretch; margin-top: 6px; }
.blk-add input { flex: 1; min-width: 0; }
.blk-add select { max-width: 130px; }

/* start/stop timer */
.timer-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 10px;
    background: var(--card); border: 1px solid var(--card-border); border-radius: var(--r-md); padding: 10px 14px; }
.tm-disp { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: 1px; color: var(--accent2); direction: ltr; }

/* org-settings subsection divider + digest preview */
.settings-sub { font-weight: 700; font-size: 13px; color: var(--accent2); margin: 16px 2px 8px; padding-top: 12px; border-top: 1px solid var(--card-border); }
.digest-pre { white-space: pre-wrap; word-break: break-word; background: var(--bg2); border: 1px solid var(--card-border);
    border-radius: var(--r-sm); padding: 12px; font-family: 'Vazir', monospace; font-size: 12.5px; line-height: 1.9; max-height: 50vh; overflow: auto; direction: rtl; }

/* members editor with allocation */
.mem-edit-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--card-border); }
.mer-name { font-size: 13.5px; }
.alloc-in { width: 56px; }

/* 4-way status segment (todo/doing/blocked/done) */
.seg.seg4 { display: grid; grid-template-columns: repeat(4, 1fr); }
.seg .opt.blocked.sel { background: rgba(248,113,113,.2); color: var(--bad); border-color: rgba(248,113,113,.5); }

/* ---- personal / private projects ---- */
.priv-note { background: var(--limebg, #f2f7e6); border: 1px solid var(--rule, #d9e3c2); border-left: 3px solid var(--accent);
    border-radius: var(--r-sm); padding: 9px 12px; margin: 8px 0; font-size: 12.5px; color: var(--text); line-height: 1.7; }
.proj-card.private { border-color: var(--accent); }
.proj-card.private .accent { background: var(--accent) !important; }

/* ---- workspace switch (work ↔ personal shell) ---- */
.space-switch { margin: 2px 0 6px; }
.space-switch .seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--card); border: 1px solid var(--card-border); border-radius: var(--r-md); padding: 4px; }
.space-switch .opt { text-align: center; padding: 10px 8px; border-radius: var(--r-sm); font-weight: 700; font-size: 14px; color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.space-switch .opt.sel { background: var(--brand); color: var(--on-accent); }

/* ---- brand logo doubles as the work/personal switch ---- */
.logo.switchable { cursor: pointer; position: relative; transition: transform .12s, box-shadow .2s; }
.logo.switchable:active { transform: scale(.92); }
.logo.switchable.personal { box-shadow: 0 0 0 2.5px var(--bg), 0 0 0 4.5px var(--accent); }
.logo .logo-badge { position: absolute; bottom: -5px; inset-inline-start: -5px; font-size: 11px; line-height: 1;
    background: var(--card-solid); border: 1px solid var(--card-border); border-radius: 999px; padding: 2px 3px; }

/* ---- offline / pending-sync chip (Phase C) ---- */
.sync-chip { font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 999px; cursor: pointer; white-space: nowrap; align-self: center; }
.sync-chip.off { background: rgba(248,113,113,.16); color: var(--bad,#f87171); border: 1px solid rgba(248,113,113,.4); }
.sync-chip.pending { background: rgba(251,191,36,.16); color: var(--warn,#fbbf24); border: 1px solid rgba(251,191,36,.4); }

/* ---- chat: system notices (membership/lifecycle) + group settings ---- */
.chat-system { text-align: center; margin: 10px auto; max-width: 86%; font-size: 12px; color: var(--muted);
  background: rgba(255,255,255,.05); border-radius: 12px; padding: 5px 12px; }
.grp-mems { margin: 6px 0 2px; max-height: 46vh; overflow-y: auto; }
.grp-mem { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 2px; border-bottom: 1px solid rgba(255,255,255,.06); }
.grp-mem-name { font-size: 14px; }
.grp-mem-acts { display: flex; gap: 6px; flex: none; }
.grp-act { background: rgba(255,255,255,.07); color: var(--text); border: none; border-radius: 8px; padding: 5px 10px; font-size: 12px; font-family: inherit; cursor: pointer; }
.grp-act:active { background: rgba(255,255,255,.14); }
.grp-role { font-size: 11px; padding: 1px 7px; border-radius: 7px; margin-inline-start: 4px; }
.grp-role.owner { background: rgba(120,220,120,.16); color: var(--accent, #8fe388); }
.grp-role.admin { background: rgba(120,170,255,.16); color: #8fb6ff; }

/* ---- password reveal (eye) toggle ---- */
.pw-wrap { position: relative; display: block; }
.pw-wrap > input { width: 100%; padding-right: 44px; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; line-height: 0;
  display: flex; align-items: center; border-radius: 8px; }
.pw-eye:hover, .pw-eye:active { color: var(--text); background: rgba(255,255,255,.07); }

/* ---- project priority badge (Phase 2) ---- */
.pri-badge { font-size: 11px; padding: 1px 8px; border-radius: 7px; margin-inline-start: 4px; white-space: nowrap; font-weight: 600; }
.pri-badge.high { background: rgba(255,93,108,.16); color: var(--danger); }
.pri-badge.low { background: rgba(255,255,255,.07); color: var(--muted); }

/* ---- project health panel (Phase 1) ---- */
.hl-rag { text-align: center; border: 1px solid; border-radius: 12px; padding: 8px; font-weight: 700; font-size: 14px; margin: 6px 0 12px; }
.hl-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 4px; }
.hl-chip { border-radius: 12px; padding: 10px 4px; text-align: center; background: rgba(255,255,255,.05); }
.hl-chip.bad { background: rgba(255,93,108,.12); }
.hl-chip.warn { background: rgba(240,160,32,.12); }
.hl-chip .hl-n { font-size: 20px; font-weight: 800; line-height: 1.1; }
.hl-chip .hl-l { font-size: 11px; color: var(--muted); margin-top: 3px; }
.hl-line { font-size: 13.5px; line-height: 1.9; color: var(--text); padding: 2px 2px 4px; }

/* ---- team capacity board (Phase 3) + block sources (Phase 4) ---- */
.cap-card { display: flex; align-items: center; gap: 12px; padding: 11px 13px; margin-bottom: 9px;
    background: var(--card); border: 1px solid var(--card-border); border-radius: var(--r-md); }
.cap-body { flex: 1; min-width: 0; }
.cap-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cap-name { font-weight: 600; font-size: var(--fs-base); }
.cap-chip { font-size: 11px; padding: 1px 9px; border-radius: 20px; white-space: nowrap; font-weight: 600; }
.cap-chip.bad { background: rgba(255,93,108,.16); color: var(--danger); }
.cap-chip.ok { background: rgba(118,185,0,.16); color: var(--accent-soft); }
.cap-chip.warn { background: rgba(240,160,32,.16); color: #f0a020; }
.cap-bar { height: 7px; border-radius: 10px; background: var(--track); overflow: hidden; margin: 7px 0 5px; }
.cap-bar > i { display: block; height: 100%; border-radius: 10px; transition: width .5s cubic-bezier(.2,.8,.2,1); }
.cap-meta { font-size: var(--fs-xs); color: var(--muted); }
.cap-block { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 13px; margin-bottom: 8px;
    background: var(--card); border: 1px solid var(--card-border); border-radius: var(--r-md); }

/* ---- multi-company: active-company chip in the appbar ---- */
.co-chip { font-size: 12px; font-weight: 600; color: var(--text); background: rgba(255,255,255,.08);
  border: 1px solid var(--card-border); border-radius: 20px; padding: 5px 11px; cursor: pointer; white-space: nowrap;
  max-width: 42vw; overflow: hidden; text-overflow: ellipsis; flex: none; }
.co-chip:active { transform: scale(.95); background: rgba(255,255,255,.14); }

/* ---- chat video + file save ---- */
.chat-video { max-width: 240px; max-height: 320px; border-radius: 12px; display: block; background: #000; }
.chat-vidload { display: flex; flex-direction: column; gap: 3px; align-items: center; justify-content: center;
  min-width: 180px; min-height: 96px; background: rgba(0,0,0,.28); border-radius: 12px; cursor: pointer; padding: 14px; text-align: center; }
.chat-vidload .cf-ic { font-size: 28px; line-height: 1; }
.chat-vidload .cf-name { font-weight: 600; font-size: 13px; }
.chat-vidload .cf-size { font-size: 11px; color: var(--muted); }
.chat-fileact { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 5px; }
.chat-fileact .cf-name { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.cf-save { background: rgba(255,255,255,.13); color: var(--text); border: none; border-radius: 8px; padding: 4px 11px; font-size: 12px; font-family: inherit; cursor: pointer; flex: none; }
.cf-save:active { transform: scale(.94); }
.chat-msg.mine .cf-save { background: rgba(0,0,0,.18); }
.chat-msg.mine .chat-fileact .cf-name { color: rgba(0,0,0,.6); }

/* ---- chat: links, reactions, quick-react, pin bar, unread divider, draft ---- */
.chat-link { color: var(--accent); text-decoration: underline; word-break: break-all; }
.chat-msg.mine .chat-link { color: #0a3d0a; }
.chat-rx { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.rx { font-size: 12px; padding: 1px 8px; border-radius: 12px; background: var(--card-solid); border: 1px solid var(--card-border); cursor: pointer; line-height: 1.7; }
.rx.mine { background: rgba(118,185,0,.18); border-color: var(--accent); }
.rx-quick { display: flex; gap: 6px; margin: 4px 0 12px; }
.rx-quick button { font-size: 22px; background: var(--card-solid); border: 1px solid var(--card-border); border-radius: 12px; padding: 6px 0; cursor: pointer; flex: 1; }
.rx-quick button:active { transform: scale(.9); }
.chat-pinbar { display: flex; align-items: center; gap: 8px; padding: 7px 12px; background: var(--bg2); border-bottom: 1px solid var(--card-border); flex: none; }
.chat-pinbar .pin-txt { flex: 1; min-width: 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.chat-pinbar .pin-x { flex: none; background: none; border: none; color: var(--muted2); font-size: 14px; cursor: pointer; }
.chat-unread-divider { text-align: center; margin: 10px 0; }
.chat-unread-divider span { background: var(--brand); color: var(--on-accent); font-size: 11px; font-weight: 700; padding: 2px 12px; border-radius: 12px; }
.chat-draft { color: var(--danger); font-weight: 600; }

/* ---- chat batch 2: search bar, search hits, @mentions ---- */
.chat-searchbar { display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--bg2); border-bottom: 1px solid var(--card-border); flex: none; }
.chat-searchbar .cs-ic { font-size: 14px; color: var(--muted); flex: none; }
.chat-searchbar #chatSearchInput { flex: 1; min-width: 0; background: var(--card-solid); border: 1px solid var(--card-border); border-radius: 9px; color: var(--text); font: inherit; font-size: 13.5px; padding: 6px 10px; }
.chat-searchbar #chatSearchInput:focus { outline: none; border-color: var(--accent); }
.chat-search-count { flex: none; font-size: 12px; color: var(--muted); min-width: 30px; text-align: center; }
.chat-searchbar .cs-nav { flex: none; width: 30px; height: 30px; font-size: 13px; }
.chat-searchbar .cs-older { flex: none; background: var(--card-solid); border: 1px solid var(--accent); color: var(--accent); border-radius: 9px; padding: 4px 9px; font-size: 12px; cursor: pointer; }
.chat-msg.chat-search-hit .chat-bubble { box-shadow: 0 0 0 1.5px rgba(142,208,17,.5); }
.chat-msg.chat-search-current .chat-bubble { box-shadow: 0 0 0 2px var(--accent); }
/* @mention: inline highlight + a bubble that mentions me + the autocomplete popup */
.chat-mention { color: var(--accent); font-weight: 700; }
.chat-msg.mine .chat-mention { color: #0a2; }
.chat-msg.mentions-me .chat-bubble { border-inline-start: 3px solid var(--accent); }
.chat-composer { position: relative; }
.chat-mentionpop { position: absolute; bottom: calc(100% + 4px); inset-inline-start: 11px; inset-inline-end: 11px; max-height: 210px; overflow-y: auto; background: var(--card-solid); border: 1px solid var(--card-border); border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.28); z-index: 40; }
.chat-mentionpop .cm-row { padding: 9px 12px; font-size: 14px; cursor: pointer; border-bottom: 1px solid var(--card-border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-mentionpop .cm-row:last-child { border-bottom: none; }
.chat-mentionpop .cm-row.active, .chat-mentionpop .cm-row:hover { background: rgba(142,208,17,.16); }
.chat-mentionpop .cm-un { color: var(--muted2); font-size: 12px; }

/* ===================== Knowledge Management («دانش») — fits the existing tokens ===================== */
.km-searchbar { display: flex; align-items: center; gap: 6px; padding: 4px 0 10px; }
.km-searchbar .cs-ic { font-size: 15px; color: var(--muted); flex: none; }
.km-searchbar #kmSearch { flex: 1; min-width: 0; background: var(--card-solid); border: 1px solid var(--card-border); border-radius: 11px; color: var(--text); font: inherit; font-size: 14px; padding: 9px 12px; }
.km-searchbar #kmSearch:focus { outline: none; border-color: var(--accent); }
.km-filter-chip { flex: none; background: var(--card-solid); border: 1px solid var(--card-border); color: var(--muted); border-radius: 11px; padding: 8px 12px; font-size: 12.5px; cursor: pointer; }
.km-filter-chip.on { border-color: var(--accent); color: var(--accent); }
.km-discrow { display: flex; gap: 8px; overflow-x: auto; padding: 0 0 12px; -webkit-overflow-scrolling: touch; }
.km-discrow .dep-chip { flex: none; }
/* knowledge card built on proj-card */
.km-card { cursor: pointer; }
.km-card .accent { background: var(--todo); }
.km-card.km-published .accent { background: var(--accent); }
.km-card.km-review .accent, .km-card.km-pending .accent { background: var(--doing); }
.km-card.km-rejected .accent, .km-card.km-expired .accent { background: var(--danger); }
.km-typeicon { width: 44px; height: 44px; flex: none; border-radius: 50%; background: var(--surface-raised); display: grid; place-items: center; font-size: 20px; }
.km-typeicon.big { width: 38px; height: 38px; font-size: 19px; }
.km-grade { font-size: 10.5px; color: var(--accent); padding: 2px 8px; border-radius: 999px; background: rgba(118,185,0,.10); border: 1px solid rgba(118,185,0,.30); white-space: nowrap; }
.km-state { font-size: 10.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.km-state.st-draft { color: var(--muted); background: rgba(122,122,122,.18); }
.km-state.st-review { color: var(--doing); background: rgba(251,191,36,.16); }
.km-state.st-pub { color: var(--done); background: rgba(61,220,132,.16); }
.km-state.st-bad { color: var(--danger); background: rgba(248,113,113,.16); }
/* doc detail */
.km-doc { padding: 4px 2px 90px; }
.km-doc-head { display: flex; align-items: center; gap: 11px; margin-bottom: 8px; }
.km-doc-head h2 { margin: 0; font-size: var(--fs-xl); font-weight: 800; }
.km-doc-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.km-summary { color: var(--muted); font-size: var(--fs-base); line-height: 1.85; margin: 6px 0 12px; }
.km-body { color: var(--text); font-size: var(--fs-base); line-height: 2.05; white-space: normal; word-break: break-word; }
.km-byline { color: var(--muted2); font-size: 12px; margin-top: 16px; padding-top: 10px; border-top: 1px solid var(--card-border); }
.km-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.km-tag { font-size: 12px; color: var(--muted); background: var(--card); border: 1px solid var(--card-border); border-radius: 999px; padding: 3px 10px; cursor: pointer; }
.km-att { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--card-border); border-radius: 12px; padding: 11px 12px; margin: 10px 0; cursor: pointer; }
.km-att .cf-meta { display: flex; flex-direction: column; min-width: 0; }
.km-att .cf-name { font-size: 13.5px; color: var(--text); }
.km-att .cf-size { font-size: 11.5px; color: var(--muted2); }
.km-actions { display: flex; flex-direction: column; gap: 9px; margin-top: 18px; }
.km-note { border-radius: 11px; padding: 10px 12px; font-size: 13px; line-height: 1.8; margin: 8px 0; background: var(--surface-raised); border-inline-start: 3px solid var(--accent); }
.km-note.bad { border-inline-start-color: var(--danger); color: var(--text); }
/* editor */
.km-editor { padding: 2px 2px 40px; }
.km-2col { display: flex; gap: 10px; }
.km-2col .field { flex: 1; min-width: 0; }
.km-typetabs { display: flex; gap: 8px; margin: 4px 0 12px; }
.km-typetab { flex: 1; background: var(--card-solid); border: 1px solid var(--card-border); color: var(--muted); border-radius: 11px; padding: 9px 4px; font-size: 13px; cursor: pointer; }
.km-typetab.sel { border-color: var(--accent); color: var(--accent); background: rgba(118,185,0,.08); }
.km-editor textarea { width: 100%; box-sizing: border-box; background: var(--card-solid); border: 1px solid var(--card-border); border-radius: 11px; color: var(--text); font: inherit; font-size: 14px; line-height: 1.9; padding: 10px 12px; resize: vertical; }
.km-editor textarea:focus { outline: none; border-color: var(--accent); }

/* ---- KM Phase 2: trust signals, freshness, steward tools ---- */
.km-stewardbar { display: flex; gap: 8px; overflow-x: auto; padding: 0 0 12px; }
.km-stewardbar .btn { flex: none; padding: 7px 12px; font-size: 12.5px; }
.km-projbanner { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--card2, #eef2f7); border: 1px solid var(--line, #d8dee6); border-radius: 12px; padding: 9px 12px; margin: 0 0 12px; font-size: 13px; font-weight: 600; }
.km-projbanner .btn { flex: none; padding: 6px 10px; font-size: 12px; }
.km-provenance { margin: 6px 0 2px; }
.km-provchip { background: var(--card2, #eef2f7); border: 1px solid var(--line, #d8dee6); border-radius: 999px; padding: 5px 12px; font-size: 12.5px; font-weight: 600; color: var(--ink, #1b2733); cursor: pointer; }
.km-provchip:active { opacity: .7; }
.km-state.st-restricted { background: #fce8e6; color: #c5221f; }
.km-state.st-projconf { background: #fef0e0; color: #b06000; }
.km-nudge { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #e8f0fe; border: 1px solid #aecbfa; border-radius: 12px; padding: 9px 12px; margin: 10px 0 0; font-size: 13px; font-weight: 600; color: #174ea6; }
.km-nudge-acts { display: flex; align-items: center; gap: 4px; flex: none; }
.km-nudge-acts .btn { padding: 5px 12px; font-size: 12px; }
.km-ratemini { font-size: 11px; color: var(--doing); }
.km-endorse-badge { font-size: 10.5px; font-weight: 700; color: var(--done); background: rgba(61,220,132,.14); border-radius: 999px; padding: 2px 9px; }
.km-rate { display: flex; align-items: center; gap: 3px; margin-top: 14px; flex-wrap: wrap; }
.km-rate-lbl { font-size: 12.5px; color: var(--muted); margin-inline-end: 4px; }
.km-star { font-size: 22px; color: var(--card-border); cursor: pointer; line-height: 1; }
.km-star.on { color: var(--doing); }
.km-rate-agg { font-size: 12px; color: var(--muted2); margin-inline-start: 8px; }
.km-revlist { max-height: 60vh; overflow: auto; }
.km-revrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--card-border); }
.km-revmeta { font-size: 12.5px; color: var(--muted); }
.km-revacts { display: flex; gap: 6px; flex: none; }
.km-revacts .grp-act { background: var(--card); border: 1px solid var(--card-border); color: var(--text); border-radius: 8px; padding: 4px 10px; font-size: 12px; cursor: pointer; }

/* ---- KM Phase 3: Q&A, lessons, expertise locator ---- */
.km-answer { background: var(--card); border: 1px solid var(--card-border); border-radius: 12px; padding: 11px 13px; margin: 8px 0; }
.km-answer.accepted { border-color: var(--done); background: rgba(61,220,132,.06); }
.km-answer-meta { font-size: 11.5px; color: var(--muted2); margin-top: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.km-answer-meta .grp-act { background: var(--card-solid); border: 1px solid var(--card-border); color: var(--text); border-radius: 8px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
.km-experts { display: flex; flex-direction: column; gap: 9px; }
.km-expert { background: var(--card); border: 1px solid var(--card-border); border-radius: 12px; padding: 11px 13px; }
.km-expert-top { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.km-expert-top b { font-size: var(--fs-base); }
.km-expert-top .km-ask { margin-inline-start: auto; padding: 5px 12px; font-size: 12.5px; }
.km-rep-bar { height: 6px; background: var(--surface-raised); border-radius: 4px; margin-top: 9px; overflow: hidden; }
.km-rep-bar span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

/* ===== UX P4: multi-view selector + Kanban board + Jalali calendar ===== */
.view-tabs { display: inline-flex; gap: 2px; margin-inline-start: auto; background: var(--bg-overlay); border-radius: var(--r-pill); padding: 2px; }
.view-tab { background: none; border: none; color: var(--text-tertiary); padding: 5px 9px; border-radius: var(--r-pill); cursor: pointer; display: grid; place-items: center;
    transition: background var(--dur-instant) var(--ease-out), color var(--dur-fast) var(--ease-out); }
.view-tab:hover { color: var(--text); }
.view-tab.sel { background: var(--bg-card); color: var(--brand-soft); }

/* Kanban board */
.board { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 10px; -webkit-overflow-scrolling: touch; }
.board-col { flex: 0 0 230px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 8px; min-height: 120px; }
.board-col-h { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: var(--fs-sm); margin-bottom: 10px; padding: 0 2px; }
.board-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.board-cnt { font-size: var(--fs-2xs); color: var(--text-tertiary); background: var(--bg-overlay); padding: 0 7px; border-radius: var(--r-pill); margin-inline-start: auto; }
.board-empty { text-align: center; color: var(--text-tertiary); font-size: var(--fs-2xs); padding: 16px 0; opacity: .5; }
.board-card { background: var(--bg-overlay); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 9px 10px; margin-bottom: 7px; position: relative;
    transition: border-color var(--dur-fast) var(--ease-out), transform var(--dur-instant) var(--ease-out); }
.board-card:active { transform: scale(.98); }
.bc-title { font-size: var(--fs-sm); font-weight: 500; line-height: 1.4; margin-bottom: 6px; cursor: pointer; }
.bc-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.bc-due { font-size: var(--fs-2xs); color: var(--text-tertiary); margin-inline-start: auto; }
.bc-move { display: flex; gap: 4px; margin-top: 6px; opacity: .6; }
.bc-btn { background: var(--bg-surface); border: 1px solid var(--border); color: var(--text-secondary); width: 24px; height: 22px; border-radius: var(--r-xs); cursor: pointer; font-size: 14px; line-height: 1; display: grid; place-items: center; }
.bc-btn:active { background: var(--bg-active); }

/* Jalali calendar */
.cal-head { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 4px 0 10px; }
.cal-title { font-weight: 700; min-width: 130px; text-align: center; }
.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 4px; }
.cal-dow span { text-align: center; font-size: var(--fs-2xs); color: var(--text-tertiary); font-weight: 700; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-cell { min-height: 64px; background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--r-sm); padding: 4px; display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
.cal-cell.empty { background: transparent; border: none; }
.cal-cell.today { border-color: var(--brand); background: rgba(118,185,0,0.06); }
.cal-cell.has-tasks { border-color: var(--border); }
.cal-d { font-size: var(--fs-2xs); color: var(--text-secondary); font-weight: 600; }
.cal-cell.today .cal-d { color: var(--brand-soft); }
.cal-task { font-size: 9.5px; line-height: 1.3; padding: 1px 4px; border-radius: 3px; background: var(--bg-overlay); color: var(--text-secondary); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    transition: background var(--dur-instant); }
.cal-task:hover { background: var(--bg-hover); }
.cal-task.doing { border-inline-start: 2px solid var(--status-doing); }
.cal-task.done { border-inline-start: 2px solid var(--status-done); text-decoration: line-through; opacity: .6; }
.cal-task.blocked { border-inline-start: 2px solid var(--status-blocked); }
.cal-task.todo { border-inline-start: 2px solid var(--status-todo); }
.cal-more { font-size: 9px; color: var(--text-tertiary); text-align: center; }

/* ===== UX P5: global search results ===== */
.search-row { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: var(--r-md); cursor: pointer;
    transition: background var(--dur-instant) var(--ease-out); margin-bottom: 2px; }
.search-row:hover { background: var(--bg-hover); }
.search-row:active { background: var(--bg-active); }
.search-ic { width: 36px; height: 36px; flex: none; border-radius: var(--r-sm); background: var(--bg-overlay); color: var(--text-secondary); display: grid; place-items: center; }
.search-body { flex: 1; min-width: 0; }
.search-title { font-weight: 500; font-size: var(--fs-base); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-sub { font-size: var(--fs-2xs); color: var(--text-tertiary); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== D4: command palette (Ctrl+K, desktop) ===== */
.palette-bg { align-items: flex-start; justify-content: center; padding-top: 12vh; }
.palette { width: min(640px, 92vw); max-height: 62vh; display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg-overlay); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--elev-3);
  animation: scalein var(--dur-base) var(--ease-spring); }
.palette-inputrow { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border-subtle); color: var(--text-tertiary); flex: none; }
.palette-inputrow input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--text); font: inherit; font-size: var(--fs-lg); }
.palette-results { overflow-y: auto; padding: 6px; flex: 1; min-height: 0; }
.palette-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r-sm); cursor: pointer; }
.palette-row.sel { background: var(--bg-hover); }
.palette-ic { color: var(--text-tertiary); display: grid; place-items: center; width: 24px; flex: none; }
.palette-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: var(--fs-base); }
.palette-sub { color: var(--text-tertiary); font-size: var(--fs-2xs); }
.palette-kind { flex: none; font-size: var(--fs-2xs); color: var(--text-tertiary); background: var(--bg-card); border: 1px solid var(--border-subtle); padding: 1px 8px; border-radius: var(--r-pill); }
.palette-hint { display: flex; gap: 16px; padding: 8px 16px; border-top: 1px solid var(--border-subtle); color: var(--text-tertiary); font-size: var(--fs-2xs); flex: none; }
.kbd { display: inline-block; min-width: 22px; text-align: center; padding: 2px 6px; border-radius: var(--r-xs);
  background: var(--bg-card); border: 1px solid var(--border); border-bottom-width: 2px; font-size: var(--fs-2xs); color: var(--text-secondary); direction: ltr; }

/* ===== D5: desktop interactions — context menu + hover affordances + kanban DnD ===== */
#ctxRoot { position: fixed; inset: 0 auto auto 0; z-index: 90; width: 0; height: 0; }
.ctx-menu { position: fixed; z-index: 91; min-width: 190px; padding: 5px; background: var(--bg-overlay);
  border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--elev-3);
  animation: ctxin var(--dur-fast) var(--ease-out); }
@keyframes ctxin { from { transform: scale(.96); opacity: 0; } }
.ctx-item { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: var(--r-sm);
  font-size: var(--fs-sm); color: var(--text-secondary); cursor: pointer; white-space: nowrap; }
.ctx-item:hover { background: var(--bg-hover); color: var(--text); }
.ctx-item.danger { color: var(--danger); }
.ctx-item.danger:hover { background: rgba(239, 68, 68, .12); color: var(--danger); }
.ctx-ic { display: grid; place-items: center; width: 18px; color: var(--text-tertiary); }
.ctx-item.danger .ctx-ic { color: var(--danger); }

@media (hover: hover) and (pointer: fine) {
  .task:hover { background: var(--bg-hover); border-color: var(--border-strong); }
  .chat-row:hover { background: var(--bg-hover); }
  .board-card:hover { border-color: var(--border-strong); box-shadow: var(--elev-1); }
  /* row actions appear on hover (Linear pattern) instead of always-visible */
  .task .del-x { opacity: 0; transition: opacity var(--dur-fast) var(--ease-out); }
  .task:hover .del-x, .task .del-x:focus-visible { opacity: 1; }
  .chat-row .chat-row-more { opacity: 0; transition: opacity var(--dur-fast) var(--ease-out); }
  .chat-row:hover .chat-row-more { opacity: 1; }
  .board-card[draggable="true"] { cursor: grab; }
  .board-card.dragging { opacity: .45; cursor: grabbing; }
}
.board-col.drop { outline: 2px dashed var(--brand); outline-offset: -2px; border-radius: var(--r-md); background: rgba(118, 185, 0, .06); }

/* ===== P6: «نمای مدیر» hub — segmented sub-tabs over the four dashboards ===== */
.mgr-tabs { display: flex; gap: 4px; margin: 4px 0 14px; padding: 4px; background: var(--bg-raised); border: 1px solid var(--border-subtle); border-radius: var(--r-md); }
.mgr-tab { flex: 1; padding: 9px 6px; border: 0; border-radius: var(--r-sm); background: none; color: var(--text-secondary);
  font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out); }
.mgr-tab:hover { color: var(--text); }
.mgr-tab.sel { background: var(--bg-card); color: var(--text); box-shadow: var(--elev-1); }
.mgr-tab .count { font-size: var(--fs-2xs); color: var(--brand-soft); }

/* ===== Consortium فاز ۱.۳: DoD checklist rows (task detail + template sheet) ===== */
.dod-row { display: flex; align-items: center; gap: 10px; padding: 7px 2px; border-bottom: 1px solid var(--border-subtle); }
.dod-check { width: 20px; height: 20px; flex: none; border-radius: 6px; border: 1.5px solid var(--border-strong);
  display: grid; place-items: center; cursor: pointer; color: var(--on-accent, #fff);
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out); }
.dod-row.done .dod-check { background: var(--done); border-color: var(--done); }
.dod-title { flex: 1; min-width: 0; font-size: var(--fs-sm); }
.dod-row.done .dod-title { text-decoration: line-through; color: var(--text-tertiary); }
.dod-row .del-x { color: var(--text-tertiary); cursor: pointer; }
.dod-row .del-x:hover { color: var(--danger); }

/* ===== Consortium فاز ۲: «پرتفو» tab — milestones / risk matrix / intake funnel ===== */
.pf-proj { display: flex; align-items: center; gap: 8px; margin: 12px 0 6px; font-size: var(--fs-sm); }
.pf-ms { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--r-md); padding: 10px 12px; margin-bottom: 6px; cursor: pointer; }
.pf-ms:hover { border-color: var(--border-strong); }
.pf-ms-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.pf-ms-title { flex: 1; min-width: 0; font-weight: 600; font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-ms-pct { font-size: var(--fs-2xs); color: var(--text-tertiary); flex: none; }
.pf-late { color: var(--danger); }
/* labeled risk matrix (severity rows × likelihood columns) with axis headers */
.risk-grid { display: grid; grid-template-columns: auto repeat(3, 40px); gap: 4px; margin: 4px 0 2px; direction: ltr; width: max-content; }
.rg-colh, .rg-rowh { font-size: var(--fs-2xs); color: var(--text-tertiary); display: grid; place-items: center; }
.rg-rowh { justify-content: end; padding-inline-end: 4px; text-align: end; }
.rm-axis { display: flex; gap: 16px; direction: ltr; font-size: var(--fs-2xs); color: var(--text-tertiary); margin-bottom: 10px; }
.rm-cell { height: 34px; border-radius: var(--r-xs); display: grid; place-items: center; font-size: var(--fs-sm); font-weight: 700;
  background: var(--bg-card);   /* fallback for WebViews without color-mix */
  background: color-mix(in srgb, var(--danger) calc(var(--heat) * 8%), var(--bg-card)); border: 1px solid var(--border-subtle); color: var(--text-tertiary); }
.rm-cell.has { color: #fff; border-color: var(--border-strong); }
.rm-badge { flex: none; width: 28px; height: 28px; border-radius: var(--r-sm); display: grid; place-items: center; font-size: var(--fs-xs); font-weight: 800; color: #fff;
  background: var(--bg-overlay);   /* fallback for WebViews without color-mix */
  background: color-mix(in srgb, var(--danger) calc(var(--heat) * 9%), var(--bg-overlay)); border: 1px solid var(--border-subtle); }

/* ===== Consortium فاز ۴: interface (ICD) board ===== */
.iface-card { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--r-md); padding: 10px 12px; margin-bottom: 6px; cursor: pointer; }
.iface-card:hover { border-color: var(--border-strong); }
.iface-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.iface-name { font-weight: 600; font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iface-flow { display: flex; align-items: center; gap: 8px; }
.iface-node { flex: 1; min-width: 0; text-align: center; font-size: var(--fs-2xs); padding: 5px 8px; border-radius: var(--r-sm);
  background: var(--bg-surface); border: 1px solid var(--border); border-inline-start-width: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iface-node.iface-empty { color: var(--text-tertiary); border-style: dashed; }
.iface-arrow { flex: none; color: var(--accent-interface); display: grid; place-items: center; }

/* ===== Shared stat-tile component (portfolio / interface / gateway summaries) =====
   Accent via --stat-accent (default = brand); column count via --stat-cols (default 4).
   Tone modifiers recolor the value + top edge. */
.stat-row { display: grid; grid-template-columns: repeat(var(--stat-cols, 4), 1fr); gap: 8px; margin: 2px 0 14px; --stat-accent: var(--brand); }
.stat-tile { background: var(--bg-card); border: 1px solid var(--border-subtle); border-top: 2px solid var(--stat-accent);
  border-radius: var(--r-md); padding: 11px 6px 9px; text-align: center; }
.stat-tile.bad { border-top-color: var(--danger); }
.stat-tile.warn { border-top-color: var(--warning); }
.stat-tile.muted { border-top-color: var(--border-strong); }
.stat-val { font-size: var(--fs-xl); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.05; }
.stat-tile.bad .stat-val { color: var(--danger); }
.stat-tile.warn .stat-val { color: var(--warning); }
.stat-label { font-size: var(--fs-2xs); color: var(--text-tertiary); margin-top: 4px; line-height: 1.25; }
@media (max-width: 400px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }

/* ===== Consortium فاز ۵: «درگاه» tab — CDEO gateway health cockpit ===== */
.gw-hero { border: 1px solid var(--border-subtle); border-inline-start: 3px solid var(--accent-consortium);
  border-radius: var(--r-lg); padding: 14px 16px; margin-bottom: 14px; background: var(--bg-card); }
.gw-hero.off { border-inline-start-color: var(--border-strong); opacity: .92; }
.gw-hero-top { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.gw-hero-state { font-weight: 700; font-size: var(--fs-lg); }
.gw-hero-sub { font-size: var(--fs-2xs); color: var(--text-secondary); }
.gw-hero-sub code { background: var(--bg-surface); border-radius: var(--r-xs); padding: 1px 5px; font-size: .92em; }
.gw-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--text-tertiary); }
.gw-dot.on { background: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 22%, transparent); animation: gw-pulse 2.4s ease-in-out infinite; }
.gw-dot.off { background: var(--text-tertiary); }
@keyframes gw-pulse { 0%, 100% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 26%, transparent); } 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--brand) 6%, transparent); } }
.gw-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.gw-row-item { flex: 1 1 140px; background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--r-md); padding: 9px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gw-k { font-size: var(--fs-2xs); color: var(--text-tertiary); }
.gw-v { font-size: var(--fs-xs); font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .gw-dot.on { animation: none; } }

/* ===== Consortium فاز ۶: «کنسرسیوم» / «حاکمیت» / «بازارِ سهام» tabs (Hub) =====
   Reuses the فاز ۵ gateway's dot/pulse language for node traffic-lights, and the
   shared cap-card/chip-mini vocabulary for holders/signatures/votes, so the Hub
   cockpit reads as one family with the rest of the manager hub, not a bolt-on. */
.hub-node-card, .hub-contract-card, .hub-proposal-card { background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-inline-start: 3px solid var(--accent-consortium); border-radius: var(--r-lg); padding: 12px 14px; margin-bottom: 10px; }
.hub-node-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hub-node-name { font-weight: 700; font-size: var(--fs-sm); }
.hub-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--text-tertiary); }
.hub-dot.ok { background: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 22%, transparent); }
.hub-dot.warn { background: var(--warning); box-shadow: 0 0 0 4px color-mix(in srgb, var(--warning) 22%, transparent); }
.hub-dot.bad { background: var(--danger); box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 22%, transparent); animation: gw-pulse 2.4s ease-in-out infinite; }
.hub-dot.muted { background: var(--text-tertiary); }
.hub-holders { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.hub-holder-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--bg-card);
  border: 1px solid var(--border-subtle); border-radius: var(--r-md); margin-bottom: 6px; }
.hub-holder-row span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-xs); }
.hub-icd-row { border: 1px solid var(--border-subtle); border-radius: var(--r-md); padding: 10px 12px; margin-bottom: 8px; }
.hub-icd-row.mismatch { border-color: var(--danger); background: rgba(255,93,108,.06); }
.hub-icd-top { margin-bottom: 6px; font-size: var(--fs-sm); }
.hub-icd-entry { display: flex; align-items: center; gap: 8px; padding: 4px 0; flex-wrap: wrap; }
.hub-bottleneck, .hub-settlement { display: flex; align-items: center; gap: 8px; padding: 9px 12px; background: var(--bg-card);
  border: 1px solid var(--border-subtle); border-radius: var(--r-md); margin-bottom: 6px; flex-wrap: wrap; }
.hub-settlement .hd { flex: 1; min-width: 0; }
@media (prefers-reduced-motion: reduce) { .hub-dot.bad { animation: none; } }

/* ===== P7.1: context bar — company + sync chips live UNDER the appbar, not inside it (W9) ===== */
.context-bar { display: flex; align-items: center; gap: 8px; margin: -6px 0 10px; min-height: 26px; }
.context-bar .co-chip, .context-bar .sync-chip { margin: 0; }

/* ===== D6.1: tablet (768–1023px) — sheets centered like a dialog, not bottom-docked ===== */
@media (min-width: 768px) and (max-width: 1023px) {
  .modal-bg { align-items: center; }
  .sheet { max-width: 560px; width: 100%; border-radius: var(--r-2xl); }
  .drag-sheet.half, .drag-sheet.full { height: auto; max-height: 86vh; }
}

/* ============================================================
   RESPONSIVE LAYOUT (D0) — docs/DESKTOP-MOBILE-MODERNIZATION.md
   Mobile (default): bottom tab bar + FAB + centered #app.
   Tablet (≥768px): 2-col grids.
   Desktop (≥1024px + fine pointer): left sidebar + full-width content,
                                     tab bar + FAB hidden, modal centered.
   ============================================================ */

/* Tablet (768–1023px): wider grids, no sidebar yet */
@media (min-width: 768px) {
  .proj-grid { grid-template-columns: repeat(2, 1fr); }
  .quick-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 768px) and (max-width: 1023px) {
  /* keep mobile nav on touch tablets, even if wide */
}

/* Desktop (≥1024px AND fine pointer = real mouse) */
@media (min-width: 1024px) and (pointer: fine) {
  body { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
  body[data-detail="open"] { grid-template-columns: var(--sidebar-w) 1fr var(--detail-w); }
  /* explicit placement — body has other children (#fab/#tabbarRoot/#modalRoot/#toast), so
     auto-placement would drop #app into the 240px sidebar column and wrap the sidebar below the fold.
     RTL: column 1 = inline-start = the right side, which is where a Persian sidebar belongs. */
  .desktop-sidebar { grid-column: 1; grid-row: 1; }
  #app { grid-column: 2; grid-row: 1; min-width: 0; }
  body[data-detail="open"] .detail-pane { grid-column: 3; grid-row: 1; }

  /* the sidebar host (rendered by srvDesktopSidebar) */
  .desktop-sidebar {
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
    background: var(--bg-raised); border-inline-end: 1px solid var(--border);
    overflow-y: auto; padding: 14px 10px;
  }
  /* hide mobile nav chrome */
  .tabbar, .fab { display: none !important; }
  /* full-width content area (the #app still centers its children ≤ a max for readability) */
  #app { max-width: none; padding: 0 28px 60px; margin: 0; }
  /* the mobile appbar gradient still works, but on desktop give breathing room */
  .appbar { padding-top: 20px; }

  /* the master-detail right pane (filled by openDetail on desktop) */
  .detail-pane {
    display: block; position: sticky; top: 0; height: 100vh;
    background: var(--bg-raised); border-inline-start: 1px solid var(--border);
    overflow-y: auto; padding: 18px;
  }
  body:not([data-detail="open"]) .detail-pane { display: none; }

  /* modal/sheet → centered dialog on desktop (the drag-grip becomes a title bar) */
  .modal-bg { align-items: center; }
  .drag-sheet, .sheet { max-width: 560px; width: 100%; border-radius: var(--r-2xl); animation: scalein var(--dur-base) var(--ease-spring); }
  .drag-sheet.half, .drag-sheet.full { height: auto; max-height: 88vh; }   /* desktop: not 60vh, just a tall modal */
  @keyframes scalein { from { transform: scale(.96); opacity: 0; } }
  /* chat room: no longer full-screen takeover; sits in the content column */
  .chat-room { position: relative; inset: auto; z-index: auto; height: calc(100vh - 40px); border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--border); }

  /* ===== D3: chat = Slack-style split (rooms pane + docked room) ===== */
  .chat-split { display: grid; grid-template-columns: 300px minmax(0, 1fr); height: calc(100vh - 40px); margin-top: 20px;
    border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; background: var(--bg-surface); }
  .chat-split-list { display: flex; flex-direction: column; min-height: 0; background: var(--bg-raised); border-inline-end: 1px solid var(--border); }
  .chat-split-head { display: flex; align-items: center; gap: 2px; padding: 10px 14px; border-bottom: 1px solid var(--border-subtle); flex: none; }
  .chat-split-rows { flex: 1; min-height: 0; overflow-y: auto; }
  .chat-split-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
  .chat-split .chat-room { height: 100%; border: 0; border-radius: 0; }
  .chat-split .chat-head .iconbtn[aria-label="بازگشت"] { display: none; }   /* the list is always visible — no back arrow */
  .chat-split-empty { display: grid; place-items: center; height: 100%; color: var(--text-tertiary); font-size: var(--fs-sm); }
  .chat-split .chat-row.sel { background: rgba(118, 185, 0, 0.10); }
  .chat-split .chat-row.sel .chat-name { color: var(--brand-soft); }
}
/* on mobile, the sidebar/detail-pane hosts are hidden */
@media (max-width: 1023px), (pointer: coarse) {
  .desktop-sidebar, .detail-pane { display: none !important; }
}

/* ===== D1: desktop sidebar ===== */
.sb-brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 14px; border-bottom: 1px solid var(--border-subtle); margin-bottom: 10px; }
.sb-brand .logo { width: 34px; height: 34px; border-radius: var(--r-sm); background: var(--grad-brand); color: var(--on-accent); display: grid; place-items: center; flex: none; }
.sb-name { font-weight: 700; font-size: var(--fs-base); }
.sb-sub { font-size: var(--fs-2xs); color: var(--text-tertiary); }
.sb-section { display: flex; flex-direction: column; gap: 1px; padding: 6px 0; }
.sb-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); color: var(--text-secondary); cursor: pointer; font-size: var(--fs-sm); font-weight: 500;
    transition: background var(--dur-instant) var(--ease-out), color var(--dur-fast) var(--ease-out); text-decoration: none; }
.sb-item:hover { background: var(--bg-hover); color: var(--text); }
.sb-item.sel { background: rgba(118,185,0,0.10); color: var(--brand-soft); }
.sb-item svg { flex: none; opacity: .85; }
.sb-badge { margin-inline-start: auto; background: var(--danger); color: var(--bg-app); font-size: 10px; font-weight: 700; min-width: 18px; height: 18px; line-height: 18px; text-align: center; border-radius: var(--r-pill); padding: 0 5px; }
.sb-sync { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--warning); }
.sb-sync.off { background: var(--danger); }
.sb-footer { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border-subtle); display: flex; flex-direction: column; gap: 1px; }
.desktop-sidebar .av.sm { width: var(--av-sm); height: var(--av-sm); font-size: 11px; flex: none; }

/* ===== D2: desktop detail-pane close button ===== */
.dp-close { position: absolute; top: 10px; inset-inline-start: 10px; z-index: 2; width: 30px; height: 30px; border-radius: var(--r-sm); display: grid; place-items: center; cursor: pointer; color: var(--text-tertiary); background: var(--bg-card); border: 1px solid var(--border); }
.dp-close:hover { color: var(--text); background: var(--bg-hover); }
.detail-pane { position: relative; padding-top: 50px; }   /* room for the close button */
/* ===== D2.4: draggable resize handle on the pane's content-facing edge ===== */
.dp-resize { position: absolute; top: 0; bottom: 0; inset-inline-start: -3px; width: 7px; z-index: 5; cursor: ew-resize; touch-action: none; }
.dp-resize:hover, .dp-resize.dragging { background: rgba(118, 185, 0, 0.18); }
