:root {
    --record-bg: #f4f6f8;
    --record-panel: #ffffff;
    --record-panel-subtle: #f8fafb;
    --record-sidebar: #f1f4f7;
    --record-ink: #22292f;
    --record-muted: #68737d;
    --record-faint: #8a96a0;
    --record-line: #d9e1e7;
    --record-line-strong: #c4d0da;
    --record-accent: #df684d;
    --record-accent-strong: #c85139;
    --record-accent-soft: #fff1ec;
    --record-focus: rgba(223, 104, 77, 0.22);
    --record-blue-soft: #edf5ff;
    --record-green-soft: #e7f6ee;
    --record-shadow: 0 1px 2px rgba(20, 31, 40, 0.06);
    --record-shadow-lg: 0 18px 45px rgba(20, 31, 40, 0.14);
    --record-radius: 10px;
    --record-radius-sm: 7px;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

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

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-header {
    height: 64px;
    padding: 0 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    background: var(--record-panel);
    border-bottom: 1px solid var(--record-line);
}

.eyebrow {
    margin: 0 0 1px;
    color: var(--record-faint);
    font-size: 0.66rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.app-header h1 {
    margin: 0;
    font-family: Fredoka, Inter, sans-serif;
    font-size: 1.62rem;
    line-height: 1;
    font-weight: 700;
}

.app-header h1 span {
    color: var(--record-accent);
}

.header-actions,
.class-tools,
.page-actions,
.import-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.icon-btn,
.dashboard-link-btn,
.btn-secondary,
.btn-primary {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--record-ink);
    background: var(--record-panel);
    border: 1px solid var(--record-line);
    border-radius: var(--record-radius-sm);
    font-weight: 800;
    text-decoration: none;
    transition: background 0.14s, border-color 0.14s, color 0.14s;
}

.icon-btn,
.dashboard-link-btn {
    width: 36px;
    height: 36px;
    padding: 0;
}

.btn-secondary,
.btn-primary {
    padding: 8px 13px;
}

.btn-primary {
    color: #ffffff;
    background: var(--record-accent);
    border-color: var(--record-accent);
}

.icon-btn:hover,
.dashboard-link-btn:hover,
.btn-secondary:hover {
    background: var(--record-panel-subtle);
    border-color: var(--record-line-strong);
}

.btn-primary:hover {
    background: var(--record-accent-strong);
    border-color: var(--record-accent-strong);
}

.icon-btn svg,
.dashboard-link-btn svg {
    width: 18px;
    height: 18px;
}

.record-layout {
    height: calc(100vh - 64px);
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
    min-height: 0;
    overflow: auto;
    background: var(--record-sidebar);
    border-right: 1px solid var(--record-line);
}

.workbench {
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--record-panel);
}

