/* =========================================
   استایل‌های اصلی صفحه (وب)
   ========================================= */
.mdf-cutting-page { direction: rtl; padding: 24px 12px 40px; color: #263238; font-family: inherit; }
.mdf-cutting-page * { box-sizing: border-box; }
.cutting-container { width: 100%; max-width: 1500px; margin: 0 auto; }
.cutting-header { margin-bottom: 24px; text-align: center; }
.cutting-header h1 { margin: 0 0 10px; font-size: clamp(24px, 3vw, 34px); font-weight: 800; }
.cutting-header p { margin: 0; color: #64748b; line-height: 1.9; }
.cutting-card { margin-bottom: 22px; padding: 22px; background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; box-shadow: 0 4px 18px rgba(15, 23, 42, 0.045); }
.cutting-card h2, .section-heading { margin: 0 0 18px; font-size: 20px; font-weight: 800; }
.cutting-field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.cutting-field label { font-size: 13px; font-weight: 700; color: #475569; }
.cutting-field input, .cutting-field select, .piece-input { width: 100%; min-width: 0; min-height: 42px; padding: 9px 10px; font: inherit; font-size: 14px; color: #1e293b; background: #fff; border: 1px solid #cbd5e1; border-radius: 8px; }
.cutting-field input:focus, .cutting-field select:focus, .piece-input:focus { outline: 2px solid rgba(37, 99, 235, 0.18); border-color: #2563eb; }
.cutting-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.cutting-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 18px; }
.cutting-submit, .delete-cabinet-button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 10px 18px; font: inherit; font-size: 14px; font-weight: 700; border: 0; border-radius: 9px; cursor: pointer; transition: opacity 0.15s ease, transform 0.15s ease; }
.cutting-submit { color: #fff; background: #176b45; }
.cutting-submit:hover, .delete-cabinet-button:hover { opacity: 0.88; }
.cutting-submit:active, .delete-cabinet-button:active { transform: translateY(1px); }
.secondary-button { color: #1e40af; background: #eaf1ff; }
.delete-cabinet-button { color: #b91c1c; background: #fee2e2; }
.cutting-notice { margin: 14px 0 0; padding: 12px 14px; color: #854d0e; font-size: 13px; line-height: 1.9; background: #fefce8; border: 1px solid #fde68a; border-radius: 8px; }
.cutting-errors { margin-bottom: 18px; padding: 12px 16px; color: #991b1b; background: #fef2f2; border: 1px solid #fecaca; border-radius: 10px; }
.cutting-errors p { margin: 4px 0; line-height: 1.8; }
.cabinet-card { border-right: 4px solid #176b45; }
.cabinet-card-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.cabinet-card-heading h3 { margin: 0; font-size: 18px; font-weight: 800; }
.cabinet-card-heading span { padding: 5px 10px; color: #475569; font-size: 12px; background: #f1f5f9; border-radius: 20px; }
.cabinet-card-footer { display: flex; justify-content: flex-start; margin-top: 18px; padding-top: 14px; border-top: 1px solid #e2e8f0; }
.results-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; margin-bottom: 18px; }
.results-heading h2 { margin: 0 0 6px; }
.results-heading p { margin: 0; color: #64748b; font-size: 13px; line-height: 1.8; }

/* =========================================
   جدول آنالیز برش
   ========================================= */
.cutting-table-wrap {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #000;
    border-radius: 0;
    background: #fff;
}

.cutting-table {
    width: 100%;
    min-width: 900px;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 12px;
    margin: 0 auto;
    direction: ltr;
    font-family: Tahoma, Arial, sans-serif;
}

.cutting-table th,
.cutting-table td {
    padding: 4px 3px;
    border: 1px solid #000;
    text-align: center;
    vertical-align: middle;
    background: #fff;
    color: #000;
    height: 28px;
}

/* هدر جدول */
.cutting-table thead th {
    background: #d4c9a8;
    color: #000;
    font-weight: 700;
    white-space: nowrap;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.cutting-table thead tr:nth-child(2) th {
    background: #d4c9a8;
}

.cutting-table tbody tr:nth-child(even) td {
    background: #d4c9a8;
}

.cutting-table tbody tr:nth-child(odd) td {
    background: #fff;
}

/* تنظیم اولیه عرض ستون‌ها */
.cutting-table th.col-row { width: 3%; }
.cutting-table th.col-dim { width: 6%; }
.cutting-table th.col-qty { width: 4%; }
.cutting-table th.col-note { width: 40%; }

/* ورودی‌های جدول */
.cutting-table .piece-input {
    display: block;
    width: 100%;
    min-width: 0;
    height: 26px;
    padding: 0 3px;
    font-size: 12px;
    text-align: center;
    border: none;
    border-radius: 0;
    background: transparent;
    color: #000;
    font-family: Tahoma, Arial, sans-serif;
}

.cutting-table .piece-input:focus {
    background: #fffde7;
    outline: 1px solid #2563eb;
}

.cutting-table .note-input {
    width: 100%;
    min-width: 0;
    text-align: right;
    direction: rtl;
    padding: 0 4px;
    font-size: 12px;
}

.cutting-table .dimension-input,
.cutting-table .qty-input {
    direction: ltr;
    text-align: center;
    padding: 0 1px;
    font-size: 10px;
}

.cutting-table .operation-cell {
    padding: 0;
}

.cutting-table select {
    width: 100%;
    min-width: 0;
    height: 26px;
    padding: 0;
    font-size: 12px;
    text-align: center;
    border: none;
    background: transparent;
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    color: #000;
    font-family: Tahoma, Arial, sans-serif;
}

.cutting-table select:focus {
    background: #e0f2fe;
}

.cutting-table tbody tr.empty-row td {
    height: 26px;
}

/* =========================================
   هدر و فوتر جدول
   ========================================= */
.print-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #d4c9a8;
    border: 1px solid #000;
    border-bottom: none;
    border-radius: 0;
    margin-bottom: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.print-header-info p {
    margin: 3px 0;
    font-size: 13px;
    color: #000;
    font-family: Tahoma, Arial, sans-serif;
}

.print-input-header {
    border: 1px solid #000;
    border-radius: 2px;
    padding: 3px 6px;
    font-size: 13px;
    width: 180px;
    background: #fff;
    color: #000;
    font-family: Tahoma, Arial, sans-serif;
}

.print-header-logo {
    text-align: right;
}

.print-header-logo h1 {
    margin: 0;
    font-size: 26px;
    font-style: italic;
    color: #000;
    font-family: Arial, sans-serif;
}

.print-header-logo p {
    margin: 0;
    font-size: 11px;
    color: #000;
    font-family: Arial, sans-serif;
}

.print-footer {
    display: flex;
    justify-content: space-between;
    padding: 8px;
    background: #d4c9a8;
    border: 1px solid #000;
    border-top: none;
    border-radius: 0;
    margin-top: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.footer-box-cut {
    border: 1px solid #000;
    padding: 6px;
    flex: 1;
    margin: 0 3px;
    font-size: 12px;
    color: #000;
    font-family: Tahoma, Arial, sans-serif;
}

.footer-box p {
    margin: 0 0 4px 0;
    font-weight: bold;
}

.print-input-footer {
    border: 1px solid #000;
    border-radius: 2px;
    padding: 2px 5px;
    font-size: 12px;
    background: #fff;
    width: 90px;
    color: #000;
    font-family: Tahoma, Arial, sans-serif;
}

/* =========================================
   ریسپانسیو کامل برای همه موبایل‌ها و تبلت‌ها
   ========================================= */

/* تبلت و موبایل بزرگ (تا 1024px) */
@media (max-width: 1024px) {
    .mdf-cutting-page {
        padding: 16px 8px 28px;
    }

    .cutting-container {
        max-width: 100%;
        padding: 0;
    }

    .cutting-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .cutting-card {
        padding: 16px;
    }

    .print-header,
    .print-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .print-input-header {
        width: 100%;
    }

    .print-footer {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    .print-footer .footer-box {
        width: 100% !important;
        margin: 0 !important;
    }
}

/* موبایل (تا 700px) */
/* =========================================
   موبایل: نمایش وب (بدون تغییر نسبت به قبل)
   ========================================= */
@media screen and (max-width: 700px) {
    /* هدر جدول: لوگو کنار آدرس (نمایش وب موبایل) */
    .print-header {
        flex-direction: row !important;
        align-items: flex-start !important;
        justify-content: space-between !important;
        gap: 8px !important;
        padding: 8px !important;
    }

    .print-header-info {
        flex: 1 1 auto;
        min-width: 0;
    }

    .print-header-info p {
        font-size: 9px !important;
        gap: 3px !important;
        margin: 1px 0 !important;
    }

    .print-input-header {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 130px !important;
        height: 18px !important;
        min-height: 0 !important;
        font-size: 9px !important;
        padding: 0 3px !important;
        line-height: 16px !important;
        border-radius: 2px !important;
        flex: 0 1 auto !important;
    }

    .print-header-logo {
        flex: 0 0 auto !important;
        text-align: right !important;
    }

    .print-header-logo h1 {
        font-size: 16px !important;
        line-height: 1 !important;
        margin: 0 !important;
    }

    .print-header-logo p {
        font-size: 7px !important;
        margin: 0 !important;
    }

    /* جدول در موبایل: دقیقاً مثل دسکتاپ */
    .cutting-table-wrap {
        overflow-x: hidden !important;
        overflow-y: visible !important;
    }

    .mdf-cutting-page #print-section table.cutting-table {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        table-layout: fixed !important;
        border-collapse: collapse !important;
        font-size: 7px !important;
    }

    .mdf-cutting-page #print-section .cutting-table th,
    .mdf-cutting-page #print-section .cutting-table td {
        padding: 1px 0 !important;
        height: 22px !important;
        max-height: 22px !important;
        line-height: 20px !important;
        overflow: hidden !important;
        white-space: nowrap !important;
        font-size: 7px !important;
    }

    .mdf-cutting-page #print-section .cutting-table thead tr:nth-child(2) th {
        font-size: 6px !important;
        padding: 1px 0 !important;
        line-height: 1 !important;
    }

    .mdf-cutting-page #print-section .cutting-table .piece-input,
    .mdf-cutting-page #print-section .cutting-table select {
        height: 20px !important;
        max-height: 20px !important;
        min-height: 0 !important;
        line-height: 18px !important;
        font-size: 7px !important;
        padding: 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .mdf-cutting-page #print-section .cutting-table .note-input {
        font-size: 7px !important;
        line-height: 18px !important;
        text-align: right !important;
        direction: rtl !important;
        padding: 0 1px !important;
    }

    .mdf-cutting-page #print-section .cutting-table .dimension-input,
    .mdf-cutting-page #print-section .cutting-table .qty-input {
        font-size: 7px !important;
        line-height: 18px !important;
    }

    /* فوتر جدول: تک‌ستونی */
    .print-footer {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
        padding: 8px !important;
    }

    .print-footer .footer-box {
        width: 100% !important;
        margin: 0 !important;
        padding: 8px 10px !important;
    }

    .print-footer .print-input-footer {
        max-width: 100% !important;
        width: 100% !important;
        height: 28px !important;
        font-size: 11px !important;
    }
}

/* =========================================
   موبایل: پرینت (لوگو گوشه بالا-چپ)
   ========================================= */


/* موبایل کوچک (تا 480px) */
@media (max-width: 480px) {
    .mdf-cutting-page {
        padding: 10px 5px 20px;
    }

    .cutting-header h1 {
        font-size: 19px;
    }

    .cutting-header p {
        font-size: 12px;
    }

    .cutting-card {
        padding: 10px;
    }

    .cutting-field input,
    .cutting-field select,
    .piece-input {
        min-height: 40px;
        font-size: 14px;
    }

    .cutting-table {
        min-width: 960px;
        font-size: 10px;
    }

    .cutting-table .piece-input,
    .cutting-table select {
        height: 22px;
        font-size: 10px;
    }

    .print-header-logo h1 {
        font-size: 18px;
    }
}

/* موبایل خیلی کوچک (تا 360px مثل iPhone SE) */
@media (max-width: 360px) {
    .mdf-cutting-page {
        padding: 8px 4px 16px;
    }

    .cutting-header h1 {
        font-size: 17px;
    }

    .cutting-card {
        padding: 8px;
    }

    .cutting-table {
        min-width: 920px;
        font-size: 9.5px;
    }

    .cutting-table .piece-input,
    .cutting-table select {
        height: 20px;
        font-size: 9.5px;
    }

    .cutting-table th,
    .cutting-table td {
        padding: 2px 1px;
        height: 22px;
    }
}

/* حالت افقی موبایل (landscape) */
@media (max-width: 900px) and (orientation: landscape) {
    .cutting-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .cutting-table {
        min-width: 1000px;
    }
}

/* =========================================
   تنظیمات چاپ A4
   ========================================= */
@page {
    size: A4 portrait;
    margin: 5mm;
}

@media print {
    /* فقط بخش جدول چاپ شود */
    body.printing-table * {
        visibility: hidden !important;
    }

    body.printing-table #print-section,
    body.printing-table #print-section * {
        visibility: visible !important;
    }

    body.printing-table #print-section {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
        background: #fff !important;
    }

    /* حفظ اندازه ستون‌ها مثل وب */
    body.printing-table .cutting-table {
        width: 100% !important;
        min-width: 0 !important;
        table-layout: fixed !important;
        border-collapse: collapse !important;
    }

    body.printing-table .cutting-table th,
    body.printing-table .cutting-table td {
        border: 1px solid #000 !important;
        padding: 2px 2px !important;
        font-size: 8pt !important;
        height: auto !important;
        vertical-align: middle !important;
        text-align: center !important;
        background: #fff !important;
        color: #000 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    body.printing-table .cutting-table thead th {
        background: #d4c9a8 !important;
    }

    body.printing-table .cutting-table tbody tr:nth-child(even) td {
        background: #d4c9a8 !important;
    }

    body.printing-table .cutting-table tbody tr:nth-child(odd) td {
        background: #fff !important;
    }

    /* ورودی‌ها به شکل متن اما بدون تغییر چیدمان */
    body.printing-table .cutting-table input,
    body.printing-table .cutting-table select {
        border: none !important;
        background: transparent !important;
        padding: 0 !important;
        margin: 0 !important;
        font-size: inherit !important;
        color: #000 !important;
        width: 100% !important;
        text-align: center !important;
        appearance: none !important;
        -webkit-appearance: none !important;
    }

    body.printing-table .cutting-table .note-input {
        text-align: right !important;
        direction: rtl !important;
    }

    /* هدر و فوتر — مثل وب: لوگو چپ، Name/phone/address راست (با order ثابت) */
    body.printing-table .print-header {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        gap: 8px !important;
        padding: 6px 8px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        direction: ltr !important;
    }
    body.printing-table .print-header-logo {
        order: 1 !important;
        flex: 0 0 auto !important;
        text-align: left !important;
        direction: ltr !important;
    }
    body.printing-table .print-header-info {
        order: 2 !important;
        flex: 1 1 auto !important;
        min-width: 0 !important;
        text-align: right !important;
        direction: ltr !important;
    }
    body.printing-table .print-header-info p {
        display: block !important;
        margin: 2px 0 !important;
        padding: 0 !important;
        font-size: 9pt !important;
        line-height: 1.4 !important;
        white-space: nowrap !important;
        text-align: right !important;
        direction: ltr !important;
        color: #000 !important;
        font-family: Tahoma, Arial, sans-serif !important;
    }
    body.printing-table .print-input-header {
        display: inline-block !important;
        width: 140px !important;
        max-width: 140px !important;
        height: 18px !important;
        min-height: 0 !important;
        max-height: 18px !important;
        font-size: 9pt !important;
        line-height: 16px !important;
        padding: 0 4px !important;
        margin: 0 0 0 4px !important;
        border: 1px solid #000 !important;
        border-radius: 2px !important;
        background: #fff !important;
        color: #000 !important;
        box-sizing: border-box !important;
        vertical-align: middle !important;
        text-align: left !important;
        direction: ltr !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    body.printing-table .print-header-logo h1 {
        margin: 0 !important;
        font-size: 20pt !important;
        line-height: 1 !important;
        font-style: italic !important;
        text-align: left !important;
        color: #000 !important;
        font-family: Arial, sans-serif !important;
    }
    body.printing-table .print-header-logo p {
        margin: 0 !important;
        font-size: 8pt !important;
        text-align: left !important;
        color: #000 !important;
        font-family: Arial, sans-serif !important;
    }

    body.printing-table .print-footer {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        direction: rtl !important;
        gap: 8px !important;
        margin-top: 3px !important;
    }

    /* حذف دکمه‌ها */
    body.printing-table button {
        display: none !important;
    }

    /* جلوگیری از شکستن ردیف‌ها */
    body.printing-table .cutting-table tr {
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }

    @page {
        size: A4 portrait;
        margin: 5mm;
    }
}

/* =========================================
   تنظیم نهایی عرض ستون‌ها در وب
   ========================================= */
.mdf-cutting-page #print-section table.cutting-table {
    width: 100% !important;
    min-width: 900px;
    table-layout: fixed !important;
    border-collapse: collapse !important;
}

#print-section .cutting-table thead tr:first-child th.col-row {
    width: 3% !important;
}

#print-section .cutting-table thead tr:first-child th.col-dim {
    width: 6% !important;
}

#print-section .cutting-table thead tr:first-child th.col-qty {
    width: 4% !important;
}
#print-section .cutting-table thead tr:first-child th[colspan="2"] {
    width: 10% !important;
}
#print-section .cutting-table thead tr:first-child th.col-note {
    width: 27% !important;
}

#print-section .cutting-table tbody td:nth-child(1) {
    width: 3% !important;
}

#print-section .cutting-table tbody td:nth-child(2),
#print-section .cutting-table tbody td:nth-child(3) {
    width: 6% !important;
}

