:root {
    --primary-color: #5b2c6f; /* HASE Escolar Purple */
    --secondary-color: #8e44ad;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #c0392b;
    --text-color: #333;
    --bg-color: #f4f6f7;
    --white: #ffffff;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--white);
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

h1, h2, h3 {
    color: var(--primary-color);
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 20px;
    margin-bottom: 30px;
}

.btn {
    display: inline-block;
    padding: 10px 20px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border-radius: 4px;
    cursor: pointer;
    border: none;
    transition: background-color 0.3s ease;
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--white);
}

.btn-primary:hover {
    background-color: var(--secondary-color);
}

.upload-card {
    border: 2px dashed #bdc3c7;
    padding: 40px;
    text-align: center;
    border-radius: 8px;
    background-color: #fafafa;
    margin-top: 20px;
}

.upload-card input[type="file"] {
    display: block;
    margin: 20px auto;
}

.table-responsive {
    overflow-x: auto;
    margin-top: 20px;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

th, td {
    border: 1px solid #ddd;
    padding: 12px 15px;
    text-align: center;
}

th {
    background-color: var(--primary-color);
    color: var(--white);
}

.results-scroll {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: var(--white);
}

.results-matrix {
    width: max-content;
    min-width: 100%;
}

.results-matrix th {
    position: sticky;
    top: 0;
    z-index: 2;
}

.results-matrix th, .results-matrix td {
    vertical-align: middle;
}

.results-matrix .col-area {
    width: 80px;
    min-width: 80px;
}

.results-matrix .col-indicador {
    width: 260px;
    min-width: 260px;
    text-align: left;
    white-space: normal;
}

.results-matrix .col-promedio {
    width: 200px;
    min-width: 200px;
}

.results-matrix .student-col {
    min-width: 190px;
    max-width: 260px;
    white-space: normal;
    line-height: 1.2;
}

.results-matrix .sticky-area {
    position: sticky;
    left: 0;
    z-index: 4;
}

.results-matrix .sticky-indicador {
    position: sticky;
    left: 80px;
    z-index: 4;
}

.results-matrix .sticky-promedio {
    position: sticky;
    left: 340px;
    z-index: 4;
    box-shadow: 6px 0 10px rgba(0, 0, 0, 0.06);
}

.results-matrix td.sticky-area,
.results-matrix td.sticky-indicador {
    background: var(--white);
}

.results-matrix td.sticky-promedio:not(.status-inicio):not(.status-proceso):not(.status-satisfactorio):not(.risk-bajo):not(.risk-moderado):not(.risk-alto) {
    background: var(--white);
}

.status-inicio {
    background-color: #a2d9ce; /* Greenish */
    color: #0e6655;
    font-weight: bold;
}

.status-proceso {
    background-color: #73c6b6; /* Lighter Green */
    color: #0b5345;
    font-weight: bold;
}

.status-satisfactorio {
    background-color: #1abc9c; /* Dark Green */
    color: #fff;
    font-weight: bold;
}

.risk-bajo {
    background-color: #2ecc71;
    color: #fff;
    font-weight: bold;
}

.risk-moderado {
    background-color: #f1c40f;
    color: #333;
    font-weight: bold;
}

.risk-alto {
    background-color: #e74c3c;
    color: #fff;
    font-weight: bold;
}

.filter-container {
    margin-bottom: 20px;
}

.report-toolbar {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 18px;
}

.legend-card {
    flex: 0 0 300px;
    max-width: 300px;
}

.legend-card table {
    width: 100%;
}

.report-toolbar .filter-container {
    flex: 1 1 520px;
    min-width: 320px;
    margin-bottom: 0;
}

.filter-panel {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
    width: 100%;
    padding: 14px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: var(--white);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.filter-field {
    flex: 1 1 160px;
}

.filter-field label {
    display: block;
    font-weight: 700;
    margin-bottom: 6px;
    font-size: 13px;
    color: #374151;
}

.filter-panel select,
.filter-panel input[type="text"],
.filter-panel input[type="number"] {
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    color: #111827;
    outline: none;
}

.filter-panel select:focus,
.filter-panel input[type="text"]:focus,
.filter-panel input[type="number"]:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(91, 44, 111, 0.12);
}

.filter-field.filter-nivel select {
    min-width: 180px;
}

.filter-field.filter-grado select {
    min-width: 120px;
}

.filter-field.filter-seccion select {
    min-width: 120px;
}

.filter-field.filter-estudiante select {
    min-width: 260px;
}

.filter-field.filter-estudiante-lg select {
    min-width: 320px;
}

.filter-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-left: auto;
}

.filter-actions .btn {
    padding: 10px 16px;
    font-size: 14px;
    border-radius: 8px;
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 16px;
        border-radius: 10px;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .btn {
        width: 100%;
    }

    th, td {
        padding: 10px 10px;
        font-size: 14px;
    }

    .filter-panel {
        padding: 12px;
        gap: 10px;
    }

    .filter-field {
        width: 100%;
    }

    .filter-field.filter-nivel select,
    .filter-field.filter-grado select,
    .filter-field.filter-seccion select,
    .filter-field.filter-estudiante select,
    .filter-panel input[type="text"],
    .filter-panel input[type="number"] {
        min-width: 100%;
        width: 100%;
    }

    .filter-actions {
        width: 100%;
    }

    .filter-actions .btn {
        width: 100%;
    }

    .legend-card {
        flex: 1 1 100%;
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    body {
        padding: 8px;
    }

    .container {
        padding: 12px;
    }

    th, td {
        padding: 8px 8px;
        font-size: 13px;
    }
}
