/* =========================================================
   1. Root variables & base
   ========================================================= */
:root {
    --bg: #f6f5f2;
    --surface: #ffffff;
    --line: #e7e4dd;
    --text: #1f2430;
    --muted: #6b7280;
    --brick: #c8102e;
    --brick-dark: #a30d26;
    --cost: #0f6f5c;
    --cost-bg: #e6f4f1;
}
* {
    font-family: IRANYekanX, sans-serif;
    font-variation-settings: "dots" 2;
}
@supports (font-variation-settings: normal) {
    * {
        font-family: "IRANYekanXVF", sans-serif;
    }
}
body {
    background: var(--bg);
    color: var(--text);
    margin: 0;
}
table .part-name-btn,
table .mf-name-btn,
table .color-name,
table .name-btn {
    font-size: 0.8rem;
}
table .toman-unit {
    font-size: 0.5rem;
}
.modal-content .form-label,
.card-box .form-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #888;
    margin-bottom: 2px;
}
table .row-num {
    text-align: center;
}
/* =========================================================
   2. App shell / sidebar (shared layout, see includes/sidebar.php)
   ========================================================= */
.app-shell {
    min-height: 100vh;
}
.sidebar {
    width: 230px;
    background: var(--surface);
    border-left: 1px solid var(--line);
    padding: 20px 14px;
}
.sidebar-brand {
    font-weight: 800;
    color: var(--brick);
    font-size: 1.15rem;
    margin-bottom: 24px;
    padding: 0 8px;
}
.sidebar-nav a {
    padding: 10px 12px;
    display: block;
    border-radius: 8px;
    color: var(--text);
    font-weight: 500;
    margin-bottom: 3px;
    text-decoration: none;
    font-size: 0.85rem;
}
.sidebar-nav a:hover {
    background: #f1efea;
}
.sidebar-nav a.active {
    background: var(--brick);
    color: #fff;
    font-weight: 700;
}
.sidebar-nav .nav-parent {
    cursor: pointer;
}
.sidebar-nav .nav-parent .chev {
    font-size: 0.7rem;
    transition: transform 0.2s;
    opacity: 0.6;
}
.sidebar-nav .nav-parent[aria-expanded="true"] .chev {
    transform: rotate(180deg);
}
.sidebar-nav .nav-parent.has-active-child {
    background: #f1efea;
    font-weight: 700;
}
.submenu {
    padding-right: 16px;
    margin-bottom: 2px;
}
.submenu a {
    display: block;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    text-decoration: none;
    border-radius: 7px;
    margin-bottom: 2px;
}
.submenu a:hover {
    background: #f1efea;
}
.submenu a.active {
    background: var(--brick);
    color: #fff;
    font-weight: 700;
}
.submenu-group-label {
    display: block;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
}
.submenu-nested {
    padding-right: 14px;
    margin-top: -2px;
    margin-bottom: 4px;
}
.submenu-nested a {
    display: block;
    padding: 7px 12px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
    border-radius: 7px;
    margin-bottom: 2px;
}
.submenu-nested a:hover {
    background: #f1efea;
    color: var(--text);
}
.submenu-nested a.active {
    background: var(--brick);
    color: #fff;
    font-weight: 700;
}
.main-content {
    min-width: 0;
}
.main-inner {
    padding: 24px 32px;
}

/* =========================================================
   3. Shared page chrome (header, buttons, search, tables)
   ========================================================= */
.page-head h1 {
    font-size: 1rem;
    font-weight: 800;
    margin: 0;
}
/* Icon-only “back to list” — matches page title size/weight; sits beside the title. */
.page-head-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    text-decoration: none;
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1;
    opacity: 0.55;
    transition: opacity .15s ease, color .15s ease;
}
.page-head-back:hover,
.page-head-back:focus-visible {
    opacity: 1;
    color: var(--brick);
}
.page-sub {
    color: var(--muted);
    font-size: 0.85rem;
    margin-bottom: 18px;
}
/* Default app button size — matches page-head «افزودن قطعه».
   Compact controls (pager, bulk bar, grid row actions) keep .btn-sm. */
.btn:not(.btn-sm):not(.btn-lg) {
    font-size: 0.8rem;
    padding: 0.375rem 0.75rem;
    line-height: 1.5;
}
.btn-brick {
    background: var(--brick);
    border-color: var(--brick);
    font-weight: 600;
}
.btn-brick:hover {
    background: var(--brick-dark);
    border-color: var(--brick-dark);
}

.search-wrap {
    position: relative;
    margin-bottom: 18px;
}
.search-wrap input {
    padding-right: 42px;
    height: 46px;
    border-radius: 10px;
    border: 1px solid var(--line);
}
.search-wrap i {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
}

/* Inline "?" hint icon next to a form-label/checkbox-label, replacing the old .form-text help line. */
.help-tip {
    color: var(--muted);
    font-size: 0.85em;
    cursor: help;
    margin-inline-start: 4px;
    vertical-align: middle;
}
.help-tip:hover {
    color: var(--brick);
}

