/* ===== HospitalERP — تمِ تمیزِ ERP (RTL) ===== */
:root {
    --brand: #0ea5a4;
    --brand-dark: #0b7c7b;
    --brand-soft: #e6f6f5;
    --sidebar-bg: #0f2b46;
    --sidebar-bg2: #0c2338;
    --sidebar-ink: #c7d3e0;
    --sidebar-ink-dim: #8698ad;
    --ink: #1f2937;
    --muted: #6b7280;
    --bg: #f4f6f9;
    --card: #ffffff;
    --border: #e5e7eb;
    --danger: #dc3545;
    --warning: #f59e0b;
    --success: #16a34a;
    --info: #0ea5e9;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
    --sidebar-w: 264px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: Vazirmatn, "Segoe UI", Tahoma, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
}

a { text-decoration: none; color: var(--brand-dark); }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.strong { font-weight: 700; }

/* ===== چیدمانِ اصلی ===== */
.app-shell { display: flex; min-height: 100vh; }

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

/* ===== سایدبار ===== */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg2));
    color: var(--sidebar-ink);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}

.sidebar-brand .brand-logo {
    width: 38px; height: 38px;
    border-radius: 10px;
    background: var(--brand);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; color: #fff;
    box-shadow: 0 4px 12px rgba(14, 165, 164, .4);
}

.sidebar-brand .brand-name { font-weight: 800; font-size: 16px; line-height: 1.2; }
.sidebar-brand .brand-sub { font-size: 11px; color: var(--sidebar-ink-dim); }

.nav-section { padding: 10px 12px 2px; }
.nav-section-title {
    font-size: 11px;
    color: var(--sidebar-ink-dim);
    padding: 8px 12px 6px;
    letter-spacing: .3px;
}

.nav-link-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 13px;
    margin: 2px 0;
    border-radius: 9px;
    color: var(--sidebar-ink);
    font-size: 14px;
    transition: background .15s, color .15s;
}
.nav-link-item i { font-size: 17px; width: 20px; text-align: center; }
.nav-link-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-link-item.active {
    background: var(--brand);
    color: #fff;
    box-shadow: 0 4px 12px rgba(14, 165, 164, .35);
}

/* زیرمنو */
.nav-children {
    margin: 2px 6px 4px;
    padding-inline-start: 14px;
    border-inline-start: 2px solid rgba(255, 255, 255, .08);
}
.nav-link-item.nav-child { padding: 8px 12px; font-size: 13px; }
.nav-link-item.nav-child i { font-size: 15px; }
.nav-link-item.nav-child.active { background: rgba(14, 165, 164, .85); box-shadow: none; }

