/* ═══════════════════════════════════════════════════════════════
   Psyno Design System v4 — توکن‌ها و صیقل نهایی رابط کاربری
   بعد از app.css / ui.css / customer-club.css / staff-monitoring.css و قبل از
   responsive.css بارگذاری می‌شود. هدف: خوانایی، کنتراست استاندارد (WCAG AA)،
   تایپوگرافی درست فارسی، دسترس‌پذیری و یکدستی اجزا — بدون تغییر هویت بصری.
   ═══════════════════════════════════════════════════════════════ */

/* ─── ۱. توکن‌ها ─────────────────────────────────────────────── */
:root {
    --ds-font-sans: 'Vazirmatn', 'Segoe UI', Tahoma, system-ui, sans-serif;

    --ds-text-xs: 0.75rem;
    --ds-text-sm: 0.8125rem;
    --ds-text-md: 0.875rem;
    --ds-text-base: 0.9375rem;
    --ds-text-lg: 1.0625rem;
    --ds-text-xl: 1.25rem;
    --ds-text-2xl: 1.5rem;
    --ds-leading-tight: 1.4;
    --ds-leading-body: 1.75;

    --ds-space-1: 0.25rem;
    --ds-space-2: 0.5rem;
    --ds-space-3: 0.75rem;
    --ds-space-4: 1rem;
    --ds-space-5: 1.25rem;
    --ds-space-6: 1.5rem;
    --ds-space-8: 2rem;

    --ds-radius-xs: 6px;
    --ds-radius-sm: 10px;
    --ds-radius-md: 14px;
    --ds-radius-lg: 18px;
    --ds-radius-pill: 999px;

    --ds-dur-fast: 120ms;
    --ds-dur-base: 200ms;
    --ds-dur-slow: 320ms;
    --ds-ease: cubic-bezier(0.2, 0, 0, 1);

    /* در staff-monitoring.css استفاده شده ولی هرگز تعریف نشده بود */
    --text-secondary: var(--text-muted);

    --ds-text-1: var(--text-primary);
    --ds-text-2: var(--text-muted);
    --ds-text-3: #7d8ca6;
    --ds-border: var(--glass-border);
    --ds-border-strong: rgba(255, 255, 255, 0.16);
    --ds-surface-raised: #121a2e;
    --ds-surface-sunken: rgba(255, 255, 255, 0.03);
    --ds-focus-color: #a78bfa;

    --ds-success-fg: #34d399;
    --ds-success-bg: rgba(16, 185, 129, 0.13);
    --ds-success-line: rgba(16, 185, 129, 0.32);
    --ds-warning-fg: #fbbf24;
    --ds-warning-bg: rgba(245, 158, 11, 0.13);
    --ds-warning-line: rgba(245, 158, 11, 0.32);
    --ds-danger-fg: #fb7185;
    --ds-danger-bg: rgba(244, 63, 94, 0.13);
    --ds-danger-line: rgba(244, 63, 94, 0.32);
    --ds-info-fg: #22d3ee;
    --ds-info-bg: rgba(6, 182, 212, 0.13);
    --ds-info-line: rgba(6, 182, 212, 0.32);

    --ds-shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
    --ds-shadow-2: 0 10px 28px rgba(0, 0, 0, 0.38);
    --ds-shadow-3: 0 22px 60px rgba(0, 0, 0, 0.5);

    --ds-content-max: 1440px;
}

/* تم روشن: رنگ‌هایی که روی زمینهٔ روشن به‌عنوان «متن» استفاده می‌شوند تیره‌تر شده‌اند
   تا کنتراست حداقل ۴.۵:۱ داشته باشند (قبلاً سبز/زرد/فیروزه‌ای/بنفش روشن حدود ۲ تا ۳:۱ بودند). */
[data-theme="light"] {
    --text-muted: #4a5a72;
    --accent-light: #6d28d9;
    --cyan: #0e7490;
    --success: #047857;
    --warning: #b45309;
    --danger: #be123c;
    --tone-green: #047857;
    --tone-amber: #b45309;
    --tone-cyan: #0e7490;

    --ds-text-3: #64748b;
    --ds-border-strong: rgba(15, 23, 42, 0.18);
    --ds-surface-raised: #ffffff;
    --ds-surface-sunken: rgba(15, 23, 42, 0.03);
    --ds-focus-color: #6d28d9;

    --ds-success-fg: #047857;
    --ds-success-bg: rgba(16, 185, 129, 0.1);
    --ds-success-line: rgba(4, 120, 87, 0.28);
    --ds-warning-fg: #b45309;
    --ds-warning-bg: rgba(245, 158, 11, 0.12);
    --ds-warning-line: rgba(180, 83, 9, 0.28);
    --ds-danger-fg: #be123c;
    --ds-danger-bg: rgba(244, 63, 94, 0.09);
    --ds-danger-line: rgba(190, 18, 60, 0.26);
    --ds-info-fg: #0e7490;
    --ds-info-bg: rgba(6, 182, 212, 0.1);
    --ds-info-line: rgba(14, 116, 144, 0.26);

    --ds-shadow-1: 0 1px 2px rgba(15, 23, 42, 0.08);
    --ds-shadow-2: 0 10px 28px rgba(15, 23, 42, 0.1);
    --ds-shadow-3: 0 22px 60px rgba(15, 23, 42, 0.16);
}