#print-section .cutting-table tbody td:nth-child(4) {
    width: 4% !important;
}

#print-section .cutting-table tbody td:nth-child(n+5):nth-child(-n+14) {
    width: 5% !important;
}

#print-section .cutting-table tbody td:last-child {
    width: 27% !important;
}

/* هدر ردیف دوم: بلند/کوتاه جا شود */
#print-section .cutting-table thead tr:nth-child(2) th {
    white-space: nowrap !important;
    font-size: 6.5pt !important;
    padding: 2px 1px !important;
    line-height: 1.1 !important;
}

.mdf-cutting-page #print-section .cutting-table .dimension-input,
.mdf-cutting-page #print-section .cutting-table .qty-input {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    padding: 0 1px !important;
    font-size: 10px !important;
    text-align: center !important;
}

.mdf-cutting-page #print-section .cutting-table .note-input {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    padding: 0 4px !important;
    font-size: 11px !important;
    text-align: right !important;
    direction: rtl !important;
}


/* کادرهای پایین جدول چاپ */
.print-footer {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    direction: rtl !important;
    width: 100% !important;
    gap: 12px !important;
    margin: 0 auto !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    align-items: stretch !important;
}

.print-footer .footer-box {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 48px !important;
    box-sizing: border-box !important;
    border: 1px solid #222 !important;
    border-radius: 9px !important;
    background: #c8c3a2 !important;
    padding: 5px 8px !important;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: space-around !important;
    gap: 5px 10px !important;
    font-size: 11px !important;
}

