/* ============================================================================
   Production Costs — صفحة تكاليف الإنتاج
   مرآة طبق الأصل لِلغة صفحة الطلبات (orders-cards.css): نفس شريط الأدوات
   الموحّد (.ot-*) ونفس نظام البطاقات «Bold Colorful» ونفس عرض القائمة
   القابل للتوسيع (.ot-expandable). معزول بالكامل تحت #productionCostsPage
   وبادئة .pcc-* كي لا يمسّ بطاقات/جداول الطلبات أو التقارير.
   الفرق الوحيد: «الحالة» هنا ربح/خسارة بدل حالة الطلب، فنستخدم توكنز
   --profitable-product-* / --losing-product-* بدل --new-*/
--ready-*.
   ============================================================================ */

/* ============================================================
   1) شريط الأدوات الموحّد (.ot-*) — نسخة معاد تحديدها تحت #productionCostsPage
   (القوائم المنبثقة .ot-view-menu / .ot-col-menu / .otf-* عامّة في orders-cards.css
   فلا نُعيد تعريفها هنا).
   ============================================================ */

#productionCostsPage .orders-toolbar-v2 {
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    z-index: 1;
}
#productionCostsPage .ot-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* --- حقل البحث الذكي --- */
#productionCostsPage .ot-search {
    flex: 1 1 320px;
    min-width: 280px;
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 42px;
    padding: 0 12px 0 14px;
    background: color-mix(in srgb, var(--bg-main) 70%, var(--surface-solid));
    border: 1px solid var(--border-main);
    border-radius: 10px;
    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease,
        background-color 0.15s ease;
}
#productionCostsPage .ot-search:hover,
#productionCostsPage .ot-search:focus-within {
    background: color-mix(in srgb, var(--bg-main) 70%, var(--surface-solid));
    border-color: var(--border-main);
}
#productionCostsPage .ot-search-icon {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
    flex: 0 0 18px;
}
#productionCostsPage .ot-search input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    font: inherit;
    font-size: 14px;
    color: var(--text-title);
    padding: 0;
}
#productionCostsPage .ot-search input::placeholder {
    color: var(--text-secondary);
}

/* --- زر عام + زر الفلترة + الشارة --- */
#productionCostsPage .ot-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 42px;
    padding: 0 14px;
    border: 1px solid var(--border-main);
    border-radius: 999px;
    background: color-mix(in srgb, var(--bg-main) 70%, var(--surface-solid));
    color: var(--text-title);
    font: inherit;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease,
        box-shadow 0.15s ease;
    white-space: nowrap;
}
#productionCostsPage .ot-btn:hover {
    background: var(--surface-hover);
    border-color: color-mix(in srgb, var(--primary) 38%, var(--border-main));
}
#productionCostsPage .ot-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
#productionCostsPage .ot-btn svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
    flex: 0 0 16px;
}
#productionCostsPage .ot-btn[aria-expanded='true'] {
    background: color-mix(in srgb, var(--primary) 10%, var(--surface-main));
    border-color: color-mix(in srgb, var(--primary) 38%, var(--border-main));
    color: var(--primary);
}
#productionCostsPage .ot-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--primary);
    color: #fff;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    font-family: var(--app-mono-family);
}
#productionCostsPage .ot-btn[aria-expanded='true'] .ot-badge {
    background: var(--primary);
}

/* زر الفلترة: دائري أيقوني 42px */
#productionCostsPage .ot-btn-filter {
    width: 42px;
    padding: 0;
    flex: 0 0 42px;
    justify-content: center;
    border-radius: 999px;
    position: relative;
}
#productionCostsPage .ot-btn-filter:hover {
    background: color-mix(in srgb, var(--bg-main) 70%, var(--surface-solid));
    border-color: var(--border-main);
    color: var(--text-title);
}
#productionCostsPage .ot-btn-filter .ot-badge {
    position: absolute;
    top: -5px;
    inset-inline-start: -5px;
}

/* --- قائمة العرض (Dropdown trigger) --- */
#productionCostsPage .ot-view-wrap {
    position: relative;
}
#productionCostsPage .ot-view-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    height: 42px;
    padding: 0 12px;
    min-width: 168px;
    background: color-mix(in srgb, var(--bg-main) 70%, var(--surface-solid));
    border: 1px solid var(--border-main);
    border-radius: 999px;
    color: var(--text-title);
    font: inherit;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}