/* ─── ۲. پایه و تایپوگرافی فارسی ─────────────────────────────── */
body { font-family: var(--ds-font-sans); }
h1, h2, h3, h4 { text-wrap: balance; line-height: var(--ds-leading-tight); }
p, li, dd { text-wrap: pretty; }
input, select, textarea, button { font-family: inherit; }
textarea { line-height: var(--ds-leading-body); }
input[type="number"], .num, .data-table td { font-variant-numeric: tabular-nums; }

/* فاصلهٔ حروف، اتصال حروف فارسی را از هم می‌گسلد؛ فقط برای کد، شماره و متن لاتین باقی می‌ماند */
.brand-sub:not([lang="en"]),
.auth-brand-sub:not([lang="en"]),
.user-role,
.data-table th,
.data-table thead th,
.login-tagline,
.timer-label,
.invoice-watermark,
.invoice-ribbon,
.invoice-number-label,
.invoice-party-label,
.invoice-table thead th,
.invoice-stamp,
.jalali-today-label,
.sa-nav-label,
.nav-group-label {
    letter-spacing: normal;
    text-transform: none;
}

/* ─── ۳. فوکوس و دسترس‌پذیری ─────────────────────────────────── */
.btn:focus-visible,
a:focus-visible,
summary:focus-visible,
[role="button"]:focus-visible,
[role="tab"]:focus-visible,
.nav-links a:focus-visible,
.cmdk-trigger:focus-visible,
.header-bell:focus-visible {
    outline: 2px solid var(--ds-focus-color);
    outline-offset: 2px;
}
.modal:focus, .modal:focus-visible, #main-content:focus { outline: none; }

.skip-link {
    position: fixed;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 10001;
    padding: 0.6rem 1rem;
    border-radius: var(--ds-radius-sm);
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: var(--ds-text-md);
    text-decoration: none;
    box-shadow: var(--ds-shadow-2);
    transform: translateY(calc(-100% - 1.5rem));
    transition: transform var(--ds-dur-base) var(--ds-ease);
}
.skip-link:focus, .skip-link:focus-visible { transform: none; outline: 2px solid #fff; outline-offset: 2px; }

[hidden] { display: none !important; }

/* ─── ۴. دکمه‌ها ─────────────────────────────────────────────── */
.btn { line-height: 1.35; font-weight: 600; -webkit-tap-highlight-color: transparent; }
.btn-ghost { color: var(--ds-text-2); }
.btn-ghost:hover:not(:disabled) { color: var(--ds-text-1); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; box-shadow: none; transform: none; }
.btn[aria-busy="true"] { cursor: progress; }

/* ─── ۵. فرم‌ها ──────────────────────────────────────────────── */
.form-group label { font-weight: 500; line-height: 1.6; }
::placeholder { color: var(--ds-text-3); opacity: 1; }
/* با :where وزن انتخابگر حداقل می‌ماند تا هر حاشیهٔ رنگی اختصاصیِ اجزا (مثل OTP) بر آن غلبه کند */
input:where(:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):hover:not(:focus):not(:disabled)),
select:where(:hover:not(:focus):not(:disabled)),
textarea:where(:hover:not(:focus):not(:disabled)) {
    border-color: var(--ds-border-strong);
}
input:disabled, select:disabled, textarea:disabled { opacity: 0.6; cursor: not-allowed; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
/* در تم روشن، قانون «background» بعدی در app.css فلش منوی کشویی را پاک می‌کرد */
[data-theme="light"] select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 0.75rem center;
}
/* خطای فیلد فقط پس از تعامل کاربر (نه هنگام باز شدن فرم خالی) */
input:user-invalid, select:user-invalid, textarea:user-invalid {
    border-color: var(--ds-danger-line);
    box-shadow: 0 0 0 3px var(--ds-danger-bg);
}

/* ─── ۶. جدول‌ها ─────────────────────────────────────────────── */
.data-table th { font-weight: 600; color: var(--ds-text-2); white-space: nowrap; }
.data-table td { vertical-align: middle; }
@media (min-width: 769px) {
    .table-wrap .data-table tbody tr:last-child td { border-bottom-color: transparent; }
}

