/* ==========================================================================
   خدمات نقل الملكية — أنماط القسم
   يُحمَّل بعد site.css في كل الصفحات، لذا كل قاعدة هنا محصورة في أصناف
   القسم الجديدة ولا تلمس أصناف نظام التقسيط، ولا يوجد هنا أي @page:
   قواعد الصفحة المطبوعة تبقى في print.css وفي صفحة الستكر نفسها.
   ========================================================================== */

:root {
    /* ألوان سلاسل الرسوم — لوحة مفحوصة لعمى الألوان بالترتيب نفسه دائماً:
       الكحلي = حصة المعرض، الذهبي، الأخضر المزرق، والبنفسجي للحلقة الرباعية فقط */
    --series-1: #2456A6;
    --series-2: #B8860B;
    --series-3: #128E7E;
    --series-4: #8E5BC4;

    /* المصروفات: سلسلة واحدة بلونها المعتاد في النظام (الأحمر) — لا تدخل حلقات المصادر الأربعة */
    --series-expense: #D32F2F;

    --teal-700: #0B6B5F;
    --deduct: #9E2A2B;
}

/* ===================== الصفحة الرئيسية والتنقل بين القسمين ===================== */

/* بطاقة قسم نقل الملكية بتنسيق بطاقات البوابات نفسه (site.css) — بلا تمييز لوني */

.app-header .btn-section-switch {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    min-height: 34px;
    padding: .25rem .7rem;
    line-height: 1;
    color: var(--gold-500);
    background: rgba(212, 175, 55, .1);
    border: 1px solid rgba(212, 175, 55, .55);
    border-radius: var(--radius-sm);
    white-space: nowrap;
}
.app-header .btn-section-switch:hover,
.app-header .btn-section-switch:focus-visible {
    background: var(--gold-500);
    border-color: var(--gold-500);
    color: var(--black);
}

@media (max-width: 575.98px) {
    .app-header .btn-section-switch { min-width: 34px; padding: .25rem .45rem; margin-inline-start: .25rem !important; }
}

/* صفحة «قسم غير مسموح» */
.section-denied {
    width: 100%;
    max-width: 540px;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(212, 175, 55, .35);
    border-radius: 18px;
    padding: 2.25rem 1.75rem;
    box-shadow: 0 18px 44px rgba(0, 0, 0, .28);
}

/* ===================== المستخدمون: صلاحية الأقسام ===================== */

.section-choice {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .5rem;
}

.section-option {
    display: flex;
    align-items: center;
    gap: .55rem;
    margin: 0;
    padding: .65rem .75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: var(--white);
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.section-option:hover { border-color: var(--navy-600); }
.section-option .form-check-input { margin: 0; flex: 0 0 auto; cursor: pointer; }
.section-option span { font-size: .86rem; font-weight: 500; color: var(--navy-900); line-height: 1.35; }
.section-option span .bi { color: var(--navy-600); margin-inline-end: .15rem; }

.section-option:has(input:checked) {
    border-color: var(--navy-700);
    background: var(--navy-100);
    box-shadow: inset 0 0 0 1px var(--navy-700);
}
.section-option:has(input:focus-visible) { outline: 3px solid var(--gold-500); outline-offset: 2px; }

@media (max-width: 575.98px) {
    .section-choice { grid-template-columns: 1fr; }
}

.badge-section-installments { background: rgba(36, 86, 166, .12); color: var(--navy-600); }
.badge-section-transfer     { background: rgba(18, 142, 126, .13); color: var(--teal-700); }
.badge-section-installments + .badge-section-transfer { margin-inline-start: .25rem; }
.badge-section-installments .bi,
.badge-section-transfer .bi { margin-inline-end: .1rem; }

/* ===================== عناصر مشتركة في القسم ===================== */

/* رقم مستند (عملية، بطاقة، فاتورة): يُقرأ من اليسار ولا ينكسر */
.doc-number {
    font-weight: 600;
    color: var(--navy-700);
    letter-spacing: .3px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
:is(span, a, dd).doc-number { direction: ltr; unicode-bidi: isolate; }
a.doc-number:hover { color: var(--navy-900); text-decoration: underline; }

.page-title .doc-number {
    display: inline-block;
    background: var(--navy-100);
    border-radius: 8px;
    padding: .05rem .55rem;
    font-size: .88em;
}

/* لوحة السيارة: إطار داكن وشريط جانبي كاللوحة السعودية */
.plate-chip {
    display: inline-block;
    background: var(--white);
    color: var(--black);
    border: 1.5px solid #1C1C1C;
    border-inline-start: 6px solid var(--navy-700);
    border-radius: 5px;
    padding: 0 .45rem;
    font-size: .82rem;
    font-weight: 600;
    letter-spacing: .5px;
    line-height: 1.55;
    white-space: nowrap;
    vertical-align: middle;
}
.plate-chip-lg {
    font-size: 1.2rem;
    padding: .2rem .95rem;
    border-width: 2px;
    border-inline-start-width: 11px;
    border-radius: 8px;
}

/* قائمة مفتاح/قيمة في صفحات التفاصيل */
.kv-list {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: .5rem 1rem;
    margin: 0;
}
.kv-list dt { font-weight: 500; font-size: .84rem; color: var(--gray-600); }
.kv-list dd {
    margin: 0;
    text-align: left;
    font-weight: 500;
    color: var(--navy-900);
    overflow-wrap: anywhere;
}

/* أزرار الحفظ أسفل النماذج */
.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    align-items: center;
    padding: .25rem 0 1rem;
}

@media (max-width: 767.98px) {
    .form-actions { flex-direction: column; align-items: stretch; }
    .form-actions > .btn { width: 100%; }
}

/* أزرار الاختيار (فرد/شركة، العميل في الفاتورة): ‎.btn-outline-navy‎ صنف خاص بالمشروع
   لا يعرّف متغيرات Bootstrap لحالة الاختيار، فبدون هذا يبدو المختار وغير المختار سواء */
.btn-check + .btn-outline-navy { background: var(--white); }
.btn-check:not(:checked) + .btn-outline-navy:hover { background: var(--navy-100); color: var(--navy-800); }
.btn-check:checked + .btn-outline-navy,
.btn-check + .btn-outline-navy:active {
    background: var(--navy-700);
    border-color: var(--navy-700);
    color: var(--white);
}
.btn-check:focus-visible + .btn-outline-navy { outline: 3px solid var(--gold-500); outline-offset: 2px; box-shadow: none; }

/* قائمة نوع السيارة + زر الإضافة السريعة في صف واحد */
.car-type-picker {
    display: flex;
    align-items: stretch;
    gap: .4rem;
}
.car-type-picker > .ss-combo,
.car-type-picker > select { flex: 1 1 auto; min-width: 0; }
.car-type-picker .car-type-add {
    flex: 0 0 auto;
    padding-inline: .8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ===================== نموذج نقل الملكية ===================== */

.party-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
}
.party-type .btn { padding: .2rem .65rem; font-size: .8rem; }

.amount-card .amount-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    background: var(--navy-100);
    border-top: 1px solid var(--gray-300);
    color: var(--navy-800);
    font-size: .88rem;
    font-weight: 500;
}
.amount-card .amount-total strong {
    font-size: 1.08rem;
    color: var(--navy-900);
    direction: ltr;
    font-variant-numeric: tabular-nums;
}