#productionCostsPage .ot-view-trigger:hover {
    border-color: color-mix(in srgb, var(--primary) 38%, var(--border-main));
}
#productionCostsPage .ot-view-trigger[aria-expanded='true'] {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent);
}
#productionCostsPage .ot-view-trigger:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
#productionCostsPage .ot-view-left {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
#productionCostsPage .ot-view-left svg {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
    stroke-width: 2;
    flex: 0 0 16px;
}
#productionCostsPage .ot-view-caret {
    width: 14px;
    height: 14px;
    color: var(--text-secondary);
    flex: 0 0 14px;
    transition: transform 0.15s ease;
}
#productionCostsPage .ot-view-trigger[aria-expanded='true'] .ot-view-caret {
    transform: rotate(180deg);
    color: var(--primary);
}

/* زر «طريقة العرض» فقط (#pcViewTrigger): مربّع أيقوني 42px */
#productionCostsPage #pcViewTrigger {
    justify-content: center;
    gap: 0;
    width: 42px;
    min-width: 0;
    padding: 0;
    flex: 0 0 42px;
    border-radius: 999px;
    font-size: 13.5px;
    font-weight: 500;
}
#productionCostsPage #pcViewTrigger .ot-view-left {
    justify-content: center;
    gap: 0;
}
#productionCostsPage #pcViewTrigger .ot-view-left svg {
    color: inherit;
}
#productionCostsPage #pcViewTrigger:hover {
    background: var(--surface-hover);
}
#productionCostsPage #pcViewTrigger[aria-expanded='true'] {
    background: color-mix(in srgb, var(--primary) 10%, var(--surface-main));
    border-color: color-mix(in srgb, var(--primary) 38%, var(--border-main));
    color: var(--primary);
    box-shadow: none;
}

/* --- شريط الفلاتر النشطة (chips) --- */
#productionCostsPage .ot-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: 12px 14px;
    border-top: 1px solid var(--border-light);
    margin-top: 6px;
    background: var(--surface-hover);
    border-radius: 0 0 10px 10px;
}
#productionCostsPage .ot-chips:empty {
    display: none;
}
#productionCostsPage .ot-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 4px 0 12px;
    background: color-mix(in srgb, var(--primary) 10%, var(--surface-main));
    color: var(--primary);
    border: 1px solid color-mix(in srgb, var(--primary) 22%, var(--border-main));
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    box-shadow: 0 1px 2px color-mix(in srgb, var(--primary) 8%, transparent);
}
#productionCostsPage .ot-chip-label {
    color: color-mix(in srgb, var(--primary) 60%, var(--text-secondary));
    font-weight: 500;
    margin-inline-end: 2px;
}
#productionCostsPage .ot-chip button {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: color-mix(in srgb, var(--primary) 14%, transparent);
    color: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}
