body {
    font-family: Vazirmatn, Tahoma, sans-serif;
    background: #f6f8fb;
}

.card {
    border-radius: 1rem;
}

.badge {
    font-size: .75rem;
}

/* ---------- فاصله‌ی راست در متن فارسی ----------
   Bootstrap نسخه‌ی LTR مارجین‌های ms-* / me-* را فیزیکی (چپ/راست) می‌گذارد؛
   در صفحه‌ی RTL باید منطقی (inline-start/end) باشند. */
span.badge:not(:first-child) {
    margin-inline-start: .5rem;
}

[dir="rtl"] .ms-1 { margin-left: 0 !important; margin-right: .25rem !important; }
[dir="rtl"] .ms-2 { margin-left: 0 !important; margin-right: .5rem !important; }
[dir="rtl"] .ms-3 { margin-left: 0 !important; margin-right: 1rem !important; }
[dir="rtl"] .me-1 { margin-right: 0 !important; margin-left: .25rem !important; }
[dir="rtl"] .me-2 { margin-right: 0 !important; margin-left: .5rem !important; }
[dir="rtl"] .me-3 { margin-right: 0 !important; margin-left: 1rem !important; }

/* ---------- امتیاز ---------- */
.score-ring {
    --p: 0;
    --c: #198754;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: conic-gradient(var(--c) calc(var(--p) * 1%), #e9ecef 0);
    display: grid;
    place-items: center;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
}

.score-ring-inner {
    width: 114px;
    height: 114px;
    border-radius: 50%;
    background: #fff;
    display: grid;
    place-content: center;
    text-align: center;
}

.score-number {
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1;
}

.grade-badge {
    display: inline-block;
    min-width: 2.2rem;
    padding: .25rem .6rem;
    border-radius: .6rem;
    font-weight: 700;
    color: #fff;
    background: #6c757d;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
}

