* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
        
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}
        
.title_card {
    background: linear-gradient(135deg, #6B46C1 0%, #9333EA 100%);
    color: white;
    text-align: center;
    padding: 30px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
        
.title_card h1 {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}
        
.title_card p {
    font-size: 16px;
    opacity: 0.9;
}
        
.container {
    max-width: 1400px;
    margin: 30px auto;
    padding: 0 20px;
}
        
.workflow-steps {
    display: flex;
    justify-content: space-around;
    margin-bottom: 30px;
    gap: 20px;
}
        
.step {
    background: white;
    padding: 15px 25px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: transform 0.3s ease;
}
        
.step:hover {
    transform: translateY(-5px);
}
        
.step-number {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
}
        
.step.completed .step-number {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}
        
.bigbox {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}
        
.box {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
        
.box:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}
        
.box h2 {
    color: #6B46C1;
    margin-bottom: 20px;
    font-size: 24px;
    border-bottom: 3px solid #E9D5FF;
    padding-bottom: 10px;
}
        
.upload-area {
    border: 3px dashed #D8B4FE;
    border-radius: 10px;
    padding: 30px;
    text-align: center;
    margin: 20px 0;
    transition: all 0.3s ease;
    cursor: pointer;
}
        
.upload-area:hover {
    border-color: #9333EA;
    background: #F5F3FF;
}
        
.upload-area.dragover {
    background: #E9D5FF;
    border-color: #6B46C1;
}
        
input[type="file"] {
    display: none;
}
        
.file-label {
    display: inline-block;
    padding: 12px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}
        
.file-label:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}
        
button {
    padding: 12px 30px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 10px 5px;
}
        
button:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}
        
button:disabled {
    background: #ccc;
    cursor: not-allowed;
}
        
.output-section {
    background: #F9FAFB;
    padding: 20px;
    border-radius: 10px;
    margin-top: 20px;
    min-height: 200px;
}
        
.status-message {
    padding: 15px;
    border-radius: 8px;
    margin: 10px 0;
    animation: slideIn 0.3s ease;
}
        
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
        
.status-message.success {
    background: #D1FAE5;
    border-left: 4px solid #10b981;
    color: #065F46;
}
        
.status-message.error {
    background: #FEE2E2;
    border-left: 4px solid #EF4444;
    color: #991B1B;
}
        
.status-message.info {
    background: #DBEAFE;
    border-left: 4px solid #3B82F6;
    color: #1E3A8A;
}
        
.prediction-card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin: 15px 0;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
        
.probability-bar {
    background: #E5E7EB;
    height: 50px;
    border-radius: 5px;
    overflow: hidden;
    margin: 10px 0;
}
        
.probability-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    padding: 0 10px;
    color: white;
    font-weight: 600;
    transition: width 0.5s ease;
}

/* Confusion matrix base styles */
.confusion-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: #fff;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.06);
}

.confusion-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 420px; /* ensures table stays readable on larger small screens */
}

.confusion-table th,
.confusion-table td {
    border: 1px solid #E6E6F0;
    padding: 12px 14px;
    text-align: center;
}

.confusion-table th {
    background: linear-gradient(135deg, #F3E8FF 0%, #E9D5FF 100%);
    color: #4C1D95;
    font-weight: 700;
}

.confusion-table td small {
    display: block;
    color: #6B7280;
    font-weight: 500;
}
        
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 10px;
    margin-top: 15px;
}
        
.feature-item {
    background: #F9FAFB;
    padding: 10px;
    border-radius: 5px;
    border-left: 3px solid #9333EA;
}
        
.feature-label {
    font-size: 12px;
    color: #6B7280;
    text-transform: uppercase;
}
        
.feature-value {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
}
        
.loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}
        
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
        
.model-results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
}
        
.metric-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
}
        
.metric-value {
    font-size: 32px;
    font-weight: bold;
    margin: 10px 0;
}
        