#productionCostsPage .ot-chip button:hover {
    background: var(--primary);
    color: #fff;
    transform: rotate(90deg);
}
#productionCostsPage .ot-chip button svg {
    width: 10px;
    height: 10px;
    stroke-width: 2.5;
}
#productionCostsPage .ot-chip-clear {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 999px;
    margin-inline-start: 4px;
    transition: all 0.15s ease;
}
#productionCostsPage .ot-chip-clear:hover {
    background: color-mix(in srgb, var(--btn-danger-bg, #fa896b) 12%, transparent);
    color: var(--btn-danger-bg, #fa896b);
}

/* --- حقل البحث القابل للطيّ (Dock) --- */
#productionCostsPage .ot-search[data-collapsed='true'] {
    flex: 0 0 42px;
    min-width: 42px;
    width: 42px;
    padding: 0;
    gap: 0;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    border-radius: 999px;
    transition:
        flex-basis 0.35s cubic-bezier(0.2, 0.8, 0.2, 1),
        width 0.35s cubic-bezier(0.2, 0.8, 0.2, 1),
        min-width 0.35s cubic-bezier(0.2, 0.8, 0.2, 1),
        padding 0.35s cubic-bezier(0.2, 0.8, 0.2, 1),
        border-radius 0.25s ease,
        background-color 0.15s ease,
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}
#productionCostsPage .ot-search[data-collapsed='true']:hover {
    background: color-mix(in srgb, var(--bg-main) 70%, var(--surface-solid));
    border-color: var(--border-main);
    color: var(--text-title);
}
#productionCostsPage .ot-search .ot-search-trigger {
    appearance: none;
    border: none;
    background: transparent;
    padding: 0;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: inherit;
    border-radius: 6px;
    transition: opacity 0.2s ease;
}
#productionCostsPage .ot-search[data-collapsed='false'] .ot-search-trigger {
    pointer-events: none;
}
#productionCostsPage .ot-search[data-collapsed='true'] #pcSearchInput {
    width: 0;
    padding: 0;
    opacity: 0;
    pointer-events: none;
}
#productionCostsPage .ot-search[data-collapsed='false'] {
    flex: 0 0 300px;
    min-width: 260px;
    max-width: 360px;
    width: auto;
    padding: 0 16px 0 18px;
    justify-content: flex-start;
    cursor: text;
    border-radius: 999px;
    transition:
        flex-basis 0.35s cubic-bezier(0.2, 0.8, 0.2, 1),
        width 0.35s cubic-bezier(0.2, 0.8, 0.2, 1),
        min-width 0.35s cubic-bezier(0.2, 0.8, 0.2, 1),
        padding 0.35s cubic-bezier(0.2, 0.8, 0.2, 1),
        border-radius 0.25s ease,
        background-color 0.15s ease,
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}
#productionCostsPage .ot-search[data-collapsed='false'] #pcSearchInput {
    width: auto;
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.25s ease 0.1s;
}
#productionCostsPage .ot-search .ot-search-icon {
    transition: transform 0.25s ease;
}
#productionCostsPage .ot-search .ot-search-clear {
    appearance: none;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    width: 26px;
    height: 26px;
    border-radius: 999px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex: 0 0 26px;
    padding: 0;
    transition:
        background-color 0.15s ease,
        color 0.15s ease,
        transform 0.15s ease;
}
#productionCostsPage .ot-search .ot-search-clear svg {
    width: 14px;
    height: 14px;
}
#productionCostsPage .ot-search .ot-search-clear:hover {
    background: color-mix(in srgb, var(--text-title) 8%, transparent);
    color: var(--text-title);
}
#productionCostsPage .ot-search .ot-search-clear:active {
    transform: scale(0.92);
}
#productionCostsPage .ot-search[data-collapsed='false'] .ot-search-input-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    min-width: 0;
}
#productionCostsPage .ot-search[data-collapsed='false'] .ot-search-clear.is-visible {
    display: inline-flex;
}

@media (prefers-reduced-motion: reduce) {
    #productionCostsPage .ot-search,
    #productionCostsPage .ot-search[data-collapsed='true'],
    #productionCostsPage .ot-search[data-collapsed='false'],
    #productionCostsPage .ot-search .ot-search-icon,
    #productionCostsPage .ot-search #pcSearchInput {
        transition: none !important;
    }
}

/* ============================================================
   2) البطاقات «Bold Colorful» (.pcc-*) — مرآة .oc-*
   شريط ربح/خسارة على الحافة + رقاقة + صفوف معلومات + تذييل صافي الربح.
   ============================================================ */

.pcc-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}
/* تدرّج عدد الأعمدة حسب عرض الشاشة: ٤ على الواسع، ثم ٣، ٢، وأخيراً عمود واحد على الجوال */
@media (max-width: 1200px) {
    .pcc-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
@media (max-width: 900px) {
    .pcc-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 560px) {
    .pcc-grid {
        grid-template-columns: 1fr;
    }
}

/* البطاقة: سطح صلب، ركن ناعم كبير، ظلّ ثابت، هالة بلون الربح/الخسارة عند المرور */
.pcc-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--surface-solid);
    border: none;
    --pcc-r-big: 40px;
    --pcc-r: 16px;
    border-start-end-radius: var(--pcc-r-big);
    border-start-start-radius: var(--pcc-r);
    border-end-start-radius: var(--pcc-r);
    border-end-end-radius: var(--pcc-r);
    padding: 16px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: box-shadow 0.22s ease;
}
.pcc-card:hover {
    box-shadow:
        var(--shadow-lg),
        0 0 0 1px color-mix(in srgb, var(--pcc-band, var(--primary)) 32%, transparent),
        0 18px 40px -14px color-mix(in srgb, var(--pcc-band, var(--primary)) 48%, transparent);
}
/* نطاق الربح/الخسارة: chip + هالة hover */
.pcc-card[data-st='profit'] {
    --pcc-band: var(--profitable-product-text);
    --pcc-band-bg: var(--profitable-product-bg);
}
.pcc-card[data-st='loss'] {
    --pcc-band: var(--losing-product-text);
    --pcc-band-bg: var(--losing-product-bg);
}