/* ===== نوارِ بالا ===== */
.topbar {
    height: 62px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar .page-title { font-weight: 700; font-size: 16px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .spacer { flex: 1; }

.icon-btn {
    width: 40px; height: 40px;
    border: 0; background: transparent;
    border-radius: 10px;
    color: var(--muted);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 19px; cursor: pointer;
    position: relative;
    transition: background .15s;
}
.icon-btn:hover { background: var(--bg); color: var(--ink); }

.notif-badge {
    position: absolute; top: 6px; inset-inline-start: 6px;
    background: var(--danger); color: #fff;
    font-size: 10px; min-width: 16px; height: 16px;
    border-radius: 8px; display: flex; align-items: center; justify-content: center;
    padding: 0 4px;
}

.user-btn {
    display: flex; align-items: center; gap: 9px;
    border: 0; background: transparent; cursor: pointer;
    padding: 5px 8px; border-radius: 10px;
}
.user-btn:hover { background: var(--bg); }
.user-btn .u-name { font-weight: 600; font-size: 13px; }
.user-btn .u-role { font-size: 11px; color: var(--muted); }

.sidebar-toggle { display: none; }

/* ===== محتوا ===== */
.content { padding: 22px; flex: 1; }
.page-header { margin-bottom: 18px; }
.page-header h1 { font-size: 20px; font-weight: 800; margin: 0 0 4px; }
.page-header p { margin: 0; color: var(--muted); font-size: 13px; }

/* ===== کارت‌ها ===== */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-pad { padding: 18px; }

/* کارتِ آماری */
.stat-card {
    display: flex; align-items: center; gap: 14px;
    padding: 18px;
}
.stat-icon {
    width: 52px; height: 52px; border-radius: 13px;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; color: #fff; flex-shrink: 0;
}
.stat-card .stat-val { font-size: 24px; font-weight: 800; line-height: 1.1; }
.stat-card .stat-label { font-size: 13px; color: var(--muted); }

.bg-brand { background: var(--brand); }
.bg-blue { background: #3b82f6; }
.bg-violet { background: #8b5cf6; }
.bg-amber { background: #f59e0b; }
.bg-green { background: #16a34a; }
.bg-rose { background: #f43f5e; }

/* شبکهٔ ماژول‌ها */
.module-card {
    display: block; padding: 20px;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--card); box-shadow: var(--shadow);
    transition: transform .15s, box-shadow .15s, border-color .15s;
    height: 100%;
}
.module-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(16, 24, 40, .1);
    border-color: var(--brand);
}
.module-card .m-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 23px; color: #fff; margin-bottom: 12px;
}
.module-card h3 { font-size: 15px; font-weight: 700; margin: 0 0 6px; color: var(--ink); }
.module-card p { font-size: 12.5px; color: var(--muted); margin: 0; line-height: 1.7; }

.badge-soft {
    display: inline-block; padding: 3px 9px; border-radius: 20px;
    font-size: 11px; font-weight: 600;
    background: var(--brand-soft); color: var(--brand-dark);
}
.badge-soon { background: #fff4e5; color: #b45309; }
.badge-ok { background: #dcfce7; color: #15803d; }

/* دکمه‌ها */
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }

/* ===== صفحهٔ ورود ===== */
.auth-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #0f2b46, #0b7c7b);
    padding: 20px;
}
.auth-card {
    width: 100%; max-width: 410px;
    background: #fff; border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
    padding: 34px 30px;
}
.auth-logo {
    width: 60px; height: 60px; border-radius: 15px;
    background: var(--brand); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 30px; margin: 0 auto 14px;
    box-shadow: 0 8px 20px rgba(14, 165, 164, .4);
}
.auth-card h1 { text-align: center; font-size: 19px; font-weight: 800; margin: 0 0 4px; }
.auth-card .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.form-label { font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.demo-box {
    margin-top: 18px; padding: 12px 14px; border-radius: 10px;
    background: var(--brand-soft); font-size: 12px; color: var(--brand-dark); line-height: 2;
}
.demo-box code { background: #fff; padding: 1px 6px; border-radius: 5px; color: var(--ink); }

/* جدول‌های داده: اسکرول افقی درون کارت به‌جای سرریزِ صفحه */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-responsive > table { margin-bottom: 0; }
.data-table th, .data-table td { white-space: nowrap; }

/* تب‌های فرم پرسنل */
.form-tabs { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 2px solid var(--border); margin-bottom: 18px; }
.form-tab {
    padding: 9px 16px; border: 0; background: transparent; cursor: pointer;
    font-size: 14px; font-weight: 600; color: var(--muted);
    border-bottom: 3px solid transparent; margin-bottom: -2px; border-radius: 8px 8px 0 0;
    display: inline-flex; align-items: center; gap: 6px;
}
.form-tab:hover { color: var(--ink); background: var(--bg); }
.form-tab.active { color: var(--brand-dark); border-bottom-color: var(--brand); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* فیلد نمایشی در صفحهٔ جزئیات */
.field { margin-bottom: 4px; }
.field .f-label { font-size: 11.5px; color: var(--muted); margin-bottom: 2px; display: flex; align-items: center; gap: 4px; }
.field .f-value { font-weight: 600; font-size: 13.5px; word-break: break-word; }
.detail-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 18px; }
@media (max-width: 992px) { .detail-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 576px) { .detail-grid { grid-template-columns: 1fr 1fr; gap: 10px; } }

/* بخش زیرمجموعه در جزئیات */
.sub-block { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.sub-block > .sub-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }

/* جدول‌های سوابق و مدارک: وسط‌چین و مرتب */
#d-records .table th,
#d-records .table td { text-align: center; vertical-align: middle; }
#d-records .table th:first-child,
#d-records .table td:first-child { text-align: start; }
#d-records .table td[dir="ltr"] { unicode-bidi: plaintext; }

/* ===== واکنش‌گرا ===== */
@media (max-width: 992px) {
    .content { padding: 16px; }
}

@media (max-width: 576px) {
    body { font-size: 13.5px; }
    .content { padding: 12px; }
    .page-header h1 { font-size: 17px; }
    .card-pad { padding: 14px; }
    .stat-card { padding: 13px; gap: 10px; }
    .stat-icon { width: 42px; height: 42px; font-size: 19px; }
    .stat-card .stat-val { font-size: 19px; }
    /* نوارِ بالا در گوشی ۹ کنترل دارد و با فاصله‌های دسکتاپ از عرضِ صفحه می‌زد بیرون */
    .topbar { padding: 0 8px; gap: 4px; }
    .user-btn { padding-inline: 4px; gap: 6px; }
    .user-btn .bi-chevron-down { display: none; }
    .form-tab { padding: 8px 11px; font-size: 12.5px; }
    .btn { font-size: 13px; }
    h1, .h1 { font-size: 17px; }
}

@media (max-width: 860px) {
    .sidebar {
        /* لبهٔ آغازین: راست در فارسی/عربی، چپ در انگلیسی (ترجمهٔ ±100% آن را بیرون می‌برد) */
        position: fixed; inset-inline-start: 0; top: 0; z-index: 50;
        transform: translateX(100%);
        transition: transform .22s;
    }
    .sidebar.open { transform: translateX(0); box-shadow: -8px 0 30px rgba(0, 0, 0, .3); }
    /* چپ‌به‌راست: سایدبار از سمتِ چپ باز می‌شود */
    [dir="ltr"] .sidebar { transform: translateX(-100%); }
    [dir="ltr"] .sidebar.open { transform: translateX(0); box-shadow: 8px 0 30px rgba(0, 0, 0, .3); }
    .sidebar-toggle { display: inline-flex; }
    .sidebar-backdrop {
        display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 40;
    }
    .sidebar-backdrop.show { display: block; }
}

/* ═══════════ لودرِ سراسری (ضدِ ارسالِ دوباره) ═══════════ */
#app-loader {
    position: fixed;
    inset: 0;
    z-index: 20000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, .38);
    backdrop-filter: blur(1.5px);
    cursor: progress;
}
#app-loader.show { display: flex; }
.app-loader-box {
    background: #fff;
    border-radius: 14px;
    padding: 22px 30px;
    box-shadow: 0 12px 40px rgba(0,0,0,.25);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.app-spinner {
    width: 42px;
    height: 42px;
    border: 4px solid #d9e2ec;
    border-top-color: #0d9488;
    border-radius: 50%;
    animation: app-spin .7s linear infinite;
}
.app-loader-text { font-size: .85rem; color: #334155; font-weight: 600; }
@keyframes app-spin { to { transform: rotate(360deg); } }

/* ═══════════ لانچرِ نرم‌افزارها (App Switcher) ═══════════ */
.app-launcher-wrap { margin-inline-start: 4px; }
.app-switch-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    background: var(--surface, #fff);
    color: var(--text, #1e293b);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.app-switch-btn:hover { background: var(--hover, #f1f5f9); border-color: #cbd5e1; }
.app-switch-btn > .bi-grid-3x3-gap-fill { color: #0d9488; font-size: 16px; }
.app-switch-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.app-launcher { min-width: 320px; border-radius: 16px; border: none; }
.app-launcher-head { font-size: 12px; font-weight: 700; color: #64748b; padding: 2px 6px 10px; }
.app-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.app-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 14px 6px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--text, #334155);
    transition: background .15s, transform .1s;
}
.app-tile:hover { background: var(--hover, #f1f5f9); transform: translateY(-1px); color: var(--text, #334155); }
.app-tile.active { background: rgba(13,148,136,.10); }
.app-tile.active .app-tile-name { color: #0d9488; font-weight: 700; }
.app-tile-icon {
    width: 46px; height: 46px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 20px;
    box-shadow: 0 3px 8px rgba(0,0,0,.15);
}
.app-tile-name { font-size: 12px; font-weight: 600; text-align: center; line-height: 1.3; }

/* ═══════════ چندزبانگی: جهت، فونت، آیکن‌های جهت‌دار ═══════════ */
/* آیکن‌های جهت‌دار («بازگشت»، «بعدی») در چپ‌به‌راست قرینه می‌شوند */
[dir="ltr"] .bi-dir { display: inline-block; transform: scaleX(-1); }
html[lang="en"] body { line-height: 1.5; }
html[lang="ar"] body { line-height: 1.75; }
.user-text { unicode-bidi: plaintext; }
bdi { unicode-bidi: isolate; }

.back-btn { width: auto !important; padding: 0 12px !important; gap: 6px; }
.back-btn span { font-size: 13px; }
.notif-menu { min-width: 300px; }

/* ── انتخابِ زبان (نوارِ بالا) ── */
.lang-btn {
    display: inline-flex; align-items: center; gap: 6px;
    height: 38px; padding: 0 10px 0 11px;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--card); color: var(--ink);
    font-size: 13px; cursor: pointer;
    transition: background .15s, border-color .15s, box-shadow .15s;
}
.lang-btn:hover { background: var(--bg); border-color: #cbd5e1; }
.lang-btn[aria-expanded="true"] { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(14, 165, 164, .15); }
.lang-btn > .bi-translate { font-size: 17px; color: var(--brand-dark); }
.lang-code {
    font: 700 10.5px/1 system-ui, "Segoe UI", sans-serif; letter-spacing: .6px;
    padding: 4px 6px; border-radius: 6px;
    background: var(--sidebar-bg); color: #fff;
}

.lang-menu { width: 272px; padding: 6px; border: none; border-radius: 14px; }
.lang-menu-head {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px 10px; margin-bottom: 4px;
    border-bottom: 1px solid var(--border);
    font-size: 12px; font-weight: 700; color: var(--muted);
}
.lang-menu-head .bi { color: var(--brand-dark); font-size: 15px; }
.lang-item {
    width: 100%; display: flex; align-items: center; gap: 12px;
    padding: 9px 10px; margin: 2px 0;
    border: 1px solid transparent; border-radius: 10px;
    background: transparent; color: var(--ink);
    text-align: start; cursor: pointer;
    transition: background .12s, border-color .12s;
}
.lang-item:hover { background: var(--bg); }
.lang-item:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.lang-item.active { background: var(--brand-soft); border-color: rgba(14, 165, 164, .35); }
.lang-glyph {
    flex: none; width: 38px; height: 38px; border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 15px; color: #fff;
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .12);
}
.lang-glyph-fa { background: linear-gradient(135deg, #0f2b46, #1d4e7a); }
.lang-glyph-en { background: linear-gradient(135deg, #0b7c7b, #0ea5a4); font-family: system-ui, "Segoe UI", sans-serif; font-size: 14px; }
.lang-glyph-ar { background: linear-gradient(135deg, #7c2d12, #b45309); font-size: 19px; }
.lang-names { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; line-height: 1.35; }
.lang-native { font-weight: 700; font-size: 14px; }
.lang-sub { font-size: 11.5px; color: var(--muted); }
.lang-check { color: var(--brand-dark); font-size: 17px; }
.lang-menu-foot {
    display: flex; align-items: center; gap: 8px;
    margin-top: 4px; padding: 9px 10px 6px;
    border-top: 1px solid var(--border);
    font-size: 12.5px; color: var(--brand-dark);
}
.lang-menu-foot:hover { text-decoration: underline; }

/* صفحهٔ ورود: انتخابِ زبان در گوشهٔ بالا */
.auth-lang { position: fixed; top: 16px; inset-inline-end: 16px; z-index: 10; }
.auth-lang .lang-btn { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .28); color: #fff; backdrop-filter: blur(6px); }
.auth-lang .lang-btn:hover { background: rgba(255, 255, 255, .2); }
.auth-lang .lang-btn > .bi-translate { color: #fff; }
.auth-lang .lang-code { background: #fff; color: var(--sidebar-bg); }

@media (max-width: 576px) {
    .lang-btn { padding: 0 8px; }
    .topbar .lang-btn > .bi-translate { display: none; }
}

/* ── تنظیماتِ نمایش (پروفایل) ── */
.prefs-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.prefs-head > .bi {
    width: 42px; height: 42px; border-radius: 12px; flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--brand-soft); color: var(--brand-dark); font-size: 20px;
}
.prefs-label { font-size: 12px; font-weight: 700; color: var(--muted); margin: 14px 0 8px; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.choice { position: relative; cursor: pointer; margin: 0; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice-body {
    display: flex; align-items: center; gap: 10px; height: 100%;
    padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 12px;
    background: var(--card); transition: border-color .12s, background .12s, box-shadow .12s;
}
.choice:hover .choice-body { border-color: #cbd5e1; }
.choice input:checked + .choice-body { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 3px rgba(14, 165, 164, .12); }
.choice input:focus-visible + .choice-body { outline: 2px solid var(--brand); outline-offset: 2px; }
.choice .lang-glyph { width: 34px; height: 34px; font-size: 14px; }
.choice-icon { font-size: 20px; color: var(--brand-dark); flex: none; }
.prefs-preview {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    margin-top: 16px; padding: 10px 12px; border-radius: 10px;
    background: var(--bg); border: 1px dashed var(--border); font-size: 13px;
}

/* ── صفحهٔ ترجمه‌ها ── */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    padding: 5px 12px; border-radius: 20px; font-size: 12.5px;
    border: 1px solid var(--border); background: var(--card); color: var(--ink);
}
.chip:hover { border-color: #cbd5e1; background: var(--bg); color: var(--ink); }
.chip.active { background: var(--sidebar-bg); border-color: var(--sidebar-bg); color: #fff; }
.tr-big { font-size: 26px; font-weight: 800; line-height: 1.3; }
.tr-bar { height: 6px; border-radius: 6px; background: var(--bg); overflow: hidden; margin-top: 8px; }
.tr-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-dark)); border-radius: 6px; }
.tr-grid { display: flex; flex-direction: column; }
.tr-row {
    display: grid; grid-template-columns: minmax(200px, 1.1fr) 1fr 1fr 70px;
    gap: 10px; align-items: start; padding: 10px 14px; margin: 0;
    border-bottom: 1px solid var(--border);
}
.tr-row:last-child { border-bottom: 0; }
.tr-row.dirty { background: #fffbeb; }
.tr-head {
    position: sticky; top: 62px; z-index: 2;
    background: var(--card); font-size: 12px; font-weight: 700; color: var(--muted);
    padding-top: 12px; padding-bottom: 12px; border-radius: var(--radius) var(--radius) 0 0;
}
.tr-src { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tr-fa { font-size: 13.5px; line-height: 1.8; padding-top: 4px; word-break: break-word; }
.tr-key { font-size: 11px; color: var(--muted); background: var(--bg); padding: 1px 6px; border-radius: 5px; align-self: flex-start; }
.tr-ctx { font-size: 10.5px; font-weight: 700; color: #7c3aed; background: #f3e8ff; padding: 1px 7px; border-radius: 5px; align-self: flex-start; }
.tr-row textarea { resize: none; overflow: hidden; min-height: 34px; line-height: 1.6; font-size: 13px; }
.tr-row textarea.is-empty { background: #fff7ed; border-color: #fed7aa; }
.tr-actions { display: flex; align-items: center; gap: 6px; padding-top: 1px; }
.tr-state { font-size: 11px; white-space: nowrap; }
.tr-state.saving::before {
    content: ""; display: inline-block; width: 12px; height: 12px;
    border: 2px solid #cbd5e1; border-top-color: var(--brand); border-radius: 50%;
    animation: app-spin .7s linear infinite;
}
.tr-state.saved { color: var(--success); }
.tr-state.failed { color: var(--danger); font-weight: 800; }
@media (max-width: 860px) {
    .tr-row { grid-template-columns: 1fr; gap: 6px; }
    .tr-head { display: none; }
}
.choice-text { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; line-height: 1.45; }

/* تقویمِ persian-datepicker در صفحه‌های چپ‌به‌راست (انگلیسی/میلادی) */
[dir="ltr"] .datepicker-plot-area,
[dir="ltr"] .datepicker-plot-area table,
[dir="ltr"] .datepicker-plot-area table tr,
[dir="ltr"] .datepicker-plot-area table td,
[dir="ltr"] .datepicker-plot-area table th { direction: ltr !important; }
[dir="ltr"] .datepicker-plot-area .datepicker-navigator { direction: ltr; text-align: center; }
[dir="ltr"] .datepicker-plot-area .datepicker-navigator .pwt-btn-switch { float: none; display: inline-block; }
[dir="ltr"] .datepicker-plot-area .datepicker-navigator .pwt-btn-prev { float: left; font-size: 0; }
[dir="ltr"] .datepicker-plot-area .datepicker-navigator .pwt-btn-next { float: right; font-size: 0; }
[dir="ltr"] .datepicker-plot-area .datepicker-navigator .pwt-btn-prev::before { content: "\2039"; font-size: 18px; }
[dir="ltr"] .datepicker-plot-area .datepicker-navigator .pwt-btn-next::before { content: "\203A"; font-size: 18px; }
[dir="ltr"] .datepicker-plot-area .header-row-cell { float: left !important; }
.datepicker-plot-area { font-family: Vazirmatn, "Segoe UI", Tahoma, sans-serif; }
/* ===== ماتریسِ مجوزِ ریزدانه و دیفِ ممیزی (مدیریت سیستم) ===== */
.perm-matrix td, .perm-matrix th { text-align: center; }
.perm-matrix td:first-child, .perm-matrix th:first-child { text-align: start; }
.perm-matrix input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--fu-action, #0f766e); cursor: pointer; }
.perm-matrix .na { color: var(--fu-line, #e4e7ec); }

/* دیفِ ممیزی */
.audit-diff { margin: 0; font-size: 12px; }
.audit-diff td { padding: 2px 8px; border-bottom: 1px dashed var(--fu-line, #e5e7eb); vertical-align: top; white-space: normal !important; overflow-wrap: anywhere; max-width: 420px; }
.audit-diff .k { color: var(--fu-muted, #6b7280); white-space: nowrap; }
.audit-diff .b { color: var(--sev-critical, #b42318); text-decoration: line-through; text-decoration-thickness: 1px; }
.audit-diff .a { color: var(--st-ok, #067647); }
