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

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

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

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px;
    text-align: center;
}

header h1 {
    font-size: 3em;
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    font-size: 1.2em;
    opacity: 0.9;
}

main {
    padding: 40px;
}

.upload-section {
    margin-bottom: 30px;
}

.upload-area {
    border: 3px dashed #667eea;
    border-radius: 15px;
    padding: 60px 20px;
    text-align: center;
    background: #f8f9ff;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-area:hover {
    background: #f0f2ff;
    border-color: #764ba2;
}

.upload-area.dragover {
    background: #e8ebff;
    border-color: #764ba2;
    transform: scale(1.02);
}

.upload-content svg {
    color: #667eea;
    margin-bottom: 20px;
}

.upload-content h2 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.5em;
}

.upload-content p {
    color: #666;
    margin-bottom: 20px;
}

.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.file-list {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9ff;
    border-radius: 10px;
}

.file-list h3 {
    margin-bottom: 15px;
    color: #333;
}

.file-list ul {
    list-style: none;
    margin-bottom: 20px;
}

.file-item {
    padding: 10px;
    background: white;
    border-radius: 5px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.file-item span {
    flex: 1;
}

.file-item button {
    background: #dc3545;
    color: white;
    border: none;
    padding: 5px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
}

.result-section {
    margin-top: 30px;
}

.result-section h2 {
    margin-bottom: 20px;
    color: #333;
}

#result-content {
    margin-bottom: 30px;
}

.pdf-preview {
    border: 2px solid #ddd;
    border-radius: 10px;
    padding: 20px;
    background: #f8f9ff;
    text-align: center;
}

.pdf-preview iframe {
    width: 100%;
    height: 600px;
    border: none;
    border-radius: 5px;
}

.pdf-download {
    margin-top: 15px;
}

.pdf-download a {
    display: inline-block;
    padding: 12px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.pdf-download a:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* Стили для финальной кнопки "Скачать PDF" */
.pdf-download-final {
    text-align: center;
    margin-top: 30px;
    margin-bottom: 20px;
}

.btn-download-pdf {
    display: inline-block;
    padding: 14px 40px;
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1.1em;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.btn-download-pdf:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.5);
    background: linear-gradient(135deg, #45a049 0%, #4caf50 100%);
}

.payment-section {
    margin-top: 30px;
    padding: 30px;
    background: #f8f9ff;
    border-radius: 15px;
    border: 2px solid #667eea;
}

.payment-section h3 {
    margin-bottom: 20px;
    color: #333;
    text-align: center;
}

.tariffs {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.tariff-card {
    background: white;
    border: 2px solid #667eea;
    border-radius: 15px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 150px;
}

.tariff-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
    border-color: #764ba2;
}

.tariff-price {
    font-size: 2em;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 10px;
}

.tariff-days {
    color: #666;
    font-size: 1.1em;
}

.access-key-section {
    margin-top: 30px;
}

.access-key-section h4 {
    margin-bottom: 15px;
    color: #333;
}

.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.input-group input {
    flex: 1;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
}

.input-group input:focus {
    outline: none;
    border-color: #667eea;
}

.help-text {
    color: #666;
    font-size: 0.9em;
    margin-top: 5px;
}


.loading {
    text-align: center;
    padding: 40px;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 8px;
    margin-top: 20px;
    border: 1px solid #f5c6cb;
}

.success-message {
    background: #d4edda;
    color: #155724;
    padding: 15px;
    border-radius: 8px;
    margin-top: 20px;
    border: 1px solid #c3e6cb;
}

footer {
    background: #f8f9fa;
    padding: 30px;
    text-align: center;
    color: #666;
    font-size: 0.9em;
    border-top: 1px solid #e0e0e0;
}

footer .footer-content {
    max-width: 900px;
    margin: 0 auto;
}

footer p {
    margin-bottom: 10px;
}

footer .footer-links {
    margin: 15px 0;
}

footer .footer-links a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
}

footer .footer-links a:hover {
    color: #764ba2;
    text-decoration: underline;
}

footer .footer-info {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
    font-size: 0.85em;
}

footer .footer-info p {
    margin: 5px 0;
}

footer .footer-info a {
    color: #667eea;
    text-decoration: none;
}

footer .footer-info a:hover {
    text-decoration: underline;
}

/* Стили для модального окна кадрирования */
.crop-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    overflow: auto;
}

.crop-modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 0;
    border: 1px solid #888;
    border-radius: 15px;
    width: 90%;
    max-width: 900px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

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

.crop-modal-header h3 {
    margin: 0;
    color: white;
}