.clickable-pcc-card {
    cursor: pointer;
    user-select: none;
}
.clickable-pcc-card:hover {
    box-shadow:
        var(--shadow-lg),
        0 0 0 1px color-mix(in srgb, var(--pcc-band, var(--primary)) 32%, transparent),
        0 18px 40px -14px color-mix(in srgb, var(--pcc-band, var(--primary)) 48%, transparent);
    transform: none;
}
.clickable-pcc-card:active {
    transform: none;
}

/* الرأس: اسم المنتج + chip الربح/الخسارة */
.pcc-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    padding-inline-start: 10px;
}
.pcc-name {
    font-size: 14.5px;
    font-weight: 700;
    color: var(--text-title);
    letter-spacing: -0.01em;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1 1 auto;
}
.pcc-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 999px;
    color: var(--text-title);
    background: color-mix(in srgb, var(--pcc-band, var(--primary)) 24%, var(--surface-solid));
    white-space: nowrap;
    flex: 0 0 auto;
}
.pcc-chip::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--pcc-band, var(--primary));
}

/* صفوف المعلومات: سعر البيع / إجمالي التكلفة */
.pcc-rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
    padding-inline-start: 10px;
}
.pcc-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-main);
    min-width: 0;
}
.pcc-row .ico {
    width: 14px;
    flex-shrink: 0;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
}
.pcc-row .lbl {
    color: var(--text-secondary);
    font-weight: 500;
}
.pcc-row .val {
    font-weight: 600;
    margin-inline-start: auto;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.pcc-row .cur {
    color: var(--text-muted);
    font-size: 10px;
    margin-inline-start: 1px;
}

/* التذييل: صافي الربح (القيمة البطلة) + أزرار الإجراءات */
.pcc-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border-main);
}
.pcc-total-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.pcc-total-label {
    font-size: 10.5px;
    color: var(--text-muted);
    font-weight: 600;
}
.pcc-total-val {
    font-family: var(--app-font-family);
    font-size: 24px;
    font-weight: 800;
    color: var(--pcc-band, var(--text-title));
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.03em;
    line-height: 1;
}
.pcc-total-val .cur {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    margin-inline-start: 2px;
}
.pcc-margin-tag {
    font-size: 11px;
    font-weight: 700;
    color: var(--pcc-band, var(--text-title));
    margin-top: 3px;
}

/* أزرار الإجراءات داخل البطاقة: أيقونية مدمجة كزر واتساب في الطلبات */
.pcc-actions {
    flex: 0 0 auto;
    display: flex;
    gap: 6px;
}
.pcc-act {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 999px;
    border: 1px solid var(--border-main);
    background: var(--surface-solid);
    color: var(--text-secondary);
    cursor: pointer;
    transition:
        background 0.15s ease,
        color 0.15s ease,
        border-color 0.15s ease;
}
.pcc-act svg {
    width: 15px;
    height: 15px;
    stroke-width: 2;
}
.pcc-act:hover {
    background: color-mix(in srgb, var(--primary) 10%, var(--surface-solid));
    color: var(--primary);
    border-color: color-mix(in srgb, var(--primary) 38%, transparent);
}
.pcc-act.pcc-act-danger:hover {
    background: color-mix(in srgb, var(--danger) 10%, var(--surface-solid));
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger) 38%, transparent);
}

