:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --background: #f8fafc;
    --card-background: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: var(--text-primary);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header */
.header {
    text-align: center;
    color: white;
    margin-bottom: 40px;
    animation: fadeInDown 0.6s ease-out;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}

.logo i {
    font-size: 3rem;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-top: 8px;
}

/* Upload Section */
.upload-section {
    animation: fadeInUp 0.6s ease-out;
    /* Измените расположение формы здесь: */
    /* margin: 0 auto; - центрирование */
    /* max-width: 800px; - ограничение ширины */
    /* margin-left: 0; - слева */
    /* margin-right: auto; - справа */
    /* position: relative; - для абсолютного позиционирования */
}

.upload-card {
    background: var(--card-background);
    border-radius: 20px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
    text-align: center;
    /* Измените расположение карточки здесь: */
    /* margin: 0 auto; - центрирование */
    /* max-width: 600px; - ограничение ширины */
    /* margin-left: 50px; - отступ слева */
    /* margin-right: 50px; - отступ справа */
}

.upload-icon {
    font-size: 4rem;
    color: var(--primary-color);
    margin-bottom: 20px;
}

.upload-card h2 {
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.upload-description {
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.upload-area {
    border: 3px dashed var(--border-color);
    border-radius: 15px;
    padding: 60px 40px;
    margin-bottom: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: #f8fafc;
}

.upload-area.drag-over {
    border-color: var(--primary-color);
    background: #eef2ff;
    transform: scale(1.02);
}

.upload-content i {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.upload-content p {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.browse-link {
    color: var(--primary-color);
    font-weight: 600;
    cursor: pointer;
}

.browse-link:hover {
    text-decoration: underline;
}

/* File Info */
.file-info {
    background: #f8fafc;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.file-details {
    display: flex;
    align-items: center;
    gap: 15px;
}

.file-details i {
    font-size: 2rem;
    color: var(--primary-color);
}

.file-name-size {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.file-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.file-size {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.btn-remove {
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 15px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-remove:hover {
    background: #dc2626;
    transform: scale(1.05);
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-action {
    border: none;
    border-radius: 12px;
    padding: 15px 40px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    width: 100%;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-secondary:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

.btn-action {
    background: #f8fafc;
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    padding: 12px 30px;
}

.btn-action:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

/* Progress Section */
.progress-section {
    animation: fadeInUp 0.6s ease-out;
}

.progress-card {
    background: var(--card-background);
    border-radius: 20px;
    padding: 60px 40px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.progress-icon {
    margin-bottom: 30px;
}

.spinner {
    width: 80px;
    height: 80px;
    border: 6px solid #e2e8f0;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.progress-card h3 {
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.progress-text {
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.progress-bar {
    background: #e2e8f0;
    border-radius: 50px;
    height: 12px;
    overflow: hidden;
    margin-bottom: 15px;
}

.progress-fill {
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    height: 100%;
    border-radius: 50px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-percentage {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Results Section */
.results-section {
    animation: fadeInUp 0.6s ease-out;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 0 10px;
}

.results-header h2 {
    color: white;
    font-size: 2rem;
    display: flex;
    align-items: center;
    gap: 15px;
}

.success-icon {
    color: var(--secondary-color);
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.result-card {
    background: var(--card-background);
    border-radius: 15px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.result-card.full-width {
    grid-column: 1 / -1;
}

.result-card-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.1rem;
}

.result-card-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.result-card-body {
    padding: 25px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

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

.info-label {
    font-weight: 600;
    color: var(--text-secondary);
}

.info-value {
    color: var(--text-primary);
    font-weight: 500;
    text-align: right;
}

/* Table Container */
.table-container {
    overflow-x: visible; /* Убрана прокрутка - таблица должна помещаться в 100% ширины */
    position: relative;
    width: 100%;
    max-width: 100%;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
}

.items-table th {
    background: #f8fafc;
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
}

.items-table td {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

.items-table tr:hover {
    background: #f8fafc;
}

.items-table tr:last-child td {
    border-bottom: none;
}

/* Actions Section */
.actions-section {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

/* JSON Viewer */
.json-viewer {
    background: var(--card-background);
    border-radius: 15px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.json-viewer-header {
    background: #1e293b;
    color: white;
    padding: 15px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.json-viewer-header h4 {
    margin: 0;
    font-size: 1rem;
    font-family: 'Courier New', monospace;
}

.btn-toggle {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

.btn-toggle.active {
    transform: rotate(180deg);
}

.json-content {
    background: #1e293b;
    color: #94a3b8;
    padding: 25px;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 0;
}

/* Error Section */
.error-section {
    animation: fadeInUp 0.6s ease-out;
}

.error-card {
    background: var(--card-background);
    border-radius: 20px;
    padding: 60px 40px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.error-card i {
    font-size: 4rem;
    color: var(--danger-color);
    margin-bottom: 20px;
}

.error-card h3 {
    font-size: 1.8rem;
    margin-bottom: 15px;
}

.error-card p {
    color: var(--text-secondary);
    margin-bottom: 30px;
    font-size: 1.05rem;
    line-height: 1.7;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    text-align: left;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.error-card p a {
    color: var(--primary-color);
    text-decoration: underline;
    word-break: break-all;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--card-background);
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    animation: slideInUp 0.3s ease;
}

.modal-header {
    padding: 25px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 25px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Переключатель режима авторизации */
.auth-mode-switcher {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 8px;
}

.mode-btn {
    flex: 1;
    padding: 10px 15px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.mode-btn:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
}

.mode-btn.active {
    background: white;
    color: var(--primary-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.mode-btn i {
    font-size: 1rem;
}

/* Контент режима авторизации */
.auth-mode-content {
    animation: fadeIn 0.3s ease;
}

/* Поле ввода с иконкой */
.input-with-icon {
    position: relative;
}

.input-with-icon input {
    padding-right: 45px;
}

.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
}

.toggle-password:hover {
    color: var(--primary-color);
}

/* Сообщения авторизации */
.auth-message {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    border-radius: 8px;
    margin-top: 15px;
    font-size: 0.9rem;
    animation: fadeIn 0.3s ease;
}

.auth-message.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}

.auth-message.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

.auth-message i {
    font-size: 1.1rem;
}

/* Ссылка на регистрацию */
.btn-link {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 8px 0;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.3s ease;
    width: 100%;
    justify-content: center;
}

.btn-link:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.btn-link i {
    font-size: 0.85rem;
}

.modal-footer {
    padding: 20px 25px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Settings Button */
.btn-settings {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: white;
    color: var(--primary-color);
    border: none;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    font-size: 1.5rem;
    transition: all 0.3s ease;
    z-index: 100;
}

.btn-settings:hover {
    transform: scale(1.1) rotate(90deg);
    background: var(--primary-color);
    color: white;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Login Modal Styles */
.login-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease-out;
}

.login-modal-card {
    background: var(--card-background);
    border-radius: 16px;
    padding: 40px;
    max-width: 440px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.4s ease-out;
}

.login-modal-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-modal-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.login-modal-icon i {
    color: white;
    font-size: 28px;
}

.login-modal-header h2 {
    color: var(--text-primary);
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
}

.login-modal-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

.login-modal-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login-form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.login-form-group label {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.login-form-group label i {
    color: var(--primary-color);
    font-size: 14px;
}

.login-form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.3s;
    background: white;
}

.login-form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.input-with-icon {
    position: relative;
}

.input-with-icon input {
    padding-right: 45px;
}

.toggle-password {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s;
}

.toggle-password:hover {
    color: var(--primary-color);
}

.login-form-message {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    animation: slideDown 0.3s ease-out;
}

.login-form-message.error {
    background: #fef2f2;
    color: var(--danger-color);
    border: 1px solid #fecaca;
}

.login-form-message.success {
    background: #f0fdf4;
    color: var(--secondary-color);
    border: 1px solid #bbf7d0;
}

.login-form-message i {
    font-size: 16px;
}

.btn-login-modal {
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-login-modal:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.btn-login-modal:active:not(:disabled) {
    transform: translateY(0);
}

.btn-login-modal:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Editable Data Section */
.editable-section {
    margin-bottom: 30px;
    grid-column: 1 / -1;
}

.editable-data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
    gap: 20px;
    margin-bottom: 25px;
    align-items: start;
}

.editable-group {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 15px;
    background: #f8fafc;
}

.editable-group-title {
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.editable-field {
    margin-bottom: 15px;
}

.editable-field:last-child {
    margin-bottom: 0;
}

.editable-label {
    display: block;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.editable-input,
.editable-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
    background: white;
}

.editable-input:focus,
.editable-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.editable-textarea {
    min-height: 80px;
    resize: vertical;
}

.editable-items-table {
    width: 100%;
    border-collapse: separate; /* Changed from collapse for border-radius support */
    border-spacing: 0; /* Remove spacing between cells */
    margin-top: 10px;
    table-layout: auto; /* Automatic layout for flexibility - adapts to content */
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden; /* Clip content to border-radius */
    /* Allow table to adapt to content and screen width */
    max-width: 100%; /* Не выходить за границы контейнера */
    /* Smooth rendering */
    font-variant-numeric: tabular-nums; /* Align numbers nicely */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08); /* Более мягкая тень для аккуратного вида */
}

/* All columns - automatic width, browser calculates based on content */
/* No static sizes - responsive for all devices */

/* All column widths are set dynamically via inline styles from JavaScript */
/* Based on content analysis and weight calculations - NO HARDCODED UNITS */
/* Relative units only (%, min-content, max-content, fit-content) */

/* Line number column - narrow, centered */
.editable-items-table th.col-line-number,
.editable-items-table td.col-line-number {
    width: auto; /* Width set via inline style based on weight */
    min-width: min-content; /* Minimum based on content, not fixed */
    text-align: center !important;
    white-space: nowrap !important;
    overflow: visible !important;
}

/* Quantity column - narrow, centered */
.editable-items-table th.col-quantity,
.editable-items-table td.col-quantity {
    width: auto; /* Width set via inline style based on weight */
    min-width: min-content; /* Minimum based on content */
    text-align: center !important;
    white-space: nowrap !important;
}

/* Numeric columns (prices) - narrow, right-aligned, never wrap */
.editable-items-table th.col-numeric,
.editable-items-table td.col-numeric {
    width: auto; /* Width set via inline style based on weight */
    min-width: min-content; /* Minimum based on content */
    text-align: right !important;
}

.editable-items-table td.col-numeric {
    white-space: nowrap !important; /* Never wrap prices */
    padding-right: 6px !important;
    padding-left: 6px !important;
}

/* Input для numeric - компактная ширина по содержимому */
.editable-items-table td.col-numeric input {
    width: 100%; /* Full width of cell */
    min-width: min-content; /* Minimum based on content */
    max-width: 100% !important;
    padding: 6px 8px !important;
    text-align: right;
    box-sizing: border-box;
}

/* Code column - medium width, left-aligned */
.editable-items-table th.col-code,
.editable-items-table td.col-code {
    width: auto; /* Width set via inline style based on weight */
    min-width: min-content; /* Minimum based on content */
    text-align: left !important;
    white-space: normal !important; /* Allow wrapping for long codes */
    word-wrap: break-word; /* Word wrap */
}

.editable-items-table td.col-code textarea {
    padding: 6px 8px;
    width: 100%; /* Textarea занимает всю ширину ячейки */
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box;
    white-space: pre-wrap; /* Сохраняем форматирование */
    word-wrap: break-word;
    resize: vertical; /* Пользователь может изменить размер вручную */
}

/* Short repetitive column - narrow, centered */
.editable-items-table th.col-short-repetitive,
.editable-items-table td.col-short-repetitive {
    width: auto; /* Width set via inline style based on weight */
    min-width: min-content; /* Minimum based on content */
    text-align: center !important;
    white-space: nowrap !important;
}

/* Text columns (descriptions, notes, addresses, comments, etc.) */
/* Width set dynamically via JavaScript based on content analysis - NO HARDCODED VALUES */
/* Primary description column gets maximum space, others get proportional width */
.editable-items-table th.col-text,
.editable-items-table td.col-text {
    width: auto; /* Width set via inline style based on weight */
    min-width: fit-content; /* Minimum based on header text or content */
    /* Primary description column has no max-width (set via inline style) */
    /* Other text columns have max-width based on weight ratio (set via inline style) */
}

.editable-items-table td.col-text textarea {
    /* Высота определяется автоматически на основе содержимого */
    line-height: 1.5;
    padding: 6px 8px; /* Компактные отступы */
    resize: vertical; /* Пользователь может изменить размер вручную */
}


.editable-items-table th {
    background: #7c3aed; /* Purple header matching the UI theme */
    color: white;
    padding: 10px 8px; /* Более компактные отступы */
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem; /* Немного меньше шрифт для более аккуратного вида */
    white-space: normal; /* Разрешаем перенос заголовков */
    word-wrap: break-word; /* Перенос слов в заголовках */
    line-height: 1.4; /* Улучшенная читаемость при переносе */
    border-right: 1px solid rgba(255, 255, 255, 0.15);
    box-sizing: border-box;
    overflow: visible;
    position: sticky;
    top: 0;
    z-index: 10;
    /* Subtle text shadow for better readability */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    /* Smooth transitions */
    transition: background-color 0.2s;
    vertical-align: middle; /* Центрирование по вертикали */
}

.editable-items-table th:hover {
    background: #6d28d9; /* Slightly darker on hover */
}

/* Price column headers - allow wrap for 2-line headers */
.editable-items-table th.col-numeric {
    white-space: normal !important;
    word-wrap: break-word !important;
    line-height: 1.3;
    height: auto;
}

.editable-items-table th:last-child {
    border-right: none;
}

.editable-items-table td {
    padding: 6px 8px; /* Более компактные отступы для аккуратного вида */
    border-bottom: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    background: white;
    color: var(--text-primary);
    box-sizing: border-box;
    vertical-align: middle; /* Центрирование для более аккуратного вида */
    /* Smooth transitions for interactive states */
    transition: background-color 0.15s;
}

/* Hover effect on rows for better UX */
.editable-items-table tbody tr:hover td {
    background: #f8fafc;
}

/* Zebra striping for better readability - более мягкая для аккуратного вида */
.editable-items-table tbody tr:nth-child(even) td {
    background: #fcfcfd; /* Очень легкая полосатая раскраска */
}

.editable-items-table tbody tr:nth-child(even):hover td {
    background: #f8fafc; /* Мягкий hover эффект */
}

.editable-items-table td:last-child {
    border-right: none;
}

.editable-items-table tbody tr:last-child td {
    border-bottom: none;
}

/* Динамические типы колонок - стили применяются через inline styles из JavaScript */
/* Базовые стили для всех колонок */
.editable-items-table th[class^="col-"],
.editable-items-table td[class^="col-"] {
    /* Ширина и выравнивание задаются динамически через inline styles */
}

/* Специфичные стили для заголовков - перенос только если не помещается */
.editable-items-table th[class^="col-"] {
    overflow: visible; /* Allow header text to wrap fully */
    text-overflow: clip; /* Don't use ellipsis - show full text */
}

/* Для заголовков с длинным текстом разрешаем перенос (определяется динамически) */
.editable-items-table th[class^="col-"]:hover {
    /* При наведении можно показать полный текст через title */
}

/* Стили для ячеек с многострочным текстом */
.editable-items-table td.col-long-descriptive {
    word-wrap: break-word;
    word-break: break-word;
}

.editable-items-table input {
    /* Ширина устанавливается inline через style="width: Xch" на основе содержимого + 1 символ */
    /* width устанавливается динамически в JavaScript для каждого input отдельно */
    min-width: 1ch; /* Минимальная ширина - один символ */
    /* max-width задаётся через inline style из JavaScript */
    padding: 6px 8px; /* Компактные отступы для аккуратного вида */
    border: 1px solid #e2e8f0;
    border-radius: 4px; /* Немного меньше радиус для более строгого вида */
    font-size: 0.9rem; /* Немного меньше шрифт */
    box-sizing: border-box;
    background: white;
    color: var(--text-primary);
    font-family: inherit;
    overflow: visible; /* Don't clip text */
    text-overflow: clip; /* Show full text, don't use ellipsis */
    /* Smooth transitions */
    transition: border-color 0.2s, box-shadow 0.2s;
    /* Ширина определяется содержимым через size атрибут или содержимое */
    display: inline-block; /* Для правильного расчета ширины */
    margin: 0; /* Убираем внешние отступы */
}

.editable-items-table input:hover {
    border-color: #cbd5e1;
}

.editable-items-table input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Line number input - centered */
/* Width is inherited from parent td, which has width set via inline style based on weight */
.editable-items-table td.col-line-number {
    /* width и min-width задаются через inline style из JavaScript */
}

.editable-items-table td.col-line-number input {
    text-align: center !important;
    font-weight: 500 !important;
    /* width задаётся через inline style из JavaScript */
    /* min-width и max-width задаются через inline style из JavaScript */
    box-sizing: border-box !important;
    padding: 6px 4px !important;
    color: var(--text-primary) !important;
    background: white !important;
    font-size: 0.9rem !important;
    line-height: 1.4 !important;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    overflow: visible !important;
    text-overflow: clip !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 4px !important;
    margin: 0 !important;
}

/* Numeric input (prices, amounts) - right-aligned */
.editable-items-table td.col-numeric input {
    text-align: right;
    font-variant-numeric: tabular-nums; /* Align numbers nicely */
    /* width, min-width, max-width задаются через inline style из JavaScript */
    font-weight: 500;
}

/* Textarea для колонок с длинным текстом - многострочный текст */
/* Width controlled by column min-width from JavaScript - NO HARDCODED VALUES */
.editable-items-table td textarea {
    width: 100%;
    min-width: 0; /* Позволяет textarea сжиматься */
    padding: 6px 8px; /* Компактные отступы */
    border: 1px solid #e2e8f0;
    border-radius: 4px; /* Немного меньше радиус для более строгого вида */
    font-size: 0.9rem; /* Немного меньше шрифт */
    box-sizing: border-box;
    white-space: pre-wrap; /* Сохраняем переносы строк и переносим текст */
    word-wrap: break-word;
    word-break: break-word;
    resize: vertical; /* Allow vertical resizing */
    font-family: inherit; /* Inherit font */
    line-height: 1.5;
    overflow-wrap: break-word;
    min-height: 36px; /* Уменьшена минимальная высота для более компактного вида */
    background: white;
    color: var(--text-primary);
    /* Smooth transitions */
    transition: border-color 0.2s, box-shadow 0.2s;
    margin: 0; /* Убираем внешние отступы */
}

.editable-items-table td textarea:hover {
    border-color: #cbd5e1;
}

.editable-items-table td textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Code column textarea - auto height based on content */
.editable-items-table td.col-code textarea {
    resize: vertical;
}

/* Product description textarea - auto height based on content */
.editable-items-table td.col-long-descriptive textarea {
    resize: vertical;
}

.save-section {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 2px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    flex-wrap: nowrap;
}

.btn-save-action {
    font-size: 1.1rem;
    padding: 18px 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    white-space: nowrap;
}

.save-section #backBtn {
    min-width: 140px;
}

.save-section #saveAndContinueBtn {
    min-width: 220px;
    max-width: 280px;
}

/* Responsive */
@media (max-width: 1200px) {
    .editable-data-grid {
        grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
    }
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 2rem;
    }

    .upload-card {
        padding: 30px 20px;
    }

    .upload-area {
        padding: 40px 20px;
    }

    .results-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .results-grid {
        grid-template-columns: 1fr;
    }

    .actions-section {
        flex-direction: column;
    }

    .btn-action {
        width: 100%;
    }

    .btn-settings {
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }

    .editable-data-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .editable-group {
        padding: 12px;
    }

    .btn-save {
        min-width: 100%;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    .container {
        max-width: 100%;
    }

    .editable-group {
        padding: 10px;
    }

    .editable-field {
        margin-bottom: 12px;
    }

    .editable-label {
        font-size: 0.85rem;
    }

    .editable-input,
    .editable-textarea {
        font-size: 0.9rem;
        padding: 8px 10px;
    }
}


/* Parse Buttons - Two buttons side by side */
.parse-buttons {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.btn-fast, .btn-detailed {
    border: none;
    border-radius: 12px;
    padding: 15px 30px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
    flex: 1;
    width: auto; /* Переопределяем width: 100% из btn-primary */
}

.btn-fast {
    background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
    color: white;
}

.btn-fast:hover:not(:disabled) {
    background: linear-gradient(135deg, #d97706 0%, #ea580c 100%);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-detailed {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
}

.btn-detailed:hover:not(:disabled) {
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-fast i, .btn-detailed i {
    font-size: 1.2rem;
}
