<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:base="https://www.pandoraburo.ru/" xml:lang="ru">
  <id>https://www.pandoraburo.ru/zavodskoy-kalkulyator-dlya-rascheta-tceny-metalloproduktcii</id>
  <link href="https://www.pandoraburo.ru/zavodskoy-kalkulyator-dlya-rascheta-tceny-metalloproduktcii.xml" rel="self"/>
  <title>Заводской калькулятор для расчета цены металлопродукции</title>
  <subtitle type="html">
&lt;html lang="ru"&gt;
&lt;head&gt;
    &lt;meta charset="UTF-8"&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
    &lt;title&gt;СРМ Пандорра — Калькулятор ценообразования&lt;/title&gt;
    &lt;style&gt;
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
            padding: 20px;
        }

        .container {
            max-width: 1400px;
            margin: 0 auto;
            background: white;
            border-radius: 20px;
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
            overflow: hidden;
        }

        .header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 30px 40px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .logo {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .logo-icon {
            width: 50px;
            height: 50px;
            background: rgba(255, 255, 255, 0.2);
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 28px;
        }

        .logo-text h1 {
            font-size: 24px;
            font-weight: 700;
            margin-bottom: 4px;
        }

        .logo-text p {
            font-size: 13px;
            opacity: 0.9;
        }

        .header-actions {
            display: flex;
            gap: 12px;
        }

        .btn-icon {
            width: 42px;
            height: 42px;
            border-radius: 10px;
            background: rgba(255, 255, 255, 0.2);
            border: none;
            color: white;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
            transition: all 0.2s;
        }

        .btn-icon:hover {
            background: rgba(255, 255, 255, 0.3);
            transform: translateY(-2px);
        }

        .content {
            display: grid;
            grid-template-columns: 1fr 420px;
            gap: 0;
            min-height: 700px;
        }

        @media (max-width: 1100px) {
            .content {
                grid-template-columns: 1fr;
            }
        }

        .inputs-section {
            padding: 30px 40px;
            overflow-y: auto;
            max-height: calc(100vh - 120px);
        }

        .section-title {
            font-size: 18px;
            font-weight: 700;
            color: #2c3e50;
            margin-bottom: 20px;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .section-title::before {
            content: '';
            width: 4px;
            height: 20px;
            background: #667eea;
            border-radius: 2px;
        }

        .preset-buttons {
            display: flex;
            gap: 10px;
            margin-bottom: 24px;
            flex-wrap: wrap;
        }

        .preset-btn {
            padding: 8px 16px;
            background: #f8f9fa;
            border: 2px solid #e9ecef;
            border-radius: 10px;
            font-size: 13px;
            font-weight: 600;
            color: #495057;
            cursor: pointer;
            transition: all 0.2s;
        }

        .preset-btn:hover {
            border-color: #667eea;
            background: #f0f4ff;
            transform: translateY(-2px);
        }

        .preset-btn.active {
            background: #667eea;
            color: white;
            border-color: #667eea;
        }

        .panel {
            background: #f8f9fa;
            border-radius: 16px;
            padding: 24px;
            margin-bottom: 20px;
            border: 1px solid #e9ecef;
        }

        .panel-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 18px;
        }

        .panel-title {
            font-size: 16px;
            font-weight: 700;
            color: #2c3e50;
        }

        .panel-badge {
            font-size: 11px;
            padding: 4px 10px;
            background: #e8f5e9;
            color: #2e7d32;
            border-radius: 12px;
            font-weight: 600;
        }

        .input-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 16px;
        }

        .input-group {
            display: flex;
            flex-direction: column;
        }

        .input-group label {
            font-size: 12px;
            font-weight: 600;
            color: #6c757d;
            margin-bottom: 6px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .input-group input,
        .input-group select {
            padding: 10px 14px;
            border: 2px solid #dee2e6;
            border-radius: 10px;
            font-size: 14px;
            transition: all 0.2s;
            background: white;
        }

        .input-group input:focus,
        .input-group select:focus {
            outline: none;
            border-color: #667eea;
            box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
        }

        .input-hint {
            font-size: 11px;
            color: #adb5bd;
            margin-top: 4px;
        }

        .vim-bar {
            margin-top: 16px;
            background: #e9ecef;
            height: 8px;
            border-radius: 4px;
            overflow: hidden;
            position: relative;
        }

        .vim-fill {
            height: 100%;
            background: linear-gradient(90deg, #667eea, #764ba2);
            transition: width 0.4s;
            border-radius: 4px;
        }

        .vim-label {
            display: flex;
            justify-content: space-between;
            font-size: 12px;
            color: #6c757d;
            margin-top: 6px;
        }

        .dynamic-rows {
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        .dynamic-row {
            display: grid;
            grid-template-columns: 2fr 1fr 1fr 40px;
            gap: 10px;
            align-items: center;
            padding: 12px;
            background: white;
            border-radius: 10px;
            border: 1px solid #e9ecef;
        }

        .dynamic-row input,
        .dynamic-row select {
            padding: 8px 12px;
            border: 1px solid #dee2e6;
            border-radius: 8px;
            font-size: 13px;
        }

        .btn-remove {
            width: 36px;
            height: 36px;
            border-radius: 8px;
            background: #ffebee;
            border: none;
            color: #c62828;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 18px;
            transition: all 0.2s;
        }

        .btn-remove:hover {
            background: #c62828;
            color: white;
        }

        .btn-add {
            width: 100%;
            padding: 12px;
            background: #f8f9fa;
            border: 2px dashed #dee2e6;
            border-radius: 10px;
            color: #6c757d;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
            margin-top: 12px;
        }

        .btn-add:hover {
            border-color: #667eea;
            color: #667eea;
            background: #f0f4ff;
        }

        /* Правая колонка — результаты */
        .results-section {
            background: #f8f9fa;
            padding: 30px;
            border-left: 1px solid #e9ecef;
            overflow-y: auto;
            max-height: calc(100vh - 120px);
        }

        .result-card {
            background: white;
            border-radius: 16px;
            padding: 24px;
            margin-bottom: 20px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
        }

        .price-main {
            text-align: center;
            padding: 20px 0;
        }

        .price-label {
            font-size: 13px;
            color: #6c757d;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            margin-bottom: 8px;
        }

        .price-value {
            font-size: 48px;
            font-weight: 800;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            margin-bottom: 8px;
        }

        .price-currency {
            font-size: 18px;
            color: #6c757d;
            font-weight: 600;
        }

        .margin-badge {
            display: inline-block;
            padding: 8px 20px;
            border-radius: 20px;
            font-weight: 700;
            font-size: 14px;
            margin-top: 12px;
        }

        .margin-badge.high {
            background: #e8f5e9;
            color: #2e7d32;
        }

        .margin-badge.good {
            background: #fff3e0;
            color: #e65100;
        }

        .margin-badge.low {
            background: #fff8e1;
            color: #f57f17;
        }

        .margin-badge.danger {
            background: #ffebee;
            color: #c62828;
        }

        .breakdown-item {
            display: flex;
            justify-content: space-between;
            padding: 12px 0;
            border-bottom: 1px solid #f1f3f5;
            font-size: 14px;
        }

        .breakdown-item:last-child {
            border-bottom: none;
        }

        .breakdown-item .name {
            color: #495057;
        }

        .breakdown-item .cost {
            font-weight: 700;
            color: #2c3e50;
        }

        .breakdown-item.highlight .cost {
            color: #e67e22;
        }

        .total-row {
            display: flex;
            justify-content: space-between;
            padding: 16px 0 8px 0;
            border-top: 2px solid #dee2e6;
            margin-top: 8px;
            font-weight: 700;
            font-size: 18px;
        }

        .gauge-container {
            text-align: center;
            padding: 20px 0;
        }

        .gauge-svg {
            width: 180px;
            height: 100px;
        }

        .gauge-value {
            font-size: 32px;
            font-weight: 800;
            color: #667eea;
            margin-top: 8px;
        }

        .gauge-label {
            font-size: 12px;
            color: #6c757d;
            margin-top: 4px;
        }

        .batch-stats {
            display: grid;
            grid-template-columns: 1fr 1fr 1fr;
            gap: 12px;
            margin-top: 16px;
        }

        .stat-box {
            background: #f8f9fa;
            padding: 16px;
            border-radius: 12px;
            text-align: center;
        }

        .stat-label {
            font-size: 11px;
            color: #6c757d;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            margin-bottom: 6px;
        }

        .stat-value {
            font-size: 18px;
            font-weight: 700;
            color: #2c3e50;
        }

        .stat-value.profit {
            color: #2e7d32;
        }

        .actions {
            display: flex;
            gap: 12px;
            margin-top: 20px;
        }

        .btn-action {
            flex: 1;
            padding: 14px;
            border-radius: 12px;
            font-weight: 700;
            font-size: 14px;
            cursor: pointer;
            border: none;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
        }

        .btn-primary {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
        }

        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
        }

        .btn-secondary {
            background: white;
            color: #6c757d;
            border: 2px solid #dee2e6;
        }

        .btn-secondary:hover {
            border-color: #667eea;
            color: #667eea;
        }

        /* Модальное окно истории */
        .history-modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.5);
            z-index: 1000;
            align-items: center;
            justify-content: center;
        }

        .history-modal.active {
            display: flex;
        }

        .history-content {
            background: white;
            border-radius: 20px;
            max-width: 800px;
            width: 90%;
            max-height: 80vh;
            overflow-y: auto;
            padding: 30px;
        }

        .history-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }

        .history-item {
            padding: 16px;
            background: #f8f9fa;
            border-radius: 12px;
            margin-bottom: 12px;
            cursor: pointer;
            transition: all 0.2s;
        }

        .history-item:hover {
            background: #f0f4ff;
            transform: translateX(4px);
        }

        .history-date {
            font-size: 12px;
            color: #6c757d;
            margin-bottom: 6px;
        }

        .history-info {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .history-name {
            font-weight: 700;
            color: #2c3e50;
        }

        .history-price {
            font-size: 18px;
            font-weight: 700;
            color: #667eea;
        }

        @media print {
            body {
                background: white;
                padding: 0;
            }
            .header, .inputs-section, .actions, .preset-buttons {
                display: none !important;
            }
            .container {
                box-shadow: none;
                border-radius: 0;
            }
            .content {
                grid-template-columns: 1fr;
            }
            .results-section {
                border-left: none;
                max-height: none;
            }
        }

        @media (max-width: 768px) {
            .header {
                padding: 20px;
                flex-direction: column;
                gap: 16px;
            }
            .inputs-section, .results-section {
                padding: 20px;
                max-height: none;
            }
            .batch-stats {
                grid-template-columns: 1fr;
            }
        }
    &lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;div class="container"&gt;
        &lt;div class="header"&gt;
            &lt;div class="logo"&gt;
                &lt;div class="logo-icon"&gt;?&lt;/div&gt;
                &lt;div class="logo-text"&gt;
                    &lt;h1&gt;СРМ Пандорра&lt;/h1&gt;
                    &lt;p&gt;Калькулятор ценообразования машиностроительного завода&lt;/p&gt;
                &lt;/div&gt;
            &lt;/div&gt;
            &lt;div class="header-actions"&gt;
                &lt;button class="btn-icon" onclick="showHistory()" title="История расчётов"&gt;?&lt;/button&gt;
                &lt;button class="btn-icon" onclick="window.print()" title="Печать/PDF"&gt;?️&lt;/button&gt;
                &lt;button class="btn-icon" onclick="resetCalculator()" title="Сброс"&gt;?&lt;/button&gt;
            &lt;/div&gt;
        &lt;/div&gt;

        &lt;div class="content"&gt;
            &lt;div class="inputs-section"&gt;
                &lt;h2 class="section-title"&gt;Быстрый старт&lt;/h2&gt;
                &lt;div class="preset-buttons"&gt;
                    &lt;button class="preset-btn" data-preset="flange"&gt;Фланец Ду100&lt;/button&gt;
                    &lt;button class="preset-btn" data-preset="shaft"&gt;Вал-шестерня&lt;/button&gt;
                    &lt;button class="preset-btn" data-preset="housing"&gt;Корпус редуктора&lt;/button&gt;
                    &lt;button class="preset-btn" data-preset="bracket"&gt;Кронштейн&lt;/button&gt;
                &lt;/div&gt;

                &lt;div class="panel"&gt;
                    &lt;div class="panel-header"&gt;
                        &lt;div class="panel-title"&gt;? Параметры изделия&lt;/div&gt;
                        &lt;span class="panel-badge"&gt;Обязательно&lt;/span&gt;
                    &lt;/div&gt;
                    &lt;div class="input-grid"&gt;
                        &lt;div class="input-group" style="grid-column: span 2;"&gt;
                            &lt;label&gt;Наименование&lt;/label&gt;
                            &lt;input type="text" id="pName" value="Фланец стальной Ду100" /&gt;
                        &lt;/div&gt;
                        &lt;div class="input-group"&gt;
                            &lt;label&gt;№ чертежа / ТУ&lt;/label&gt;
                            &lt;input type="text" id="pDraw" value="ПРГ.301124.017" /&gt;
                        &lt;/div&gt;
                        &lt;div class="input-group"&gt;
                            &lt;label&gt;Объём партии (шт)&lt;/label&gt;
                            &lt;input type="number" id="qtyNum" min="1" value="120" step="10" /&gt;
                            &lt;div class="input-hint"&gt;Скидки: 50+ шт = -2%, 200+ = -4%, 500+ = -7%&lt;/div&gt;
                        &lt;/div&gt;
                    &lt;/div&gt;
                &lt;/div&gt;

                &lt;div class="panel"&gt;
                    &lt;div class="panel-header"&gt;
                        &lt;div class="panel-title"&gt;? Материал&lt;/div&gt;
                        &lt;span class="panel-badge"&gt;ВИМ: &lt;span id="vimPct"&gt;0&lt;/span&gt;%&lt;/span&gt;
                    &lt;/div&gt;
                    &lt;div class="input-grid"&gt;
                        &lt;div class="input-group" style="grid-column: span 2;"&gt;
                            &lt;label&gt;Марка материала&lt;/label&gt;
                            &lt;select id="matSel"&gt;&lt;/select&gt;
                        &lt;/div&gt;
                        &lt;div class="input-group"&gt;
                            &lt;label&gt;Цена (₽/кг)&lt;/label&gt;
                            &lt;input type="number" id="matPrice" min="0" step="1" value="92" /&gt;
                        &lt;/div&gt;
                        &lt;div class="input-group"&gt;
                            &lt;label&gt;Масса заготовки (кг)&lt;/label&gt;
                            &lt;input type="number" id="matGross" min="0" step="0.1" value="4.2" /&gt;
                        &lt;/div&gt;
                        &lt;div class="input-group"&gt;
                            &lt;label&gt;Масса чистая (кг)&lt;/label&gt;
                            &lt;input type="number" id="matNet" min="0" step="0.1" value="2.9" /&gt;
                        &lt;/div&gt;
                        &lt;div class="input-group"&gt;
                            &lt;label&gt;ТЗР (%)&lt;/label&gt;
                            &lt;input type="number" id="tzr" min="0" step="0.5" value="4" /&gt;
                        &lt;/div&gt;
                    &lt;/div&gt;
                    &lt;div class="vim-bar"&gt;
                        &lt;div class="vim-fill" id="vimBar" style="width: 0%"&gt;&lt;/div&gt;
                    &lt;/div&gt;
                    &lt;div class="vim-label"&gt;
                        &lt;span&gt;Отходы: &lt;strong id="scrapKg"&gt;0&lt;/strong&gt; кг&lt;/span&gt;
                        &lt;span id="vimGrade"&gt;&lt;/span&gt;
                    &lt;/div&gt;
                &lt;/div&gt;

                &lt;div class="panel"&gt;
                    &lt;div class="panel-header"&gt;
                        &lt;div class="panel-title"&gt;? Покупные комплектующие&lt;/div&gt;
                    &lt;/div&gt;
                    &lt;div class="dynamic-rows" id="compRows"&gt;&lt;/div&gt;
                    &lt;button class="btn-add" onclick="addComponent()"&gt;+ Добавить комплектующее&lt;/button&gt;
                &lt;/div&gt;

                &lt;div class="panel"&gt;
                    &lt;div class="panel-header"&gt;
                        &lt;div class="panel-title"&gt;⚙️ Трудозатраты по операциям&lt;/div&gt;
                        &lt;span class="panel-badge"&gt;Σ: &lt;span id="sumHours"&gt;0&lt;/span&gt; н-ч&lt;/span&gt;
                    &lt;/div&gt;
                    &lt;div class="dynamic-rows" id="opRows"&gt;&lt;/div&gt;
                    &lt;button class="btn-add" onclick="addOperation()"&gt;+ Добавить операцию&lt;/button&gt;
                &lt;/div&gt;

                &lt;div class="panel"&gt;
                    &lt;div class="panel-header"&gt;
                        &lt;div class="panel-title"&gt;⚡ Производственные расходы&lt;/div&gt;
                    &lt;/div&gt;
                    &lt;div class="input-grid"&gt;
                        &lt;div class="input-group"&gt;
                            &lt;label&gt;Электроэнергия (кВт·ч/шт)&lt;/label&gt;
                            &lt;input type="number" id="kwh" min="0" step="0.1" value="3.6" /&gt;
                        &lt;/div&gt;
                        &lt;div class="input-group"&gt;
                            &lt;label&gt;Тариф (₽/кВт·ч)&lt;/label&gt;
                            &lt;input type="number" id="kwhRate" min="0" step="0.1" value="8.9" /&gt;
                        &lt;/div&gt;
                        &lt;div class="input-group"&gt;
                            &lt;label&gt;Амортизация (₽/шт)&lt;/label&gt;
                            &lt;input type="number" id="depr" min="0" step="1" value="85" /&gt;
                        &lt;/div&gt;
                        &lt;div class="input-group"&gt;
                            &lt;label&gt;Инструмент (₽/шт)&lt;/label&gt;
                            &lt;input type="number" id="tool" min="0" step="1" value="40" /&gt;
                        &lt;/div&gt;
                        &lt;div class="input-group"&gt;
                            &lt;label&gt;Логистика (₽/шт)&lt;/label&gt;
                            &lt;input type="number" id="logist" min="0" step="1" value="26" /&gt;
                        &lt;/div&gt;
                    &lt;/div&gt;
                &lt;/div&gt;

                &lt;div class="panel"&gt;
                    &lt;div class="panel-header"&gt;
                        &lt;div class="panel-title"&gt;? Ценообразование&lt;/div&gt;
                    &lt;/div&gt;
                    &lt;div class="input-grid"&gt;
                        &lt;div class="input-group"&gt;
                            &lt;label&gt;Страховые взносы (%)&lt;/label&gt;
                            &lt;input type="number" id="socRate" min="0" max="60" step="0.1" value="30.2" /&gt;
                        &lt;/div&gt;
                        &lt;div class="input-group"&gt;
                            &lt;label&gt;Накладные (% к ЗП)&lt;/label&gt;
                            &lt;input type="number" id="overhead" min="0" step="5" value="110" /&gt;
                        &lt;/div&gt;
                        &lt;div class="input-group"&gt;
                            &lt;label&gt;Рентабельность (%)&lt;/label&gt;
                            &lt;input type="number" id="margin" min="0" max="60" step="1" value="18" /&gt;
                        &lt;/div&gt;
                        &lt;div class="input-group"&gt;
                            &lt;label&gt;Срочность (%)&lt;/label&gt;
                            &lt;input type="number" id="urgent" min="0" max="50" step="1" value="0" /&gt;
                        &lt;/div&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
            &lt;/div&gt;

            &lt;div class="results-section"&gt;
                &lt;div class="result-card"&gt;
                    &lt;div class="price-main"&gt;
                        &lt;div class="price-label"&gt;Отпускная цена за единицу&lt;/div&gt;
                        &lt;div class="price-value" id="rPrice"&gt;0&lt;/div&gt;
                        &lt;div class="price-currency"&gt;рублей с НДС&lt;/div&gt;
                        &lt;div class="margin-badge" id="marginBadge"&gt;Оптимально&lt;/div&gt;
                    &lt;/div&gt;
                &lt;/div&gt;

                &lt;div class="result-card"&gt;
                    &lt;h3 style="margin-bottom: 16px; color: #2c3e50;"&gt;Структура себестоимости&lt;/h3&gt;
                    &lt;div id="breakdownContainer"&gt;&lt;/div&gt;
                    &lt;div class="total-row"&gt;
                        &lt;span class="name"&gt;Полная себестоимость&lt;/span&gt;
                        &lt;span class="cost" id="rFull"&gt;0 ₽&lt;/span&gt;
                    &lt;/div&gt;
                &lt;/div&gt;

                &lt;div class="result-card"&gt;
                    &lt;div class="gauge-container"&gt;
                        &lt;svg class="gauge-svg" viewbox="0 0 180 100"&gt;
                            &lt;path d="M20 90 A70 70 0 0 1 160 90" fill="none" stroke="#e9ecef" stroke-width="12"&gt;&lt;/path&gt;
                            &lt;path id="gaugeArc" d="M20 90 A70 70 0 0 1 160 90" fill="none" stroke="url(#gaugeGradient)" stroke-width="12" stroke-dasharray="219.9" stroke-dashoffset="219.9" style="transition:stroke-dashoffset 0.6s"&gt;&lt;/path&gt;
                            &lt;defs&gt;
                                &lt;lineargradient id="gaugeGradient"&gt;
                                    &lt;stop offset="0%" style="stop-color:#667eea"&gt;&lt;/stop&gt;
                                    &lt;stop offset="100%" style="stop-color:#764ba2"&gt;&lt;/stop&gt;
                                &lt;/lineargradient&gt;
                            &lt;/defs&gt;
                        &lt;/svg&gt;
                        &lt;div class="gauge-value" id="gaugeVal"&gt;0%&lt;/div&gt;
                        &lt;div class="gauge-label"&gt;Рентабельность изделия&lt;/div&gt;
                    &lt;/div&gt;
                &lt;/div&gt;

                &lt;div class="result-card"&gt;
                    &lt;h3 style="margin-bottom: 16px; color: #2c3e50;"&gt;Показатели партии&lt;/h3&gt;
                    &lt;div class="batch-stats"&gt;
                        &lt;div class="stat-box"&gt;
                            &lt;div class="stat-label"&gt;Себестоимость&lt;/div&gt;
                            &lt;div class="stat-value" id="bCost"&gt;0 ₽&lt;/div&gt;
                        &lt;/div&gt;
                        &lt;div class="stat-box"&gt;
                            &lt;div class="stat-label"&gt;Выручка&lt;/div&gt;
                            &lt;div class="stat-value" id="bRev"&gt;0 ₽&lt;/div&gt;
                        &lt;/div&gt;
                        &lt;div class="stat-box"&gt;
                            &lt;div class="stat-label"&gt;Прибыль&lt;/div&gt;
                            &lt;div class="stat-value profit" id="bProfit"&gt;0 ₽&lt;/div&gt;
                        &lt;/div&gt;
                    &lt;/div&gt;
                &lt;/div&gt;

                &lt;div class="actions"&gt;
                    &lt;button class="btn-action btn-primary" onclick="saveCalculation()"&gt;? Сохранить&lt;/button&gt;
                    &lt;button class="btn-action btn-secondary" onclick="window.print()"&gt;?️ Печать&lt;/button&gt;
                &lt;/div&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;

    
    &lt;div class="history-modal" id="historyModal"&gt;
        &lt;div class="history-content"&gt;
            &lt;div class="history-header"&gt;
                &lt;h2&gt;История расчётов&lt;/h2&gt;
                &lt;button class="btn-icon" onclick="closeHistory()"&gt;✕&lt;/button&gt;
            &lt;/div&gt;
            &lt;div id="historyList"&gt;&lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;

    &lt;script&gt;
        // Данные материалов
        const MATERIALS = {
            "Сталь Ст45 (круг)": 92,
            "Сталь 40Х": 105,
            "Сталь 09Г2С": 88,
            "Сталь 12Х18Н10Т (нерж.)": 385,
            "Чугун СЧ20": 74,
            "Латунь ЛС59-1": 520,
            "Алюминий Д16Т": 340,
            "Титан ВТ6": 2400
        };

        // Данные операций
        const OPS = {
            "Токарная": 950,
            "Токарная с ЧПУ": 1150,
            "Фрезерная": 1050,
            "Расточная": 1100,
            "Сверлильная": 800,
            "Шлифовальная": 1100,
            "Зубонарезная": 1250,
            "Сварочная": 1150,
            "Слесарно-сборочная": 850,
            "Термическая": 950
        };

        // Пресеты
        const PRESETS = {
            flange: {
                name: "Фланец стальной Ду100",
                draw: "ПРГ.301124.017",
                qty: 250,
                mat: "Сталь Ст45 (круг)",
                price: 92,
                gross: 3.1,
                net: 2.2,
                comps: [["Шпилька М16", 8, 24]],
                ops: [["Токарная с ЧПУ", 0.35], ["Сверлильная", 0.20]]
            },
            shaft: {
                name: "Вал-шестерня привода",
                draw: "ПРГ.753111.042",
                qty: 60,
                mat: "Сталь 40Х",
                price: 105,
                gross: 8.4,
                net: 5.6,
                comps: [["Шпонка 10×8×45", 1, 35]],
                ops: [["Токарная с ЧПУ", 0.60], ["Зубонарезная", 0.85], ["Шлифовальная", 0.30]]
            },
            housing: {
                name: "Корпус редуктора Ц2-100",
                draw: "ПРГ.321456.008",
                qty: 25,
                mat: "Чугун СЧ20",
                price: 74,
                gross: 46,
                net: 31.5,
                comps: [["Подшипник 206", 2, 210]],
                ops: [["Фрезерная", 2.4], ["Расточная", 1.8], ["Сверлильная", 1.1]]
            },
            bracket: {
                name: "Кронштейн сварной",
                draw: "ПРГ.782213.114",
                qty: 400,
                mat: "Сталь 09Г2С",
                price: 88,
                gross: 6.8,
                net: 5.9,
                comps: [],
                ops: [["Сварочная", 1.2], ["Слесарно-сборочная", 0.4]]
            }
        };

        const DEFAULT = {
            name: "Фланец стальной Ду100",
            draw: "ПРГ.301124.017",
            qty: 120,
            mat: "Сталь Ст45 (круг)",
            price: 92,
            gross: 4.2,
            net: 2.9,
            comps: [["Подшипник 206", 2, 210]],
            ops: [["Токарная с ЧПУ", 0.42], ["Фрезерная", 0.30], ["Шлифовальная", 0.12]]
        };

        // Инициализация
        const $ = id =&gt; document.getElementById(id);
        const nf = new Intl.NumberFormat('ru-RU', {minimumFractionDigits: 0, maximumFractionDigits: 0});
        const nf2 = new Intl.NumberFormat('ru-RU', {minimumFractionDigits: 2, maximumFractionDigits: 2});

        // Заполнение списка материалов
        Object.keys(MATERIALS).forEach(k =&gt; {
            const opt = document.createElement('option');
            opt.value = k;
            opt.textContent = k;
            $('matSel').appendChild(opt);
        });
        $('matSel').value = DEFAULT.mat;

        // Функция скидки по объёму
        function tierDiscount(q) {
            return q &gt;= 500 ? 7 : q &gt;= 200 ? 4 : q &gt;= 50 ? 2 : 0;
        }

        // Создание строки операции
        function createOperationRow(name, hours) {
            const div = document.createElement('div');
            div.className = 'dynamic-row';
            div.innerHTML = `
                &lt;select class="opSel"&gt;
                    ${Object.keys(OPS).map(k =&gt; `&lt;option value="${k}" ${k === name ? 'selected' : ''}&gt;${k}&lt;/option&gt;`).join('')}
                &lt;/select&gt;
                &lt;input type="number" class="opH" placeholder="Н-ч" min="0" step="0.01" value="${hours}"&gt;
                &lt;input type="number" class="opR" placeholder="Ставка" min="0" step="10" value="${OPS[name] || 950}"&gt;
                &lt;button class="btn-remove" onclick="this.parentElement.remove(); recalc();"&gt;✕&lt;/button&gt;
            `;
            div.querySelector('.opSel').addEventListener('change', e =&gt; {
                div.querySelector('.opR').value = OPS[e.target.value];
                recalc();
            });
            return div;
        }

        // Создание строки комплектующего
        function createComponentRow(name, qty, price) {
            const div = document.createElement('div');
            div.className = 'dynamic-row';
            div.innerHTML = `
                &lt;input type="text" class="cpN" placeholder="Наименование" value="${name}"&gt;
                &lt;input type="number" class="cpQ" placeholder="Кол-во" min="0" step="1" value="${qty}"&gt;
                &lt;input type="number" class="cpP" placeholder="Цена ₽" min="0" step="1" value="${price}"&gt;
                &lt;button class="btn-remove" onclick="this.parentElement.remove(); recalc();"&gt;✕&lt;/button&gt;
            `;
            return div;
        }

        // Добавление операции
        function addOperation() {
            $('opRows').appendChild(createOperationRow('Токарная', 0.20));
            recalc();
        }

        // Добавление комплектующего
        function addComponent() {
            $('compRows').appendChild(createComponentRow('Позиция', 1, 100));
            recalc();
        }

        // Основной расчёт
        function recalc() {
            const qty = Math.max(1, Math.round(parseFloat($('qtyNum').value) || 1));
            const gross = parseFloat($('matGross').value) || 0;
            const net = parseFloat($('matNet').value) || 0;
            const mprice = parseFloat($('matPrice').value) || 0;
            const tzr = parseFloat($('tzr').value) || 0;
            const kwh = parseFloat($('kwh').value) || 0;
            const kwhRate = parseFloat($('kwhRate').value) || 0;
            const depr = parseFloat($('depr').value) || 0;
            const tool = parseFloat($('tool').value) || 0;
            const logist = parseFloat($('logist').value) || 0;
            const socRate = parseFloat($('socRate').value) || 0;
            const overhead = parseFloat($('overhead').value) || 0;
            const margin = parseFloat($('margin').value) || 0;
            const urgent = parseFloat($('urgent').value) || 0;

            // Расчёт материалов
            const matCost = gross * mprice * (1 + tzr / 100);
            const vim = gross &gt; 0 ? (net / gross) * 100 : 0;

            // Комплектующие
            let compCost = 0;
            document.querySelectorAll('#compRows .dynamic-row').forEach(row =&gt; {
                const q = parseFloat(row.querySelector('.cpQ').value) || 0;
                const p = parseFloat(row.querySelector('.cpP').value) || 0;
                compCost += q * p;
            });

            // Операции
            let wage = 0, hours = 0;
            document.querySelectorAll('#opRows .dynamic-row').forEach(row =&gt; {
                const h = parseFloat(row.querySelector('.opH').value) || 0;
                const r = parseFloat(row.querySelector('.opR').value) || 0;
                wage += h * r;
                hours += h;
            });

            // Социальные взносы
            const soc = wage * socRate / 100;

            // Энергия
            const energy = kwh * kwhRate;

            // Амортизация и инструмент
            const deprTotal = depr + tool;

            // Накладные
            const overheadCost = wage * overhead / 100;

            // Полная себестоимость
            const fullCost = matCost + compCost + wage + soc + energy + deprTotal + logist + overheadCost;

            // Прибыль
            const profit = fullCost * margin / 100;

            // Надбавка за срочность
            const urgSum = (fullCost + profit) * urgent / 100;

            // Скидка
            const disc = tierDiscount(qty);
            const discSum = (fullCost + profit + urgSum) * disc / 100;

            // Цена без НДС
            const priceExcl = fullCost + profit + urgSum - discSum;

            // НДС
            const vat = priceExcl * 0.2;

            // Итоговая цена
            const price = priceExcl + vat;

            // Рентабельность
            const rent = fullCost &gt; 0 ? (profit / fullCost) * 100 : 0;
            const margPct = priceExcl &gt; 0 ? ((priceExcl - fullCost) / priceExcl) * 100 : 0;

            // Обновление UI
            $('rPrice').textContent = nf.format(price);
            $('rFull').textContent = nf.format(fullCost) + ' ₽';
            $('gaugeVal').textContent = nf2.format(rent).replace('.', ',') + '%';

            // Бейдж маржи
            const badge = $('marginBadge');
            if (margPct &gt; 40) {
                badge.textContent = '? Высокая маржа';
                badge.className = 'margin-badge high';
            } else if (margPct &gt; 20) {
                badge.textContent = '✅ Оптимально';
                badge.className = 'margin-badge good';
            } else if (margPct &gt; 5) {
                badge.textContent = '⚠️ Низкая маржа';
                badge.className = 'margin-badge low';
            } else {
                badge.textContent = '? Убыточно';
                badge.className = 'margin-badge danger';
            }

            // ВИМ
            $('vimPct').textContent = nf.format(vim);
            $('vimBar').style.width = Math.min(100, vim) + '%';
            $('scrapKg').textContent = nf2.format(Math.max(0, gross - net)).replace('.', ',');

            // Часы
            $('sumHours').textContent = nf2.format(hours).replace('.', ',');

            // Gauge
            const rc = Math.min(rent, 50) / 50;
            $('gaugeArc').style.strokeDashoffset = 219.9 * (1 - rc);

            // Разбивка
            const breakdownItems = [
                { name: '? Материалы', cost: matCost },
                { name: '? Комплектующие', cost: compCost },
                { name: '⚙️ Зарплата', cost: wage },
                { name: '? Страховые взносы', cost: soc },
                { name: '⚡ Электроэнергия', cost: energy },
                { name: '? Амортизация и инструмент', cost: deprTotal },
                { name: '? Логистика', cost: logist },
                { name: '? Накладные расходы', cost: overheadCost }
            ];

            let html = '';
            breakdownItems.forEach(item =&gt; {
                html += `
                    &lt;div class="breakdown-item"&gt;
                        &lt;span class="name"&gt;${item.name}&lt;/span&gt;
                        &lt;span class="cost"&gt;${nf.format(item.cost)} ₽&lt;/span&gt;
                    &lt;/div&gt;
                `;
            });
            $('breakdownContainer').innerHTML = html;

            // Партия
            $('bCost').textContent = nf.format(fullCost * qty) + ' ₽';
            $('bRev').textContent = nf.format(price * qty) + ' ₽';
            $('bProfit').textContent = nf.format((priceExcl - fullCost) * qty) + ' ₽';

            // Сохранение в localStorage
            saveToLocalStorage();
        }

        // Сохранение в localStorage
        function saveToLocalStorage() {
            const data = {
                pName: $('pName').value,
                pDraw: $('pDraw').value,
                qtyNum: $('qtyNum').value,
                matSel: $('matSel').value,
                matPrice: $('matPrice').value,
                matGross: $('matGross').value,
                matNet: $('matNet').value,
                tzr: $('tzr').value,
                kwh: $('kwh').value,
                kwhRate: $('kwhRate').value,
                depr: $('depr').value,
                tool: $('tool').value,
                logist: $('logist').value,
                socRate: $('socRate').value,
                overhead: $('overhead').value,
                margin: $('margin').value,
                urgent: $('urgent').value,
                price: $('rPrice').textContent,
                timestamp: new Date().toISOString()
            };
            localStorage.setItem('currentCalc', JSON.stringify(data));
        }

        // Загрузка из localStorage
        function loadFromLocalStorage() {
            const data = JSON.parse(localStorage.getItem('currentCalc'));
            if (data) {
                $('pName').value = data.pName || DEFAULT.name;
                $('pDraw').value = data.pDraw || DEFAULT.draw;
                $('qtyNum').value = data.qtyNum || DEFAULT.qty;
                $('matSel').value = data.matSel || DEFAULT.mat;
                $('matPrice').value = data.matPrice || DEFAULT.price;
                $('matGross').value = data.matGross || DEFAULT.gross;
                $('matNet').value = data.matNet || DEFAULT.net;
                $('tzr').value = data.tzr || 4;
                $('kwh').value = data.kwh || 3.6;
                $('kwhRate').value = data.kwhRate || 8.9;
                $('depr').value = data.depr || 85;
                $('tool').value = data.tool || 40;
                $('logist').value = data.logist || 26;
                $('socRate').value = data.socRate || 30.2;
                $('overhead').value = data.overhead || 110;
                $('margin').value = data.margin || 18;
                $('urgent').value = data.urgent || 0;
            }
        }

        // Применение пресета
        function applyPreset(presetKey) {
            const p = PRESETS[presetKey];
            $('pName').value = p.name;
            $('pDraw').value = p.draw;
            $('qtyNum').value = p.qty;
            $('matSel').value = p.mat;
            $('matPrice').value = p.price;
            $('matGross').value = p.gross;
            $('matNet').value = p.net;

            $('opRows').innerHTML = '';
            p.ops.forEach(op =&gt; $('opRows').appendChild(createOperationRow(op[0], op[1])));

            $('compRows').innerHTML = '';
            p.comps.forEach(c =&gt; $('compRows').appendChild(createComponentRow(c[0], c[1], c[2])));

            // Подсветка активной кнопки
            document.querySelectorAll('.preset-btn').forEach(btn =&gt; btn.classList.remove('active'));
            document.querySelector(`[data-preset="${presetKey}"]`).classList.add('active');

            recalc();
        }

        // Сброс калькулятора
        function resetCalculator() {
            if (confirm('Сбросить все данные?')) {
                applyPreset('flange');
                document.querySelectorAll('.preset-btn').forEach(btn =&gt; btn.classList.remove('active'));
            }
        }

        // Сохранение расчёта в историю
        function saveCalculation() {
            const history = JSON.parse(localStorage.getItem('calcHistory') || '[]');
            const entry = {
                id: Date.now(),
                name: $('pName').value,
                price: $('rPrice').textContent,
                timestamp: new Date().toISOString(),
                data: JSON.parse(localStorage.getItem('currentCalc'))
            };
            history.unshift(entry);
            if (history.length &gt; 20) history = history.slice(0, 20);
            localStorage.setItem('calcHistory', JSON.stringify(history));
            alert('Расчёт сохранён в историю!');
        }

        // Показ истории
        function showHistory() {
            const history = JSON.parse(localStorage.getItem('calcHistory') || '[]');
            const list = $('historyList');

            if (history.length === 0) {
                list.innerHTML = '&lt;p style="text-align:center; color:#6c757d; padding:40px;"&gt;История пуста&lt;/p&gt;';
            } else {
                list.innerHTML = history.map(entry =&gt; `
                    &lt;div class="history-item" onclick="loadFromHistory(${entry.id})"&gt;
                        &lt;div class="history-date"&gt;${new Date(entry.timestamp).toLocaleString('ru-RU')}&lt;/div&gt;
                        &lt;div class="history-info"&gt;
                            &lt;span class="history-name"&gt;${entry.name}&lt;/span&gt;
                            &lt;span class="history-price"&gt;${entry.price} ₽&lt;/span&gt;
                        &lt;/div&gt;
                    &lt;/div&gt;
                `).join('');
            }

            $('historyModal').classList.add('active');
        }

        // Загрузка из истории
        function loadFromHistory(id) {
            const history = JSON.parse(localStorage.getItem('calcHistory') || '[]');
            const entry = history.find(h =&gt; h.id === id);
            if (entry) {
                localStorage.setItem('currentCalc', JSON.stringify(entry.data));
                loadFromLocalStorage();
                recalc();
                closeHistory();
            }
        }

        // Закрытие истории
        function closeHistory() {
            $('historyModal').classList.remove('active');
        }

        // Автоматический расчёт при изменении
        document.addEventListener('DOMContentLoaded', function() {
            loadFromLocalStorage();

            // Инициализация операций и комплектующих по умолчанию
            DEFAULT.ops.forEach(op =&gt; $('opRows').appendChild(createOperationRow(op[0], op[1])));
            DEFAULT.comps.forEach(c =&gt; $('compRows').appendChild(createComponentRow(c[0], c[1], c[2])));

            // Пресеты
            document.querySelectorAll('.preset-btn').forEach(btn =&gt; {
                btn.addEventListener('click', () =&gt; applyPreset(btn.dataset.preset));
            });

            // Материал
            $('matSel').addEventListener('change', e =&gt; {
                $('matPrice').value = MATERIALS[e.target.value];
                recalc();
            });

            // Все инпуты
            document.querySelectorAll('input, select').forEach(el =&gt; {
                el.addEventListener('input', recalc);
                el.addEventListener('change', recalc);
            });

            // Закрытие модалки по клику вне
            $('historyModal').addEventListener('click', e =&gt; {
                if (e.target === $('historyModal')) closeHistory();
            });

            recalc();
        });
    &lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;</subtitle>
  <updated>2026-08-17T08:49:32Z</updated>
  <logo>https://pandoraburo.ru/ssl/u/pic/e2/6850fe98a211f18279a3cef0e847cc/-/logo.png</logo>
  <author>
    <name>1592962</name>
    <uri>https://www.pandoraburo.ru/</uri>
  </author>
</feed>
