/* ==========================================================================
   DoodleMate Admin: the one stylesheet.

   Rules of the house (they come from the Content-Security-Policy):
   - This file is the only source of styling. No inline styles and no style elements.
   - Every url() points at a file on the admin origin. No data URIs.
   - States are switched by the `hidden` attribute, ARIA attributes or a
     modifier class. Nothing here depends on injected HTML.

   Contents
     1. Fonts
     2. Tokens (light, then dark)
     3. Base
     4. Utilities
     5. Page frame: header, section navigation, main
     6. Buttons and links
     7. Forms
     8. Notices (results, errors, warnings, success)
     9. Tags
    10. Sign-in view
    11. Teacher lookup and match list
    12. Teacher record: head, limit rows
    13. Data tables (classrooms, history)
    14. Change dialog
    15. History view
    16. Waiting and empty states
    17. Motion and forced colours
   ========================================================================== */

/* 1. Fonts ---------------------------------------------------------------- */
/* Cabin is the interface face. Cabin Sketch draws the "Doodle" half of the
   wordmark and nothing else. Both are SIL OFL 1.1 (assets/fonts/OFL.txt). */

@font-face {
  font-family: 'Cabin';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('assets/fonts/Cabin-Variable.woff2') format('woff2');
}

@font-face {
  font-family: 'Cabin Sketch';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('assets/fonts/CabinSketch-700.woff2') format('woff2');
}

/* 2. Tokens --------------------------------------------------------------- */

:root {
  color-scheme: light dark;

  /* Surfaces */
  --color-bg: #f5f2ec;            /* the page: warm paper, quieter than the product's */
  --color-surface: #ffffff;       /* cards, header, fields */
  --color-sunk: #ece8e0;          /* table heads, read-only values */

  /* Ink */
  --color-ink: #1a1a1a;           /* the product's pencil */
  --color-ink-2: #45413b;         /* secondary text */
  --color-ink-3: #625d55;         /* hints and meta; still AA on every surface */

  /* Lines */
  --color-line: #d8d2c7;          /* dividers; decoration only */
  --color-control: #857e73;       /* borders of fields and buttons; 3:1 or better */

  /* Accent: the product's utility plum */
  --color-accent: #6f5a8c;
  --color-accent-hover: #5a4775;
  --color-on-accent: #ffffff;
  --color-accent-soft: #efeaf6;

  /* Status */
  --color-danger: #a8271f;
  --color-danger-soft: #fbeceb;
  --color-danger-line: #c2453d;
  --color-caution: #7a4f00;
  --color-caution-soft: #fcf1d8;
  --color-caution-line: #a86f00;
  --color-ok: #22613b;
  --color-ok-soft: #e6f2ea;
  --color-ok-line: #3f8a5a;

  /* Brand: the wordmark only */
  --color-brand-coral: #e8645f;
  --color-brand-orange: #fd9830;

  --color-focus: #6f5a8c;
  --color-scrim: rgb(26 26 26 / 0.55);
  --shadow-dialog: 0 12px 40px rgb(26 26 26 / 0.28);

  /* Type */
  --font-ui: 'Cabin', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-brand: 'Cabin Sketch', 'Cabin', system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;

  --text-xs: 0.8125rem;   /* 13px: meta, table heads, tags */
  --text-sm: 0.9375rem;   /* 15px: tables, hints */
  --text-md: 1rem;        /* 16px: body and every field (no zoom on iOS) */
  --text-lg: 1.125rem;    /* 18px: section headings */
  --text-xl: 1.375rem;    /* 22px: view titles, the teacher's address */
  --text-2xl: 2rem;       /* 32px: the old and new value in the review */

  --leading-tight: 1.25;
  --leading: 1.5;

  /* Space: a 4px grid */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;

  /* Shape */
  --radius: 4px;
  --radius-lg: 6px;
  --border: 1px solid var(--color-line);
  --border-control: 1px solid var(--color-control);

  /* Size */
  --control-height: 2.5rem;       /* 40px with a mouse; 44px on touch, below */
  --page-max: 68rem;
  --measure: 38rem;               /* longest comfortable line of copy */
  --gutter: var(--space-4);
}

