:root {
    color-scheme: light;
    --ink: #17212b;
    --muted: #5c6975;
    --paper: #f5f7f8;
    --surface: #ffffff;
    --line: #d9e0e5;
    --accent: #176b55;
    --accent-dark: #105141;
    --signal: #e6a534;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: Inter, Arial, sans-serif;
}

.topbar {
    min-height: 68px;
    padding: 0 5vw;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--ink);
    font-weight: 700;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    background: var(--accent);
    color: white;
    font-size: 14px;
}

nav {
    display: flex;
    align-items: center;
    gap: 24px;
}

nav a,
.nav-button {
    color: var(--muted);
    text-decoration: none;
    font-size: 14px;
}

nav form {
    margin: 0;
}

.nav-button {
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

nav a:hover,
.nav-button:hover {
    color: var(--accent);
}

.page {
    width: min(1120px, 90vw);
    margin: 0 auto;
}

.journal-page .page {
    width: 90vw;
    max-width: none;
}

.welcome {
    max-width: 760px;
    padding: 11vh 0 9vh;
}

.eyebrow {
    margin: 0 0 16px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

h1 {
    max-width: 700px;
    margin: 0;
    font-family: Georgia, serif;
    font-size: clamp(44px, 7vw, 82px);
    font-weight: 500;
    line-height: 1;
}

.lead {
    max-width: 640px;
    margin: 28px 0;
    color: var(--muted);
    font-size: 20px;
    line-height: 1.55;
}

.primary-action {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    padding: 0 18px;
    background: var(--accent);
    color: white;
    text-decoration: none;
    font-weight: 700;
}

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

.module-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-top: 1px solid var(--line);
}

.module-grid article {
    min-height: 180px;
    padding: 28px;
    background: var(--surface);
    border-right: 1px solid var(--line);
}

.module-grid article:last-child {
    border-right: 0;
}

.module-number {
    color: var(--signal);
    font-weight: 700;
}

.module-grid h2 {
    margin: 28px 0 10px;
    font-size: 19px;
}

.module-grid p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.messages {
    margin-top: 24px;
}

.messages p {
    padding: 12px 16px;
    border-left: 4px solid var(--accent);
    background: var(--surface);
}

.dashboard-section-title {
    margin: 28px 0 12px;
    font-size: 20px;
}

.curated-assignment-list {
    margin-bottom: 36px;
}

.messages .error,
.form-error {
    border-color: #b23939;
    color: #8b2727;
}

.page-title {
    margin: 0;
    font-family: Georgia, serif;
    font-size: clamp(36px, 5vw, 58px);
    font-weight: 500;
    line-height: 1.05;
}

.section-header {
    min-height: 190px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.user-label,
.subject-label {
    color: var(--muted);
}

.data-list {
    border-top: 1px solid var(--line);
}

.data-list a {
    min-height: 84px;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    color: var(--ink);
    text-decoration: none;
}

.data-list a:hover {
    background: #eef4f1;
}

.data-list span:first-child,
.journal-table td:first-child {
    display: grid;
    gap: 5px;
}

.data-list small,
.journal-table small {
    color: var(--muted);
}

.row-action {
    color: var(--accent);
    font-size: 14px;
    font-weight: 700;
}

.empty-state {
    padding: 40px;
    background: var(--surface);
    border-top: 3px solid var(--signal);
}

.empty-state.compact {
    padding: 24px;
}

.auth-panel {
    width: min(480px, 100%);
    margin: 10vh auto;
    padding: 36px;
    background: var(--surface);
    border-top: 4px solid var(--accent);
}

.stacked-form {
    display: grid;
    gap: 10px;
    margin-top: 30px;
}

.stacked-form label {
    margin-top: 8px;
    font-size: 14px;
    font-weight: 700;
}

input,
select {
    width: 100%;
    min-height: 44px;
    padding: 8px 10px;
    border: 1px solid #b9c4cb;
    border-radius: 0;
    background: white;
    color: var(--ink);
    font: inherit;
}

.stacked-form .primary-action {
    justify-content: center;
    margin-top: 16px;
    border: 0;
    cursor: pointer;
}

.secondary-action {
    color: var(--accent);
    font-weight: 700;
    text-decoration: none;
}

.delete-lesson-action {
    color: #a22c2c;
}

.confirmation-page {
    width: min(720px, 100%);
    margin: 9vh auto;
}

.confirmation-details {
    margin-top: 32px;
    padding: 22px;
    display: grid;
    gap: 8px;
    background: var(--surface);
    border-left: 4px solid var(--accent);
}

.confirmation-details span {
    color: var(--muted);
}

.warning-box {
    margin-top: 20px;
    padding: 22px;
    background: #fff3f3;
    border-left: 4px solid #a22c2c;
}

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

.confirmation-actions {
    margin-top: 24px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
}

.danger-action {
    min-height: 44px;
    padding: 0 18px;
    border: 0;
    background: #a22c2c;
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

.danger-action:hover {
    background: #841f1f;
}

.section-title {
    margin: 0 0 18px;
    font-size: 20px;
}

.section-heading-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
}

.section-heading-row .section-title {
    margin-bottom: 6px;
}

.section-note {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.record-count {
    color: var(--muted);
    font-size: 14px;
    white-space: nowrap;
}

.journal-toolbar {
    display: flex;
    align-items: center;
    gap: 18px;
}

.edit-journal-action {
    min-height: 38px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--accent);
}

.summary-section {
    min-width: 0;
    margin-bottom: 48px;
}

.journal-workspace {
    display: grid;
    grid-template-columns: minmax(0, 4fr) minmax(260px, 1fr);
    gap: 24px;
    align-items: start;
}

.lesson-sidebar {
    position: sticky;
    top: 18px;
    max-height: calc(100vh - 36px);
    padding-left: 22px;
    overflow: hidden;
    border-left: 1px solid var(--line);
}

.lesson-list {
    max-height: min(46vh, 480px);
    overflow-y: auto;
}

.lesson-list a {
    min-height: 68px;
    padding: 12px 14px;
}

.lesson-list strong {
    font-size: 14px;
    line-height: 1.35;
}

.lesson-list small {
    font-size: 12px;
}

.sidebar-divider {
    margin: 22px 0;
    border-top: 1px solid var(--line);
}

.sidebar-create .stacked-form {
    margin-top: 14px;
}

.sidebar-create select {
    font-size: 13px;
}

.split-layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    gap: 40px;
    align-items: start;
}

.tool-panel {
    padding: 24px;
    background: var(--surface);
    border-top: 3px solid var(--signal);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 18px;
}

.import-panel {
    margin-bottom: 36px;
    padding: 24px;
    background: var(--surface);
    border-top: 3px solid var(--signal);
}

.upload-form {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    align-items: end;
    gap: 12px 20px;
}

.upload-form label {
    grid-column: 1 / -1;
    font-weight: 700;
}

.upload-form input[type="file"] {
    padding: 8px;
}

.upload-form .primary-action,
.import-confirm .primary-action {
    justify-content: center;
    border: 0;
    cursor: pointer;
}

.import-preview {
    padding-bottom: 48px;
}

.curriculum-preview-wrap {
    max-height: 520px;
    margin-top: 18px;
    border: 1px solid var(--line);
}

.curriculum-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

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

.curriculum-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #e8edef;
    font-size: 12px;
    text-transform: uppercase;
}

