* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Segoe UI', Tahoma, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}
.container {
    max-width: 1600px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    overflow: hidden;
}
.header {
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    color: white;
    padding: 30px;
    text-align: center;
}
.header h1 { font-size: 2rem; margin-bottom: 10px; }
.main-content {
    display: grid;
    grid-template-columns: 300px 1fr 1fr;
    gap: 25px;
    padding: 30px;
    min-height: 600px;
}

.models-panel {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
    height: fit-content;
}
.models-panel h3 {
    margin-bottom: 15px;
    color: #2c3e50;
    font-size: 1.1rem;
}
.model-section {
    background: white;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 10px;
    border-left: 4px solid #3498db;
}
.model-section h4 {
    font-size: 0.9rem;
    color: #2c3e50;
    margin-bottom: 10px;
    font-weight: 600;
}
.model-section select {
    width: 100%;
    padding: 8px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
}
.model-section select:focus {
    outline: none;
    border-color: #3498db;
}
.model-section small {
    display: block;
    margin-top: 6px;
    color: #7f8c8d;
    font-size: 0.75rem;
    line-height: 1.3;
}

.upload-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.panel-title {
    font-size: 1.3rem;
    color: #2c3e50;
    font-weight: 600;
    margin-bottom: 10px;
}
.upload-area {
    border: 3px dashed #bdc3c7;
    border-radius: 15px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 250px;
}
.upload-area:hover {
    border-color: #3498db;
    background: #f8f9fa;
}
.upload-icon { font-size: 3rem; margin-bottom: 15px; }
.upload-btn {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    padding: 12px 30px;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}
.upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}
.image-preview-box {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 15px;
    margin-top: 15px;
}
.image-preview-box h3 {
    margin-bottom: 12px;
    color: #2c3e50;
    font-size: 1.05rem;
    font-weight: 600;
}
.preview-image {
    width: 100%;
    border-radius: 10px;
    display: block;
}

.results-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.angle-result-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}
.angle-result-card h3 {
    font-size: 0.9rem;
    margin-bottom: 10px;
    opacity: 0.9;
}
.angle-value {
    font-size: 2rem;
    font-weight: 900;
    margin: 10px 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}
.angle-confidence {
    font-size: 0.85rem;
    opacity: 0.8;
}

.result-image-box {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 15px;
}
.result-image-box h3 {
    margin-bottom: 12px;
    color: #2c3e50;
    font-size: 1.05rem;
    font-weight: 600;
}
.result-image-box img {
    width: 100%;
    border-radius: 10px;
}

.color-legend {
    background: white;
    padding: 12px;
    border-radius: 8px;
    margin-top: 12px;
}
.color-legend h4 {
    font-size: 0.9rem;
    color: #2c3e50;
    margin-bottom: 8px;
}
.legend-items {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}
.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid #ddd;
}
.legend-highlight {
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px #333;
}

.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.result-card {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 15px;
    border-left: 5px solid #3498db;
}
.result-card.full-width {
    grid-column: 1 / -1;
}
.result-card h4 {
    margin-bottom: 10px;
    color: #2c3e50;
    font-size: 1rem;
}
.result-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
}

/* Patient Form Styles */
.patient-panel {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
}
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 15px;
}
.full-width {
    grid-column: 1 / -1;
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #34495e;
}
.form-group label span {
    color: #e74c3c;
}
.form-group input, .form-group select, .form-group textarea {
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.9rem;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: #3498db;
}
.save-section {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 2px solid #eee;
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}
.save-btn {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    color: white;
    padding: 14px 40px;
    border: none;
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.save-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(46, 204, 113, 0.4);
}
.save-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    opacity: 0.7;
}
.save-btn .icon { font-size: 1.2rem; }