.crop-modal-close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    line-height: 30px;
    text-align: center;
}

.crop-modal-close:hover {
    opacity: 0.7;
}

.crop-modal-body {
    padding: 20px;
    max-height: 75vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.crop-modal-footer {
    padding: 20px;
    border-top: 1px solid #ddd;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-radius: 0 0 15px 15px;
}

#crop-container {
    width: 100%;
    max-width: 100%;
}

#crop-image {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        border-radius: 15px;
    }

    header {
        padding: 25px 20px;
    }

    header h1 {
        font-size: 2em;
    }

    .subtitle {
        font-size: 1em;
    }

    main {
        padding: 20px;
    }

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

    .upload-content h2 {
        font-size: 1.2em;
    }

    .upload-content svg {
        width: 48px;
        height: 48px;
    }

    .btn {
        padding: 12px 20px;
        font-size: 0.9em;
        width: 100%;
        margin-bottom: 10px;
    }

    .file-list {
        padding: 15px;
    }

    .pdf-preview {
        padding: 10px;
    }

    .pdf-preview iframe {
        height: 400px;
    }

    .tariffs {
        flex-direction: column;
        gap: 15px;
    }

    .tariff-card {
        width: 100%;
        padding: 20px;
    }

    .tariff-price {
        font-size: 1.5em;
    }

    .payment-section {
        padding: 20px;
        margin-top: 20px;
    }

    .payment-section h3 {
        font-size: 1.2em;
    }

    .input-group {
        flex-direction: column;
        gap: 10px;
    }

    .input-group input {
        width: 100%;
        font-size: 16px; /* Предотвращает зум на iOS */
    }

    .input-group button {
        width: 100%;
    }

    .crop-modal-content {
        width: 95%;
        margin: 2% auto;
    }

    .crop-modal-header {
        padding: 15px;
    }

    .crop-modal-header h3 {
        font-size: 1.1em;
    }

    .crop-modal-body {
        padding: 15px;
        max-height: 60vh;
    }

    .crop-modal-footer {
        padding: 15px;
        flex-direction: column;
    }

    .crop-modal-footer .btn {
        width: 100%;
        margin-bottom: 10px;
    }

    .pdf-download-final {
        margin-top: 20px;
    }

    .btn-download-pdf {
        width: 100%;
        padding: 14px 20px;
        font-size: 1em;
    }

    #crop-controls {
        padding: 15px;
    }

    #crop-controls button {
        width: 100%;
        margin-bottom: 10px;
    }

    #crop-controls p {
        font-size: 0.85em;
    }

    footer {
        padding: 20px;
        font-size: 0.85em;
    }
}

/* Адаптивность для очень маленьких экранов */
@media (max-width: 480px) {
    body {
        padding: 5px;
    }

    header {
        padding: 20px 15px;
    }

    header h1 {
        font-size: 1.5em;
    }

    .subtitle {
        font-size: 0.9em;
    }

    main {
        padding: 15px;
    }

    .upload-area {
        padding: 30px 10px;
    }

    .upload-content h2 {
        font-size: 1em;
    }

    .upload-content p {
        font-size: 0.9em;
    }

    .pdf-preview iframe {
        height: 300px;
    }

    .tariff-card {
        padding: 15px;
    }

    .tariff-price {
        font-size: 1.3em;
    }

    .payment-section {
        padding: 15px;
    }

    .crop-modal-content {
        width: 98%;
        margin: 1% auto;
    }

    .crop-modal-body {
        padding: 10px;
        max-height: 50vh;
    }
}

/* Блок ручного редактирования результата */
.edit-controls {
    border: 2px solid #2196F3;
    border-radius: 10px;
    padding: 20px;
    background: #f0f4f8;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-height: none;
    overflow: visible;
    transition: max-height 0.3s ease-out, padding 0.3s ease-out;
}

.edit-controls.collapsed {
    max-height: 0;
    padding: 0 20px;
    overflow: hidden;
    border: none;
    margin: 0;
}

.btn-toggle {
    padding: 10px 20px;
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 600;
    transition: background 0.3s ease;
}

.btn-toggle:hover {
    background: #1976D2;
}

.edit-controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.edit-control-item {
    margin-bottom: 20px;
}

.edit-control-item-full {
    margin-bottom: 20px;
    width: 100%;
}

.edit-controls-additional {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
}

.edit-control-item label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 0.95em;
}

.edit-control-label-center {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 0.95em;
    text-align: center;
}