.print-footer .footer-title {
    width: 100% !important;
    text-align: center !important;
    font-weight: normal !important;
    margin: 0 !important;
    padding: 0 !important;
}

.print-footer .footer-box label {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    margin: 0 !important;
    white-space: nowrap !important;
}

.print-footer .print-input-footer {
    max-width: 100px !important;
    min-width: 35px !important;
    height: 20px !important;
    box-sizing: border-box !important;
    font-size: 10px !important;
    padding: 1px 3px !important;
}

@media print {
    .print-footer {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        direction: rtl !important;
        width: 100% !important;
        gap: 12px !important;
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }

    .print-footer .footer-box {
        break-inside: avoid !important;
        page-break-inside: avoid !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}

/* =========================================
   تثبیت ارتفاع سلول‌ها و ردیف‌ها هنگام ورود داده
   ========================================= */

/* ارتفاع ثابت ردیف‌ها */
.mdf-cutting-page #print-section .cutting-table tbody tr {
    height: 28px !important;
    max-height: 28px !important;
}

.mdf-cutting-page #print-section .cutting-table tbody tr.empty-row {
    height: 26px !important;
    max-height: 26px !important;
}

/* ارتفاع ثابت سلول‌ها */
.mdf-cutting-page #print-section .cutting-table th,
.mdf-cutting-page #print-section .cutting-table td {
    height: 28px !important;
    max-height: 28px !important;
    line-height: 26px !important;
    padding: 0 !important;
    vertical-align: middle !important;
    overflow: hidden !important;
}