.card-table {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
}
.card-table table {
    margin: 0;
}
.card-table thead th {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
    padding: 14px 12px;
}
.card-table th.sortable {
    cursor: pointer;
    user-select: none;
}
.card-table th.sortable:hover {
    color: var(--text);
}
.card-table th.sortable i {
    font-size: 0.75rem;
    margin-right: 4px;
    opacity: 0.5;
}
.card-table tbody td {
    padding: 12px;
    vertical-align: middle;
    border-bottom: 1px solid var(--line);
    font-size: 0.92rem;
}
.card-table tbody tr:last-child td {
    border-bottom: none;
}
.card-table tbody tr:hover {
    background: #fafaf8;
}
.card-table.bom-parts-scroll {
    max-height: min(70vh, calc(100vh - 260px));
    overflow-y: auto;
    overflow-x: hidden;
}
.card-table.bom-parts-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface);
}
.po-item-remove {
    width: 1.35rem;
    height: 1.35rem;
    padding: 0 !important;
    font-size: 0.65rem !important;
    line-height: 1 !important;
    border-radius: 0.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.po-item-remove .bi {
    font-size: 0.7rem;
    line-height: 1;
}
.po-product-row {
    cursor: pointer;
}
.po-product-row.is-selected > td,
.card-table tbody tr.po-product-row.is-selected:hover > td {
    background: #fbf3f1;
}
.po-list-thumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
}
.po-list-thumb-ph,
.po-list-thumb-more {
    width: 55px;
    height: 55px;
    border-radius: 6px;
    border: 1px solid var(--line);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.po-list-thumb-ph {
    background: var(--bg-soft, #f5f3ef);
    color: #B8B3A8;
    font-size: 1.1rem;
}
.po-list-thumb-more {
    background: #fff;
    color: var(--brick, #a65d4c);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0;
    cursor: pointer;
}
.po-list-thumb-more:hover {
    background: #fbf3f1;
}
.empty-row td {
    text-align: center;
    color: var(--muted);
    padding: 48px 0;
}
.row-num {
    color: var(--muted);
    font-size: 0.85rem;
    width: 1%;
    white-space: nowrap;
}

.thumb {
    width: 65px;
    height: 65px;
    border-radius: 10px;
    object-fit: cover;
    background: #efede7;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #b8b3a8;
    font-size: 1.4rem;
    border: 1px solid var(--line);
}
.thumb-sm {
    width: 46px;
    height: 46px;
    border-radius: 8px;
    background: #efede7;
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #b8b3a8;
    flex-shrink: 0;
    cursor: pointer;
    position: relative;
    font-size: 0.95rem;
    transition: 0.15s;
}
.thumb-sm:hover {
    border-color: var(--brick);
}
.thumb-sm.add {
    border-style: dashed;
    color: var(--muted);
}
.thumb-sm .feat-badge {
    position: absolute;
    top: -6px;
    left: -6px;
    background: var(--cost);
    color: #fff;
    font-size: 0.55rem;
    padding: 1px 5px;
    border-radius: 6px;
    font-weight: 700;
    white-space: nowrap;
}

.code-badge {
    background: #f1efea;
    color: var(--muted);
    font-size: 0.78rem;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 600;
}
.weight-kg {
    color: var(--muted);
    font-size: 0.78rem;
}
.price-row .row-value .weight-kg {
    display: block;
    text-align: inherit;
}
.swatch {
    width: 13px;
    height: 13px;
    border-radius: 3px;
    display: inline-block;
    border: 1px solid rgba(0, 0, 0, 0.15);
    vertical-align: middle;
    margin-left: 6px;
}
.color-tag {
    display: flex;
    align-items: center;
    gap: 5px;
}
.color-tag .swatch {
    margin-left: 0;
}
.final-cost {
    background: var(--cost-bg);
    color: var(--cost);
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 0.95rem;
    white-space: nowrap;
}
.badge-soft {
    background: #f1efea;
    color: var(--text);
    font-weight: 600;
    font-size: 0.78rem;
    border: 1px solid #ccc;
    line-height: 20px;
}
.dash {
    color: var(--muted);
}

/* ---------- bulk action bar ---------- */
.bulk-bar {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    background: var(--surface);
    border-top: 2px solid var(--brick);
    padding: 12px 28px;
    display: none;
    align-items: center;
    gap: 12px;
    z-index: 1040;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
    flex-wrap: wrap;
}
.bulk-bar.active {
    display: flex;
    height: 100px;
}
.bulk-bar-count {
    font-weight: 700;
    color: var(--brick);
    white-space: nowrap;
}
.bulk-bar .btn {
    font-size: 0.85rem;
}
.modal-body .row-label{
    font-weight: 600px;
    font-size: .8rem;
}
.modal-body .detail-section{
    border:1px solid #ccc;
    border-radius: 8px;
    padding: 10px;
    background:#f1f1f1;
}
/* ---------- skeleton loading rows (shown in a <tbody> while an AJAX list call is in flight) ---------- */
.skeleton-row td {
    border-top: none !important;
    padding: 10px 14px !important;
}
.skeleton-bar {
    height: 18px;
    border-radius: 6px;
    background: linear-gradient(90deg, #eceae4 25%, #f6f4ef 50%, #eceae4 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
@keyframes skeleton-shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.row-actions button {
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 7px;
    width: 32px;
    height: 32px;
    color: var(--muted);
}
.row-actions button:hover {
    color: var(--brick);
    border-color: var(--brick);
}
.bi::before,
[class*=" bi-"]::before,
[class^="bi-"]::before {
    padding-top: 5px;
}
/* =========================================================
   4. Detail modal / price breakdown / confirm dialog
   ========================================================= */
.detail-hero-img {
    width: 100%;
    height: auto;
    border-radius: 12px;
    background: #efede7;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #b8b3a8;
    font-size: 2.5rem;
}
/* Label/value rows used across detail modals (parts, products, imported products). Each row's
   two children carry .row-label / .row-value so either side can be targeted/styled independently
   without relying on :first-child/:last-child or per-page element ids. */
.price-row {
    padding: 8px 0;
    border-bottom: 1px dashed var(--line);
    font-size: 0.9rem;
}
.price-row:last-child {
    border-bottom: none;
}
.price-row.final {
    font-weight: 800;
    color: var(--cost);
    font-size: 1rem;
}
/* BrickOwl-style category breadcrumb in catalog modals (parts / imported).
   Trails sit on the same row as the modal title; size matches in view and edit. */
.detail-part-code {
    font-size: .82em;
    font-weight: 400;
    color: var(--muted);
}
.modal-header .modal-title,
.modal-header h1,
.modal-header h2,
.modal-header h3,
.modal-header h4,
.modal-header h5,
.modal-header h6 {
    font-size: 1.2rem;
    font-weight: 800;
}
.modal-title-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem 1rem;
    min-width: 0;
}
.modal-title-row .modal-title {
    margin-bottom: 0;
    flex-shrink: 0;
}
.modal-title-row .cat-breadcrumb-wrap,
.cat-breadcrumb-wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.75rem;
    margin: 0;
    font-size: 0.78rem;
    line-height: 1.4;
    min-width: 0;
}
.cat-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    font-size: inherit;
    line-height: 1.4;
}
.cat-breadcrumb + .cat-breadcrumb {
    margin-top: 0;
}
.cat-breadcrumb a {
    color: var(--muted);
    text-decoration: none;
}
.cat-breadcrumb a:hover {
    color: var(--brick);
    text-decoration: underline;
}
.cat-breadcrumb a:last-child {
    color: var(--text);
    font-weight: 700;
}
.cat-breadcrumb .crumb-sep {
    color: var(--muted);
    font-size: .62rem;
}

/* Parts / imported view+edit: near full viewport; body scrolls; footer stays put. */
.catalog-modal-dialog {
    max-width: 96vw;
    width: 96vw;
    height: 94vh;
    margin: 3vh auto;
    max-height: 94vh;
}
.catalog-modal-dialog .modal-content {
    height: 100%;
    max-height: 94vh;
    display: flex;
    flex-direction: column;
}
.catalog-modal-dialog .modal-header,
.catalog-modal-dialog .modal-footer {
    flex-shrink: 0;
}
.catalog-modal-dialog .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}
.catalog-detail-cols > [class*="col-"] {
    min-width: 0;
}
.catalog-detail-cols .parts-list-box {
    max-height: min(420px, 50vh);
}
.catalog-col-panel {
    height: 100%;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #f8f7f4;
}

/* Clickable chips in the part detail modal linking to other color variants of the same physical
   part (same base LEGO code, different colors) — clicking re-opens the detail modal on that row. */
.color-variant-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 4px 4px 14px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--surface);
    cursor: pointer;
    font-size: .8rem;
    transition: border-color .15s ease, background .15s ease;
}
.color-variant-chip:hover {
    border-color: var(--brick);
    background: #fbf3f1;
}
.color-variant-chip.active {
    border-color: var(--brick);
    background: var(--cost-bg);
    font-weight: 700;
}
.color-variant-chip .variant-thumb {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, .12);
}
.color-variant-chip .swatch {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    margin: 0;
    flex-shrink: 0;
}