@media (pointer: coarse) {
  :root {
    --control-height: 2.75rem;
  }
}

@media (min-width: 45em) {
  :root {
    --gutter: var(--space-5);
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #1a1816;
    --color-surface: #23201d;
    --color-sunk: #141210;

    --color-ink: #f2eee7;
    --color-ink-2: #d0c9be;
    --color-ink-3: #aaa397;

    --color-line: #3b3733;
    --color-control: #8a8378;

    --color-accent: #bfabdf;
    --color-accent-hover: #d2c2ec;
    --color-on-accent: #1a1816;
    --color-accent-soft: #31293f;

    --color-danger: #f4a59f;
    --color-danger-soft: #3b1f1d;
    --color-danger-line: #d9665e;
    --color-caution: #f1c670;
    --color-caution-soft: #382b0f;
    --color-caution-line: #c9973a;
    --color-ok: #93d3a8;
    --color-ok-soft: #17301f;
    --color-ok-line: #5aa877;

    --color-focus: #bfabdf;
    --color-scrim: rgb(0 0 0 / 0.7);
    --shadow-dialog: 0 12px 40px rgb(0 0 0 / 0.6);
  }
}

/* 3. Base ----------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-ui);
  font-size: var(--text-md);
  line-height: var(--leading);
  font-variant-numeric: tabular-nums;
  overflow-wrap: break-word;
}

h1,
h2,
h3,
p,
ul,
ol,
dl,
dd,
figure {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

h1,
h2,
h3 {
  line-height: var(--leading-tight);
  font-weight: 700;
}

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

img {
  display: block;
  max-width: 100%;
}

/* `hidden` must win over any display rule below. */
[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

/* Headings and regions that receive focus from script show no ring. */
[tabindex='-1']:focus {
  outline: none;
}

::selection {
  background: var(--color-accent);
  color: var(--color-on-accent);
}

/* 4. Utilities ------------------------------------------------------------ */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

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

.nowrap {
  white-space: nowrap;
}

.stack > :not([hidden], .visually-hidden) ~ :not([hidden]) {
  margin-top: var(--space-4);
}

.stack-lg > :not([hidden], .visually-hidden) ~ :not([hidden]) {
  margin-top: var(--space-6);
}

/* 5. Page frame ----------------------------------------------------------- */

.skip-link {
  position: absolute;
  left: var(--space-2);
  top: var(--space-2);
  z-index: 10;
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface);
  color: var(--color-ink);
  border: var(--border-control);
  border-radius: var(--radius);
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

.app-header {
  background: var(--color-surface);
  border-bottom: var(--border);
}

/* Staging wears a caution band so it can never be taken for production. */
.app-header--staging {
  border-top: 6px solid var(--color-caution-line);
}

.app-header__bar,
.app-nav,
.app-main {
  width: 100%;
  max-width: var(--page-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.app-header__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  padding-block: var(--space-3);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  font-size: var(--text-xl);
  line-height: 1;
}

/* The brand wordmark: always bold, always these two faces and colours. */
.wordmark {
  font-weight: 700;
  white-space: nowrap;
}

.wordmark__doodle {
  font-family: var(--font-brand);
  color: var(--color-brand-coral);
}

.wordmark__mate {
  font-family: var(--font-ui);
  color: var(--color-brand-orange);
}

.brand__product {
  font-size: var(--text-md);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-ink);
}

.account {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-3);
  margin-inline-start: auto;
  font-size: var(--text-sm);
  min-width: 0;
}

.account__who {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: var(--leading-tight);
}

