/* ═══════════════════════════════════════════════
   Font: Vazirmatn (Local — بدون نیاز به اینترنت)
   ═══════════════════════════════════════════════ */
@font-face {
    font-family: 'Vazirmatn';
    src: url('/fonts/Vazirmatn-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Vazirmatn';
    src: url('/fonts/Vazirmatn-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* ─── اعمال روی کل برنامه ─── */
body, input, button, select, textarea {
    font-family: 'Vazirmatn', Tahoma, Arial, sans-serif;
}


/* ═══════════════ متغیرها ═══════════════ */
:root {
    --primary: #4F46E5;
    --primary-dark: #4338CA;
    --primary-light: #EEF2FF;
    --success: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;
    --bg: #F3F4F6;
    --card: #FFFFFF;
    --text: #111827;
    --text-muted: #6B7280;
    --border: #E5E7EB;
    --sidebar-bg: #1F2937;
    --sidebar-hover: #374151;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-width: 240px;
    --topbar-height: 64px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

.hidden {
    display: none !important;
}

.muted {
    color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════
   LOGIN v2 — طراحی حرفه‌ای
   ═══════════════════════════════════════════════════ */

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    position: relative;
    overflow: hidden;
    background: #0F0B2E;
    background: linear-gradient(135deg, #0F0B2E 0%, #1E1B4B 50%, #312E81 100%);
}

/* ═══ تزئینات پس‌زمینه ═══ */
.login-decor {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.ld-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    animation: blobFloat 20s ease-in-out infinite;
}

.ld-blob-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #7C3AED 0%, transparent 70%);
    top: -150px;
    right: -100px;
    animation-delay: 0s;
}

.ld-blob-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #4F46E5 0%, transparent 70%);
    bottom: -100px;
    left: -100px;
    animation-delay: -7s;
}

.ld-blob-3 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, #EC4899 0%, transparent 70%);
    top: 40%;
    left: 40%;
    animation-delay: -14s;
    opacity: 0.25;
}

@keyframes blobFloat {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(30px, -40px) scale(1.1);
    }

    66% {
        transform: translate(-30px, 30px) scale(0.95);
    }
}

/* گرید نقطه‌ای */
.ld-grid {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(255,255,255,0.08) 1px, transparent 1px);
    background-size: 24px 24px;
    mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
    -webkit-mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
}

/* ═══ کارت اصلی ═══ */
.login-card-v2 {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 420px 460px;
    background: #fff;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 40px 80px -20px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
    max-width: 100%;
    animation: loginCardIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes loginCardIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ═══ ستون برند ═══ */
.login-brand-panel {
    background: linear-gradient(160deg, #1E1B4B 0%, #4F46E5 100%);
    color: #fff;
    padding: 40px 32px;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

    .login-brand-panel::before {
        content: '';
        position: absolute;
        inset: 0;
        background-image: radial-gradient(circle at 20% 20%, rgba(124, 58, 237, 0.4), transparent 40%), radial-gradient(circle at 80% 80%, rgba(236, 72, 153, 0.25), transparent 40%);
        pointer-events: none;
    }

    .login-brand-panel > * {
        position: relative;
        z-index: 1;
    }

/* لوگو */
.login-brand-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
}

    .login-brand-logo .logo-circle {
        width: 56px;
        height: 56px;
        font-size: 22px;
        background: rgba(255, 255, 255, 0.12);
        backdrop-filter: blur(10px);
        border: 1px solid rgba(255, 255, 255, 0.2);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    }

.login-brand-names {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.login-brand-name-main {
    font-size: 17px !important;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.3px;
    white-space: nowrap;
}

.login-brand-name-sub {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 500;
    letter-spacing: 1.2px;
    text-transform: uppercase;
}

/* عنوان */
.login-brand-heading {
    margin-bottom: 32px;
}

    .login-brand-heading h1 {
        font-size: 24px;
        font-weight: 800;
        color: #fff;
        margin: 0 0 8px;
        line-height: 1.3;
        letter-spacing: -0.3px;
    }

    .login-brand-heading p {
        font-size: 13px;
        color: rgba(255, 255, 255, 0.7);
        margin: 0;
        font-weight: 400;
    }

/* ویژگی‌ها */
.login-brand-features {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    flex: 1;
}

    .login-brand-features li {
        display: flex;
        align-items: center;
        gap: 12px;
        font-size: 12.5px;
    }

.lbf-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.login-brand-features li > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.login-brand-features strong {
    font-size: 13px;
    font-weight: 700;
    color: #fff;
}

.login-brand-features small {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
}

/* فوتر */
/*.login-brand-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 11px;
    color: rgba(255, 255, 255, 0.55);
}*/

    .login-brand-footer a {
        color: rgba(255, 255, 255, 0.8);
        text-decoration: none;
        font-weight: 600;
        transition: color 0.15s;
    }

        .login-brand-footer a:hover {
            color: #fff;
            text-decoration: underline;
        }

/* ═══ ستون فرم ═══ */
.login-form-panel {
    padding: 40px 36px;
    display: flex;
    flex-direction: column;
    background: #fff;
    min-width: 0;
}

/* Mobile brand */
.login-mobile-brand {
    display: none;
}

/* ═══ لایسنس ═══ */
.license-status {
    margin-bottom: 20px;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 11.5px; /* ← کوچیک‌تر */
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.4;
    /* ⭐ جدید: تک‌خطی */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    animation: licenseIn 0.3s ease;
    /**/
    white-space: normal !important; /* ⭐ اجازه‌ی شکستن خط */
    word-break: break-word !important; /* ⭐ کلمات بلند رو بشکن */
    overflow-wrap: anywhere !important; /* ⭐ حتی وسط کلمه */
    line-height: 1.6 !important; /* ⭐ فاصله‌ی خطوط */
    max-width: 100% !important;
    display: block !important;
}

@keyframes licenseIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.license-status.license-valid {
    background: #ECFDF5;
    color: #065F46;
    border: 1px solid #A7F3D0;
}

.license-status.license-invalid {
    background: #FEF2F2;
    color: #991B1B;
    border: 1px solid #FECACA;
}

.license-status.license-loading {
    background: #EFF6FF;
    color: #1E40AF;
    border: 1px solid #BFDBFE;
}

.license-status::before {
    font-size: 16px;
    flex-shrink: 0;
}

.license-status.license-valid::before {
    content: '✅';
}

.license-status.license-invalid::before {
    content: '⚠️';
}

.license-status.license-loading::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #BFDBFE;
    border-top-color: #1E40AF;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@media (max-width: 768px) {
    .license-status {
        white-space: normal;
        font-size: 11px;
        line-height: 1.5;
    }
}

/* ═══ Header فرم ═══ */
.login-form-header {
    margin-bottom: 24px;
}

    .login-form-header h2 {
        font-size: 22px;
        font-weight: 800;
        color: #0F172A;
        margin: 0 0 6px;
        letter-spacing: -0.3px;
    }

    .login-form-header p {
        font-size: 13px;
        color: #64748B;
        margin: 0;
    }

/* ═══ فرم ═══ */
.login-form-v2 {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
}

.lf-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.lf-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

    .lf-field label {
        display: flex;
        align-items: center;
        gap: 6px;
        font-size: 12.5px;
        font-weight: 600;
        color: #334155;
    }

.lf-icon {
    font-size: 13px;
    line-height: 1;
}

.lf-field input,
.lf-field select {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid #E2E8F0;
    border-radius: 10px;
    font-family: inherit;
    font-size: 13.5px;
    background: #fff;
    color: #0F172A;
    transition: all 0.15s;
    box-sizing: border-box;
    min-height: 42px;
}

    .lf-field input::placeholder {
        color: #94A3B8;
    }

    .lf-field input:focus,
    .lf-field select:focus {
        outline: none;
        border-color: #4F46E5;
        box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
        background: #FEFEFF;
    }

.lf-field select {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg 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'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: left 14px center;
    padding-left: 36px;
}

/* Password toggle */
.lf-password-wrap {
    position: relative;
    display: flex;
}

    .lf-password-wrap input {
        padding-left: 42px;
    }

.lf-pwd-toggle {
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    font-size: 15px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    opacity: 0.55;
    transition: all 0.15s;
}

    .lf-pwd-toggle:hover {
        opacity: 1;
        background: #F1F5F9;
    }

/* ═══ دکمه ورود ═══ */
.btn-login {
    width: 100%;
    padding: 13px 20px;
    margin-top: 4px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    box-shadow: 0 8px 20px -4px rgba(79, 70, 229, 0.4);
    position: relative;
    overflow: hidden;
}

    .btn-login::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
        transition: left 0.5s;
    }

    .btn-login:hover:not(:disabled)::before {
        left: 100%;
    }

    .btn-login:hover:not(:disabled) {
        transform: translateY(-1px);
        box-shadow: 0 12px 24px -4px rgba(79, 70, 229, 0.5);
    }

    .btn-login:active:not(:disabled) {
        transform: translateY(0);
    }

    .btn-login:disabled {
        opacity: 0.7;
        cursor: not-allowed;
    }

.btn-login-arrow {
    font-size: 16px;
    transition: transform 0.2s;
}

.btn-login:hover:not(:disabled) .btn-login-arrow {
    transform: translateX(-4px);
}

/* ═══ Footer فرم ═══ */
.login-form-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #F1F5F9;
    font-size: 11.5px;
    color: #94A3B8;
}

/* ═══ ریسپانسیو ═══ */
@media (max-width: 900px) {
    .login-wrapper {
        padding: 16px;
    }

    .login-card-v2 {
        grid-template-columns: 1fr;
        max-width: 460px;
        border-radius: 20px;
    }

    .login-brand-panel {
        display: none;
    }

    .login-mobile-brand {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-bottom: 20px;
        padding-bottom: 20px;
        border-bottom: 1px solid #F1F5F9;
    }

        .login-mobile-brand .logo-circle {
            width: 40px;
            height: 40px;
            font-size: 16px;
            background: linear-gradient(135deg, #4F46E5, #7C3AED);
            color: #fff;
        }

        .login-mobile-brand span {
            font-size: 14px;
            font-weight: 700;
            color: #0F172A;
        }

    .login-form-panel {
        padding: 28px 24px;
    }
}

@media (max-width: 480px) {
    .login-wrapper {
        padding: 0;
    }

    .login-card-v2 {
        max-width: 100%;
        border-radius: 0;
        min-height: 100vh;
    }

    .login-form-panel {
        padding: 24px 20px;
    }

    .lf-row {
        grid-template-columns: 1fr;
    }

    .login-form-header h2 {
        font-size: 20px;
    }
}

/* ═══════════════ دکمه‌ها ═══════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: none;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

    .btn-primary:hover {
        background: var(--primary-dark);
    }

    .btn-primary:disabled {
        opacity: 0.6;
        cursor: not-allowed;
    }

.btn-ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

    .btn-ghost:hover {
        background: var(--bg);
    }

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.error-box {
    background: #FEF2F2;
    color: var(--danger);
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-top: 12px;
    border: 1px solid #FECACA;
}

/* ═══════════════════════════════════════════════════
   APP LAYOUT — Responsive
   ═══════════════════════════════════════════════════ */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* ═══════════════ Sidebar ═══════════════ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #E5E7EB;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0; /* RTL: from right side */
    z-index: 1000;
    transition: transform var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid #374151;
    min-height: var(--topbar-height);
    position: relative;
}

.logo-mini {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
}