.sidebar-section {
    padding: 14px 14px 16px;
    border-bottom: 1px solid var(--record-line);
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

h2,
h3,
label {
    margin: 0;
}

h2 {
    font-size: 0.92rem;
}

h3 {
    margin-top: 18px;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

label {
    display: block;
    margin-bottom: 6px;
    color: var(--record-muted);
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0;
}

.muted {
    margin: 8px 0 0;
    color: var(--record-muted);
    font-size: 0.82rem;
}

.class-tools {
    margin-top: 12px;
}

.dashboard-shortcut {
    display: none;
}

.select-input,
input,
textarea {
    width: 100%;
    color: var(--record-ink);
    background: #ffffff;
    border: 1px solid var(--record-line);
    border-radius: var(--record-radius-sm);
    outline: none;
}

.select-input,
input {
    min-height: 36px;
    padding: 7px 9px;
}

textarea {
    min-width: 260px;
    padding: 10px;
    resize: vertical;
}

.select-input:focus,
input:focus,
textarea:focus {
    border-color: var(--record-accent);
    box-shadow: 0 0 0 3px var(--record-focus);
}

.page-list,
.template-list {
    display: grid;
    gap: 5px;
}

.page-tab,
.template-btn {
    width: 100%;
    padding: 10px 9px;
    display: grid;
    gap: 3px;
    text-align: left;
    color: var(--record-ink);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--record-radius-sm);
    box-shadow: none;
    transition: background 0.14s, border-color 0.14s;
}

.template-btn {
    background: #ffffff;
    border-color: var(--record-line);
}

.page-tab span,
.template-btn strong {
    font-weight: 800;
}

.page-tab small,
.template-btn span {
    color: var(--record-muted);
    font-size: 0.76rem;
}

.page-tab.is-active {
    background: #ffffff;
    border-color: var(--record-line-strong);
    box-shadow: inset 3px 0 0 var(--record-accent);
}

.page-tab:hover,
.template-btn:hover {
    background: #ffffff;
    border-color: var(--record-line-strong);
}

.archived-pages {
    margin-top: 6px;
}

.archived-pages summary,
.tool-drawer summary,
.page-settings-drawer summary,
.tool-strip-drawer summary,
.metadata-field summary,
.evidence-field summary,
.analysis > summary {
    min-height: 34px;
    padding: 7px 9px;
    color: var(--record-ink);
    background: #ffffff;
    border: 1px solid var(--record-line);
    border-radius: var(--record-radius-sm);
    font-size: 0.82rem;
    font-weight: 800;
    list-style-position: inside;
    cursor: pointer;
}

.archived-pages summary {
    color: var(--record-muted);
}

.page-tab-secondary {
    opacity: 0.78;
}

.tool-drawer {
    padding-top: 12px;
    padding-bottom: 12px;
}

.drawer-body,
.custom-page-form,
.import-csv-form {
    display: grid;
    gap: 9px;
    margin-top: 12px;
}

.custom-page-form label {
    margin-top: 4px;
}

.page-toolbar {
    min-height: 90px;
    padding: 18px 22px 16px;
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto;
    align-items: start;
    gap: 18px;
    background: var(--record-panel);
    border-bottom: 1px solid var(--record-line);
}

.page-title-input {
    min-height: 38px;
    padding: 2px 0;
    color: var(--record-ink);
    background: transparent;
    border-color: transparent;
    border-radius: 0;
    font-family: Fredoka, Inter, sans-serif;
    font-size: 1.62rem;
    font-weight: 800;
}

.page-title-input:focus {
    border-color: transparent;
    box-shadow: inset 0 -3px 0 var(--record-accent);
}

.page-settings-drawer {
    min-width: 176px;
}

.page-settings-drawer summary {
    background: var(--record-panel-subtle);
}

.page-settings-grid {
    width: min(680px, calc(100vw - 40px));
    margin-top: 10px;
    display: grid;
    grid-template-columns: repeat(4, minmax(96px, 1fr));
    gap: 10px;
}

.page-actions {
    grid-column: 1 / -1;
}

.compact-field {
    min-width: 110px;
}

.session-form {
    padding: 12px 22px;
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 140px 82px minmax(112px, auto) minmax(150px, auto) auto;
    align-items: end;
    gap: 10px;
    background: var(--record-panel-subtle);
    border-bottom: 1px solid var(--record-line);
}

.session-form.is-star-award {
    grid-template-columns: minmax(150px, 1fr) 140px minmax(160px, 1fr) 120px minmax(180px, 1fr) minmax(190px, 1.2fr);
}

.session-form.is-star-award .btn-primary {
    grid-column: 1 / -1;
    justify-self: end;
    min-width: 140px;
}

.metadata-field,
.evidence-field {
    align-self: stretch;
    min-width: 150px;
}

.metadata-field summary,
.evidence-field summary {
    background: #ffffff;
}

.metadata-field label,
.evidence-field label {
    margin-top: 8px;
}

.metadata-field input {
    margin-bottom: 2px;
}

.evidence-field textarea {
    margin-top: 8px;
}

.tool-strip-drawer {
    padding: 8px 22px;
    background: #ffffff;
    border-bottom: 1px solid var(--record-line);
}

.tool-strip-drawer summary {
    width: fit-content;
    min-height: 32px;
    padding: 6px 9px;
    color: var(--record-accent-strong);
    background: #ffffff;
}

.builder-panel {
    padding: 10px 22px;
    background: #ffffff;
    border-bottom: 1px solid var(--record-line);
}

.builder-drawer summary {
    width: fit-content;
    min-height: 32px;
    padding: 6px 9px;
    color: var(--record-ink);
    background: var(--record-panel-subtle);
    border: 1px solid var(--record-line);
    border-radius: var(--record-radius-sm);
    font-size: 0.82rem;
    font-weight: 800;
    list-style-position: inside;
    cursor: pointer;
}

.builder-grid {
    margin-top: 10px;
    display: grid;
    grid-template-columns: minmax(220px, 0.8fr) minmax(380px, 1.4fr) minmax(320px, 1.1fr);
    gap: 10px;
}

.builder-card {
    padding: 10px;
    display: grid;
    gap: 8px;
    background: var(--record-panel-subtle);
    border: 1px solid var(--record-line);
    border-radius: var(--record-radius-sm);
}

.builder-card h3 {
    margin: 0 0 2px;
}

.builder-field-list {
    align-content: start;
    max-height: 320px;
    overflow: auto;
}

.builder-field-row {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) 118px 96px minmax(130px, 1fr) 74px auto auto;
    align-items: end;
    gap: 6px;
    padding: 7px;
    background: #ffffff;
    border: 1px solid var(--record-line);
    border-radius: var(--record-radius-sm);
}