.mdf-cutting-page #print-section .cutting-table thead th {
    height: auto !important;
    max-height: none !important;
    line-height: 1.2 !important;
    padding: 3px 2px !important;
    overflow: visible !important;
}

/* inputهای داخل جدول: بدون افزایش ارتفاع */
.mdf-cutting-page #print-section .cutting-table .piece-input {
    display: block !important;
    width: 100% !important;
    height: 26px !important;
    max-height: 26px !important;
    min-height: 0 !important;
    padding: 0 2px !important;
    margin: 0 !important;
    line-height: 24px !important;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-sizing: border-box !important;
    font-size: 11px !important;
}

.mdf-cutting-page #print-section .cutting-table .dimension-input,
.mdf-cutting-page #print-section .cutting-table .qty-input {
    font-size: 10px !important;
    line-height: 24px !important;
    text-align: center !important;
}

.mdf-cutting-page #print-section .cutting-table .note-input {
    font-size: 11px !important;
    line-height: 24px !important;
    text-align: right !important;
    direction: rtl !important;
}

/* selectهای عملیات: هم‌ارتفاع با input */
.mdf-cutting-page #print-section .cutting-table .operation-cell {
    padding: 0 !important;
    height: 28px !important;
    max-height: 28px !important;
    overflow: hidden !important;
}