.sidebar-title {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

    .sidebar-title > span {
        font-weight: 700;
        font-size: 16px;
        color: white;
    }

    .sidebar-title small {
        font-size: 11px;
        color: #9CA3AF;
        font-weight: 400;
    }

.sidebar-close {
    display: none;
    background: transparent;
    border: none;
    color: #9CA3AF;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.15s;
}

    .sidebar-close:hover {
        background: var(--sidebar-hover);
        color: white;
    }

/* ═══════════════ Nav ═══════════════ */
.nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 16px 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: #D1D5DB;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.18s;
    text-decoration: none;
    user-select: none;
    position: relative;
}

    .nav-item:hover {
        background: var(--sidebar-hover);
        color: white;
        transform: translateX(-2px);
    }

    .nav-item.active {
        background: linear-gradient(90deg, var(--primary), var(--primary-dark));
        color: white;
        box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
    }

        .nav-item.active::before {
            content: '';
            position: absolute;
            right: -12px;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 60%;
            background: #A5B4FC;
            border-radius: 2px;
        }

.nav-icon {
    font-size: 18px;
    line-height: 1;
}

.nav-label {
    flex: 1;
}

.nav-divider {
    height: 1px;
    background: #374151;
    margin: 8px 14px;
}

/* ═══════════════ User Mini (Sidebar footer) ═══════════════ */
.user-mini {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #374151;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.user-mini-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.user-mini-info {
    flex: 1;
    min-width: 0;
}

.user-mini-name {
    font-size: 13px;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-mini-org {
    font-size: 11px;
    color: #9CA3AF;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid #374151;
}

    .sidebar-footer .btn-ghost {
        color: #D1D5DB;
        border-color: #374151;
    }

        .sidebar-footer .btn-ghost:hover {
            background: var(--sidebar-hover);
            color: white;
        }

/* ═══════════════ Overlay ═══════════════ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity var(--transition);
    backdrop-filter: blur(2px);
}

    .sidebar-overlay.active {
        opacity: 1;
    }

/* ═══════════════ Main ═══════════════ */
.main {
    flex: 1;
    margin-right: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
    transition: margin var(--transition);
}

/* ═══════════════ Topbar ═══════════════ */
.topbar {
    background: var(--card);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: var(--topbar-height);
    box-shadow: var(--shadow-sm);
}

    .topbar h2 {
        font-size: 18px;
        font-weight: 600;
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

.topbar-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}

    .topbar-btn:hover {
        background: var(--primary-light);
        border-color: var(--primary);
    }

    .topbar-btn.hamburger {
        display: none;
        font-size: 22px;
    }

        .topbar-btn.hamburger:hover {
            transform: none;
        }

#btnSettings:hover {
    transform: rotate(45deg);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 15px;
    flex-shrink: 0;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
}

.user-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.content {
    padding: 24px;
    flex: 1;
    min-width: 0;
}

/* ═══════════════ Cards ═══════════════ */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

    .card-title > div {
        display: flex;
        align-items: center;
        gap: 8px;
    }

/* ═══════════════ Stats ═══════════════ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.15s;
}

    .stat-card:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow);
    }

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: var(--primary-light);
    flex-shrink: 0;
}

    .stat-icon.green {
        background: #D1FAE5;
    }

    .stat-icon.orange {
        background: #FEF3C7;
    }

    .stat-icon.purple {
        background: #EDE9FE;
    }

.stat-value {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
}

/* ═══════════════ Filters ═══════════════ */
.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

    .filters .form-group {
        margin-bottom: 0;
    }

/* ═══════════════ Radio Group ═══════════════ */
.radio-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 4px 0;
}

.radio-item {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 500;
    padding: 8px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    transition: all 0.15s;
    user-select: none;
    background: white;
}

    .radio-item:hover {
        border-color: var(--primary);
        background: var(--primary-light);
    }

    .radio-item input[type="radio"] {
        cursor: pointer;
        accent-color: var(--primary);
    }

    .radio-item:has(input[type="radio"]:checked) {
        border-color: var(--primary);
        background: var(--primary-light);
        color: var(--primary);
        font-weight: 600;
    }

/* ═══════════════ Table ═══════════════ */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--card);
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead {
    background: #F9FAFB;
}

th {
    padding: 12px 14px;
    text-align: right;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr {
    transition: background 0.1s;
}

    tbody tr:hover {
        background: #F9FAFB;
    }

    tbody tr:last-child td {
        border-bottom: none;
    }

tfoot td {
    padding: 12px 14px;
    border-bottom: none;
}

.num {
    font-variant-numeric: tabular-nums;
}

.text-left {
    text-align: left;
}

.text-center {
    text-align: center;
}

/* ═══════════════ Badge ═══════════════ */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.badge-success {
    background: #D1FAE5;
    color: #065F46;
}

.badge-warning {
    background: #FEF3C7;
    color: #92400E;
}

.badge-danger {
    background: #FEE2E2;
    color: #991B1B;
}

.badge-info {
    background: #DBEAFE;
    color: #1E40AF;
}

.badge-gray {
    background: #F3F4F6;
    color: #374151;
}

/* ═══════════════ Modal ═══════════════ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(2px);
}

.modal-box {
    position: relative;
    background: var(--card);
    border-radius: var(--radius);
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.96);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

    .modal-header h3 {
        font-size: 16px;
        font-weight: 600;
    }

.modal-close {
    background: none;
    border: none;
    font-size: 26px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: 0 8px;
    border-radius: 6px;
}

    .modal-close:hover {
        color: var(--text);
        background: var(--bg);
    }

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

/* ═══════════════ Loading ═══════════════ */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.spinner {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* ═══════════════ Toast ═══════════════ */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #1F2937;
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 3000;
    font-size: 14px;
    animation: slideUp 0.3s;
    max-width: calc(100% - 32px);
}

    .toast.success {
        background: var(--success);
    }

    .toast.error {
        background: var(--danger);
    }

@keyframes slideUp {
    from {
        transform: translate(-50%, 100%);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

/* ═══════════════ Pagination ═══════════════ */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    font-size: 13px;
}

    .pagination button {
        padding: 6px 12px;
        border-radius: 6px;
        border: 1px solid var(--border);
        background: white;
        cursor: pointer;
        font-family: inherit;
        font-size: 13px;
    }

        .pagination button:hover:not(:disabled) {
            background: var(--primary-light);
            border-color: var(--primary);
        }

        .pagination button:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

.pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    padding: 12px 16px;
    background: #F9FAFB;
    border-radius: 10px;
    flex-wrap: wrap;
    gap: 12px;
}

.pagination-info {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.page-btn {
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: white;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    touch-action: manipulation;
}

    .page-btn:hover:not(:disabled):not(.active) {
        background: var(--primary-light);
        border-color: var(--primary);
        color: var(--primary);
    }

    .page-btn.active {
        background: var(--primary);
        border-color: var(--primary);
        color: white;
        font-weight: 600;
    }

    .page-btn:disabled {
        opacity: 0.4;
        cursor: not-allowed;
    }

/* ═══════════════ Info Grid ═══════════════ */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 24px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px dashed var(--border);
    gap: 12px;
}

    .info-item:nth-last-child(-n+2) {
        border-bottom: none;
    }

.info-label {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

.info-value {
    font-weight: 600;
    font-size: 14px;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.info-meta {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 400;
}

.db-code {
    background: #EEF2FF;
    color: #4338CA;
    padding: 4px 10px;
    border-radius: 6px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12.5px;
    direction: ltr;
    font-weight: 600;
}

/* ═══════════════ Quick Actions ═══════════════ */
/*.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.quick-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: #F9FAFB;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text);
    transition: all 0.15s;
    text-align: right;
    touch-action: manipulation;
}

    .quick-btn:hover {
        background: var(--primary-light);
        border-color: var(--primary);
        transform: translateY(-2px);
        box-shadow: var(--shadow);
    }

.quick-icon {
    font-size: 22px;
    line-height: 1;
}*/

/* ═══════════════ Export Bar ═══════════════ */
.export-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    margin: 12px 0 4px;
    padding: 10px 0;
    border-top: 1px dashed var(--border);
}

    .export-bar button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        padding: 7px 14px;
        font-family: inherit;
        font-size: 12.5px;
        font-weight: 500;
        border-radius: 8px;
        border: 1px solid var(--border);
        background: #fff;
        color: var(--text);
        cursor: pointer;
        transition: all 0.15s;
    }

        .export-bar button:hover {
            background: #EEF2FF;
            border-color: var(--primary);
            color: var(--primary);
            transform: translateY(-1px);
        }

/* ═══════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════ */

/* ═══ Tablet (≤ 1024px) ═══ */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 220px;
    }

    .content {
        padding: 20px;
    }

    .filters {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }
}