.curriculum-table th:first-child,
.curriculum-table td:first-child,
.curriculum-table th:nth-child(4),
.curriculum-table td:nth-child(4) {
    text-align: center;
}

.import-confirm {
    padding: 18px 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 20px;
}

.import-confirm p {
    margin: 0;
    color: var(--muted);
}

.button-link {
    border: 1px solid var(--accent);
    background: transparent;
    cursor: pointer;
    font: inherit;
}

.curriculum-add-form {
    display: flex;
    align-items: center;
    gap: 10px;
}

.curriculum-add-form label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.curriculum-add-form input {
    width: 76px;
    min-width: 76px;
    min-height: 38px;
    padding: 6px 10px;
    text-align: center;
    font-size: 16px;
}

.curriculum-editor {
    padding-bottom: 48px;
}

.curriculum-editor-wrap {
    max-height: 68vh;
    margin-top: 18px;
    border: 1px solid var(--line);
}

.curriculum-edit-table {
    min-width: 1300px;
}

.curriculum-edit-table th:first-child {
    width: 68px;
}

.curriculum-edit-table th:nth-child(2) {
    width: 150px;
}

.curriculum-edit-table th:nth-child(3) {
    width: 140px;
}

.curriculum-edit-table th:nth-child(4) {
    width: 330px;
}

.curriculum-edit-table th:nth-child(5) {
    width: 210px;
}

.curriculum-edit-table th:nth-child(6) {
    width: 90px;
}

.curriculum-edit-table th:nth-child(7) {
    width: 240px;
}

.curriculum-edit-table th:nth-child(8) {
    width: 120px;
}

.curriculum-edit-table input,
.curriculum-edit-table select,
.curriculum-edit-table textarea {
    width: 100%;
    min-height: 40px;
    padding: 7px 8px;
    resize: vertical;
    border: 1px solid #b9c4cb;
    background: #fff;
    color: var(--ink);
    font: inherit;
}