.tamm-table td[data-out] {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    color: var(--navy-900);
}
.tamm-table tbody td:last-child { font-weight: 600; }
.tamm-table .form-control { min-width: 110px; }
.tamm-table tfoot td { font-weight: 600; color: var(--navy-900); border-top: 1px solid var(--gray-300); }

@media (max-width: 575.98px) {
    /* الجدول يتسع للشاشة بلا تمرير أفقي: العناوين تلتف والحقل أضيق */
    .tamm-table thead th { white-space: normal; font-size: .76rem; line-height: 1.35; vertical-align: middle; }
    .tamm-table th, .tamm-table td { padding-inline: .35rem; }
    .tamm-table tbody td:first-child { min-width: 78px; font-size: .84rem; }
    .tamm-table .form-control { min-width: 76px; padding-inline: .45rem; }
    .tamm-table td[data-out] { font-size: .84rem; }
}

/* قيمة محسوبة سالبة: تنبيه لوني بجانب رسالة التحذير */
[data-out].is-negative { color: var(--red) !important; }

/* ---------- ملخص العملية الحي ---------- */
.calc-panel {
    background:
        radial-gradient(420px 180px at 100% 0%, rgba(212, 175, 55, .16), transparent 65%),
        linear-gradient(165deg, var(--navy-900), var(--navy-800));
    color: var(--white);
    border: 1px solid rgba(212, 175, 55, .35);
    border-radius: var(--radius);
    padding: 1.1rem 1.15rem 1rem;
    box-shadow: var(--shadow-md);
}

/* يلازم الشاشة أثناء التمرير على الشاشات العريضة فقط (العمودان متجاوران) */
@media (min-width: 1200px) {
    .calc-panel { position: sticky; top: calc(62px + 1rem); }
}

.calc-title {
    display: flex;
    align-items: center;
    gap: .45rem;
    font-weight: 600;
    font-size: 1rem;
    color: var(--gold-500);
    padding-bottom: .55rem;
    margin-bottom: .25rem;
    border-bottom: 1px solid rgba(212, 175, 55, .3);
}

