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

:root {
    --primary: #3498db;
    --primary-dark: #2980b9;
    --success: #27ae60;
    --danger: #e74c3c;
    --gray-light: #ecf0f1;
    --gray-dark: #7f8c8d;
    --text: #2c3e50;
    --border: #bdc3c7;
}

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

.container {
    max-width: 600px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

header {
    background: var(--primary);
    color: white;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

header .logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
}

header h1 {
    font-size: 18px;
    margin: 0;
    flex: 1;
    text-align: left;
}

.btn-scan-header {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.5);
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 60px;
    transition: background 0.2s;
}

.btn-scan-header:active {
    background: rgba(255, 255, 255, 0.3);
}

.btn-scan-header .scan-icon {
    font-size: 20px;
    line-height: 1;
}

.btn-scan-header .scan-text {
    font-size: 9px;
    line-height: 1.1;
    font-weight: 600;
    text-align: center;
}

/* Success Message */
.success-message {
    background: var(--success);
    color: white;
    padding: 20px;
    text-align: center;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

.success-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.success-icon {
    font-size: 28px;
}

#success-text {
    font-size: 16px;
    font-weight: 500;
}

/* Form */
#order-form {
    padding: 24px 20px;
}

/* Info Box */
.info-box {
    background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
    border-left: 4px solid var(--primary);
    padding: 12px 16px;
    margin-bottom: 20px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
}

.info-box p {
    margin: 0 0 8px 0;
}

.info-box strong {
    color: var(--primary);
    font-size: 14px;
}

.info-box ol {
    margin: 0;
    padding-left: 20px;
}

.info-box li {
    margin-bottom: 4px;
}

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

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.2s;
}

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

/* Order Lines */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--gray-light);
}

.section-header h2 {
    font-size: 18px;
}

.btn-add {
    background: var(--success);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-add:active {
    transform: scale(0.98);
}

/* Line Item */
.line-item {
    background: var(--gray-light);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    position: relative;
    animation: fadeIn 0.3s ease;
}

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

.line-header {
    display: none;
}

.line-number {
    font-weight: 700;
    color: var(--primary);
    font-size: 14px;
    display: inline-block;
    margin-bottom: 8px;
}

.btn-remove {
    background: var(--danger);
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    font-size: 16px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    transition: opacity 0.2s;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-remove:active {
    opacity: 0.8;
    transform: scale(0.95);
}

.line-fields {
    display: grid;
    grid-template-columns: 70px 70px 60px 1fr 28px;
    gap: 8px;
    margin-bottom: 8px;
    align-items: end;
}

.field-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--gray-dark);
}

.field-group input {
    width: 100%;
    padding: 8px 6px;
    border: 2px solid white;
    border-radius: 6px;
    font-size: 15px;
    text-align: center;
}

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

.field-group.field-comment input {
    text-align: left;
    font-size: 14px;
}

.line-note {
    grid-column: 1 / -1;
    width: 100%;
    margin-top: 8px;
}

.line-note textarea {
    width: 100%;
    padding: 8px;
    border: 2px solid white;
    border-radius: 6px;
    font-size: 13px;
    resize: vertical;
    min-height: 45px;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 24px;
}

.btn-submit {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    padding: 16px;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-submit:active {
    background: var(--primary-dark);
    transform: scale(0.98);
}

.btn-submit:disabled {
    background: var(--gray-dark);
    cursor: not-allowed;
}

.btn-add-bottom {
    width: 100%;
    background: var(--success);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-add-bottom:active {
    transform: scale(0.98);
}

.btn-scan {
    width: 100%;
    background: #9b59b6;
    color: white;
    border: none;
    padding: 14px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-scan:active {
    transform: scale(0.98);
}

/* Footer */
footer {
    background: var(--gray-light);
    padding: 16px;
    text-align: center;
    font-size: 13px;
    color: var(--gray-dark);
}

/* Mobile Optimization */
@media (max-width: 480px) {
    body {
        padding: 0;
        font-size: 85%; /* Уменьшаем общий масштаб на 15% */
    }

    .container {
        border-radius: 0;
        min-height: 100vh;
    }

    /* Compact form padding */
    #order-form {
        padding: 12px 10px;
    }

    /* Компактный инфо-блок */
    .info-box {
        padding: 5px 8px;
        margin-bottom: 8px;
        font-size: 9px;
        line-height: 1.25;
    }

    .info-box p {
        margin: 0 0 3px 0;
    }

    .info-box strong {
        font-size: 9px;
    }

    .info-box ol {
        padding-left: 12px;
        margin: 0;
    }

    .info-box li {
        margin-bottom: 1px;
        padding-left: 1px;
    }

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

    .form-group label {
        margin-bottom: 4px;
        font-size: 12px;
    }

    .form-group input {
        padding: 8px 10px;
    }

    /* Заголовок секции */
    .section-header {
        margin-bottom: 8px;
        padding-bottom: 6px;
    }

    .section-header h2 {
        font-size: 15px;
    }

    /* Keep compact grid layout on mobile */
    .line-fields {
        grid-template-columns: 70px 70px 60px 1fr 28px;
        gap: 3px; /* Еще меньше зазор */
    }

    .field-group input {
        padding: 3px 2px;
        font-size: 12px;
        height: auto;
        line-height: 1.2;
    }

    .field-group label {
        font-size: 9px;
        margin-bottom: 1px;
    }

    /* Минимальное расстояние между строками */
    .line-item {
        padding: 8px;
        margin-bottom: 3px; /* Было 6px, делаем 3px - почти склеены */
    }

    /* Компактные кнопки */
    .action-buttons {
        gap: 6px;
        margin-top: 12px;
    }

    .btn-submit {
        padding: 10px;
        font-size: 15px;
    }

    .btn-add-bottom {
        padding: 8px;
        font-size: 13px;
    }

    /* Компактный header */
    header {
        padding: 10px 12px;
    }

    header h1 {
        font-size: 16px;
    }

    /* Компактный footer */
    footer {
        padding: 12px;
        font-size: 11px;
    }
}
