:root {
    --bg: #f4f7f8;
    --surface: #ffffff;
    --ink: #17202a;
    --muted: #627082;
    --line: #d8e1e8;
    --brand: #0e6f73;
    --brand-strong: #09555a;
    --danger: #b42318;
    --ok: #197348;
    --warn: #976100;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

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

a:hover {
    text-decoration: underline;
}

.topbar {
    align-items: center;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    padding: 1rem clamp(1rem, 4vw, 3rem);
}

.brand {
    color: var(--ink);
    font-weight: 850;
}

.nav {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
}

.container {
    margin: 0 auto;
    max-width: 1120px;
    padding: clamp(1.25rem, 4vw, 3rem);
}

.hero {
    align-items: center;
    display: grid;
    gap: clamp(1.25rem, 4vw, 3rem);
    grid-template-columns: minmax(0, 1.1fr) minmax(280px, .9fr);
    min-height: calc(100vh - 82px);
}

.hero h1,
.page-title {
    font-size: clamp(2.15rem, 5vw, 4.25rem);
    letter-spacing: 0;
    line-height: 1.02;
    margin: 0 0 1rem;
}

.lead {
    color: var(--muted);
    font-size: 1.15rem;
    max-width: 62ch;
}

.page-heading {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
}

.panel,
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 14px 34px rgba(23, 32, 42, .07);
}

.panel {
    padding: clamp(1.4rem, 4vw, 2.5rem);
}

.card {
    padding: 1.2rem;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    margin-top: 1.35rem;
}

.button,
button {
    align-items: center;
    background: var(--brand);
    border: 1px solid var(--brand);
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 750;
    justify-content: center;
    min-height: 42px;
    padding: .65rem 1rem;
}

.button.secondary,
button.secondary {
    background: #fff;
    color: var(--brand);
}

.button.danger,
button.danger {
    background: var(--danger);
    border-color: var(--danger);
}

.button:hover,
button:hover {
    background: var(--brand-strong);
    color: #fff;
    text-decoration: none;
}

.grid {
    display: grid;
    gap: 1rem;
}

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

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

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

.form {
    display: grid;
    gap: 1rem;
    max-width: 760px;
}

.field {
    display: grid;
    gap: .35rem;
}

label {
    font-weight: 750;
}

input,
select,
textarea {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    font: inherit;
    padding: .75rem .85rem;
    width: 100%;
}

textarea {
    min-height: 120px;
    resize: vertical;
}

.checkbox-list {
    display: grid;
    gap: .45rem;
}

.checkbox-list label {
    align-items: center;
    display: flex;
    gap: .5rem;
    font-weight: 600;
}

.checkbox-list input {
    width: auto;
}

.notice {
    background: #e7f5ef;
    border: 1px solid #b4dec9;
    border-radius: 8px;
    color: #155237;
    margin-bottom: 1rem;
    padding: .85rem 1rem;
}

.error {
    color: var(--danger);
}

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

.metric {
    color: var(--brand);
    font-size: 2.2rem;
    font-weight: 850;
}

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

.full-width-section,
.collapsible-form {
    margin-top: 1rem;
    width: 100%;
}

.subjects-table {
    margin-left: 50%;
    max-width: 1480px;
    transform: translateX(-50%);
    width: min(calc(100vw - 2rem), 1480px);
}

.collapsible-form {
    display: inline-block;
    max-width: 760px;
}

.collapsible-form[open] {
    display: block;
}

.collapsible-form summary {
    list-style: none;
    width: max-content;
}

.collapsible-form summary::-webkit-details-marker {
    display: none;
}

.collapsible-form-body {
    margin-top: 1.2rem;
}

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

th,
td {
    border-bottom: 1px solid var(--line);
    padding: .8rem;
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: .9rem;
}

.badge {
    border-radius: 999px;
    display: inline-flex;
    font-size: .82rem;
    font-weight: 850;
    padding: .25rem .65rem;
}

.badge.pending {
    background: #fff3dc;
    color: var(--warn);
}

.badge.approved {
    background: #e7f5ef;
    color: var(--ok);
}

.badge.rejected {
    background: #fde8e7;
    color: var(--danger);
}

.badge.secondary {
    background: #edf3f7;
    color: var(--muted);
}

.module-card,
.material-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 1rem;
    padding: 1rem;
}

.module-toolbar {
    align-items: center;
    display: block;
    gap: 1rem;
    margin-bottom: 1rem;
}

.module-toolbar .actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    margin-top: 1rem;
}

.toolbar-details,
.nested-details {
    width: auto;
}

.toolbar-details[open] {
    flex-basis: 100%;
    width: 100%;
}

.toolbar-details summary,
.nested-details summary {
    list-style: none;
    width: max-content;
}

.toolbar-details summary::-webkit-details-marker,
.nested-details summary::-webkit-details-marker {
    display: none;
}

.toolbar-panel,
.nested-panel {
    border-top: 1px solid var(--line);
    margin-top: 1rem;
    max-width: 760px;
    padding-top: 1rem;
}