/* Built products using this part — image thumbs only in the part detail modal */
.built-products-list {
    min-width: 0;
}
.built-products-thumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.built-product-thumb-link {
    display: block;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: #efede7;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.built-product-thumb-link:hover {
    border-color: var(--brick);
    box-shadow: 0 2px 8px rgba(196, 92, 38, 0.12);
}
.built-product-thumb {
    display: block;
    width: 56px;
    height: 56px;
    object-fit: cover;
}
.built-product-thumb--empty {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #b8b3a8;
    font-size: 1.2rem;
}

/* Groups a modal's detail body into labeled sections (e.g. pricing / weight & stock / description)
   so related fields are visually scannable instead of one long list. */
.detail-section {
    margin-top: 22px;
}
.detail-section:first-child {
    margin-top: 0;
}
.detail-section-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--muted);
    padding-bottom: 6px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--line);
}
.detail-section-title i {
    color: var(--brick);
    font-size: 0.85rem;
}
.confirm-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: #fdecec;
    color: var(--brick);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}
.color-tag {
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 2px 4px;
    width: 110px;
}
table .color-tag {
    margin: 5px 0;
}
/* =========================================================
   5. Toast notifications
   ========================================================= */
/* Slim indeterminate progress bar pinned to the top of the viewport — shown automatically by
   apiRequest() for the duration of every AJAX call (saves, deletes, loads, etc.) so the app never
   feels unresponsive, even on pages that don't have their own button-level spinner. */
.top-loading-bar {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    height: 3px;
    z-index: 2100;
    pointer-events: none;
}
.top-loading-bar::before {
    content: '';
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--brick), var(--brick-dark));
    opacity: 0;
    transition: width .2s ease, opacity .15s ease;
}
.top-loading-bar.active::before {
    width: 70%;
    opacity: 1;
    transition: width 4s cubic-bezier(.1, .6, .2, 1), opacity .15s ease;
}
.top-loading-bar.done::before {
    width: 100%;
    opacity: 1;
    transition: width .2s ease;
}

.toast-stack {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.app-toast {
    min-width: 280px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    animation: toastIn 0.2s ease;
}
.app-toast.success {
    border-right: 4px solid var(--cost);
}
.app-toast.error {
    border-right: 4px solid var(--brick);
}
.app-toast i {
    font-size: 1.2rem;
}
.app-toast.success i {
    color: var(--cost);
}
.app-toast.error i {
    color: var(--brick);
}
.app-toast span {
    font-size: 0.88rem;
    font-weight: 600;
}
@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================================================
   6. Media library / image picker (parts, products, imported products)
   ========================================================= */
.media-main {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 14px;
    background: #efede7;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #b8b3a8;
    font-size: 2.6rem;
    border: 1px solid var(--line);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: 0.15s;
}
.media-main:hover {
    border-color: var(--brick);
}
.media-overlay {
    position: absolute;
    inset: 0;
    background: rgba(20, 20, 20, 0.55);
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    opacity: 0;
    transition: 0.2s;
    font-size: 0.8rem;
    font-weight: 700;
}
.media-overlay i {
    font-size: 1.2rem;
}
.media-main:hover .media-overlay {
    opacity: 1;
}
.media-clear-btn {
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 2;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: rgba(20, 20, 20, 0.72);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}
.media-clear-btn:hover {
    background: var(--brick);
}
.media-main img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.media-strip {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    overflow-x: auto;
    overflow-y: visible;
    padding: 4px 2px 6px;
    margin: 0 -2px;
}
.media-strip .media-strip-thumb {
    width: 56px;
    height: 56px;
    overflow: hidden;
    border-width: 2px;
}
.media-strip .media-strip-thumb.is-featured {
    border-color: var(--cost);
    box-shadow: 0 0 0 2px var(--cost-bg);
}
/* Read-only detail gallery: highlight the currently shown thumb (may differ from featured). */
.media-strip.view-gallery-strip .media-strip-thumb.is-active {
    border-color: var(--cost);
    box-shadow: 0 0 0 2px var(--cost-bg);
}
.media-strip.view-gallery-strip .media-strip-thumb:not(.is-active) {
    opacity: 0.72;
}
.media-strip.view-gallery-strip .media-strip-thumb:not(.is-active):hover {
    opacity: 1;
}
.media-strip .media-strip-thumb-hit {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.media-strip .media-strip-thumb-hit img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.media-strip .feat-badge {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 0 0 6px 6px;
    font-size: 0.5rem;
    padding: 2px 0;
    text-align: center;
    line-height: 1.2;
    z-index: 2;
    pointer-events: none;
}
.media-strip .thumb-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--brick);
    color: #fff;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    z-index: 3;
}
.media-strip .thumb-remove:hover {
    background: #a84a1f;
}
.media-strip .media-strip-add {
    width: 56px;
    height: 56px;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    max-height: 440px;
    overflow-y: auto;
    padding: 4px;
}
.media-card {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.media-item {
    aspect-ratio: 1;
    border-radius: 8px;
    background: #efede7;
    border: 2px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #b8b3a8;
    cursor: pointer;
    font-size: 1.3rem;
    transition: 0.15s;
    overflow: hidden;
    position: relative;
}
.media-item:hover {
    border-color: var(--brick);
}
.media-item.selected {
    border-color: var(--cost);
    box-shadow: 0 0 0 2px var(--cost-bg);
}
.media-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.media-selected-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--cost);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}
.media-delete-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(20, 20, 20, 0.65);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    opacity: 0;
    transition: 0.15s;
}
.media-item:hover .media-delete-btn {
    opacity: 1;
}
.media-card .part-name {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.media-card .desc-input {
    font-size: 0.72rem;
    padding: 3px 7px;
    height: 28px;
    border: 1px solid var(--line);
    border-radius: 5px;
    width: 100%;
}
.media-empty {
    grid-column: 1/-1;
    text-align: center;
    color: var(--muted);
    padding: 40px 0;
}

/* Universal media library modal (almost full-screen, 2-column layout) */
.media-library-dialog {
    max-width: 96vw;
    width: 96vw;
    height: 94vh;
    margin: 3vh auto;
}
.media-library-dialog .modal-content {
    height: 100%;
    display: flex;
    flex-direction: column;
}
.media-library-dialog .modal-body {
    overflow: hidden;
    min-height: 0;
    flex: 1 1 auto;
}
.media-library-body {
    display: flex;
    flex-direction: row;
    min-height: 0;
    flex: 1 1 auto;
    overflow: hidden;
}

/* Left detail column (start side in RTL) */
.media-library-detail {
    width: 300px;
    flex-shrink: 0;
    border-inline-start: 1px solid var(--line);
    padding: 16px;
    overflow-y: auto;
    background: #fafaf8;
}
.media-library-detail-empty {
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    padding: 32px 8px;
}
.media-library-detail-preview {
    border-radius: 10px;
    overflow: hidden;
    background: #efede7;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}
.media-library-detail-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #fff;
}
.media-library-detail-placeholder {
    color: #b8b3a8;
    font-size: 2rem;
}
.media-library-detail-meta {
    margin: 0 0 14px;
}
.media-library-meta-row {
    display: grid;
    grid-template-columns: 72px 1fr;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 0.8rem;
}
.media-library-meta-row dt {
    color: var(--muted);
    margin: 0;
    font-weight: 600;
}
.media-library-meta-row dd {
    margin: 0;
    word-break: break-word;
}

/* Right main column — grid + drag/drop upload zone */
.media-library-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #fff;
}
.media-library-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
}
.media-library-search {
    width: min(360px, 100%);
}
.media-library-toolbar-hint {
    white-space: nowrap;
}
.media-library-grid-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    position: relative;
}
.media-library-dropzone {
    border: none;
    background: transparent;
    min-height: 100%;
    padding: 12px 16px 0;
    position: relative;
}
.media-library-dropzone .dz-message {
    display: none;
}
.media-library-dropzone.dz-drag-hover::after {
    content: 'رها کنید تا آپلود شود';
    position: absolute;
    inset: 8px;
    border: 2px dashed var(--brick, #c45c26);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--brick, #c45c26);
    z-index: 20;
    pointer-events: none;
}
.media-library-load-sentinel {
    height: 1px;
    margin-bottom: 8px;
}
.media-library-grid-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 16px;
    border-top: 1px solid var(--line);
    flex-shrink: 0;
}

