/* ============================================================================
   استایل اصلی سیستم ثبت دانش شرکت توسعه آهن و فولاد گل گهر
   ----------------------------------------------------------------------------
   - رنگ‌بندی: قرمز (رنگ سازمانی لوگو) و خاکستری
   - فونت پیش‌فرض: Vazirmatn و فونت دوم: Tahoma
   - راست‌به‌چپ و بهینه برای موبایل (Mobile First)
   ============================================================================ */

/* ---------- فونت وزیرمتن (فایل‌های محلی) ---------- */
@font-face { font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn-Light.woff2') format('woff2'); font-weight: 300; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn-Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }

/* ---------- متغیرهای رنگ و اندازه ---------- */
:root {
    --red: #c8202a;          /* قرمز سازمانی */
    --red-dark: #a3161f;
    --red-light: #fdecec;
    --gray-900: #2e2e2c;     /* خاکستری تیره لوگو */
    --gray-800: #3a3a38;
    --gray-700: #4f4f4c;
    --gray-600: #6b6b68;
    --gray-500: #8d8d8a;
    --gray-400: #b5b5b2;
    --gray-300: #d6d6d3;
    --gray-200: #e8e8e6;
    --gray-100: #f3f3f2;
    --gray-50: #f9f9f8;
    --white: #ffffff;
    --green: #1e8e4e;
    --green-light: #e6f5ec;
    --amber: #b7791f;
    --amber-light: #fdf5e4;
    --blue: #2b6cb0;
    --blue-light: #e8f1fb;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 40px rgba(0,0,0,.18);
    --sidebar-w: 270px;
    --font: 'Vazirmatn', Tahoma, sans-serif;
}

/* ---------- پایه ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
    margin: 0; font-family: var(--font); color: var(--gray-900); background: var(--gray-100);
    direction: rtl; line-height: 1.8; min-height: 100vh;
}
input, select, textarea, button { font-family: var(--font); font-size: 1rem; }
a { color: var(--red); text-decoration: none; }
a:hover { color: var(--red-dark); }
h1, h2, h3, h4 { line-height: 1.5; margin: 0 0 .6rem; }
img { max-width: 100%; }
code { background: var(--gray-100); padding: 1px 6px; border-radius: 4px; direction: ltr; display: inline-block; }
.ltr { direction: ltr; text-align: left; }
.text-muted { color: var(--gray-600); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0 } .mt-1 { margin-top: .5rem } .mt-2 { margin-top: 1rem } .mt-3 { margin-top: 1.5rem }
.mb-0 { margin-bottom: 0 } .mb-1 { margin-bottom: .5rem } .mb-2 { margin-bottom: 1rem }
.hidden { display: none !important; }
.ic { width: 18px; height: 18px; flex-shrink: 0; vertical-align: middle; }

/* ---------- کارت ---------- */
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1.25rem; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
    border-bottom: 1px solid var(--gray-200); margin: -1.25rem -1.25rem 1.25rem; padding: 1rem 1.25rem; }
.card-header h2, .card-header h3 { margin: 0; font-size: 1.1rem; display: flex; align-items: center; gap: .5rem; }
.card-header h2 .ic, .card-header h3 .ic { color: var(--red); }