.curriculum-edit-table .sequence-input {
    width: 72px;
    min-width: 72px;
    padding: 7px 10px;
    text-align: center;
    font-size: 16px;
}

.curriculum-edit-table textarea {
    line-height: 1.35;
}

.curriculum-status {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.curriculum-status.is-complete {
    color: var(--accent);
}

.actual-date-cell span {
    display: block;
    white-space: nowrap;
}

.curriculum-delete-cell {
    width: 54px;
    text-align: center !important;
}

.curriculum-delete {
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #a22c2c;
    cursor: pointer;
    font-size: 28px;
    font-weight: 700;
    line-height: 30px;
}

.curriculum-delete:hover,
.curriculum-delete:focus-visible {
    background: #a22c2c;
    color: #fff;
    outline: 0;
}

.curriculum-actions {
    padding-top: 18px;
    display: flex;
    justify-content: flex-end;
}

.curriculum-actions .primary-action {
    border: 0;
    cursor: pointer;
}

.table-wrap {
    overflow-x: auto;
    background: var(--surface);
}

.journal-table-wrap {
    max-height: min(68vh, 720px);
    overflow: auto;
    border: 1px solid var(--line);
}

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

.summary-table {
    width: 100%;
    min-width: 720px;
    border-collapse: separate;
    border-spacing: 0;
}

.summary-table th,
.summary-table td {
    height: 58px;
    padding: 10px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    text-align: center;
}

.summary-table th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #e8edef;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.summary-table th a {
    color: var(--accent);
    text-decoration: none;
}

.lesson-field-labels {
    margin-top: 6px;
    display: grid;
    grid-template-columns: 34px 28px;
    justify-content: center;
    gap: 3px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
}

.summary-table .student-column {
    position: sticky;
    left: 0;
    z-index: 4;
    width: 240px;
    min-width: 240px;
    background: var(--surface);
    text-align: left;
}

.summary-table thead .student-column {
    z-index: 7;
    background: #e8edef;
}

.summary-table .student-column small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
}

.lesson-column,
.lesson-cell {
    width: 64px;
    min-width: 64px;
}

.metric-column {
    width: 98px;
    min-width: 98px;
}

.summary-table th.metric-column,
.summary-table td.metric-column {
    position: sticky;
    z-index: 4;
    background-clip: border-box;
    border-left: 1px solid var(--line);
    box-shadow:
        -1px 0 0 var(--line),
        -8px 0 12px rgb(23 33 43 / 7%);
}

.summary-table th.metric-column {
    z-index: 7;
    background: #e8edef;
}

.summary-table th.metric-column:last-child,
.summary-table td.metric-column:last-child {
    right: 0;
    border-right: 0;
}

.summary-table th.metric-column:nth-last-child(2),
.summary-table td.metric-column:nth-last-child(2) {
    right: 98px;
}

.lesson-cell {
    position: relative;
    white-space: nowrap;
}

.grade-editor {
    width: 34px;
    min-width: 34px;
    min-height: 34px;
    padding: 2px;
    border-color: var(--accent);
    text-align: center;
    font-weight: 700;
}

.attendance-editor {
    width: 28px;
    min-width: 28px;
    min-height: 34px;
    padding: 2px;
    border-color: #9a8bba;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.pass-fail-editor {
    width: 42px;
    min-width: 42px;
    font-size: 12px;
}

.no-grade-mark {
    min-width: 34px;
    color: var(--muted);
    font-size: 12px;
}

.grade-pass {
    width: auto;
    min-width: 34px;
    padding: 0 6px;
    background: #e6f2ed;
    color: var(--accent-dark);
    font-size: 12px;
}

.cell-editors {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
}

.grade-editor:focus,
.attendance-editor:focus {
    position: relative;
    z-index: 2;
    outline: 2px solid var(--signal);
    outline-offset: 1px;
}

.journal-choice-popover {
    position: fixed;
    z-index: 100;
    padding: 6px;
    display: flex;
    gap: 5px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: 0 8px 24px rgb(23 33 43 / 18%);
}

.journal-choice-popover[hidden] {
    display: none;
}

.journal-choice-popover button {
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--line);
    background: var(--paper);
    color: var(--ink);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

.journal-choice-popover button:hover,
.journal-choice-popover button:focus-visible {
    border-color: var(--accent);
    background: #e6f2ed;
    color: var(--accent-dark);
    outline: 0;
}

.journal-choice-popover button.wide-choice {
    width: auto;
    min-width: 62px;
    padding: 0 8px;
}

.journal-choice-popover .clear-choice {
    color: var(--muted);
    font-weight: 400;
}

.journal-edit-form .lesson-cell {
    padding: 8px 6px;
    background-clip: padding-box;
}