.mdf-cutting-page #print-section .cutting-table select {
    display: block !important;
    width: 100% !important;
    height: 26px !important;
    max-height: 26px !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 24px !important;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-sizing: border-box !important;
    font-size: 11px !important;
    text-align: center !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
}

/* حذف فلش select که باعث افزایش ارتفاع می‌شود */
.mdf-cutting-page #print-section .cutting-table select::-ms-expand {
    display: none !important;
}


/* =========================================
   آکاردئون کارت کمد (details/summary)
   ========================================= */
details.cabinet-card {
    padding: 0 !important;
    overflow: hidden;
}

/* summary باید block باشد تا کلیک مطمئن کار کند */
details.cabinet-card > summary.cabinet-card-heading {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

/* حذف فلش پیش‌فرض مرورگر */
details.cabinet-card > summary::-webkit-details-marker { display: none; }
details.cabinet-card > summary::marker { content: ""; }

/* چیدمان داخلی summary با flex */
.cabinet-summary-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 18px;
    width: 100%;
    box-sizing: border-box;
}

details.cabinet-card > summary:hover .cabinet-summary-inner {
    background: #f8fafc;
}

details.cabinet-card[open] > summary .cabinet-summary-inner {
    border-bottom: 1px solid #e2e8f0;
}

.cabinet-title {
    font-size: 18px;
    font-weight: 800;
    color: #263238;
}