/* ─── ۷. نشان‌ها و وضعیت‌ها ──────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 0.3rem; line-height: 1.55; font-weight: 600; white-space: nowrap; vertical-align: middle; }

/* ─── ۸. پیام‌های درون‌صفحه‌ای ──────────────────────────────── */
.alert { line-height: var(--ds-leading-body); border: 1px solid transparent; border-inline-start-width: 3px; }
.alert-error { background: var(--ds-danger-bg); border-color: var(--ds-danger-line); border-inline-start-color: var(--ds-danger-fg); }
.alert-success { background: var(--ds-success-bg); border-color: var(--ds-success-line); border-inline-start-color: var(--ds-success-fg); }
.alert-warning { background: var(--ds-warning-bg); border-color: var(--ds-warning-line); border-inline-start-color: var(--ds-warning-fg); color: var(--ds-text-1); }
.alert-info { background: var(--ds-info-bg); border-color: var(--ds-info-line); border-inline-start-color: var(--ds-info-fg); color: var(--ds-text-1); }
[data-theme="light"] .alert-error { color: #9f1239; }
[data-theme="light"] .alert-success { color: #065f46; }

/* ─── ۹. اعلان‌ها (Toast) و دیالوگ‌ها ───────────────────────── */
.notify-toast {
    background: color-mix(in srgb, var(--ds-surface-raised) 94%, transparent);
    border-inline-start: 3px solid var(--ds-info-fg);
    box-shadow: var(--ds-shadow-3);
    color: var(--ds-text-1);
}
.notify-success { border-inline-start-color: var(--ds-success-fg); }
.notify-error { border-inline-start-color: var(--ds-danger-fg); }
.notify-warning { border-inline-start-color: var(--ds-warning-fg); }
.notify-success .notify-toast-icon { color: var(--ds-success-fg); background: var(--ds-success-bg); }
.notify-error .notify-toast-icon { color: var(--ds-danger-fg); background: var(--ds-danger-bg); }
.notify-warning .notify-toast-icon { color: var(--ds-warning-fg); background: var(--ds-warning-bg); }
.notify-info .notify-toast-icon { color: var(--ds-info-fg); background: var(--ds-info-bg); }
.notify-toast-body { line-height: 1.7; overflow-wrap: anywhere; }
.notify-toast-close { min-width: 28px; min-height: 28px; border-radius: var(--ds-radius-xs); }
.notify-toast-close:hover { background: var(--ds-surface-sunken); }
.notify-toast.is-paused .notify-toast-progress { animation-play-state: paused; }

.notify-dialog { background: color-mix(in srgb, var(--ds-surface-raised) 96%, transparent); box-shadow: var(--ds-shadow-3); }
.notify-dialog-message { line-height: var(--ds-leading-body); }
[data-theme="light"] .notify-dialog-overlay { background: rgba(15, 23, 42, 0.32); }

.notify-panel { width: min(500px, 100%); text-align: right; }
.notify-panel .notify-dialog-title { text-align: center; margin-bottom: 1rem; }
.notify-panel .notify-dialog-actions { margin-top: 1.25rem; }
.ds-shortcuts { display: grid; gap: 0.4rem; margin: 0; }
.ds-shortcut-row {
    display: grid;
    grid-template-columns: minmax(130px, auto) 1fr;
    align-items: center;
    gap: 0.85rem;
    padding: 0.55rem 0.75rem;
    border-radius: var(--ds-radius-sm);
    background: var(--ds-surface-sunken);
    border: 1px solid var(--ds-border);
}
.ds-shortcut-row dt { display: flex; align-items: center; gap: 0.25rem; flex-wrap: wrap; direction: ltr; justify-content: flex-end; color: var(--ds-text-2); font-size: var(--ds-text-xs); }
.ds-shortcut-row dd { margin: 0; font-size: var(--ds-text-md); color: var(--ds-text-1); line-height: 1.6; }
.ds-shortcuts kbd {
    display: inline-block;
    min-width: 1.6rem;
    padding: 0.12rem 0.45rem;
    border-radius: var(--ds-radius-xs);
    border: 1px solid var(--ds-border-strong);
    border-bottom-width: 2px;
    background: var(--ds-surface-sunken);
    color: var(--ds-text-1);
    font-family: inherit;
    font-size: var(--ds-text-xs);
    font-weight: 700;
    text-align: center;
}
.ds-shortcuts-hint { margin: 0.85rem 0 0; font-size: var(--ds-text-xs); color: var(--ds-text-2); text-align: center; }

/* ─── ۱۰. پنجره‌های مودال ────────────────────────────────────── */
.modal-overlay { overscroll-behavior: contain; }
.modal { overscroll-behavior: contain; }
[data-theme="light"] .modal-overlay { background: rgba(15, 23, 42, 0.38); }

/* ─── ۱۱. چیدمان صفحه‌های عریض ───────────────────────────────── */
/* در نمایشگرهای بزرگ، محتوا کنار منو گیر نمی‌کند و در فضای موجود وسط‌چین می‌شود */
@media (min-width: 1600px) {
    .app-layout > .main-content.sa-main-content { max-width: none; }
    .app-layout > .main-content > .page-header,
    .app-layout > .main-content > .sa-main-header,
    .app-layout > .main-content > .sa-content-body {
        width: 100%;
        max-width: var(--ds-content-max);
        margin-inline: auto;
    }
}

/* ─── ۱۲. نمای فشرده (از جستجوی سریع: «نمای فشرده») ──────────── */
html[data-density="compact"] { font-size: 15px; }
[data-density="compact"] .data-table th,
[data-density="compact"] .data-table td { padding: 0.5rem 0.75rem; }
[data-density="compact"] .form-group { margin-bottom: 0.7rem; }
[data-density="compact"] .modal { padding: 1.35rem 1.5rem; }
@media (min-width: 769px) {
    [data-density="compact"] .main-content { padding: 1.35rem; }
}
[data-density="compact"] .sa-content-body { gap: 0.9rem; }
[data-density="compact"] .nav-links a { padding: 0.55rem 0.8rem; margin-bottom: 0.2rem; }
[data-density="compact"] .stat-card { padding: 1rem; }

/* ─── ۱۳. اصلاح کنتراست متن‌های رنگی در تم روشن ─────────────── */
[data-theme="light"] .gift-reveal-tag,
[data-theme="light"] .gift-expiry-hint,
[data-theme="light"] .sm-status-idle,
[data-theme="light"] .secretary-profile-status.needs-setup { color: #b45309; }
[data-theme="light"] .share-pill.share-therapist,
[data-theme="light"] .kpi-delta.up,
[data-theme="light"] .fu-done-check,
[data-theme="light"] .mood-shift.up,
[data-theme="light"] .sm-status-online,
[data-theme="light"] .sm-section-icon.sm-pulse,
[data-theme="light"] .secretary-profile-status.is-ready { color: #047857; }
[data-theme="light"] .share-pill.share-clinic { color: #0e7490; }
[data-theme="light"] .leader-row:nth-child(2) .leader-rank { color: #64748b; }
[data-theme="light"] .sa-share-wa { color: #15803d; }
[data-theme="light"] .star-display.active,
[data-theme="light"] .star-btn.active,
[data-theme="light"] .star-btn:hover,
[data-theme="light"] .star-input label:hover,
[data-theme="light"] .star-input label:hover ~ label,
[data-theme="light"] .star-input input:checked ~ label,
[data-theme="light"] .sr-stars,
[data-theme="light"] .leader-row:nth-child(1) .leader-rank { color: #d97706; }

/* ─── ۱۴. ترجیحات سیستم‌عامل ─────────────────────────────────── */
/* شفافیت کمتر: سطح‌های مات و بدون blur (خواناتر و سبک‌تر روی دستگاه‌های ضعیف) */
@media (prefers-reduced-transparency: reduce) {
    .glass-panel, .glass-panel-sm, .sidebar, .notify-toast, .notify-dialog, .cmdk {
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
        background-color: var(--bg-secondary);
    }
    .arabesque-bg .aurora { display: none; }
}

/* حالت کنتراست بالای ویندوز: متن‌های گرادیانی شفاف نامرئی نشوند و مرز اجزا دیده شود */
@media (forced-colors: active) {
    .brand-text, .page-title, .stat-value, .page-hero-title, .kpi-value, .timer-value {
        background: none !important;
        -webkit-text-fill-color: CanvasText !important;
        color: CanvasText !important;
    }
    .btn, .badge, .glass-panel, .notify-toast, .notify-dialog, .modal { border: 1px solid CanvasText; }
    :focus-visible { outline: 2px solid Highlight !important; }
    .arabesque-bg { display: none; }
}

/* صفحه‌لمسی: هدف لمس دکمه‌های کوچک حداقل ۴۰ پیکسل */
@media (pointer: coarse) {
    .notify-toast-close { min-width: 40px; min-height: 40px; }
}

/* موبایل: اعلان‌ها تمام‌عرض در بالای صفحه و دور از ناچ */
@media (max-width: 600px) {
    #notify-root {
        top: calc(0.75rem + env(safe-area-inset-top, 0px));
        left: 0.75rem;
        right: 0.75rem;
        max-width: none;
    }
}

/* اسکرول‌بار افقی جدول‌ها هم‌اندازهٔ اسکرول‌بار عمودی */
::-webkit-scrollbar { height: 6px; }
@supports (-moz-appearance: none) {
    html { scrollbar-width: thin; scrollbar-color: rgba(148, 163, 184, 0.4) transparent; }
}

/* ─── ۱۵. چاپ ────────────────────────────────────────────────── */
@media print {
    .skip-link, #notify-root, .notify-dialog-overlay, .cmdk-overlay, .mobile-nav-toggle { display: none !important; }
    .brand-text, .page-title, .stat-value, .page-hero-title {
        background: none !important;
        -webkit-text-fill-color: #111 !important;
        color: #111 !important;
    }
}

/* ─── ۱۶. میز پذیرش امروز ───────────────────────────────────── */
#reception-root {
    --rx-info: var(--ds-info-fg);
    --rx-good: var(--ds-success-fg);
    --rx-warn: var(--ds-warning-fg);
    --rx-bad: var(--ds-danger-fg);
    --rx-violet: var(--accent-light);
    --rx-live: #10b981;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
#reception-root .tone-info { --rx-tone: var(--rx-info); }
#reception-root .tone-good { --rx-tone: var(--rx-good); }
#reception-root .tone-warn { --rx-tone: var(--rx-warn); }
#reception-root .tone-bad { --rx-tone: var(--rx-bad); }
#reception-root .tone-violet { --rx-tone: var(--rx-violet); }
#reception-root .tone-live { --rx-tone: var(--rx-live); }
#reception-root .tone-muted { --rx-tone: var(--ds-text-3); }

/* سربرگ */
.rx-hero {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1.4rem 1.6rem;
    border-radius: var(--radius-lg, 22px);
    border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--ds-border));
    background:
        radial-gradient(420px 200px at 100% 0%, color-mix(in srgb, var(--accent) 26%, transparent), transparent 70%),
        radial-gradient(360px 180px at 0% 100%, color-mix(in srgb, var(--cyan) 18%, transparent), transparent 70%),
        var(--glass-bg);
    box-shadow: var(--ds-shadow-2);
}
.rx-hero-greet { font-size: var(--ds-text-sm); color: var(--ds-text-2); font-weight: 600; }
.rx-hero h2 { margin: 0.15rem 0 0.25rem; font-size: 1.55rem; font-weight: 800; }
.rx-hero p { margin: 0; display: flex; align-items: center; gap: 0.45rem; color: var(--ds-text-2); font-size: var(--ds-text-sm); }
.rx-live { width: 8px; height: 8px; border-radius: 50%; background: var(--rx-live); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55); animation: rx-pulse 2s infinite; }
@keyframes rx-pulse { 70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); } 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); } }
.rx-hero-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.rx-ring {
    --p: 0;
    flex-shrink: 0;
    width: 132px;
    height: 132px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: conic-gradient(var(--rx-good) calc(var(--p) * 1%), color-mix(in srgb, var(--ds-text-3) 22%, transparent) 0);
}
.rx-ring > div {
    width: 106px;
    height: 106px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    align-content: center;
    background: var(--ds-surface-raised);
    text-align: center;
}
.rx-ring strong { font-size: 1.6rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.rx-ring strong small { font-size: 0.9rem; color: var(--ds-text-2); font-weight: 600; }
.rx-ring span { font-size: var(--ds-text-xs); color: var(--ds-text-2); }

/* هشدار تأخیر */
.rx-alert {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
    padding: 0.8rem 1rem;
    border-radius: var(--ds-radius-md);
    background: var(--ds-warning-bg);
    border: 1px solid var(--ds-warning-line);
    border-inline-start: 4px solid var(--ds-warning-fg);
}
.rx-alert > span { font-size: 1.35rem; }
.rx-alert strong { display: block; }
.rx-alert small { color: var(--ds-text-2); }
.rx-alert-hint { margin-inline-start: auto; }

/* کارت‌های آمار */
.rx-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 0.75rem; }
.rx-stat {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.9rem 1rem;
    border-radius: var(--ds-radius-md);
    background: var(--glass-bg);
    border: 1px solid var(--ds-border);
    transition: transform var(--ds-dur-base) var(--ds-ease), border-color var(--ds-dur-base);
}
.rx-stat:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--rx-tone) 45%, var(--ds-border)); }
.rx-stat-icon {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 1.2rem;
    background: color-mix(in srgb, var(--rx-tone) 15%, transparent);
    border: 1px solid color-mix(in srgb, var(--rx-tone) 30%, transparent);
}
.rx-stat small { display: block; color: var(--ds-text-2); font-size: var(--ds-text-xs); font-weight: 600; }
.rx-stat strong { display: block; font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.45; }
.rx-stat em { display: block; font-style: normal; font-size: var(--ds-text-xs); color: var(--rx-tone); }