.metric-label {
    font-size: 14px;
    opacity: 0.9;
}
        
.row-input-section {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 20px 0;
}
        
input[type="number"] {
    padding: 12px;
    border: 2px solid #D8B4FE;
    border-radius: 8px;
    font-size: 16px;
    flex: 1;
    transition: border-color 0.3s ease;
}
        
input[type="number"]:focus {
    outline: none;
    border-color: #9333EA;
}

/* Responsive tweaks */
@media (max-width: 1200px) {
    .container { padding: 0 14px; }
    .title_card { padding: 22px 20px; }
    .box { padding: 20px; }
}

@media (max-width: 900px) {
    /* Keep the steps usable on medium screens by allowing horizontal scrolling.
       On narrower screens we'll stack them vertically (see 600px rules). */
    .workflow-steps {
        justify-content: flex-start;
        gap:8px;
        overflow-x: auto;
        padding-bottom: 8px; /* space for touch scrolling */
        -webkit-overflow-scrolling: touch;
    }
    /* Make each step a fixed minimum width so they are readable when scrolled horizontally */
    .workflow-steps .step {
        min-width: 200px;
        flex: 0 0 auto;
    }
    .step { padding:10px 12px; font-size:13px }
    .step-number { width:32px; height:32px; font-size:14px }
    .bigbox { grid-template-columns: 1fr; gap:18px; }
    .title_card { flex-direction:column; align-items:flex-start; gap:10px }
    .title_card .nav-actions { width:100%; display:flex; justify-content:flex-end }
    .file-label { padding:8px 12px }
    .upload-area { padding:14px }
    .file-label, button { font-size:14px; padding:10px 14px }
    .output-section { min-height:140px }
    .probability-bar { height:36px }
    .feature-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
    .row-input-section { flex-direction:column; align-items:stretch }
    input[type="number"] { width:100%; }

    /* Tablet: make confusion matrix scrollable with slightly larger min-width */
    .confusion-wrap { padding: 10px; }
    .confusion-table { min-width: 520px; }

    /* Prediction card tweaks for medium screens */
    .prediction-card { padding: 16px; }
    .probability-bar { height: 40px; }
    .probability-fill { padding: 0 8px; font-size: 14px; }
}

@media (max-width: 600px) {
    body { padding:16px 12px }
    .title_card h1 { font-size:20px }
    .title_card p { font-size:13px }
    .box { padding:16px }
    .upload-area { padding:12px }
    .file-label { width:100%; display:block; text-align:center }
    button { width:100%; margin:8px 0 }
    .model-results { grid-template-columns: 1fr 1fr }
    .metric-value { font-size:18px }
    .prediction-card { padding:12px }
    .probability-fill { font-size:12px }
    .confusion-table th, .confusion-table td { padding:8px }

    /* On small screens stack workflow steps vertically so they take full width */
    .workflow-steps {
        flex-direction: column;
        gap: 10px;
        overflow: visible;
        padding-bottom: 0;
    }
    .workflow-steps .step {
        width: 100%;
        min-width: unset;
        justify-content: flex-start;
    }
    .step-number { width:36px; height:36px; }

    /* Mobile: collapse confusion matrix spacing, allow horizontal scroll and readable font-sizes */
    .confusion-wrap {
        padding: 4px;
        margin-bottom: 12px;
    }
    .confusion-table {
        min-width: 320px;
        font-size: 10px;
    }
    .confusion-table th, .confusion-table td { padding: 8px 10px; }

    /* Make prediction cards full width and stack probability visuals */
    .prediction-card {
        width: 100%;
        padding: 12px;
        box-sizing: border-box;
    }
    .probability-bar { height: 28px; }
    .probability-fill { font-size: 12px; padding: 0 8px; }
    .feature-grid { grid-template-columns: 1fr; }
}

/* Accessibility: prefer larger tap targets when touch-enabled */
@media (pointer: coarse) {
    .file-label, button { padding:14px 18px; border-radius:12px }
}

