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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    color: white;
    padding: 40px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

header p {
    font-size: 1.1em;
    opacity: 0.9;
}

.upload-section {
    padding: 40px;
}

.upload-section h2 {
    margin-bottom: 30px;
    color: #333;
}

.upload-area {
    border: 3px dashed #667eea;
    border-radius: 10px;
    padding: 60px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8f9ff;
}

.upload-area:hover {
    border-color: #764ba2;
    background: #f0f2ff;
}

.upload-area.dragover {
    background: #e8ebff;
    border-color: #764ba2;
}

.upload-icon {
    font-size: 4em;
    margin-bottom: 20px;
}

.upload-hint {
    color: #666;
    font-size: 0.9em;
    margin-top: 10px;
}

.model-selection {
    display: flex;
    gap: 40px;
    justify-content: center;
    margin: 30px 0;
    padding: 20px;
    background: #f8f9ff;
    border-radius: 10px;
}

.selection-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.selection-group h3 {
    font-size: 0.9em;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.model-selection label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
}

.model-selection input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.disabled-option {
    opacity: 0.4;
    cursor: not-allowed !important;
}

.disabled-option input[type="radio"] {
    cursor: not-allowed !important;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin: 30px 0;
}

.preview-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: #f5f5f5;
    aspect-ratio: 1;
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-item .remove-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(255,255,255,0.9);
    border: none;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: background 0.3s;
}

.preview-item .remove-btn:hover {
    background: #ff4444;
    color: white;
}

.action-buttons {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.clear-btn {
    flex: 0 0 150px;
    padding: 18px;
    background: #ff4444;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.clear-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(255,68,68,0.4);
    background: #cc0000;
}

.analyze-btn {
    flex: 1;
    padding: 18px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.analyze-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102,126,234,0.4);
}

.analyze-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.results-section {
    padding: 40px;
    border-top: 1px solid #eee;
}

.export-pdf-btn {
    padding: 12px 24px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.export-pdf-btn:hover {
    background: #1d4ed8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.hidden {
    display: none !important;
}

.spinner {
    text-align: center;
    padding: 40px;
}

.spinner-icon {
    width: 50px;
    height: 50px;
    margin: 0 auto 20px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Results styles */
.portfolio-overview {
    background: #f8f9ff;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 30px;
}

.portfolio-overview h3 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.4em;
}

.overview-table {
    width: 100%;
    border-collapse: collapse;
}

.overview-table th,
.overview-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.overview-table th {
    background: #667eea;
    color: white;
    font-weight: 600;
}

.overview-table tr:hover {
    background: #f5f5ff;
}

.risk-high {
    color: #ff4444;
    font-weight: 600;
}

.risk-moderate {
    color: #ff8800;
    font-weight: 600;
}

.risk-low {
    color: #00aa00;
    font-weight: 600;
}

.clusters {
    background: #fff5f5;
    border: 2px solid #ffdddd;
    border-radius: 10px;
    padding: 25px;
    margin: 30px 0;
}

.clusters h3 {
    color: #ff4444;
    margin-bottom: 15px;
}

.cluster-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.cluster-item h4 {
    color: #ff8800;
    margin-bottom: 10px;
}

.cluster-images {
    list-style: none;
    padding-left: 20px;
}

.cluster-images li {
    padding: 5px 0;
    color: #666;
}

.health-score {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 10px;
    padding: 25px;
    margin: 30px 0;
}

.health-score h3 {
    margin-bottom: 20px;
    font-size: 1.4em;
}

.health-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.metric {
    background: rgba(255,255,255,0.2);
    padding: 15px;
    border-radius: 8px;
}

.metric-label {
    font-size: 0.9em;
    opacity: 0.9;
    margin-bottom: 5px;
}

.metric-value {
    font-size: 1.8em;
    font-weight: 700;
}

.recommendation {
    background: white;
    color: #333;
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
}

.recommendation h4 {
    color: #667eea;
    margin-bottom: 10px;
}

.no-clusters {
    background: #f0fff0;
    border: 2px solid #90ee90;
    color: #00aa00;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    margin: 30px 0;
    font-weight: 600;
}

/* Thumbnail hover zoom */
.thumbnail-container {
    position: relative;
    display: inline-block;
}

.thumbnail-zoom {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 12px;
    vertical-align: middle;
    cursor: pointer;
    transition: all 0.2s ease;
}

.thumbnail-zoom:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.thumbnail-enlarged {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    border: 3px solid white;
    max-width: 400px;
    max-height: 400px;
    object-fit: contain;
    display: none;
}

.thumbnail-zoom:hover + .thumbnail-enlarged {
    display: block;
}