/* ==========================================================================
   IREMS IRAS Donation Module - design system
   Hand-written, dependency-free (no Bootstrap/CDN) so it works under a strict
   Content-Security-Policy and on an air-gapped server.
   ========================================================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --transition: 160ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Light theme (default) */
  --bg: #f4f6fb;
  --bg-elevated: #ffffff;
  --bg-sunken: #eef1f8;
  --bg-glass: rgba(255, 255, 255, 0.82);
  --text: #101828;
  --text-muted: #5b6478;
  --border: #dde2ed;
  --border-strong: #c3cad9;

  --primary: #4338ca;
  --primary-hover: #3730a3;
  --primary-soft: #eef0ff;
  --primary-contrast: #ffffff;

  --success: #0f7b52;
  --success-soft: #e6f6ef;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #9a6700;
  --warn-soft: #fff5e0;
  --info: #0b6bb1;
  --info-soft: #e7f2fb;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow: 0 4px 12px rgba(16, 24, 40, 0.08), 0 2px 4px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 20px 40px -12px rgba(16, 24, 40, 0.22);
  --focus: 0 0 0 3px rgba(67, 56, 202, 0.32);
}

[data-theme="dark"] {
  --bg: #0d1017;
  --bg-elevated: #151a24;
  --bg-sunken: #10141c;
  --bg-glass: rgba(21, 26, 36, 0.86);
  --text: #e8ecf4;
  --text-muted: #98a2b6;
  --border: #242c3a;
  --border-strong: #333d4f;

  --primary: #8b8dfb;
  --primary-hover: #a5a7ff;
  --primary-soft: #1d2136;
  --primary-contrast: #101320;

  --success: #4ade9f;
  --success-soft: #10241c;
  --danger: #ff8b7e;
  --danger-soft: #2a1512;
  --warn: #f2c05c;
  --warn-soft: #2a2113;
  --info: #6cc0f5;
  --info-soft: #10222e;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 48px -16px rgba(0, 0, 0, 0.7);
  --focus: 0 0 0 3px rgba(139, 141, 251, 0.4);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, var(--primary-soft), transparent 60%),
    var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0 0 var(--space-2);
  letter-spacing: -0.02em;
}