/* ═══ Mobile (≤ 768px) — منوی کشویی ═══ */
@media (max-width: 768px) {

    /* Sidebar مخفی، از راست باز می‌شود */
    .sidebar {
        transform: translateX(100%);
        width: 280px;
        box-shadow: var(--shadow-lg);
    }

        .sidebar.open {
            transform: translateX(0);
        }

    .sidebar-close {
        display: block;
    }

    /* Overlay فعال می‌شود */
    .sidebar-overlay {
        display: block;
        pointer-events: none;
    }

        .sidebar-overlay.active {
            pointer-events: auto;
        }

    /* Main تمام عرض */
    .main {
        margin-right: 0;
    }

    /* همبرگر نمایش داده می‌شود */
    .topbar-btn.hamburger {
        display: flex;
    }

    /* یوزر متا مخفی */
    .user-meta-desktop {
        display: none;
    }

    /* Padding کمتر */
    .topbar {
        padding: 10px 16px;
    }

        .topbar h2 {
            font-size: 16px;
        }

    .content {
        padding: 16px;
    }

    /* کارت‌ها */
    .card {
        padding: 16px;
        border-radius: 10px;
    }

    /* Stats */
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 12px;
    }

    .stat-card {
        padding: 14px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .stat-icon {
        width: 42px;
        height: 42px;
        font-size: 20px;
    }

    .stat-value {
        font-size: 20px;
    }

    /* فیلترها تمام عرض */
    .filters {
        grid-template-columns: 1fr;
    }

    /* Info Grid تک ستون */
    .info-grid {
        grid-template-columns: 1fr;
    }

    .info-item:nth-last-child(-n+2) {
        border-bottom: 1px dashed var(--border);
    }

    .info-item:last-child {
        border-bottom: none;
    }

    /* Radio Group */
    .radio-group {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .radio-item {
        justify-content: center;
        padding: 10px 8px;
        font-size: 13px;
    }

    /* Export Bar */
    .export-bar {
        flex-direction: column-reverse;
        align-items: stretch;
    }

        .export-bar button {
            width: 100%;
            justify-content: center;
        }

    /* Quick actions */
    /*.quick-actions {
        grid-template-columns: 1fr 1fr;
    }*/

    /* Modal */
    .modal {
        padding: 0;
    }

    .modal-box {
        max-width: 100%;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
    }

    /* Table: کوچک‌تر */
    table {
        font-size: 12px;
    }

    th {
        padding: 10px 8px;
        font-size: 11px;
    }

    td {
        padding: 10px 8px;
    }

    /* Pagination */
    .pagination-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .pagination-info {
        text-align: center;
    }

    .pagination-controls {
        justify-content: center;
    }

    .page-btn {
        min-width: 32px;
        height: 32px;
        padding: 0 8px;
        font-size: 12px;
    }

    /* کارت title */
    .card-title {
        font-size: 14px;
    }

    /* user-avatar کوچک */
    .user-avatar {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .topbar-btn {
        width: 38px;
        height: 38px;
    }
}

/* ═══ Small phones (≤ 480px) ═══ */
@media (max-width: 480px) {
    .content {
        padding: 12px;
    }

    .topbar {
        padding: 10px 12px;
    }

        .topbar h2 {
            font-size: 15px;
        }

    .stats-grid {
        grid-template-columns: 1fr;
    }

 /*   .quick-actions {
        grid-template-columns: 1fr;
    }*/

    .radio-group {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 14px;
    }

    /*   .login-card {
        padding: 28px 20px;
    }*/

    .form-row {
        grid-template-columns: 1fr;
    }

    .page-btn {
        min-width: 30px;
        height: 30px;
        padding: 0 6px;
        font-size: 11px;
    }

    /* مخفی کردن صفحه‌های میانی در pagination */
    .pagination-controls .page-btn.dots {
        display: none;
    }
}

/* ═══ Landscape موبایل ═══ */
@media (max-width: 900px) and (orientation: landscape) {
    .sidebar {
        width: 260px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ═══ Safe area (نچ‌بار پایین در آیفون/اندروید) ═══ */
@supports (padding: env(safe-area-inset-bottom)) {
    .sidebar-footer {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }

    .toast {
        bottom: calc(24px + env(safe-area-inset-bottom));
    }
}

/* ═══ Print ═══ */
@media print {
    .sidebar, .topbar, .export-bar, .pagination-bar, button {
        display: none !important;
    }

    .main {
        margin-right: 0;
    }

    .content {
        padding: 0;
    }

    .card {
        box-shadow: none;
        border: none;
    }
}
/* ═══════════════ Logo با تصویر ═══════════════ */
.logo-circle,
.logo-mini {
    position: relative;
    overflow: hidden;
    cursor: default;
}

    .logo-circle img,
    .logo-mini img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        border-radius: inherit;
        display: block;
    }

    .logo-circle .logo-text,
    .logo-mini .logo-text {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100%;
    }

    /* وقتی تصویر لود شد، متن مخفی می‌شه */
    .logo-circle.has-image .logo-text,
    .logo-mini.has-image .logo-text {
        display: none;
    }

/* ═══════════════ Logo Uploader (Settings) ═══════════════ */
.logo-uploader {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 16px;
    background: #F9FAFB;
    border-radius: 12px;
    border: 2px dashed var(--border);
    margin-bottom: 20px;
    transition: all 0.15s;
}

    .logo-uploader:hover {
        border-color: var(--primary);
        background: var(--primary-light);
    }

.logo-preview {
    width: 80px;
    height: 80px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 32px;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
    box-shadow: var(--shadow);
}

    .logo-preview img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

.logo-upload-info {
    flex: 1;
    min-width: 0;
}

    .logo-upload-info h4 {
        font-size: 14px;
        font-weight: 600;
        margin-bottom: 4px;
    }

    .logo-upload-info p {
        font-size: 12px;
        color: var(--text-muted);
        margin-bottom: 10px;
        line-height: 1.5;
    }

.logo-upload-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

    .logo-upload-actions button {
        padding: 6px 12px;
        font-size: 12px;
        border-radius: 6px;
        border: 1px solid var(--border);
        background: white;
        cursor: pointer;
        font-family: inherit;
        transition: all 0.15s;
    }

        .logo-upload-actions button:hover {
            background: var(--primary-light);
            border-color: var(--primary);
            color: var(--primary);
        }

    .logo-upload-actions .btn-danger {
        color: var(--danger);
        border-color: #FECACA;
    }

        .logo-upload-actions .btn-danger:hover {
            background: #FEF2F2;
            border-color: var(--danger);
            color: var(--danger);
        }

/* حالت درگ */
.logo-uploader.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
    transform: scale(1.02);
}
/* ═══════════════ Factor Detail ═══════════════ */
.factor-header {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    padding: 16px;
    background: #F9FAFB;
    border-radius: 10px;
    margin-bottom: 16px;
}

.factor-header-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.factor-field {
    display: flex;
    gap: 6px;
    font-size: 13px;
    align-items: baseline;
}

.factor-field-wide {
    grid-column: 1 / -1;
}

.factor-label {
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
}

.factor-value {
    font-weight: 600;
    color: var(--text);
}

.factor-party {
    background: #EEF2FF;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 16px;
    border: 1px solid #C7D2FE;
}

    .factor-party h4 {
        font-size: 13px;
        color: #4338CA;
        margin-bottom: 10px;
        font-weight: 700;
    }

.factor-party-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
}

.factor-descript {
    background: #FEF3C7;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid #FDE68A;
    font-size: 13px;
    margin-bottom: 8px;
}

.factor-totals {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 16px;
    padding: 16px;
    background: #F9FAFB;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.factor-total-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
}

    .factor-total-item .factor-value {
        font-size: 15px;
        font-variant-numeric: tabular-nums;
    }

.factor-total-final {
    grid-column: 1 / -1;
    padding-top: 12px;
    border-top: 2px dashed #C7D2FE;
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
}

    .factor-total-final .factor-value {
        font-size: 18px;
        color: var(--primary);
    }

    .factor-party-grid {
        grid-template-columns: 1fr;
    }


/* ═══════════════ Form Select (RTL fix) ═══════════════ */
.form-select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    background-color: white;
    color: var(--text);
    cursor: pointer;
    min-height: 42px;
    /* RTL */
    direction: rtl;
    text-align: right;
    /* ✅ ظاهر پیش‌فرض رو حفظ کن — بذار مرورگر خودش مدیریت کنه */
    /* appearance رو دست نمی‌زنیم */

    transition: border-color 0.15s, box-shadow 0.15s;
}

    .form-select:hover {
        border-color: var(--primary);
    }

    .form-select:focus {
        outline: none;
        border-color: var(--primary);
        box-shadow: 0 0 0 3px var(--primary-light);
    }

    .form-select option {
        padding: 8px;
        font-family: inherit;
        direction: rtl;
        text-align: right;
    }

/* ═══════════════ Custom Select (RTL-safe) ═══════════════ */
.custom-select {
    position: relative;
    width: 100%;
}

.custom-select-trigger {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: white;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    text-align: right;
    min-height: 42px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

    .custom-select-trigger:hover {
        border-color: var(--primary);
    }

.custom-select.open .custom-select-trigger {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.custom-select-value {
    flex: 1;
    text-align: right;
}

.custom-select-arrow {
    color: var(--text-muted);
    font-size: 10px;
    transition: transform 0.15s;
}

.custom-select.open .custom-select-arrow {
    transform: rotate(180deg);
}

.custom-select-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.15);
    z-index: 100;
    max-height: 260px;
    overflow-y: auto;
    display: none;
    padding: 4px;
}

.custom-select.open .custom-select-menu {
    display: block;
}

.custom-select-option {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 14px;
    text-align: right;
    border-radius: 6px;
    transition: all 0.1s;
}

    .custom-select-option:hover {
        background: var(--primary-light);
        color: var(--primary);
    }

    .custom-select-option.selected {
        background: var(--primary);
        color: white;
        font-weight: 600;
    }
/* ═══════════════ Tree View (حساب‌ها) ═══════════════ */
.tree-container {
    background: white;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    font-size: 13px;
}

.tree-col {
    border-bottom: 1px solid var(--border);
}

    .tree-col:last-child {
        border-bottom: none;
    }

.tree-row {
    display: grid;
    grid-template-columns: 30px 60px minmax(180px, 1fr) auto 80px 130px 130px 130px;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    transition: background 0.1s;
    cursor: default;
}

.level-col {
    background: #EEF2FF;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 1px solid #C7D2FE;
}

    .level-col:hover {
        background: #E0E7FF;
    }

.level-moein {
    background: #F9FAFB;
    padding-right: 40px;
    border-bottom: 1px dashed var(--border);
}

    .level-moein:last-child {
        border-bottom: none;
    }

    .level-moein:hover {
        background: #F3F4F6;
    }

.tree-toggle {
    display: inline-block;
    font-size: 10px;
    color: var(--primary);
    transition: transform 0.15s;
    text-align: center;
}

.tree-indent {
    display: inline-block;
}

.tree-code {
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    font-size: 12px;
}

.level-col .tree-code {
    color: var(--primary);
    font-weight: 700;
    font-size: 13px;
}

.level-moein .tree-code {
    color: var(--text-muted);
    font-size: 12px;
}

