.analytics-filter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.analytics-sort-link {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    color: inherit;
    white-space: nowrap;
    text-decoration: none;
}

.analytics-sort-link:hover,
.analytics-sort-link:focus-visible {
    color: var(--primary);
    text-decoration: underline;
}

.analytics-results th[aria-sort="ascending"],
.analytics-results th[aria-sort="descending"] {
    background: #dfe8f7;
}

.year-grid-wrap {
    display: grid;
    gap: 14px;
}

.year-grid-card {
    padding: 14px;
    border: 1px solid #dbe2ee;
    border-radius: 12px;
    background: #fff;
}

.year-grid-card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 6px 16px;
    margin-bottom: 10px;
}

.year-grid-year {
    font-size: 1.15rem;
    font-weight: 800;
}

.year-grid-questions {
    display: grid;
    grid-template-columns: repeat(20, minmax(0, 1fr));
    gap: 6px;
}

.year-grid-question {
    min-width: 0;
}

.year-grid-cell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    min-height: 34px;
    border: 1px solid transparent;
    border-radius: 7px;
    font-weight: 800;
    text-decoration: none;
}

.year-grid-question .year-grid-cell {
    width: 100%;
    min-height: 48px;
    flex-direction: column;
    line-height: 1.1;
}

.year-grid-question-no {
    font-size: 0.72rem;
    font-weight: 700;
}

.year-grid-symbol {
    font-size: 1rem;
}

.year-grid-attempt-dots {
    display: flex;
    gap: 3px;
    margin-top: 3px;
}

.year-grid-attempt-dot {
    width: 6px;
    height: 6px;
    border: 1px solid #94a3b8;
    border-radius: 50%;
    background: transparent;
}

.year-grid-attempt-dot.correct {
    border-color: #3b82f6;
    background: #3b82f6;
}

.year-grid-attempt-dot.wrong {
    border-color: #ec4899;
    background: #ec4899;
}

.year-grid-cell.unattempted {
    border-color: #cbd5e1;
    background: #e5e7eb;
    color: #374151;
}

.year-grid-cell.correct,
.year-grid-cell.mastered {
    border-color: #93c5fd;
    background: #dbeafe;
    color: #1e40af;
}

.year-grid-cell.progress-good {
    border-color: #7dd3fc;
    background: #e0f2fe;
    color: #075985;
}

.year-grid-cell.progress-low {
    border-color: #fdba74;
    background: #ffedd5;
    color: #9a3412;
}

.year-grid-cell.building {
    border-color: #cbd5e1;
    background: #f1f5f9;
    color: #475569;
}

.year-grid-cell.wrong {
    border-color: #f9a8d4;
    background: #fce7f3;
    color: #9d174d;
}

.year-grid-cell.needs-help {
    border-color: #ef4444;
    background: #fee2e2;
    color: #991b1b;
}

.year-grid-cell.missing {
    border-color: #e2e8f0;
    background: repeating-linear-gradient(135deg, #fff, #fff 5px, #f1f5f9 5px, #f1f5f9 10px);
    color: #94a3b8;
}

.year-grid-cell.out-of-syllabus {
    border-color: #000;
    background: #000;
    color: #fff;
}

.year-grid-cell.out-of-syllabus .year-grid-attempt-dot.empty {
    border-color: #cbd5e1;
}

.year-grid-cell:not(.missing):hover,
.year-grid-cell:not(.missing):focus-visible {
    outline: 3px solid #64748b;
    outline-offset: 1px;
}

.year-grid-summary {
    white-space: normal;
    text-align: right;
}

.year-grid-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.year-grid-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

@media (max-width: 900px) {
    .year-grid-card {
        padding: 10px;
    }

    .year-grid-questions {
        gap: 3px;
    }

    .year-grid-question .year-grid-cell {
        min-height: 44px;
    }

    .year-grid-question-no {
        font-size: 0.64rem;
    }
}

@media (max-width: 600px) {
    .year-grid-questions {
        grid-template-columns: repeat(10, minmax(0, 1fr));
        gap: 5px;
    }

    .year-grid-summary {
        width: 100%;
        text-align: left;
    }
}

.question-detail-modal {
    width: min(920px, calc(100% - 24px));
    max-height: calc(100vh - 24px);
    padding: 0;
    border: 0;
    border-radius: 14px;
    box-shadow: 0 24px 80px #0f172a55;
}

.question-detail-modal::backdrop {
    background: #0f172a99;
}

.question-modal-header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #dbe2ee;
    background: #fff;
}

.question-modal-header strong {
    font-size: 1.1rem;
}

.question-modal-close {
    min-width: 44px;
    min-height: 44px;
    padding: 6px;
    border-radius: 50%;
    background: #e6ebf5;
    color: #172033;
    font-size: 1.35rem;
}

.question-modal-body {
    padding: 18px;
}

.question-modal-body .question-image {
    max-height: 58vh;
}

.question-modal-stats {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 5px;
    margin: 9px 0 12px;
}

.question-modal-stat {
    min-width: 0;
    padding: 5px 3px;
    border-radius: 7px;
    background: #f3f6fb;
    text-align: center;
    line-height: 1.2;
}

.question-modal-stat .muted {
    display: block;
    overflow-wrap: anywhere;
    font-size: 0.76rem;
}

.question-modal-stat strong {
    display: block;
    margin-top: 2px;
    overflow-wrap: anywhere;
    font-size: 1.02rem;
    line-height: 1.15;
}

.question-modal-stat.mastery-status {
    border: 1px solid transparent;
}

.question-modal-stat.mastery-status.mastered {
    border-color: #86efac;
    background: #dcfce7;
    color: #166534;
}

.question-modal-stat.mastery-status.progress-good {
    border-color: #a7f3d0;
    background: #ecfdf5;
    color: #047857;
}

.question-modal-stat.mastery-status.progress-low {
    border-color: #f9a8d4;
    background: #fce7f3;
    color: #9d174d;
}

.question-modal-stat.mastery-status.wrong {
    border-color: #fda4af;
    background: #ffe4e6;
    color: #9f1239;
}

.question-modal-stat.mastery-status.needs-help {
    border-color: #ef4444;
    background: #fee2e2;
    color: #991b1b;
}

.question-modal-stat.mastery-status.building {
    border-color: #fcd34d;
    background: #fef3c7;
    color: #92400e;
}

.question-modal-stat.mastery-status.unattempted {
    border-color: #cbd5e1;
    background: #e5e7eb;
    color: #475569;
}

.question-modal-stat.mastery-status .muted {
    color: inherit;
}

.question-modal-history {
    margin-top: 16px;
}

.modal-loading {
    padding: 48px 16px;
    text-align: center;
    color: #657086;
}

body:has(.question-detail-modal[open]) {
    overflow: hidden;
}

@media (max-width: 600px) {
    .question-detail-modal {
        width: 100%;
        max-width: none;
        max-height: 96vh;
        margin: auto 0 0;
        border-radius: 14px 14px 0 0;
    }

    .question-modal-body {
        padding: 12px;
    }

    .question-modal-stats {
        grid-template-columns: repeat(6, minmax(0, 1fr));
        gap: 3px;
        margin-top: 7px;
    }

    .question-modal-stat {
        padding: 4px 1px;
    }

    .question-modal-stat .muted {
        font-size: 0.64rem;
    }

    .question-modal-stat strong {
        font-size: 0.86rem;
    }
}