.cabinet-heading-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cabinet-badge {
    padding: 5px 10px;
    color: #475569;
    font-size: 12px;
    background: #f1f5f9;
    border-radius: 20px;
}

.toggle-arrow {
    display: inline-block;
    font-size: 14px;
    color: #176b45;
    transition: transform 0.25s ease;
}

details.cabinet-card[open] .toggle-arrow {
    transform: rotate(180deg);
}

/* بدنه */
details.cabinet-card .collapsible-body {
    padding: 18px;
    /* مقادیر قبلی max-height/opacity را حذف کن */
    max-height: none !important;
    opacity: 1 !important;
    margin-top: 0 !important;
    overflow: visible !important;
}

/* حذف قواعد قدیمی که با details تداخل دارند */
.cabinet-card.is-open .collapsible-body,
.cabinet-card .collapsible-body {
    max-height: none !important;
    opacity: 1 !important;
}

/* =========================================
   لیست پروژه‌ها
   ========================================= */
.project-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.project-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 16px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}

.project-row.is-active {
    border-right: 4px solid #176b45;
    background: #f0fdf4;
}

.project-info h3 {
    margin: 0 0 4px;
    font-size: 16px;
    font-weight: 800;
}

.project-info p {
    margin: 0;
    font-size: 12px;
    color: #64748b;
}