.tree-name {
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.level-col .tree-name {
    font-weight: 700;
}

.tree-badges {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.tree-mahiat {
    text-align: center;
}

.tree-num {
    font-variant-numeric: tabular-nums;
    text-align: left;
    font-size: 12px;
}

.level-col .tree-num {
    font-weight: 600;
}

.tree-mandeh {
    color: var(--primary);
}

.tree-children {
    display: none;
}

    .tree-children.open {
        display: block;
    }

/* موبایل */
@media (max-width: 900px) {
    .tree-row {
        grid-template-columns: 30px 55px 1fr auto;
        font-size: 12px;
    }

    .tree-num,
    .tree-mahiat {
        display: none;
    }

    .level-col .tree-num,
    .level-col .tree-mahiat {
        display: none;
    }
}
/* ═══════════════ مانده - نمایش ═══════════════ */
.mandeh-dir {
    font-size: 10px;
    padding: 1px 4px;
    border-radius: 4px;
    background: rgba(0,0,0,0.08);
    margin-right: 4px;
    font-weight: 500;
}

/* سطر غیرعادی (مانده برعکس ماهیت) */
.tree-row.row-abnormal {
    background: #FEF2F2 !important;
    border-right: 3px solid #DC2626;
}

    .tree-row.row-abnormal:hover {
        background: #FEE2E2 !important;
    }

/* ردیف کل غیرعادی */
.tree-row.level-col.row-abnormal {
    background: #FEE2E2 !important;
}
/* ═══════════════ Taraz Drill-Down ═══════════════ */
.taraz-breadcrumb {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: white;
    border-radius: var(--radius);
    margin-bottom: 12px;
    border: 1px solid var(--border);
    flex-wrap: wrap;
    font-size: 13px;
}

    .taraz-breadcrumb .bc-item {
        color: var(--text);
        font-weight: 600;
    }

    .taraz-breadcrumb .bc-sep {
        color: var(--text-muted);
        font-size: 16px;
    }

    .taraz-breadcrumb .btn {
        padding: 5px 12px;
        font-size: 12px;
    }

/* ردیف‌های کلیک‌پذیر */
.taraz-row-drill {
    transition: background 0.1s;
}

    .taraz-row-drill:hover {
        background: #EEF2FF !important;
    }

        .taraz-row-drill:hover .drill-icon {
            transform: scale(1.2);
            color: var(--primary);
        }

.drill-icon {
    font-size: 14px;
    color: var(--text-muted);
    transition: all 0.15s;
    display: inline-block;
}
/* ═══════════════ ردیف‌های کلیک‌پذیر ═══════════════ */
.clickable-row {
    cursor: pointer;
    transition: background 0.1s;
}

    .clickable-row:hover {
        background: #EEF2FF !important;
    }

        .clickable-row:hover td {
            color: var(--primary);
        }

    .clickable-row:active {
        background: #E0E7FF !important;
    }

/* موبایل: تک‌ستونی */
@media (max-width: 768px) {
    .dash-charts {
        grid-template-columns: 1fr;
        gap: 12px;
    }

        .dash-charts .card:nth-child(3) {
            grid-column: auto;
        }

    .chart-wrapper {
        height: 240px;
    }
}
/* ⭐ ستون‌های عددی در RTL — بدون چسبیدن به هم */
table .num-col {
    text-align: left !important;
    direction: ltr !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
    white-space: nowrap;
    border-left: 1px solid #E5E7EB;
}

/* ⭐ ستون‌های کد — وسط‌چین و کم‌عرض */
table .code-col {
    text-align: center !important;
    direction: ltr !important;
    padding: 6px 8px;
    white-space: nowrap;
}

/* ⭐ جدول دفتر روزنامه — بدهکار و بستانکار کاملاً جدا */
.daybook-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

    .daybook-table .code-col {
        text-align: center !important;
        direction: ltr !important;
        padding: 8px 10px;
        white-space: nowrap;
        background: #FAFBFC;
        border-left: 1px solid #E5E7EB;
    }

    .daybook-table .num-col {
        text-align: left !important;
        direction: ltr !important;
        padding: 8px 14px;
        white-space: nowrap;
        font-variant-numeric: tabular-nums;
        font-family: 'Tahoma', sans-serif;
    }

    /* ⭐ خط ضخیم بین بدهکار و بستانکار */
    .daybook-table th.num-col:first-of-type,
    .daybook-table td.num-col:first-of-type {
        border-right: 3px solid #4F46E5 !important;
    }

    /* ⭐ همه‌ی ستون‌های عددی خط چپ دارن */
    .daybook-table th.num-col,
    .daybook-table td.num-col {
        border-left: 1px solid #E5E7EB;
    }

    /* ⭐ هدر ستون‌ها */
    .daybook-table thead th {
        background: #EEF2FF;
        font-weight: 700;
        color: #3730A3;
        padding: 10px 12px;
        border-bottom: 2px solid #4F46E5;
    }

    /* ⭐ ردیف‌ها */
    .daybook-table tbody tr:nth-child(even) {
        background: #FAFBFC;
    }
/* ═══════════════ Nav Groups ═══════════════ */
.nav-group {
    margin-bottom: 4px;
}

.nav-group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: #9CA3AF;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    user-select: none;
    transition: all 0.15s;
}

    .nav-group-header:hover {
        background: rgba(255, 255, 255, 0.04);
        color: #D1D5DB;
    }

.nav-group-icon {
    font-size: 13px;
    line-height: 1;
}

.nav-group-label {
    flex: 1;
}

.nav-group-arrow {
    font-size: 9px;
    transition: transform 0.2s;
    opacity: 0.6;
}

.nav-group.collapsed .nav-group-arrow {
    transform: rotate(-90deg);
}

.nav-group-items {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
    max-height: 800px;
    transition: max-height 0.28s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s;
    opacity: 1;
}

.nav-group.collapsed .nav-group-items {
    max-height: 0;
    opacity: 0;
}

/* ظرافت روی nav-item های داخل گروه */
.nav-group-items .nav-item {
    padding: 9px 14px 9px 18px;
    font-size: 13.5px;
}

    .nav-group-items .nav-item .nav-icon {
        font-size: 16px;
        width: 20px;
        text-align: center;
    }
/* ═══════════════ بهبود جدول‌ها ═══════════════ */

/* ردیف‌های راه‌راه ملایم */
.table-wrapper table tbody tr:nth-child(even) {
    background: #FAFBFC;
}

.table-wrapper table tbody tr:hover {
    background: #EEF2FF !important;
    transition: background 0.1s;
}

/* هدر چسبان (sticky) */
.table-wrapper table thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #F9FAFB;
    box-shadow: inset 0 -1px 0 #E5E7EB;
}

/* جداکننده‌ی عمودی ظریف */
.table-wrapper table th:not(:last-child),
.table-wrapper table td:not(:last-child) {
    border-left: 1px solid #F3F4F6;
}

/* اسکرول‌بار زیبا */
.table-wrapper::-webkit-scrollbar {
    height: 10px;
    width: 10px;
}

.table-wrapper::-webkit-scrollbar-track {
    background: #F9FAFB;
    border-radius: 6px;
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: #D1D5DB;
    border-radius: 6px;
    border: 2px solid #F9FAFB;
}

    .table-wrapper::-webkit-scrollbar-thumb:hover {
        background: #9CA3AF;
    }

/* ═══════════════ Topbar polish ═══════════════ */
.topbar {
    backdrop-filter: blur(8px);
    background: rgba(255, 255, 255, 0.92);
}

/* ═══════════════ Card hover ظریف ═══════════════ */
.card {
    transition: box-shadow 0.18s, border-color 0.18s;
}

    .card:hover {
        border-color: #E0E7FF;
    }

/* ═══════════════ دکمه‌ها ═══════════════ */
.btn {
    position: relative;
    overflow: hidden;
}

    .btn:active:not(:disabled) {
        transform: translateY(1px);
    }

.btn-primary {
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25);
}

    .btn-primary:hover:not(:disabled) {
        box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
    }
/* ═══════════════ اضافات FormBuilder + FilterPanel ═══════════════ */
.fb-custom-select,
.fp-custom-select {
    position: relative;
    width: 100%;
}

    .fb-custom-select .custom-select-trigger,
    .fp-custom-select .custom-select-trigger {
        min-height: 42px;
    }

    .fp-custom-select .custom-select-trigger {
        min-height: 40px;
        font-size: 13.5px;
        padding: 9px 12px;
    }

    .fb-custom-select .custom-select-menu,
    .fp-custom-select .custom-select-menu {
        max-height: 240px;
    }
.fb-section-body {
    padding: 18px;
    /* overflow: hidden حذف شد */
}

.fb-section.collapsed .fb-section-body {
    display: none;
}
/* ═══════════════ SanadForm (Clean) ═══════════════ */
.sanad-form {
    padding: 4px;
    display: flex;
    flex-direction: column;
    max-height: calc(90vh - 80px);
}

/* ═══ Modal پهن ═══ */
.modal-box.wide-modal {
    max-width: 1400px;
}

/* ═══ Header ═══ */
.sanad-form-header {
    display: grid;
    grid-template-columns: 1.2fr 1.2fr 1fr 1fr;
    gap: 10px;
    padding: 12px;
    background: #F9FAFB;
    border-radius: 10px;
    margin-bottom: 12px;
    flex-shrink: 0;
}

    .sanad-form-header .sf-field-wide {
        grid-column: 1 / -1;
    }

/* ═══ Field ═══ */
.sf-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

    .sf-field label {
        font-size: 11px;
        color: #6B7280;
        font-weight: 500;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .sf-field .req {
        color: var(--danger);
    }

    .sf-field input,
    .sf-field select {
        padding: 6px 10px;
        border: 1px solid var(--border);
        border-radius: 6px;
        font-family: inherit;
        font-size: 13px;
        background: #fff;
        min-height: 34px;
        transition: all 0.15s;
    }

        .sf-field input:focus,
        .sf-field select:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px var(--primary-light);
        }

.sf-hint {
    color: var(--primary);
    font-weight: 400;
    font-size: 10.5px;
}

/* ═══ Rows header ═══ */
.sanad-form-rows-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-shrink: 0;
}

    .sanad-form-rows-header h4 {
        margin: 0;
        font-size: 14px;
        color: var(--text);
    }

/* ═══ Rows wrapper (scroll) ═══ */
#sfRowsWrap {
    flex: 1;
    overflow-y: auto;
    padding: 4px;
    min-height: 100px;
}

/* ═══ Row (2-line) ═══ */
.sf-row {
    display: flex;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    background: #fff;
    align-items: flex-start;
    transition: all 0.15s;
}

    .sf-row:hover {
        border-color: var(--primary);
        box-shadow: 0 2px 8px rgba(79,70,229,0.08);
    }

.sf-row-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    flex-shrink: 0;
    margin-top: 2px;
}

.sf-row-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.sf-line {
    display: grid;
    gap: 8px;
}

.sf-line-codes {
    grid-template-columns: 1.3fr 1.3fr 1fr 1fr;
}

.sf-line-values {
    grid-template-columns: 1fr 1fr 1fr 2fr;
}

.sf-row-del {
    background: transparent;
    border: 1px solid #FECACA;
    color: var(--danger);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    flex-shrink: 0;
    margin-top: 18px;
    transition: all 0.15s;
}

    .sf-row-del:hover {
        background: #FEF2F2;
        border-color: var(--danger);
        transform: scale(1.05);
    }

.num-input {
    text-align: left;
    direction: ltr;
    font-variant-numeric: tabular-nums;
}

/* ═══ Sticky footer ═══ */
.sanad-form-sticky {
    position: sticky;
    bottom: 0;
    background: #fff;
    border-top: 2px solid var(--border);
    padding-top: 8px;
    margin-top: 8px;
    z-index: 5;
    box-shadow: 0 -4px 8px rgba(0,0,0,0.04);
    flex-shrink: 0;
}

.sanad-form-totals {
    display: flex;
    gap: 20px;
    justify-content: flex-end;
    padding: 12px 16px;
    background: #F9FAFB;
    border-radius: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
    border: 1px solid var(--border);
}

.sf-total-item {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 13px;
}

    .sf-total-item strong {
        font-weight: 700;
        font-variant-numeric: tabular-nums;
    }

.sanad-form-footer {
    display: flex;
    gap: 10px;
    align-items: center;
    padding-bottom: 4px;
}
/*1*/


.sanad-row-count {
    margin-right: auto;
    font-size: 12px;
    color: var(--text-muted);
}

/* ═══ Row ناتراز ═══ */
tr.row-unbalanced {
    background: #FEF2F2 !important;
    border-right: 3px solid #DC2626;
}

    tr.row-unbalanced:hover {
        background: #FEE2E2 !important;
    }

/* ═══ هدر سورت‌پذیر ═══ */
th.sortable-th {
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
    white-space: nowrap;
}

    th.sortable-th:hover {
        background: #E0E7FF !important;
    }

/* ═══ Responsive ═══ */
@media (max-width: 900px) {
    .sanad-form-header {
        grid-template-columns: 1fr 1fr;
    }

    .sf-line-codes {
        grid-template-columns: 1fr 1fr;
    }

    .sf-line-values {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 600px) {
    .sanad-form-header {
        grid-template-columns: 1fr;
    }

    .sf-line-codes {
        grid-template-columns: 1fr;
    }

    .sf-line-values {
        grid-template-columns: 1fr;
    }

    .sf-row {
        flex-direction: column;
        align-items: stretch;
    }

    .sf-row-num {
        align-self: flex-start;
    }

    .sf-row-del {
        margin-top: 0;
        align-self: flex-end;
    }
}
/* ═══ Tafzil picker — input with button ═══ */
.sf-input-with-btn {
    display: flex;
    gap: 4px;
    align-items: stretch;
}

    .sf-input-with-btn input {
        flex: 1;
    }

.sf-pick-btn {
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.15s;
    flex-shrink: 0;
}

    .sf-pick-btn:hover {
        background: var(--primary-light);
        border-color: var(--primary);
    }

/* ═══ Tafzil picker — overlay modal ═══ */
.sf-picker-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    padding: 20px;
}

.sf-picker-box {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    overflow: hidden;
}

.sf-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 14px;
    background: #F9FAFB;
}

.sf-picker-close {
    background: transparent;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0 8px;
    border-radius: 6px;
}

    .sf-picker-close:hover {
        background: var(--bg);
    }

.sf-picker-search {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

    .sf-picker-search input {
        width: 100%;
        padding: 8px 12px;
        border: 1px solid var(--border);
        border-radius: 8px;
        font-family: inherit;
        font-size: 13px;
    }

        .sf-picker-search input:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px var(--primary-light);
        }

.sf-picker-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px;
}

