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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #eaeaea;
    min-height: 100vh;
    padding: 10px;
    color: #333;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    padding: 15px;
    text-align: center;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.header p {
    font-size: 0.9rem;
    opacity: 0.9;
}

.controls {
    padding: 15px;
    background: #f8f9fa;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.form-group {
    background: white;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.form-group:hover {
    transform: translateY(-1px);
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 4px;
    color: #495057;
    font-size: 0.8rem;
}

.form-group select,
.form-group input[type="number"] {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    background: white;
}

.form-group select:focus,
.form-group input[type="number"]:focus {
    outline: none;
    border-color: #4facfe;
    box-shadow: 0 2px 6px rgba(79, 172, 254, 0.2);
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #4facfe;
}

.checkbox-group label {
    margin-bottom: 0;
    cursor: pointer;
    font-size: 0.8rem;
}

.input-section {
    background: white;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 15px;
}

.input-section label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: #495057;
    font-size: 0.85rem;
}

textarea {
    width: 100%;
    height: 120px;
    font-family: monospace;
    padding: 8px;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    font-size: 0.8rem;
    line-height: 1.3;
    resize: vertical;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

textarea:focus {
    outline: none;
    border-color: #4facfe;
    box-shadow: 0 2px 6px rgba(79, 172, 254, 0.2);
}

.button-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-width: 80px;
    justify-content: center;
}

.btn-primary {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

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

.btn:hover {
    transform: translateY(-1px);
}

#preview {
    display: none;
    padding: 15px;
    background: white;
}

.preview-header {
    text-align: center;
    margin-bottom: 15px;
    padding: 10px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border-radius: 6px;
}

.preview-header h3 {
    font-size: 1rem;
    margin-bottom: 5px;
}

.preview-header p {
    font-size: 0.8rem;
}

.page {
    page-break-after: always;
    position: relative;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 10px;
    box-sizing: border-box;
}

.page-content {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

.watermark {
    position: absolute;
    white-space: nowrap;
    color: #000;
    transform-origin: center;
    pointer-events: none;
    user-select: none;
    z-index: 1;
}

.debug-border {
    position: absolute;
    border: 1px dashed #ff6b6b;
    background: rgba(255, 107, 107, 0.05);
    pointer-events: none;
    z-index: 2;
}

.loading {
    display: none;
    text-align: center;
    padding: 30px;
    color: #6c757d;
}

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

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

@media print {
    @page {
        margin: 5mm !important;
        size: auto;
    }

    .page {
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        page-break-after: always !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
        height: 100vh !important;
        max-height: 100vh !important;
    }

    .page:last-child {
        page-break-after: avoid !important;
    }

    body {
        margin: 0 !important;
        padding: 0 !important;
        background: white !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .container {
        margin: 0 !important;
        padding: 0 !important;
        max-width: none !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        background: white !important;
    }

    #controls, #header, .loading, .preview-header {
        display: none !important;
    }

    #preview {
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
        background: white !important;
    }

    .page-content {
        overflow: hidden !important;
        position: relative !important;
    }

    .watermark {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        overflow: hidden !important;
    }
}

@media (max-width: 768px) {
    body {
        padding: 5px;
    }

    .header h1 {
        font-size: 1.2rem;
    }

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

    .button-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}