.calc-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .75rem;
    padding: .45rem .1rem;
    border-bottom: 1px dashed rgba(255, 255, 255, .12);
    font-size: .89rem;
}
.calc-row span { color: rgba(255, 255, 255, .8); }
.calc-row small { color: rgba(255, 255, 255, .52); font-size: .76rem; }
.calc-row strong {
    font-weight: 600;
    direction: ltr;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* بنود تُطرح من المدفوع: علامة الطرح قبل الرقم */
.calc-row.is-minus strong::before { content: "− "; color: rgba(255, 255, 255, .45); font-weight: 400; }

.calc-row.is-total {
    margin: .45rem 0 .2rem;
    padding: .7rem .8rem;
    border: 1px solid rgba(212, 175, 55, .55);
    border-radius: var(--radius-sm);
    background: rgba(212, 175, 55, .14);
}
.calc-row.is-total span { color: var(--white); font-weight: 500; }
.calc-row.is-total strong { color: var(--gold-500); font-size: 1.25rem; }

.calc-row.is-danger {
    border-color: rgba(255, 138, 128, .7);
    background: rgba(211, 47, 47, .22);
}
.calc-row.is-danger strong,
.calc-panel [data-out].is-negative { color: #FF8A80 !important; }

.calc-warning {
    display: flex;
    gap: .45rem;
    align-items: flex-start;
    margin: .35rem 0 .15rem;
    padding: .5rem .7rem;
    border: 1px solid rgba(255, 138, 128, .5);
    border-radius: var(--radius-sm);
    background: rgba(211, 47, 47, .18);
    color: #FFD9D5;
    font-size: .8rem;
    line-height: 1.5;
}

.calc-sub {
    margin-top: .85rem;
    padding-top: .55rem;
    border-top: 1px solid rgba(255, 255, 255, .16);
    font-size: .76rem;
    font-weight: 600;
    letter-spacing: .3px;
    color: var(--gold-300);
}

.calc-row.is-net { border-bottom: 0; }
.calc-row.is-net span { color: var(--white); font-weight: 500; }
.calc-row.is-net strong { font-size: 1.08rem; }

.calc-panel .btn-primary {
    background: var(--gold-500);
    border-color: var(--gold-500);
    color: var(--black);
    font-weight: 600;
}
.calc-panel .btn-primary:hover,
.calc-panel .btn-primary:focus-visible {
    background: var(--gold-600);
    border-color: var(--gold-600);
    color: var(--white);
}

.calc-note {
    margin-top: .7rem;
    text-align: center;
    font-size: .74rem;
    color: rgba(255, 255, 255, .55);
}

/* ===================== تفاصيل عملية نقل الملكية ===================== */

.car-hero {
    text-align: center;
    padding: .35rem 0 1rem;
    margin-bottom: .85rem;
    border-bottom: 1px dashed var(--gray-300);
}
.car-hero-name { font-size: 1.4rem; font-weight: 700; color: var(--navy-900); line-height: 1.3; }
.car-hero-year { color: var(--gray-600); margin: .1rem 0 .65rem; }

.party-name {
    font-size: 1.08rem;
    font-weight: 600;
    color: var(--navy-900);
    margin-bottom: .75rem;
    overflow-wrap: anywhere;
}

/* الطرف الذي يظهر اسمه في الفاتورة */
.card.party-payer {
    border-color: var(--gold-500);
    box-shadow: 0 0 0 1px var(--gold-500), var(--shadow-sm);
}
.card.party-payer > .card-header { background: rgba(212, 175, 55, .09); }

/* جدول تفصيل المبالغ: مجموعات، مجاميع فرعية تُطرح، ونتيجة */
.breakdown-table th,
.breakdown-table td { padding: .42rem .9rem; }
.breakdown-table th { font-weight: 500; color: var(--navy-900); }
.breakdown-table td:last-child {
    text-align: left;
    direction: ltr;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.breakdown-table td small { font-size: .74rem; }

.breakdown-table .bd-group > th {
    background: var(--gray-100);
    color: var(--navy-800);
    font-size: .8rem;
    font-weight: 600;
    padding-top: .55rem;
}
.breakdown-table .bd-sub > * { font-weight: 600; border-top: 1px solid var(--gray-300); }
.breakdown-table .bd-sub.is-out > td { color: var(--deduct); }

.breakdown-table .bd-head > * { background: var(--navy-100); font-weight: 600; font-size: .95rem; }
.breakdown-table .bd-head.is-in > td { color: var(--navy-800); }
.breakdown-table .bd-head.is-result > * {
    background: rgba(212, 175, 55, .16);
    color: var(--navy-900);
    border-top: 2px solid var(--gold-500);
}

/* التحليل الضريبي: مبيعات − مشتريات = صافي */
.vat-analysis {
    display: flex;
    align-items: stretch;
    gap: .45rem;
}
.vat-item {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .15rem;
    text-align: center;
    background: var(--gray-100);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    padding: .7rem .4rem;
}
.vat-item span { font-size: .78rem; color: var(--gray-600); }
.vat-item strong {
    font-size: 1.05rem;
    color: var(--navy-900);
    direction: ltr;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}
.vat-item small { font-size: .7rem; color: var(--gray-600); }

.vat-op {
    align-self: center;
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--gold-600);
}

.vat-item.is-net { background: var(--navy-800); border-color: var(--navy-800); }
.vat-item.is-net span,
.vat-item.is-net small { color: rgba(255, 255, 255, .78); }
.vat-item.is-net strong { color: var(--white); }
.vat-item.is-net.is-refund { background: var(--green); border-color: var(--green); }

@media (max-width: 575.98px) {
    .vat-analysis { flex-direction: column; }
    .vat-op { line-height: 1; }
}

/* ===================== الفاتورة الضريبية المبسطة (A4) ===================== */

.inv-title-en {
    font-size: 10px;
    color: var(--gray-600);
    letter-spacing: 1.5px;
    margin-top: 1px;
}

.inv-ltr { direction: ltr; unicode-bidi: isolate; }

.inv-parties {
    display: flex;
    gap: 8px;
    margin: 4px 0 10px;
}
.inv-parties > div {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--gray-300);
    border-inline-start: 3px solid var(--gold-500);
    border-radius: 6px;
    padding: 5px 10px;
}
.inv-parties span { font-size: 9.5px; color: var(--gray-600); }
.inv-parties strong { font-size: 12px; color: var(--navy-900); overflow-wrap: anywhere; }

.inv-lines {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 12px;
}
.inv-lines th {
    background: var(--navy-800);
    color: var(--white);
    font-weight: 500;
    font-size: 10px;
    padding: 5px 6px;
    text-align: center;
    border: 1px solid var(--navy-800);
}
.inv-lines td {
    border: 1px solid var(--gray-300);
    padding: 7px 6px;
    font-size: 11px;
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
}
.inv-lines td.inv-desc { text-align: start; white-space: normal; width: 44%; }
.inv-line-meta { font-size: 9.5px; color: var(--gray-600); line-height: 1.5; }

.inv-bottom {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.inv-qr-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    flex: 0 0 auto;
}
.inv-qr { padding: 5px; }
.inv-qr img { width: 124px; height: 124px; image-rendering: pixelated; }
.inv-qr-caption { font-size: 8.5px; color: var(--gray-600); text-align: center; line-height: 1.45; }

.inv-summary { flex: 0 1 60%; min-width: 0; }

.inv-totals { width: 100%; border-collapse: collapse; }
.inv-totals th,
.inv-totals td {
    border: 1px solid var(--gray-300);
    padding: 6px 10px;
    font-size: 11px;
}
.inv-totals th { background: var(--gray-100); color: var(--navy-900); font-weight: 500; text-align: start; }
.inv-totals td {
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
    min-width: 120px;
    font-variant-numeric: tabular-nums;
}
.inv-totals .inv-grand > * {
    background: var(--navy-800);
    border-color: var(--navy-800);
    color: var(--white);
    font-size: 12.5px;
    font-weight: 700;
}
.inv-totals .inv-grand small { font-weight: 500; opacity: .85; }

.inv-words {
    margin-top: 7px;
    padding: 5px 10px;
    border: 1px dashed var(--gold-500);
    border-radius: 6px;
    font-size: 10.5px;
    font-weight: 600;
    color: var(--navy-900);
    line-height: 1.6;
}
.inv-words span { color: var(--gold-600); font-weight: 500; margin-inline-end: 4px; }

.inv-role { font-size: 10px; font-weight: 500; color: var(--gray-600); }

/* --- بطاقتا المشتري والسيارة --- */
.inv-info-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 2px;
}
.inv-info {
    border: 1px solid var(--navy-800);
    border-radius: 6px;
    overflow: hidden;
}
.inv-info-head {
    background: var(--navy-800);
    color: var(--white);
    font-size: 10.5px;
    font-weight: 600;
    padding: 3px 10px;
}
.inv-kv { width: 100%; border-collapse: collapse; }
.inv-kv th,
.inv-kv td {
    border-top: 1px solid var(--gray-300);
    padding: 3px 10px;
    font-size: 10.5px;
    line-height: 1.5;
    vertical-align: middle;
}
.inv-kv tr:first-child > * { border-top: 0; }
.inv-kv th {
    width: 36%;
    background: var(--gray-100);
    color: var(--gray-600);
    font-weight: 400;
    white-space: nowrap;
}
.inv-kv td { color: var(--navy-900); font-weight: 600; overflow-wrap: anywhere; }
.inv-kv td small { font-weight: 400; color: var(--gray-600); }

.amt-note { margin-top: 4px; font-size: 8.5px; color: var(--gray-600); line-height: 1.5; }