.account__email {
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.account__session {
  color: var(--color-ink-3);
  font-size: var(--text-xs);
}

.account__session--ending {
  color: var(--color-caution);
  font-weight: 700;
}

@media (max-width: 35.99em) {
  .account {
    flex: 1 1 100%;
    flex-wrap: nowrap;
    justify-content: space-between;
    margin-inline-start: 0;
  }

  .account__who {
    flex: 1 1 auto;
  }

  .account__email {
    max-width: 100%;
  }

  .account .btn {
    flex: none;
    white-space: nowrap;
  }
}

/* Section navigation: a row of tabs. New sections are new items here. */
.app-nav ul {
  display: flex;
  gap: var(--space-1);
  overflow-x: auto;
  margin-inline: calc(var(--space-3) * -1);
  padding-inline: 0;
}

.app-nav a {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0 var(--space-3);
  border-bottom: 3px solid transparent;
  color: var(--color-ink-2);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.app-nav a:hover {
  color: var(--color-ink);
  border-bottom-color: var(--color-line);
}

.app-nav a:focus-visible {
  outline-offset: -3px;
}

.app-nav a[aria-current='page'] {
  color: var(--color-ink);
  border-bottom-color: var(--color-accent);
}

.app-main {
  padding-block: var(--space-5) var(--space-7);
}

.view__title {
  font-size: var(--text-xl);
}

.view__lead {
  max-width: var(--measure);
  color: var(--color-ink-2);
  margin-top: var(--space-1);
}

.panel {
  background: var(--color-surface);
  border: var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

@media (min-width: 45em) {
  .panel {
    padding: var(--space-5);
  }
}

.section__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-1) var(--space-4);
  margin-bottom: var(--space-3);
}

.section__title {
  font-size: var(--text-lg);
}

.section__note {
  color: var(--color-ink-3);
  font-size: var(--text-sm);
}

/* 6. Buttons and links ---------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--control-height);
  padding: 0 var(--space-4);
  border: var(--border-control);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-ink);
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover {
  border-color: var(--color-ink);
}

.btn:active {
  background: var(--color-sunk);
}

/* One per view: the action the view exists for. */
.btn--primary {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-on-accent);
}

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

/* A way out or a minor action: reads as a link, keeps a full-size target. */
.btn--quiet {
  border-color: transparent;
  background: transparent;
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  padding-inline: var(--space-2);
}

.btn--quiet:hover {
  border-color: transparent;
  color: var(--color-ink);
}

.btn--quiet:active {
  background: transparent;
}

.btn.btn--quiet:disabled,
.btn.btn--quiet[aria-disabled='true'] {
  background: transparent;
  border-color: transparent;
}

.btn--wide {
  width: 100%;
}

.btn:disabled,
.btn[aria-disabled='true'] {
  background: var(--color-sunk);
  border-color: var(--color-line);
  color: var(--color-ink-3);
  cursor: not-allowed;
  text-decoration: none;
}

.link {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.link:hover {
  color: var(--color-ink);
}

/* 7. Forms ---------------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.field__label {
  font-weight: 700;
}

.field__hint {
  color: var(--color-ink-3);
  font-size: var(--text-sm);
  max-width: var(--measure);
}

.field__error {
  color: var(--color-danger);
  font-size: var(--text-sm);
  font-weight: 700;
}

.field__foot {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  color: var(--color-ink-3);
  font-size: var(--text-xs);
}

.field__count--over {
  color: var(--color-danger);
  font-weight: 700;
}

.input,
.textarea {
  width: 100%;
  min-height: var(--control-height);
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface);
  border: var(--border-control);
  border-radius: var(--radius);
  font-size: var(--text-md);
  line-height: 1.4;
}

.input:hover,
.textarea:hover {
  border-color: var(--color-ink);
}

.input--number {
  width: 6rem;
  font-size: var(--text-lg);
  font-weight: 700;
}

.textarea {
  min-height: 5.5rem;
  resize: vertical;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--color-ink-3);
  opacity: 1;
}

.field--error .input,
.field--error .textarea,
.input[aria-invalid='true'],
.textarea[aria-invalid='true'] {
  border-color: var(--color-danger-line);
  border-width: 2px;
}

.input:disabled,
.textarea:disabled {
  background: var(--color-sunk);
  border-color: var(--color-line);
  color: var(--color-ink-2);
  cursor: not-allowed;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

/* A fieldset used only to disable a group at once. */
.fieldset-plain {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

/* 8. Notices -------------------------------------------------------------- */
/* One shape for every message. The title says what happened; the body says
   what to do next. The variant is carried by the title's words and the bar,
   never by colour alone. */

.notice {
  padding: var(--space-3) var(--space-4);
  background: var(--color-accent-soft);
  border: var(--border);
  border-inline-start: 4px solid var(--color-accent);
  border-radius: var(--radius);
  color: var(--color-ink);
}

.notice__title {
  font-size: var(--text-md);
  font-weight: 700;
}

.notice__body {
  max-width: var(--measure);
  margin-top: var(--space-1);
}

.notice__list {
  margin-top: var(--space-1);
  padding-inline-start: var(--space-4);
  list-style: disc;
}

.notice__list li + li {
  margin-top: var(--space-1);
}

.notice__list .link {
  display: inline-block;
  padding-block: 0.25rem;
}

.notice__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  margin-top: var(--space-3);
}

.notice--danger {
  background: var(--color-danger-soft);
  border-inline-start-color: var(--color-danger-line);
}

.notice--danger .notice__title {
  color: var(--color-danger);
}

.notice--caution {
  background: var(--color-caution-soft);
  border-inline-start-color: var(--color-caution-line);
}

.notice--caution .notice__title {
  color: var(--color-caution);
}

.notice--ok {
  background: var(--color-ok-soft);
  border-inline-start-color: var(--color-ok-line);
}

.notice--ok .notice__title {
  color: var(--color-ok);
}

.notice--plain {
  background: var(--color-surface);
  border-inline-start-color: var(--color-control);
}

/* 9. Tags ----------------------------------------------------------------- */

.tag {
  display: inline-block;
  padding: 0.0625rem var(--space-2);
  border: 1px solid var(--color-control);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-ink-2);
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
  vertical-align: baseline;
}