.sf-picker-item {
    display: flex;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.1s;
}

    .sf-picker-item:hover {
        background: var(--primary-light);
    }

    .sf-picker-item.selected {
        background: var(--primary);
        color: white;
    }

.sf-picker-code {
    font-family: 'Consolas', monospace;
    font-weight: 700;
    color: var(--primary);
    min-width: 50px;
    direction: ltr;
}

.sf-picker-item.selected .sf-picker-code {
    color: white;
}

.sf-picker-name {
    flex: 1;
}

.sf-picker-empty {
    padding: 30px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* ═══ Picker — badges ═══ */
.sf-picker-badges {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
}

.sf-badge-mini {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    background: #DBEAFE;
    color: #1E40AF;
    font-weight: 500;
}

.sf-badge-stock {
    background: #FEF3C7;
    color: #92400E;
}

.sf-picker-parent {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ═══ meghdar اجباری برای انبار ═══ */
.sf-required-stock {
    background: #FFFBEB !important;
    border-color: #F59E0B !important;
}

    .sf-required-stock:focus {
        box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2) !important;
    }

.sf-stock-req {
    color: #92400E !important;
    font-weight: 600;
    font-size: 10px;
}

/* ═══ input disabled ═══ */
.sf-field input:disabled {
    background: #F3F4F6;
    color: #9CA3AF;
    cursor: not-allowed;
}


/* ═══════════════ Change Password ═══════════════ */
.pwd-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 4px;
}

.pwd-user-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: #EEF2FF;
    border-radius: 10px;
    border: 1px solid #C7D2FE;
}

.pwd-user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
}

.pwd-user-name {
    font-weight: 700;
    font-size: 14px;
    color: var(--text);
}

.pwd-user-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.pwd-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

    .pwd-field label {
        font-size: 12.5px;
        font-weight: 600;
        color: #4B5563;
    }

        .pwd-field label .req {
            color: var(--danger);
            margin-right: 2px;
        }

    .pwd-field input {
        padding: 10px 14px;
        border: 1px solid var(--border);
        border-radius: 8px;
        font-family: inherit;
        font-size: 14px;
        background: #fff;
        transition: all 0.15s;
        direction: ltr;
        text-align: left;
    }

        .pwd-field input:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px var(--primary-light);
        }

.pwd-error {
    background: #FEF2F2;
    color: #991B1B;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    border: 1px solid #FECACA;
}

.pwd-footer {
    display: flex;
    gap: 10px;
    padding-top: 12px;
    border-top: 2px solid var(--border);
    margin-top: 4px;
}

    .pwd-footer .btn {
        min-width: 110px;
    }
/* ═══════════════════════════════════════════════════
   Table → Card View (Mobile)
   ═══════════════════════════════════════════════════ */

@media (max-width: 768px) {

    /* جدول به بلوک تبدیل می‌شود */
    table.mobile-card-view {
        display: block;
        width: 100%;
        border: none;
        border-collapse: separate;
        border-spacing: 0;
        font-size: 13px;
    }

        /* هدر مخفی */
        table.mobile-card-view thead {
            display: none;
        }

        /* tbody به بلوک */
        table.mobile-card-view tbody {
            display: block;
        }

            /* هر ردیف = یک کارت */
            table.mobile-card-view tbody tr {
                display: block;
                background: #fff;
                border: 1px solid var(--border);
                border-radius: 12px;
                margin-bottom: 12px;
                padding: 12px 14px;
                box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
                transition: box-shadow 0.15s, border-color 0.15s;
                position: relative;
            }

                table.mobile-card-view tbody tr:hover {
                    border-color: var(--primary);
                    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.1);
                }

                /* ردیف‌های ناتراز */
                table.mobile-card-view tbody tr.row-unbalanced {
                    border-right: 4px solid #DC2626;
                    background: #FEF2F2;
                }

            /* هر سلول = یک ردیف داخل کارت */
            table.mobile-card-view tbody td {
                display: flex !important;
                justify-content: space-between;
                align-items: center;
                padding: 7px 0 !important;
                border: none !important;
                border-bottom: 1px dashed #F3F4F6 !important;
                text-align: right !important;
                font-size: 13px;
                white-space: normal !important;
                min-height: 32px;
                gap: 12px;
            }

                table.mobile-card-view tbody td:last-child {
                    border-bottom: none !important;
                    padding-bottom: 0 !important;
                }

                table.mobile-card-view tbody td:first-child {
                    padding-top: 0 !important;
                }

                /* Label از data-label */
                table.mobile-card-view tbody td::before {
                    content: attr(data-label);
                    font-weight: 600;
                    color: var(--text-muted);
                    font-size: 12px;
                    flex-shrink: 0;
                    min-width: 90px;
                    text-align: right;
                }

                /* وقتی label خالیه (ستون عملیات) */
                table.mobile-card-view tbody td.td-actions::before {
                    display: none;
                }

                /* ستون عملیات پایین کارت */
                table.mobile-card-view tbody td.td-actions {
                    justify-content: flex-end;
                    gap: 8px;
                    padding-top: 10px !important;
                    margin-top: 4px;
                    border-top: 1px dashed var(--border) !important;
                    border-bottom: none !important;
                }

                    /* دکمه‌های عملیات بزرگ‌تر در موبایل */
                    table.mobile-card-view tbody td.td-actions button {
                        min-width: 38px;
                        height: 38px;
                        font-size: 16px;
                        border-radius: 10px;
                        background: #F9FAFB;
                        border: 1px solid var(--border);
                    }

                        table.mobile-card-view tbody td.td-actions button:active {
                            background: var(--primary-light);
                            border-color: var(--primary);
                        }

                /* اعداد تراز درست */
                table.mobile-card-view tbody td.num {
                    font-variant-numeric: tabular-nums;
                    direction: ltr;
                    text-align: left !important;
                }

                /* اگه سلول‌ها عددی و label ندارن، جفت‌جفت نمایش */
                table.mobile-card-view tbody td:empty {
                    display: none !important;
                }

    /* جدول‌های داخل modal */
    .modal-body table.mobile-card-view tbody tr {
        background: #fff;
    }

    /* جدول‌های ساده که نمی‌خوایم کارتی بشن */
    table[data-no-card] {
        display: table;
    }

        table[data-no-card] thead {
            display: table-header-group;
        }

        table[data-no-card] tbody {
            display: table-row-group;
        }

        table[data-no-card] tr {
            display: table-row;
        }

        table[data-no-card] td {
            display: table-cell;
        }

    /* جدول‌های داخل کارت — فاصله‌دار */
    .table-wrapper:has(table.mobile-card-view) {
        border: none;
        background: transparent;
        padding: 0;
        overflow: visible;
    }

    /* حذف border-radius wrapper */
    .table-wrapper table.mobile-card-view {
        border-radius: 0;
    }
}

/* ═══ در موبایل خیلی کوچک ═══ */
@media (max-width: 480px) {
    table.mobile-card-view tbody tr {
        padding: 10px 12px;
        margin-bottom: 10px;
    }

    table.mobile-card-view tbody td {
        font-size: 12.5px;
        padding: 6px 0 !important;
    }

        table.mobile-card-view tbody td::before {
            font-size: 11.5px;
            min-width: 80px;
        }
}
/* ═══════════════════════════════════════════════════
   FactorItemForm — دیالوگ ردیف کالا
   ═══════════════════════════════════════════════════ */

.ffi-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3100;
    padding: 20px;
}

.ffi-box {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 780px;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
}

.ffi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
    font-weight: 700;
    color: var(--primary);
    background: #F9FAFB;
    border-radius: 12px 12px 0 0;
}

.ffi-close {
    background: transparent;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 6px;
}

    .ffi-close:hover {
        background: var(--bg);
    }

/* ═══ Article Section ═══ */
.ffi-article-section {
    padding: 16px 20px;
    background: linear-gradient(135deg, #EEF2FF, #F5F3FF);
    border-bottom: 1px solid #C7D2FE;
}

.ffi-article-row {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    align-items: center;
    margin-bottom: 8px;
}

    .ffi-article-row > label {
        font-size: 12.5px;
        font-weight: 600;
        color: #4338CA;
        white-space: nowrap;
    }

.ffi-input-with-btn {
    display: flex;
    gap: 4px;
}

    .ffi-input-with-btn input {
        flex: 1;
        padding: 8px 12px;
        border: 1px solid var(--border);
        border-radius: 8px;
        font-family: inherit;
        font-size: 13.5px;
        background: #fff;
    }

        .ffi-input-with-btn input:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px var(--primary-light);
        }

.ffi-pick-btn {
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font-size: 15px;
    transition: all 0.15s;
}

    .ffi-pick-btn:hover {
        background: var(--primary-light);
        border-color: var(--primary);
    }

.ffi-article-name {
    font-size: 14px;
    font-weight: 700;
    color: #4338CA;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 8px;
    min-height: 28px;
}

/* ═══ Info Bar ═══ */
.ffi-info-bar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    padding: 10px 20px;
    background: #F9FAFB;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
}

.ffi-info-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

    .ffi-info-item > span {
        color: var(--text-muted);
        font-weight: 500;
        font-size: 11px;
    }

    .ffi-info-item > strong {
        color: var(--text);
        font-weight: 700;
        font-variant-numeric: tabular-nums;
        font-size: 13px;
        direction: ltr;
        text-align: right;
    }

/* ═══ Body ═══ */
.ffi-body {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ffi-grid {
    display: grid;
    gap: 12px;
}

.ffi-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ffi-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ffi-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

    .ffi-field > label {
        font-size: 11.5px;
        color: #6B7280;
        font-weight: 600;
    }

    .ffi-field .req {
        color: var(--danger);
    }

    .ffi-field input {
        padding: 8px 12px;
        border: 1px solid var(--border);
        border-radius: 8px;
        font-family: inherit;
        font-size: 13.5px;
        background: #fff;
        font-variant-numeric: tabular-nums;
    }

        .ffi-field input:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px var(--primary-light);
        }

.ffi-readonly {
    background: #F3F4F6 !important;
    color: var(--text-muted) !important;
    cursor: not-allowed;
}

/* ═══ Final Cost ═══ */
.ffi-final {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: linear-gradient(135deg, #EEF2FF, #F5F3FF);
    border-top: 1px solid #C7D2FE;
    border-bottom: 2px solid var(--primary);
    font-size: 14px;
    font-weight: 600;
    color: #4338CA;
}

    .ffi-final strong {
        font-size: 20px;
        color: var(--primary);
        font-variant-numeric: tabular-nums;
        direction: ltr;
    }

/* ═══ Footer ═══ */
.ffi-footer {
    display: flex;
    gap: 10px;
    padding: 14px 20px;
    background: #F9FAFB;
    border-radius: 0 0 12px 12px;
}

    .ffi-footer .btn {
        min-width: 130px;
    }

/* ═══ Article Picker (داخل دیالوگ) ═══ */
.ffi-article-picker {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3200;
    padding: 20px;
}

.ffi-picker-box {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 640px;
    max-height: 78vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

.ffi-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
    background: #F9FAFB;
}

.ffi-picker-close {
    background: transparent;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 6px;
}

    .ffi-picker-close:hover {
        background: var(--bg);
    }

.ffi-picker-search {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

    .ffi-picker-search input {
        width: 100%;
        padding: 10px 14px;
        border: 1px solid var(--border);
        border-radius: 8px;
        font-family: inherit;
        font-size: 14px;
    }

        .ffi-picker-search input:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px var(--primary-light);
        }

.ffi-picker-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
}

