:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --ink: #172033;
    --muted: #697386;
    --line: #dce3ee;
    --primary: #176b87;
    --primary-dark: #104d61;
    --accent: #f2a900;
    --danger: #b42318;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--bg);
    font-family: Arial, Helvetica, sans-serif;
}

a {
    color: var(--primary);
    text-decoration: none;
}

.login-page {
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at top left, rgba(242, 169, 0, 0.18), transparent 32%),
        radial-gradient(circle at bottom right, rgba(23, 107, 135, 0.16), transparent 34%),
        var(--bg);
}

.login-shell {
    width: min(760px, 100%);
}

.login-panel,
.empty-state,
.table-panel,
.sync-panel,
.filters,
.stats-grid article {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.login-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: clamp(28px, 6vw, 64px);
    box-shadow: 0 24px 70px rgba(23, 32, 51, 0.12);
}

.brand-heading {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-logo {
    width: 58px;
    height: 58px;
    object-fit: contain;
    flex: 0 0 auto;
}

.large-logo {
    width: clamp(132px, 22vw, 172px);
    height: clamp(132px, 22vw, 172px);
    margin-bottom: 22px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
}

.login-panel h1 {
    max-width: 620px;
    font-size: clamp(2rem, 5vw, 3.4rem);
    line-height: 1.08;
}

.lead {
    max-width: 680px;
    color: var(--muted);
    font-size: 1.05rem;
    line-height: 1.65;
}

.primary-btn,
button,
.topbar nav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 16px;
    border: 0;
    border-radius: 6px;
    color: #fff;
    background: var(--primary);
    cursor: pointer;
    font-weight: 700;
}

.primary-btn:hover,
button:hover,
.topbar nav a:hover {
    background: var(--primary-dark);
}

.secondary-btn {
    background: #18864b;
}

.secondary-btn:hover {
    background: #116236;
}

.login-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 24px;
}

.login-actions .primary-btn {
    min-width: 170px;
    min-height: 48px;
    font-size: 1rem;
}

.small-note,
.sync-note {
    color: var(--muted);
    font-size: 0.9rem;
}

.alert {
    margin: 16px 0;
    padding: 12px 14px;
    border-radius: 6px;
    background: #e8f6ee;
    color: #17603a;
}

.alert.error {
    background: #fff0ed;
    color: var(--danger);
}

.inline-note {
    margin: 0 0 12px;
    color: var(--muted);
    line-height: 1.5;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 22px clamp(18px, 4vw, 48px);
    color: #fff;
    background: linear-gradient(90deg, #12394a 0%, #176b87 58%, #18864b 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 10px 32px rgba(18, 57, 74, 0.24);
}

.topbar h1 {
    font-size: 1.7rem;
}

.topbar nav {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.topbar nav span {
    color: rgba(255, 255, 255, 0.82);
}

.topbar .eyebrow {
    color: #fff7df;
}

.topbar nav .icon-link {
    width: 40px;
    min-width: 40px;
    padding: 0;
    font-size: 1.25rem;
}

.topbar nav .refresh-link {
    background: #18864b;
}

.topbar nav .refresh-link:hover {
    background: #116236;
}

.dashboard {
    width: min(1280px, calc(100% - 32px));
    margin: 24px auto 48px;
}

.filters {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    padding: 18px;
}

.sync-panel {
    display: grid;
    grid-template-columns: minmax(240px, 0.8fr) minmax(320px, 1.2fr);
    gap: 18px;
    margin-bottom: 18px;
    padding: 18px;
}

.sync-panel p {
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.5;
}

.class-sync-list {
    display: grid;
    gap: 10px;
}

.admin-login-form {
    display: grid;
    gap: 14px;
    max-width: 360px;
    margin-top: 20px;
}

.check-row {
    display: grid;
    grid-template-columns: 22px 1fr;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
}

.check-row input {
    width: 18px;
    min-height: 18px;
}

.check-row span,
.check-row small {
    display: block;
}

.check-row small {
    margin-top: 2px;
    color: var(--muted);
    font-weight: 400;
}

.filters form {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(120px, 0.6fr) minmax(150px, 0.7fr) minmax(260px, 1.4fr);
    gap: 16px;
    width: min(1040px, 100%);
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
}

select,
input {
    width: 100%;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 10px;
    color: var(--ink);
    background: #fff;
    font: inherit;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin: 18px 0;
}

.stats-grid article {
    padding: 18px;
}

.stats-grid strong {
    display: block;
    font-size: 2rem;
    line-height: 1;
}

.stats-grid span {
    display: block;
    margin-top: 8px;
    color: var(--muted);
}

.chart-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(260px, 1fr));
    gap: 12px;
    margin: 18px 0;
}