.media-grid-large {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 10px;
    padding: 4px;
}
@media (max-width: 1100px) {
    .media-grid-large {
        grid-template-columns: repeat(8, 1fr);
    }
}
@media (max-width: 700px) {
    .media-library-detail {
        width: 240px;
    }
    .media-grid-large {
        grid-template-columns: repeat(4, 1fr);
    }
}
.dropzone {
    border: 2px dashed var(--line);
    border-radius: 12px;
    background: #fff;
    min-height: 110px;
    padding: 14px;
    font-family: inherit;
}
.dropzone .dz-message {
    font-size: 0.95rem;
    color: var(--muted);
    margin: 16px 0;
}
.dropzone .dz-preview .dz-image {
    border-radius: 8px;
}

/* =========================================================
   7. Forms (price toggle, password visibility, select2)
   ========================================================= */
.avg-purchase-hint {
    margin-top: 0.35rem;
    font-size: 0.75rem;
    color: var(--muted);
    line-height: 1.5;
}
.avg-purchase-hint strong {
    color: var(--text);
    font-weight: 700;
}
.toggle-seg {
    border: none;
    background: none;
    padding: 4px 14px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.7rem;
    color: var(--muted);
    cursor: pointer;
    transition: 0.2s;
    min-width: 50px;
    line-height: 1.3;
}
.toggle-seg .toman-unit {
    font-size: inherit;
}
.toggle-seg.active {
    background: var(--brick);
    color: #fff;
}
.toggle-seg:hover:not(.active) {
    color: var(--text);
}

.pwd-wrap {
    position: relative;
}
.pwd-toggle {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    cursor: pointer;
    background: none;
    border: none;
}

/* Select2 + Bootstrap 5 theme — brand-tuned (brick focus, app line color, compact type) */
.select2-container {
    width: 100% !important;
}
.select2-container--bootstrap-5 .select2-selection {
    border-color: var(--line);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    min-height: calc(1.5em + 0.75rem + 2px);
    background-color: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: var(--brick);
    box-shadow: 0 0 0 0.2rem rgba(200, 16, 46, 0.14);
}
.select2-container--bootstrap-5 .select2-dropdown {
    border-color: var(--brick);
    border-radius: 0.5rem;
    box-shadow: 0 8px 24px rgba(31, 36, 48, 0.1);
    overflow: hidden;
}
.select2-container--bootstrap-5 .select2-dropdown .select2-search .select2-search__field {
    border-color: var(--line);
    border-radius: 0.375rem;
    font-size: 0.875rem;
}
.select2-container--bootstrap-5 .select2-dropdown .select2-search .select2-search__field:focus {
    border-color: var(--brick);
    box-shadow: 0 0 0 0.2rem rgba(200, 16, 46, 0.12);
}
.select2-container--bootstrap-5 .select2-dropdown .select2-results__options .select2-results__option {
    font-size: 0.875rem;
    border-radius: 0.35rem;
    margin: 2px 4px;
    padding: 0.4rem 0.65rem;
}
.select2-container--bootstrap-5 .select2-dropdown .select2-results__options .select2-results__option.select2-results__option--highlighted {
    color: var(--text);
    background-color: #f1efea;
}
.select2-container--bootstrap-5 .select2-dropdown .select2-results__options .select2-results__option.select2-results__option--selected,
.select2-container--bootstrap-5 .select2-dropdown .select2-results__options .select2-results__option[aria-selected=true]:not(.select2-results__option--highlighted) {
    color: #fff;
    background-color: var(--brick);
}
.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__rendered .select2-selection__choice {
    border-color: var(--line);
    background: #f8f7f4;
    border-radius: 0.375rem;
    font-size: 0.8rem;
    padding: 0.25em 0.55em;
}
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered,
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered .select2-selection__placeholder {
    font-size: 0.875rem;
}
/* Select2 inside modals — z-index also bumped in app.js when a modal Select2 opens */
.select2-container--open {
    z-index: 1065 !important;
}
.select2-dropdown {
    z-index: 1065 !important;
}

