.gradebook-page {
    --gradebook-ink: #172b47;
    --gradebook-muted: #607089;
    --gradebook-line: #deddd8;
    --gradebook-soft-line: #ebe9e4;
    --gradebook-surface: #ffffff;
    --gradebook-soft: #f8f7f4;
    --gradebook-green: #1f7a59;
    --gradebook-amber: #9a6215;
    --gradebook-red: #a8483f;
    --gradebook-blue: #2d5e9e;
    background: #f4f2ee;
}

.gradebook-page .app-workspace > main {
    view-transition-name: app-page-content;
}

.gradebook-page .gradebook-layout {
    display: grid;
    gap: 22px;
    width: min(100%, 1460px);
    margin: 0 auto;
    padding: clamp(30px, 4vw, 58px) clamp(24px, 4vw, 56px) 64px;
    color: var(--gradebook-ink);
}

.gradebook-back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    color: #52647d;
    font-weight: 750;
    text-decoration: none;
}

.gradebook-back-link::before {
    content: "←";
    font-size: 1.05em;
    transition: transform 160ms ease;
}

.gradebook-back-link:hover,
.gradebook-back-link:focus-visible {
    color: var(--gradebook-ink);
}

.gradebook-back-link:hover::before,
.gradebook-back-link:focus-visible::before {
    transform: translateX(-3px);
}

.gradebook-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--gradebook-line);
}

.gradebook-header__copy {
    display: grid;
    gap: 8px;
    max-width: 860px;
}

.gradebook-header .eyebrow {
    margin: 0;
    color: #4f6380;
    letter-spacing: .13em;
}

.gradebook-header h1 {
    margin: 0;
    color: var(--gradebook-ink);
    font-size: clamp(2.45rem, 4vw, 4.35rem);
    line-height: .98;
    letter-spacing: -.055em;
}

.gradebook-header .intro {
    max-width: 70ch;
    margin: 4px 0 0;
    color: var(--gradebook-muted);
    font-size: clamp(1rem, 1.3vw, 1.18rem);
    line-height: 1.55;
}

.gradebook-header__actions {
    flex: 0 0 auto;
}

.gradebook-header__actions .secondary-button {
    min-height: 44px;
    border-color: #d7d4cd;
    background: rgba(255, 255, 255, .7);
    color: var(--gradebook-ink);
    box-shadow: none;
}

.gradebook-status:empty {
    display: none;
}

.gradebook-status:not(:empty) {
    margin: 0;
}

.gradebook-workspace {
    overflow: hidden;
    border: 1px solid var(--gradebook-line);
    border-radius: 20px;
    background: var(--gradebook-surface);
    box-shadow: 0 18px 48px rgba(35, 39, 45, .06);
}

.gradebook-section-heading {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 28px;
    padding: 28px 30px 22px;
}

.gradebook-section-heading h2,
.gradebook-section-heading p {
    margin: 0;
}

.gradebook-section-heading h2 {
    color: var(--gradebook-ink);
    font-size: clamp(1.5rem, 2vw, 2rem);
    letter-spacing: -.03em;
}

.gradebook-section-heading p {
    max-width: 78ch;
    margin-top: 7px;
    color: var(--gradebook-muted);
    line-height: 1.55;
}

.gradebook-live-state {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    margin-top: 4px;
    color: #476258;
    font-size: .82rem;
    font-weight: 800;
}

.gradebook-live-state > span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2b9b72;
    box-shadow: 0 0 0 4px #e5f5ef;
}

.gradebook-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin: 0 30px 26px;
    border: 1px solid var(--gradebook-soft-line);
    border-radius: 14px;
    background: var(--gradebook-soft);
}

.gradebook-summary-card {
    display: grid;
    align-content: center;
    gap: 5px;
    min-height: 108px;
    padding: 20px 22px;
    border-right: 1px solid var(--gradebook-soft-line);
}

.gradebook-summary-card:last-child {
    border-right: 0;
}