p {
  margin: 0 0 var(--space-3);
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code,
pre {
  font-family: var(--font-mono);
  font-size: 0.86em;
}

code {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 5px;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

.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 {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--primary);
  color: var(--primary-contrast);
  padding: var(--space-3) var(--space-4);
  border-radius: 0 0 var(--radius-sm) 0;
}

.skip-link:focus {
  left: 0;
}

.muted {
  color: var(--text-muted);
}

.small {
  font-size: 0.85rem;
}

/* ---------------------------------------------------------------- Topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
  background: var(--bg-glass);
  border-bottom: 1px solid var(--border);
}

.topbar__inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--space-3) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: inherit;
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  color: var(--primary-contrast);
  background: linear-gradient(140deg, var(--primary), #7c3aed);
  box-shadow: var(--shadow-sm);
}

.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand__text strong {
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.brand__text small {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.nav {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
}

.nav__link {
  padding: 7px 12px;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}

.nav__link:hover {
  background: var(--bg-sunken);
  color: var(--text);
  text-decoration: none;
}

.nav__link.is-active {
  background: var(--primary-soft);
  color: var(--primary);
}

.topbar__aside {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.icon-sun {
  display: none;
}

[data-theme="dark"] .icon-sun {
  display: block;
}

[data-theme="dark"] .icon-moon {
  display: none;
}

/* ---------------------------------------------------------------- Layout */

.page {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5) var(--space-7);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.grid {
  display: grid;
  gap: var(--space-4);
}

.grid--2 {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.grid--3 {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
}

.panel--narrow {
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}

.panel__head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.panel__title {
  font-size: 1.4rem;
  margin: 0;
}

.panel__hint {
  color: var(--text-muted);
  margin: 0;
  max-width: 62ch;
}

.panel__link {
  font-size: 0.9rem;
  white-space: nowrap;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-4);
  transition: box-shadow var(--transition), transform var(--transition);
}

.card:last-child {
  margin-bottom: 0;
}

.card--action:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.card--plain,
.card--muted {
  background: var(--bg-sunken);
}

.card--cta {
  text-align: center;
  padding: var(--space-6);
}

.card--cta .btn {
  margin-bottom: var(--space-3);
}

.card__badge {
  display: flex;
  gap: var(--space-2);
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}

.card__title {
  font-size: 1.05rem;
}

.card__body {
  color: var(--text-muted);
  margin: 0 0 var(--space-3);
}

.code-line {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  overflow-x: auto;
  margin: 0 0 var(--space-3);
}

/* ---------------------------------------------------------------- Hero */

.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  padding: var(--space-7) var(--space-6);
  background: linear-gradient(135deg, var(--primary) 0%, #6d28d9 55%, #0ea5e9 130%);
  color: #fff;
  box-shadow: var(--shadow-lg);
}

.hero__text {
  max-width: 60ch;
}

.hero h1 {
  font-size: clamp(1.7rem, 3.4vw, 2.5rem);
  margin-bottom: var(--space-3);
}

.hero .lede {
  font-size: 1.03rem;
  opacity: 0.92;
  margin-bottom: var(--space-5);
}

.hero__actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.hero .btn--primary {
  background: #fff;
  color: #2f2a80;
}

.hero .btn--primary:hover {
  background: #eef0ff;
}

.hero .btn--ghost {
  border-color: rgba(255, 255, 255, 0.55);
  color: #fff;
}

.hero .btn--ghost:hover {
  background: rgba(255, 255, 255, 0.14);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-size: 0.72rem;
  font-weight: 700;
  opacity: 0.85;
  margin-bottom: var(--space-2);
}

/* ---------------------------------------------------------------- Stepper */

.stepper {
  list-style: none;
  display: flex;
  gap: var(--space-2);
  margin: 0;
  padding: var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.stepper__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-size: 0.88rem;
  white-space: nowrap;
}

.stepper__item.is-current {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.stepper__item.is-done {
  color: var(--success);
}

.stepper__dot {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  font-size: 0.75rem;
  font-weight: 700;
  flex: none;
}

.stepper__item.is-done .stepper__dot {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.stepper__label {
  color: inherit;
  font-weight: inherit;
}

/* ---------------------------------------------------------------- Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), color var(--transition),
    border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn--primary {
  background: var(--primary);
  color: var(--primary-contrast);
  box-shadow: var(--shadow-sm);
}

.btn--primary:hover {
  background: var(--primary-hover);
}

.btn--outline {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn--outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}

.btn--ghost:hover {
  color: var(--text);
  background: var(--bg-sunken);
}

.btn--danger {
  background: var(--danger);
  color: #fff;
}

.btn--tiny {
  padding: 4px 10px;
  font-size: 0.78rem;
  border-radius: 6px;
  background: var(--bg-elevated);
  border-color: var(--border-strong);
  color: var(--text-muted);
}

.btn--tiny:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.btn--tiny.btn--primary {
  background: var(--primary);
  color: var(--primary-contrast);
  border-color: transparent;
}

.btn--lg {
  padding: 13px 22px;
  font-size: 1rem;
}

.btn--xl {
  padding: 16px 30px;
  font-size: 1.05rem;
}

.btn[disabled],
.btn.is-busy {
  opacity: 0.62;
  cursor: progress;
  transform: none;
}

.btn.is-busy::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.cta-row {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  align-items: center;
  margin-top: var(--space-4);
}

.cta-row--tight {
  margin-top: var(--space-3);
  gap: var(--space-2);
}

.inline {
  display: inline;
}

/* The sign-in choice: the optional job-id field, then one button per identity
   provider. Equal columns are the point - the choices have to line up with each
   other, and stack evenly rather than wrap one-here-one-there when the card is
   too narrow for both side by side. */
.signin {
  margin-top: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px dashed var(--border);
}

.signin__choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-3);
}

/* ---------------------------------------------------------------- Pills */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  background: var(--bg-sunken);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.pill__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.pill--success {
  background: var(--success-soft);
  color: var(--success);
  border-color: transparent;
}

.pill--danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}

.pill--warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: transparent;
}

.pill--info {
  background: var(--info-soft);
  color: var(--info);
  border-color: transparent;
}

/* ---------------------------------------------------------------- Callouts */

.callout {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  margin-bottom: var(--space-4);
}

.callout__icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  font-weight: 700;
  color: #fff;
  background: var(--text-muted);
}

.callout__title {
  margin: 0 0 2px;
  font-weight: 700;
}

.callout__text {
  margin: 0;
  color: var(--text-muted);
}

.callout--success {
  background: var(--success-soft);
  border-color: transparent;
}

.callout--success .callout__icon {
  background: var(--success);
}

.callout--danger {
  background: var(--danger-soft);
  border-color: transparent;
}

.callout--danger .callout__icon {
  background: var(--danger);
}

.callout--warn {
  background: var(--warn-soft);
  border-color: transparent;
}

.callout--warn .callout__icon {
  background: var(--warn);
}

/* ---------------------------------------------------------------- Forms */

.field {
  display: block;
  margin-bottom: var(--space-4);
  flex: 1 1 260px;
}

.field__label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 6px;
}

.field__hint {
  display: block;
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.input {
  width: 100%;
  padding: 11px 13px;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus);
}

.input--mono {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.5;
  resize: vertical;
}

.disclosure {
  margin-top: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-sunken);
  overflow: hidden;
}