/* === كثافة البطاقة على الجوال (≤768px) === */
@media (max-width: 768px) {
    .pcc-grid {
        gap: 10px;
    }
    .pcc-card {
        padding: 12px;
        --pcc-r-big: 30px;
        --pcc-r: 14px;
    }
    .pcc-name {
        font-size: 12.5px;
    }
    .pcc-foot {
        flex-wrap: nowrap;
        gap: 10px;
        margin-top: 10px;
        padding-top: 10px;
    }
    .pcc-total-block {
        min-width: 0;
        flex: 1 1 auto;
    }
    .pcc-total-val {
        white-space: nowrap;
    }
    .pcc-actions {
        flex: 0 0 auto;
    }
}
@media (max-width: 420px) {
    .pcc-card {
        padding: 10px;
        --pcc-r-big: 24px;
        --pcc-r: 12px;
    }
}

/* ============================================================
   3) عرض القائمة — جدول قابل للتوسيع (.pc-list.ot-expandable)
   مرآة .orders-list.ot-expandable: صف رئيسي كثيف + صف تفاصيل مدمج.
   ============================================================ */

#productionCostsPage .pc-list {
    border-radius: var(--pane-radius);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    background: var(--surface-solid);
}
#productionCostsPage .pc-list table {
    table-layout: fixed;
    width: 100%;
    min-width: 640px;
}
#productionCostsPage .pc-list thead th {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-title);
    background: var(--table-header-bg);
    padding: var(--table-header-padding);
    border-bottom: 1px solid var(--table-header-border);
}
#productionCostsPage .pc-list tbody td {
    padding: var(--table-cell-padding);
    font-size: 13.5px;
    border-bottom: 1px solid var(--table-row-border);
    color: var(--table-row-text, var(--text-main));
    vertical-align: middle;
}
#productionCostsPage .pc-list tbody tr {
    border-bottom: none;
}
#productionCostsPage .pc-list tbody tr:nth-child(even) {
    background: var(--table-row-alt-bg, transparent);
}
#productionCostsPage .pc-list tbody tr:hover {
    background: var(--table-row-hover-bg);
}

/* خلية المنتج: شريط ربح/خسارة + اسم قابل للقصّ */
#productionCostsPage .pc-list .pc-product-cell {
    white-space: nowrap;
    vertical-align: middle;
    padding-inline-start: 16px;
}
#productionCostsPage .pc-list .pc-product-wrap {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
    max-width: 100%;
}
#productionCostsPage .pc-list .pc-band {
    display: inline-block;
    width: 4px;
    height: 18px;
    border-radius: 2px;
    flex-shrink: 0;
}
#productionCostsPage .pc-list .pc-band.s-profit {
    background: var(--profitable-product-text);
}
#productionCostsPage .pc-list .pc-band.s-loss {
    background: var(--losing-product-text);
}
#productionCostsPage .pc-list .pc-product-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1 1 auto;
    font-weight: 600;
    color: var(--text-title);
}
#productionCostsPage .pc-list .pc-price-cell {
    font-weight: 700;
    color: var(--text-title);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
#productionCostsPage .pc-list .pc-profit-cell {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
#productionCostsPage .pc-list .pc-profit-cell.is-profit {
    color: var(--profitable-product-text);
}
#productionCostsPage .pc-list .pc-profit-cell.is-loss {
    color: var(--losing-product-text);
}

/* رقاقة الربح/الخسارة داخل الجدول */
#productionCostsPage .pc-list .pc-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 700;
    font-size: 11px;
    padding: 4px 9px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--pcc-band, var(--primary)) 28%, var(--surface-solid));
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--pcc-band, var(--primary)) 32%, transparent);
    color: var(--text-title);
    white-space: nowrap;
}
#productionCostsPage .pc-list .pc-chip::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--pcc-band, var(--primary));
}
#productionCostsPage .pc-list .pc-chip.s-profit {
    --pcc-band: var(--profitable-product-text);
}
#productionCostsPage .pc-list .pc-chip.s-loss {
    --pcc-band: var(--losing-product-text);
}