.gradebook-summary-card__label {
    color: var(--gradebook-muted);
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .035em;
    text-transform: uppercase;
}

.gradebook-summary-card__value {
    color: var(--gradebook-ink);
    font-size: clamp(1.55rem, 2.2vw, 2.25rem);
    line-height: 1;
    letter-spacing: -.04em;
}

.gradebook-summary-card__detail {
    color: #718097;
    font-size: .82rem;
}

.gradebook-summary-card[data-tone="review"] .gradebook-summary-card__value {
    color: var(--gradebook-amber);
}

.gradebook-filters {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px;
    padding: 22px 30px;
    border-top: 1px solid var(--gradebook-soft-line);
    border-bottom: 1px solid var(--gradebook-soft-line);
    background: #fcfbf9;
}

.gradebook-filters__heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    grid-column: 1 / -1;
    gap: 18px;
    margin-bottom: 2px;
}

.gradebook-filters__heading > div {
    display: grid;
    gap: 2px;
}

.gradebook-filters__heading strong {
    color: var(--gradebook-ink);
    font-size: 1.06rem;
}

.gradebook-filters__heading span {
    color: var(--gradebook-muted);
    font-size: .86rem;
}

.gradebook-filters .form-field {
    min-width: 0;
    gap: 6px;
}

.gradebook-filters .form-field > span {
    color: #52647d;
    font-size: .74rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.gradebook-filters select {
    width: 100%;
    min-height: 42px;
    padding-inline: 12px 34px;
    border-color: #d9d7d1;
    border-radius: 10px;
    background-color: #fff;
    color: var(--gradebook-ink);
    font-size: .9rem;
    text-overflow: ellipsis;
}

.gradebook-page--classroom-scoped .gradebook-filters {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.gradebook-page--classroom-scoped .gradebook-scope-filter {
    display: none;
}

.gradebook-filters .quiet-button {
    min-height: 34px;
    padding: 6px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #4c617d;
    font-weight: 750;
}

.gradebook-filters .quiet-button:hover,
.gradebook-filters .quiet-button:focus-visible {
    background: #efede8;
    color: var(--gradebook-ink);
}

.gradebook-results {
    min-width: 0;
    padding: 10px 30px 30px;
}

.gradebook-table-shell {
    overflow: hidden;
    border: 1px solid var(--gradebook-soft-line);
    border-radius: 14px;
}

.gradebook-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.gradebook-table th,
.gradebook-table td {
    padding: 15px 16px;
    text-align: left;
    vertical-align: middle;
}

.gradebook-table th {
    border-bottom: 1px solid var(--gradebook-soft-line);
    background: #f7f6f3;
    color: #66758a;
    font-size: .72rem;
    font-weight: 850;
    letter-spacing: .055em;
    text-transform: uppercase;
}

.gradebook-table th:first-child,
.gradebook-table td:first-child {
    width: 23%;
}

.gradebook-table th:nth-child(2),
.gradebook-table td:nth-child(2) {
    width: 31%;
}

.gradebook-table th:nth-child(3),
.gradebook-table td:nth-child(3) {
    width: 16%;
}

.gradebook-table th:nth-child(4),
.gradebook-table td:nth-child(4) {
    width: 15%;
}

.gradebook-table tbody tr {
    border-bottom: 1px solid var(--gradebook-soft-line);
    transition: background-color 150ms ease;
}

.gradebook-table tbody tr:last-child {
    border-bottom: 0;
}

.gradebook-table tbody tr:hover,
.gradebook-table tbody tr:focus-within {
    background: #faf9f6;
}

.gradebook-student,
.gradebook-lesson-link {
    display: block;
    overflow: hidden;
    color: var(--gradebook-ink);
    font-weight: 780;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gradebook-lesson-link {
    color: #244f83;
    text-decoration: none;
}

.gradebook-lesson-link:hover,
.gradebook-lesson-link:focus-visible {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.gradebook-cell-meta {
    display: block;
    overflow: hidden;
    margin-top: 3px;
    color: #718097;
    font-size: .8rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gradebook-score {
    display: block;
    color: var(--gradebook-ink);
    font-weight: 850;
}

.gradebook-score--pending {
    color: #798497;
    font-weight: 700;
}

.gradebook-status-chip {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 5px 9px;
    border-radius: 999px;
    background: #edf1f5;
    color: #52647a;
    font-size: .76rem;
    font-weight: 800;
    white-space: nowrap;
}

.gradebook-status-chip[data-status="auto_scored"],
.gradebook-status-chip[data-status="reviewed"] {
    background: #e7f3ed;
    color: var(--gradebook-green);
}

.gradebook-status-chip[data-status="needs_review"] {
    background: #f8eedc;
    color: var(--gradebook-amber);
}

.gradebook-status-chip[data-status="missing"] {
    background: #f6eae8;
    color: var(--gradebook-red);
}

.gradebook-empty-state {
    display: grid;
    justify-items: start;
    gap: 8px;
    margin-top: 10px;
    padding: 30px;
    border: 1px dashed #d5d2ca;
    border-radius: 14px;
    background: #faf9f6;
}

.gradebook-empty-state h3,
.gradebook-empty-state p {
    margin: 0;
}

.gradebook-empty-state h3 {
    color: var(--gradebook-ink);
    font-size: 1.08rem;
}

.gradebook-empty-state p {
    max-width: 62ch;
    color: var(--gradebook-muted);
    line-height: 1.5;
}

@media (max-width: 1120px) {
    .gradebook-filters,
    .gradebook-page--classroom-scoped .gradebook-filters {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .gradebook-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .gradebook-summary-card:nth-child(2) {
        border-right: 0;
    }

    .gradebook-summary-card:nth-child(-n + 2) {
        border-bottom: 1px solid var(--gradebook-soft-line);
    }
}

@media (max-width: 820px) {
    .gradebook-page .gradebook-layout {
        padding: 24px 16px 42px;
    }

    .gradebook-header,
    .gradebook-section-heading {
        align-items: start;
        flex-direction: column;
    }

    .gradebook-header__actions,
    .gradebook-header__actions .secondary-button {
        width: 100%;
    }

    .gradebook-section-heading,
    .gradebook-filters,
    .gradebook-results {
        padding-inline: 20px;
    }

    .gradebook-summary {
        margin-inline: 20px;
    }

    .gradebook-table-shell {
        overflow: visible;
        border: 0;
    }

    .gradebook-table,
    .gradebook-table tbody,
    .gradebook-table tr,
    .gradebook-table td {
        display: block;
        width: 100% !important;
    }

    .gradebook-table thead {
        position: absolute;
        overflow: hidden;
        width: 1px;
        height: 1px;
        clip: rect(0 0 0 0);
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .gradebook-table tbody {
        display: grid;
        gap: 10px;
    }

    .gradebook-table tbody tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 10px 14px;
        padding: 16px;
        border: 1px solid var(--gradebook-soft-line);
        border-radius: 12px;
    }

    .gradebook-table td {
        padding: 0;
    }

    .gradebook-table td:nth-child(2) {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .gradebook-table td:nth-child(3) {
        grid-column: 2;
        grid-row: 1;
    }

    .gradebook-table td:nth-child(4),
    .gradebook-table td:nth-child(5) {
        align-self: end;
    }
}

@media (max-width: 620px) {
    .gradebook-filters,
    .gradebook-page--classroom-scoped .gradebook-filters {
        grid-template-columns: 1fr;
    }

    .gradebook-summary {
        grid-template-columns: 1fr;
    }

    .gradebook-summary-card {
        min-height: 88px;
        border-right: 0;
        border-bottom: 1px solid var(--gradebook-soft-line);
    }

    .gradebook-summary-card:last-child {
        border-bottom: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .gradebook-back-link::before,
    .gradebook-table tbody tr {
        transition: none;
    }
}