.module-list {
    display: grid;
    gap: .85rem;
}

.module-row-shell {
    background: linear-gradient(180deg, #fff 0%, #fbfcfd 100%);
    position: relative;
}

.module-row-header {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    padding: 1rem 1.2rem;
}

.module-row-title {
    flex: 1 1 280px;
    min-width: 0;
}

.module-title-toggle,
button.module-title-toggle {
    background: transparent;
    border: 0;
    color: var(--ink);
    cursor: pointer;
    display: grid;
    gap: .15rem;
    justify-content: start;
    min-height: 0;
    padding: 0;
    text-align: left;
}

.module-title-toggle:hover,
button.module-title-toggle:hover {
    background: transparent;
    color: var(--brand);
}

.module-title-toggle strong {
    font-size: 1.02rem;
}

.module-row-title strong,
.module-row-title .muted {
    display: block;
}

.module-row {
    padding: 0;
}

.module-row > summary {
    align-items: center;
    cursor: pointer;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    list-style: none;
    padding: 1rem 4.75rem 1rem 1.2rem;
}

.module-row > summary::-webkit-details-marker {
    display: none;
}

.module-row > summary strong,
.module-row > summary .muted {
    display: block;
}

.module-row-body {
    border-top: 1px solid var(--line);
    padding: 1rem 1.2rem 1.2rem;
}

.module-row-meta {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.module-row-actions {
    align-items: center;
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    gap: .5rem;
    margin-left: auto;
}

.module-quick-toggle {
    position: absolute;
    right: 1rem;
    top: .95rem;
    z-index: 1;
}

.module-row-header .module-quick-toggle {
    position: static;
}

.badge-button,
button.badge-button {
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    display: inline-flex;
    font-size: .85rem;
    font-weight: 800;
    line-height: 1;
    min-height: 0;
    padding: .3rem .65rem;
}

.badge-button.approved,
button.badge-button.approved {
    background: #e7f6ee;
    color: var(--ok);
}

.badge-button.pending,
button.badge-button.pending {
    background: #fff4db;
    color: var(--warn);
}

.badge-button:hover,
button.badge-button:hover {
    background: var(--brand);
    color: #fff;
}

.icon-button {
    align-items: center;
    display: inline-flex;
    justify-content: center;
    min-height: 36px;
    padding: .35rem;
    width: 42px;
}

.module-action-button {
    min-height: 36px;
    padding: .45rem .75rem;
}

.eye-icon {
    border: 2px solid currentColor;
    border-radius: 50% 50% 45% 45%;
    display: block;
    height: 16px;
    position: relative;
    transform: rotate(45deg);
    width: 16px;
}

.eye-icon::before {
    background: currentColor;
    border-radius: 50%;
    content: "";
    height: 5px;
    left: 50%;
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 5px;
}

.eye-icon.is-off::after {
    background: currentColor;
    content: "";
    height: 2px;
    left: -5px;
    position: absolute;
    top: 7px;
    transform: rotate(90deg);
    width: 26px;
}

.module-start-panel {
    align-items: center;
    background: #f8fbfb;
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
}

.module-instruction {
    color: var(--ink);
    flex-basis: 100%;
    margin: 0;
}

.module-document-links {
    display: grid;
    flex-basis: 100%;
    gap: .4rem;
    margin-top: .25rem;
}

.module-document-links a {
    color: #0645ad;
    font-weight: 650;
    text-decoration: underline;
}

.module-document-links a:hover {
    color: #0b62d6;
}

.module-start-panel[hidden] {
    display: none;
}

.student-menu {
    margin-top: 1rem;
}

.menu-tabs {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin: -1.2rem -1.2rem 1.2rem;
    padding: .75rem 1.2rem 0;
}

.menu-tabs a,
.menu-tabs span {
    border-bottom: 3px solid transparent;
    color: var(--muted);
    font-weight: 750;
    padding: .65rem .75rem .75rem;
}

.menu-tabs a.active {
    border-bottom-color: var(--brand);
    color: var(--brand);
}

.student-module-list {
    display: grid;
    gap: .85rem;
}

.student-module-list .module-row-shell {
    box-shadow: none;
}

.student-module-list .module-row-header {
    padding: 1rem;
}

.student-module-list .module-row {
    background: #fbfcfd;
    border: 1px solid var(--line);
    box-shadow: none;
}

.module-card {
    background: #fbfcfd;
}

.material-item {
    background: #fff;
    box-shadow: none;
}

.interactive-frame {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    height: min(72vh, 760px);
    margin-top: 1rem;
    width: 100%;
}

.interactive-viewer {
    margin-top: 1rem;
}

.interactive-controls {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
}

.interactive-viewer.is-expanded {
    background: var(--surface);
    display: grid;
    grid-template-rows: auto 1fr;
    inset: 0;
    padding: 1rem;
    position: fixed;
    z-index: 1000;
}

.interactive-viewer.is-expanded .interactive-controls {
    border-bottom: 1px solid var(--line);
    padding-bottom: .75rem;
}

.interactive-viewer.is-expanded .interactive-frame {
    border-radius: 0;
    height: 100%;
    margin-top: 1rem;
}

body.interactive-open {
    overflow: hidden;
}

.split {
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
}

.activity-dashboard {
    display: grid;
    gap: 1rem;
    margin-top: 1rem;
}

.activity-metric {
    display: grid;
    gap: .35rem;
}

.activity-metric strong {
    color: var(--brand);
    font-size: 1.6rem;
    line-height: 1.15;
}

.activity-visuals {
    grid-template-columns: minmax(0, 1.2fr) minmax(300px, .8fr);
}

.activity-section-heading {
    align-items: baseline;
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1rem;
    justify-content: space-between;
}

.activity-section-heading h2,
.activity-timeline-card h2 {
    margin-bottom: .4rem;
}

.activity-bars {
    display: grid;
    gap: .85rem;
}

.activity-total-row {
    align-items: center;
    display: grid;
    gap: .75rem;
    grid-template-columns: minmax(160px, .8fr) minmax(160px, 1.2fr) auto;
}

.activity-total-row .muted,
.timeline-row-label span {
    display: block;
    font-size: .86rem;
}

.activity-total-track {
    background: #edf3f7;
    border-radius: 999px;
    height: 12px;
    overflow: hidden;
}

.activity-total-track span {
    background: linear-gradient(90deg, var(--brand), #2563eb);
    border-radius: inherit;
    display: block;
    height: 100%;
}

.activity-day-summary {
    align-items: end;
    display: grid;
    gap: .75rem;
    grid-template-columns: repeat(7, minmax(54px, 1fr));
    min-height: 190px;
}

.activity-day-summary.is-single {
    grid-template-columns: minmax(120px, 220px);
    justify-content: start;
}

.activity-day-column {
    align-items: center;
    display: grid;
    gap: .35rem;
    justify-items: center;
}

.activity-day-bar {
    background: linear-gradient(180deg, #2563eb, var(--brand));
    border-radius: 6px 6px 2px 2px;
    min-height: 8px;
    width: 100%;
}

.timeline-scale {
    color: var(--muted);
    display: grid;
    font-size: .82rem;
    grid-template-columns: repeat(5, 1fr);
    margin: .75rem 0 .4rem 210px;
}

.timeline-scale span {
    border-left: 1px solid var(--line);
    padding-left: .35rem;
}

.activity-timeline {
    display: grid;
    gap: .55rem;
}

.timeline-day-label {
    color: var(--muted);
    font-weight: 850;
    margin-top: .35rem;
}

.timeline-row {
    align-items: center;
    display: grid;
    gap: .75rem;
    grid-template-columns: 190px minmax(360px, 1fr);
}

.timeline-row-label {
    min-width: 0;
}

.timeline-row-label strong,
.timeline-row-label span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.timeline-track {
    background:
        linear-gradient(90deg, rgba(216, 225, 232, .9) 1px, transparent 1px) 0 0 / 25% 100%,
        #f8fbfb;
    border: 1px solid var(--line);
    border-radius: 6px;
    height: 38px;
    overflow: hidden;
    position: relative;
}

.timeline-session {
    align-items: center;
    border-radius: 5px;
    color: #fff;
    display: flex;
    font-size: .78rem;
    font-weight: 800;
    height: 26px;
    min-width: 8px;
    overflow: hidden;
    padding: 0 .4rem;
    position: absolute;
    text-decoration: none;
    top: 5px;
}

.timeline-session:hover {
    color: #fff;
    filter: brightness(.92);
    text-decoration: none;
}

.timeline-session span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.timeline-row.is-empty .timeline-track {
    opacity: .65;
}

.live-status {
    align-items: center;
    color: var(--ok);
    display: inline-flex;
    font-size: .82rem;
    font-weight: 850;
    gap: .35rem;
    margin-bottom: .25rem;
}

.live-status span {
    background: var(--ok);
    border-radius: 999px;
    box-shadow: 0 0 0 5px rgba(25, 115, 72, .14);
    display: inline-block;
    height: 9px;
    width: 9px;
}

@media (max-width: 820px) {
    .hero,
    .split,
    .grid.two,
    .grid.three,
    .grid.four {
        grid-template-columns: 1fr;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .module-toolbar {
        align-items: stretch;
        grid-template-columns: 1fr;
    }

    .module-toolbar .actions {
        justify-content: flex-start;
    }

    .module-row > summary {
        align-items: flex-start;
        flex-direction: column;
    }

    .module-row-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .module-row-actions {
        margin-left: 0;
    }

    .activity-total-row,
    .timeline-row {
        grid-template-columns: 1fr;
    }

    .timeline-scale {
        margin-left: 0;
    }

    .timeline-track {
        min-width: 520px;
    }

    .activity-timeline {
        overflow-x: auto;
    }

    .activity-day-summary {
        grid-template-columns: repeat(7, minmax(44px, 1fr));
    }
}