@media (max-width: 767.98px) {
    /* Dropdown is appended to body; keep it on-screen and tappable on small viewports */
    .select2-modal-dropdown {
        position: fixed !important;
        left: 12px !important;
        right: 12px !important;
        width: auto !important;
        max-width: calc(100vw - 24px);
    }
    .select2-modal-dropdown .select2-results > .select2-results__options {
        max-height: min(50vh, 320px);
    }
    .modal.select2-open {
        overflow: visible !important;
    }
    .modal.select2-open .modal-dialog,
    .modal.select2-open .modal-content,
    .modal.select2-open .modal-body {
        overflow: visible !important;
    }
}

/* =========================================================
   8. Page: Login / Initial setup
   ========================================================= */
.auth-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 40px 36px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.06);
}
.auth-card.setup {
    max-width: 440px;
}
.auth-card .form-control {
    height: 46px;
    border-radius: 10px;
    border: 1px solid var(--line);
}
.auth-card .btn-brick,
.auth-card .btn-cost {
    height: 46px;
    font-size: 1rem;
    padding: 0.375rem 0.75rem;
}
.auth-brand-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: var(--brick);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    margin: 0 auto 14px;
}
.auth-brand-icon.cost {
    background: var(--cost);
}
.auth-card h1 {
    font-size: 1.2rem;
    font-weight: 800;
    margin: 0 0 4px;
}
.auth-card p.sub {
    font-size: 0.82rem;
    color: var(--muted);
    margin: 0;
}
.err-box {
    background: #fdecec;
    border: 1px solid #f5c2c2;
    color: var(--brick-dark);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 0.85rem;
    margin-bottom: 16px;
    display: none;
    align-items: center;
    gap: 8px;
}
.err-box.show {
    display: flex;
}
.note-box {
    background: var(--cost-bg);
    color: var(--cost);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 0.8rem;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.foot-note {
    text-align: center;
    margin-top: 22px;
    font-size: 0.78rem;
    color: var(--muted);
}
.btn-cost {
    background: var(--cost);
    border-color: var(--cost);
    font-weight: 700;
    color: #fff;
}
.btn-cost:hover {
    background: #0a5446;
    border-color: #0a5446;
    color: #fff;
}

/* =========================================================
   9. Page: Dashboard
   ========================================================= */
.role-toggle {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 16px;
    margin-bottom: 18px;
    font-size: 0.85rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 20px 22px;
    height: 100%;
    position: relative;
    overflow: hidden;
}
.stat-card .icon-bg {
    position: absolute;
    left: -10px;
    bottom: -10px;
    font-size: 4.5rem;
    opacity: 0.06;
    line-height: 1;
}
.stat-label {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.stat-value {
    font-size: 1.9rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 4px;
}
.stat-sub {
    font-size: 0.78rem;
    color: var(--muted);
}
.stat-card.highlight {
    background: var(--cost-bg);
    border-color: #c3e4de;
}
.stat-card.highlight .stat-value {
    color: var(--cost);
}

.rate-bar {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px 22px;
    margin-bottom: 20px;
}
.rate-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}
.rate-icon.cny {
    background: #fff3e0;
    color: #e65100;
}
.rate-icon.ship {
    background: #e8f5e9;
    color: #2e7d32;
}
.rate-icon.print {
    background: #f3e5f5;
    color: #6a1b9a;
}
.rate-icon.labor {
    background: #e3f2fd;
    color: #1565c0;
}
.rate-label {
    font-size: 0.78rem;
    color: var(--muted);
    margin-bottom: 2px;
}
.rate-value {
    font-size: 1rem;
    font-weight: 800;
}

.section-head h2 {
    font-size: 1rem;
    font-weight: 800;
    margin: 0;
}
.section-head a {
    font-size: 0.82rem;
    color: var(--brick);
    text-decoration: none;
}
.mini-table {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
}
.mini-table table {
    margin: 0;
}
.mini-table thead th {
    font-weight: 700;
    font-size: 0.78rem;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
    padding: 10px 14px;
    white-space: nowrap;
}
.mini-table tbody td {
    padding: 10px 14px;
    vertical-align: middle;
    border-bottom: 1px solid var(--line);
    font-size: 0.85rem;
}
.mini-table tbody tr:last-child td {
    border-bottom: none;
}
.mini-table tbody tr:hover {
    background: #fafaf8;
}
.cost-pill {
    background: var(--cost-bg);
    color: var(--cost);
    font-weight: 800;
    padding: 3px 9px;
    border-radius: 7px;
    font-size: 0.82rem;
    white-space: nowrap;
}

/* =========================================================
   10. Page: Categories & Tags
   ========================================================= */
.nav-tabs .nav-link {
    font-weight: 600;
    color: var(--muted);
    border: none;
    padding: 10px 18px;
}
.nav-tabs .nav-link.active {
    color: var(--brick);
    border-bottom: 2px solid var(--brick);
    background: none;
}
.panel-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 20px;
}

.tree-row {
    padding: 8px 8px;
    border-radius: 8px;
}
.tree-row:hover {
    background: #fafaf8;
}
.tree-toggle {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    cursor: pointer;
    flex-shrink: 0;
    font-size: 0.8rem;
}
.tree-toggle.empty {
    visibility: hidden;
}
.tree-name {
    font-weight: 600;
    font-size: 0.92rem;
}
.tree-count {
    font-size: 0.72rem;
    color: var(--muted);
    background: #f1efea;
    padding: 1px 8px;
    border-radius: 20px;
    margin-right: 6px;
}
.tree-children {
    border-right: 1px dashed var(--line);
    margin-right: 10px;
}
.tree-children.collapsed {
    display: none;
}

/* Select2 dropdown options for hierarchical category pickers (categories-tags.php, parts.php,
   imported-products.php) — indentation + branch marker mimic the tree view above so users can see
   each category's nesting level while picking it. */
