/* Reports Online — design system
   Light and dark are both first-class: teachers do reports at night. Colour is
   defined once as tokens; only the tokens change between themes. */

:root {
    color-scheme: light dark;

    --brand-500: #0d7fb0;
    --brand-600: #0a6a94;
    --brand-50: #e8f4fa;

    --ink: #16212c;
    --ink-soft: #55677a;
    --ink-faint: #8397aa;

    --surface: #ffffff;
    --surface-sunken: #f4f7f9;
    --surface-raised: #ffffff;
    --line: #e2e9ef;
    --line-strong: #cbd7e1;

    --ok: #17795e;
    --ok-bg: #e6f4ef;
    --warn: #8a5a00;
    --warn-bg: #fdf3e2;
    --danger: #b3261e;
    --danger-bg: #fdecea;

    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(16, 33, 48, .06), 0 1px 3px rgba(16, 33, 48, .05);
    --shadow-md: 0 4px 12px rgba(16, 33, 48, .08);
    --measure: 68rem;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --brand-500: #3aa6d6;
        --brand-600: #55b8e4;
        --brand-50: #10293a;

        --ink: #e6edf3;
        --ink-soft: #a3b4c4;
        --ink-faint: #7d90a1;

        --surface: #121a22;
        --surface-sunken: #0d141a;
        --surface-raised: #18222c;
        --line: #24313d;
        --line-strong: #33434f;

        --ok: #4cc79f;
        --ok-bg: #102b23;
        --warn: #e0b063;
        --warn-bg: #2c2213;
        --danger: #f0857c;
        --danger-bg: #2e1614;

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow-md: 0 6px 18px rgba(0, 0, 0, .45);
    }
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--ink);
    background: var(--surface-sunken);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-500); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--brand-600); }

h1 { font-size: 1.75rem; line-height: 1.25; letter-spacing: -.02em; margin: 0 0 .35rem; }
h2 { font-size: 1.15rem; margin: 0 0 .5rem; letter-spacing: -.01em; }
p { margin: 0 0 1rem; }
.muted { color: var(--ink-soft); }
.small { font-size: .875rem; }

/* ---------- app shell ---------- */

.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: .7rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.brand {
    display: flex; align-items: center; gap: .55rem;
    font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em;
    color: var(--ink); text-decoration: none;
}
.brand-mark {
    display: grid; place-items: center;
    width: 28px; height: 28px; border-radius: 8px;
    background: var(--brand-500); color: #fff; font-size: .85rem; font-weight: 800;
}
.topbar nav { display: flex; align-items: center; gap: 1rem; font-size: .92rem; }
.topbar .who { color: var(--ink-soft); }
.inline { display: inline; margin: 0; }
.linkish {
    background: none; border: 0; padding: 0; cursor: pointer;
    font: inherit; color: var(--brand-500); text-decoration: underline;
}

main { max-width: var(--measure); margin: 2rem auto 4rem; padding: 0 1.5rem; }

footer {
    max-width: var(--measure); margin: 0 auto 2.5rem; padding: 1.25rem 1.5rem 0;
    border-top: 1px solid var(--line); color: var(--ink-faint); font-size: .875rem;
}

.page-head { margin-bottom: 1.5rem; }
.breadcrumb { font-size: .9rem; margin-bottom: .5rem; }
.breadcrumb a { text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* ---------- cards & tables ---------- */

.card {
    background: var(--surface-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.card + .card { margin-top: 1rem; }
.card-head {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: .85rem 1.1rem; border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface-sunken) 55%, transparent);
}
.card-body { padding: 1.1rem; }

table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td { text-align: left; padding: .7rem 1.1rem; border-bottom: 1px solid var(--line); }
table.grid th {
    font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
    color: var(--ink-soft); background: color-mix(in srgb, var(--surface-sunken) 55%, transparent);
}
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover { background: color-mix(in srgb, var(--brand-50) 45%, transparent); }
table.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid a { font-weight: 600; text-decoration: none; }
table.grid a:hover { text-decoration: underline; }

/* ---------- messages ---------- */

.notice, .error, .success {
    display: flex; gap: .6rem; align-items: flex-start;
    padding: .7rem .95rem; border-radius: var(--radius); margin: 0 0 1.25rem;
    border: 1px solid transparent; font-size: .95rem;
}
.notice { background: var(--brand-50); border-color: color-mix(in srgb, var(--brand-500) 25%, transparent); }
.error { background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 30%, transparent); color: var(--danger); }
.success { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 30%, transparent); color: var(--ok); }