/* ---------- دکمه‌ها ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .55rem 1.1rem;
    border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer; font-weight: 500;
    transition: background .15s, box-shadow .15s, transform .05s; text-decoration: none; white-space: nowrap; line-height: 1.6;
    background: var(--gray-200); color: var(--gray-900);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); color: #fff; }
.btn-dark { background: var(--gray-900); color: #fff; }
.btn-dark:hover { background: var(--gray-700); color: #fff; }
.btn-light { background: var(--gray-100); color: var(--gray-900); border-color: var(--gray-300); }
.btn-light:hover { background: var(--gray-200); color: var(--gray-900); }
.btn-outline { background: transparent; border-color: var(--red); color: var(--red); }
.btn-outline:hover { background: var(--red-light); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #17733f; color: #fff; }
.btn-danger { background: transparent; color: var(--red); border-color: var(--gray-300); }
.btn-danger:hover { background: var(--red-light); border-color: var(--red); color: var(--red); }
.btn-sm { padding: .3rem .7rem; font-size: .88rem; }
.btn-lg { padding: .75rem 1.4rem; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-icon { padding: .5rem; background: var(--gray-100); border-color: var(--gray-300); }
.btn-group { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.actions { display: flex; gap: .35rem; flex-wrap: wrap; }
.actions form { display: inline; margin: 0; }

/* ---------- فرم‌ها ---------- */
.form-group { margin-bottom: 1rem; }
.form-group > label, .form-label { display: block; font-weight: 500; margin-bottom: .35rem; font-size: .93rem; color: var(--gray-800); }
.req::after { content: ' *'; color: var(--red); }
.form-control {
    width: 100%; padding: .6rem .85rem; border: 1px solid var(--gray-300); border-radius: var(--radius-sm);
    background: var(--white); color: var(--gray-900); transition: border-color .15s, box-shadow .15s; min-height: 44px;
}
.form-control:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(200, 32, 42, .12); }
.form-control.is-invalid { border-color: var(--red); background: #fff8f8; }
textarea.form-control { min-height: 120px; resize: vertical; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6b68' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: left .8rem center; padding-left: 2rem; }
.form-hint { font-size: .82rem; color: var(--gray-600); margin-top: .25rem; }
.field-error { font-size: .82rem; color: var(--red); margin-top: .25rem; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 0 1rem; }
.form-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .5rem; }
.input-icon { position: relative; }
.input-icon .form-control { padding-left: 2.6rem; }
.input-icon .toggle-pass { position: absolute; left: .5rem; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--gray-500); cursor: pointer; padding: .3rem; }
.check { display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--red); }

