:root {
    --ink: #172026;
    --muted: #60707c;
    --line: #d9e1e6;
    --paper: #ffffff;
    --page: #f4f7f8;
    --primary: #b7192a;
    --primary-dark: #8f1020;
    --primary-soft: #fff0f2;
    --primary-line: #edb8bf;
    --gold: #c8972d;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--page);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px 28px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.brand img {
    width: 58px;
    height: 58px;
    object-fit: contain;
}

.brand p,
.panel-head p {
    margin: 0 0 3px;
    color: var(--primary);
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0;
}

h1,
h2 {
    margin: 0;
    line-height: 1.15;
}

h1 {
    font-size: 24px;
}

h2 {
    font-size: 18px;
}

main {
    width: min(1500px, calc(100% - 36px));
    margin: 24px auto 48px;
}

.notice {
    margin-bottom: 16px;
    padding: 12px 14px;
    color: var(--primary-dark);
    background: var(--primary-soft);
    border: 1px solid var(--primary-line);
    border-radius: 6px;
    font-weight: 700;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(5, minmax(130px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.metrics article,
.panel {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.metrics article {
    padding: 16px;
}

.metrics span {
    display: block;
    min-height: 18px;
    color: var(--muted);
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
}

.metrics strong {
    display: block;
    margin-top: 8px;
    font-size: 30px;
}

.metrics .attention {
    border-color: #efcbc8;
    background: #fff7f6;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 390px;
    gap: 18px;
    align-items: start;
}

.panel {
    overflow: hidden;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--line);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 14px;
    color: #fff;
    background: var(--primary);
    border: 1px solid var(--primary);
    border-radius: 6px;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

.button:hover {
    background: var(--primary-dark);
}

.button.ghost {
    color: var(--primary-dark);
    background: #fff;
    border-color: var(--primary-line);
}

.button.small {
    min-height: 30px;
    padding: 0 10px;
    font-size: 13px;
}

.button.full {
    width: 100%;
}

.button.danger {
    color: var(--primary-dark);
    background: #fff;
    border-color: var(--primary-line);
}

.button.danger:hover {
    color: #fff;
    background: var(--primary-dark);
}

.filters,
.add-form {
    display: grid;
    gap: 10px;
}

.filters {
    grid-template-columns: minmax(180px, 1.5fr) repeat(4, minmax(120px, 1fr)) auto auto;
    padding: 16px;
    border-bottom: 1px solid var(--line);
}

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

.table-wrap {
    overflow: auto;
    max-height: 680px;
}

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

th,
td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid #edf1f3;
    vertical-align: middle;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    color: var(--muted);
    background: #fbfcfd;
    font-size: 12px;
    text-transform: uppercase;
}

td strong {
    display: block;
}

td small {
    display: block;
    margin-top: 3px;
    color: var(--primary);
    font-weight: 700;
}

.selected-row {
    background: var(--primary-soft);
}

.tags {
    color: var(--primary-dark);
    font-weight: 700;
}

.empty,
.empty-state {
    color: var(--muted);
}

.empty-state {
    padding: 16px;
    text-align: center;
}

.side {
    display: grid;
    gap: 18px;
}

.assignment-form,
.add-form {
    padding: 16px;
}

.activity-management {
    max-height: 320px;
    overflow: auto;
    border-top: 1px solid var(--line);
}

.activity-management-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid #edf1f3;
}

.activity-management-row strong,
.activity-management-row small {
    display: block;
}

.activity-management-row small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.pupil-meta {
    margin-bottom: 12px;
    color: var(--muted);
    font-weight: 700;
}

.activity-grid {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
    max-height: 410px;
    overflow: auto;
}

.activity-grid label {
    display: grid;
    grid-template-columns: 22px 1fr;
    gap: 8px;
    align-items: start;
    padding: 9px;
    border: 1px solid #e5ebef;
    border-radius: 6px;
    cursor: pointer;
}

.activity-grid input {
    min-height: auto;
    margin-top: 3px;
}

.activity-grid small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.reports {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
    gap: 18px;
    margin-top: 18px;
}

.activity-cards,
.compact-list {
    padding: 16px;
}

.activity-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
}

.activity-card {
    display: grid;
    gap: 8px;
    min-height: 118px;
    padding: 14px;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.activity-card:hover,
.activity-card:focus-visible {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
    outline: none;
}

.activity-card span {
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.activity-card strong {
    font-size: 18px;
    line-height: 1.2;
}

.activity-card em {
    align-self: end;
    color: var(--muted);
    font-style: normal;
    font-weight: 700;
}

.bar-row {
    display: grid;
    grid-template-columns: minmax(120px, 220px) 1fr 42px;
    gap: 12px;
    align-items: center;
    margin-bottom: 10px;
}

.bar-row div {
    height: 12px;
    background: #edf1f3;
    border-radius: 999px;
    overflow: hidden;
}

.bar-row i {
    display: block;
    height: 100%;
    background: var(--gold);
}

.bar-row strong {
    text-align: right;
}

.compact-list {
    display: grid;
    gap: 8px;
}

.compact-list a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 0;
    color: var(--ink);
    border-bottom: 1px solid #edf1f3;
    text-decoration: none;
}

.compact-list small {
    color: var(--muted);
    white-space: nowrap;
}

.pill {
    min-width: 42px;
    padding: 6px 10px;
    color: #fff;
    background: var(--primary);
    border-radius: 999px;
    text-align: center;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 22px;
    background: rgba(23, 32, 38, 0.55);
}

.modal-backdrop[hidden] {
    display: none;
}

.activity-modal {
    width: min(920px, 100%);
    max-height: min(780px, calc(100vh - 44px));
    overflow: hidden;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 24px 80px rgba(23, 32, 38, 0.28);
}

.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px;
    border-bottom: 1px solid var(--line);
}

.modal-head p {
    margin: 0 0 4px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    color: var(--primary-dark);
    background: #fff;
    border: 1px solid var(--primary-line);
    border-radius: 6px;
    font: inherit;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.modal-close:hover,
.modal-close:focus-visible {
    color: #fff;
    background: var(--primary-dark);
    outline: none;
}

.modal-body {
    max-height: calc(100vh - 150px);
    overflow: auto;
    padding: 18px;
}

.modal-summary {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 16px;
    color: var(--muted);
    font-weight: 700;
}

.modal-summary strong {
    color: var(--primary-dark);
    font-size: 32px;
}

.class-groups {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 14px;
}

.class-group {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.class-group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    background: var(--primary-soft);
    border-bottom: 1px solid var(--primary-line);
}

.class-group-head h3 {
    margin: 0;
    font-size: 16px;
}

.class-group-head strong {
    color: var(--primary-dark);
}

.class-pupil-list {
    display: grid;
}

.class-pupil-list a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    color: var(--ink);
    border-bottom: 1px solid #edf1f3;
    text-decoration: none;
}

.class-pupil-list a:last-child {
    border-bottom: 0;
}

.class-pupil-list a:hover {
    background: #fbfcfd;
}

.class-pupil-list small {
    color: var(--muted);
    white-space: nowrap;
}

@media (max-width: 1150px) {
    .metrics,
    .workspace,
    .reports {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 720px) {
    .topbar,
    .panel-head {
        align-items: flex-start;
        flex-direction: column;
    }

    main {
        width: min(100% - 20px, 1500px);
        margin-top: 14px;
    }

    .brand img {
        width: 48px;
        height: 48px;
    }

    h1 {
        font-size: 19px;
    }

    .metrics,
    .filters,
    .reports {
        grid-template-columns: 1fr;
    }

    .table-wrap {
        max-height: none;
    }

    th,
    td {
        min-width: 130px;
    }

    .bar-row {
        grid-template-columns: 1fr 2fr 36px;
    }

    .modal-backdrop {
        align-items: start;
        padding: 10px;
    }

    .modal-head {
        padding: 14px;
    }

    .modal-body {
        padding: 14px;
    }

    .class-groups {
        grid-template-columns: 1fr;
    }

    .class-pupil-list a {
        align-items: flex-start;
        flex-direction: column;
        gap: 3px;
    }
}
