* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    padding: 20px;
}

header {
    background-color: #2c3e50;
    color: white;
    text-align: center;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 5px;
}

h1, h2 {
    margin-bottom: 15px;
}

.container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.settings-panel, .results-panel {
    background: white;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    padding: 20px;
}

.settings-panel {
    flex: 1;
    min-width: 300px;
}

.results-panel {
    flex: 2;
    min-width: 500px;
}

.form-group {
    margin-bottom: 15px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

input, select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

button {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 5px;
    font-size: 14px;
}

button:hover {
    background-color: #2980b9;
}

.primary-button {
    background-color: #2ecc71;
    padding: 12px;
    width: 100%;
    margin-top: 15px;
    font-weight: bold;
}

.primary-button:hover {
    background-color: #27ae60;
}

.parts-list {
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 15px;
}

.part-header {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr auto;
    gap: 10px;
    background: #f8f9fa;
    padding: 10px;
    font-weight: bold;
    border-bottom: 1px solid #ddd;
}

.part-item {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr auto;
    gap: 10px;
    padding: 10px;
    border-bottom: 1px solid #ddd;
}

.part-item:last-child {
    border-bottom: none;
}

.remove-button {
    background-color: #e74c3c;
    color: white;
}

.remove-button:hover {
    background-color: #c0392b;
}

.action-buttons {
    display: flex;
    gap: 10px;
}

.stats-block {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: #2c3e50;
}

.stat-label {
    font-size: 14px;
    color: #7f8c8d;
}

#cutting-plan-container {
    border: 1px solid #ddd;
    border-radius: 5px;
    overflow: auto;
    min-height: 300px;
    max-height: 600px;
    padding: 20px;
    background: #f8f9fa;
}

.sheet {
    margin-bottom: 30px;
    position: relative;
    border: 2px solid #333;
    background-color: #fff;
}

.sheet-title {
    margin-bottom: 10px;
    font-weight: bold;
}

.part {
    position: absolute;
    border: 1px solid #333;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-weight: bold;
    color: #333;
    text-align: center;
    transition: box-shadow 0.2s, transform 0.05s;
    z-index: 1;
}

/* Стили для перетаскиваемых элементов */
.part:hover {
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
    cursor: move;
}

.part.dragging {
    opacity: 0.8;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
    z-index: 100;
    transform: scale(1.02);
    border: 2px solid #3498db;
}

footer {
    text-align: center;
    margin-top: 30px;
    color: #7f8c8d;
    font-size: 14px;
}