.tag--caution {
  background: var(--color-caution-soft);
  border-color: var(--color-caution-line);
  color: var(--color-caution);
}

.tag--ok {
  background: var(--color-ok-soft);
  border-color: var(--color-ok-line);
  color: var(--color-ok);
}

/* 10. Sign-in view -------------------------------------------------------- */

.signin {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--gutter);
}

.signin__card {
  width: 100%;
  max-width: 24rem;
  text-align: center;
}

.signin__mascot {
  width: 6rem;
  height: 6rem;
  margin: 0 auto var(--space-1);
}

.signin__brand {
  justify-content: center;
  font-size: 1.75rem;
}

.signin__env {
  margin-top: var(--space-2);
}

.signin__lead {
  margin-top: var(--space-5);
  color: var(--color-ink-2);
}

.signin__action {
  margin-top: var(--space-5);
}

.signin__foot {
  margin-top: var(--space-4);
  color: var(--color-ink-3);
  font-size: var(--text-sm);
}

.signin .notice {
  margin-top: var(--space-5);
  text-align: start;
}

/* 11. Teacher lookup and match list --------------------------------------- */

.lookup__row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  max-width: 34rem;
}

.lookup__row .input {
  flex: 1 1 16rem;
  width: auto;
}

.match-list > li + li {
  margin-top: var(--space-2);
}

.match {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2) var(--space-4);
  align-items: center;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: var(--border);
  border-radius: var(--radius-lg);
}

.match__email {
  font-weight: 700;
}

.match__meta {
  color: var(--color-ink-2);
  font-size: var(--text-sm);
}

@media (min-width: 36em) {
  .match {
    grid-template-columns: 1fr auto;
  }
}

/* 12. Teacher record ------------------------------------------------------ */

.record__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
}

.record__kind {
  color: var(--color-ink-3);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.record__title {
  font-size: var(--text-xl);
  overflow-wrap: anywhere;
}

/* Facts about a thing: label above value, flowing into columns. */
.facts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-6);
}

.facts dt {
  color: var(--color-ink-3);
  font-size: var(--text-xs);
  font-weight: 700;
}

.facts dd {
  font-weight: 600;
}

/* A limit row: what the limit is, how much is used, its value, the action.
   Every new kind of account limit is one more row in this list. */
.limit-list {
  border-top: var(--border);
}

.limit {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    'what value'
    'action action';
  align-items: center;
  gap: var(--space-2) var(--space-4);
  padding-block: var(--space-3);
  border-bottom: var(--border);
}

.limit__what {
  grid-area: what;
}

.limit__name {
  font-weight: 700;
}

.limit__use {
  color: var(--color-ink-2);
  font-size: var(--text-sm);
}