.export-sub-label-center {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #333;
    font-size: 0.95em;
    text-align: center;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.slider {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #2196F3;
    cursor: pointer;
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #2196F3;
    cursor: pointer;
    border: none;
}

.slider-container span {
    min-width: 50px;
    text-align: right;
    font-size: 0.9em;
    color: #666;
    font-weight: 500;
}

.btn-auto {
    padding: 6px 12px;
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 500;
    transition: background 0.3s ease;
}

.btn-auto:hover {
    background: #1976D2;
}

.resolution-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.resolution-input-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

.resolution-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.9em;
}

.resolution-input-group span {
    font-size: 0.9em;
    color: #666;
    min-width: 25px;
}

.resolution-toggle-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 10px 0;
}

.toggle-label-text {
    font-size: 0.9em;
    color: #666;
    font-weight: 500;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.4s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #2196F3;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.edit-controls-apply {
    margin-top: 20px;
    text-align: center;
}

.btn-apply-main {
    padding: 12px 30px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: background 0.3s ease;
}

.btn-apply-main:hover {
    background: #45a049;
}

.preview-container {
    margin-top: 20px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.preview-container label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 0.95em;
}

.preview-wrapper {
    position: relative;
    display: inline-block;
    cursor: crosshair;
}

.preview-image {
    width: 100%;
    height: 100%;
    border-radius: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: block;
    object-fit: contain;
}

.preview-magnifier {
    position: absolute;
    left: 100%;
    top: 0;
    margin-left: 20px;
    width: 300px;
    height: 300px;
    border: 3px solid #2196F3;
    border-radius: 8px;
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    z-index: 1000;
    pointer-events: none;
}

.preview-magnifier img {
    position: absolute;
    max-width: none;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
}

/* Элементы управления перспективой */
.perspective-controls {
    width: 100%;
}

.perspective-row {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.perspective-control-item {
    flex: 1;
    min-width: 150px;
}

.perspective-horizontal-item {
    flex: 0 0 auto;
    width: 100%;
    max-width: 100%;
}

/* Ограничиваем ширину элементов горизонтали и вертикали, чтобы они были одинаковыми */
.perspective-row:first-child .perspective-horizontal-item {
    max-width: calc(50% - 15px);
}

.perspective-row:last-child .perspective-horizontal-item {
    max-width: calc(50% - 15px);
}

.perspective-control-item label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 0.95em;
}

/* Цветокоррекция */
.color-controls {
    width: 100%;
}

.color-control-row {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.color-control-item {
    flex: 1;
    min-width: 150px;
}

.color-control-item label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 0.95em;
}

/* Фильтры */
.filter-controls {
    width: 100%;
}

.filter-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-filter {
    padding: 8px 16px;
    background: #f5f5f5;
    color: #333;
    border: 2px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-filter:hover {
    background: #e0e0e0;
    border-color: #2196F3;
}

.btn-filter.active {
    background: #2196F3;
    color: white;
    border-color: #2196F3;
}

/* Автоматическая обработка и улучшение качества */
.auto-controls,
.quality-controls {
    width: 100%;
    text-align: center;
}

.auto-buttons,
.quality-buttons {
    display: inline-flex;
    gap: 10px;
    flex-wrap: nowrap;
    justify-content: center;
}

.btn-auto-action {
    padding: 10px 20px;
    background: #FF9800;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    transition: background 0.3s ease;
}

.btn-auto-action:hover {
    background: #F57C00;
}

/* Экспорт */
.export-controls {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    background: #fafafa;
}

.export-sub-label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #333;
    font-size: 0.95em;
}

.export-color-controls,
.export-filter-controls,
.export-buttons-container {
    margin-bottom: 20px;
}

.export-color-controls:last-child,
.export-filter-controls:last-child,
.export-buttons-container:last-child {
    margin-bottom: 0;
}

.export-filter-controls {
    text-align: center;
}

/* Маркеры для ручной коррекции перспективы */
.perspective-markers {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

.perspective-marker {
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: #FF0000;
    border: 2px solid #FFFFFF;
    pointer-events: none;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    font-size: 12px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    animation: markerPulse 0.5s ease-out;
}

@keyframes markerPulse {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.export-buttons-container {
    text-align: center;
}

.filter-controls {
    display: inline-block;
    width: auto;
}

.export-buttons {
    display: inline-flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-export {
    padding: 10px 20px;
    background: #9C27B0;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    transition: background 0.3s ease;
}

.btn-export:hover {
    background: #7B1FA2;
}

/* Адаптивность для блока редактирования */
@media (max-width: 768px) {
    .edit-controls-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .edit-controls {
        padding: 15px;
    }
    
    .preview-magnifier {
        display: none !important; /* Скрываем лупу на мобильных устройствах */
    }
}

