/* Blue and white, per Mia. Both supplied logos are white-on-transparent, so
   every surface they sit on has to be blue — hence the solid brand header. */

:root {
    color-scheme: light;

    /* Sampled from the school emblem in the supplied artwork. */
    --brand: #006bce;
    --brand-dark: #004e97;
    --brand-darker: #00335f;
    --brand-tint: #e8f1fb;
    --gold: #deae15;

    --bg: #f2f7fc;
    --surface: #ffffff;
    --line: #d8e3f0;
    --ink: #10233a;
    --muted: #5a6b80;

    --ok: #12784f;
    --ok-bg: #e4f5ec;
    --warn: #9a6207;
    --warn-bg: #fdf3e0;
    --bad: #b3261e;
    --bad-bg: #fdeceb;

    --radius: 12px;
    --shadow: 0 10px 30px rgba(16, 35, 58, 0.08);
}

* {
    box-sizing: border-box;
}

/* The UA rule for [hidden] is display:none at the same specificity as a class,
   so any .btn or .card we hide with the attribute would otherwise still show.
   Author-stylesheet wins over UA, hence !important. */
[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

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

h1,
h2,
h3,
p {
    margin: 0;
}

/* ---------- Brand header ---------- */

.masthead {
    background: linear-gradient(135deg, var(--brand-darker), var(--brand));
    color: #ffffff;
}

.masthead-inner {
    width: min(1140px, calc(100% - 32px));
    margin: 0 auto;
    padding: 16px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

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

.logo-archangel {
    height: 34px;
    width: auto;
}

.logo-school {
    height: 40px;
    width: auto;
}

.logo-divider {
    width: 1px;
    height: 30px;
    background: rgba(255, 255, 255, 0.35);
}

.masthead h1 {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.masthead .who {
    font-size: 0.85rem;
    opacity: 0.85;
}

.masthead-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ---------- Layout ---------- */

.page {
    width: min(1140px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 56px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 18px;
}

.card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.card-head h2 {
    font-size: 1.3rem;
    font-weight: 750;
    letter-spacing: -0.01em;
}

.subhead {
    margin: 26px 0 14px;
    font-size: 1.05rem;
    font-weight: 700;
}

.card-head p {
    color: var(--muted);
    font-size: 0.9rem;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.field {
    display: grid;
    gap: 6px;
    margin-bottom: 14px;
}

.field.full {
    grid-column: 1 / -1;
}

label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="time"],
select,
textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

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

/* WCAG wants a focus indicator with 3:1 contrast against what surrounds it.
   The old rgba(0,107,206,.35) ring measured 1.69:1 on white — visible to me,
   invisible to anyone relying on it. Solid brand blue measures 5.26:1. */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
    outline: 3px solid var(--brand);
    outline-offset: 2px;
    border-radius: 4px;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    border-color: var(--brand);
}

.masthead :focus-visible {
    outline-color: #ffffff;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
    font-weight: 650;
    cursor: pointer;
}

.btn:hover:not(:disabled) {
    background: var(--brand-dark);
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn.ghost {
    background: transparent;
    border-color: var(--line);
    color: var(--ink);
}

.btn.ghost:hover:not(:disabled) {
    background: var(--brand-tint);
    border-color: var(--brand);
}

.btn.on-brand {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.55);
    color: #fff;
    min-height: 44px;
    padding: 0 14px;
}

.btn.on-brand:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.24);
}

.btn.danger {
    background: transparent;
    border-color: var(--line);
    color: var(--bad);
}

.btn.danger:hover:not(:disabled) {
    background: var(--bad-bg);
    border-color: var(--bad);
}

.btn.big {
    width: 100%;
    min-height: 60px;
    font-size: 1.05rem;
}

/* iOS asks 44pt, Android 48dp. 36px failed both — these are the Delete and
   Edit buttons, the easiest ones to mis-tap and the worst ones to mis-tap. */
.btn.icon {
    min-height: 44px;
    padding: 0 12px;
    font-size: 0.9rem;
}

/* ---------- Messages ---------- */

.msg {
    display: none;
    padding: 11px 13px;
    border-radius: 8px;
    font-size: 0.92rem;
    font-weight: 550;
    margin-bottom: 14px;
}

.msg.show {
    display: block;
}

.msg.ok {
    background: var(--ok-bg);
    color: var(--ok);
    border: 1px solid rgba(18, 120, 79, 0.3);
}

.msg.error {
    background: var(--bad-bg);
    color: var(--bad);
    border: 1px solid rgba(179, 38, 30, 0.3);
}

.msg.info {
    background: var(--brand-tint);
    color: var(--brand-dark);
    border: 1px solid rgba(0, 107, 206, 0.25);
}

/* ---------- Status pills ---------- */

.pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
    background: var(--brand-tint);
    color: var(--brand-dark);
}