.builder-hide-toggle {
    width: fit-content;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    color: var(--record-muted);
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: none;
}

.builder-hide-toggle input {
    width: 16px;
    min-height: 16px;
    accent-color: var(--record-accent);
}

.builder-inline,
.builder-rule-grid {
    display: grid;
    gap: 8px;
}

.builder-inline {
    grid-template-columns: minmax(150px, 1fr) auto auto;
}

.builder-rule-grid {
    grid-template-columns: repeat(3, minmax(110px, 1fr));
    align-items: end;
}

.session-strip {
    min-height: 58px;
    padding: 9px 22px;
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    background: #ffffff;
    border-bottom: 1px solid var(--record-line);
}

.session-chip {
    min-width: 124px;
    padding: 8px 10px;
    display: grid;
    gap: 2px;
    flex: 0 0 auto;
    color: var(--record-ink);
    text-align: left;
    background: var(--record-panel-subtle);
    border: 1px solid var(--record-line);
    border-radius: var(--record-radius-sm);
}

.session-chip span,
.session-chip small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-chip span {
    font-weight: 800;
}

.session-chip small {
    color: var(--record-muted);
    font-size: 0.7rem;
}

.session-chip.is-active {
    color: var(--record-accent-strong);
    background: var(--record-accent-soft);
    border-color: rgba(223, 104, 77, 0.42);
}

.star-view-chip {
    min-width: 148px;
}

.builder-view-chip {
    min-width: 156px;
}

.table-wrap {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: auto;
    background: #ffffff;
}

.record-table {
    width: 100%;
    min-width: 560px;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.86rem;
    background: #ffffff;
}

.record-table.is-week-view {
    min-width: 860px;
}

.record-table.is-star-tracker {
    min-width: 880px;
}

.record-table.is-builder-table {
    min-width: 980px;
}

.record-table th,
.record-table td {
    padding: 8px 10px;
    border-right: 1px solid var(--record-line);
    border-bottom: 1px solid var(--record-line);
    vertical-align: middle;
}

.record-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f3f7fb;
    color: #33404c;
    text-align: left;
}

.record-table thead th:first-child,
.record-table tbody th {
    position: sticky;
    left: 0;
    z-index: 1;
    min-width: 190px;
    background: #ffffff;
    text-align: left;
}

.record-table thead th:first-child {
    z-index: 3;
    background: #f3f7fb;
}

.record-table tbody tr:nth-child(even) td,
.record-table tbody tr:nth-child(even) th {
    background-color: #fbfcfd;
}

.record-table tbody tr:hover td,
.record-table tbody tr:hover th {
    background-color: var(--record-blue-soft);
}

.record-table th span,
.record-table th small,
.record-table th em {
    display: block;
}

.record-table th small,
.record-table th em {
    margin-top: 2px;
    color: var(--record-muted);
    font-size: 0.7rem;
    font-style: normal;
}

.record-table th em {
    color: var(--record-accent-strong);
}

.status-pill {
    width: fit-content;
    min-height: 24px;
    padding: 4px 9px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 900;
}

.star-status-button {
    border: 1px solid transparent;
    cursor: pointer;
}