.export-btn {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    padding: 14px 40px;
    border: none;
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.export-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}
.export-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    opacity: 0.7;
}
.export-btn .icon { font-size: 1.2rem; }
.confidence {
    font-size: 0.85rem;
    color: #7f8c8d;
    margin-top: 5px;
}
.badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 15px;
    font-weight: 600;
    font-size: 0.9rem;
}
.badge-success { background: #d4edda; color: #155724; }
.badge-danger { background: #f8d7da; color: #721c24; }
.severity-card { border-left-color: #e74c3c; }
.severity-badge {
    padding: 8px 16px;
    border-radius: 20px;
    color: white;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.9rem;
}
.severity-details {
    margin-top: 10px;
    font-size: 0.9rem;
    color: #555;
    line-height: 1.5;
}
.severity-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
}
.stat-box {
    background: white;
    padding: 10px;
    border-radius: 8px;
    text-align: center;
}
.stat-label {
    font-size: 0.75rem;
    color: #7f8c8d;
    margin-bottom: 4px;
}
.stat-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: #2c3e50;
}
.loading {
    text-align: center;
    padding: 40px;
    display: none;
}
.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.error {
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 10px;
    margin: 15px 0;
    display: none;
}
#fileInput { display: none; }
.no-results-message {
    text-align: center;
    color: #7f8c8d;
    padding: 60px 20px;
    font-size: 1rem;
}
.info-badge {
    background: #e3f2fd;
    color: #1976d2;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    margin-top: 8px;
    display: block;
    line-height: 1.4;
}
.measurement-main {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    margin-bottom: 12px;
}
.measurement-value {
    font-size: 2.5rem;
    font-weight: 900;
    margin: 10px 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}
.measurement-label {
    font-size: 0.9rem;
    opacity: 0.9;
}
.measurement-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.detail-box {
    background: white;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
}
.detail-label {
    font-size: 0.75rem;
    color: #7f8c8d;
    margin-bottom: 4px;
}
.detail-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #2c3e50;
}

/* Modal Styles - Expanded */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(12px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 1000px;
    max-height: 95vh;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3);
    overflow-y: auto;
    transform: scale(0.9) translateY(30px);
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
}

.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
}

.modal-header {
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    color: white;
    padding: 20px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}

.modal-header h2 {
    font-size: 1.4rem;
    font-weight: 800;
}

.close-modal {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-modal:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.modal-body {
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

/* Image Grid in Modal */
.modal-images-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.modal-img-box {
    background: #f1f3f5;
    padding: 10px;
    border-radius: 12px;
    text-align: center;
}

.img-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    color: #495057;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.modal-img-box img {
    width: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* Details Grid in Modal */
.modal-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.modal-detail-card {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    border: 1px solid #e9ecef;
}

.modal-detail-card.highlight {
    background: linear-gradient(135deg, #f0f7ff 0%, #e3f2fd 100%);
    border-color: #bbdefb;
}

.modal-detail-card .label {
    font-size: 0.8rem;
    color: #6c757d;
    font-weight: 600;
    margin-bottom: 5px;
}

.modal-detail-card .value {
    font-size: 1.25rem;
    font-weight: 800;
    color: #2c3e50;
}

.modal-legend {
    background: white;
    padding: 20px;
    border-radius: 16px;
    border: 1px solid #dee2e6;
}

.modal-legend h4 {
    margin-bottom: 12px;
    font-size: 0.95rem;
}

.modal-advice {
    background: #fff9db;
    padding: 20px;
    border-radius: 16px;
    border-left: 5px solid #fcc419;
    color: #856404;
    font-size: 1rem;
    line-height: 1.6;
}

.modal-footer {
    padding: 0 30px 40px;
    display: flex;
    justify-content: center;
}

.modal-btn-primary {
    background: linear-gradient(135deg, #228be6, #1c7ed6);
    color: white;
    border: none;
    padding: 16px 60px;
    border-radius: 35px;
    font-size: 1.2rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 10px 25px -5px rgba(34, 139, 230, 0.4);
    transition: all 0.3s;
}

.modal-btn-primary:hover {
    transform: translateY(-4px);
    box-shadow: 0 15px 30px -5px rgba(34, 139, 230, 0.5);
}

/* Responsive Modal */
@media (max-width: 768px) {
    .modal-images-grid {
        grid-template-columns: 1fr;
    }
    .modal-content {
        max-height: 100vh;
        border-radius: 0;
    }
    .modal-overlay {
        padding: 0;
    }
}