.pill.present,
.pill.checked-in {
    background: var(--ok-bg);
    color: var(--ok);
}

.pill.absent,
.pill.incomplete {
    background: var(--bad-bg);
    color: var(--bad);
}

.pill.expected,
.pill.late {
    background: var(--warn-bg);
    color: var(--warn);
}

.pill.holiday {
    background: #fbf3d6;
    color: #7a5f05;
}

.pill.not-scheduled,
.pill.upcoming,
.pill.excused {
    background: #eef2f7;
    color: var(--muted);
}

/* ---------- Today panel ---------- */

.today-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.today-date {
    font-size: 1.25rem;
    font-weight: 700;
}

.stamp-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.stamp {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 14px;
    background: var(--brand-tint);
}

.stamp .label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
}

.stamp .value {
    display: block;
    font-size: 1.4rem;
    font-weight: 750;
    font-variant-numeric: tabular-nums;
}

.stamp .value.empty {
    color: var(--muted);
    font-weight: 600;
}

.action-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

/* ---------- Tasks ---------- */

.task-form {
    display: flex;
    gap: 12px;
    align-items: end;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.task-form .field {
    margin-bottom: 0;
}

.task-field {
    flex: 1 1 260px;
}

.task-date {
    flex: 0 0 auto;
}

.task-date input {
    width: auto;
}

.align-end {
    align-self: end;
}

.task-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.task-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.task-row.done .task-text {
    text-decoration: line-through;
    color: var(--muted);
}

.task-check {
    width: 24px;
    height: 24px;
    flex: 0 0 auto;
    accent-color: var(--brand);
    cursor: pointer;
}

.task-text {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
    /* It is a <label> so tapping the words toggles the box, but it must still
       read as body copy rather than a form label. */
    font-size: 1rem;
    font-weight: 400;
    color: var(--ink);
    cursor: pointer;
}

.task-day {
    flex: 0 0 auto;
    font-size: 0.8rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

/* ---------- Tables ---------- */

.table-scroll {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 10px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

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

th {
    background: var(--brand-tint);
    color: var(--brand-darker);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
    position: sticky;
    top: 0;
}

tbody tr:last-child td {
    border-bottom: 0;
}

tbody tr:hover {
    background: #f7fbff;
}

td.num {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.empty-note {
    padding: 24px 12px;
    text-align: center;
    color: var(--muted);
}

/* ---------- Auth ---------- */

.auth-wrap {
    width: min(430px, 100%);
    margin: 48px auto;
}

.auth-tabs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    padding: 5px;
    background: var(--brand-tint);
    border-radius: 10px;
    margin-bottom: 20px;
}

.auth-tab {
    min-height: 40px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--brand-dark);
    font-weight: 650;
    cursor: pointer;
}

.auth-tab.active {
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 1px 3px rgba(16, 35, 58, 0.12);
}

.hint {
    font-size: 0.82rem;
    color: var(--muted);
}

.auth-first-time {
    margin-bottom: 14px;
}

/* ---------- Admin ---------- */

.toolbar {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.toolbar .field {
    margin-bottom: 0;
}

.toolbar input[type="date"],
.toolbar select {
    width: auto;
    min-width: 150px;
}

.weekday-set {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.weekday-set label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 7px;
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: 0.78rem;
    cursor: pointer;
}

.weekday-set input {
    accent-color: var(--brand);
    margin: 0;
}

.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.stat {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px;
    background: var(--surface);
}

.stat .n {
    font-size: 1.8rem;
    font-weight: 750;
    line-height: 1.1;
}

.stat .k {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
}

.row-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

dialog {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0;
    width: min(460px, calc(100% - 32px));
    box-shadow: 0 24px 60px rgba(16, 35, 58, 0.28);
}

dialog::backdrop {
    background: rgba(16, 35, 58, 0.45);
}

.dialog-body {
    padding: 20px;
}

.dialog-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 4px;
}

/* Inline style attributes are blocked by the page's own CSP (style-src 'self'),
   so every one-off tweak needs a class. */
.dialog-field,
.dialog-grid {
    margin-top: 16px;
}

.card-centered {
    text-align: center;
}

.not-found-note {
    margin: 10px 0 18px;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
}

footer.site {
    color: var(--muted);
    font-size: 0.82rem;
    text-align: center;
    padding-bottom: 28px;
}

.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;
}


/* ---------- Skip link ---------- */

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 10;
    padding: 12px 18px;
    background: var(--surface);
    color: var(--brand-dark);
    font-weight: 700;
    border-radius: 0 0 8px 0;
}