@media print {
    .inv-lines th,
    .inv-totals .inv-grand > *,
    .inv-parties > div,
    .inv-info-head,
    .inv-kv th {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .inv-bottom, .inv-info-row { page-break-inside: avoid; break-inside: avoid; }
}

/* ===================== تفاصيل المبالغ — في الفاتورة والعقد ===================== */
/* مطابقة لتفصيل المبالغ في صفحة العملية، بلا تحليل ضريبي (داخلي فقط) */

.amt-cards {
    display: grid;
    grid-template-columns: 1fr 1fr 1.5fr;
    gap: 6px;
    align-items: stretch;
}
.amt-card {
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.amt-head {
    background: var(--navy-100);
    color: var(--navy-900);
    font-size: 10px;
    font-weight: 600;
    text-align: center;
    padding: 2px 6px;
    border-bottom: 1px solid var(--gray-300);
}
.amt-head small { font-size: 8.5px; font-weight: 400; color: var(--gray-600); }

/* أعمدة ثابتة العرض: جدول الأسطر وجدول الإجمالي تحته يتطابقان عموداً بعمود */
.amt-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.amt-col-amount { width: 42%; }
.amt-col-fee { width: 21%; }
.amt-col-vat { width: 18%; }
.amt-col-total { width: 22%; }

.amt-table th,
.amt-table td {
    padding: 2px 8px;
    font-size: 10px;
    line-height: 1.55;
    border-top: 1px solid var(--gray-100);
    overflow: hidden;
    text-overflow: ellipsis;
}
.amt-table.amt-vat th,
.amt-table.amt-vat td { padding-inline: 5px; }
.amt-table th { font-weight: 400; color: var(--gray-600); text-align: start; white-space: nowrap; }
.amt-table td {
    text-align: left;
    white-space: nowrap;
    color: var(--navy-900);
    font-variant-numeric: tabular-nums;
}
.amt-table thead th {
    font-size: 8.5px;
    text-align: left;
    border-top: 0;
    border-bottom: 1px solid var(--gray-300);
    padding-top: 1px;
    padding-bottom: 1px;
}
.amt-table thead th:first-child { text-align: start; }
.amt-table tbody tr:first-child > * { border-top: 0; }

/* سطر الإجمالي في قاع البطاقة مهما قلّت أسطرها */
.amt-sum { margin-top: auto; }
.amt-sum th,
.amt-sum td {
    background: var(--gray-100);
    border-top: 1px solid var(--gray-300);
    color: var(--navy-900);
    font-weight: 600;
}

/* سطر المطابقة: المدفوع − الحكومية − التأمين − منصة تم = خدمة المعرض */
.amt-flow {
    display: flex;
    align-items: stretch;
    gap: 4px;
    margin-top: 6px;
}
.amt-flow-item {
    flex: 1 1 0;
    min-width: 0;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    padding: 2px 6px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.amt-flow-item span { font-size: 8.5px; color: var(--gray-600); line-height: 1.35; }
.amt-flow-item strong {
    font-size: 12px;
    color: var(--navy-900);
    line-height: 1.35;
    font-variant-numeric: tabular-nums;
}
.amt-flow-item.is-paid { border-color: var(--gold-500); background: rgba(212, 175, 55, .1); }
.amt-flow-item.is-result { flex-grow: 1.25; background: var(--navy-800); border-color: var(--navy-800); }
.amt-flow-item.is-result span { color: rgba(255, 255, 255, .8); }
.amt-flow-item.is-result strong { color: var(--white); }
.amt-op { align-self: center; font-size: 15px; font-weight: 700; color: var(--gold-600); line-height: 1; }

@media print {
    .amt-head,
    .amt-sum th,
    .amt-sum td,
    .amt-flow-item.is-paid,
    .amt-flow-item.is-result {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .amt { page-break-inside: avoid; break-inside: avoid; }
}

/* ===================== عقد نقل الملكية (A4) ===================== */
/* محتوى العقد ثابت، فخطوطه ومسافاته مكبّرة لتملأ ورقة A4 بلا فراغ وتبقى ورقة واحدة.
   كل القواعد مسبوقة بـ ‎.tc-doc‎ فتغلب ضغط print.css المخصص لعقد التقسيط، على الشاشة والورقة معاً. */

.tc-doc {
    display: flex;
    flex-direction: column;
    min-height: 273mm;
    font-size: 13px;
    line-height: 1.45; /* ثابت على الشاشة والورقة، فيصح قياس الارتفاع قبل الطباعة */
}

/* --- الترويسة --- */
.tc-doc .c-header { padding-bottom: 8px; margin-bottom: 2px; border-bottom: 2px solid var(--gold-500); }
.tc-doc .c-logo { max-height: 62px; }
.tc-doc .c-company { font-size: 16px; }
.tc-doc .c-license { font-size: 11.5px; }
.tc-doc .c-header-title { padding-top: 8px; }
.tc-doc .c-header-title h1 { font-size: 25px; margin: 3px 0; }
.tc-doc .c-ornament { font-size: 11px; }
.tc-doc .c-meta-table th,
.tc-doc .c-meta-table td { font-size: 11.5px; padding: 3px 9px; }
.tc-doc .c-qr img { width: 70px; height: 70px; }
/* عمود رقم العقد والرمز بعرض محتواه لا بثلث الترويسة، فلا يُقصّ جدوله بالخط الأكبر */
.tc-doc .c-header-side { width: auto; flex: 1 1 0; min-width: 0; }
.tc-doc .c-header-side.c-header-meta { flex: 0 0 auto; }
.tc-doc .c-header-title { flex: 0 0 auto; width: auto; }
.tc-doc .c-header-title h1 { white-space: nowrap; }
.tc-doc .c-table th { white-space: nowrap; }
.tc-doc .c-meta-table td { white-space: nowrap; }

/* --- الأقسام والجداول --- */
.tc-doc .c-section { font-size: 13px; padding: 4px 28px; margin: 9px auto 5px; border-radius: 6px; }
.tc-doc .c-box,
.tc-doc .c-party { border-radius: 7px; }
.tc-doc .c-party { margin-bottom: 6px; }
.tc-doc .c-party-head { font-size: 13px; padding: 4px 10px; }
.tc-doc .c-party-icon { top: 5px; font-size: 13px; }
.tc-doc .c-table th { font-size: 12px; padding: 4px 6px; }
.tc-doc .c-table td { font-size: 13px; padding: 4px 6px; }

/* --- البنود --- */
.tc-terms { min-height: 0; padding: 9px 13px; border-radius: 7px; }
.tc-terms p {
    margin: 0 0 4px;
    font-size: 12px;
    line-height: 1.7;
    text-align: justify;
}
.tc-terms p:last-child { margin-bottom: 0; }
.tc-terms b { color: var(--navy-800); }

/* --- الملاحظات: تظهر تحت البنود متى وُجدت --- */
.tc-notes {
    margin-top: 7px;
    padding: 7px 13px;
    border: 1px dashed var(--gold-500);
    border-radius: 7px;
    background: rgba(212, 175, 55, .06);
    font-size: 12px;
    line-height: 1.7;
    white-space: pre-line;
    text-align: justify;
}
.tc-notes b { color: var(--navy-800); }

/* --- التوقيعات والختم ---
   سطر العنوان بارتفاع الختم: الختم في يساره فوق خانة الطرف الثالث، والعنوان في وسطه */
.tc-bottom { margin-top: auto; padding-top: 8px; }
.tc-sign-top {
    position: relative;
    min-height: 100px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.tc-doc .c-signatures-title { font-size: 14px; margin: 0 0 6px; }

.tc-stamp {
    position: absolute;
    left: 0;
    bottom: 4px;
    width: calc((100% - 16px) / 3);
    height: 94px;
    direction: ltr; /* بداية المرن يساراً فعلياً في صفحة عربية */
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    padding-left: 6px;
    line-height: 0;
    pointer-events: none;
}
.tc-stamp img { max-width: 100%; max-height: 100%; object-fit: contain; }

.tc-signatures {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
/* رأس فاتح للخانات */
.tc-signatures .c-sign-box { border-radius: 7px; }
.tc-signatures .c-sign-head {
    background: var(--navy-100);
    color: var(--navy-900);
    border-bottom: 1px solid var(--navy-800);
    font-size: 13px;
    padding: 5px;
}
.tc-signatures .c-sign-line { font-size: 13px; padding: 7px 11px; }

.tc-doc .c-footer { margin-top: 10px; padding: 6px 12px; font-size: 11.5px; border-radius: 6px; }

@media print {
    /* 265 ملم: تتسع حتى مع هوامش طباعة أكبر من هوامش ‎@page‎ (12.7 ملم افتراضي بعض المتصفحات)،
       فلا تنزلق التوقيعات والتذييل إلى ورقة ثانية */
    .tc-doc { min-height: 265mm; }

    .tc-signatures .c-sign-head,
    .tc-doc .c-section,
    .tc-doc .c-party-head,
    .tc-doc .c-meta-table th,
    .tc-doc .c-table thead th,
    .tc-doc .c-footer {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .tc-notes { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .tc-bottom, .tc-signatures { page-break-inside: avoid; break-inside: avoid; }
}

/* ===================== المستندات على الجوال ===================== */
/* transfer-doc.js يصغّر ورقة A4 لعرض الشاشة؛ هنا نضيّق الحواف المحيطة بها فقط */
.print-body.tdoc-zoomed { padding: 8px; }
.tdoc-zoomed .print-toolbar { margin-bottom: 8px; }

@media print {
    .page-a4 { zoom: 1 !important; }
}

/* ===================== سيارات العرض ===================== */

/* معروضة أطول من المعتاد: صف بتظليل خفيف وشريط في بدايته */
.table .row-stale > td { --bs-table-bg: rgba(211, 47, 47, .045); }

@media (min-width: 768px) {
    .table .row-stale > td:first-child { box-shadow: inset -3px 0 0 var(--red), inset 0 0 0 9999px var(--bs-table-bg-state, var(--bs-table-bg-type, var(--bs-table-accent-bg))); }
}

@media (max-width: 767.98px) {
    .table-cards tbody tr.row-stale { border-color: rgba(211, 47, 47, .45); box-shadow: inset -4px 0 0 var(--red); }
}

/* ===================== لوحة مؤشرات نقل الملكية ===================== */

.period-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .6rem 1rem;
    margin-bottom: 1rem;
    padding: .6rem .75rem;
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.period-switch .btn { min-width: 78px; }

.period-nav {
    display: flex;
    align-items: center;
    gap: .4rem;
}
.period-nav .btn-sm { padding: .3rem .6rem; }
.period-label {
    min-width: 150px;
    text-align: center;
    font-weight: 600;
    color: var(--navy-900);
}

@media (max-width: 575.98px) {
    .period-bar { flex-direction: column; align-items: stretch; }
    .period-switch { width: 100%; }
    .period-switch .btn { min-width: 0; flex: 1 1 0; }
    .period-nav { justify-content: space-between; flex-wrap: wrap; }
    .period-label { min-width: 0; flex: 1 1 auto; }
}

/* ---------- الرقم الرئيسي: إيراد المعرض العام ---------- */
.hero-card {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1.1rem 2rem;
    padding: 1.4rem 1.6rem;
    color: var(--white);
    border-radius: calc(var(--radius) + 4px);
    border: 1px solid rgba(212, 175, 55, .35);
    background:
        radial-gradient(640px 260px at 100% 0%, rgba(212, 175, 55, .2), transparent 62%),
        linear-gradient(135deg, var(--navy-900) 0%, var(--navy-800) 55%, var(--navy-700) 100%);
    box-shadow: var(--shadow-md);
}

.hero-main { min-width: 0; flex: 1 1 260px; }
.hero-label { color: var(--gold-300); font-size: .9rem; display: flex; align-items: center; gap: .4rem; }
.hero-value {
    font-size: clamp(1.8rem, 5vw, 2.7rem);
    font-weight: 700;
    line-height: 1.2;
    margin-top: .2rem;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}
.hero-value small { font-size: .42em; font-weight: 500; color: rgba(255, 255, 255, .7); }

.hero-delta {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    margin-top: .5rem;
    padding: .22rem .7rem;
    border-radius: 999px;
    font-size: .84rem;
    background: rgba(255, 255, 255, .1);
    color: rgba(255, 255, 255, .82);
}
.hero-delta.is-up   { background: rgba(46, 125, 50, .28); color: #B9E4BC; }
.hero-delta.is-down { background: rgba(211, 47, 47, .28); color: #FFD0CC; }

.hero-parts {
    display: flex;
    flex-direction: column;
    gap: .45rem;
    flex: 1 1 300px;
    max-width: 440px;
}
.hero-part {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem .8rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, .07);
    border: 1px solid rgba(255, 255, 255, .08);
}
.hero-part-label { flex: 1 1 auto; font-size: .86rem; color: rgba(255, 255, 255, .82); }
.hero-part strong { font-variant-numeric: tabular-nums; white-space: nowrap; }

@media (max-width: 767.98px) {
    .hero-card { padding: 1.15rem 1.1rem; }
    .hero-parts { max-width: none; }
}

/* نقطة هوية السلسلة: لونها من متغير --dot وحلقة بلون السطح تفصلها عن الخلفية */
.legend-dot {
    display: inline-block;
    flex: 0 0 auto;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--dot, var(--series-1));
    box-shadow: 0 0 0 2px rgba(255, 255, 255, .92);
}

/* ---------- بطاقات المؤشرات ---------- */
.kpi-section-title {
    display: flex;
    align-items: center;
    gap: .45rem;
    margin: .35rem 0 .7rem;
    font-size: .95rem;
    font-weight: 600;
    color: var(--navy-800);
}
.kpi-section-title::after {
    content: "";
    flex: 1 1 auto;
    height: 1px;
    background: var(--gray-300);
    margin-inline-start: .35rem;
}

.kpi {
    position: relative;
    display: block;
    height: 100%;
    min-width: 0;
    overflow: hidden;
    padding: 1rem 1.1rem;
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    color: inherit;
}

.kpi-icon {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: .6rem;
    border-radius: 10px;
    background: var(--navy-100);
    color: var(--navy-700);
    font-size: 1.1rem;
}

.kpi-label { color: var(--gray-600); font-size: .83rem; line-height: 1.35; overflow-wrap: anywhere; }
.kpi-label small { font-size: .72rem; }

.kpi-value {
    margin-top: .15rem;
    font-size: clamp(1.1rem, 2.4vw, 1.55rem);
    font-weight: 600;
    line-height: 1.3;
    color: var(--navy-900);
    font-variant-numeric: tabular-nums;
    /* الأرقام (ومنها السالبة) تُقرأ من اليسار وتبقى ملاصقة لبداية البطاقة */
    direction: ltr;
    text-align: right;
    overflow-wrap: anywhere;
}

.kpi-note { margin-top: .2rem; font-size: .78rem; color: var(--gray-600); }

.kpi.is-accent {
    border-color: rgba(212, 175, 55, .65);
    background: linear-gradient(160deg, var(--white) 55%, rgba(212, 175, 55, .13));
}
.kpi.is-accent .kpi-icon { background: rgba(212, 175, 55, .2); color: var(--gold-600); }

/* صافي الضريبة: مستحق (تنبيه) أو مسترد — دائماً بأيقونة ونص لا باللون وحده */
.kpi.is-due .kpi-icon   { background: rgba(237, 108, 2, .12); color: var(--orange); }
.kpi.is-due .kpi-note   { color: #B45309; font-weight: 500; }
.kpi.is-refund .kpi-icon { background: rgba(46, 125, 50, .12); color: var(--green); }
.kpi.is-refund .kpi-note { color: var(--green); font-weight: 500; }

a.kpi-link { transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
a.kpi-link:hover,
a.kpi-link:focus-visible {
    transform: translateY(-2px);
    border-color: var(--navy-600);
    box-shadow: var(--shadow-md);
    color: inherit;
}
/* سهم «انتقال» في الزاوية — «←» لا يُعكس في الاتجاه العربي بخلاف ‹ › */
a.kpi-link::after {
    content: "←";
    position: absolute;
    inset-block-start: .85rem;
    inset-inline-end: .95rem;
    font-size: 1rem;
    line-height: 1;
    color: var(--gray-300);
    transition: color .15s ease;
}
a.kpi-link:hover::after { color: var(--navy-600); }

/* ---------- الرسوم وجدول بياناتها ---------- */
.viz-root .card-header { font-size: .92rem; }

.tabular th,
.tabular td { white-space: nowrap; font-variant-numeric: tabular-nums; }

@media print {
    .hero-card, .kpi, .calc-panel, .vat-item.is-net {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .kpi, .hero-card { box-shadow: none; }
    .calc-panel { position: static; }
}

/* ===================== ستكر العرض على ورقة A4 ===================== */
/* قاعدة ‎@page‎ (بلا هوامش) في صفحة الستكر نفسها كي لا تمس طباعة باقي الصفحات */

.sticker-body {
    margin: 0;
    min-height: 100vh;
    padding: 76px 16px 28px;
    background: #4A5361;
}

.sticker-toolbar {
    position: fixed;
    inset-block-start: 0;
    inset-inline: 0;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    padding: .6rem 1rem;
    background: var(--navy-900);
    box-shadow: 0 2px 12px rgba(0, 0, 0, .3);
}
.sticker-hint { margin-inline-start: auto; color: rgba(255, 255, 255, .72); font-size: .82rem; }

.sticker {
    --st-ink: var(--navy-900);
    --st-gold: var(--gold-500);

    position: relative;
    width: 210mm;
    height: 296mm; /* أقل من 297 بملليمتر: يمنع صفحة ثانية فارغة من فروق التقريب */
    margin: 0 auto;
    padding: 15mm 15mm 13mm;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--white);
    color: var(--st-ink);
    box-shadow: 0 14px 44px rgba(0, 0, 0, .38);
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

/* إطار مزدوج داخل الهامش الآمن للطابعات: كحلي عريض وذهبي رفيع */
.sticker::before,
.sticker::after {
    content: "";
    position: absolute;
    pointer-events: none;
}
.sticker::before { inset: 6mm; border: 1.4mm solid var(--st-ink); border-radius: 7mm; }
.sticker::after  { inset: 8.6mm; border: .5mm solid var(--st-gold); border-radius: 5mm; }

.sticker * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

.sticker-head {
    display: flex;
    align-items: center;
    gap: 5mm;
    padding-bottom: 5mm;
    border-bottom: .6mm solid var(--gray-300);
}
.sticker-logo { max-height: 20mm; max-width: 42mm; object-fit: contain; }
.sticker-company { flex: 1 1 auto; min-width: 0; font-size: 19pt; font-weight: 700; line-height: 1.25; }
.sticker-ribbon {
    flex: 0 0 auto;
    padding: 1.5mm 11mm 2.5mm;
    border-radius: 4mm;
    background: var(--st-gold);
    color: var(--st-ink);
    font-size: 34pt;
    font-weight: 800;
    line-height: 1.15;
    box-shadow: inset 0 -1.2mm 0 rgba(0, 0, 0, .12);
}

.sticker-main {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7mm;
    text-align: center;
    padding: 5mm 0;
}

.sticker-type {
    margin: 0;
    max-width: 100%;
    font-size: 64pt;
    font-weight: 800;
    line-height: 1.15;
    color: var(--st-ink);
    overflow-wrap: anywhere;
}
.sticker-rule {
    display: block;
    flex: 0 0 auto;
    width: 34mm;
    height: 1.4mm;
    margin-top: -3mm;
    border-radius: 1mm;
    background: var(--st-gold);
}

.sticker-specs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6mm;
    width: 100%;
}
.sticker-spec {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1mm;
    padding: 4mm 3mm 5mm;
    border: .7mm solid var(--gray-300);
    border-radius: 5mm;
    background: var(--gray-100);
}

.sticker-label { font-size: 18pt; font-weight: 600; color: var(--gray-600); }
.sticker-value { font-size: 46pt; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.sticker-value small { font-size: 20pt; font-weight: 600; color: var(--gray-600); }

/* بطاقة السعر بخلفية كحلية فاتحة جداً توفّر حبر الطابعة، والمبلغ بالكحلي الداكن
   على الخلفية الفاتحة فيبقى أوضح عنصر في الستكر (تباين أعلى من الذهبي على الكحلي) */
.sticker-price {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1mm;
    padding: 5mm 6mm 6mm;
    border-radius: 6mm;
    color: var(--navy-800);
    background: #EEF3FA;
    border: .9mm solid #C9D6EA;
    border-top: 2.2mm solid var(--gold-500);
}
.sticker-price .sticker-label { color: var(--navy-700); }
.sticker-price-value {
    max-width: 100%;
    font-size: 100pt;
    font-weight: 800;
    line-height: 1.05;
    color: var(--navy-900);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.sticker-currency { font-size: 22pt; font-weight: 600; color: var(--navy-700); }

.sticker-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 3mm 6mm;
    padding-top: 5mm;
    border-top: .6mm solid var(--gray-300);
    font-size: 19pt;
    font-weight: 600;
}
.sticker-foot i { color: var(--gold-600); }
.sticker-foot b { font-size: 24pt; color: var(--st-ink); }

.sticker-plate {
    display: inline-block;
    padding: .5mm 5mm;
    border: .8mm solid #1C1C1C;
    border-inline-start: 5mm solid var(--navy-700);
    border-radius: 2.5mm;
    background: var(--white);
    font-size: 20pt;
    letter-spacing: 1pt;
}

/* معاينة الشاشات الصغيرة: تصغير بصري للورقة فقط، والطباعة بمقاسها الحقيقي */
@media screen and (max-width: 860px) { .sticker { zoom: .72; } }
@media screen and (max-width: 640px) { .sticker { zoom: .52; } .sticker-hint { display: none; } }
@media screen and (max-width: 440px) { .sticker { zoom: .4; } }

@media print {
    .sticker-body { background: var(--white); padding: 0; min-height: 0; }
    .sticker-toolbar { display: none !important; }
    .sticker {
        margin: 0;
        box-shadow: none;
        zoom: 1;
        page-break-after: avoid;
        break-after: avoid;
        page-break-inside: avoid;
        break-inside: avoid;
    }
}

/* ===================== تقارير نقل الملكية ===================== */

/* ---------- صفحة التقارير ---------- */
.report-hub-card {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    height: 100%;
    padding: 1.15rem 1.2rem;
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    color: inherit;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.report-hub-card:hover,
.report-hub-card:focus-visible {
    transform: translateY(-3px);
    border-color: var(--navy-600);
    box-shadow: var(--shadow-md);
    color: inherit;
}
.report-hub-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: .35rem;
    border-radius: 12px;
    background: var(--navy-100);
    color: var(--navy-700);
    font-size: 1.3rem;
}
.report-hub-card h2 { margin: 0; font-size: 1rem; font-weight: 600; color: var(--navy-900); line-height: 1.4; }
.report-hub-card p { flex: 1 1 auto; margin: 0; font-size: .84rem; color: var(--gray-600); line-height: 1.6; }
.report-hub-meta {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    margin-top: .4rem;
    font-size: .76rem;
    color: var(--navy-700);
}
.report-hub-card.is-featured {
    border-color: rgba(212, 175, 55, .7);
    background: linear-gradient(160deg, var(--white) 58%, rgba(212, 175, 55, .13));
}
.report-hub-card.is-featured .report-hub-icon { background: rgba(212, 175, 55, .2); color: var(--gold-600); }

/* ---------- رأس التقرير والفترة ---------- */
.report-title-block { min-width: 0; }
.report-crumb { font-size: .8rem; margin-bottom: .15rem; }
.report-crumb a { color: var(--gray-600); }
.report-crumb a:hover { color: var(--navy-700); }
.report-period {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .15rem .65rem;
    border-radius: 999px;
    background: var(--navy-100);
    color: var(--navy-800);
    font-size: .82rem;
    font-weight: 500;
}
.report-subtitle { margin-top: .3rem; font-size: .82rem; color: var(--gray-600); }

.report-presets {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem;
    margin-top: .8rem;
}
.report-presets-label { font-size: .78rem; color: var(--gray-600); margin-inline-end: .15rem; }
.report-preset {
    padding: .22rem .75rem;
    border: 1px solid var(--gray-300);
    border-radius: 999px;
    background: var(--white);
    color: var(--navy-800);
    font-size: .8rem;
    line-height: 1.5;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.report-preset:hover { border-color: var(--navy-600); background: var(--navy-100); color: var(--navy-900); }
.report-preset.is-active { background: var(--navy-700); border-color: var(--navy-700); color: var(--white); }

/* ---------- جداول التقارير ---------- */
.report-table .num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.report-table .is-neg { color: var(--red); }
/* فترة بلا حركة: خافتة كي لا تُقرأ أصفارها كنتيجة */
.report-table tr.is-empty > td { color: #9AA3AF; }
.report-table tr.is-empty > td a { color: inherit; }
.report-table thead .th-group { text-align: center; border-bottom: 1px solid rgba(255, 255, 255, .22); }
.report-table thead th[rowspan] { vertical-align: middle; }
.report-table tfoot > tr > * {
    background: var(--navy-100);
    color: var(--navy-900);
    font-weight: 600;
    border-top: 2px solid var(--navy-700);
    white-space: nowrap;
}
.report-table .report-parties { min-width: 180px; }

/* ---------- قوائم الحصص: أشرطة بلون واحد، والقيم نصاً بجانبها ---------- */
.share-list { display: flex; flex-direction: column; gap: .8rem; }
.share-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: .3rem;
}
.share-name { font-size: .88rem; font-weight: 500; color: var(--navy-900); min-width: 0; overflow-wrap: anywhere; }
.share-figures {
    display: inline-flex;
    align-items: baseline;
    gap: .5rem;
    white-space: nowrap;
    font-size: .88rem;
    font-variant-numeric: tabular-nums;
}
.share-figures strong { color: var(--navy-900); font-weight: 600; }
.share-count, .share-pct { font-size: .76rem; color: var(--gray-600); }
.share-bar {
    height: 8px;
    border-radius: 4px;
    background: var(--gray-100);
    overflow: hidden;
}
.share-bar > span {
    display: block;
    height: 100%;
    min-width: 2px;
    border-radius: 4px;
    background: var(--series-1);
}

/* ملخص الإقرار في تقرير الضريبة أكبر من نظيره في صفحة العملية */
.vat-analysis-lg .vat-item { padding: 1rem .6rem; }
.vat-analysis-lg .vat-item span { font-size: .85rem; }
.vat-analysis-lg .vat-item strong { font-size: clamp(1.15rem, 2.6vw, 1.6rem); }
.vat-analysis-lg .vat-item small { font-size: .76rem; }
.vat-analysis-lg .vat-op { font-size: 1.7rem; }

/* ---------- الطباعة ---------- */
@media print {
    .report-print-head {
        justify-content: space-between;
        align-items: flex-end;
        gap: 12px;
        margin-bottom: 10px;
        padding-bottom: 6px;
        border-bottom: 2px solid var(--navy-800);
    }
    .report-print-company { font-size: 15px; font-weight: 700; color: var(--navy-900); }
    .report-print-title { font-size: 12.5px; font-weight: 600; color: var(--navy-700); }
    .report-print-meta { font-size: 10px; color: var(--gray-600); text-align: left; line-height: 1.6; }

    .report-root .card { box-shadow: none; break-inside: auto; }
    .report-root .table-responsive { overflow: visible; }
    .report-root .stat-card { box-shadow: none; padding: .5rem .7rem; }
    .report-root .stat-card .stat-value { font-size: 14px; }

    .report-table { font-size: 10px; }
    .report-table th,
    .report-table td { padding: 3px 5px !important; font-size: 10px !important; }
    .report-table thead { display: table-header-group; }
    .report-table tr { break-inside: avoid; page-break-inside: avoid; }
    .report-table thead th,
    .report-table tfoot > tr > *,
    .share-bar > span,
    .hero-card,
    .vat-item.is-net {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .report-extras { break-inside: avoid; page-break-inside: avoid; }
    .report-root .alert { border: 0 !important; padding: 0; font-size: 9.5px; color: var(--gray-600); }
}


/* ===== المصروفات الشهرية: التوزيع حسب النوع ===== */
.exp-types { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px 24px; }
.exp-type-head { display: flex; justify-content: space-between; gap: 8px; font-size: .9rem; margin-bottom: 4px; }
.exp-type-bar { height: 6px; background: #EEF1F6; border-radius: 4px; overflow: hidden; }
.exp-type-bar > span { display: block; height: 100%; background: var(--red, #C0392B); border-radius: 4px; min-width: 2px; }

/* ===== لوحة المؤشرات: المصروفات تُخصم من الإيراد العام ===== */
.hero-formula {
    margin-top: .3rem;
    font-size: .86rem;
    color: rgba(255, 255, 255, .78);
    font-variant-numeric: tabular-nums;
}
.hero-formula strong { color: var(--white); font-weight: 600; }
.hero-formula .op { margin: 0 .35rem; color: #FFB4AC; font-weight: 700; }

.hero-part.is-total {
    background: rgba(255, 255, 255, .12);
    border-color: rgba(212, 175, 55, .4);
}
.hero-part.is-total .hero-part-label { color: var(--gold-300); font-weight: 500; }
.hero-part.is-expense { background: rgba(211, 47, 47, .16); border-color: rgba(255, 180, 172, .28); }
.hero-part.is-expense > i { color: #FFB4AC; font-size: .95rem; line-height: 1; }
.hero-part.is-expense strong { color: #FFD0CC; }

.kpi.is-expense { border-color: rgba(211, 47, 47, .35); }
.kpi.is-expense .kpi-icon { background: rgba(211, 47, 47, .1); color: var(--red); }
.kpi-value.kpi-value-text { direction: rtl; font-size: clamp(1rem, 2vw, 1.25rem); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media print {
    .hero-part.is-expense, .hero-part.is-total { border: 1px solid #999; }
}

/* ===================== طباعة البطاقة الجمركية ===================== */
/* مستند قصير: لا يمتد لكامل الصفحة كالعقد، والتوقيعات تلي المحتوى مباشرة */
.tc-doc.cc-doc { min-height: 0; }
.cc-doc .tc-bottom { margin-top: 22px; }
.cc-doc .cc-words { font-size: 12px; color: var(--gray-700, #495057); background: var(--gray-100, #f8f9fa); }
@media print {
    .tc-doc.cc-doc { min-height: 0; }
}

/* ===================== إيراد المعرض العام: كل مصدر بإجماليه وضريبته وصافيه ===================== */
/* شبكة واحدة لكل الصفوف (subgrid): أعمدة الأرقام تأخذ عرض أعرض رقم فيها وتصطف بين الصفوف،
   بلا جدول حقيقي (الجدول داخل البطاقة الكحلية يرث ألوان Bootstrap ويصعب تحويله لبطاقات على الجوال). */
.hero-card > .rev-table { flex: 3 1 500px; }

.rev-table {
    display: grid;
    grid-template-columns: minmax(0, 1fr) repeat(3, max-content);
    row-gap: .35rem;
    min-width: 0;
    font-variant-numeric: tabular-nums;
}
.rev-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: subgrid;
    column-gap: 1.25rem;
    align-items: center;
    padding: .48rem .8rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, .07);
    border: 1px solid rgba(255, 255, 255, .08);
}
/* متصفح قديم بلا subgrid: أعمدة أرقام ثابتة العرض تحفظ الاصطفاف */
@supports not (grid-template-columns: subgrid) {
    .rev-row { grid-template-columns: minmax(0, 1fr) repeat(3, 6.3rem); }
}

.rev-head {
    padding-block: .1rem;
    background: none;
    border-color: transparent;
    font-size: .74rem;
    color: rgba(255, 255, 255, .62);
}
.rev-head > span:not(:first-child) { text-align: left; }

.rev-label { display: flex; align-items: center; gap: .55rem; min-width: 0; font-size: .86rem; color: rgba(255, 255, 255, .88); }
.rev-label > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.rev-label small { display: block; font-size: .7rem; color: rgba(255, 255, 255, .58); line-height: 1.35; }
.rev-label > i { color: #FFB4AC; font-size: .95rem; line-height: 1; }

/* الأرقام تُقرأ من اليسار وتصطف على الحافة اليسرى لعمودها */
.rev-num { direction: ltr; text-align: left; white-space: nowrap; font-size: .86rem; color: rgba(255, 255, 255, .82); }
strong.rev-num { color: var(--white); font-weight: 600; }
.rev-num.is-none { color: rgba(255, 255, 255, .42); }

.rev-row.is-total { background: rgba(255, 255, 255, .13); border-color: rgba(212, 175, 55, .45); }
.rev-row.is-total .rev-label { color: var(--gold-300); font-weight: 500; }
.rev-row.is-total .rev-num { color: var(--white); }

/* المصروفات: اسم ومبلغ فقط — المبلغ تحت عمود «الصافي» */
.rev-row.is-expense {
    grid-template-columns: minmax(0, 1fr) auto;
    background: rgba(211, 47, 47, .16);
    border-color: rgba(255, 180, 172, .28);
}
.rev-row.is-expense strong.rev-num { color: #FFD0CC; }

/* الزكاة تُخصم كالمصروفات بلون ذهبي، ثم الصافي بعدهما بإطار ذهبي */
.rev-row.is-zakat { background: rgba(212, 175, 55, .14); border-color: rgba(212, 175, 55, .35); }
.rev-row.is-zakat > .rev-label > i { color: var(--gold-300); }
.rev-row.is-zakat strong.rev-num { color: #F3DE9B; }
.rev-row.is-final { background: rgba(255, 255, 255, .13); border-color: rgba(212, 175, 55, .55); }
.rev-row.is-final .rev-label { color: var(--gold-300); font-weight: 600; }
.rev-row.is-final strong.rev-num { color: var(--white); font-size: 1.02rem; }

/* الجوال: الاسم في سطر، وتحته الأرقام الثلاثة كلٌّ بعنوانه */
@media (max-width: 575.98px) {
    .rev-table { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .rev-head { display: none; }
    .rev-row { column-gap: .5rem; row-gap: .3rem; padding: .55rem .7rem; }
    .rev-row > .rev-label { grid-column: 1 / -1; }
    .rev-row > .rev-num { font-size: .8rem; text-align: right; }
    .rev-row > .rev-num::before {
        content: attr(data-label);
        display: block;
        direction: rtl;
        text-align: right;
        font-size: .66rem;
        font-weight: 400;
        color: rgba(255, 255, 255, .58);
    }
    .rev-row.is-expense { grid-template-columns: minmax(0, 1fr) auto; }
    .rev-row.is-expense > .rev-label { grid-column: auto; }
    .rev-row.is-expense > .rev-num::before { content: none; }
}
@supports not (grid-template-columns: subgrid) {
    @media (max-width: 575.98px) {
        .rev-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
        .rev-row.is-expense { grid-template-columns: minmax(0, 1fr) auto; }
    }
}

@media print {
    .rev-row:not(.rev-head) { border: 1px solid rgba(255, 255, 255, .35); }
}

/* أزرار الإضافة السريعة في اللوحة: أربعة أزرار في شبكة 2×2 على الجوال بدل أربعة أسطر */
@media (max-width: 767.98px) {
    .toolbar .d-flex.dash-actions { flex-direction: row; flex-wrap: wrap; }
    .toolbar .d-flex.dash-actions > .btn {
        width: auto;
        flex: 1 1 calc(50% - .25rem);
        min-width: 0;
        padding-inline: .5rem;
        white-space: nowrap;
    }
}

/* ===================== قوائم الحصص بلون المصدر ===================== */
.share-list.is-expense .share-bar > span { background: var(--series-expense); }
.exp-types.is-revenue .exp-type-bar > span { background: var(--series-1); }

/* ===================== الإعدادات: الضريبة على أقسام إيراد المعرض ===================== */
.vat-toggle {
    height: 100%;
    padding: .85rem 1rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: var(--white);
    transition: border-color .15s ease, background .15s ease;
}
.vat-toggle.is-on {
    border-color: rgba(212, 175, 55, .7);
    background: linear-gradient(160deg, var(--white) 55%, rgba(212, 175, 55, .12));
}
.vat-toggle .form-check-label { color: var(--navy-900); }
.vat-toggle .vat-from { margin-top: .7rem; padding-top: .7rem; border-top: 1px dashed var(--gray-300); }
.vat-toggle .vat-from .form-label { font-size: .82rem; margin-bottom: .25rem; }

