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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 40px 20px;
}

header {
    text-align: center;
    margin-bottom: 40px;
}

header h1 {
    font-size: 2rem;
    color: #1a3a5c;
}

.subtitle {
    color: #666;
    margin-top: 8px;
}

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #444;
}

.form-group input[type="text"] {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-group input[type="text"]:focus {
    outline: none;
    border-color: #1a3a5c;
    box-shadow: 0 0 0 3px rgba(26, 58, 92, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.drop-zone {
    border: 2px dashed #d0d5dd;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: #1a3a5c;
    background: rgba(26, 58, 92, 0.03);
}

.drop-zone.has-file {
    border-color: #16a34a;
    background: rgba(22, 163, 74, 0.04);
}

.drop-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.drop-zone p {
    color: #666;
    font-size: 14px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary {
    background: #1a3a5c;
    color: #fff;
    width: 100%;
}

.btn-primary:hover {
    background: #15304d;
}

.btn-download {
    background: #16a34a;
    color: #fff;
    display: inline-block;
    text-decoration: none;
    margin-right: 12px;
}

.btn-download:hover {
    background: #15803d;
}

/* Progress */
.progress-container {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-top: 20px;
}

/* Stage steps */
.stage-steps {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    position: relative;
}
.stage-steps::before {
    content: '';
    position: absolute;
    top: 14px;
    left: 0; right: 0;
    height: 2px;
    background: #e5e7eb;
    z-index: 0;
}
.stage-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    z-index: 1;
}
.stage-dot {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: #e5e7eb;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #999;
    transition: all 0.3s;
}
.stage-dot.active {
    background: #1a3a5c;
    color: #fff;
    box-shadow: 0 0 0 4px rgba(26,58,92,0.15);
    animation: pulse 1.5s infinite;
}
.stage-dot.done {
    background: #16a34a;
    color: #fff;
}
.stage-label {
    font-size: 11px;
    color: #999;
    white-space: nowrap;
}
.stage-label.active { color: #1a3a5c; font-weight: 600; }
.stage-label.done   { color: #16a34a; }

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(26,58,92,0.15); }
    50%       { box-shadow: 0 0 0 8px rgba(26,58,92,0.05); }
}

.progress-bar {
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #1a3a5c, #2563eb);
    border-radius: 4px;
    transition: width 0.5s ease;
}
.progress-fill.done { background: #16a34a; }

.progress-text {
    font-size: 13px;
    color: #666;
}

/* Result */
.result-container {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-top: 20px;
}

.result-container h3 {
    margin-bottom: 16px;
    color: #16a34a;
}

.result-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.email-form {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.email-form input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    font-size: 14px;
}

.btn-send {
    background: #1a3a5c;
    color: #fff;
    white-space: nowrap;
}

.error-message {
    color: #dc2626;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 16px;
    margin-top: 20px;
}

/* Document type segmented control */
.doc-type-group {
    display: flex;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    overflow: hidden;
}

.doc-type-option {
    flex: 1;
    cursor: pointer;
    text-align: center;
    padding: 10px 8px;
    background: #fff;
    border-right: 1px solid #d0d5dd;
    transition: background 0.15s, color 0.15s;
    user-select: none;
}

.doc-type-option:last-child {
    border-right: none;
}

.doc-type-option input[type="radio"] {
    display: none;
}

.doc-type-label {
    display: block;
    font-weight: 600;
    font-size: 0.95rem;
    color: #444;
    pointer-events: none;
}

.doc-type-hint {
    display: block;
    font-size: 0.72rem;
    color: #888;
    margin-top: 2px;
    pointer-events: none;
}

.doc-type-option.active {
    background: #1a3a5c;
}

.doc-type-option.active .doc-type-label {
    color: #fff;
}

.doc-type-option.active .doc-type-hint {
    color: #93bbdc;
}

.doc-type-option:not(.active):hover {
    background: #f0f4f8;
}

/* Dual-document download buttons */
.dual-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.btn-download-ps {
    background: #0e7490;
}

.btn-download-ps:hover {
    background: #0c6881;
}

/* Per-task log panel */
.log-panel {
    margin-top: 16px;
    background: #0f172a;
    border-radius: 6px;
    padding: 12px 14px;
    max-height: 220px;
    overflow-y: auto;
    font-family: "JetBrains Mono", "Fira Mono", monospace;
    font-size: 0.78rem;
}

.log-line {
    color: #94a3b8;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
}

.log-line:last-child {
    color: #e2e8f0;
}

.log-empty {
    color: #475569;
    font-size: 0.78rem;
    font-family: monospace;
}

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