@media print {
    body * {
        visibility: hidden;
    }
    #cutting-plan, #cutting-plan * {
        visibility: visible;
    }
    #cutting-plan {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }
    .settings {
        display: none;
    }
    
    header, footer, .settings-panel {
        display: none;
    }
    
    .results-panel {
        width: 100%;
    }
    
    /* Улучшение качества печати */
    * {
        -webkit-print-color-adjust: exact !important;
        color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    /* Четкое отображение деталей */
    .part-item-display {
        border: 2px solid #000 !important;
        background-color: #e6f3ff !important;
        color: #000 !important;
        font-weight: bold !important;
        -webkit-font-smoothing: antialiased !important;
        -moz-osx-font-smoothing: grayscale !important;
    }
    
    /* Четкий текст в деталях */
    .part-info {
        color: #000 !important;
        font-weight: bold !important;
        font-size: 12px !important;
        line-height: 1.2 !important;
        text-shadow: none !important;
        -webkit-font-smoothing: antialiased !important;
        -moz-osx-font-smoothing: grayscale !important;
    }
    
    .part-name {
        font-size: 11px !important;
        font-weight: bold !important;
        color: #000 !important;
        margin-bottom: 2px !important;
    }
    
    .part-dimensions {
        font-size: 10px !important;
        font-weight: bold !important;
        color: #000 !important;
    }
    
    /* Четкие границы листов */
    .sheet-container {
        border: 2px solid #000 !important;
        margin-bottom: 20px !important;
        page-break-inside: avoid !important;
    }
    
    .sheet-title {
        background-color: #f0f0f0 !important;
        color: #000 !important;
        font-weight: bold !important;
        font-size: 14px !important;
        border-bottom: 2px solid #000 !important;
    }
    
    .sheet-content {
        border: 1px solid #000 !important;
        background-color: #fff !important;
    }
    
    /* Четкие свободные области */
    .scrap-area {
        background-color: rgba(144, 238, 144, 0.3) !important;
        border: 1px dashed #008000 !important;
    }
    
    .scrap-size {
        color: #008000 !important;
        font-weight: bold !important;
        font-size: 10px !important;
        -webkit-font-smoothing: antialiased !important;
        -moz-osx-font-smoothing: grayscale !important;
    }
    
    /* Четкая сетка */
    .grid-line {
        background-color: rgba(0, 0, 0, 0.1) !important;
    }
    
    /* Статистика */
    .stats-table {
        border: 2px solid #000 !important;
        font-size: 12px !important;
    }
    
    .stats-table td {
        border: 1px solid #000 !important;
        color: #000 !important;
        font-weight: normal !important;
    }
    
    /* Разрешение для печати */
    .sheet-content, .part-item-display, .scrap-area {
        image-rendering: -webkit-optimize-contrast !important;
        image-rendering: crisp-edges !important;
    }
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.stats-table td {
    padding: 5px;
    border: 1px solid #ddd;
    font-size: 14px;
}

.stats-table tr:nth-child(even) {
    background-color: #f8f9fa;
}

.stats-table tr td:nth-child(1), 
.stats-table tr td:nth-child(3) {
    font-weight: normal;
    width: 25%;
}

.stats-table tr td:nth-child(2), 
.stats-table tr td:nth-child(4) {
    text-align: right;
    width: 25%;
}

.export-buttons {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    background-color: #f5f5f5;
    padding: 5px;
    border-radius: 4px;
}

.export-button {
    background-color: white;
    border: 1px solid #ddd;
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.export-button:hover {
    background-color: #f0f0f0;
}

.sheets-header {
    background-color: #555;
    color: white;
    padding: 5px 10px;
    font-weight: bold;
    margin-bottom: 10px;
}

/* Стили для плана раскроя и элементов перетаскивания */
.sheet-container {
    margin-bottom: 30px;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.sheet-title {
    background-color: #f5f5f5;
    padding: 10px;
    font-weight: bold;
    border-bottom: 1px solid #ddd;
}

.sheet-content {
    background-color: #fff;
    position: relative;
    margin: 10px;
    border: 1px solid #ccc;
}

.part-item-display {
    position: absolute;
    border: 2px solid #333;
    box-sizing: border-box;
    cursor: move;
    z-index: 2;
    overflow: hidden;
    border-radius: 2px;
    transition: box-shadow 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.part-item-display:hover {
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
    z-index: 3;
}

.part-item-display.dragging {
    opacity: 0.8;
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.5);
    z-index: 10;
    transform: scale(1.01);
}

.part-info {
    padding: 2px;
    font-size: 12px;
    text-align: center;
    width: 100%;
    font-weight: bold;
    line-height: 1.3;
    pointer-events: none;
    user-select: none;
}

.part-name {
    font-weight: bold;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 11px;
}

.part-dimensions {
    font-size: 10px;
    font-weight: normal;
}

/* Текстуры для деталей */
.texture-along {
    background-image: linear-gradient(0deg, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
    background-size: 100% 20px;
}

.texture-across {
    background-image: linear-gradient(90deg, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
    background-size: 20px 100%;
}

/* Сетка на листе */
.grid-line {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.05);
    z-index: 1;
    pointer-events: none;
}

.grid-line.horizontal {
    height: 1px;
    left: 0;
}

.grid-line.vertical {
    width: 1px;
    top: 0;
}

/* Свободные области (остатки) */
.scrap-area {
    position: absolute;
    background-color: rgba(0, 200, 0, 0.15);
    border: 1px dashed rgba(0, 150, 0, 0.4);
    box-sizing: border-box;
    z-index: 1;
    pointer-events: none;
}

.scrap-size {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(0, 100, 0, 0.7);
    font-size: 11px;
    font-weight: bold;
    white-space: nowrap;
}

.exporting .scrap-area {
    background-color: rgba(144, 238, 144, 0.3);
    border-color: rgba(0, 128, 0, 0.5);
}

/* Селектор языка */
.language-selector-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 15px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px dashed #ddd;
}

.language-selector-container label {
    margin-right: 5px;
}

#language-selector {
    padding: 5px;
    border-radius: 4px;
    border: 1px solid #ccc;
    background-color: #f8f8f8;
    min-width: 120px;
}

/* Улучшенная мобильная адаптация */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        flex-direction: column;
        gap: 15px;
        max-width: 100%;
    }
    
    .settings-panel, .results-panel {
        min-width: unset;
        width: 100%;
        padding: 15px;
    }
    
    .part-header, .part-item {
        grid-template-columns: 1fr 1fr 60px 1fr auto;
        gap: 5px;
        font-size: 14px;
        padding: 8px;
    }
    
    .part-header div, .part-item input, .part-item select {
        font-size: 12px;
        padding: 5px;
    }
    
    .action-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .action-buttons button {
        width: 100%;
        margin-right: 0;
    }
    
    .export-buttons {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
        margin-top: 15px;
    }
    
    .export-button {
        min-width: 60px;
        min-height: 60px;
        flex: 0 0 auto;
    }
    
    .stats-table {
        font-size: 12px;
        width: 100%;
        overflow-x: auto;
        display: block;
        white-space: nowrap;
    }
    
    .stats-table td {
        padding: 3px;
        min-width: 80px;
    }
    
    #cutting-plan-container {
        max-height: 400px;
        padding: 10px;
        overflow: auto;
    }
    
    .sheet-title {
        font-size: 14px;
        margin-bottom: 5px;
    }
    
    .part-info {
        font-size: 10px;
    }
    
    .part-name {
        font-size: 9px;
    }
    
    .part-dimensions {
        font-size: 8px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 5px;
    }
    
    header {
        padding: 15px 10px;
        margin-bottom: 15px;
    }
    
    header h1 {
        font-size: 24px;
        margin-bottom: 10px;
    }
    
    header p {
        font-size: 14px;
    }
    
    .settings-panel, .results-panel {
        padding: 10px;
    }
    
    .part-header, .part-item {
        grid-template-columns: 1fr 1fr 50px auto;
        gap: 3px;
        padding: 5px;
    }
    
    .part-header div:nth-child(4), 
    .part-item .part-texture {
        display: none;
    }
    
    .form-group {
        margin-bottom: 12px;
    }
    
    .form-group label {
        font-size: 14px;
        margin-bottom: 3px;
    }
    
    .form-group input, .form-group select {
        font-size: 14px;
        padding: 8px;
    }
    
    button {
        font-size: 14px;
        padding: 12px;
        margin-bottom: 5px;
    }
    
    .primary-button {
        padding: 15px;
        font-size: 16px;
    }
    
    .export-buttons {
        justify-content: space-around;
    }
    
    .export-button {
        min-width: 50px;
        min-height: 50px;
        padding: 8px;
    }
    
    .stats-table {
        font-size: 11px;
    }
    
    .stats-table td {
        padding: 2px;
        min-width: 70px;
    }
    
    #cutting-plan-container {
        max-height: 300px;
        padding: 5px;
    }
    
    .sheet-container {
        margin-bottom: 15px;
    }
    
    .sheet-content {
        min-height: 200px;
    }
}