/* === صفوف قابلة للتوسيع (design-5) === */
#productionCostsPage .pc-list.ot-expandable .ot-toggle-th {
    width: 48px;
    padding: 0;
}
#productionCostsPage .pc-list.ot-expandable .ot-toggle-cell {
    width: 48px;
    padding-inline-start: 14px;
    padding-inline-end: 4px;
    text-align: center;
    vertical-align: middle;
}
#productionCostsPage .pc-list.ot-expandable .ot-toggle {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-main);
    background: var(--surface-solid);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    transition:
        color 0.15s ease,
        background-color 0.15s ease,
        border-color 0.15s ease;
}
#productionCostsPage .pc-list.ot-expandable .ot-toggle:hover,
#productionCostsPage .pc-list.ot-expandable .ot-toggle:focus-visible {
    background: color-mix(in srgb, var(--primary) 10%, var(--surface-solid));
    color: var(--primary);
    border-color: color-mix(in srgb, var(--primary) 38%, transparent);
    outline: none;
}
#productionCostsPage .pc-list.ot-expandable .ot-toggle svg {
    transition: transform 0.2s ease;
}
#productionCostsPage .pc-list.ot-expandable .ot-main.is-open .ot-toggle svg,
#productionCostsPage .pc-list.ot-expandable .ot-toggle.is-open svg {
    transform: rotate(90deg);
}
#productionCostsPage .pc-list.ot-expandable .ot-main.is-open .ot-toggle {
    color: var(--primary);
    border-color: color-mix(in srgb, var(--primary) 38%, transparent);
}
#productionCostsPage .pc-list.ot-expandable .ot-main.is-open {
    background: color-mix(in srgb, var(--primary) 6%, var(--surface-solid));
}
#productionCostsPage .pc-list.ot-expandable .ot-main.is-open:hover {
    background: color-mix(in srgb, var(--primary) 9%, var(--surface-solid));
}
#productionCostsPage .pc-list.ot-expandable .ot-detail {
    display: none;
}
#productionCostsPage .pc-list.ot-expandable .ot-detail.is-open {
    display: table-row;
}
#productionCostsPage .pc-list.ot-expandable .ot-detail > td {
    padding: 0 !important;
    border-bottom: 1px solid var(--table-row-border);
    background: var(--surface-alt, color-mix(in srgb, var(--primary) 3%, var(--surface-solid)));
}
#productionCostsPage .pc-list.ot-expandable .ot-detail-inner {
    padding: 16px 18px 18px;
    animation: pcDetailIn 0.18s ease-out;
}
@keyframes pcDetailIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}
@media (prefers-reduced-motion: reduce) {
    #productionCostsPage .pc-list.ot-expandable .ot-detail-inner {
        animation: none;
    }
    #productionCostsPage .pc-list.ot-expandable .ot-toggle svg {
        transition: none;
    }
}
#productionCostsPage .pc-list.ot-expandable .ot-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 12px 22px;
    margin-bottom: 14px;
}
#productionCostsPage .pc-list.ot-expandable .ot-dt-item {
    min-width: 0;
}
#productionCostsPage .pc-list.ot-expandable .ot-dt-lbl {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 3px;
    letter-spacing: 0.2px;
}
#productionCostsPage .pc-list.ot-expandable .ot-dt-val {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-title);
    line-height: 1.5;
}
#productionCostsPage .pc-list.ot-expandable .ot-dt-val.is-profit {
    color: var(--profitable-product-text);
}
#productionCostsPage .pc-list.ot-expandable .ot-dt-val.is-loss {
    color: var(--losing-product-text);
}
#productionCostsPage .pc-list.ot-expandable .ot-dt-item--note .ot-dt-val {
    font-weight: 500;
    color: var(--text-main);
}
#productionCostsPage .pc-list.ot-expandable .ot-detail-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--table-row-border);
}

@media (max-width: 540px) {
    #productionCostsPage .pc-list.ot-expandable .ot-detail-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    #productionCostsPage .pc-list.ot-expandable .ot-detail-actions {
        gap: 6px;
    }
}
@media (max-width: 768px) {
    #productionCostsPage .pc-list.ot-expandable .ot-detail-inner {
        padding: 14px;
    }
}

/* --- الكثافة (compact) --- */
#productionCostsPage .pc-grid.ot-density-compact .pcc-card {
    padding: 11px 14px 10px;
}
#productionCostsPage .pc-list.ot-density-compact tbody td {
    padding: 8px 14px;
}
#productionCostsPage .pc-list.ot-density-compact thead th {
    padding: 8px 14px;
}