/* ink-3 on the panel: 6.53:1 light, 6.48:1 dark (AA). */
.limit__hint {
  color: var(--color-ink-3);
  font-size: var(--text-xs);
}

.limit__value {
  grid-area: value;
  font-size: var(--text-xl);
  font-weight: 700;
  text-align: end;
}

.limit__action {
  grid-area: action;
}

@media (min-width: 36em) {
  .limit {
    grid-template-columns: 1fr auto auto;
    grid-template-areas: 'what value action';
  }

  .limit__value {
    min-width: 4rem;
  }
}

/* The value that was just changed, until the next lookup. */
.is-changed {
  background: var(--color-ok-soft);
  box-shadow: inset 4px 0 0 var(--color-ok-line);
}

.limit.is-changed {
  padding-inline: var(--space-3);
}

/* 13. Data tables --------------------------------------------------------- */
/* The markup carries explicit table roles so the structure survives the
   small-screen layout, where rows become stacked cards. */

.table-wrap {
  border: var(--border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.data-table caption {
  text-align: start;
}

.data-table th,
.data-table td {
  padding: var(--space-2) var(--space-3);
  text-align: start;
  vertical-align: top;
}

.data-table thead th {
  background: var(--color-sunk);
  color: var(--color-ink-2);
  font-size: var(--text-xs);
  font-weight: 700;
  white-space: nowrap;
  border-bottom: var(--border);
}

.data-table tbody tr + tr > * {
  border-top: var(--border);
}

.data-table tbody th {
  font-weight: 700;
  font-size: var(--text-md);
}

.data-table .cell--when {
  white-space: normal;
}

@media (min-width: 64em) {
  .data-table .cell--when {
    white-space: nowrap;
  }
}

.data-table .cell--note {
  min-width: 12rem;
}

.data-table .cell--change {
  min-width: 13rem;
}

@media (min-width: 64em) {
  .data-table .cell--change {
    min-width: 20rem;
  }
}

@media (max-width: 44.99em) {
  .data-table .cell--change,
  .data-table .cell--note {
    min-width: 0;
  }
}

.data-table .cell--num {
  text-align: end;
  white-space: nowrap;
}

.data-table .cell--action {
  text-align: end;
  white-space: nowrap;
  padding-block: var(--space-1);
}

.data-table .cell--value {
  font-weight: 700;
  font-size: var(--text-md);
}

.cell__sub {
  display: block;
  color: var(--color-ink-2);
  font-size: var(--text-xs);
  font-weight: 400;
  overflow-wrap: anywhere;
}

.table-foot {
  margin-top: var(--space-2);
  color: var(--color-ink-3);
  font-size: var(--text-sm);
}

@media (max-width: 44.99em) {
  .table-wrap {
    border: 0;
    border-radius: 0;
    background: transparent;
    overflow: visible;
  }

  .data-table,
  .data-table tbody,
  .data-table tr,
  .data-table th,
  .data-table td {
    display: block;
  }

  /* Column heads stay available to screen readers. */
  .data-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .data-table tbody tr {
    padding: var(--space-3) var(--space-4);
    background: var(--color-surface);
    border: var(--border);
    border-radius: var(--radius-lg);
  }

  .data-table tbody tr + tr {
    margin-top: var(--space-2);
  }

  .data-table tbody tr + tr > * {
    border-top: 0;
  }

  .data-table th,
  .data-table td {
    padding: var(--space-1) 0;
  }

  .data-table td {
    display: flex;
    justify-content: space-between;
    gap: var(--space-4);
    text-align: end;
  }

  /* The column name, repeated beside each value. `data-label` is fixed
     text in the markup, never data from the server. */
  .data-table td[data-label]::before {
    content: attr(data-label);
    flex: none;
    color: var(--color-ink-3);
    font-size: var(--text-xs);
    font-weight: 700;
    text-align: start;
  }

  .data-table .cell--action {
    display: block;
    padding-top: var(--space-2);
    text-align: start;
  }

  .data-table .cell--note {
    display: block;
    text-align: start;
  }

  .data-table .cell--note::before {
    display: block;
  }

  .data-table tr.is-changed {
    background: var(--color-ok-soft);
  }
}

/* 14. Change dialog ------------------------------------------------------- */
/* Opened with showModal(). The scrim is a spread shadow on the dialog so it
   looks the same in the static mock, where the dialog is merely `open`. */

.dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  width: calc(100% - 2 * var(--space-3));
  max-width: 34rem;
  height: fit-content;
  max-height: calc(100vh - 2 * var(--space-3));
  max-height: calc(100dvh - 2 * var(--space-3));
  padding: 0;
  background: var(--color-surface);
  color: var(--color-ink);
  border: 1px solid var(--color-control);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-dialog), 0 0 0 100vmax var(--color-scrim);
}