.disclosure > summary {
  cursor: pointer;
  padding: var(--space-3) var(--space-4);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-muted);
  list-style: none;
}

.disclosure > summary::-webkit-details-marker {
  display: none;
}

.disclosure > summary::before {
  content: "▸";
  display: inline-block;
  margin-right: var(--space-2);
  transition: transform var(--transition);
}

.disclosure[open] > summary::before {
  transform: rotate(90deg);
}

.disclosure > summary:hover {
  color: var(--text);
}

.disclosure__body {
  padding: 0 var(--space-4) var(--space-4);
}

/* ---------------------------------------------------------------- Chips */

.chips {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: 0;
  margin: 0 0 var(--space-4);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 7px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  font-size: 0.83rem;
}

.chip__key {
  color: var(--text-muted);
  font-weight: 600;
}

.chip__value {
  font-weight: 600;
  font-family: var(--font-mono);
  word-break: break-all;
}

.chip--highlight {
  border-color: var(--success);
  background: var(--success-soft);
  color: var(--success);
}

/* ---------------------------------------------------------------- Result */

.result {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  padding: var(--space-5);
  box-shadow: var(--shadow);
  border-top-width: 4px;
  animation: rise 260ms ease-out;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.result--success {
  border-top-color: var(--success);
}

.result--danger {
  border-top-color: var(--danger);
}

.result--warn {
  border-top-color: var(--warn);
}

.result--info {
  border-top-color: var(--info);
}

.result__head {
  display: flex;
  gap: var(--space-4);
  align-items: flex-start;
  margin-bottom: var(--space-4);
}

.result__icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 50%;
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  background: var(--text-muted);
}

.result--success .result__icon {
  background: var(--success);
}

.result--danger .result__icon {
  background: var(--danger);
}

.result--warn .result__icon {
  background: var(--warn);
}

.result--info .result__icon {
  background: var(--info);
}

.result__heading {
  flex: 1 1 auto;
}

.result__title {
  font-size: 1.15rem;
  margin-bottom: 2px;
}

.result__message {
  margin: 0;
  color: var(--text-muted);
}

.result__grid {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.result__dumps {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: var(--space-4) 0 0;
  word-break: break-all;
}

/* IRAS's own validation diagnostics, straight out of the response's info block. */
.result__errors {
  border: 1px solid var(--danger, var(--border));
  border-radius: var(--radius);
  background: var(--bg-sunken);
  padding: var(--space-3);
  margin: 0 0 var(--space-4);
}

.result__errors-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0 0 var(--space-2);
}

.result__errors ul {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.86rem;
}

/* A submission split by the record limit: one row per request actually sent. */
.result__payloads {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  margin: 0 0 var(--space-4);
}

.result__payloads caption {
  text-align: left;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding-bottom: var(--space-2);
}

.result__payloads th,
.result__payloads td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- JSON block */

.jsonblock {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-sunken);
  overflow: hidden;
}

.jsonblock__summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  list-style: none;
  flex-wrap: wrap;
}

.jsonblock__title {
  flex: 0 1 auto;
}

.jsonblock__summary::-webkit-details-marker {
  display: none;
}

.jsonblock__summary::before {
  content: "▸";
  margin-right: var(--space-2);
  transition: transform var(--transition);
}

.jsonblock[open] .jsonblock__summary::before {
  transform: rotate(90deg);
}

.jsonblock__meta {
  margin-left: auto;
  font-weight: 500;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
  text-align: right;
}

.jsonblock__toolbar {
  display: flex;
  gap: var(--space-2);
  padding: 0 var(--space-4) var(--space-2);
}

.jsonblock__code {
  margin: 0;
  padding: var(--space-4);
  max-height: 340px;
  overflow: auto;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  font-size: 0.79rem;
  line-height: 1.6;
  white-space: pre;
  tab-size: 2;
}

.jsonblock__empty {
  margin: 0;
  padding: var(--space-4);
  color: var(--text-muted);
  font-size: 0.85rem;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
}

/* ---------------------------------------------------------------- Tables */

/* ------------------------------------------------------ Composer entries */

/* One card per donation. The fields are a responsive grid of labelled blocks,
   so nothing is clipped and every input says what it is, at any width. */
.donor-list {
  display: grid;
  gap: var(--space-3);
}

.donor-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-sunken);
}

/* Alternating shade, so neighbouring donations stay visually distinct when the
   list is long. Uses the two existing surface tones rather than new ones, so it
   works in both themes. */
.donor-list .donor-row:nth-child(even) {
  background: var(--bg-elevated);
}

.donor-row__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
}

/* The whole title is the collapse toggle: a card reads as one line when it is
   closed, and the operator can put finished donations out of the way. */