.star-status-button:hover,
.star-status-button:focus-visible {
    border-color: currentColor;
    box-shadow: 0 0 0 3px var(--record-focus);
}

.star-status-button:active {
    transform: translateY(1px);
}

.status-pill::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: currentColor;
}

.status-pill.is-had {
    color: #247a57;
    background: var(--record-green-soft);
}

.status-pill.is-not-had {
    color: #69737b;
    background: #eef1f3;
}

.latest-award {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    white-space: nowrap;
}

.latest-award strong,
.latest-award span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.latest-award span,
.muted-inline {
    color: var(--record-muted);
    font-size: 0.76rem;
    font-style: normal;
}

.mini-action {
    min-height: 30px;
    padding: 5px 9px;
    color: var(--record-ink);
    background: var(--record-panel);
    border: 1px solid var(--record-line);
    border-radius: var(--record-radius-sm);
    font-size: 0.76rem;
    font-weight: 900;
}

.mini-action:hover {
    background: var(--record-panel-subtle);
    border-color: var(--record-line-strong);
}

.star-empty-row {
    padding: 18px;
    color: var(--record-muted);
    text-align: center;
}

.builder-add-field-heading {
    width: 104px;
}

.record-table th[data-field-color="grey"] {
    background: #eef1f3;
}

.record-table th[data-field-color="blue"] {
    background: #edf5ff;
}

.record-table th[data-field-color="green"] {
    background: #e7f6ee;
}

.record-table th[data-field-color="red"] {
    background: #fff0ed;
}

.record-table th[data-field-color="orange"] {
    background: #fff5e8;
}

.record-table th[data-field-color="purple"] {
    background: #f3efff;
}

.builder-row-spacer {
    width: 104px;
    background: #ffffff;
}

.builder-cell {
    min-width: 132px;
}

.builder-cell-input {
    min-width: 130px;
    min-height: 32px;
    padding: 6px 8px;
    font-size: 0.82rem;
}

.builder-cell-status,
.builder-cell-select {
    min-width: 150px;
}

.builder-note-input {
    min-width: 190px;
    min-height: 32px;
    resize: vertical;
}

.builder-check input {
    width: 18px;
    min-height: 18px;
    accent-color: var(--record-accent);
}

.entry-control {
    display: grid;
    gap: 5px;
    min-width: 116px;
}

.entry-score {
    grid-template-columns: 74px auto;
    align-items: center;
}

.tick-entry,
.absent-entry {
    width: fit-content;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin: 0;
    color: var(--record-ink);
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: none;
}

.absent-entry {
    color: var(--record-muted);
    font-size: 0.74rem;
    white-space: nowrap;
}

.tick-entry input {
    width: 18px;
    min-height: 18px;
    accent-color: var(--record-accent);
}

.absent-entry input {
    width: 16px;
    min-height: 16px;
    accent-color: var(--record-accent);
}

.score-entry {
    max-width: 68px;
    min-height: 31px;
    font-weight: 900;
}

.cell-note {
    grid-column: 1 / -1;
    height: 0;
    min-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow: hidden;
    border-color: transparent;
    opacity: 0;
    pointer-events: none;
    font-size: 0.8rem;
    transition: opacity 0.12s;
}

.cell-note:not(:placeholder-shown),
.record-table td:hover .cell-note,
.record-table td:focus-within .cell-note,
.cell-note:focus {
    height: auto;
    min-height: 30px;
    padding-top: 7px;
    padding-bottom: 7px;
    border-color: var(--record-line);
    opacity: 1;
    pointer-events: auto;
}

.empty-state {
    margin: 28px;
    padding: 18px;
    color: var(--record-muted);
    background: var(--record-panel-subtle);
    border: 1px dashed var(--record-line);
    border-radius: var(--record-radius);
}

.analysis {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 20;
    width: min(360px, calc(100vw - 32px));
}

.analysis > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--record-green-soft);
    box-shadow: var(--record-shadow);
}

.analysis-body {
    max-height: calc(100vh - 154px);
    margin-top: 10px;
    padding: 14px;
    overflow: auto;
    background: var(--record-panel);
    border: 1px solid var(--record-line);
    border-radius: var(--record-radius);
    box-shadow: var(--record-shadow-lg);
}