.skip-link:focus {
    left: 0;
}

.masthead-title {
    min-width: 0;
}

/* ---------- My record: cards on phones ---------- */

/* A seven-column table on a 375px screen is a horizontal-scroll puzzle. Both
   renderings are populated in one pass; only one is ever displayed. */
.record-cards {
    display: none;
    flex-direction: column;
    gap: 12px;
}

.record-card {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px;
    background: var(--surface);
}

.record-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.record-card-date {
    font-weight: 700;
    font-size: 1rem;
}

.record-card-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 14px;
    margin: 0;
}

.record-card-list dt {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 650;
}

.record-card-list dd {
    margin: 0;
    font-size: 1rem;
    overflow-wrap: anywhere;
}

.record-card-list:empty::after {
    content: "Nothing logged for this day.";
    color: var(--muted);
    font-size: 0.95rem;
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

@media (max-width: 700px) {
    .grid-2,
    .stamp-row,
    .action-row {
        grid-template-columns: 1fr;
    }

    .masthead-inner {
        justify-content: center;
        text-align: center;
    }

    .logo-school {
        height: 34px;
    }

    /* Secondary text creeps below comfortable reading size on a phone;
       nudge it back up rather than shrinking everything to fit. */
    .hint,
    .card-head p,
    .msg {
        font-size: 0.95rem;
    }

    .task-day {
        font-size: 0.9rem;
    }

    .task-field,
    .task-date,
    .task-date input,
    .task-form .btn {
        width: 100%;
        flex: 1 1 100%;
    }

    /* The student's record becomes cards; the table stays in the DOM for
       wide screens only. */
    .record-table {
        display: none;
    }

    .record-cards {
        display: flex;
    }

    .toolbar .btn {
        width: 100%;
    }

    /* A checkbox, the text, a date and a Delete button do not fit on one
       375px line — the summary ends up three words wide. Give the text the
       full line and let the controls wrap beneath it. */
    .task-row {
        flex-wrap: wrap;
        row-gap: 8px;
    }

    .task-text {
        flex: 1 1 calc(100% - 36px);
    }

    .task-day {
        margin-left: 36px;
    }

    .task-row .btn.icon {
        margin-left: auto;
    }

    .row-actions .btn {
        flex: 1 1 auto;
    }
}