/* ---------- هشدارها ---------- */
.alert { position: relative; padding: .8rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; border-right: 4px solid; font-size: .95rem; }
.alert-success { background: var(--green-light); border-color: var(--green); color: #14532d; }
.alert-error   { background: var(--red-light); border-color: var(--red); color: #7f1d1d; }
.alert-warning { background: var(--amber-light); border-color: var(--amber); color: #78350f; }
.alert-info    { background: var(--blue-light); border-color: var(--blue); color: #1e3a5f; }
.alert-close { position: absolute; left: .6rem; top: .45rem; background: none; border: 0; font-size: 1.3rem; cursor: pointer; color: inherit; opacity: .6; }
.alert ul { margin: .3rem 0 0; padding-right: 1.2rem; }

/* ---------- نشان‌ها ---------- */
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px;
    border-radius: 10px; background: var(--red); color: #fff; font-size: .75rem; font-weight: 700; font-style: normal; }
.tag { display: inline-block; padding: 1px 10px; border-radius: 20px; font-size: .8rem; background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-200); white-space: nowrap; }
.tag-green { background: var(--green-light); color: var(--green); border-color: #bfe5cd; }
.tag-red { background: var(--red-light); color: var(--red); border-color: #f5c6c8; }
.tag-dark { background: var(--gray-900); color: #fff; border-color: var(--gray-900); }

/* ---------- جدول‌ها ---------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-sm); border: 1px solid var(--gray-200); }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; background: var(--white); }
.table th, .table td { padding: .7rem .8rem; text-align: right; border-bottom: 1px solid var(--gray-200); vertical-align: middle; }
.table th { background: var(--gray-50); color: var(--gray-700); font-weight: 700; white-space: nowrap; font-size: .85rem; }
.table tbody tr:hover { background: #fcf7f7; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { width: 50px; color: var(--gray-500); }
.table tr.row-inactive td { color: var(--gray-500); }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--gray-500); }
.empty-state .ic { width: 42px; height: 42px; color: var(--gray-300); display: block; margin: 0 auto .5rem; }

/* ---------- فیلترها ---------- */
.filters { display: grid; grid-template-columns: 1fr; gap: .75rem; align-items: end; margin-bottom: 1rem; }
.filters .form-group { margin: 0; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.result-count { color: var(--gray-600); font-size: .9rem; }

/* ---------- صفحه‌بندی ---------- */
.pagination { display: flex; gap: .3rem; justify-content: center; margin-top: 1rem; flex-wrap: wrap; }
.pagination a { min-width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-sm);
    background: var(--white); border: 1px solid var(--gray-300); color: var(--gray-800); }
.pagination a.active, .pagination a:hover { background: var(--red); border-color: var(--red); color: #fff; }

/* ============================================================================
   ساختار پیشخوان: منوی کناری + محتوا
   ============================================================================ */
.sidebar {
    position: fixed; top: 0; right: 0; bottom: 0; width: var(--sidebar-w); background: var(--gray-900); color: #e8e8e6;
    display: flex; flex-direction: column; z-index: 1000; transform: translateX(100%); transition: transform .25s ease; overflow-y: auto;
}
.sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
.sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 999; display: none; }
.sidebar-overlay.show { display: block; }
.sidebar-brand { display: flex; align-items: center; gap: .75rem; padding: 1.1rem 1.1rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-brand img { width: 46px; height: 46px; object-fit: contain; background: #fff; border-radius: 10px; padding: 5px; }
.sidebar-brand strong { display: block; font-size: 1rem; color: #fff; }
.sidebar-brand small { display: block; font-size: .78rem; color: var(--gray-400); }
.sidebar-nav { padding: .6rem .6rem 1.2rem; flex: 1; }
.sidebar-nav a, .logout-form button {
    display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem; color: #d6d6d3; border-radius: var(--radius-sm);
    margin-bottom: 2px; font-size: .93rem; transition: background .15s, color .15s; width: 100%; background: none; border: 0; cursor: pointer; text-align: right;
}
.sidebar-nav a:hover, .logout-form button:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-nav a.active { background: var(--red); color: #fff; box-shadow: 0 4px 14px rgba(200,32,42,.35); }
.sidebar-nav a .badge { margin-right: auto; background: #fff; color: var(--red); }
.sidebar-nav a.active .badge { background: #fff; }
.nav-section { font-size: .75rem; color: var(--gray-500); padding: .9rem .8rem .3rem; font-weight: 700; letter-spacing: .3px; }
.logout-form { margin: .8rem 0 0; border-top: 1px solid rgba(255,255,255,.08); padding-top: .6rem; }
.logout-form button { color: #f3a5a9; }

.main { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: .75rem; background: var(--white);
    padding: .6rem 1rem; box-shadow: 0 1px 0 var(--gray-200); min-height: 64px;
}
.menu-toggle { background: var(--gray-100); border: 0; border-radius: var(--radius-sm); padding: .5rem; cursor: pointer; color: var(--gray-900); display: inline-flex; }
.topbar-title { display: flex; align-items: center; gap: .6rem; flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 1.05rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-logo { width: 32px; height: 32px; object-fit: contain; }
.topbar-user { display: flex; align-items: center; gap: .6rem; }
.topbar-icon { position: relative; color: var(--gray-700); display: inline-flex; padding: .4rem; border-radius: var(--radius-sm); }
.topbar-icon:hover { background: var(--gray-100); color: var(--red); }
.topbar-icon .badge { position: absolute; top: -4px; left: -6px; }
.user-chip { display: flex; align-items: center; gap: .5rem; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--red); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.user-chip-text { display: none; line-height: 1.3; }
.user-chip-text strong { display: block; font-size: .9rem; }
.user-chip-text small { color: var(--gray-600); font-size: .78rem; }
.content { padding: 1rem; flex: 1; width: 100%; max-width: 1400px; margin: 0 auto; }
.footer { text-align: center; color: var(--gray-500); font-size: .82rem; padding: 1rem; }

/* ---------- کارت‌های آمار ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .8rem; margin-bottom: 1.25rem; }
.stat-card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; display: flex; align-items: center; gap: .8rem; position: relative; overflow: hidden; }
.stat-card::before { content: ''; position: absolute; right: 0; top: 0; bottom: 0; width: 4px; background: var(--red); }
.stat-card.gray::before { background: var(--gray-700); }
.stat-icon { width: 46px; height: 46px; border-radius: 12px; background: var(--red-light); color: var(--red); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-card.gray .stat-icon { background: var(--gray-100); color: var(--gray-800); }
.stat-icon .ic { width: 24px; height: 24px; }
.stat-value { font-size: 1.45rem; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: .82rem; color: var(--gray-600); }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 1.25rem; }
.grid-2 > *, .card, .chart-box { min-width: 0; }
.quick-links { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; }
.quick-links a { display: flex; flex-direction: column; align-items: center; gap: .4rem; padding: 1rem .5rem; border-radius: var(--radius-sm);
    background: var(--gray-50); border: 1px solid var(--gray-200); color: var(--gray-800); text-align: center; font-size: .9rem; }
.quick-links a:hover { border-color: var(--red); color: var(--red); background: var(--red-light); }
.quick-links .ic { width: 26px; height: 26px; color: var(--red); }
.welcome { background: linear-gradient(120deg, var(--gray-900), #4a4a47); color: #fff; border-radius: var(--radius); padding: 1.3rem; margin-bottom: 1.25rem; display: flex; align-items: center; gap: 1rem; position: relative; overflow: hidden; }
.welcome::after { content: ''; position: absolute; left: -40px; bottom: -40px; width: 140px; height: 140px; border-radius: 50%; background: var(--red); opacity: .9; }
.welcome h2 { margin: 0; font-size: 1.15rem; }
.welcome p { margin: .2rem 0 0; color: var(--gray-300); font-size: .9rem; }
.welcome > * { position: relative; z-index: 1; }

/* ---------- مودال ---------- */
.modal { position: fixed; inset: 0; background: rgba(20,20,20,.55); display: none; align-items: flex-end; justify-content: center; z-index: 2000; padding: 0; }
.modal.show { display: flex; }
.modal-dialog { background: var(--white); width: 100%; max-width: 560px; border-radius: var(--radius) var(--radius) 0 0; max-height: 92vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: modalIn .2s ease; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.2rem; border-bottom: 1px solid var(--gray-200); }
.modal-header h3 { margin: 0; font-size: 1.05rem; }
.modal-close { background: none; border: 0; font-size: 1.6rem; cursor: pointer; color: var(--gray-500); line-height: 1; }
.modal-body { padding: 1.2rem; overflow-y: auto; }
.modal-footer { padding: .9rem 1.2rem; border-top: 1px solid var(--gray-200); display: flex; gap: .5rem; justify-content: flex-start; }
@keyframes modalIn { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- ویزارد ثبت دانش ---------- */
.wizard-steps { display: flex; justify-content: space-between; list-style: none; padding: 0; margin: 0 0 1.5rem; counter-reset: step; position: relative; }
.wizard-steps::before { content: ''; position: absolute; top: 18px; right: 12%; left: 12%; height: 3px; background: var(--gray-200); z-index: 0; }
.wizard-steps li { flex: 1; text-align: center; position: relative; z-index: 1; font-size: .78rem; color: var(--gray-500); }
.wizard-steps li span { width: 38px; height: 38px; border-radius: 50%; background: var(--white); border: 3px solid var(--gray-300); display: flex; align-items: center; justify-content: center;
    margin: 0 auto .3rem; font-weight: 700; color: var(--gray-500); transition: all .2s; }
.wizard-steps li.active span { border-color: var(--red); background: var(--red); color: #fff; box-shadow: 0 0 0 5px rgba(200,32,42,.15); }
.wizard-steps li.active { color: var(--gray-900); font-weight: 700; }
.wizard-steps li.done span { border-color: var(--gray-900); background: var(--gray-900); color: #fff; }
.wizard-panel { display: none; }
.wizard-panel.active { display: block; animation: fadeIn .2s ease; }
.wizard-nav { display: flex; justify-content: space-between; gap: .6rem; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--gray-200); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ناحیه کشیدن و رها کردن فایل */
.dropzone { border: 2px dashed var(--gray-300); border-radius: var(--radius); padding: 1.6rem 1rem; text-align: center; cursor: pointer; background: var(--gray-50); transition: all .15s; }
.dropzone:hover, .dropzone.dragover { border-color: var(--red); background: var(--red-light); }
.dropzone .ic { width: 40px; height: 40px; color: var(--red); }
.dropzone p { margin: .4rem 0 0; }
.file-list { list-style: none; padding: 0; margin: .8rem 0 0; }
.file-list li { display: flex; align-items: center; gap: .6rem; padding: .5rem .7rem; border: 1px solid var(--gray-200); border-radius: var(--radius-sm); margin-bottom: .4rem; background: var(--white); font-size: .9rem; }
.file-list li .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: right; }
.file-list li .size { color: var(--gray-500); font-size: .8rem; white-space: nowrap; }
.file-list li.removed { opacity: .45; text-decoration: line-through; }
.file-list .ic { color: var(--gray-600); }

/* درخت دانش */
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { padding-right: 1.4rem; border-right: 1px dashed var(--gray-300); margin-right: .6rem; }
.tree li { margin: .15rem 0; }
.tree-node { display: flex; align-items: center; gap: .4rem; padding: .35rem .5rem; border-radius: var(--radius-sm); }
.tree-node:hover { background: var(--gray-50); }
.tree-toggle { width: 22px; height: 22px; border: 0; background: var(--gray-200); border-radius: 5px; cursor: pointer; font-weight: 700; line-height: 1; color: var(--gray-700); flex-shrink: 0; }
.tree-toggle.empty { visibility: hidden; }
.tree li.collapsed > ul { display: none; }
.tree-node label { display: flex; align-items: center; gap: .4rem; cursor: pointer; flex: 1; }
.tree-node input[type=radio] { accent-color: var(--red); width: 17px; height: 17px; }
.tree-node input[type=radio]:checked + span { color: var(--red); font-weight: 700; }
.tree-node .tree-actions { margin-right: auto; display: flex; gap: .25rem; }
.tree-box { max-height: 420px; overflow: auto; border: 1px solid var(--gray-200); border-radius: var(--radius-sm); padding: .6rem; }
.selected-path { margin-top: .6rem; padding: .5rem .8rem; background: var(--red-light); border-radius: var(--radius-sm); font-size: .9rem; }

/* مشارکت‌کنندگان */
.owner-box { display: flex; align-items: center; gap: .7rem; padding: .8rem 1rem; background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: var(--radius-sm); margin-bottom: 1rem; }
.percent-bar { height: 8px; background: var(--gray-200); border-radius: 4px; overflow: hidden; margin-top: .4rem; }
.percent-bar > div { height: 100%; background: var(--red); transition: width .2s; }

/* جستجوی کاربر در لیست بازشونده */
.searchable-select { position: relative; }
.searchable-select .ss-list { position: absolute; top: 100%; right: 0; left: 0; z-index: 30; background: var(--white); border: 1px solid var(--gray-300); border-radius: var(--radius-sm);
    max-height: 230px; overflow-y: auto; box-shadow: var(--shadow); display: none; margin-top: 2px; }
.searchable-select.open .ss-list { display: block; }
.ss-list div { padding: .5rem .8rem; cursor: pointer; font-size: .92rem; }
.ss-list div:hover, .ss-list div.hl { background: var(--red-light); }
.ss-list small { color: var(--gray-500); }

/* ---------- محتوای دانش ---------- */
.k-meta { display: grid; grid-template-columns: 1fr; gap: .5rem 1.5rem; margin-bottom: 1rem; }
.k-meta div { font-size: .92rem; padding: .3rem 0; border-bottom: 1px dashed var(--gray-200); }
.k-meta b { color: var(--gray-600); font-weight: 500; margin-left: .3rem; }
.rich-content { line-height: 2; overflow-wrap: anywhere; }
.rich-content img { height: auto; border-radius: 6px; }
.rich-content table { border-collapse: collapse; max-width: 100%; }
.rich-content td, .rich-content th { border: 1px solid var(--gray-300); padding: .3rem .5rem; }

/* ---------- پیام‌ها ---------- */
.tabs { display: flex; gap: .3rem; border-bottom: 2px solid var(--gray-200); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .55rem 1rem; color: var(--gray-700); border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; display: inline-flex; align-items: center; gap: .4rem; }
.tabs a.active { color: var(--red); border-color: var(--red); font-weight: 700; }
.msg-list { list-style: none; margin: 0; padding: 0; }
.msg-list li a { display: flex; gap: .8rem; padding: .85rem .6rem; border-bottom: 1px solid var(--gray-200); color: var(--gray-900); align-items: flex-start; }
.msg-list li a:hover { background: var(--gray-50); }
.msg-list li.unread a { background: #fff7f7; }
.msg-list li.unread .msg-subject { font-weight: 700; }
.msg-list .msg-body { flex: 1; min-width: 0; }
.msg-list .msg-subject { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-list .msg-from { font-size: .82rem; color: var(--gray-600); }
.msg-list .msg-date { font-size: .78rem; color: var(--gray-500); white-space: nowrap; }
.msg-thread .msg-item { border: 1px solid var(--gray-200); border-radius: var(--radius-sm); padding: .9rem 1rem; margin-bottom: .8rem; background: var(--white); }
.msg-thread .msg-item.mine { background: var(--gray-50); border-right: 3px solid var(--gray-700); }
.msg-thread .msg-item.theirs { border-right: 3px solid var(--red); }
.msg-thread .msg-head { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; font-size: .85rem; color: var(--gray-600); margin-bottom: .4rem; }
.msg-thread .msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }

/* نمودارها */
.chart-box { position: relative; height: 300px; }

/* دیت‌پیکر شمسی */
jdp-container { --jdp-primary: #c8202a; font-family: var(--font) !important; }
jdp-container * { font-family: var(--font) !important; }
input[data-jdp] { direction: ltr; text-align: right; }

/* ============================================================================
   صفحه ورود
   ============================================================================ */
.login-page { background: var(--gray-100); background-image: radial-gradient(circle at 10% 90%, rgba(200,32,42,.08), transparent 40%), radial-gradient(circle at 90% 10%, rgba(46,46,44,.08), transparent 40%); display: flex; flex-direction: column; }
.login-wrapper { flex: 1; display: grid; grid-template-columns: 1fr; gap: 1.25rem; max-width: 1100px; width: 100%; margin: 0 auto; padding: 1rem; align-items: center; }
.login-info { order: 2; }
.login-card { order: 1; padding: 1.6rem 1.3rem; border-top: 4px solid var(--red); margin: 0; }
.login-card h2 { text-align: center; font-size: 1.2rem; margin-bottom: 1rem; }
.login-card-logo { display: block; width: 70px; margin: 0 auto .6rem; }
.login-logo { display: block; width: 240px; max-width: 70%; margin: 0 auto 1rem; }
.login-info h1 { font-size: 1.25rem; text-align: center; color: var(--gray-900); }
.login-info .lead { text-align: center; color: var(--gray-600); margin-bottom: 1rem; }
.help-block { background: var(--white); border-radius: var(--radius); padding: 1rem 1.2rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.help-block h2 { font-size: 1rem; display: flex; align-items: center; gap: .5rem; color: var(--red); }
.help-block ul, .help-block ol { margin: 0; padding-right: 1.2rem; font-size: .92rem; color: var(--gray-700); }
.help-block li { margin-bottom: .25rem; }
.steps-list { list-style: none; padding: 0 !important; }
.role-switch { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; background: var(--gray-100); border-radius: var(--radius-sm); padding: .3rem; margin-bottom: 1.2rem; }
.role-switch label { display: flex; align-items: center; justify-content: center; gap: .4rem; padding: .6rem; border-radius: 7px; cursor: pointer; font-weight: 500; color: var(--gray-600); transition: all .15s; }
.role-switch label.active { background: var(--white); color: var(--red); box-shadow: var(--shadow); }
.role-switch input { position: absolute; opacity: 0; pointer-events: none; }
.captcha-row { display: flex; gap: .5rem; align-items: center; }
.captcha-row .form-control { flex: 1; min-width: 70px; font-size: 1.1rem; text-align: center; }
.captcha-row img { border-radius: var(--radius-sm); border: 1px solid var(--gray-300); height: 44px; width: auto; }
/* فیلد تله ضد ربات: بدون جابجایی خارج از صفحه (در RTL باعث اسکرول افقی می‌شد) */
.hp-field { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); opacity: 0; pointer-events: none; }
#loginForm { position: relative; }
body { overflow-x: hidden; }
.login-footer { text-align: center; color: var(--gray-500); font-size: .82rem; padding: 1rem; }

/* صفحه نصب */
.install-page { display: flex; align-items: center; justify-content: center; padding: 1rem; }
.install-box { max-width: 520px; width: 100%; text-align: center; }
.install-logo { width: 220px; margin-bottom: 1rem; }
.install-box h1 { font-size: 1.15rem; }
.install-info { text-align: right; }

/* ============================================================================
   واکنش‌گرایی (تبلت و دسکتاپ)
   ============================================================================ */
@media (min-width: 576px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-grid { grid-template-columns: repeat(2, 1fr); }
    .filters { grid-template-columns: repeat(2, 1fr); }
    .quick-links { grid-template-columns: repeat(3, 1fr); }
    .k-meta { grid-template-columns: repeat(2, 1fr); }
    .modal { align-items: center; padding: 1rem; }
    .modal-dialog { border-radius: var(--radius); }
    .wizard-steps li { font-size: .88rem; }
    .user-chip-text { display: block; }
}
@media (min-width: 768px) {
    .content { padding: 1.5rem; }
    .filters { grid-template-columns: repeat(4, 1fr); }
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
    .form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 992px) {
    .sidebar { transform: none; }
    .sidebar-overlay { display: none !important; }
    .main { margin-right: var(--sidebar-w); }
    .menu-toggle, .topbar-logo { display: none; }
    .grid-2 { grid-template-columns: 1fr 1fr; }
    .login-wrapper { grid-template-columns: 1.15fr .85fr; gap: 2.5rem; padding: 2rem; }
    .login-info { order: 1; }
    .login-card { order: 2; padding: 2rem; }
    .login-info h1, .login-info .lead { text-align: right; }
    .login-logo { margin-right: 0; }
}

/* حالت چاپ */
@media print {
    .sidebar, .topbar, .footer, .btn, .filters, .actions { display: none !important; }
    .main { margin: 0 !important; }
    body { background: #fff; }
    .card { box-shadow: none; }
}