.project-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.project-actions a.cutting-submit {
    text-decoration: none;
}

.project-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 700;
    color: #176b45;
    background: #dcfce7;
    border-radius: 20px;
}

/* دکمه‌های لینک‌شکل در header */
.cutting-actions a.cutting-submit {
    text-decoration: none;
}

/* =========================================
   نوار شناسه کاربر (همگام‌سازی بین دستگاه‌ها)
   ========================================= */
.owner-key-bar {
    margin-bottom: 16px;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}

.owner-key-bar form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    width: 100%;
}

.owner-key-bar label {
    font-size: 13px;
    color: #475569;
    font-weight: 700;
}

.owner-key-bar input {
    flex: 1 1 220px;
    min-height: 38px;
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font: inherit;
    font-size: 14px;
    background: #fff;
    color: #1e293b;
}

.owner-key-bar input:focus {
    outline: 2px solid rgba(37, 99, 235, 0.18);
    border-color: #2563eb;
}

/* =========================================
   تثبیت رنگ و ارتفاع بعد از ذخیره (موبایل و دسکتاپ)
   ========================================= */

.mdf-cutting-page #print-section .cutting-table tbody tr:nth-child(even) td {
    background: #d4c9a8 !important;
}

.mdf-cutting-page #print-section .cutting-table tbody tr:nth-child(odd) td {
    background: #ffffff !important;
}

.mdf-cutting-page #print-section .cutting-table tbody tr.empty-row td {
    background: #ffffff !important;
}

/* جلوگیری از تغییر ارتفاع بعد از رفرش */
.mdf-cutting-page #print-section .cutting-table tbody tr {
    height: 28px !important;
}

.mdf-cutting-page #print-section .cutting-table th,
.mdf-cutting-page #print-section .cutting-table td {
    height: 28px !important;
    max-height: 28px !important;
    line-height: 26px !important;
    padding: 0 !important;
    vertical-align: middle !important;
    overflow: hidden !important;
}

.mdf-cutting-page #print-section .cutting-table thead th {
    height: auto !important;
    max-height: none !important;
    line-height: 1.2 !important;
    padding: 3px 2px !important;
}


/* =========================================
   فاصله برای اسکرول به anchor
   ========================================= */
details.cabinet-card {
    scroll-margin-top: 80px;
}

#results-section,
#cabinet-list {
    scroll-margin-top: 80px;
}

/* =========================================
   رنگ‌بندی ردیف‌های خاص در جدول آنالیز
   ========================================= */

/* ردیف پشت‌بند ۳ میل — رنگ آبی روشن */
.mdf-cutting-page #print-section .cutting-table tbody tr.row-back-3mm td,
.mdf-cutting-page #print-section .cutting-table tbody tr.row-back-3mm th {
    background: #a8d5f2 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
}

/* ردیف درب — رنگ صورتی/نارنجی روشن */
.mdf-cutting-page #print-section .cutting-table tbody tr.row-door td,
.mdf-cutting-page #print-section .cutting-table tbody tr.row-door th {
    background: #f9c9a0 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
}

/* حفظ رنگ در حالت چاپ */
@media print {
    body.printing-table .cutting-table tbody tr.row-back-3mm td {
        background: #a8d5f2 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    body.printing-table .cutting-table tbody tr.row-door td {
        background: #f9c9a0 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}

.locked-field {
    background-color: #f0f0f0;
    cursor: not-allowed;
    opacity: 0.8;
}