.journal-edit-form .lesson-column,
.journal-edit-form .lesson-cell {
    width: 76px;
    min-width: 76px;
}

.journal-save-bar {
    position: sticky;
    bottom: 0;
    z-index: 4;
    min-height: 72px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 24px;
    background: var(--surface);
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 20px rgb(23 33 43 / 8%);
}

.journal-save-bar p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.autosave-status {
    min-width: 110px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    text-align: right;
}

.autosave-status.is-saving {
    color: #765314;
}

.autosave-status.is-saved {
    color: var(--accent);
}

.autosave-status.is-error {
    color: #a22c2c;
}

.audit-reason-panel {
    margin: 14px 0;
    padding: 14px;
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(220px, 1fr);
    align-items: start;
    gap: 10px;
    background: #fff8e7;
    border-left: 4px solid var(--signal);
}

.audit-reason-panel[hidden] {
    display: none;
}

.archive-notice {
    margin: 0 0 18px;
    padding: 14px 18px;
    color: #614b12;
    background: #fff8dc;
    border-left: 4px solid #c99a20;
    font-weight: 700;
}

.audit-form-field {
    display: grid;
    gap: 6px;
}

.audit-form-field label {
    font-size: 13px;
    font-weight: 700;
}

.audit-form-field select,
.audit-form-field input,
.audit-form-field textarea {
    width: 100%;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid #b9c4cb;
    background: #fff;
    font: inherit;
}

.audit-form-field textarea {
    min-height: 44px;
    resize: vertical;
}

.audit-other-reason {
    grid-column: 1 / -1;
}

.audit-other-reason[hidden] {
    display: none;
}

.delete-reason-fields {
    width: 100%;
    display: grid;
    grid-template-columns: 150px 1fr;
    align-items: center;
    gap: 10px;
}

.delete-reason-fields label {
    font-weight: 700;
}

.delete-reason-fields textarea {
    min-height: 70px;
    padding: 8px 10px;
    resize: vertical;
    border: 1px solid #b9c4cb;
    font: inherit;
}

.confirmation-actions {
    flex-wrap: wrap;
}

.journal-save-bar .primary-action {
    border: 0;
    cursor: pointer;
}

.grade {
    display: inline-grid;
    width: 30px;
    height: 30px;
    place-items: center;
    background: #e6f2ed;
    color: var(--accent-dark);
    font-weight: 700;
}

.grade-2 {
    background: #f7dddd;
    color: #8b2727;
}

.grade-3 {
    background: #faedcf;
    color: #765314;
}

.attendance-mark {
    display: inline-block;
    margin-left: 3px;
    color: var(--muted);
    font-weight: 700;
    vertical-align: middle;
}

.summary-table td.is-absent {
    background: #fff3f3;
}

.summary-table td.is-excused {
    background: #fff8e7;
}

.summary-table td.is-late {
    background: #f2f0fa;
}

.journal-table th,
.journal-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    text-align: left;
}

.journal-table th {
    background: #e8edef;
    font-size: 13px;
    text-transform: uppercase;
}

.journal-table th:first-child {
    width: 52%;
}

.journal-table select {
    min-width: 130px;
}

.form-actions {
    padding: 24px 0 48px;
    display: flex;
    justify-content: flex-end;
}

.form-actions .primary-action {
    border: 0;
    cursor: pointer;
}

@media (max-width: 980px) {
    .journal-workspace {
        grid-template-columns: 1fr;
    }

    .lesson-sidebar {
        position: static;
        max-height: none;
        padding: 28px 0 0;
        border-top: 1px solid var(--line);
        border-left: 0;
    }

    .lesson-list {
        max-height: 360px;
    }

    .audit-reason-panel {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
        padding-top: 16px;
        padding-bottom: 16px;
    }

    nav {
        width: 100%;
        justify-content: space-between;
    }

    .welcome {
        padding: 64px 0;
    }

    .module-grid {
        grid-template-columns: 1fr;
    }

    .module-grid article {
        min-height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .section-header {
        min-height: auto;
        padding: 48px 0 32px;
        align-items: flex-start;
        flex-direction: column;
    }

    .split-layout {
        grid-template-columns: 1fr;
    }

    .header-actions,
    .upload-form,
    .import-confirm {
        width: 100%;
        align-items: stretch;
        flex-direction: column;
        grid-template-columns: 1fr;
    }

    .section-heading-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }

    .journal-toolbar {
        width: 100%;
        justify-content: space-between;
    }

    .journal-save-bar {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
    }

    .journal-save-bar .primary-action {
        justify-content: center;
    }

    .auth-panel {
        margin: 48px auto;
        padding: 24px;
    }
}