.analysis:not([open]) .analysis-body {
    display: none;
}

.analysis-header {
    margin-bottom: 12px;
}

.save-status {
    color: var(--record-muted);
    font-size: 0.74rem;
    white-space: nowrap;
}

.snapshot-picker,
.pupil-snapshot-panel {
    margin-bottom: 12px;
}

.snapshot-summary,
.analysis-grid {
    display: grid;
    gap: 8px;
}

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

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

.analysis-card {
    min-height: 68px;
    padding: 10px;
    display: grid;
    align-content: center;
    gap: 2px;
    background: var(--record-green-soft);
    border: 1px solid var(--record-line);
    border-radius: var(--record-radius-sm);
}

.metric {
    font-size: 1.24rem;
    font-weight: 900;
}

.label {
    color: var(--record-muted);
    font-size: 0.74rem;
}

.trend-list,
.snapshot-list,
.smart-groups,
.compact-list,
.evidence-list {
    display: grid;
    gap: 7px;
}

.trend-row,
.snapshot-row,
.smart-group,
.compact-list span,
.evidence-list details {
    padding: 8px 9px;
    background: #ffffff;
    border: 1px solid var(--record-line);
    border-radius: var(--record-radius-sm);
}

.trend-row,
.snapshot-row,
.smart-group summary {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.smart-group summary {
    font-weight: 800;
}

.smart-group p {
    margin: 8px 0 0;
    color: var(--record-muted);
    font-size: 0.84rem;
}

.evidence-list summary {
    font-weight: 800;
}

.evidence-list pre {
    max-height: 260px;
    overflow: auto;
    margin: 8px 0 0;
    white-space: pre-wrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.78rem;
}

.fatal-error {
    margin: 24px;
    padding: 24px;
    background: white;
    border: 1px solid var(--record-line);
    border-radius: var(--record-radius);
    box-shadow: var(--record-shadow);
}

@media (max-width: 1180px) {
    .record-layout {
        grid-template-columns: 232px minmax(0, 1fr);
        height: auto;
        min-height: calc(100vh - 64px);
    }

    .session-form {
        grid-template-columns: minmax(170px, 1fr) 135px 82px auto;
    }

    .session-form.is-star-award {
        grid-template-columns: repeat(3, minmax(150px, 1fr)) auto;
    }

    .session-form.is-star-award .btn-primary {
        grid-column: auto;
        justify-self: stretch;
    }
}

@media (max-width: 820px) {
    .app-header {
        height: auto;
        min-height: 62px;
        padding: 10px 12px;
    }

    .record-layout {
        display: block;
        min-height: 0;
    }

    .sidebar {
        border-right: 0;
        border-bottom: 1px solid var(--record-line);
    }

    .page-toolbar,
    .session-form,
    .session-form.is-star-award,
    .page-settings-grid {
        grid-template-columns: 1fr;
    }

    .session-form.is-star-award .btn-primary {
        grid-column: auto;
    }

    .page-toolbar,
    .session-form,
    .builder-panel,
    .tool-strip-drawer,
    .session-strip {
        padding-left: 14px;
        padding-right: 14px;
    }

    .builder-grid,
    .builder-rule-grid,
    .builder-inline {
        grid-template-columns: 1fr;
    }

    .builder-field-row {
        grid-template-columns: 1fr;
    }

    .analysis {
        position: static;
        margin: 10px 12px 12px;
        width: auto;
    }

    .analysis-body {
        max-height: 68vh;
    }

    .analysis-grid,
    .snapshot-summary {
        grid-template-columns: 1fr;
    }

    .table-wrap {
        max-height: 70vh;
    }
}

@media print {
    body {
        background: white;
    }

    .app-header,
    .sidebar,
    .session-form,
    .builder-panel,
    .analysis,
    .page-settings-drawer,
    .tool-strip-drawer {
        display: none !important;
    }

    .record-layout,
    .workbench {
        display: block;
        height: auto;
        padding: 0;
        border: 0;
        box-shadow: none;
    }

    .table-wrap {
        overflow: visible;
    }

    .record-table {
        min-width: 0;
        font-size: 0.75rem;
    }
}