.chart-card {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.chart-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.chart-heading h2 {
    font-size: 1.05rem;
}

.chart-heading strong {
    font-size: 1.4rem;
    color: var(--primary);
}

.stacked-bar {
    display: flex;
    height: 18px;
    overflow: hidden;
    border-radius: 999px;
    background: #edf2f7;
}

.stacked-bar span {
    min-width: 0;
}

.bar-submitted,
.legend-submitted {
    background: #18864b;
}

.bar-missing,
.legend-missing {
    background: #e5484d;
}

.bar-reviewed,
.legend-reviewed {
    background: #176b87;
}

.bar-pending,
.legend-pending {
    background: #f2a900;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 12px;
    color: var(--muted);
    font-size: 0.9rem;
}

.chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.chart-legend i {
    width: 10px;
    height: 10px;
    border-radius: 999px;
}

.table-panel,
.empty-state {
    padding: 18px;
}

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.panel-heading input {
    width: 260px;
    max-width: 100%;
}

.panel-tools {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
}

.panel-tools button,
.panel-tools .tool-btn {
    white-space: nowrap;
    min-width: 116px;
    min-height: 40px;
    padding: 0 14px;
    font: inherit;
    font-size: 0.92rem;
    line-height: 1;
}

.tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 6px;
    color: #fff;
    background: #18864b;
    font-weight: 700;
}

.tool-btn:hover {
    background: #116236;
}

.panel-tools .print-btn {
    background: var(--primary);
}

.panel-tools .print-btn:hover {
    background: var(--primary-dark);
}

.table-wrap {
    overflow-x: auto;
}

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

th,
td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
}

.sort-btn {
    display: inline-flex;
    min-height: auto;
    padding: 0;
    color: inherit;
    background: transparent;
    font: inherit;
    text-transform: inherit;
}

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

.sort-btn::after {
    content: "↕";
    margin-left: 5px;
    font-size: 0.72rem;
    opacity: 0.7;
}

td span {
    display: block;
    color: var(--muted);
    font-size: 0.88rem;
}

.pill {
    display: inline-flex;
    width: fit-content;
    padding: 5px 9px;
    border-radius: 999px;
    background: #ecf7fa;
    color: var(--primary);
    font-weight: 700;
}

.checked-pill {
    background: #e8f6ee;
    color: #17603a;
}

.submitted-pill {
    background: #e8f6ee;
    color: #17603a;
}

.not-submitted-pill {
    background: #fff0ed;
    color: var(--danger);
}

.pending-pill {
    background: #fff7df;
    color: #8a5b00;
}

.muted-text {
    color: var(--muted);
}

.grade-form {
    display: contents;
}

.grade-form input {
    width: 96px;
}

.actions {
    min-width: 230px;
}

.action-note {
    display: inline-block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.82rem;
}

.return-btn {
    background: var(--accent);
    color: #201800;
}

.return-btn:hover {
    background: #d99600;
}

.empty-row {
    color: var(--muted);
    text-align: center;
}

.print-report {
    display: none;
}

@media (max-width: 800px) {
    .topbar,
    .filters,
    .sync-panel,
    .panel-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .filters form,
    .sync-panel,
    .chart-panel,
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .panel-heading input {
        max-width: none;
    }
}

@media print {
    body {
        padding: 10mm;
        background: #fff;
    }

    .topbar nav,
    .filters,
    .panel-tools,
    .sync-note,
    .chart-panel,
    .stats-grid,
    .panel-heading,
    script {
        display: none !important;
    }

    .print-report {
        display: block;
    }

    .print-header {
        display: grid;
        grid-template-columns: 78px 1fr;
        gap: 14px;
        align-items: center;
        margin-bottom: 14px;
        padding-bottom: 12px;
        border-bottom: 3px solid #176b87;
    }

    .print-header img {
        width: 72px;
        height: 72px;
        object-fit: contain;
    }

    .print-header h1 {
        margin: 0 0 4px;
        font-size: 20px;
        text-transform: uppercase;
    }

    .print-header p {
        margin: 0;
        color: #4b5563;
        font-size: 12px;
    }

    .print-meta {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin-bottom: 12px;
        font-size: 12px;
    }

    .print-meta div {
        padding: 7px 9px;
        border: 1px solid #cbd5e1;
        border-radius: 4px;
    }

    .print-summary {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 8px;
        margin-bottom: 14px;
    }

    .print-summary div {
        padding: 8px;
        border: 1px solid #cbd5e1;
        border-radius: 4px;
        text-align: center;
    }

    .print-summary strong {
        display: block;
        color: #176b87;
        font-size: 18px;
    }

    .print-summary span {
        display: block;
        margin-top: 3px;
        color: #4b5563;
        font-size: 10px;
        text-transform: uppercase;
    }

    .topbar,
    .table-panel,
    .chart-card,
    .stats-grid article {
        box-shadow: none;
        border-color: #cbd5e1;
    }

    .dashboard {
        width: 100%;
        margin: 0;
    }

    th,
    td {
        padding: 7px 6px;
        border: 1px solid #9ca3af;
        font-size: 10px;
    }

    th {
        color: #fff;
        background: #176b87;
    }

    .topbar {
        display: none;
    }

    .table-panel {
        padding: 0;
        border: 0;
    }

    .table-wrap {
        overflow: visible;
    }

    @page {
        size: A4 landscape;
        margin: 10mm;
    }
}