.cat-option {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .8rem;
}
.cat-option .bi-tag {
    color: #b8b3a8;
}
.cat-option-branch {
    display: inline-block;
    color: var(--muted);
    font-size: 0.85rem;
    transform: scaleX(-1); /* mirror the corner so it reads correctly in RTL */
}

.tag-table {
    width: 100%;
}
.tag-table th {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 700;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    text-align: right;
}
.tag-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    font-size: 0.9rem;
    vertical-align: middle;
}
.tag-table tr:last-child td {
    border-bottom: none;
}

/* =========================================================
   11. Page: Settings
   ========================================================= */
.settings-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 22px;
    margin-bottom: 18px;
}
.settings-card h2 {
    font-size: 1rem;
    font-weight: 800;
    margin-bottom: 2px;
}
.settings-card .card-sub {
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 18px;
}
.setting-row {
    padding: 14px 0;
    border-top: 1px dashed var(--line);
}
.setting-row:first-of-type {
    border-top: none;
}
.setting-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}
.setting-icon.cny {
    background: #fff3e0;
    color: #e65100;
}
.setting-icon.ship {
    background: #e8f5e9;
    color: #2e7d32;
}
.setting-icon.dep {
    background: #fce4ec;
    color: #ad1457;
}
.setting-icon.print {
    background: #f3e5f5;
    color: #6a1b9a;
}
.setting-icon.labor {
    background: #e3f2fd;
    color: #1565c0;
}
.setting-icon.pack {
    background: #fff8e1;
    color: #f57f17;
}
.setting-label {
    font-weight: 700;
    font-size: 0.92rem;
    margin-bottom: 2px;
}
.setting-hint {
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.5;
}
.setting-input input {
    width: 140px;
    height: 42px;
    text-align: left;
}
.setting-input .unit {
    font-size: 0.82rem;
    color: var(--muted);
    white-space: nowrap;
}
.save-bar {
    position: sticky;
    bottom: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px 20px;
    margin-top: 6px;
}
.save-bar .hint {
    font-size: 0.8rem;
    color: var(--muted);
}

/* =========================================================
   12. Page: Colors
   ========================================================= */
.swatch-lg {
    width: 38px;
    height: 38px;
    border-radius: 9px;
    border: 1px solid rgba(0, 0, 0, 0.12);
}
.color-name {
    font-weight: 700;
}
.meta {
    font-size: 0.78rem;
    color: var(--muted);
}
.picker-row input[type="color"] {
    width: 50px;
    height: 42px;
    padding: 3px;
    border-radius: 8px;
}
.no-color-box {
    width: 50px;
    height: 42px;
    border-radius: 8px;
    border: 1px dashed var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 0.8rem;
}

/* =========================================================
   13. Page: Users
   ========================================================= */
.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #e7e4dd;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.avatar.admin {
    background: var(--brick);
    color: #fff;
}
.role-badge {
    font-size: 0.76rem;
    font-weight: 700;
    padding: 3px 11px;
    border-radius: 20px;
}
.role-badge.admin {
    background: var(--cost-bg);
    color: var(--cost);
}
.role-badge.member {
    background: #f1efea;
    color: var(--muted);
}
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-left: 6px;
}
.status-dot.active {
    background: #2e7d32;
}
.status-dot.inactive {
    background: #b0b0b0;
}
.username-meta {
    font-size: 0.78rem;
    color: var(--muted);
}

/* =========================================================
   14. Page: Product builder
   ========================================================= */
.card-box {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px 20px;
    margin-bottom: 16px;
}

.slot-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px 18px;
    margin-bottom: 14px;
}
.slot-title {
    font-weight: 600;
    font-size: 0.98rem;
}
.slot-count {
    font-size: 0.78rem;
    color: var(--muted);
    background: #f1efea;
    padding: 2px 9px;
    border-radius: 20px;
    margin-right: 8px;
}
.qty-input {
    width: 72px;
}
.qty-stepper {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 4px;
    border-radius: 6px;
    background: #fff;
    border:1px solid #e7e4dd;
    user-select: none;
    margin-left: 20px;
}
.qty-stepper-btn {
    border: none;
    background: transparent;
    color: #888;
    font-size: 1.15rem;
    font-weight: normal;
    line-height: 1;
    padding: 2px 6px;
    cursor: pointer;
    min-width: 1.4rem;
}
.qty-stepper-btn:disabled {
    opacity: 0.35;
    cursor: default;
}
.qty-stepper-val {
    min-width: 1.6rem;
    text-align: center;
    color: #888;
    font-weight: 600;
    font-size: 0.8rem;
}

.slot-item {
    padding: 8px 0;
    border-top: 1px dashed var(--line);
}
.slot-item:first-of-type {
    border-top: none;
}
.item-thumb {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: #efede7;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #b8b3a8;
    font-size: 1.1rem;
    border: 1px solid var(--line);
    flex-shrink: 0;
}
button.item-thumb.part-thumb-btn {
    width: 42px;
    height: 42px;
    aspect-ratio: auto;
    border: 1px solid var(--line);
    padding: 0;
    background: #efede7;
    cursor: pointer;
    border-radius: 8px;
    box-shadow: none;
}
button.item-thumb.part-thumb-btn:hover {
    border-color: var(--brick);
    box-shadow: 0 0 0 2px rgba(196, 92, 38, 0.15);
}
.item-qty {
    width: 55px;
}
.item-name {
    font-weight: 600;
    font-size: 0.8rem;
}
.item-code {
    font-size: 0.74rem;
    color: var(--muted);
}
.item-cost {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--cost);
    white-space: nowrap;
}
.item-remove {
    color: var(--muted);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}
.item-remove:hover {
    color: var(--brick);
}
.empty-slot {
    color: var(--muted);
    font-size: 0.82rem;
    padding: 6px 0;
}

.summary-card {
    position: sticky;
    top: 24px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 20px;
}
.summary-card h2 {
    font-size: 1.05rem;
    font-weight: 800;
    margin-bottom: 14px;
}
.summary-card > .d-flex > h2 {
    margin-bottom: 0;
}
.summary-card > .d-flex {
    margin-bottom: 14px;
}
/* Same label/value convention as .price-row (see above) — .row-label / .row-value mark the two
   sides of each summary row, whether the value side is plain text or an editable input. */