.dialog::backdrop {
  background: transparent;
}

/* A column: the head and the foot (the buttons) stay put and the body
   scrolls, so the confirming button is on screen on a phone. */
.dialog[open] {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dialog > form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.dialog__head,
.dialog__foot {
  flex: none;
}

.dialog__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.dialog__head {
  padding: var(--space-4) var(--space-4) var(--space-3);
  border-bottom: var(--border);
}

.dialog__step {
  color: var(--color-ink-3);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dialog__title {
  font-size: var(--text-xl);
}

.dialog__body {
  padding: var(--space-4);
}

.dialog__foot {
  padding: var(--space-3) var(--space-4) var(--space-4);
  border-top: var(--border);
}

.dialog__fine {
  color: var(--color-ink-3);
  font-size: var(--text-sm);
}

@media (min-width: 45em) {
  .dialog__head,
  .dialog__body,
  .dialog__foot {
    padding-inline: var(--space-5);
  }
}

/* Whose limit this is. Shown on both steps so the target is never off screen. */
.target {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-1) var(--space-4);
  padding: var(--space-3);
  background: var(--color-sunk);
  border-radius: var(--radius);
}

.target dt {
  color: var(--color-ink-2);
  font-size: var(--text-sm);
}

.target dd {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.target__sub {
  display: block;
  font-weight: 400;
  font-size: var(--text-sm);
  color: var(--color-ink-2);
}

/* Old value beside new value. */
.compare {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: var(--space-3);
}

.compare__side {
  padding: var(--space-3);
  border: var(--border);
  border-radius: var(--radius);
  text-align: center;
}

.compare__side--new {
  border: 2px solid var(--color-accent);
  background: var(--color-accent-soft);
}

.compare__label {
  color: var(--color-ink-2);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.compare__value {
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.2;
}

.compare__arrow {
  align-self: center;
  color: var(--color-ink-2);
  font-size: var(--text-xl);
}

.quote {
  padding: var(--space-2) var(--space-3);
  border-inline-start: 3px solid var(--color-line);
  color: var(--color-ink);
}

.quote__label {
  color: var(--color-ink-3);
  font-size: var(--text-xs);
  font-weight: 700;
}

/* 15. History view -------------------------------------------------------- */

.note--removed {
  color: var(--color-ink-3);
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  margin-top: var(--space-4);
}

.pager__status {
  color: var(--color-ink-2);
  font-size: var(--text-sm);
}

.pager__status--error {
  color: var(--color-danger);
  font-weight: 700;
}

/* 16. Waiting and empty states -------------------------------------------- */

.waiting {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-ink-2);
}

.spinner {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  border: 3px solid var(--color-line);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.empty {
  padding: var(--space-6) var(--space-4);
  border: 1px dashed var(--color-control);
  border-radius: var(--radius-lg);
  text-align: center;
}

.empty__title {
  font-size: var(--text-lg);
}

.empty__body {
  max-width: var(--measure);
  margin: var(--space-1) auto 0;
  color: var(--color-ink-2);
}

/* 17. Motion and forced colours ------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }

  /* A still ring would read as stuck. The words beside it carry the state. */
  .spinner {
    display: none;
  }
}

@media (forced-colors: active) {
  .app-nav a[aria-current='page'] {
    border-bottom-color: Highlight;
  }

  .btn--primary {
    border: 2px solid ButtonText;
  }

  .dialog {
    box-shadow: none;
  }

  .dialog::backdrop {
    background: rgb(0 0 0 / 0.6);
  }

  .is-changed {
    outline: 2px solid Highlight;
    outline-offset: -2px;
  }
}