/* پنل‌ها */
.rx-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1rem; align-items: start; }
.rx-panel { border-radius: var(--radius-lg, 22px); background: var(--glass-bg); border: 1px solid var(--ds-border); box-shadow: var(--ds-shadow-1); min-width: 0; }
.rx-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; padding: 1rem 1.1rem 0.75rem; border-bottom: 1px solid var(--ds-border); }
.rx-panel-head h3 { margin: 0; font-size: var(--ds-text-lg); }
.rx-filters { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.rx-filter {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.35rem 0.75rem; min-height: 34px;
    border-radius: var(--ds-radius-pill); border: 1px solid var(--ds-border);
    background: var(--ds-surface-sunken); color: var(--ds-text-2);
    font: inherit; font-size: var(--ds-text-sm); font-weight: 600; cursor: pointer;
    transition: background var(--ds-dur-fast), color var(--ds-dur-fast), border-color var(--ds-dur-fast);
}
.rx-filter b { min-width: 1.4rem; padding: 0 0.35rem; border-radius: var(--ds-radius-pill); background: color-mix(in srgb, var(--ds-text-3) 18%, transparent); font-size: var(--ds-text-xs); text-align: center; }
.rx-filter:hover { color: var(--ds-text-1); border-color: var(--ds-border-strong); }
.rx-filter.is-active { color: #fff; background: linear-gradient(135deg, var(--accent), #4f46e5); border-color: transparent; }
.rx-filter.is-active b { background: rgba(255, 255, 255, 0.22); }

/* نوار زمانی */
.rx-timeline { list-style: none; margin: 0; padding: 0.9rem 1.1rem 1.1rem; position: relative; display: grid; gap: 0.6rem; }
.rx-item { display: grid; grid-template-columns: 58px 18px minmax(0, 1fr); align-items: stretch; gap: 0.5rem; position: relative; }
.rx-item::before { content: ''; position: absolute; inset-block: -0.6rem; inset-inline-start: calc(58px + 0.5rem + 8px); width: 2px; background: var(--ds-border); }
.rx-item:first-child::before { inset-block-start: 1.2rem; }
.rx-item:last-child::before { inset-block-end: calc(100% - 1.2rem); }
.rx-item-time { display: flex; flex-direction: column; align-items: flex-end; padding-top: 0.55rem; font-variant-numeric: tabular-nums; }
.rx-item-time strong { font-size: var(--ds-text-base); }
.rx-item-time small { color: var(--ds-text-3); font-size: var(--ds-text-xs); }
.rx-item-dot { position: relative; z-index: 1; width: 14px; height: 14px; margin-top: 0.8rem; justify-self: center; border-radius: 50%; background: var(--ds-surface-raised); border: 3px solid var(--rx-tone); }
.rx-item.tone-live .rx-item-dot { background: var(--rx-live); animation: rx-pulse 2s infinite; }
.rx-item-card {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.5rem 0.75rem; align-items: center;
    padding: 0.7rem 0.85rem; border-radius: var(--ds-radius-md);
    background: color-mix(in srgb, var(--rx-tone) 6%, var(--ds-surface-sunken));
    border: 1px solid color-mix(in srgb, var(--rx-tone) 22%, var(--ds-border));
    border-inline-start: 3px solid var(--rx-tone);
    transition: transform var(--ds-dur-base) var(--ds-ease), box-shadow var(--ds-dur-base);
}
.rx-item-card:hover { transform: translateX(-2px); box-shadow: var(--ds-shadow-1); }
.rx-item.tone-good .rx-item-card, .rx-item.tone-bad .rx-item-card, .rx-item.tone-muted .rx-item-card { opacity: 0.72; }
.rx-item-main { display: flex; align-items: center; gap: 0.65rem; min-width: 0; }
.rx-avatar {
    width: 38px; height: 38px; flex-shrink: 0; border-radius: 12px; display: grid; place-items: center;
    font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--accent), var(--cyan));
}
.rx-avatar.sm { width: 32px; height: 32px; border-radius: 10px; font-size: var(--ds-text-sm); }
.rx-item-who { min-width: 0; }
.rx-item-who a { display: block; color: var(--ds-text-1); font-weight: 700; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rx-item-who a:hover { color: var(--accent-light); }
.rx-item-who small { display: block; color: var(--ds-text-2); font-size: var(--ds-text-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rx-item-side { display: flex; flex-direction: column; align-items: flex-end; gap: 0.3rem; }
.rx-status { font-size: var(--ds-text-xs); font-weight: 700; color: var(--rx-tone); white-space: nowrap; }
.rx-item-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0.4rem; padding-top: 0.5rem; border-top: 1px dashed var(--ds-border); }
.rx-act {
    min-height: 32px; padding: 0.25rem 0.7rem; border-radius: var(--ds-radius-sm);
    border: 1px solid var(--ds-border); background: var(--ds-surface-raised); color: var(--ds-text-1);
    font: inherit; font-size: var(--ds-text-sm); font-weight: 600; cursor: pointer;
    transition: background var(--ds-dur-fast), border-color var(--ds-dur-fast), color var(--ds-dur-fast);
}
.rx-act:hover { border-color: var(--ds-border-strong); }
.rx-act-ok { color: var(--ds-success-fg); border-color: var(--ds-success-line); }
.rx-act-ok:hover { background: var(--ds-success-bg); }
.rx-act-bad { color: var(--ds-danger-fg); border-color: var(--ds-danger-line); margin-inline-start: auto; }
.rx-act-bad:hover { background: var(--ds-danger-bg); }
.rx-chip { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.15rem 0.55rem; border-radius: var(--ds-radius-pill); font-size: var(--ds-text-xs); font-weight: 700; white-space: nowrap; }
.rx-chip-ok { color: var(--ds-success-fg); background: var(--ds-success-bg); }
.rx-chip-debt { color: var(--ds-warning-fg); background: var(--ds-warning-bg); border: 1px solid var(--ds-warning-line); }

/* خط «اکنون» */
.rx-now { position: relative; display: flex; align-items: center; gap: 0.5rem; margin: 0.15rem 0; color: var(--ds-danger-fg); font-size: var(--ds-text-xs); font-weight: 800; }
.rx-now::after { content: ''; flex: 1; height: 2px; border-radius: 2px; background: linear-gradient(90deg, transparent, var(--ds-danger-fg)); }
.rx-now span { padding: 0.1rem 0.6rem; border-radius: var(--ds-radius-pill); background: var(--ds-danger-bg); border: 1px solid var(--ds-danger-line); }

/* بدهکاران */
.rx-debtors ul { list-style: none; margin: 0; padding: 0.75rem; display: grid; gap: 0.45rem; }
.rx-debtors li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 0.6rem; padding: 0.55rem 0.65rem; border-radius: var(--ds-radius-md); background: var(--ds-surface-sunken); border: 1px solid var(--ds-border); }
.rx-debtors li a { display: block; color: var(--ds-text-1); font-weight: 700; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rx-debtors li small { color: var(--ds-text-2); font-size: var(--ds-text-xs); }
.rx-debtors li strong { color: var(--ds-warning-fg); font-size: var(--ds-text-sm); white-space: nowrap; font-variant-numeric: tabular-nums; }
.rx-debtors .btn-block { margin: 0 0.75rem 0.85rem; width: calc(100% - 1.5rem); }

.rx-empty { display: grid; justify-items: center; gap: 0.5rem; padding: 2.2rem 1rem; text-align: center; color: var(--ds-text-2); }
.rx-empty > span { font-size: 2.2rem; }
.rx-empty p { margin: 0; }

@media (max-width: 1100px) { .rx-grid { grid-template-columns: minmax(0, 1fr); } }
.rx-panel-head > * { min-width: 0; }
.rx-filters { max-width: 100%; }
@media (max-width: 640px) {
    .rx-hero { flex-direction: column-reverse; align-items: stretch; text-align: center; padding: 1.15rem; }
    .rx-hero p { justify-content: center; }
    .rx-hero-actions { justify-content: center; }
    .rx-hero-actions .btn { flex: 1 1 auto; }
    .rx-ring { align-self: center; width: 112px; height: 112px; }
    .rx-ring > div { width: 90px; height: 90px; }
    .rx-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.55rem; }
    .rx-stat { flex-direction: column; align-items: flex-start; gap: 0.45rem; padding: 0.75rem; }
    .rx-stat strong { font-size: 1rem; }
    .rx-panel-head { flex-direction: column; align-items: stretch; }
    .rx-filters { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; scrollbar-width: none; }
    .rx-filter { flex-shrink: 0; }
    .rx-timeline { padding: 0.75rem; }
    .rx-item { grid-template-columns: 46px minmax(0, 1fr); }
    .rx-item::before, .rx-item-dot { display: none; }
    .rx-item-card { grid-template-columns: minmax(0, 1fr); }
    .rx-item-side { flex-direction: row; align-items: center; justify-content: space-between; }
    .rx-act { flex: 1 1 auto; min-height: 40px; }
    .rx-act-bad { margin-inline-start: 0; }
    .rx-alert-hint { margin-inline-start: 0; }
}
@media (prefers-reduced-motion: reduce) { .rx-live, .rx-item.tone-live .rx-item-dot { animation: none; } }
@media print { .rx-hero-actions, .rx-filters, .rx-item-actions { display: none !important; } }

/* ─── ۱۷. مرکز خروجی Excel ───────────────────────────────────── */
.export-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 1rem 1.25rem; margin-bottom: 1rem; }
.export-toolbar small { display: block; }
.export-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.export-card { display: flex; flex-direction: column; gap: 0.55rem; padding: 1.15rem; }
.export-card header { display: flex; align-items: center; gap: 0.6rem; }
.export-card h3 { margin: 0; }
.export-card p { margin: 0; line-height: var(--ds-leading-body); }
.export-card-icon { font-size: 1.5rem; }
.export-card-scope { color: var(--ds-info-fg); font-size: var(--ds-text-xs); }
.export-card-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: auto; padding-top: 0.4rem; }
.export-note { margin-top: 1rem; font-size: var(--ds-text-sm); line-height: var(--ds-leading-body); }
.invoices-toolbar { align-items: center; }

