/* ------------------------------------------------------------------
 *  Конструктор печати: модальное окно, шаги, выбор оснастки и дизайна
 * ------------------------------------------------------------------ */

.cfg-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.28s ease;
    z-index: 210;
}
.cfg-overlay.show { opacity: 1; }

.cfg-modal {
    position: fixed;
    z-index: 211;
    top: 50%;
    left: 50%;
    width: min(880px, calc(100vw - 40px));
    max-height: min(860px, calc(100dvh - 40px));
    transform: translate(-50%, -46%) scale(0.98);
    opacity: 0;
    background: #fff;
    border-radius: 28px;
    box-shadow: 0 30px 70px rgba(15, 23, 42, 0.28);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
.cfg-modal.open { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.cfg-modal[hidden] { display: none; }

.cfg-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 26px 16px;
    flex-shrink: 0;
}
.cfg-head h2 { font-size: 1.35rem; font-weight: 800; color: #0f172a; }
.cfg-steps { font-size: 0.85rem; color: #64748b; margin-top: 4px; }

.cfg-progress { height: 3px; background: #eef2ff; flex-shrink: 0; }
.cfg-progress span {
    display: block;
    height: 100%;
    background: #2563eb;
    border-radius: 0 3px 3px 0;
    transition: width 0.3s ease;
}

.cfg-body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 22px 26px 26px;
}

.cfg-step-title { font-size: 1.1rem; font-weight: 800; color: #0f172a; margin-bottom: 6px; }
.cfg-step-hint { font-size: 0.9rem; color: #64748b; margin-bottom: 18px; line-height: 1.5; }

.cfg-warn {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    font-size: 0.88rem;
    padding: 10px 14px;
    border-radius: 14px;
    margin-bottom: 16px;
}

/* ── карточки-варианты (оснастки, «свой макет») ── */
.cfg-options { display: grid; gap: 12px; }
.cfg-options-inline { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin-bottom: 18px; }

.cfg-opt {
    display: grid;
    grid-template-columns: 74px 1fr 26px;
    gap: 14px;
    align-items: center;
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 18px;
    background: #fff;
    font: inherit;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.cfg-opt:hover { border-color: #93b4fb; }
.cfg-opt.selected {
    border-color: #2563eb;
    background: #f5f9ff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.cfg-opt-media {
    width: 74px;
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    border-radius: 12px;
    overflow: hidden;
}
.cfg-opt-media img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.cfg-opt-icon { color: #2563eb; font-size: 1.4rem; }
.cfg-opt-plain .cfg-opt-media { background: #eff6ff; }
.cfg-opt-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cfg-opt-text b { font-size: 1rem; color: #0f172a; }
.cfg-opt-text small { font-size: 0.82rem; color: #64748b; line-height: 1.4; }
.cfg-opt-price { font-size: 0.9rem; font-weight: 700; color: #1d4ed8; margin-top: 2px; }
.cfg-opt-check {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1.5px solid #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    font-size: 0.75rem;
    transition: 0.2s;
}
.cfg-opt.selected .cfg-opt-check { background: #2563eb; border-color: #2563eb; color: #fff; }

/* ── поиск и плитки дизайнов ── */
.cfg-search { position: relative; margin-bottom: 14px; }
.cfg-search i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 0.85rem;
}
.cfg-search input {
    width: 100%;
    padding: 10px 14px 10px 38px;
    border: 1px solid #e2e8f0;
    border-radius: 40px;
    font: inherit;
    font-size: 0.92rem;
    background: #fff;
}
.cfg-search input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.cfg-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
}
.cfg-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 8px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 16px;
    background: #fff;
    font: inherit;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}
.cfg-tile:hover { border-color: #93b4fb; transform: translateY(-2px); }
.cfg-tile.selected {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
    background: #f5f9ff;
}
.cfg-tile img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.cfg-tile-name { font-size: 0.82rem; font-weight: 700; color: #0f172a; }
.cfg-tile-price { font-size: 0.75rem; color: #64748b; }
.cfg-empty { text-align: center; color: #64748b; padding: 28px 10px; }

/* ── шаг с данными оттиска ── */
.cfg-preview {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    background: #f8fafc;
    border-radius: 18px;
    margin-bottom: 18px;
}
.cfg-preview img { width: 96px; height: 96px; object-fit: contain; flex-shrink: 0; }
.cfg-preview-side { min-width: 0; }
.cfg-preview-title { font-weight: 700; color: #0f172a; font-size: 0.95rem; margin-bottom: 6px; }
.cfg-preview-note { font-size: 0.8rem; color: #64748b; line-height: 1.45; }

.cfg-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.cfg-fields .form-group { margin: 0; }
.cfg-fields input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    font: inherit;
    font-size: 0.95rem;
    color: #0f172a;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.cfg-fields input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* ── логотип организации ── */
.cfg-logo { margin-top: 16px; }
.cfg-logo .file-upload-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border: 1px dashed #cbd5e1;
    border-radius: 14px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #475569;
    transition: 0.2s;
}
.cfg-logo .file-upload-label:hover { border-color: #2563eb; color: #2563eb; }
.cfg-logo .file-upload-label.has-file {
    border-style: solid;
    border-color: #16a34a;
    color: #15803d;
    background: #f0fdf4;
}
.cfg-logo-del {
    margin-top: 8px;
    background: none;
    border: none;
    color: #94a3b8;
    font: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 2px 0;
}
.cfg-logo-del:hover { color: #dc2626; }
.cfg-logo-hint { font-size: 0.78rem; color: #94a3b8; margin-top: 8px; line-height: 1.45; }
.cfg-logo-err {
    font-size: 0.82rem;
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 12px;
    padding: 8px 12px;
    margin-top: 8px;
    line-height: 1.4;
}

/* ── логотип в корзине ── */
.cart-group-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 4px 10px;
    font-size: 0.78rem;
    color: #475569;
}
.cart-group-logo img {
    width: 34px;
    height: 34px;
    object-fit: contain;
    border-radius: 8px;
    background: #fff;
    border: 1px solid #e2e8f0;
}
.cart-group-logo i { color: #94a3b8; font-size: 1.1rem; width: 34px; text-align: center; }

/* ── допродажа расходников ── */
.cfg-cross { margin-top: 26px; border-top: 1px dashed #e2e8f0; padding-top: 20px; }
.cfg-cross h4 { font-size: 1rem; font-weight: 800; color: #0f172a; margin-bottom: 12px; }
.cfg-cross-item {
    display: grid;
    grid-template-columns: 22px 52px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: 0.2s;
}
.cfg-cross-item:hover { border-color: #93b4fb; }
.cfg-cross-item.checked { border-color: #2563eb; background: #f5f9ff; }
.cfg-cross-item input { width: 18px; height: 18px; accent-color: #2563eb; cursor: pointer; }
.cfg-cross-item img { width: 52px; height: 44px; object-fit: contain; background: #f8fafc; border-radius: 10px; }
.cfg-cross-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cfg-cross-text b { font-size: 0.92rem; color: #0f172a; }
.cfg-cross-text small { font-size: 0.78rem; color: #64748b; }
.cfg-cross-price { font-size: 0.85rem; font-weight: 700; color: #1d4ed8; white-space: nowrap; }

/* ── низ окна ── */
.cfg-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
    padding: 16px 26px 20px;
    border-top: 1px solid #eef2ff;
    background: #fff;
    flex-shrink: 0;
}
.cfg-summary { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; min-width: 0; }
.cfg-summary-parts { display: flex; flex-direction: column; gap: 2px; font-size: 0.82rem; color: #475569; }
.cfg-summary-parts i { color: #94a3b8; }
.cfg-summary-price { font-size: 1.3rem; font-weight: 800; color: #0f172a; white-space: nowrap; }

.cfg-actions { display: flex; gap: 10px; align-items: center; margin-left: auto; }
.cfg-back {
    padding: 12px 22px;
    border: 1.5px solid #cbd5e1;
    border-radius: 40px;
    background: #fff;
    color: #334155;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}
.cfg-back:hover { border-color: #2563eb; color: #2563eb; }
.cfg-next {
    padding: 12px 30px;
    border: none;
    border-radius: 40px;
    background: #2563eb;
    color: #fff;
    font: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
}
.cfg-next:hover { background: #1d4ed8; box-shadow: 0 10px 22px rgba(37, 99, 235, 0.28); }
.cfg-next.is-final { background: #16a34a; }
.cfg-next.is-final:hover { background: #15803d; box-shadow: 0 10px 22px rgba(22, 163, 74, 0.28); }

/* ── комплект в корзине: две позиции, связанные группой ── */
.cart-group {
    border: 1.5px solid #dbe7fe;
    border-radius: 20px;
    background: #f8fbff;
    padding: 12px;
}
.cart-group-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 10px;
    padding: 0 4px 10px;
}
.cart-group-title {
    font-size: 0.9rem;
    font-weight: 800;
    color: #1d4ed8;
    display: inline-flex;
    align-items: center;
    gap: 7px;
}
.cart-group-meta { font-size: 0.78rem; color: #64748b; min-width: 0; word-break: break-word; }
.cart-group-items { list-style: none; display: grid; gap: 8px; }
.cart-group-items .cart-item { border-color: #e4edfd; }
.cart-group-note { font-size: 0.72rem; color: #94a3b8; padding: 8px 4px 0; line-height: 1.4; }

/* ── состав комплекта внутри строки (старые заказы) ── */
.cart-item-parts, .cart-item-meta { list-style: none; margin: 0 0 8px; font-size: 0.78rem; }
.cart-item-parts li {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: #64748b;
    padding: 1px 0;
}
.cart-item-parts li span { white-space: nowrap; }
.cart-item-meta li { color: #475569; padding: 1px 0; }
.cart-item-meta b { color: #334155; font-weight: 600; }

@media (max-width: 700px) {
    .cfg-modal {
        top: 0; left: 0;
        transform: translateY(3%);
        width: 100vw;
        max-height: 100dvh;
        height: 100dvh;
        border-radius: 0;
    }
    .cfg-modal.open { transform: translateY(0); }
    .cfg-head { padding: 16px 18px 12px; }
    .cfg-head h2 { font-size: 1.15rem; }
    .cfg-body { padding: 18px; }
    .cfg-preview { padding: 12px 14px; gap: 12px; }
    .cfg-preview img { width: 72px; height: 72px; }
    .cfg-opt { grid-template-columns: 58px 1fr 24px; gap: 10px; }
    .cfg-opt-media { width: 58px; height: 52px; }
    .cfg-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
    .cfg-foot { padding: 12px 18px 16px; gap: 10px; }
    .cfg-summary { width: 100%; justify-content: space-between; }
    .cfg-actions { width: 100%; }
    .cfg-next { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .cfg-modal, .cfg-overlay, .cfg-progress span, .cfg-tile { transition: none; }
}

/* ── выбор цвета оснастки в конструкторе ── */
.cfg-colors {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: -4px 0 4px;
    padding: 12px 14px;
    background: #f5f9ff;
    border: 1.5px solid #dbe7fe;
    border-top: none;
    border-radius: 0 0 18px 18px;
}
.cfg-colors-label { font-size: 0.85rem; color: #475569; }
.cfg-colors-name { font-size: 0.9rem; color: #1d4ed8; }

.cfg-step-note {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    color: #15803d;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 12px;
    padding: 9px 14px;
    margin-bottom: 14px;
}

/* ── что уже выбрано (шаг 3) ── */
.cfg-chosen {
    background: #f8fafc;
    border-radius: 18px;
    padding: 14px 16px;
    margin-bottom: 18px;
}
.cfg-chosen-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}
.cfg-chosen-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 10px 12px;
    min-width: 0;
}
.cfg-chosen-item img,
.cfg-chosen-ico {
    width: 62px;
    height: 62px;
    flex-shrink: 0;
    object-fit: contain;
    background: #f8fafc;
    border-radius: 10px;
}
.cfg-chosen-ico {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #2563eb;
    font-size: 1.2rem;
}
.cfg-chosen-item div { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cfg-chosen-item small { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; color: #94a3b8; }
.cfg-chosen-item b { font-size: 0.92rem; color: #0f172a; line-height: 1.3; }
.cfg-chosen-price { font-size: 0.82rem; color: #1d4ed8; font-weight: 600; }
.cfg-chosen .cfg-preview-note { margin-top: 10px; }