.ffi-picker-item {
    display: flex;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.1s;
    align-items: center;
    border-bottom: 1px solid #F3F4F6;
}

    .ffi-picker-item:hover {
        background: var(--primary-light);
    }

.ffi-picker-code {
    font-family: 'Consolas', monospace;
    font-weight: 700;
    color: var(--primary);
    min-width: 80px;
    direction: ltr;
    text-align: center;
    font-size: 12.5px;
}

.ffi-picker-info {
    flex: 1;
    min-width: 0;
}

.ffi-picker-name {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}

.ffi-picker-sub {
    font-size: 11.5px;
    color: var(--text-muted);
}

    .ffi-picker-sub .positive {
        color: #059669;
        font-weight: 700;
    }

    .ffi-picker-sub .negative {
        color: #DC2626;
        font-weight: 700;
    }

    .ffi-picker-sub .zero {
        color: #6B7280;
    }

.ffi-picker-empty {
    padding: 30px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* ═══ Responsive ═══ */
@media (max-width: 768px) {
    .ffi-grid-3 {
        grid-template-columns: 1fr;
    }

    .ffi-grid-2 {
        grid-template-columns: 1fr;
    }

    .ffi-info-bar {
        grid-template-columns: repeat(2, 1fr);
    }

    .ffi-box {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .ffi-header {
        border-radius: 0;
    }

    .ffi-footer {
        border-radius: 0;
    }
}
/* ═══ Factor New Dropdown ═══ */
.fac-new-dropdown {
    position: relative;
    display: inline-block;
}

.fac-new-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 200px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.15);
    padding: 6px;
    z-index: 100;
    display: none;
}

.fac-new-dropdown.open .fac-new-menu {
    display: block;
    animation: facDropIn 0.15s ease;
}

@keyframes facDropIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fac-new-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13.5px;
    color: var(--text);
    transition: background 0.1s;
}

    .fac-new-item:hover {
        background: var(--primary-light);
        color: var(--primary);
        font-weight: 600;
    }

    .fac-new-item > span:first-child {
        font-size: 16px;
        width: 22px;
        text-align: center;
    }
/* ═══════════════════════════════════════════════════
   FactorForm — فرم اصلی فاکتور (ff-*)
   ═══════════════════════════════════════════════════ */

/* Modal پهن برای فرم فاکتور */
.modal-box:has(.ff-form) {
    max-width: 1250px !important;
    width: 96vw;
}

.ff-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 4px;
}

/* ═══ Sections ═══ */
.ff-section {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
}

.ff-section-top {
    background: linear-gradient(135deg, #EEF2FF, #F5F3FF) !important;
    border: 2px solid #C7D2FE !important;
}

.ff-section-customer {
    background: #FAFBFF !important;
    border: 2px solid #E0E7FF !important;
}

.ff-section-marketer {
    background: #FFFAF0 !important;
    border: 2px dashed #FDE68A !important;
}

.ff-section-bulk {
    background: #F0FDF4 !important;
    border: 1px dashed #86EFAC !important;
}

.ff-section-title {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.ff-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

    .ff-section-header .ff-section-title {
        margin-bottom: 0;
        padding-bottom: 0;
        border-bottom: none;
    }

/* ═══ Grid Layouts ═══ */
.ff-grid {
    display: grid;
    gap: 12px;
}

.ff-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ff-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ff-grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.ff-col-2 {
    grid-column: span 2;
}

.ff-col-full {
    grid-column: 1 / -1;
}

/* ═══ Fields ═══ */
.ff-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

    .ff-field > label {
        font-size: 12px;
        color: #4B5563;
        font-weight: 600;
    }

    .ff-field .req {
        color: var(--danger);
        margin-right: 2px;
    }

    .ff-field input[type="text"],
    .ff-field select,
    .ff-select {
        width: 100%;
        padding: 8px 12px;
        border: 1px solid var(--border);
        border-radius: 8px;
        font-family: inherit;
        font-size: 13.5px;
        background: #fff;
        color: var(--text);
        transition: all 0.15s;
        min-height: 36px;
        box-sizing: border-box;
    }

        .ff-field input[type="text"]:focus,
        .ff-field select:focus,
        .ff-select:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px var(--primary-light);
        }

.ff-readonly {
    background: #F3F4F6 !important;
    color: var(--text-muted) !important;
    cursor: not-allowed;
}


/* ═══ Input with button ═══ */
.ff-input-with-btn {
    display: flex;
    gap: 4px;
    align-items: stretch;
}

    .ff-input-with-btn input {
        flex: 1;
        min-width: 0;
    }

.ff-pick-btn {
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font-size: 15px;
    flex-shrink: 0;
    min-width: 38px;
    transition: all 0.15s;
}

    .ff-pick-btn:hover {
        background: var(--primary-light);
        border-color: var(--primary);
    }

/* ═══ Radio Inline ═══ */
.ff-radio-inline {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    padding: 6px 10px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    min-height: 36px;
}

    .ff-radio-inline label {
        display: flex;
        align-items: center;
        gap: 4px;
        font-size: 12.5px;
        cursor: pointer;
        font-weight: 500;
    }

    .ff-radio-inline input[type="radio"] {
        cursor: pointer;
        accent-color: var(--primary);
    }

/* ═══ Items Grid ═══ */
.ff-grid-wrap {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.ff-grid-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    background: #FAFBFC;
}

.ff-items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

    .ff-items-table thead {
        background: #F9FAFB;
    }

    .ff-items-table th {
        padding: 8px 6px;
        text-align: right;
        font-weight: 600;
        font-size: 11.5px;
        color: var(--text-muted);
        border-bottom: 2px solid var(--border);
        white-space: nowrap;
    }

        .ff-items-table th.num-col {
            text-align: left;
        }

    .ff-items-table td {
        padding: 8px 6px;
        border-bottom: 1px solid #F3F4F6;
        font-size: 12.5px;
    }

.ff-item-row {
    cursor: pointer;
    transition: background 0.1s;
}

    .ff-item-row:hover {
        background: #EEF2FF !important;
    }

.ff-items-table td.num {
    font-variant-numeric: tabular-nums;
    font-family: 'Tahoma', sans-serif;
}

.ff-row-del {
    background: transparent;
    border: 1px solid #FECACA;
    color: var(--danger);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
}

    .ff-row-del:hover {
        background: #FEF2F2;
        transform: scale(1.05);
    }

/* ═══ Totals ═══ */
.ff-totals {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    padding: 14px 16px;
    background: #F9FAFB;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.ff-total-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
}

    .ff-total-item > span {
        color: var(--text-muted);
        font-weight: 500;
    }

    .ff-total-item > strong {
        font-size: 15px;
        font-weight: 700;
        font-variant-numeric: tabular-nums;
        direction: ltr;
        text-align: right;
        color: var(--text);
    }

.ff-total-final {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #EEF2FF, #F5F3FF);
    border: 2px solid #C7D2FE;
    border-radius: 8px;
    padding: 12px 16px;
    flex-direction: row !important;
    justify-content: space-between;
    align-items: center;
}

    .ff-total-final > span {
        color: #4338CA;
        font-weight: 600;
        font-size: 13px;
    }

    .ff-total-final > strong {
        font-size: 20px;
        color: var(--primary);
    }

/* ═══ Footer ═══ */
.ff-footer {
    position: sticky;
    bottom: -20px; /* منفی چون modal-body padding: 20px داره */
    margin: 8px -20px -20px -20px; /* بیرون بزن تا به لبه‌ی modal بچسبه */
    padding: 12px 20px;
    background: #fff;
    border-top: 2px solid var(--border);
    box-shadow: 0 -6px 14px rgba(0, 0, 0, 0.08);
    display: flex;
    gap: 10px;
    align-items: center;
    z-index: 10;
}

    .ff-footer .btn {
        min-width: 130px;
    }

.ff-row-count {
    margin-right: auto;
    font-size: 12.5px;
    color: var(--text-muted);
    font-weight: 600;
}

/* ═══ Picker (Tafzili/Marketer) ═══ */
.ff-picker-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3100;
    padding: 20px;
}

.ff-picker-box {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 540px;
    max-height: 78vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

.ff-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    font-size: 14px;
    background: #F9FAFB;
    color: var(--primary);
}

.ff-picker-close {
    background: transparent;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 6px;
}

    .ff-picker-close:hover {
        background: var(--bg);
    }

.ff-picker-search {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

    .ff-picker-search input {
        width: 100%;
        padding: 10px 14px;
        border: 1px solid var(--border);
        border-radius: 8px;
        font-family: inherit;
        font-size: 13.5px;
        box-sizing: border-box;
    }

        .ff-picker-search input:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px var(--primary-light);
        }

.ff-picker-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
}

.ff-picker-item {
    display: flex;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.1s;
    align-items: center;
    border-bottom: 1px solid #F3F4F6;
}

    .ff-picker-item:hover {
        background: var(--primary-light);
    }

.ff-picker-code {
    font-family: 'Consolas', monospace;
    font-weight: 700;
    color: var(--primary);
    min-width: 60px;
    direction: ltr;
    text-align: center;
    font-size: 12.5px;
}

.ff-picker-name-wrap {
    flex: 1;
    min-width: 0;
}

.ff-picker-name {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}

.ff-picker-sub {
    font-size: 11px;
    color: var(--text-muted);
}