/* ============================================================
   4) مودال الإضافة/التعديل — حقول floating-label (.ao-field)
   نسخة من قواعد #addOrderModal في order-details.css لكن تحت
   #addProductionCostModal. يتطلّب placeholder=" " على كل مدخل.
   ============================================================ */

#addProductionCostModal .ao-field {
    position: relative;
}
/* حدّ الحقل يتحوّل إلى الأساسي عند التركيز (مرآة .ao-field-wrap.is-focused بلا JS) */
#addProductionCostModal .ao-field-wrap:focus-within {
    border-color: var(--primary);
}
#addProductionCostModal .ao-field:has(input, select, textarea) .ao-field-label {
    position: absolute;
    inset-inline-start: 14px;
    top: 50%;
    transform: translateY(-50%);
    transform-origin: start center;
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0;
    padding: 0 4px;
    max-width: calc(100% - 24px);
    background: transparent;
    color: var(--text-muted);
    font-size: 13.5px;
    font-weight: 500;
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    transition:
        top 0.16s ease,
        transform 0.16s ease,
        color 0.15s ease,
        background 0.15s ease;
    z-index: 2;
}
#addProductionCostModal .ao-field:has(input, select, textarea):focus-within .ao-field-label,
#addProductionCostModal .ao-field:has(input:not([type='hidden']):not(:placeholder-shown)) .ao-field-label,
#addProductionCostModal .ao-field:has(.is-filled) .ao-field-label,
#addProductionCostModal .ao-field:has(select option:checked:not([value=''])) .ao-field-label {
    top: 0;
    transform: translateY(-50%) scale(0.82);
    background: var(--surface-solid);
    color: var(--primary);
}
#addProductionCostModal
    .ao-field:has(input:not([type='hidden']):not(:placeholder-shown)):not(:focus-within)
    .ao-field-label,
#addProductionCostModal .ao-field:has(.is-filled):not(:focus-within) .ao-field-label {
    color: var(--text-secondary);
}
/* حقل الملاحظات (textarea): التسمية تطفو من الأعلى لا المنتصف */
#addProductionCostModal .ao-field:has(textarea) .ao-field-label {
    top: 16px;
    transform: none;
}
#addProductionCostModal .ao-field:has(textarea):focus-within .ao-field-label,
#addProductionCostModal .ao-field:has(textarea:not(:placeholder-shown)) .ao-field-label {
    top: 0;
    transform: translateY(-50%) scale(0.82);
}

/* شبكة حقول التكاليف: عمودان على الواسع، عمود على الضيق */
#addProductionCostModal .pc-cost-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 14px;
}
@media (max-width: 560px) {
    #addProductionCostModal .pc-cost-grid {
        grid-template-columns: 1fr;
    }
}

/* لوحة ملخّص الربح الحيّ — بأسلوب تذييل البطاقة لا صندوق رمادي قديم */
#addProductionCostModal .pc-summary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1px;
    background: var(--border-light);
    border: 1px solid var(--border-main);
    border-radius: 16px;
    overflow: hidden;
    margin: 4px 0 8px;
}
#addProductionCostModal .pc-summary-cell {
    background: var(--surface-solid);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
#addProductionCostModal .pc-summary-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}
#addProductionCostModal .pc-summary-val {
    font-size: 19px;
    font-weight: 800;
    color: var(--text-title);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    line-height: 1.1;
}
#addProductionCostModal .pc-summary-val .cur {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    margin-inline-start: 2px;
}
#addProductionCostModal .pc-summary-val.is-profit {
    color: var(--profitable-product-text);
}
#addProductionCostModal .pc-summary-val.is-loss {
    color: var(--losing-product-text);
}
#addProductionCostModal .pc-summary-cell.pc-summary-hero {
    grid-column: 1 / -1;
    background: color-mix(in srgb, var(--primary) 4%, var(--surface-solid));
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
#addProductionCostModal .pc-summary-hero .pc-summary-val {
    font-size: 26px;
}

/* أزرار المودال: نفس لغة .btn مع عرض كامل على الجوال */
#addProductionCostModal .pc-form-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}
#addProductionCostModal .pc-form-actions .btn {
    flex: 1;
}