.donor-row__toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  flex: 1;
  padding: 2px 0;
  font: inherit;
  text-align: left;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

.donor-row__toggle:hover .donor-row__title {
  color: var(--primary);
}

.donor-row__caret {
  flex: none;
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: transform var(--transition);
}

.donor-row.is-collapsed .donor-row__caret {
  transform: rotate(-90deg);
}

.donor-row.is-collapsed .donor-row__head {
  border-bottom: 0;
}

.donor-row.is-collapsed .donor-row__grid {
  display: none;
}

.donor-row__title {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
}

.donor-row__meta {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}

.donor-row__magic,
.donor-row__remove {
  flex: none;
}

/* The spec value (YYYYMMDD) and the browser's own calendar, side by side and
   kept in step by the page script. */
.date-field {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.date-field .input {
  flex: 1 1 110px;
}

.date-field__picker {
  flex: 0 0 auto;
  width: 148px;
  min-width: 148px;
}

.donor-row__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: var(--space-3);
  padding: var(--space-3);
}

/* Name and addresses read better across two columns of the grid. */
.donor-row__grid .field--wide {
  grid-column: span 2;
}

/* The base .field carries a bottom margin for a one-per-row layout; the grid
   already spaces them. */
.donor-row__grid .field {
  margin-bottom: 0;
}

@media (max-width: 480px) {
  .donor-row__grid .field--wide {
    grid-column: span 1;
  }
}

.donor-row__head .btn--tiny {
  padding: 3px 8px;
  font-size: 0.78rem;
}

.table__actions {
  white-space: nowrap;
  text-align: right;
}

.validation {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.validation__group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-sunken);
  padding: var(--space-3);
}

.validation__group--error {
  border-color: var(--danger, var(--border));
}

.validation__group--warn {
  border-color: var(--warning, var(--border));
}

.validation__title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0 0 var(--space-2);
}

.validation ul {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.86rem;
}

.validation code {
  word-break: break-all;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  background: var(--bg-elevated);
}

.table th,
.table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table th {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--bg-sunken);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: var(--bg-sunken);
}

.table td small {
  display: block;
  color: var(--text-muted);
  font-size: 0.74rem;
}

.list {
  list-style: none;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.list__item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  word-break: break-all;
}

.list__item:last-child {
  border-bottom: none;
}

.empty {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-sunken);
}

.empty__title {
  font-weight: 700;
  margin: 0 0 4px;
}

.empty__text {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* ---------------------------------------------------------------- Test cases */

.testcase {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  padding: var(--space-4);
}

.testcase__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
  flex-wrap: wrap;
}

.testcase__title {
  font-size: 0.98rem;
  margin: 0;
}

.testcase__desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin: 0 0 var(--space-2);
}

.testcase__expect {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0;
}

/* ---------------------------------------------------------------- Toasts */

.toasts {
  position: fixed;
  right: var(--space-5);
  bottom: var(--space-5);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: min(420px, calc(100vw - 32px));
}

.toast {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  animation: rise 200ms ease-out;
}

.toast--success {
  border-left: 4px solid var(--success);
}

.toast--danger {
  border-left: 4px solid var(--danger);
}

.toast--warn {
  border-left: 4px solid var(--warn);
}

.toast--info {
  border-left: 4px solid var(--info);
}

.toast__title {
  font-weight: 700;
  margin: 0 0 2px;
}

.toast__text {
  margin: 0;
  color: var(--text-muted);
}

.toast__close {
  margin-left: auto;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 2px 4px;
}

/* ---------------------------------------------------------------- Modal */

.modal {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: 480px;
  width: calc(100vw - 32px);
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

.modal::backdrop {
  background: rgba(8, 11, 18, 0.62);
  backdrop-filter: blur(2px);
}

.modal__body {
  padding: var(--space-5);
}

.modal__title {
  font-size: 1.15rem;
}

.modal__text {
  color: var(--text-muted);
  font-size: 0.92rem;
}

.modal__text--muted {
  font-size: 0.84rem;
}

.modal__actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  margin-top: var(--space-5);
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------- Footer */

.footer {
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  flex: none;
}

.footer__inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--space-5);
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  font-size: 0.83rem;
  color: var(--text-muted);
}

.footer__inner p {
  margin: 0;
}

/* ---------------------------------------------------------------- Responsive */

@media (max-width: 820px) {
  .topbar__inner {
    flex-wrap: wrap;
    padding: var(--space-3) var(--space-4);
    gap: var(--space-3);
  }

  .nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
  }

  .page {
    padding: var(--space-5) var(--space-4) var(--space-6);
  }

  .hero {
    padding: var(--space-6) var(--space-4);
  }

  .panel,
  .card {
    padding: var(--space-4);
  }

  .toasts {
    right: var(--space-3);
    left: var(--space-3);
    bottom: var(--space-3);
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