/* ---------- buttons ---------- */

.btn {
    display: inline-flex; align-items: center; gap: .45rem;
    padding: .55rem 1.05rem; border: 1px solid transparent; border-radius: 8px;
    font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer;
    background: var(--brand-500); color: #fff; text-decoration: none;
    transition: background .12s ease, transform .06s ease, box-shadow .12s ease;
}
.btn:hover { background: var(--brand-600); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn.secondary:hover { background: var(--surface-sunken); color: var(--ink); }
.btn.ghost { background: transparent; color: var(--brand-500); }
.btn.ghost:hover { background: var(--brand-50); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }

/* ---------- forms ---------- */

label { font-weight: 600; font-size: .9rem; }
input[type="text"], input[type="password"], input[type="search"], select, textarea {
    width: 100%; padding: .6rem .75rem; font: inherit;
    color: var(--ink); background: var(--surface);
    border: 1px solid var(--line-strong); border-radius: 8px;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--brand-500);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-500) 22%, transparent);
}
textarea { line-height: 1.7; resize: vertical; min-height: 12rem; }

.field { margin-bottom: .9rem; }
.field label { display: block; margin-bottom: .3rem; }

.switchrow { display: flex; gap: 1.25rem; flex-wrap: wrap; margin: 0 0 1rem; }
.switchrow label { display: inline-flex; align-items: center; gap: .4rem; font-weight: 500; font-size: .92rem; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand-500); width: auto; }

/* ---------- sign in ---------- */

.login-shell {
    max-width: 23rem; margin: 4rem auto;
    background: var(--surface-raised); border: 1px solid var(--line);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 2rem;
}
.login-shell h1 { font-size: 1.4rem; }
.login-shell .tagline { color: var(--ink-soft); margin: .15rem 0 1.5rem; }
.login-shell .btn { width: 100%; justify-content: center; margin-top: 1.25rem; }
.login-shell .help { margin: 1.5rem 0 0; font-size: .875rem; color: var(--ink-soft); }

/* ---------- chips / tabs ---------- */

.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 1.25rem; }
.chip {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .35rem .8rem; border-radius: 999px;
    border: 1px solid var(--line-strong); background: var(--surface);
    color: var(--ink-soft); text-decoration: none; font-size: .9rem; font-weight: 500;
}
.chip:hover { border-color: var(--brand-500); color: var(--brand-500); }
.chip.active { background: var(--brand-500); border-color: var(--brand-500); color: #fff; }
.chip .count {
    font-size: .75rem; padding: 0 .35rem; border-radius: 999px;
    background: color-mix(in srgb, var(--ink) 10%, transparent);
}
.chip.active .count { background: rgba(255, 255, 255, .25); }

/* ---------- stats ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: .75rem; margin-bottom: 1.5rem; }
.stat {
    background: var(--surface-raised); border: 1px solid var(--line);
    border-radius: var(--radius); padding: .85rem 1rem;
}
.stat .value { font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .label { font-size: .8rem; color: var(--ink-soft); }

/* ---------- indicator grid ---------- */

.strand { margin-bottom: 1rem; }
.strand summary {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: .85rem 1.1rem; cursor: pointer; list-style: none;
    font-weight: 650; border-radius: var(--radius-lg);
}
.strand summary::-webkit-details-marker { display: none; }
.strand summary::after {
    content: "▾"; color: var(--ink-faint); transition: transform .15s ease;
}
.strand[open] summary::after { transform: rotate(180deg); }
.strand summary:hover { background: color-mix(in srgb, var(--brand-50) 50%, transparent); }
.strand .tally { font-size: .8rem; font-weight: 500; color: var(--ink-soft); }

.outcome { padding: .5rem 1.1rem 1rem; }
.outcome h3 {
    font-size: .8rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--ink-soft); margin: .75rem 0 .5rem; font-weight: 600;
}
.outcome .code { color: var(--ink-faint); font-weight: 500; text-transform: none; letter-spacing: 0; }

.ind {
    display: flex; align-items: flex-start; gap: .85rem;
    padding: .5rem .65rem; border-radius: 8px; border: 1px solid transparent;
}
.ind:hover { background: var(--surface-sunken); }
.ind.on-ac { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 28%, transparent); }
.ind.on-wt { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 28%, transparent); }
.ind .text { flex: 1; font-size: .95rem; }

