* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: #f0f2f5;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 16px;
}

.container {
    background: white;
    border-radius: 20px;
    padding: 20px;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.header {
    text-align: center;
    margin-bottom: 18px;
}
.header h1 {
    color: #1a237e;
    font-size: 22px;
}
.header p {
    color: #888;
    font-size: 13px;
}

.form-card {
    background: #f5f5f5;
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 14px;
}
.form-group {
    margin-bottom: 10px;
}
.form-group:last-child {
    margin-bottom: 0;
}
.form-group label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    color: #333;
    margin-bottom: 4px;
}
select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 15px;
    background: white;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}
select:focus {
    border-color: #1a237e;
    outline: none;
}

.camera-selector {
    display: flex;
    gap: 10px;
    margin: 10px 0 14px;
}
.cam-btn {
    flex: 1;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 12px;
    background: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    color: #666;
}
.cam-btn.active {
    border-color: #1a237e;
    background: #1a237e;
    color: white;
}

.video-wrapper {
    background: #1a1a2e;
    border-radius: 12px;
    overflow: hidden;
    min-height: 280px;
    position: relative;
}
#video {
    width: 100%;
    display: block;
    background: #1a1a2e;
    min-height: 280px;
}
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #1a1a2e;
    color: #888;
}
.loading-overlay span {
    font-size: 40px;
}
.loading-overlay p {
    color: #aaa;
    font-size: 15px;
    margin-top: 4px;
}
.loading-overlay small {
    color: #666;
    font-size: 12px;
}

.btn-capture {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 12px;
    background: #2e7d32;
    color: white;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 12px;
}
.btn-capture:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#preview {
    text-align: center;
    margin-top: 12px;
}
#previewImage {
    max-width: 100%;
    max-height: 300px;
    border-radius: 12px;
    border: 3px solid #2e7d32;
}
.preview-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}
.btn-secondary {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    background: #757575;
    color: white;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
}
.btn-success {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    background: #2e7d32;
    color: white;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
}
.btn-success:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#status {
    margin-top: 12px;
    padding: 10px;
    border-radius: 10px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    display: none;
}
#status.success {
    display: block;
    background: #e8f5e9;
    color: #2e7d32;
}
#status.error {
    display: block;
    background: #fce4ec;
    color: #c62828;
}
#status.loading {
    display: block;
    background: #e3f2fd;
    color: #0d47a1;
}

.footer {
    text-align: center;
    margin-top: 18px;
    padding-top: 12px;
    border-top: 1px solid #eee;
    color: #bbb;
    font-size: 11px;
}

/* MODAL */
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    justify-content: center;
    align-items: center;
    background: rgba(0,0,0,0.5);
}
.modal.active {
    display: flex !important;
}
.modal-box {
    background: white;
    padding: 30px 24px 24px;
    border-radius: 20px;
    max-width: 360px;
    width: 92%;
    text-align: center;
    border-top: 6px solid #2e7d32;
}
.modal-box.error {
    border-top-color: #c62828;
}
.modal-icon {
    font-size: 50px;
    display: block;
}
.modal-box h2 {
    color: #1a237e;
    font-size: 20px;
}
.modal-detail {
    background: #f5f5f5;
    padding: 12px;
    border-radius: 10px;
    margin: 12px 0 16px;
    text-align: left;
    font-size: 14px;
    line-height: 2;
    border-left: 4px solid #2e7d32;
}
.modal-btn {
    padding: 12px 44px;
    border: none;
    border-radius: 10px;
    background: #2e7d32;
    color: white;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}
.modal-btn.error {
    background: #c62828;
}

@media (max-width: 400px) {
    .container {
        padding: 14px;
    }
    .video-wrapper {
        min-height: 200px;
    }
    #video {
        min-height: 200px;
    }
}