.ff-picker-empty {
    padding: 30px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* ═══ Responsive ═══ */
@media (max-width: 900px) {
    .ff-grid-3, .ff-grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ff-col-2 {
        grid-column: span 2;
    }

    .ff-totals {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .ff-grid-2, .ff-grid-3, .ff-grid-4 {
        grid-template-columns: 1fr;
    }

    .ff-col-2, .ff-col-full {
        grid-column: auto;
    }

    .ff-totals {
        grid-template-columns: 1fr;
    }

    .modal-box:has(.ff-form) {
        max-width: 100% !important;
        width: 100%;
    }

    .ff-footer {
        flex-wrap: wrap;
    }

        .ff-footer .btn {
            min-width: 0;
            flex: 1;
        }
}
.ff-footer-summary {
    margin-right: auto;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 6px 12px;
    background: linear-gradient(135deg, #EEF2FF, #F5F3FF);
    border-radius: 8px;
    border: 1px solid #C7D2FE;
}

.ff-footer-count {
    font-size: 12px;
    color: #4338CA;
    font-weight: 600;
}

.ff-footer-total {
    font-size: 13px;
    color: #4338CA;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

 .ff-footer-total strong {
        font-size: 16px;
        color: var(--primary);
        font-variant-numeric: tabular-nums;
        direction: ltr;
    }
/* ═══ Section سند خودکار ═══ */
.ff-section-sanad {
    background: #F5F3FF !important;
    border: 2px solid #C7D2FE !important;
}

    .ff-section-sanad .ff-section-title {
        color: #5B21B6 !important;
        border-bottom-color: #C7D2FE !important;
    }

.ff-checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    padding: 8px 10px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    min-height: 36px;
    transition: all 0.15s;
}

    .ff-checkbox-label:hover {
        background: #EEF2FF;
        border-color: var(--primary);
    }

    .ff-checkbox-label input[type="checkbox"] {
        width: 18px;
        height: 18px;
        cursor: pointer;
        accent-color: var(--primary);
        margin: 0;
    }

.form-hint {
    font-size: 10.5px;
    color: var(--text-muted);
    margin: 4px 0 0 0;
    line-height: 1.4;
}

/* ═══ دکمه‌های لیست ═══ */
.fac-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ═══ Badge وضعیت سند در لیست ═══ */
.sanad-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

    .sanad-badge.sanad-ok {
        background: #D1FAE5;
        color: #065F46;
    }

    .sanad-badge.sanad-none {
        background: #FEE2E2;
        color: #991B1B;
        padding: 3px 6px;
    }

/* ═══ Bulk Sanad Dialog ═══ */
.bulk-sanad-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.bulk-sanad-info {
    background: #EEF2FF;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid #C7D2FE;
    font-size: 13px;
}

    .bulk-sanad-info p {
        margin: 0 0 4px 0;
    }

        .bulk-sanad-info p:last-child {
            margin-bottom: 0;
        }

    .bulk-sanad-info .muted {
        color: var(--text-muted);
        font-size: 12px;
    }

.bulk-sanad-result h4 {
    font-size: 14px;
    margin-bottom: 10px;
    color: var(--success);
}

.bulk-sanad-stats {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    padding: 12px 14px;
    background: #F9FAFB;
    border-radius: 8px;
    font-size: 13px;
}

    .bulk-sanad-stats .success {
        color: var(--success);
    }

    .bulk-sanad-stats .fail {
        color: var(--danger);
    }

/* ═══ Section سند در جزئیات ═══ */
.factor-sanad-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
    background: linear-gradient(135deg, #F0FDF4, #DCFCE7);
    border: 1px solid #86EFAC;
    border-radius: 10px;
}

.factor-sanad-info {
    display: flex;
    gap: 16px;
    align-items: center;
    font-size: 13px;
    flex-wrap: wrap;
}

.factor-sanad-delete {
    color: var(--danger) !important;
    border-color: #FECACA !important;
}

    .factor-sanad-delete:hover {
        background: #FEF2F2 !important;
        border-color: var(--danger) !important;
    }
/* ═══ فیلتر خطاهای سند ═══ */
.sanad-error-filter {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #F9FAFB;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 12px;
    gap: 12px;
    flex-wrap: wrap;
}

.sanad-err-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #FEE2E2;
    color: #991B1B;
    border-radius: 20px;
    font-weight: 600;
    font-size: 12.5px;
    border: 1px solid #FECACA;
}

.sanad-ok-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #D1FAE5;
    color: #065F46;
    border-radius: 20px;
    font-weight: 600;
    font-size: 12.5px;
    border: 1px solid #6EE7B7;
}

.sanad-filter-select {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
}

    .sanad-filter-select label {
        font-weight: 600;
        color: var(--text-muted);
    }

    .sanad-filter-select select {
        padding: 7px 12px;
        border: 1px solid var(--border);
        border-radius: 8px;
        background: #fff;
        font-family: inherit;
        font-size: 12.5px;
        cursor: pointer;
        min-width: 240px;
    }

        .sanad-filter-select select:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px var(--primary-light);
        }

.sanad-row-err {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 10px;
    margin-right: 4px;
    cursor: help;
}

.sanad-err-error {
    background: #FEE2E2;
    color: #991B1B;
}

.sanad-err-warn {
    background: #FEF3C7;
    color: #92400E;
}

.sanad-err-info {
    background: #DBEAFE;
    color: #1E40AF;
}

tr.sanad-row-has-error {
    background: #FEF2F2 !important;
    border-right: 3px solid #DC2626;
}

    tr.sanad-row-has-error:hover {
        background: #FEE2E2 !important;
    }

tr.sanad-row-has-warn {
    background: #FFFBEB !important;
}

    tr.sanad-row-has-warn:hover {
        background: #FEF3C7 !important;
    }

/* ═══ Badge خطا در لیست اسناد ═══ */
.sanad-list-ok {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #D1FAE5;
    color: #065F46;
    font-size: 12px;
}

.sanad-list-err {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: #FEE2E2;
    color: #991B1B;
    border-radius: 20px;
    font-weight: 700;
    font-size: 11.5px;
    border: 1px solid #FECACA;
    cursor: help;
    font-variant-numeric: tabular-nums;
}

tr.row-has-errors {
    background: #FEF2F2 !important;
    border-right: 3px solid #DC2626;
}

    tr.row-has-errors:hover {
        background: #FEE2E2 !important;
    }

    tr.row-has-errors.row-unbalanced {
        background: #FEF2F2 !important;
    }
/* ═══════════════════════════════════════════════════
   Dashboard v3 — تمیز و حرفه‌ای
   ═══════════════════════════════════════════════════ */

.dash {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 1400px;
    margin: 0 auto;
}

.dash-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    gap: 12px;
    color: var(--text-muted);
}

.ico {
    width: 20px;
    height: 20px;
    display: block;
    flex-shrink: 0;
}

.ico-fallback {
    font-size: 18px;
    line-height: 1;
}

/* ═══ Greeting (باریک) ═══ */
.dash-greeting {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 4px 4px 8px;
}

    .dash-greeting h2 {
        font-size: 15px;
        font-weight: 500;
        color: var(--text);
        margin: 0;
    }

        .dash-greeting h2 strong {
            font-weight: 700;
            color: var(--primary);
        }

    .dash-greeting .muted {
        font-size: 12px;
        color: var(--text-muted);
        margin-top: 2px;
    }

.dash-date {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
    background: #fff;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    direction: ltr;
    letter-spacing: 0.5px;
}

/* ═══ KPI Strip (نوار افقی فشرده) ═══ */
.dash-strip {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 4px;
    overflow: hidden;
}

.dash-strip-item {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    transition: background 0.15s;
    min-width: 0;
}

    .dash-strip-item:hover {
        background: #F9FAFB;
    }

.dash-strip-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

    .dash-strip-icon .ico {
        width: 17px;
        height: 17px;
    }

.dash-strip-primary {
    background: #EEF2FF;
    color: #4F46E5;
}

.dash-strip-success {
    background: #D1FAE5;
    color: #059669;
}

.dash-strip-warning {
    background: #FEF3C7;
    color: #D97706;
}

.dash-strip-info {
    background: #DBEAFE;
    color: #2563EB;
}

.dash-strip-value {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.dash-strip-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
}

.dash-strip-sep {
    width: 1px;
    height: 28px;
    background: var(--border);
    flex-shrink: 0;
}

/* ═══ Income / Expense / Net ═══ */
.dash-ie {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}

.dash-ie-box {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    position: relative;
    overflow: hidden;
}

