:root {
    --primary: #0071bc;
    --primary-dark: #0a3a54;
    --secondary: #1d71b8;
    --light: #f8f9fa;
    --dark: #212529;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    --success: #198754;
    --success-dark: #157347;
    --danger: #dc3545;
    --border-radius: 8px;
    --box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    --transition: all 0.3s ease;
    --input-padding: 10px 12px;
    --input-height: 42px;
    --panel-padding: 24px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    line-height: 1.6;
    color: var(--gray-800);
    background: linear-gradient(135deg, #f5f7fa 0%, #e4edf5 100%);
    min-height: 100vh;
    padding: 20px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

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

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px 0;
}

h1 {
    font-size: clamp(1.8rem, 4vw, 2.2rem);
    color: var(--primary);
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    color: var(--gray-600);
    font-size: clamp(1rem, 2vw, 1.1rem);
    font-weight: 300;
}

.app-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

@media (max-width: 1024px) {
    .app-grid {
        grid-template-columns: 1fr;
    }
}

.card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    overflow: hidden;
    transition: var(--transition);
}

.card:hover {
    box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}

.card h2 {
    background: var(--primary);
    color: white;
    padding: 18px var(--panel-padding);
    font-size: 1.3rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

.form-content {
    padding: var(--panel-padding);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

@media (max-width: 600px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .form-group.full-width {
        grid-column: 1;
    }
}

.form-group {
    display: flex;
    flex-direction: column;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--dark);
    font-size: 0.95rem;
}

.required {
    color: var(--danger);
    font-weight: bold;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
textarea {
    width: 100%;
    padding: var(--input-padding);
    height: var(--input-height);
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 16px;
    transition: var(--transition);
    font-family: inherit;
}

input:focus,
textarea:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(29, 113, 184, 0.2);
}

input::placeholder {
    color: var(--gray-400);
}

textarea {
    min-height: 180px;
    resize: vertical;
    padding: 15px;
    font-family: monospace;
    font-size: 14px;
    line-height: 1.5;
    background: var(--gray-100);
}

.form-section {
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 24px;
    background: var(--gray-100);
}

.form-section legend {
    font-weight: 600;
    color: var(--dark);
    padding: 0 8px;
    font-size: 1rem;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 12px 0;
}

.radio-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    padding: 12px;
    border-radius: 6px;
    transition: var(--transition);
}

.radio-label:hover {
    background: white;
}

.radio-label input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.radio-custom {
    display: inline-block;
    width: 20px;
    height: 20px;
    min-width: 20px;
    border: 2px solid var(--primary);
    border-radius: 50%;
    position: relative;
    transition: var(--transition);
    margin-top: 2px;
}

.radio-label input[type="radio"]:checked + .radio-custom {
    background: var(--primary);
}

.radio-label input[type="radio"]:checked + .radio-custom::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    top: 4px;
    left: 4px;
}

.radio-label input[type="radio"]:focus-visible + .radio-custom {
    outline: 2px solid var(--secondary);
    outline-offset: 2px;
}

.radio-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.radio-text strong {
    font-size: 1rem;
    color: var(--dark);
}

.radio-text small {
    font-size: 0.85rem;
    color: var(--gray-600);
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 12px 0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: var(--transition);
}

.checkbox-label:hover {
    background: white;
}

.checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.checkbox-custom {
    display: inline-block;
    width: 20px;
    height: 20px;
    min-width: 20px;
    border: 2px solid var(--primary);
    border-radius: 4px;
    position: relative;
    transition: var(--transition);
    background: white;
}

.checkbox-custom::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 5px;
    border: 2px solid white;
    border-top: none;
    border-right: none;
    transform: rotate(-45deg);
    top: 4px;
    left: 3px;
    opacity: 0;
    transition: var(--transition);
}

input[type="checkbox"]:checked + .checkbox-custom {
    background: var(--primary);
    border-color: var(--primary);
}

input[type="checkbox"]:checked + .checkbox-custom::after {
    opacity: 1;
}

.help-text {
    margin-top: 12px;
    color: var(--gray-600);
    font-size: 0.9rem;
}

.field-error {
    margin-top: 6px;
    color: var(--danger);
    font-size: 0.85rem;
    min-height: 1em;
}

input[aria-invalid="true"],
textarea[aria-invalid="true"] {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.2);
}

.instructions {
    background: #e3f2fd;
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 24px;
    border-left: 4px solid var(--secondary);
}

.instructions h3 {
    font-size: 1rem;
    margin-bottom: 8px;
    color: var(--primary);
}

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

.instructions li {
    margin-bottom: 6px;
    line-height: 1.5;
    color: var(--gray-700);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: none;
    padding: 14px 28px;
    font-size: 1.05rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    font-family: inherit;
    text-decoration: none;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

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

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
    transform: none !important;
}

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

.btn.primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn.small {
    padding: 8px 16px;
    font-size: 0.9rem;
    width: auto;
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn.small:hover {
    background: var(--gray-300);
}

.preview-container {
    padding: 20px;
    margin: var(--panel-padding);
    margin-top: 20px;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    background: var(--gray-100);
    min-height: 300px;
    overflow-x: auto;
}

.signature-preview {
    margin: 0;
}

.placeholder {
    color: var(--gray-500);
    text-align: center;
    padding: 60px 20px;
    font-style: italic;
}

.code-section {
    padding: 0 var(--panel-padding) var(--panel-padding);
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--gray-200);
    flex-wrap: wrap;
    gap: 12px;
}

.code-label {
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 0;
}

footer {
    text-align: center;
    padding: 20px;
    color: var(--gray-600);
    font-size: 0.95rem;
    margin-top: 20px;
    border-top: 1px solid var(--gray-300);
}

.separator {
    margin: 0 8px;
}

.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--success);
    color: white;
    padding: 15px 25px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transform: translateX(calc(100% + 50px));
    transition: transform 0.3s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    max-width: 90vw;
}

.toast.show {
    transform: translateX(0);
}

.icon-settings::before,
.icon-eye::before,
.icon-copy::before,
.icon-check::before {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    vertical-align: middle;
}

.icon-settings::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='3'%3E%3C/circle%3E%3Cpath d='M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z'%3E%3C/path%3E%3C/svg%3E");
}

.icon-eye::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z'%3E%3C/path%3E%3Ccircle cx='12' cy='12' r='3'%3E%3C/circle%3E%3C/svg%3E");
}

.icon-copy::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='9' width='13' height='13' rx='2' ry='2'%3E%3C/rect%3E%3Cpath d='M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1'%3E%3C/path%3E%3C/svg%3E");
}

.icon-check::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
}

@media (max-width: 600px) {
    body {
        padding: 10px;
    }
    
    .card h2 {
        padding: 14px 16px;
        font-size: 1.1rem;
    }
    
    .form-content,
    .preview-container,
    .code-section {
        padding: 16px;
    }
    
    .instructions {
        margin: 16px 0;
        padding: 12px 16px;
    }
    
    .btn {
        padding: 12px 20px;
        font-size: 1rem;
    }
    
    .toast {
        bottom: 20px;
        right: 20px;
        left: 20px;
        max-width: calc(100vw - 40px);
    }
    
    .code-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .btn.small {
        width: 100%;
    }
}

*:focus-visible {
    outline: 2px solid var(--secondary);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: no-preference) {
    .card {
        animation: fadeInUp 0.4s ease-out;
    }
    
    @keyframes fadeInUp {
        from {
            opacity: 0;
            transform: translateY(20px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}