.grade-A { background: #198754; }
.grade-B { background: #20c997; }
.grade-C { background: #ffc107; color: #212529; }
.grade-D { background: #fd7e14; }
.grade-F { background: #dc3545; }

.stat-box {
    background: #f8f9fa;
    border-radius: .75rem;
    padding: .5rem;
}

.stat-number {
    font-size: 1.5rem;
    font-weight: 700;
}

/* ---------- مشخصات گزارش ---------- */
.report-meta th {
    width: 11rem;
    white-space: nowrap;
    vertical-align: top;
}

.report-meta td {
    word-break: break-word;
}

/* ---------- تب‌ها ---------- */
.report-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
    border-bottom: 2px solid #dee2e6;
    margin-bottom: 1.25rem;
}

.report-tab-btn {
    border: 0;
    background: transparent;
    padding: .65rem 1.1rem;
    font-weight: 600;
    color: #6c757d;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

.report-tab-btn:hover {
    color: #0d6efd;
}

.report-tab-btn.active {
    color: #0d6efd;
    border-bottom-color: #0d6efd;
}

/* ---------- تب ساده ---------- */
.lay-verdict {
    border-inline-start: 5px solid #0d6efd !important;
}

.lay-acute {
    border-inline-start: 5px solid #dc3545 !important;
}

.lay-cat {
    background: #f8f9fa;
    border-radius: .75rem;
    padding: .9rem 1rem;
    height: 100%;
}

.lay-item {
    border: 1px solid #e9ecef;
    border-radius: .75rem;
    padding: .75rem 1rem;
    margin-bottom: .6rem;
    background: #fff;
}

.lay-item-critical {
    border-color: #f1aeb5;
    background: #fff8f8;
}

.lay-item-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .25rem;
}

.lay-item-text {
    margin-top: .35rem;
    color: #495057;
    font-size: .92rem;
}

.lay-item-ask {
    margin-top: .35rem;
    font-size: .88rem;
    background: #f1f3f5;
    border-radius: .5rem;
    padding: .4rem .65rem;
}

.rate-great { background: #198754; color: #fff; }
.rate-good { background: #20c997; color: #fff; }
.rate-mid { background: #ffc107; color: #212529; }
.rate-weak { background: #fd7e14; color: #fff; }
.rate-bad { background: #dc3545; color: #fff; }

/* ---------- سختی اصلاح ---------- */
.effort-badge {
    font-weight: 600;
    cursor: help;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
}

.effort-easy { background: #d1e7dd; color: #0f5132; }
.effort-medium { background: #fff3cd; color: #664d03; }
.effort-hard { background: #f8d7da; color: #842029; }

.effort-cell {
    white-space: nowrap;
}

.effort-legend .legend-text {
    margin-inline-start: .35rem;
    margin-inline-end: .9rem;
}

/* ---------- نمای کلی دسته‌ها ---------- */
.overview-row {
    display: grid;
    grid-template-columns: 11rem 1fr 4rem 6rem;
    gap: .75rem;
    align-items: center;
    padding: .25rem 0;
}

.overview-bar {
    height: .6rem;
}

.overview-score {
    font-weight: 700;
    text-align: center;
}

.overview-time {
    text-align: left;
}

/* ---------- دسته‌ها ---------- */
.cat-card > summary {
    list-style: none;
    cursor: pointer;
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cat-card > summary::-webkit-details-marker {
    display: none;
}

.cat-card > summary::before {
    content: "\25C2";
    margin-inline-end: .5rem;
    transition: transform .15s;
}

.cat-card[open] > summary::before {
    transform: rotate(-90deg);
}

.cat-card > summary .fw-bold {
    flex: 1;
}

.cat-meta {
    display: inline-flex;
    align-items: center;
}

.scan-value {
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* جدول بررسی‌ها: عرض ستون‌ها با colgroup در report.js تعیین می‌شود (بررسی 20٪، وضعیت 8٪، مقدار 30٪، توضیحات 30٪، پیچیدگی 12٪) */
.checks-table {
    table-layout: fixed;
    width: 100%;
    min-width: 900px;
}

.checks-table th,
.checks-table td {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.checks-table .effort-cell {
    white-space: normal;
}

/* لینک فایل‌ها: فقط نام فایل (آدرس کامل در tooltip و href) */
.file-link {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
    unicode-bidi: plaintext;
}

/* ---------- لینک‌های آموزش و مستندات ---------- */
.desc-links {
    margin-top: .35rem;
    display: flex;
    flex-wrap: wrap;
    gap: .25rem 1rem;
    font-size: .8rem;
}

.desc-link {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    text-decoration: none;
    white-space: nowrap;
}

.desc-link:hover {
    text-decoration: underline;
}

.desc-link + .desc-link {
    margin-inline-start: .5rem;
}

.icon-svg {
    flex: 0 0 auto;
    vertical-align: middle;
}

.learn-link {
    font-weight: 600;
}

.fade-in {
    animation: fadeIn .35s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

/* ---------- نمودار روند ---------- */
.trend-box {
    overflow-x: auto;
}

.trend-svg {
    width: 100%;
    max-width: 720px;
    height: auto;
    display: block;
}

.trend-grid {
    stroke: #dee2e6;
    stroke-width: 1;
}

.trend-line {
    stroke: #0d6efd;
    stroke-width: 2.5;
    stroke-linejoin: round;
}

.trend-point {
    stroke: #fff;
    stroke-width: 2;
}

.trend-label {
    font-size: 11px;
    fill: #6c757d;
}

/* ---------- صفحه‌ی قوانین ---------- */
.legal-text {
    line-height: 2;
}

@media (max-width: 767px) {
    .overview-row {
        grid-template-columns: 1fr 5rem 3rem;
    }

    .overview-time {
        display: none;
    }
}

/* ---------- چاپ ---------- */
@page {
    margin: 12mm;
}

@media print {
    body {
        background: #fff;
    }

    .no-print,
    #scanForm,
    #loading,
    #printButton,
    header,
    footer,
    nav {
        display: none !important;
    }

    /* در چاپ هر دو تب (خلاصه‌ی ساده و گزارش فنی) چاپ می‌شوند. */
    .tab-panel[hidden] {
        display: block !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        break-inside: avoid;
    }

    .cat-card {
        break-inside: auto;
    }

    .cat-card > summary::before {
        display: none;
    }

    .cat-card tr,
    .lay-item {
        break-inside: avoid;
    }

    a[href]:after {
        content: none !important;
    }

    .fade-in {
        animation: none;
    }
}

/* ---------- نوار پیشرفت نمایشی اسکن ---------- */
.scan-progress {
    max-width: 900px;
    margin: 0 auto;
}

.scan-progress-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .6rem;
}

.scan-progress-bar {
    height: 10px;
    border-radius: 999px;
}

.scan-progress-bar .progress-bar {
    transition: width .5s ease;
}

.scan-steps {
    list-style: none;
    margin: 1.25rem 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: .6rem 1.5rem;
}

.scan-steps li {
    display: flex;
    align-items: center;
    gap: .6rem;
    color: #9ca3af;
    transition: color .3s ease;
}

.scan-steps li.is-active {
    color: #1f2937;
    font-weight: 600;
}

.scan-steps li.is-done {
    color: #198754;
}

.scan-step-icon {
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid #d1d5db;
    display: inline-grid;
    place-items: center;
    box-sizing: border-box;
    font-size: 13px;
    line-height: 1;
}

.is-active .scan-step-icon {
    border-color: #cfd8ff;
    border-top-color: #3d5afe;
    animation: scan-step-spin .8s linear infinite;
}

.is-done .scan-step-icon {
    border-color: #198754;
    background: #198754;
    color: #fff;
}

.is-done .scan-step-icon::before {
    content: "✓";
}

@keyframes scan-step-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .is-active .scan-step-icon { animation: none; border-top-color: #3d5afe; }
    .scan-progress-bar .progress-bar { transition: none; }
}