@media (max-width: 320px) {
    .part-header, .part-item {
        grid-template-columns: 1fr 1fr auto;
        gap: 2px;
    }
    
    .part-header div:nth-child(3), 
    .part-item .part-count {
        max-width: 40px;
    }
    
    .export-button {
        min-width: 45px;
        min-height: 45px;
        font-size: 12px;
    }
    
    .stats-table {
        font-size: 10px;
    }
    
    .stats-table td {
        padding: 1px;
        min-width: 60px;
    }
}

/* Селектор методов раскроя */
.cutting-method-selector {
    display: flex;
    gap: 15px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.method-option {
    flex: 1;
    min-width: 120px;
}

.method-option input[type="radio"] {
    display: none;
}

.method-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: #f9f9f9;
    text-align: center;
}

.method-label:hover {
    border-color: #3498db;
    background-color: #f0f8ff;
}

.method-option input[type="radio"]:checked + .method-label {
    border-color: #2ecc71;
    background-color: #e8f5e8;
    box-shadow: 0 2px 8px rgba(46, 204, 113, 0.3);
}

.method-icon {
    margin-bottom: 8px;
}

.method-icon svg {
    display: block;
}

.method-label span {
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.method-option input[type="radio"]:checked + .method-label span {
    color: #27ae60;
    font-weight: bold;
}

/* Адаптация селектора методов */
.cutting-method-selector {
    flex-direction: column;
    gap: 10px;
}

.method-option {
    min-width: unset;
}

.method-label {
    flex-direction: row;
    padding: 10px;
    gap: 10px;
}

.method-icon {
    margin-bottom: 0;
}

.method-icon svg {
    width: 30px;
    height: 22px;
} 