.dash-ie-icon-wrap {
    position: absolute;
    top: 12px;
    inset-inline-start: 12px; /* RTL: right side */
    width: 32px;
    height: 32px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .dash-ie-icon-wrap .ico {
        width: 16px;
        height: 16px;
    }

.dash-ie-icon-income {
    background: #D1FAE5;
    color: #059669;
}

.dash-ie-icon-expense {
    background: #FEE2E2;
    color: #DC2626;
}

.dash-ie-donut {
    width: 140px;
    height: 140px;
    position: relative;
    margin-top: 8px;
}

.dash-ie-meta {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dash-ie-label {
    font-size: 12.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.dash-ie-value {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    direction: ltr;
}

    .dash-ie-value small {
        font-size: 11px;
        color: var(--text-muted);
        font-weight: 500;
    }

/* ─── خالص (وسط) ─── */
.dash-ie-box-net {
    background: linear-gradient(160deg, #F5F3FF 0%, #EEF2FF 100%);
    border-color: #C7D2FE;
    justify-content: center;
    gap: 8px;
    padding: 24px 18px;
}

.dash-ie-net-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: #fff;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(79,70,229,0.12);
    margin-bottom: 4px;
}

    .dash-ie-net-icon .ico {
        width: 22px;
        height: 22px;
    }

.dash-ie-net-label {
    font-size: 12.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.dash-ie-net-value {
    font-size: 24px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    direction: ltr;
    line-height: 1.1;
}

    .dash-ie-net-value.dash-positive {
        color: #059669;
    }

    .dash-ie-net-value.dash-negative {
        color: #DC2626;
    }

.dash-ie-net-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 12px;
    border-radius: 20px;
    margin-top: 2px;
}

.dash-ie-net-positive {
    background: #D1FAE5;
    color: #065F46;
}

.dash-ie-net-negative {
    background: #FEE2E2;
    color: #991B1B;
}

/* ═══ ۳ چارت ═══ */
.dash-charts {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.dash-chart {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.dash-chart-head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text);
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--border);
}

.dash-chart-ico {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: #EEF2FF;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

    .dash-chart-ico .ico {
        width: 14px;
        height: 14px;
    }

.dash-chart-body {
    position: relative;
    height: 230px;
}

/* ═══ Connection (باریک) ═══ */
.dash-section-compact {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 16px;
}

.dash-conn-row {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    font-size: 12.5px;
}

.dash-conn-item {
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
}

.dash-conn-label {
    color: var(--text-muted);
    font-weight: 500;
    flex-shrink: 0;
}

.dash-conn-value {
    color: var(--text);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ═══ Responsive ═══ */
@media (max-width: 1100px) {
    .dash-ie {
        grid-template-columns: 1fr 1fr;
    }

    .dash-ie-box-net {
        grid-column: 1 / -1;
    }



        .dash-charts .dash-chart:nth-child(3) {
            grid-column: 1 / -1;
        }
}

@media (max-width: 768px) {
    .dash {
        gap: 10px;
    }

    .dash-greeting h2 {
        font-size: 13px;
    }

    .dash-date {
        font-size: 11px;
        padding: 5px 10px;
    }

    /* KPI Strip → 2x2 */
    .dash-strip {
        display: grid;
        grid-template-columns: 1fr 1fr;
        padding: 6px;
        gap: 4px;
    }

    .dash-strip-sep {
        display: none;
    }

    .dash-strip-item {
        padding: 8px 10px;
        gap: 8px;
        background: #F9FAFB;
    }

    .dash-strip-icon {
        width: 30px;
        height: 30px;
        border-radius: 8px;
    }

        .dash-strip-icon .ico {
            width: 15px;
            height: 15px;
        }

    .dash-strip-value {
        font-size: 15px;
    }

    .dash-strip-label {
        font-size: 11px;
    }

    /* Income/Expense → تک‌ستون */
    .dash-ie {
        grid-template-columns: 1fr;
    }

    .dash-ie-box-net {
        grid-column: auto;
        padding: 20px 16px;
    }

    .dash-ie-donut {
        width: 120px;
        height: 120px;
    }



        .dash-charts .dash-chart:nth-child(3) {
            grid-column: auto;
        }

    .dash-chart-body {
        height: 210px;
    }

    /* Connection */
    .dash-conn-row {
        gap: 10px 16px;
        font-size: 11.5px;
    }
}
/* ═══════════════════════════════════════════════════
   FilterPanel — استایل یکدست با SanadForm
   ═══════════════════════════════════════════════════ */

/* فیلدهای داخل FilterPanel */
.fp-field input,
.fp-field select,
.fp-field textarea,
.filters input,
.filters select,
.filter-panel input,
.filter-panel select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    background: #fff;
    color: var(--text);
    min-height: 38px;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
    -webkit-appearance: none; /* ⭐ حذف استایل بومی */
    appearance: none;
}

    .fp-field input:focus,
    .fp-field select:focus,
    .fp-field textarea:focus,
    .filters input:focus,
    .filters select:focus {
        outline: none;
        border-color: var(--primary);
        box-shadow: 0 0 0 3px var(--primary-light);
    }

/* ⭐ حذف spinner (فلش‌های بالا/پایین) از input type=number */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* ⭐ حذف آیکن تقویم بومی از input type=date */
input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.5;
    filter: invert(0.4);
}

input[type="date"]::-webkit-inner-spin-button {
    display: none;
}

/* ⭐ تاریخ‌هایی که با type=text هستن و placeholder فارسی دارن */
input[placeholder*="1404"],
input[placeholder*="1403"],
input[placeholder*="1405"] {
    direction: ltr;
    text-align: left;
    font-variant-numeric: tabular-nums;
}

/* ⭐ Label فیلدهای FilterPanel */
.fp-field label,
.filter-panel label {
    font-size: 12px;
    font-weight: 600;
    color: #4B5563;
    margin-bottom: 4px;
    display: block;
}

/* ⭐ Select در FilterPanel (اگر Custom Select نیست) */
.fp-field select,
.filters select {
    background-image: url("data:image/svg+xml;utf8,<svg 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'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: left 12px center;
    padding-left: 32px;
    cursor: pointer;
}

/* ⭐ Grid فیلترهای عادی (در صورت نیاز) */
.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

    .filters .form-group {
        margin-bottom: 0;
    }


/* ═══════════════════════════════════════════
   Dashboard Charts — Fix موبایل (ساده و قطعی)
   ═══════════════════════════════════════════ */

@media (max-width: 768px) {
    .dash-charts {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

        .dash-charts .dash-chart {
            grid-column: auto !important;
        }

    .dash-chart-body {
        height: 260px !important;
    }
}
/* ═══════════════════════════════════════════════════
   Dashboard Collapsible Cards (موبایل)
   ═══════════════════════════════════════════════════ */

/* ⭐ دکمه‌ی toggle — فقط در موبایل نمایش داده می‌شه */
.dash-collapse-btn {
    display: none;
    position: absolute;
    top: 10px;
    inset-inline-start: 10px; /* RTL: right side */
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-muted);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: all 0.15s;
}

    .dash-collapse-btn:hover {
        background: var(--primary-light);
        border-color: var(--primary);
        color: var(--primary);
    }

.dash-collapse-icon {
    font-size: 10px;
    line-height: 1;
    display: block;
}

/* ⭐ نمایش خلاصه (فقط در حالت بسته موبایل) */
.dash-ie-summary {
    display: none;
    text-align: center;
    margin-top: 4px;
}

.dash-ie-value-small {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    direction: ltr;
}

    .dash-ie-value-small small {
        font-size: 11px;
        color: var(--text-muted);
        font-weight: 500;
    }

/* ═══════════════════════════════════════════════════
   فقط در موبایل: رفتار تاشو
   ═══════════════════════════════════════════════════ */
@media (max-width: 768px) {

    /* دکمه‌ی toggle رو نشون بده */
    .dash-collapse-btn {
        display: flex;
    }

    /* پیش‌فرض: بدنه‌ی collapsible بسته */
    .dash-collapsible .dash-collapse-body {
        display: none;
    }

    /* وقتی باز: بدنه نشون داده می‌شه */
    .dash-collapsible.open .dash-collapse-body {
        display: block;
        animation: dashSlideIn 0.25s ease;
    }

    @keyframes dashSlideIn {
        from {
            opacity: 0;
            transform: translateY(-6px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* در حالت بسته: کارت‌ها جمع و جور */
    .dash-collapsible:not(.open) {
        padding: 14px 16px;
    }

    /* خلاصه رو نشون بده */
    .dash-ie-summary {
        display: block;
    }

    /* کارت درآمد/هزینه در حالت بسته */
    .dash-ie-box.dash-collapsible:not(.open) {
        flex-direction: row;
        align-items: center;
        gap: 12px;
        padding: 14px 16px;
        min-height: auto;
    }

        .dash-ie-box.dash-collapsible:not(.open) .dash-ie-icon-wrap {
            position: static;
            margin: 0;
            flex-shrink: 0;
        }

        .dash-ie-box.dash-collapsible:not(.open) .dash-ie-summary {
            flex: 1;
            text-align: right;
            margin: 0;
        }

        /* دکمه‌ی تاشو در سمت چپ (RTL) */
        .dash-ie-box.dash-collapsible:not(.open) .dash-collapse-btn {
            position: static;
            margin-inline-start: auto;
        }

    /* کارت‌های چارت در حالت بسته */
    .dash-chart.dash-collapsible:not(.open) {
        padding: 14px 16px;
    }

        .dash-chart.dash-collapsible:not(.open) .dash-chart-head {
            margin: 0;
            padding: 0;
            border-bottom: none;
        }

    /* کاهش ارتفاع چارت در موبایل */
    .dash-chart-body {
        height: 260px !important;
    }
}

/* ═══ دسکتاپ: همه همیشه باز ═══ */
@media (min-width: 769px) {
    .dash-collapse-body {
        display: block !important;
    }

    .dash-collapse-btn {
        display: none !important;
    }

    .dash-ie-summary {
        display: none !important;
    }
}
/* ═══════════════════════════════════════════
   Fix دکمه‌ی تاشو در کارت‌های چارت
   ═══════════════════════════════════════════ */

/* ⭐ position relative برای کارت چارت */
.dash-chart.dash-collapsible {
    position: relative;
}

@media (max-width: 768px) {
    /* ⭐ دکمه در سمت چپ (RTL) — نزدیک آیکن تداخل نکنه */
    .dash-chart.dash-collapsible .dash-collapse-btn {
        top: 14px;
        inset-inline-start: auto; /* بازنویسی مقدار قبلی */
        inset-inline-end: 14px; /* ← چپ در RTL */
    }

    /* ⭐ فضای کافی برای دکمه در هدر */
    .dash-chart.dash-collapsible .dash-chart-head {
        padding-inline-end: 46px;
    }
}
/* ═══════════════════════════════════════════
   Activation Page — Professional
   ═══════════════════════════════════════════ */

/* ─── Steps (پنل برند) ─── */
.activation-steps {
    list-style: none;
    padding: 0;
    margin: 28px 0 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.activation-steps li {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255, 255, 255, 0.92);
    font-size: 14px;
    line-height: 1.6;
}

.activation-steps .step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.3);
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
    backdrop-filter: blur(6px);
}

/* ─── Brand Footer ─── */
.login-brand-footer {
    position: absolute;
    bottom: 24px;
    right: 32px;
    left: 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.85);
    font-size: 12px;
}

.brand-contact {
    display: flex;
    gap: 16px;
}

.brand-contact-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
    direction: ltr;
}

.brand-contact-item svg {
    opacity: 0.8;
}

.brand-name {
    font-weight: 700;
    font-size: 12px;
    color: #fff;
    letter-spacing: 0.3px;
}

/* ─── Activation Header ─── */
.activation-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid #F1F5F9;
}

.activation-icon-badge {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
}

.activation-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 800;
    color: #111827;
}

.activation-sub {
    margin: 4px 0 0;
    font-size: 13px;
    color: #6B7280;
}

/* ─── System ID Box ─── */
.activation-system-id {
    background: linear-gradient(135deg, #F5F3FF 0%, #EEF2FF 100%);
    border: 1px solid #DDD6FE;
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 22px;
}

.sysid-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 700;
    color: #4C1D95;
    margin-bottom: 10px;
    letter-spacing: 0.2px;
}

.sysid-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 2px solid #6366F1;
    border-radius: 10px;
    padding: 8px 10px 8px 14px;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.12);
}

.sysid-box span {
    flex: 1;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 22px;
    font-weight: 800;
    color: #3730A3;
    letter-spacing: 3px;
    direction: ltr;
    text-align: center;
    user-select: all;
}

.sysid-box button {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #6366F1 0%, #4F46E5 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    flex-shrink: 0;
}

.sysid-box button:hover {
    transform: scale(1.06);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.sysid-box button:active {
    transform: scale(0.96);
}

.sysid-hint {
    margin: 10px 0 0;
    font-size: 12px;
    color: #6D28D9;
    line-height: 1.7;
    display: flex;
    align-items: flex-start;
    gap: 4px;
}

/* ─── Serial Input ─── */
.activation-form-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    color: #374151;
    margin-bottom: 8px;
}

.activation-input {
    width: 100%;
    height: 52px;
    padding: 0 16px;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 4px;
    text-align: center;
    direction: ltr;
    color: #111827;
    background: #F9FAFB;
    border: 2px solid #E5E7EB;
    border-radius: 10px;
    transition: all 0.2s;
    outline: none;
    box-sizing: border-box;
}

.activation-input::placeholder {
    color: #9CA3AF;
    letter-spacing: 3px;
    font-weight: 500;
}

.activation-input:focus {
    border-color: #6366F1;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

/* ─── Submit Button ─── */
.activation-submit {
    width: 100%;
    height: 50px;
    margin-top: 18px;
    font-size: 15px;
    font-weight: 700;
    border-radius: 10px;
    background: linear-gradient(135deg, #6366F1 0%, #4F46E5 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.activation-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.4);
}

.activation-submit:active {
    transform: translateY(0);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.activation-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ─── Footer ─── */
.activation-footer {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #F1F5F9;
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #9CA3AF;
}

/* ─── Error Box ─── */
.error-box {
    background: linear-gradient(135deg, #FEF2F2 0%, #FEE2E2 100%);
    border: 1px solid #FECACA;
    color: #991B1B;
    padding: 12px 14px;
    border-radius: 10px;
    margin-top: 12px;
    font-size: 13px;
    line-height: 1.6;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    animation: shakeError 0.35s ease;
}

.error-box.hidden {
    display: none;
}

@keyframes shakeError {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* ─── Responsive ─── */
@media (max-width: 900px) {
    .login-brand-footer {
        position: static;
        margin-top: 24px;
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }

    .activation-steps {
        display: none;
    }
}
/* ═══════════════════════════════════════════
   Activation Layout — Centering & Polish
   ═══════════════════════════════════════════ */

/* کارت رو وسط صفحه عمودی نگه‌دار */
#activationView.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    box-sizing: border-box;
}

/* کارت نهایتاً 1000px */
#activationView .login-card-v2 {
    max-width: 1000px;
    width: 100%;
    min-height: 580px;
}

/* پنل برند: چیدمان عمودی منظم */
#activationView .login-brand-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 40px 36px;
    overflow: hidden;
}

#activationView .login-brand-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* footer داخل پنل برند — پایین ثابت */
#activationView .login-brand-footer {
    position: static;
    margin-top: auto;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-size: 12px;
}

/* آیکن لوگو بالای برند */
#activationView .login-brand-logo {
    margin-bottom: 20px;
}

/* steps تمیز */
#activationView .activation-steps {
    margin-top: 24px;
}

/* ─── Header: آیکن کوچیک‌تر ─── */
#activationView .activation-header {
    gap: 12px;
}

#activationView .activation-icon-badge {
    width: 42px;
    height: 42px;
    border-radius: 12px;
}

/* ─── پنل فرم: پدینگ بهتر ─── */
#activationView .login-form-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 40px 36px;
}

#activationView .login-form-content {
    max-width: 420px;
    width: 100%;
    margin: 0 auto;
}

/* ─── موبایل ─── */
@media (max-width: 900px) {
    #activationView .login-card-v2 {
        min-height: auto;
    }

    #activationView .login-brand-panel {
        padding: 28px 20px;
    }

    #activationView .login-form-panel {
        padding: 28px 20px;
    }
}

/* ═══════════════ Row Select (Global) ═══════════════ */
tbody tr.row-selected {
    background: #E0E7FF !important;
    box-shadow: inset 3px 0 0 var(--primary);
}

    tbody tr.row-selected td {
        color: #4338CA !important;
        font-weight: 600;
    }

tbody tr {
    cursor: pointer;
    transition: background 0.1s;
}

table[data-no-row-select] tbody tr {
    cursor: default;
}