.sum-row {
    padding: 8px 0;
    border-bottom: 1px dashed var(--line);
    font-size: 0.88rem;
}
.sum-row label {
    color: var(--muted);
    margin: 0;
}
.sum-row input {
    width: 110px;
    text-align: left;
    height: 32px;
    font-size: 0.85rem;
}
.sum-row .hint {
    font-size: 0.7rem;
    color: var(--muted);
    display: block;
    margin-top: 2px;
}
.sum-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--cost-bg);
    color: var(--cost);
    border-radius: 10px;
    padding: 10px 16px;
    margin-top: 14px;
    font-weight: 800;
    font-size: .9rem;
}

/* Save / confirm / revert — invoice, waste, production editors.
   Content-sized buttons (one line of label); wrap on narrow screens. */
.editor-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
}
.editor-actions--flush {
    margin-top: 0;
}
.editor-actions > .btn,
.editor-actions > a.btn {
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
    margin: 0;
    white-space: nowrap;
}
/* Standalone page save buttons (product builder, settings) — content-width. */
.editor-save-btn {
    white-space: nowrap;
    width: auto;
}
.editor-actions > .btn-brick {
    order: 1;
}
.editor-actions > .btn-outline-secondary {
    order: 2;
}
.editor-actions > .btn-outline-warning {
    order: 3;
}
.editor-actions > a.btn {
    order: 4;
    text-align: center;
}
/* Print (and similar icon links): pin to the visual left of the actions row. */
.editor-actions > a.editor-actions-print {
    order: 10;
    margin-inline-start: auto;
    padding-inline: 0.5rem;
}
.editor-actions-status {
    width: 100%;
    margin-top: 0.5rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--muted);
}
@media (max-width: 575.98px) {
    .editor-actions > .btn,
    .editor-actions > a.btn {
        flex: 1 1 auto;
        width: 100%;
        order: 0;
    }
    .editor-actions > a.editor-actions-print {
        margin-inline-start: 0;
        width: auto;
        flex: 0 0 auto;
    }
}

/* =========================================================
   15. Page: Products listing (detail breakdown)
   ========================================================= */
.mf-name-btn,
.name-btn,
.part-name-btn {
    background: none;
    border: none;
    padding: 0;
    font-weight: 700;
    color: var(--text);
    text-align: right;
    cursor: pointer;
    text-decoration: none;
}
.mf-name-btn:hover,
.name-btn:hover,
.part-name-btn:hover {
    color: var(--brick);
    text-decoration: underline;
}
.part-row {
    padding: 7px 0;
    border-top: 1px dashed var(--line);
    font-size: 0.85rem;
}
.part-row:first-child {
    border-top: none;
}
.part-thumb {
    width: 68px;
    height: 68px;
    border-radius: 9px;
    background: #efede7;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #b8b3a8;
    flex-shrink: 0;
    font-size: 1.4rem;
}
.slot-label {
    font-size: 0.72rem;
    color: var(--muted);
    background: #f1efea;
    padding: 2px 8px;
    border-radius: 20px;
}
.parts-list-box {
    max-height: 400px;
    overflow-y: auto;
}

/* Built product detail modal — near full-screen, 3-column layout */
.product-detail-dialog {
    max-width: 96vw;
    width: 96vw;
    height: 94vh;
    margin: 3vh auto;
}
.product-detail-dialog .modal-content {
    height: 100%;
    display: flex;
    flex-direction: column;
}
.product-detail-body {
    overflow: hidden;
    min-height: 0;
    flex: 1 1 auto;
}
.product-detail-columns {
    height: 100%;
    min-height: 0;
}
.product-detail-col {
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 18px;
    border-inline-start: 1px solid var(--line);
}
.product-detail-col-image {
    border-inline-start: none;
    background: #fafaf8;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}
.product-detail-hero {
    aspect-ratio: 1;
    overflow: hidden;
    font-size: 2.2rem;
}
.product-detail-hero img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
}
.product-parts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 12px;
}
.product-part-item {
    text-align: center;
}
.part-thumb-btn {
    border: 2px solid transparent;
    padding: 0;
    cursor: pointer;
    width: 100%;
    aspect-ratio: 1;
    position: relative;
    transition: 0.15s;
    border-radius: 9px;
    background: #efede7;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #b8b3a8;
    font-size: 1.4rem;
    overflow: hidden;
}
.part-thumb-btn:hover {
    border-color: var(--brick);
    box-shadow: 0 0 0 2px rgba(196, 92, 38, 0.15);
}
.part-qty-badge {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: rgba(20, 20, 20, 0.72);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    line-height: 1.4;
}
.product-part-item .slot-label {
    display: inline-block;
    margin-top: 6px;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
@media (max-width: 991.98px) {
    .product-detail-dialog {
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        margin: 0;
    }
    .product-detail-columns {
        height: auto;
    }
    .product-detail-col {
        height: auto;
        max-height: none;
        border-inline-start: none;
        border-top: 1px solid var(--line);
    }
    .product-detail-col-image {
        border-top: none;
    }
}

/* =========================================================
   16. Responsive / mobile (desktop layout above is untouched —
   everything in this section only takes effect at narrower widths)
   ========================================================= */
.mobile-topbar {
    display: none;
}
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 20, 0.45);
    z-index: 1044;
}
.sidebar-backdrop.show {
    display: block;
}

