* { box-sizing: border-box; }
body { margin: 0; padding: 0; background: #f4f7fc; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
.container { max-width: 900px; margin: 0 auto; background: #fff; padding: 20px 16px; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,0.08); }
h1 { font-size: 24px; color: #1a5276; border-bottom: 3px solid #1a5276; padding-bottom: 10px; margin-top: 0; }
.lang-selector { margin-bottom: 16px; }
.lang-selector select { padding: 8px 12px; border-radius: 6px; border: 1px solid #ccc; font-size: 16px; width: 100%; max-width: 200px; }
.stepper-wrapper { display: flex; justify-content: space-between; margin: 20px 0 30px; position: relative; flex-wrap: wrap; gap: 6px; }
.stepper-wrapper::before { content: ''; position: absolute; top: 18px; left: 10%; right: 10%; height: 2px; background: #dce1e8; z-index: 0; }
.stepper-item { display: flex; flex-direction: column; align-items: center; flex: 1 1 50px; position: relative; z-index: 1; cursor: pointer; min-width: 40px; }
.step-counter { width: 32px; height: 32px; border-radius: 50%; background: #dce1e8; color: #7f8c8d; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; transition: 0.3s; }
.stepper-item.active .step-counter { background: #1a5276; color: #fff; box-shadow: 0 0 0 3px rgba(26,82,118,0.2); }
.stepper-item.completed .step-counter { background: #27ae60; color: #fff; }
.step-label { margin-top: 4px; font-size: 11px; color: #7f8c8d; text-align: center; line-height: 1.2; max-width: 60px; }
.stepper-item.active .step-label { color: #1a5276; font-weight: 600; }
.stepper-item.completed .step-label { color: #27ae60; }

.form-group { display: flex; flex-direction: column; margin-bottom: 14px; }
.form-group label { font-weight: 600; color: #2c3e50; margin-bottom: 4px; font-size: 15px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 10px 12px; border: 1px solid #dce1e8; border-radius: 6px; font-size: 16px; background: #fafbfc; transition: border 0.2s; box-sizing: border-box; }
.form-group textarea { min-height: 80px; resize: vertical; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: #1a5276; outline: none; background: #fff; box-shadow: 0 0 0 3px rgba(26,82,118,0.15); }
.field-error { color: #dc3545; font-size: 14px; margin-top: 4px; display: none; }
.field-error.show { display: block; }
#loan_limit_info { font-size: 14px; color: #1a5276; font-weight: 500; }
#formatted_amount { font-weight: bold; }

@media (min-width: 769px) {
    .form-group { flex-direction: row; align-items: center; }
    .form-group label { width: 180px; flex-shrink: 0; margin-right: 12px; margin-bottom: 0; text-align: left; }
    .form-group input, .form-group select, .form-group textarea { flex: 1; width: auto; }
    .field-error { margin-left: 192px;color:red; }
}

.profile-capture { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.profile-capture .video-container { flex: 1 1 280px; min-width: 200px; }
.profile-capture .video-container video { width: 100%; height: auto; background: #000; border-radius: 6px; display: block; }
.profile-capture .preview-container { flex: 1 1 150px; text-align: center; min-height: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.profile-capture .preview-container img { max-width: 100%; border: 2px solid #ccc; border-radius: 8px; display: none; max-height: 180px; }
.profile-capture .preview-container .preview-label { font-size: 14px; color: #555; margin-bottom: 6px; }

.id-capture-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.id-capture-row .video-wrapper { flex: 1 1 280px; position: relative; background: #000; border-radius: 6px; overflow: hidden; }
.id-capture-row .video-wrapper video { width: 100%; height: auto; display: block; background: #000; }
.id-capture-row .video-wrapper .selection-box {
    position: absolute;
    border: 2px dashed #ff0;
    background: rgba(255,255,0,0.15);
    display: none;
    pointer-events: auto;
    z-index: 10;
    box-sizing: border-box;
    cursor: move;
}
.id-capture-row .video-wrapper .selection-box .handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #ff0;
    border: 1px solid #000;
    z-index: 15;
}
.id-capture-row .video-wrapper .selection-box .handle-tl { top: -5px; left: -5px; cursor: nw-resize; }
.id-capture-row .video-wrapper .selection-box .handle-tr { top: -5px; right: -5px; cursor: ne-resize; }
.id-capture-row .video-wrapper .selection-box .handle-bl { bottom: -5px; left: -5px; cursor: sw-resize; }
.id-capture-row .video-wrapper .selection-box .handle-br { bottom: -5px; right: -5px; cursor: se-resize; }
.id-capture-row .video-wrapper .selection-box .handle-t { top: -5px; left: 50%; transform: translateX(-50%); cursor: n-resize; }
.id-capture-row .video-wrapper .selection-box .handle-b { bottom: -5px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.id-capture-row .video-wrapper .selection-box .handle-l { top: 50%; left: -5px; transform: translateY(-50%); cursor: w-resize; }
.id-capture-row .video-wrapper .selection-box .handle-r { top: 50%; right: -5px; transform: translateY(-50%); cursor: e-resize; }
.id-capture-row .video-wrapper .selection-box.crop-ready {
    border: 3px solid #27ae60;
    background: rgba(39,174,96,0.15);
}
.id-capture-row .preview-container { flex: 1 1 150px; text-align: center; min-height: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.id-capture-row .preview-container .preview-label { font-size: 14px; color: #555; margin-bottom: 6px; }
.id-capture-row .preview-container img { max-width: 100%; border: 2px solid #ccc; border-radius: 8px; display: none; max-height: 150px; }
.id-capture-row .preview-container .status { font-size: 14px; color: #27ae60; font-weight: 500; margin-top: 4px; }
.id-capture-row .preview-container .reset-btn { background: #e74c3c; color: #fff; border: none; padding: 4px 12px; border-radius: 4px; cursor: pointer; font-size: 13px; margin-top: 6px; }
.id-capture-row .preview-container .reset-btn:hover { background: #c0392b; }
.camera-section { margin-bottom: 20px; }
.camera-section .hint { font-size: 14px; color: #555; margin-top: 12px; clear: both; }

.btn { display: inline-block; background: #1a5276; color: #fff; padding: 10px 20px; border: none; border-radius: 6px; font-size: 16px; font-weight: 600; cursor: pointer; transition: background 0.2s; text-align: center; text-decoration: none; width: auto; }
.btn:hover { background: #154360; }
.btn-secondary { background: #6c757d; }
.btn-secondary:hover { background: #5a6268; }
.btn-success { background: #28a745; }
.btn-success:hover { background: #218838; }
.btn-danger { background: #dc3545; }
.btn-danger:hover { background: #c82333; }
.step-nav { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.step-nav .btn { flex: 1 1 120px; min-width: 100px; }
.signature-card { max-width: 450px; margin: 20px auto; background: linear-gradient(145deg, #f8f9fa, #e9ecef); border-radius: 16px; padding: 20px 16px 24px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); border: 1px solid #ced4da; }
.signature-card .card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 14px; color: #495057; text-transform: uppercase; letter-spacing: 1px; }
.signature-card .card-header .card-label { font-weight: 600; }
.signature-card .card-header .card-logo { font-size: 18px; font-weight: 700; color: #1a5276; }
.signature-card .signature-area { background: #fff; border: 2px solid #ced4da; border-radius: 10px; padding: 4px; margin: 8px 0 12px; }
.signature-card .signature-area canvas { display: block; width: 100%; height: 100px; background: #fff; border-radius: 6px; touch-action: none; }
.signature-card .sig-actions { margin-top: 12px; display: flex; gap: 10px; justify-content: center; }
.preview-page { max-width: 700px; margin: 20px auto; background: #fff; padding: 20px; border: 1px solid #ddd; box-shadow: 0 0 10px rgba(0,0,0,0.05); overflow-x: auto; }
.preview-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 15px; }
.preview-table td { padding: 8px 10px; border-bottom: 1px solid #eee; }
.preview-table td:first-child { font-weight: bold; width: 35%; }
.preview-table img { max-width: 80px; }
.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; }
.alert-error { background: #fde8e8; color: #a93226; border-left: 5px solid #c0392b; }

.lang-switcher { text-align: right; margin-bottom: 15px; }
.lang-switcher a { display: inline-block; margin-left: 8px; padding: 4px 10px; background: #eee; border-radius: 4px; text-decoration: none; color: #333; font-size: 14px; font-weight: 600; }
.lang-switcher a.active { background: #1a5276; color: #fff; }
.lang-switcher a:hover { background: #dce1e8; }

@media (max-width: 768px) {
    .container { padding: 12px; }
    h1 { font-size: 20px; }
    .stepper-wrapper { gap: 2px; }
    .step-counter { width: 28px; height: 28px; font-size: 12px; }
    .step-label { font-size: 9px; max-width: 40px; }
    .form-group label { font-size: 14px; }
    .btn { padding: 12px; font-size: 16px; width: 100%; }
    .step-nav .btn { flex: 1 1 100%; }
    .profile-capture, .id-capture-row { flex-direction: column; align-items: stretch; }
    .profile-capture .video-container, .id-capture-row .video-wrapper { flex: 1 1 auto; }
    .profile-capture .preview-container, .id-capture-row .preview-container { flex: 1 1 auto; min-height: 100px; }
    .signature-card { max-width: 100%; padding: 16px; }
    .preview-page { padding: 12px; }
    .preview-table { font-size: 13px; }
    .preview-table td { padding: 6px 8px; }
    .id-capture-row .video-wrapper { max-width: 100%; }
    .id-capture-row .preview-container img { max-height: 120px; }
}
@media (max-width: 400px) {
    .stepper-wrapper { justify-content: center; }
    .stepper-item { flex: 0 0 auto; margin: 0 4px; }
}
