/* =====================================================
   style.css — все стили приложения.
   ===================================================== */

* { box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background: #f4f6f8;
    margin: 0;
    padding: 30px 20px;
    color: #333;
}

/* ===== Верхняя панель ===== */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    padding: 12px 18px;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}
.top-bar-left { font-size: 14px; color: #555; }
.top-bar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ===== Кнопки ===== */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-primary { background: #007bff; color: #fff; }
.btn-primary:hover { background: #0056b3; }
.btn-secondary { background: #6c757d; color: #fff; }
.btn-secondary:hover { background: #5a6268; }
.btn-danger { background: #dc3545; color: #fff; }
.btn-danger:hover { background: #c82333; }
.btn-info { background: #17a2b8; color: #fff; }
.btn-info:hover { background: #138496; }
.btn-success { background: #28a745; color: #fff; }
.btn-success:hover { background: #218838; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== Бейдж пользователя ===== */
.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #e9f2ff;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
}
.user-badge .role-icon { font-size: 15px; }
.user-badge .name { font-weight: bold; color: #0056b3; }

/* ===== Инфо-панель ===== */
.info-panel {
    background: #fff;
    padding: 20px 22px;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.6;
}
.info-panel h3 { margin: 0 0 12px 0; font-size: 15px; }
.info-panel code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: #c7254e;
}
.info-panel ul { margin: 8px 0 0 0; padding-left: 20px; }
.info-panel li { margin-bottom: 4px; }

/* ===== Модалки ===== */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.modal.open { display: flex; }

/* Вложенные модалки — поверх окна цен */
#group-edit-modal,
#ral-edit-modal,
#thickness-edit-modal {
    z-index: 1100;
}

#confirm-modal {
    z-index: 1200;
}

.modal-content {
    background: #fff;
    border-radius: 10px;
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.modal-content-wide { max-width: 1200px; }
.modal-content-mid  { max-width: 520px; }
.modal-content-lg   { max-width: 700px; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: #343a40;
    color: #fff;
    font-size: 15px;
    font-weight: bold;
    flex-shrink: 0;
}
.modal-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    padding: 0 6px;
}
.modal-close:hover { color: #ffc107; }

.modal-body {
    padding: 20px 22px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

/* ===== Шаги авторизации ===== */
.step {
    display: none;
    padding: 20px 22px 22px 22px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}
.step.active { display: block; }
.step-hint {
    font-size: 13px;
    color: #555;
    margin: 0 0 14px 0;
    line-height: 1.5;
}
.input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 15px;
    margin-bottom: 10px;
    text-align: left;
}
.input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.15);
}
.input-code {
    letter-spacing: 8px;
    font-size: 22px;
    font-weight: bold;
    text-align: left;
    padding-left: 14px;
}
.error {
    color: #dc3545;
    font-size: 12px;
    min-height: 16px;
    margin-bottom: 8px;
    text-align: center;
}
.btn-submit {
    width: 100%;
    padding: 11px;
    border: none;
    border-radius: 6px;
    background: #007bff;
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-submit:hover { background: #0056b3; }
.btn-link {
    width: 100%;
    padding: 8px;
    margin-top: 6px;
    border: none;
    background: none;
    color: #007bff;
    font-size: 12px;
    cursor: pointer;
    text-decoration: underline;
}
.btn-link:hover { color: #0056b3; }

/* ===== Панель управления ===== */
.panel {
    display: none;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    margin-bottom: 20px;
    overflow: hidden;
}
.panel.open { display: block; }
.panel-header {
    background: #343a40;
    color: #fff;
    padding: 14px 20px;
    font-size: 15px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.panel-body { padding: 20px; }

.section { margin-bottom: 25px; }
.section:last-child { margin-bottom: 0; }
.section h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: #333;
    border-bottom: 2px solid #007bff;
    padding-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.section .hint {
    font-size: 11px;
    color: #888;
    font-style: italic;
    margin: -6px 0 10px 0;
}

/* ===== Таблицы ===== */
table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table th {
    background: #f0f0f0;
    padding: 8px 10px;
    text-align: left;
    border: 1px solid #ddd;
    font-weight: bold;
    color: #555;
    font-size: 12px;
}
.data-table td {
    padding: 6px 10px;
    border: 1px solid #ddd;
    vertical-align: middle;
}
.data-table tr:hover td { background: #fafafa; }
.data-table input[type="text"],
.data-table input[type="number"],
.data-table select {
    padding: 4px 6px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 13px;
}
.empty-row td {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 15px !important;
}

/* ===== Теги ===== */
.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: bold;
}
.tag-superadmin { background: #dc3545; color: #fff; }
.tag-admin { background: #ffc107; color: #333; }
.tag-manager { background: #17a2b8; color: #fff; }
.tag-custom { background: #6c757d; color: #fff; }
.tag-system { background: #e0e0e0; color: #555; }
.tag-active { background: #d4edda; color: #155724; }
.tag-inactive { background: #f8d7da; color: #721c24; }
.tag-group { background: #e9f2ff; color: #0056b3; }
.tag-guest { background: #e2e3e5; color: #555; }
.tag-client { background: #d4edda; color: #155724; }

/* ===== Формы ===== */
.form-row { margin-bottom: 12px; }
.form-row label {
    display: block;
    font-size: 12px;
    color: #555;
    margin-bottom: 4px;
    font-weight: bold;
}
.form-row input[type="text"],
.form-row input[type="password"],
.form-row input[type="number"],
.form-row select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 14px;
}
.form-row input:focus,
.form-row select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.15);
}

/* ===== Список прав ===== */
.permissions-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 6px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}
.perm-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
}
.perm-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}
.perm-item label {
    cursor: pointer;
    margin: 0;
    font-weight: normal;
    color: #333;
}
.perm-item .perm-key {
    color: #888;
    font-family: 'Courier New', monospace;
    font-size: 11px;
}
.perm-item.locked {
    opacity: 0.6;
    cursor: not-allowed;
}
.perm-item.locked label { cursor: not-allowed; }
.perm-item.locked input[type="checkbox"] { cursor: not-allowed; }

.form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

/* ===== Окно цен ===== */
.price-modal-tabs {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    flex-wrap: wrap;
    flex-shrink: 0;
}
.group-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px solid #ccc;
    background: #fff;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}
.group-tab:hover { background: #f0f6ff; border-color: #007bff; }
.group-tab.active {
    background: #007bff;
    color: #fff;
    border-color: #0056b3;
    font-weight: bold;
}
.group-tab.guest-tab { border-color: #adb5bd; }
.group-tab.client-tab { border-color: #28a745; }
.group-tab .tab-actions {
    display: inline-flex;
    gap: 2px;
    margin-left: 4px;
}
.group-tab .tab-btn {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 13px;
    padding: 0 2px;
    opacity: 0.7;
}
.group-tab .tab-btn:hover { opacity: 1; }
.group-tab.active .tab-btn { color: #fff; }
.group-tab-add {
    padding: 7px 14px;
    border: 1px dashed #17a2b8;
    background: #e9f7fa;
    color: #17a2b8;
    border-radius: 6px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
}
.group-tab-add:hover { background: #d1eef3; }

.price-modal-body {
    padding: 20px;
    overflow-y: auto;
    overflow-x: auto;
    flex: 1;
    min-height: 0;
}
.price-modal-footer {
    display: flex;
    gap: 8px;
    padding: 15px 20px;
    background: #f8f9fa;
    border-top: 1px solid #eee;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.price-section { margin-bottom: 25px; }
.price-section h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: #333;
    border-bottom: 2px solid #007bff;
    padding-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.price-section h4 .h4-actions { display: flex; gap: 6px; }
.price-section .hint {
    font-size: 11px;
    color: #888;
    font-style: italic;
    margin: -6px 0 10px 0;
}
.price-section .formula-hint {
    font-size: 12px;
    color: #666;
    background: #f8f9fa;
    padding: 8px 12px;
    border-left: 3px solid #007bff;
    border-radius: 3px;
    margin-bottom: 12px;
    font-family: 'Courier New', monospace;
}

.price-table-wrap { overflow-x: auto; }
.price-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.price-table th {
    background: #f0f0f0;
    padding: 8px 10px;
    text-align: center;
    border: 1px solid #ddd;
    font-weight: bold;
    color: #555;
    font-size: 12px;
    white-space: nowrap;
}
.price-table td {
    padding: 6px 10px;
    border: 1px solid #ddd;
}
.price-table input[type="number"] {
    width: 90px;
    padding: 4px 6px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 13px;
    text-align: right;
}
.price-table .row-label {
    font-weight: bold;
    color: #333;
    background: #fafafa;
    text-align: left;
    white-space: nowrap;
}
.price-table .ral-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}
.price-table .ral-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid #ccc;
    flex-shrink: 0;
}

.coefficients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}
.coef-item {
    background: #f8f9fa;
    padding: 12px 15px;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}
.coef-item label {
    display: block;
    font-size: 12px;
    color: #555;
    margin-bottom: 6px;
    font-weight: bold;
}
.coef-item .coef-input-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}
.coef-item input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    text-align: right;
}
.coef-item .unit {
    font-size: 13px;
    color: #666;
    font-weight: bold;
    min-width: 30px;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 3000;
    opacity: 0;
    transition: opacity 0.25s;
    pointer-events: none;
}
.toast.show { opacity: 1; }
.toast.success { background: #28a745; }
.toast.error { background: #dc3545; }
.toast.info { background: #17a2b8; }

/* ===== Подтверждение ===== */
.confirm-text {
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    margin-bottom: 20px;
}
.confirm-text b { color: #dc3545; }

/* ===== Список RAL / толщин ===== */
.catalog-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 340px;
    overflow-y: auto;
    padding: 4px;
    border: 1px solid #eee;
    border-radius: 6px;
    background: #fafbfc;
}
.catalog-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    flex-shrink: 0;
}
.catalog-row .color-preview {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid #ccc;
    flex-shrink: 0;
}
.catalog-row .info {
    flex: 1;
    font-size: 13px;
}
.catalog-row .info .code {
    font-weight: bold;
    color: #333;
}
.catalog-row .info .name {
    color: #666;
    font-size: 12px;
    margin-left: 6px;
}
.catalog-row .info .hex {
    color: #999;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    margin-left: 6px;
}
.catalog-row .actions {
    display: flex;
    gap: 4px;
}
.catalog-add-form {
    margin-top: 12px;
    padding: 12px;
    background: #f0f6ff;
    border: 1px solid #cce0ff;
    border-radius: 6px;
    flex-shrink: 0;
}
.catalog-add-form h5 {
    margin: 0 0 10px 0;
    font-size: 13px;
    color: #0056b3;
}
.catalog-add-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: flex-end;
}
.catalog-add-row .field {
    flex: 1;
    min-width: 100px;
}
.catalog-add-row .field label {
    display: block;
    font-size: 11px;
    color: #555;
    margin-bottom: 3px;
    font-weight: bold;
}
.catalog-add-row .field input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    height: 34px;
}
.catalog-add-row .field input[type="color"] {
    padding: 2px;
    height: 34px;
    cursor: pointer;
}
.catalog-add-row .field.field-narrow { flex: 0 0 140px; }
.catalog-add-row .btn { height: 34px; }

.catalog-add-form .field-hint {
    font-size: 12px;
    margin-top: 8px;
    color: #28a745;
}
.catalog-add-form .field-hint.not-found {
    color: #dc3545;
}
/* =====================================================
   ОТЧЁТЫ / СТАТИСТИКА
   ===================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.stat-card {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px 12px;
    text-align: center;
}
.stat-value {
    font-size: 26px;
    font-weight: bold;
    color: #007bff;
    line-height: 1.1;
}
.stat-label {
    font-size: 12px;
    color: #666;
    margin-top: 6px;
}

.reports-block {
    margin-bottom: 25px;
}
.reports-block h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: #333;
    border-bottom: 2px solid #007bff;
    padding-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chart-switcher {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}
.chart-btn {
    padding: 7px 14px;
    border: 1px solid #ccc;
    background: #fff;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}
.chart-btn:hover { background: #f0f6ff; border-color: #007bff; }
.chart-btn.active {
    background: #007bff;
    color: #fff;
    border-color: #0056b3;
    font-weight: bold;
}

.chart-canvas-wrap {
    position: relative;
    height: 320px;
    padding: 10px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 6px;
}
/* =====================================================
   ЖУРНАЛ ДЕЙСТВИЙ (АУДИТ)
   ===================================================== */
.audit-filters {
    margin-bottom: 15px;
    padding: 12px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
}
.audit-filter-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}
.audit-select {
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    background: #fff;
    min-width: 160px;
}
.audit-search {
    flex: 1;
    min-width: 150px;
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
}
.audit-search:focus,
.audit-select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.15);
}
.audit-count {
    margin-top: 10px;
    font-size: 12px;
    color: #666;
}
.audit-count b {
    color: #007bff;
}

/* Таблица журнала */
#audit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
#audit-table th {
    background: #f0f0f0;
    padding: 8px 10px;
    text-align: left;
    border: 1px solid #ddd;
    font-weight: bold;
    color: #555;
    font-size: 11px;
    position: sticky;
    top: 0;
    z-index: 1;
}
#audit-table td {
    padding: 6px 10px;
    border: 1px solid #ddd;
    vertical-align: top;
}
#audit-table tr:hover td {
    background: #fafafa;
}
/* =====================================================
   ПРОФИЛЬ ПОКУПАТЕЛЯ
   ===================================================== */
#profile-modal .form-row label {
    font-size: 12px;
    color: #555;
    font-weight: bold;
    margin-bottom: 5px;
}
#profile-modal input[readonly],
#profile-modal input:disabled {
    background: #f0f0f0;
    color: #666;
    cursor: not-allowed;
}
#prof-orders {
    font-size: 13px;
    color: #555;
}

/* Кнопка «Профиль» в шапке — рядом с бейджем */
.user-badge + .btn-secondary {
    margin-left: 0;
}
/* =====================================================
   ЗАЯВКИ
   ===================================================== */
#orders-modal .modal-body {
    padding: 20px 22px;
}
#prof-orders {
    font-size: 13px;
    color: #333;
    background: #f8f9fa;
    border: 1px solid #eee;
    border-radius: 4px;
    padding: 8px 12px;
    max-height: 200px;
    overflow-y: auto;
}
/* =====================================================
   КАЛЬКУЛЯТОР — секция, рисовалка, свойства, корзина
   Перенесено из основного проекта (index.html)
   ===================================================== */

.calc-container {
    background: #fff;
    padding: 20px 22px;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    margin-bottom: 20px;
}

/* ===== Вкладки верхнего уровня ===== */
.calc-container .tabs { margin-bottom: 20px; }
.calc-container .tab-button {
    padding: 10px 20px;
    cursor: pointer;
    border: 1px solid #ccc;
    background: #f0f0f0;
    margin-right: 5px;
    font-size: 15px;
    border-radius: 4px;
}
.calc-container .tab-button.active {
    background: #fff;
    border-bottom: 2px solid #007bff;
    font-weight: bold;
}
.calc-container .tab-content {
    display: none;
    padding: 15px;
    border: 1px solid #ccc;
    border-radius: 4px;
}
.calc-container .tab-content.active { display: block; }

/* ===== Подвкладки ===== */
.calc-container .subtabs { margin-bottom: 20px; }
.calc-container .subtab-button {
    padding: 8px 15px;
    cursor: pointer;
    border: 1px solid #ddd;
    background: #fafafa;
    margin-right: 5px;
    font-size: 14px;
    border-radius: 4px;
}
.calc-container .subtab-button.active {
    background: #e9f2ff;
    border-bottom: 2px solid #007bff;
    font-weight: bold;
}
.calc-container .subtab-content { display: none; }
.calc-container .subtab-content.active { display: block; }

/* ===== Картинки ===== */
.calc-container .calc-image {
    display: block;
    max-width: 500px;
    height: auto;
    margin: 0 auto 20px auto;
    border-radius: 8px;
}

/* ===== Результаты ===== */
.calc-container .result-item {
    margin-top: 15px;
    font-size: 18px;
    font-weight: bold;
    color: #007bff;
}

/* ===== Информация о фиксированном размере ===== */
.calc-container .fixed-info {
    color: #666;
    font-style: italic;
    margin: 5px 0 15px 0;
}

/* ===== Холст для рисования ===== */
#draw-canvas {
    outline: 2px solid #333;
    border-radius: 8px;
    cursor: crosshair;
    background: #fff;
    touch-action: none;
    display: block;
}
.canvas-wrap {
    position: relative;
    display: inline-block;
    margin-bottom: 10px;
}
.draw-controls { margin-top: 10px; }
.draw-controls button {
    padding: 8px 15px;
    margin-right: 5px;
    margin-bottom: 5px;
    cursor: pointer;
    border: 1px solid #ccc;
    background: #f0f0f0;
    font-size: 14px;
    border-radius: 4px;
}
.draw-controls button:hover { background: #e0e0e0; }

/* ===== Раскладка: три колонки ===== */
.draw-layout {
    display: flex;
    gap: 15px;
    align-items: flex-start;
    flex-wrap: wrap;
}
.draw-left { flex: 0 0 auto; }
.draw-right {
    flex: 1 1 260px;
    min-width: 260px;
    max-width: 320px;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px 18px;
}
.draw-right h3 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: #333;
}
.draw-cart {
    flex: 1 1 260px;
    min-width: 260px;
    max-width: 320px;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px 18px;
}
.draw-cart h3 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: #333;
}

/* ===== Строки свойств ===== */
.prop-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    font-size: 14px;
}
.prop-row:last-of-type { border-bottom: none; }
.prop-row label { color: #555; font-size: 13px; }
.prop-row span {
    font-weight: bold;
    color: #007bff;
    font-size: 15px;
}
.prop-row select {
    padding: 4px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    max-width: 150px;
}

.prop-row-result {
    border-top: 2px solid #007bff;
    border-bottom: none;
    margin-top: 10px;
    padding-top: 12px;
}
.prop-price {
    color: #28a745 !important;
    font-size: 18px !important;
}
.prop-details {
    font-size: 11px;
    color: #888;
    text-align: right;
    margin-top: 4px;
    line-height: 1.4;
}

.prop-row-ral {
    border-bottom: none;
    padding-bottom: 4px;
}
#prop-ral-label {
    font-weight: bold;
    color: #007bff;
    font-size: 14px;
}

/* ===== Плитки RAL ===== */
.ral-tiles {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}
.ral-tile {
    width: 68px;
    height: 44px;
    border-radius: 4px;
    border: 2px solid transparent;
    cursor: pointer;
    font-size: 11px;
    font-weight: bold;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    box-sizing: border-box;
    transition: border-color 0.15s, transform 0.1s;
    user-select: none;
    outline: 1px solid #ccc;
    outline-offset: -3px;
}
.ral-tile:hover { transform: scale(1.05); }
.ral-tile.active {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.3);
}

/* ===== Покрытие (снаружи/внутри) ===== */
.prop-row-side {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding-top: 12px;
    border-bottom: none;
    border-top: 1px solid #eee;
}
.prop-row-side label { font-size: 13px; color: #555; }
.side-switch {
    display: flex;
    width: 100%;
    border: 1px solid #ccc;
    border-radius: 4px;
    overflow: hidden;
}
.side-btn {
    flex: 1;
    padding: 6px 10px;
    border: none;
    background: #fff;
    color: #555;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.side-btn:first-child { border-right: 1px solid #ccc; }
.side-btn.active {
    background: #007bff;
    color: #fff;
    font-weight: bold;
}
.side-btn:hover:not(.active) { background: #f0f0f0; }

/* ===== Подгибы ===== */
.prop-row-hem {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 8px 0;
    border-top: 1px solid #eee;
    border-bottom: none;
}
.prop-row-hem label { font-size: 13px; color: #555; }
.hem-group { display: flex; gap: 4px; align-items: center; }
.hem-arrow-btn {
    width: 32px;
    height: 30px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    color: #555;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.hem-arrow-btn.active {
    background: #dc3545;
    color: #fff;
    border-color: #a71d2a;
}
.hem-arrow-btn:hover:not(.active) { background: #f0f0f0; }
.hem-length-input {
    width: 50px;
    padding: 4px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    text-align: center;
}

/* ===== Количество ===== */
.prop-row-quantity {
    border-top: 1px solid #eee;
    border-bottom: none;
    padding-top: 12px;
}
.quantity-input {
    width: 80px;
    padding: 5px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    text-align: center;
}

/* ===== Кнопки корзины ===== */
.cart-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 15px;
}
.btn-save-cart,
.btn-new,
.btn-checkout {
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: background 0.15s;
}
.btn-save-cart {
    background: #28a745;
    color: #fff;
}
.btn-save-cart:hover { background: #218838; }
.btn-new {
    background: #6c757d;
    color: #fff;
}
.btn-new:hover { background: #5a6268; }
.btn-checkout {
    background: #007bff;
    color: #fff;
}
.btn-checkout:hover:not(:disabled) { background: #0056b3; }
.btn-checkout:disabled {
    background: #ccc;
    color: #888;
    cursor: not-allowed;
}

/* ===== Список корзины ===== */
.cart-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 380px;
    overflow-y: auto;
}
.cart-empty {
    color: #999;
    font-style: italic;
    font-size: 13px;
    text-align: center;
    padding: 10px 0;
}
.cart-item {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    position: relative;
}
.cart-item:hover {
    border-color: #007bff;
    box-shadow: 0 2px 6px rgba(0,123,255,0.15);
}
.cart-item-editing {
    border-color: #007bff !important;
    background: #e9f2ff !important;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.3);
}
.cart-item-editing::before {
    content: '✎ редактируется';
    position: absolute;
    top: 6px;
    right: 30px;
    font-size: 10px;
    color: #007bff;
    font-weight: bold;
    font-style: italic;
}
.cart-item-title {
    font-weight: bold;
    color: #333;
    margin-bottom: 4px;
}
.cart-item-info { color: #666; line-height: 1.4; }
.cart-item-price {
    color: #28a745;
    font-weight: bold;
    margin-top: 4px;
}
.cart-item-delete {
    position: absolute;
    top: 6px;
    right: 6px;
    background: none;
    border: none;
    color: #dc3545;
    font-size: 14px;
    cursor: pointer;
    padding: 0 4px;
}
.cart-item-delete:hover { color: #a71d2a; }
.cart-total-row {
    display: flex;
    justify-content: space-between;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #eee;
    font-weight: bold;
    font-size: 14px;
}
.cart-total-row span:last-child {
    color: #28a745;
    font-size: 16px;
}

/* ===== Предупреждение о пересечении ===== */
.cross-warning {
    display: none;
    position: absolute;
    top: 10px;
    right: 10px;
    background: #dc3545;
    color: #fff;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    z-index: 10;
    pointer-events: none;
}
.cross-warning.visible { display: block; }

/* ===== Панель редактирования отрезка ===== */
.edit-panel {
    display: none;
    position: absolute;
    background: #ffffff;
    border: 1px solid #bbb;
    border-radius: 6px;
    padding: 10px 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 20;
    font-size: 13px;
    min-width: 180px;
}
.edit-panel.open { display: block; }
.edit-row {
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.edit-row label {
    font-size: 12px;
    color: #555;
    min-width: 48px;
}
.edit-row input {
    padding: 3px 6px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 13px;
    width: 60px;
}
.edit-unit { font-size: 12px; color: #666; }
.edit-buttons {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}
.edit-buttons button {
    padding: 5px 10px;
    border: 1px solid #ccc;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    background: #f0f0f0;
}
.edit-buttons button:first-child {
    background: #007bff;
    color: #fff;
    border-color: #0056b3;
}
.edit-buttons button:first-child:hover { background: #0056b3; }
.edit-buttons button:last-child:hover { background: #e0e0e0; }

/* =====================================================
   МОДАЛКА 3D-МОДЕЛИ
   ===================================================== */
.modal-3d {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1900;
    justify-content: center;
    align-items: center;
}
.modal-3d.open { display: flex; }
.modal-3d-content {
    background: #fff;
    border-radius: 10px;
    padding: 0;
    width: 90%;
    max-width: 800px;
    height: 80%;
    max-height: 600px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.modal-3d-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    font-size: 16px;
    font-weight: bold;
}
.modal-3d-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #666;
    padding: 0 8px;
}
.modal-3d-close:hover { color: #000; }
#three-container {
    flex: 1;
    position: relative;
    background: #fafafa;
    overflow: hidden;
    cursor: grab;
}
#three-container:active { cursor: grabbing; }
#three-container canvas { display: block; }
/* ===== Кнопки в состоянии disabled ===== */
.draw-controls button:disabled,
.btn-save-cart:disabled,
.btn-checkout:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
/* ===== Селект RAL ===== */
.ral-select {
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    background: #fff;
    max-width: 200px;
    cursor: pointer;
}
.ral-select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.15);
}
/* ===== Плитка-превью рядом с селектом RAL ===== */
.ral-select-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    justify-content: flex-end;
}

.ral-color-preview {
    display: inline-block;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid #ccc;
    flex-shrink: 0;
    background: #ccc;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.3);
    transition: background 0.15s;
}
/* =====================================================
   КОРЗИНА-ВИДЖЕТ (плавающая)
   ===================================================== */
.cart-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 340px;
    max-height: 70vh;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.15);
    z-index: 1500;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: max-height 0.2s;
}

.cart-widget.collapsed {
    max-height: 50px;
}

.cart-widget.collapsed .cart-widget-body {
    display: none;
}

.cart-widget-header {
    padding: 12px 16px;
    background: #343a40;
    color: #fff;
    font-weight: bold;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.cart-widget-header:hover {
    background: #495057;
}

.cart-widget-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cart-widget-count {
    background: #007bff;
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: bold;
}

.cart-widget-toggle {
    font-size: 14px;
    color: #ccc;
}

.cart-widget-clear {
    background: none;
    border: none;
    color: #ffc107;
    font-size: 16px;
    cursor: pointer;
    padding: 0 6px;
    margin-left: 4px;
    transition: color 0.15s;
}
.cart-widget-clear:hover {
    color: #dc3545;
}

.cart-widget-body {
    padding: 12px 16px;
    overflow-y: auto;
    max-height: calc(70vh - 50px);
}

/* Убираем .draw-cart — оно больше не используется */
.draw-cart { display: none; }
/* =====================================================
   БЛАНК ЗАЯВКИ (для печати и PDF)
   ===================================================== */

/* Контейнер бланка (внутри модалки) */
.print-order-page {
    background: #fff;
    color: #000;
    font-family: 'Times New Roman', Times, serif;
    font-size: 11pt;
    line-height: 1.3;
    padding: 10px 0;
}

/* Каждый лист — отдельная страница */
.print-order-sheet {
    background: #fff;
    padding: 6mm;
    margin-bottom: 20px;
    border: 1px solid #000;
    font-size: 10pt;
}

/* Шапка листа */
.print-order-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    border-bottom: 2px solid #000;
    padding-bottom: 5px;
    margin-bottom: 10px;
    font-size: 14pt;
    font-weight: bold;
}

.print-order-header .customer {
    flex: 1;
}

.print-order-header .order-info {
    display: flex;
    gap: 15px;
    font-size: 12pt;
    font-weight: normal;
    margin-right: 20px;
}

.print-order-header .sheet-num {
    white-space: nowrap;
}

/* Таблица позиций */
.print-order-table {
    width: 100%;
    box-sizing: border-box;
    table-layout: fixed;
}

.print-order-table td {
    border: 1px solid #000;
    padding: 4px 6px;
    vertical-align: top;
}

/* Левая колонка — эскиз */
.print-order-table td.sketch-cell {
    width: 50%;
    height: 150px;  /* было 130px */
    text-align: center;
    vertical-align: middle;
    padding: 4px;
    border: none;
}

.print-order-table td.sketch-cell:not(:empty) {
    border: 1px solid #000;
}

.print-order-table td.sketch-cell canvas {
    max-width: 100%;
    max-height: 180px;  /* было 120px */
    display: inline-block;
}

.print-order-table td.sketch-cell img {
    max-width: 100%;
    max-height: 90px;  /* было 120px */
    object-fit: contain;
    display: inline-block;
}

/* Правая колонка — данные */
.print-order-table td.data-cell {
    width: 50%;
    padding: 0;
    border: none;
}

.print-order-table .data-row {
    display: flex;
    border-bottom: 1px solid #000;
    border-bottom: none;
}

.print-order-table .data-row:has(.value:not(:empty)) {
    border-bottom: 1px solid #000;
}

.print-order-table .data-row:last-child {
    border-bottom: none;
}

.print-order-table .data-row .label {
    width: 45%;
    padding: 3px 6px;
    font-weight: bold;
    font-size: 10pt;
    border-right: none;
}

.print-order-table .data-row:has(.value:not(:empty)) .label {
    border-right: 1px solid #000;
}

.print-order-table .data-row .value {
    flex: 1;
    padding: 3px 6px;
    font-size: 11pt;
}

.print-order-table .data-row .value.empty {
    background: #fff;
}

/* Внутренняя мини-таблица для "Развертки + Кол-во листов" */
.print-order-table .data-row .value-split {
    flex: 1;
    display: flex;
    padding: 0;
}

.print-order-table .value-split .split-label {
    flex: 1;
    padding: 3px 6px;
    border-right: 1px solid #000;
    font-size: 10pt;
    display: flex;
    align-items: center;
}

.print-order-table .value-split .split-value {
    flex: 1;
    padding: 3px 6px;
    font-size: 11pt;
}

/* Подвал с подписями */
.print-order-footer {
    margin-top: 20px;
    font-size: 11pt;
}

.print-order-footer .sig-row {
    display: flex;
    align-items: flex-end;
    margin-bottom: 10px;
    gap: 10px;
}

.print-order-footer .sig-label {
    width: 100px;
    font-weight: bold;
}

.print-order-footer .sig-role {
    width: 150px;
}

.print-order-footer .sig-line {
    flex: 1;
    border-bottom: 1px solid #000;
    height: 18px;
}

.print-order-footer .sig-slash {
    margin: 0 6px;
}

.print-order-footer .sig-fio {
    width: 200px;
    border-bottom: 1px solid #000;
    height: 18px;
}

/* При печати — скрыть всё, кроме бланка */
@media print {
    /* Скрываем всё, кроме бланка */
    body * { visibility: hidden; }
    
    /* Показываем только бланк */
    #print-order-modal,
    #print-order-modal * { visibility: visible; }
    
    /* Сбрасываем позиционирование модалки */
    #print-order-modal {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: auto;
        background: #fff;
        padding: 0;
        margin: 0;
        display: block !important;
    }

    /* Убираем фон модалки */
    #print-order-modal .modal-content {
        box-shadow: none;
        max-width: 100% !important;
        max-height: none !important;
        width: 100% !important;
        margin: 0;
        padding: 0;
    }

    /* Убираем шапку модалки и кнопки */
    #print-order-modal .modal-header,
    #print-order-modal .modal-footer {
        display: none !important;
    }

    /* Убираем скролл */
    #print-order-modal .modal-body {
        overflow: visible !important;
        max-height: none !important;
        padding: 0 !important;
    }

    /* Настройка страницы A4 */
    @page {
        size: A4 portrait;
        margin: 10mm;
    }

    /* Каждый лист — отдельная страница */
    .print-order-sheet {
        background: #fff;
        padding: 5mm;
        margin: 0;
        border: none; /* Убрали рамку вокруг всего бланка */
        font-size: 10pt;
    }
    .print-order-sheet:last-child {
        page-break-after: auto;
    }
}

/* Разрыв страницы для html2pdf */
.print-order-sheet {
    page-break-inside: avoid;
    page-break-after: always;
}
.print-order-sheet:last-child {
    page-break-after: auto;
}

/* Для html2canvas — убираем разрыв страницы внутри */
@media screen {
    .print-order-sheet {
        page-break-after: auto;
    }
}

/* ===== Валидация ===== */
.input-error {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 3px rgba(220,53,69,0.15) !important;
}

.error-message {
    color: #dc3545;
    font-size: 11px;
    margin-top: 4px;
    margin-bottom: 4px;
    display: none;
    line-height: 1.3;
}

.error-message.visible {
    display: block;
}