@media (max-width: 991.98px) {
    .mobile-topbar {
        display: flex;
        align-items: center;
        gap: 14px;
        background: var(--surface);
        border-bottom: 1px solid var(--line);
        padding: 12px 16px;
        position: sticky;
        top: 0;
        z-index: 1040;
    }
    .mobile-menu-btn {
        background: none;
        border: none;
        font-size: 1.5rem;
        color: var(--text);
        padding: 2px 6px;
        line-height: 1;
    }
    .mobile-topbar-title {
        font-weight: 800;
        font-size: 1.02rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .sidebar {
        position: fixed;
        top: 0;
        right: 0;
        height: 100vh;
        z-index: 1045;
        transform: translateX(100%);
        transition: transform 0.25s ease;
        box-shadow: -8px 0 28px rgba(0, 0, 0, 0.18);
        overflow-y: auto;
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .main-inner {
        padding: 16px;
    }
}

/* =========================================================
   17. Page: Purchase Invoices (invoice editor's Tabulator grid)
   ========================================================= */
.tabulator {
    border: 1px solid var(--line);
    border-radius: 14px;
    font-family: inherit;
    overflow: hidden;
}
.tabulator .tabulator-tableholder {
    overflow-x: hidden;
}
.tabulator-row,
.tabulator-header {
    font-size: 0.88rem;
}
.tabulator .tabulator-header {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.invoice-lines-grid .tabulator-header,
.invoice-lines-grid .tabulator-header .tabulator-col {
    font-size: 0.78rem;
}
.invoice-lines-grid .tabulator-header .tabulator-col .tabulator-col-content {
    padding: 6px 8px;
}
.tabulator-row.tabulator-row-even {
    background: #fafaf8;
}
.tabulator-cell {
    padding: 8px 10px !important;
}
.grid-thumb {
    width: 38px;
    height: 38px;
    border-radius: 7px;
    object-fit: cover;
    background: #efede7;
    border: 1px solid var(--line);
}
.line-item-name {
    font-weight: 600;
    font-size: 0.86rem;
}
.inv-row-actions .btn {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.inv-row-actions .bi::before {
    padding-top: 0;
}
.line-item-code {
    font-size: 0.72rem;
    color: var(--muted);
}
.line-item-sku {
    font-size: 0.8rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}
.cell-sub {
    font-size: 0.72rem;
    color: var(--muted);
    white-space: nowrap;
}
.inv-qty-less {
    color: var(--brick, #c8102e);
    font-weight: 700;
}
.inv-qty-more {
    color: #1a6fb5;
    font-weight: 700;
}
.role-cap-matrix .role-cap-module .card-header {
    background: var(--surface, #faf9f7);
}
.role-cap-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px 16px;
}
.role-cap-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 0.9rem;
    cursor: pointer;
}
.drag-handle {
    cursor: grab;
    color: var(--muted);
    font-size: 1rem;
}
.drag-handle:active {
    cursor: grabbing;
}
/* Tabulator's footer puts the pagination buttons first and the row counter last, which renders
   the counter at the far right — flip the order so the counter sits at the far left instead. */
.tabulator .tabulator-footer-contents {
    flex-direction: row-reverse;
}
.tabulator .tabulator-footer-contents > * + .tabulator-page-counter {
    margin-left: 0;
    margin-right: 10px;
}

@media (max-width: 767.98px) {
    /* Row/col-md-* grids inside modals already stack below this width via Bootstrap; the rest of
     this block handles the custom (non-grid) pieces that don't stack on their own. */
    .page-head {
        flex-wrap: wrap;
        gap: 10px;
    }
    .page-head h1 {
        font-size: 1.25rem;
    }
    .page-head-back {
        font-size: 1.25rem;
        width: auto;
    }
    .page-head > *:not(h1):not(.page-head-back):not(.badge) {
        width: 100%;
    }
    .page-head .btn {
        flex: 1;
    }

    .pager-bar {
        flex-wrap: wrap;
        gap: 10px;
    }
    .pager-bar > div {
        width: 100%;
        justify-content: space-between;
    }

    .card-table,
    .mini-table,
    .panel-card {
        overflow-x: auto;
    }
    .card-table table,
    .mini-table table {
        min-width: 640px;
    }

    .setting-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .setting-row > div {
        width: 100%;
        max-width: 100%;
    }
    .setting-input {
        justify-content: flex-start;
    }
    .setting-input input {
        width: 100%;
    }

    .rate-bar .col-auto {
        width: 100%;
    }

    .summary-card {
        position: static;
    }
}

/* Page: product pricing grid */
.pricing-grid-wrap {
    padding: 0;
    overflow: hidden;
}
.pricing-grid-wrap .tabulator {
    border: none;
    background: transparent;
    font-size: .88rem;
}
.pricing-grid-wrap .tabulator-header {
    background: #fafaf8;
    border-bottom: 1px solid var(--line);
}
.pricing-grid-wrap .tabulator-row {
    min-height: 58px;
}
.pricing-grid-wrap .tabulator-row .tabulator-row-handle {
    cursor: grab;
    color: var(--muted);
}
.pricing-grid-wrap .tabulator-row .tabulator-row-handle:active {
    cursor: grabbing;
}
.pricing-thumb-empty {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: #efede7;
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #b8b3a8;
}
.pricing-product-link {
    font-weight: 700;
    color: inherit;
    text-decoration: none;
}
.pricing-product-link:hover {
    color: var(--brick);
}
.pricing-product-code {
    font-size: .75rem;
    color: var(--muted);
    margin-top: 2px;
}
.pricing-markup-cell {
    line-height: 1.35;
}
#pricingGrid .final-cost{
    font-size: .8rem;
}
.pricing-markup-sell {
    font-weight: 600;
    font-size: .85rem;
}
#pricingGrid .pricing-markup-sell .toman-unit{
    font-size: .6rem;
}
.pricing-markup-meta {
    font-size: .72rem;
    color: var(--muted);
    margin-top: 2px;
}
.pricing-columns-menu {
    min-width: 220px;
    max-height: 320px;
    overflow-y: auto;
}
.pricing-col-toggle {
    display: flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
    user-select: none;
}
.pricing-col-toggle .form-check-input {
    flex-shrink: 0;
}

/* Parts list: data-quality filters + row warnings */
.parts-quality-bar {
    gap: .5rem;
}
.parts-quality-chip {
    font-size: .78rem;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}
.parts-quality-chip.active {
    background: #fff4ef;
    border-color: var(--brick);
    color: var(--brick-dark);
}
.parts-quality-count {
    background: #eceae4;
    color: #5c574d;
    font-size: .68rem;
    font-weight: 700;
    min-width: 1.35rem;
}
.parts-quality-chip.active .parts-quality-count {
    background: var(--brick);
    color: #fff;
}
.part-row-data-issue {
    background: #fffdf8;
}
.part-thumb-wrap {
    position: relative;
    display: inline-block;
}
.part-thumb-wrap.part-thumb-missing .thumb,
.part-thumb-wrap.part-thumb-missing img {
    outline: 2px dashed #d4a574;
    outline-offset: 1px;
}
.part-data-flag {
    font-size: .68rem;
    line-height: 1.2;
    color: #b45309;
    font-weight: 600;
}
.part-data-flag-image {
    position: absolute;
    left: -4px;
    top: -4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid #d4a574;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.part-data-flag-conversion {
    margin-top: 4px;
}

.pricing-toolbar-actions .pricing-tool-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.pricing-toolbar-actions .pricing-tool-btn .bi {
    line-height: 1;
}
.pricing-toolbar-actions .pricing-tool-btn .bi::before,
.pricing-rate-group .bi::before {
    padding-top: 0;
}
.pricing-rate-group .input-group-text {
    background: var(--surface);
    color: var(--muted);
}
.pricing-rate-group #btnSaveRate {
    min-width: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.pricing-rate-group #btnSaveRate .spinner-border {
    width: 0.9rem;
    height: 0.9rem;
    border-width: 0.15em;
}