/* ─── ۱۸. کارکنان و رمز شخصی اعضای نقش ─────────────────────── */
.staff-intro { margin-bottom: 1rem; }
.staff-exec-list { list-style: none; margin: 0.5rem 0 0; padding: 0; display: grid; gap: 0.4rem; }
.staff-exec-list li { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; padding: 0.5rem 0.7rem; border-radius: var(--ds-radius-sm); background: var(--ds-surface-sunken); }
.role-member-pass { margin: 0.25rem 0 0.6rem; padding: 0.85rem 1rem; display: grid; gap: 0.5rem; }
.role-member-pass p { margin: 0; }
.rs-card.is-empty { opacity: 0.6; }

/* ─── ۱۹. پیش‌نمایش چاپ ──────────────────────────────────────── */
.print-preview-overlay { position: fixed; inset: 0; z-index: 10050; display: flex; flex-direction: column; background: rgba(2, 6, 23, 0.72); backdrop-filter: blur(6px); }
[data-theme="light"] .print-preview-overlay { background: rgba(15, 23, 42, 0.45); }
.print-preview-bar { display: flex; align-items: center; gap: 0.6rem; padding: 0.75rem 1rem; background: var(--ds-surface-raised); border-bottom: 1px solid var(--ds-border); box-shadow: var(--ds-shadow-2); }
.print-preview-stage { flex: 1; overflow: auto; padding: 1.5rem 1rem 3rem; display: flex; justify-content: center; }
.print-preview-paper { width: min(210mm, 100%); min-height: 297mm; border: 0; border-radius: 4px; background: #fff; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45); }
.print-preview-paper.is-landscape { width: min(297mm, 100%); min-height: 210mm; }
@media print { .print-preview-overlay { display: none !important; } }

/* ─── ۲۰. مرکز خروجی Excel — واکنش‌گرا برای موبایل و تبلت ─────── */
.export-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.export-card { text-align: right; min-width: 0; border-radius: var(--radius-lg, 22px); }
.export-card header { min-width: 0; }
.export-card h3 { font-size: var(--ds-text-lg); line-height: 1.5; overflow-wrap: anywhere; }
.export-card-icon {
    width: 44px; height: 44px; flex-shrink: 0; display: grid; place-items: center;
    border-radius: 13px; background: color-mix(in srgb, var(--accent) 14%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
}
.export-card-actions .btn { flex: 1 1 140px; justify-content: center; }
.export-toolbar .chip-radios { min-width: 0; }
.export-toolbar .chip-radio { position: relative; }

@media (max-width: 768px) {
    .export-toolbar { flex-direction: column; align-items: stretch; gap: 0.75rem; padding: 0.95rem; }
    .export-toolbar .chip-radios {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        align-items: start;
        gap: 0.4rem;
    }
    .export-toolbar .chip-radio { display: flex; min-width: 0; }
    .export-toolbar .chip-radio input { width: 1px; height: 1px; min-height: 0; padding: 0; margin: 0; }
    .export-toolbar .chip-radio span { flex: 1; min-width: 0; justify-content: center; min-height: 42px; white-space: nowrap; }
    .export-grid { grid-template-columns: 1fr; gap: 0.75rem; }
    .export-card { padding: 1rem; }
    .export-card-actions { flex-direction: column; }
    .export-card-actions .btn { flex: none; width: 100%; min-height: 44px; }
    .export-note { font-size: var(--ds-text-xs); }

    .invoices-toolbar { flex-direction: column; align-items: stretch; }
    .invoices-toolbar .segmented { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; max-width: 100%; }
    .invoices-toolbar .toolbar-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
    .invoices-toolbar .toolbar-actions .btn { width: 100%; justify-content: center; min-height: 42px; }
}
@media (min-width: 769px) and (max-width: 1100px) {
    .export-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ─── ۲۱. ویرایشگر نقش: ورود مستقل و نوع نقش ───────────────── */
.role-login-note {
    display: flex; align-items: flex-start; gap: 0.75rem; margin: 0.75rem 0;
    padding: 0.85rem 1rem; border-radius: var(--ds-radius-md);
    background: var(--ds-success-bg); border: 1px solid var(--ds-success-line);
    border-inline-start: 4px solid var(--ds-success-fg);
}
.role-login-note-icon { font-size: 1.4rem; line-height: 1; }
.role-login-note strong { display: block; margin-bottom: 0.15rem; }
.role-login-note small { display: block; color: var(--ds-text-2); line-height: var(--ds-leading-body); }
.role-type-picker { border: 0; margin: 0.25rem 0 0.75rem; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
.role-type-picker legend { grid-column: 1 / -1; margin-bottom: 0.4rem; font-weight: 700; font-size: var(--ds-text-md); color: var(--ds-text-2); }
.role-type-option { position: relative; cursor: pointer; display: block; }
.role-type-option input { position: absolute; opacity: 0; inset: 0; margin: 0; pointer-events: none; }
.role-type-card {
    display: grid; grid-template-columns: auto 1fr; gap: 0.15rem 0.65rem; align-items: center; height: 100%;
    padding: 0.85rem 0.95rem; border-radius: var(--ds-radius-md);
    border: 1.5px solid var(--ds-border); background: var(--ds-surface-sunken);
    transition: border-color var(--ds-dur-fast), background var(--ds-dur-fast), box-shadow var(--ds-dur-fast);
}
.role-type-icon { grid-row: 1 / span 2; font-size: 1.5rem; }
.role-type-card small { color: var(--ds-text-2); line-height: 1.7; }
.role-type-option:hover .role-type-card { border-color: var(--ds-border-strong); }
.role-type-option input:checked + .role-type-card {
    border-color: var(--accent-light);
    background: color-mix(in srgb, var(--accent) 12%, var(--ds-surface-sunken));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.role-type-option input:focus-visible + .role-type-card { outline: 2px solid var(--ds-focus-color); outline-offset: 2px; }
.role-type-option.is-disabled { cursor: not-allowed; }
.role-type-option.is-disabled .role-type-card { opacity: 0.55; }
.secretary-role-section { padding: 14px; margin: 0 0 12px; }
@media (max-width: 600px) { .role-type-picker { grid-template-columns: 1fr; } }