.tri { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 7px; overflow: hidden; flex: none; }
.tri input { position: absolute; opacity: 0; pointer-events: none; }
.tri label {
    padding: .2rem .55rem; font-size: .75rem; font-weight: 600; cursor: pointer;
    background: var(--surface); color: var(--ink-soft); border-right: 1px solid var(--line-strong);
    user-select: none;
}
.tri label:last-child { border-right: 0; }
.tri input:checked + label { color: #fff; }
.tri input.v-ac:checked + label { background: var(--ok); }
.tri input.v-wt:checked + label { background: var(--warn); }
.tri input.v-no:checked + label { background: var(--ink-faint); }
.tri label:hover { background: var(--surface-sunken); }

/* sticky save bar for long grids */
.savebar {
    position: sticky; bottom: 0; z-index: 10;
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    margin-top: 1.5rem; padding: .8rem 1.1rem;
    background: var(--surface-raised); border: 1px solid var(--line);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
}

/* ---------- comment editor ---------- */

.editor-meta {
    display: flex; justify-content: space-between; align-items: center;
    gap: 1rem; margin-top: .4rem; font-size: .85rem; color: var(--ink-soft);
}
.counter.over { color: var(--danger); font-weight: 600; }

@media (max-width: 640px) {
    main { margin-top: 1.25rem; padding: 0 1rem; }
    .topbar { padding: .6rem 1rem; }
    h1 { font-size: 1.4rem; }
    table.grid th, table.grid td { padding: .6rem .75rem; }
    .ind { flex-wrap: wrap; }
    .card-head { flex-wrap: wrap; }
}

/* Report preview / print */
.report-name { font-size: 1.5rem; margin-bottom: 1rem; }
.report-block { margin-bottom: 1.5rem; }
.report-block h2 {
    font-size: .8rem; text-transform: uppercase; letter-spacing: .06em;
    color: var(--ink-soft); border-bottom: 1px solid var(--line);
    padding-bottom: .3rem; margin-bottom: .5rem;
}
.report-block p { margin: 0; line-height: 1.75; }

@media print {
    .topbar, footer, .no-print { display: none !important; }
    body { background: #fff; color: #000; font-size: 11pt; }
    main { margin: 0; padding: 0; max-width: none; }
    .card, .report-sheet { border: 0; box-shadow: none; background: #fff; }
    .card-body { padding: 0; }
    .report-block { break-inside: avoid; }
    .report-block h2 { color: #444; }
}

/* Class progress matrix — students down, subjects across */
.progressbar {
    height: .5rem; margin: 0 0 1.5rem; overflow: hidden;
    background: var(--surface-sunken);
    border: 1px solid var(--line); border-radius: 999px;
}
.progressbar span { display: block; height: 100%; background: var(--ok); transition: width .3s ease; }

.card-body.tight { padding-bottom: .25rem; }

.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center; font-size: .8rem; color: var(--ink-soft); }
.legend span { display: inline-flex; gap: .35rem; align-items: center; }
.legend .cell { pointer-events: none; flex: none; }

.matrix-scroll { overflow-x: auto; }

table.matrix { min-width: 100%; }
table.matrix th.col {
    /* Rotated so ten subjects fit on a laptop screen without scrolling. */
    height: 9rem; width: 2.9rem; padding: .5rem .25rem; vertical-align: bottom;
    font-size: .8rem; font-weight: 600; white-space: nowrap;
    /* Sentence case and no tracking: rotated subject names have to be read, and
       both cost width that only a longer name can use. */
    text-transform: none; letter-spacing: 0; color: var(--ink);
}
table.matrix th.col span {
    display: block; margin: 0 auto;
    writing-mode: vertical-rl; transform: rotate(180deg);
    /* Victoria has subjects like "Personal and Social Capability"; without a cap
       one name sets the height of the whole header. The full name stays in the
       th's title and in every cell's label. */
    max-height: 8.25rem; overflow: hidden; text-overflow: ellipsis;
}
table.matrix td.cellcell { width: 2.9rem; }
table.matrix td.num, table.matrix th.num { width: 4.5rem; }
table.matrix .stick {
    position: sticky; left: 0; z-index: 1;
    background: var(--surface); text-align: left; font-weight: 500; white-space: nowrap;
    /* Shrink to the longest name so the squares sit beside it rather than
       across a gap; the trailing Report column absorbs the slack instead. */
    width: 1%;
}
table.matrix thead .stick, table.matrix tfoot .stick { background: var(--surface-sunken); }
table.matrix tbody tr:hover .stick { background: var(--brand-50); }
table.matrix td.cellcell { padding: .25rem; text-align: center; }
table.matrix tfoot td { border-top: 1px solid var(--line-strong); font-weight: 600; }
table.matrix .all-done { color: var(--ok); }

.cell {
    display: inline-block; width: 1.6rem; height: 1.6rem; position: relative;
    border: 1px solid var(--line-strong); border-radius: 6px;
    background: var(--surface-sunken); text-decoration: none;
}
.cell:hover { border-color: var(--brand-500); box-shadow: 0 0 0 2px var(--brand-50); }
.cell:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }
.cell.done { background: var(--ok); border-color: var(--ok); }
/* A tick as well as a colour, so the grid still reads without colour vision. */
.cell.done::after {
    content: ""; position: absolute; left: .48rem; top: .2rem;
    width: .32rem; height: .68rem; border: solid #fff;
    border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.cell.started { background: var(--warn-bg); border-color: var(--warn); }
.cell.started::after {
    content: ""; position: absolute; left: .45rem; top: .45rem;
    width: .55rem; height: .55rem; border-radius: 50%; background: var(--warn);
}

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Teacher-authored indicators and improvements */
.tag {
    display: inline-block; margin-left: .5rem; padding: .05rem .4rem;
    font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
    color: var(--brand-600); background: var(--brand-50);
    border: 1px solid color-mix(in srgb, var(--brand-500) 30%, transparent);
    border-radius: 999px; vertical-align: .1em;
}
.linkish.danger { color: var(--danger); margin-left: .5rem; font-size: .8rem; }
#customTools .card-body { padding-top: .25rem; }
.own-improvement {
    margin-top: 1.25rem; padding-top: 1rem; border-top: 1px dashed var(--line-strong);
}
.own-improvement .field { max-width: 34rem; }

/* Rewriting assistant */
.assist {
    margin-top: 1.25rem; padding: 1rem; border-radius: var(--radius);
    background: var(--surface-sunken); border: 1px solid var(--line);
}
.assist-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .6rem; margin-bottom: .75rem; }
.assist ul.error { display: block; margin-bottom: .9rem; padding-left: 2rem; }
.assist ul.error li { margin: .15rem 0; }
.assist .actions label { font-weight: 500; }

/* Public demo */
.demo-who { display: flex; flex-wrap: wrap; gap: 1rem; }
.demo-who .field { flex: 1 1 12rem; margin-bottom: 0; }
.demo-result { border-color: var(--brand-500); }
.demo-comment {
    font-size: 1.05rem; line-height: 1.8;
    padding: 1rem 1.15rem; border-radius: var(--radius);
    background: var(--brand-50); border: 1px solid color-mix(in srgb, var(--brand-500) 25%, transparent);
}

/* Licence state, signup and roster editing */
.bar {
    display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: center; justify-content: center;
    padding: .6rem 1.5rem; font-size: .92rem; border-bottom: 1px solid transparent;
}
.bar-warn { background: var(--warn-bg); color: var(--warn); border-bottom-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.bar-stop { background: var(--danger-bg); color: var(--danger); border-bottom-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.bar .btn.small { padding: .3rem .8rem; font-size: .85rem; }
.bar-warn .btn { background: var(--warn); color: #fff; }
.bar-stop .btn { background: var(--danger); color: #fff; }

.two-up { display: flex; flex-wrap: wrap; gap: 1rem; }
.two-up .field { flex: 1 1 12rem; }
.fieldnote { display: block; margin-top: .25rem; font-size: .82rem; color: var(--danger); }

.pricebox {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem;
    margin: 1.25rem 0 .75rem; padding: 1.1rem;
    background: var(--surface-sunken); border: 1px solid var(--line); border-radius: var(--radius);
}
.pricebox-amount { font-size: 2rem; font-weight: 700; letter-spacing: -.02em; }

form.pronouns { display: inline-flex; gap: .25rem; }
.pronoun {
    padding: .15rem .5rem; font: inherit; font-size: .78rem; font-weight: 600; cursor: pointer;
    color: var(--ink-soft); background: var(--surface);
    border: 1px solid var(--line-strong); border-radius: 6px;
}
.pronoun:hover { background: var(--surface-sunken); }
.pronoun.on { background: var(--brand-500); border-color: var(--brand-500); color: #fff; }
