/* Autobahn Group sign-in hub. One stylesheet, system fonts, nothing loaded from
 * anywhere else.
 *
 * The same two warm modes as the AR Accounting Portal: Sepia Light (archival paper)
 * and Sepia Dark (roasted umber). Brass and honey gold mark what is chosen; sage,
 * terracotta and amber only ever mean active, stopped and waiting. The View As band is
 * the one loud thing on the page, on purpose.
 *
 * Sizes are in rem throughout, so Small, Medium and Large text (and the computer's own
 * text size setting) scale type, spacing and breakpoints together. */

/* ------------------------------------------------------------ the palette
 * Every colour is a token, written three ways so each browser gets the right one:
 *   1. plain Sepia Light values, which everything understands
 *   2. light-dark() pairs, for browsers that have it
 *   3. Sepia Dark by attribute and media query, only for browsers without light-dark()
 * tests/test_web_ui.py checks the three agree. */

:root {
  color-scheme: light dark;
  --text-scale: 1;

  --canvas: #f5efe3;
  --panel: #fcf9f2;
  --surface: #efe7d7;
  --surface-2: #e6dcc8;
  --ink: #261e16;
  --ink-2: #524436;
  --muted: #746555;
  --rule: #ddd1bb;
  --edge: #8c7a64;
  --gold: #a67418;
  --gold-ink: #7a5408;
  --gold-fill: #dba93f;
  --gold-fill-hover: #e7b952;
  --btn: #2b2118;
  --btn-hover: #46372a;
  --on-btn: #fcf9f2;
  --btn-accent: #e2ad47;
  --mast: #2b2118;
  --ok: #35603f;
  --ok-soft: #e3ead6;
  --ok-line: #5f8a64;
  --bad: #9a3a22;
  --bad-soft: #f6dfd3;
  --bad-line: #b5553a;
  --wait: #7a5200;
  --wait-soft: #f6e7c4;
  --wait-line: #a67418;
  --shadow: #2b211833;

  /* The masthead and the View As band look the same in both modes, so their inks are fixed. */
  --mast-ink: #f4ecdc;
  --mast-muted: #c9bba5;
  --mast-rule: #554536;
  --mast-edge: #94816a;
  --mast-gold: #e2ad47;
  --on-gold: #241a0d;

  --font: "Avenir Next", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system,
    "Helvetica Neue", Arial, sans-serif;
  --font-title: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua",
    "Times New Roman", serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  /* Small type never drops below a readable floor, even at Small text. */
  --fs-xs: max(0.8125rem, calc(0.75rem / var(--text-scale)));
  --fs-sm: max(0.875rem, calc(0.8125rem / var(--text-scale)));
  --fs-md: 0.9375rem;
  --s1: 0.25rem; --s2: 0.5rem; --s3: 0.75rem; --s4: 1rem; --s5: 1.5rem; --s6: 2.25rem; --s7: 3.5rem;
  --radius: 0.5rem;
  --radius-small: 0.3125rem;
  --ring: 0.1875rem;
}
:root[data-size="sm"] { --text-scale: 0.9; }
:root[data-size="lg"] { --text-scale: 1.15; }

/* A pinned mode. The meta tag is what the server and auth.js set; data-theme mirrors
 * it for browsers without :has(). */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
:root:has(> head > meta[name="color-scheme"][content="light"]) { color-scheme: light; }
:root:has(> head > meta[name="color-scheme"][content="dark"]) { color-scheme: dark; }

@supports (color: light-dark(#000, #fff)) {
  :root {
    --canvas: light-dark(#f5efe3, #18130f);
    --panel: light-dark(#fcf9f2, #231c16);
    --surface: light-dark(#efe7d7, #2c231b);
    --surface-2: light-dark(#e6dcc8, #382d22);
    --ink: light-dark(#261e16, #efe6d5);
    --ink-2: light-dark(#524436, #c9bba5);
    --muted: light-dark(#746555, #a3937d);
    --rule: light-dark(#ddd1bb, #3d3126);
    --edge: light-dark(#8c7a64, #86745f);
    --gold: light-dark(#a67418, #e2ad47);
    --gold-ink: light-dark(#7a5408, #e2ad47);
    --gold-fill: light-dark(#dba93f, #e2ad47);
    --gold-fill-hover: light-dark(#e7b952, #edc067);
    --btn: light-dark(#2b2118, #efe6d5);
    --btn-hover: light-dark(#46372a, #fbf5e8);
    --on-btn: light-dark(#fcf9f2, #18130f);
    --btn-accent: light-dark(#e2ad47, #7a5408);
    --mast: light-dark(#2b2118, #120e0b);
    --ok: light-dark(#35603f, #a3c79f);
    --ok-soft: light-dark(#e3ead6, #25301f);
    --ok-line: light-dark(#5f8a64, #6f9a70);
    --bad: light-dark(#9a3a22, #eb9c80);
    --bad-soft: light-dark(#f6dfd3, #3d2018);
    --bad-line: light-dark(#b5553a, #c96f52);
    --wait: light-dark(#7a5200, #e9bd6b);
    --wait-soft: light-dark(#f6e7c4, #3a2a11);
    --wait-line: light-dark(#a67418, #c8963a);
    --shadow: light-dark(#2b211833, #00000080);
  }
}
@supports not (color: light-dark(#000, #fff)) {
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --canvas: #18130f; --panel: #231c16; --surface: #2c231b; --surface-2: #382d22;
      --ink: #efe6d5; --ink-2: #c9bba5; --muted: #a3937d; --rule: #3d3126; --edge: #86745f;
      --gold: #e2ad47; --gold-ink: #e2ad47; --gold-fill: #e2ad47; --gold-fill-hover: #edc067;
      --btn: #efe6d5; --btn-hover: #fbf5e8; --on-btn: #18130f; --btn-accent: #7a5408;
      --mast: #120e0b;
      --ok: #a3c79f; --ok-soft: #25301f; --ok-line: #6f9a70;
      --bad: #eb9c80; --bad-soft: #3d2018; --bad-line: #c96f52;
      --wait: #e9bd6b; --wait-soft: #3a2a11; --wait-line: #c8963a;
      --shadow: #00000080;
    }
  }
  :root[data-theme="dark"] {
    --canvas: #18130f; --panel: #231c16; --surface: #2c231b; --surface-2: #382d22;
    --ink: #efe6d5; --ink-2: #c9bba5; --muted: #a3937d; --rule: #3d3126; --edge: #86745f;
    --gold: #e2ad47; --gold-ink: #e2ad47; --gold-fill: #e2ad47; --gold-fill-hover: #edc067;
    --btn: #efe6d5; --btn-hover: #fbf5e8; --on-btn: #18130f; --btn-accent: #7a5408;
    --mast: #120e0b;
    --ok: #a3c79f; --ok-soft: #25301f; --ok-line: #6f9a70;
    --bad: #eb9c80; --bad-soft: #3d2018; --bad-line: #c96f52;
    --wait: #e9bd6b; --wait-soft: #3a2a11; --wait-line: #c8963a;
    --shadow: #00000080;
  }
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html {
  /* Never a fixed pixel size here: a percentage keeps the reader's own browser and
   * system text size, and Small, Medium and Large multiply on top of it. */
  font-size: calc(100% * var(--text-scale));
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  accent-color: var(--gold); caret-color: var(--gold-ink);
  scrollbar-color: var(--edge) var(--surface);
}
body {
  margin: 0; background: var(--canvas); color: var(--ink);
  font: 400 1rem/1.5 var(--font); -webkit-font-smoothing: antialiased; overflow-wrap: break-word;
}
::selection { background: var(--gold-fill); color: var(--on-gold); }
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
h1 {
  font: 600 1.875rem/1.15 var(--font-title); letter-spacing: -0.005em;
  font-variant-numeric: lining-nums; text-wrap: balance;
}
h2 { font-size: 1.0625rem; line-height: 1.3; font-weight: 650; }
h3 { font-size: var(--fs-md); line-height: 1.3; font-weight: 650; }
a { color: inherit; text-underline-offset: 0.16em; text-decoration-thickness: 0.0625em; }
a:hover { text-decoration-color: var(--gold); text-decoration-thickness: 0.125em; }
:focus-visible { outline: var(--ring) solid var(--gold-ink); outline-offset: 0.125rem; border-radius: 0.125rem; }
strong { font-weight: 650; }
code, .mono { font-family: var(--font-mono); font-size: 0.92em; }
button, input, select, textarea { font: inherit; }

.wrap { max-width: 77.5rem; margin: 0 auto; padding: 0 var(--s5); }
.num { font-variant-numeric: tabular-nums lining-nums; }
.quiet { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.stack > * + * { margin-top: var(--s3); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.skip { position: absolute; left: -9999px; }
.skip:focus {
  left: var(--s4); top: var(--s2); z-index: 5; padding: var(--s2) var(--s3);
  background: var(--panel); color: var(--ink); border-radius: var(--radius-small);
}

/* -------------------------------------------------------------- masthead */
.demo { background: var(--surface-2); color: var(--ink); font-size: var(--fs-sm); font-weight: 600; padding: var(--s1) 0; border-bottom: 1px solid var(--edge); }
.demo a { font-weight: 650; }
.masthead { background: var(--mast); color: var(--mast-ink); border-bottom: 1px solid var(--mast-rule); }
.masthead :focus-visible { outline-color: var(--mast-gold); }
.bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3) var(--s5); padding-top: var(--s4); padding-bottom: var(--s3); }
.brand { display: flex; align-items: center; gap: var(--s3); text-decoration: none; }
.sun {
  width: 1.625rem; height: 1.625rem; border-radius: 50%; flex: none; margin: 0.3125rem;
  background: var(--mast-gold); box-shadow: 0 0 0 0.25rem var(--mast), 0 0 0 0.3125rem var(--mast-gold);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font: 600 1.1875rem/1.2 var(--font-title); }
.brand-by { font-size: var(--fs-xs); color: var(--mast-muted); }
.bar-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3) var(--s5); }
.who { display: flex; align-items: center; gap: var(--s4); font-size: var(--fs-md); }
.who form { margin: 0; }
.me { color: var(--mast-muted); }
.linkbutton { color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 0.16em; text-decoration-thickness: 0.0625em; }
.linkbutton:hover { text-decoration-color: var(--mast-gold); text-decoration-thickness: 0.125em; }
.tabs { display: flex; gap: var(--s1); overflow-x: auto; scrollbar-width: thin; }
.tabs a {
  padding: var(--s3) var(--s4); text-decoration: none; white-space: nowrap;
  color: var(--mast-muted); border-bottom: 0.1875rem solid transparent; font-weight: 550;
}
.tabs a:hover { color: var(--mast-ink); border-bottom-color: var(--mast-edge); }
.tabs a:active { color: var(--mast-gold); }
.tabs a[aria-current="page"] { color: var(--mast-ink); border-bottom-color: var(--mast-gold); }
.tabs a:focus-visible { outline-offset: -0.1875rem; }

/* Display controls: Sepia Light or Dark, and Small, Medium or Large text. */
.display { display: flex; align-items: center; gap: var(--s2); }
.seg { display: inline-flex; border: 1px solid var(--mast-edge); border-radius: 999px; overflow: hidden; }
.seg-item {
  min-width: 2rem; min-height: 1.875rem; padding: 0 0.625rem; border: 0; cursor: pointer;
  background: transparent; color: var(--mast-muted); font-size: var(--fs-xs); font-weight: 600; line-height: 1;
}
.seg-item:hover { background: var(--mast-rule); color: var(--mast-ink); }
.seg-item:active { background: var(--mast-edge); color: var(--on-gold); }
.seg-item[aria-pressed="true"] { background: var(--mast-gold); color: var(--on-gold); }
.seg-item:focus-visible { outline: 0.125rem solid var(--mast-ink); outline-offset: -0.1875rem; border-radius: 999px; }
.seg-item[aria-pressed="true"]:focus-visible { outline-color: var(--on-gold); }

/* ------------------------------------------------------------- View As band
 * Amber gold, full width, on every page while a super admin looks through someone
 * else's eyes. It says who, says read-only, and holds the only button that works. */
.viewas { background: var(--mast-gold); color: var(--on-gold); border-bottom: 0.25rem solid var(--on-gold); }
.viewas .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2) var(--s5); padding-top: var(--s3); padding-bottom: var(--s3); }
.viewas-title { font-weight: 700; font-size: 1.0625rem; }
.viewas-note { font-size: var(--fs-sm); font-weight: 550; }
.viewas form { margin: 0; }
.viewas .button { background: var(--on-gold); border-color: var(--on-gold); color: var(--mast-gold); }
.viewas .button:hover { background: #3b2c17; border-color: #3b2c17; }
.viewas :focus-visible { outline-color: var(--on-gold); }

main { padding: var(--s6) 0 var(--s7); }
main > .wrap { container: page / inline-size; }
.foot { border-top: 1px solid var(--rule); padding: var(--s5) 0; color: var(--muted); font-size: var(--fs-sm); }

/* ------------------------------------------------------------- page head */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s5); }
.page-head h1 + p { margin-top: var(--s1); }
.page-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s4); }
.back { margin-bottom: var(--s3); }
.textlink { color: var(--ink-2); font-weight: 600; }
.textlink:hover { color: var(--ink); }
.textlink:active { color: var(--gold-ink); }
.section { margin-top: var(--s6); }
.section > h2 { margin-bottom: var(--s3); font: 600 1.375rem/1.2 var(--font-title); }

/* Sub-navigation inside a console (Team, Activity; Companies, Apps, Users, Audit). */
.choices { display: flex; flex-wrap: wrap; gap: var(--s2); margin-bottom: var(--s5); }
.choices a {
  padding: var(--s1) var(--s3); border: 1px solid transparent; border-radius: var(--radius-small);
  text-decoration: none; color: var(--ink-2); font-size: var(--fs-md); font-weight: 550;
}
.choices a:hover { background: var(--surface); color: var(--ink); }
.choices a:active { background: var(--surface-2); }
.choices a[aria-current="page"] { background: var(--surface-2); border-color: var(--edge); color: var(--ink); font-weight: 650; }

/* --------------------------------------------------------------- buttons */
.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 2.625rem;
  padding: 0.375rem var(--s5); border-radius: var(--radius-small); border: 0.125rem solid var(--btn);
  background: var(--btn); color: var(--on-btn); font: 600 var(--fs-md)/1.2 var(--font);
  text-align: center; text-decoration: none; cursor: pointer;
}
.button:hover { background: var(--btn-hover); border-color: var(--btn-hover); }
.button:active { box-shadow: inset 0 0.125rem 0.3125rem var(--shadow); }
.button.secondary { background: transparent; color: var(--ink); border-color: var(--edge); }
.button.secondary:hover { border-color: var(--ink); background: var(--surface); }
.button.secondary:active { background: var(--surface-2); }
.button.gold { background: var(--gold-fill); border-color: var(--gold); color: var(--on-gold); }
.button.gold:hover { background: var(--gold-fill-hover); border-color: var(--gold-ink); }
.button.danger { background: transparent; color: var(--bad); border-color: var(--bad-line); }
.button.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.button.small { min-height: 2.125rem; padding: 0.25rem var(--s3); }
.button.wide { width: 100%; }
.button:disabled, .button[aria-disabled="true"] {
  background: var(--surface-2); border-color: var(--rule); color: var(--muted);
  box-shadow: none; cursor: not-allowed;
}
.copy {
  padding: 0.125rem var(--s2); border-radius: var(--radius-small); border: 1px solid var(--edge);
  background: var(--panel); color: var(--ink); font-size: var(--fs-xs); font-weight: 600;
  line-height: 1.5; cursor: pointer; flex: none;
}
.copy:hover { border-color: var(--ink); background: var(--surface); }
.copy:active { background: var(--surface-2); }
.copy.is-done { border-color: var(--ok-line); color: var(--ok); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); }
.inline-form { display: inline; margin: 0; }

/* ----------------------------------------------------------------- hints
 * A current browser opens a hint on hover and on keyboard focus (interestfor), draws
 * it above everything (popover) and ties it to its control (anchor positioning).
 * auth.js stands in where any of that is missing (WCAG 1.4.13: dismissable with Escape,
 * hoverable, and it stays until the pointer or focus leaves). */
.tip {
  display: none; position: fixed; inset: auto; margin: 0; z-index: 20;
  width: max-content; max-width: min(19rem, calc(100vw - 1rem)); padding: var(--s2) var(--s3);
  border: 1px solid var(--mast-edge); border-radius: var(--radius-small);
  background: var(--btn); color: var(--on-btn); box-shadow: 0 0.375rem 1.25rem var(--shadow);
  font: 500 var(--fs-xs)/1.45 var(--font); text-align: start; white-space: normal;
  letter-spacing: 0; text-transform: none; text-wrap: balance; overflow: visible;
}
.tip:popover-open { display: block; }
.tip.is-open { display: block; }
.masthead .tip, .viewas .tip { background: var(--mast-ink); color: var(--on-gold); }
[interestfor] { interest-delay: 0.35s 0.2s; }
@supports (position-area: block-start) {
  .tip { position-area: block-start; position-try-fallbacks: flip-block; margin: var(--s2); }
  .tip.is-placed { position-area: none; margin: 0; }
}

/* -------------------------------------------------------- notices, chips
 * A full border and a status dot. Nothing is told apart by colour alone: the words
 * always say what it is. */
.notice {
  display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s3) var(--s4);
  border: 1px solid var(--edge); border-radius: var(--radius-small); margin-bottom: var(--s4);
  background: var(--panel);
}
.notice::before {
  content: ""; flex: none; width: 0.625rem; height: 0.625rem; margin-top: 0.4375rem;
  border-radius: 50%; background: var(--edge);
}
.notice > div { flex: 1; min-width: 0; }
.notice > div > * + * { margin-top: var(--s2); }
.notice.ok { background: var(--ok-soft); border-color: var(--ok-line); }
.notice.ok::before { background: var(--ok); }
.notice.bad { background: var(--bad-soft); border-color: var(--bad-line); }
.notice.bad::before { background: var(--bad); }
.notice.wait { background: var(--wait-soft); border-color: var(--wait-line); }
.notice.wait::before { background: var(--wait); }
.chip, .badge {
  display: inline-flex; align-items: center; gap: 0.375rem; padding: 0.0625rem var(--s2);
  border: 1px solid transparent; border-radius: 999px;
  font-size: var(--fs-xs); font-weight: 600; line-height: 1.6; white-space: nowrap; vertical-align: baseline;
}
.chip { background: var(--surface-2); color: var(--ink-2); border-color: var(--rule); }
.chips { display: flex; flex-wrap: wrap; gap: var(--s1); }
.badge::before { content: ""; flex: none; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: currentColor; }
.badge.status-active { background: var(--ok-soft); color: var(--ok); }
.badge.status-invited { background: var(--wait-soft); color: var(--wait); }
.badge.status-disabled { background: var(--bad-soft); color: var(--bad); }
.badge.admin { background: var(--surface-2); color: var(--gold-ink); }
.badge.super { background: var(--mast); color: var(--mast-gold); }

/* A link or secret shown once, with a Copy button beside it. */
.oneoff { display: flex; align-items: center; gap: var(--s2); margin-top: var(--s2); padding: var(--s2) var(--s3); background: var(--panel); border: 1px dashed var(--edge); border-radius: var(--radius-small); }
.oneoff code { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* ------------------------------------------------------------ sign-in cards */
.auth-card {
  max-width: 28rem; margin: var(--s4) auto 0; background: var(--panel); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: var(--s6) var(--s5) var(--s5); box-shadow: 0 0.25rem 1.5rem var(--shadow);
}
.auth-card h1 { margin-bottom: var(--s2); }
.auth-card .lead { color: var(--ink-2); margin-bottom: var(--s5); }
.auth-card form + .auth-links { margin-top: var(--s5); }
.auth-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s2) var(--s4); font-size: var(--fs-sm); }
.auth-card.wide { max-width: 40rem; }

.form { display: flex; flex-direction: column; gap: var(--s4); }
.field { display: flex; flex-direction: column; gap: var(--s1); }
.field .help { font-size: var(--fs-sm); color: var(--muted); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: var(--s4); }
.check { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-md); font-weight: 550; color: var(--ink); }
.check input { width: 1.125rem; height: 1.125rem; }
label { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
input[type="text"], input[type="email"], input[type="password"], input[type="url"], select, textarea {
  font: 400 1rem/1.4 var(--font); color: var(--ink); background: var(--panel);
  border: 1px solid var(--edge); border-radius: var(--radius-small); padding: 0 var(--s3); min-height: 2.625rem; width: 100%;
}
input.code { font-family: var(--font-mono); font-size: 1.375rem; letter-spacing: 0.2em; text-align: center; }
textarea { padding: var(--s2) var(--s3); resize: vertical; min-height: 5rem; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-2); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: var(--ring) solid var(--gold-ink); outline-offset: 0; border-color: var(--ink); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface); color: var(--muted); border-color: var(--rule); cursor: not-allowed; }
fieldset { border: 1px solid var(--rule); border-radius: var(--radius-small); padding: var(--s3) var(--s4) var(--s4); margin: 0; }
legend { font-size: var(--fs-sm); font-weight: 650; color: var(--ink-2); padding: 0 var(--s1); }

/* --------------------------------------------------------------- My Apps */
.apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: var(--s4); }
.app {
  display: flex; flex-direction: column; gap: var(--s2); padding: var(--s5); text-decoration: none;
  background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius);
}
.app:hover { border-color: var(--gold); box-shadow: 0 0.25rem 1rem var(--shadow); }
.app:active { background: var(--surface); }
.app-name { font: 600 1.25rem/1.2 var(--font-title); }
.app-open { margin-top: auto; padding-top: var(--s2); font-weight: 650; color: var(--gold-ink); }
.app.admin { background: var(--surface); }
.empty { background: var(--panel); border: 1px dashed var(--edge); border-radius: var(--radius); padding: var(--s6) var(--s5); text-align: center; }
.empty p + p { margin-top: var(--s1); }

/* ---------------------------------------------------------- panels, grids */
.panel { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius); padding: var(--s5); }
.panel > h2 { margin-bottom: var(--s3); }
.panel > * + * { margin-top: var(--s3); }
.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: var(--s4); align-items: start; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: var(--s4); margin-bottom: var(--s5); }
.stat { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius); padding: var(--s4); }
.stat dt { font-size: var(--fs-xs); color: var(--muted); }
.stat dd { font-size: 1.75rem; font-weight: 650; line-height: 1.2; font-variant-numeric: tabular-nums lining-nums; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--s1) var(--s4); }
.facts dt { color: var(--muted); font-size: var(--fs-sm); }

.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); padding: var(--s4); list-style: none; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-small); }
.codes li { font-family: var(--font-mono); font-size: 1.0625rem; text-align: center; }
.qr { display: block; width: 12.5rem; height: 12.5rem; margin: 0 auto; padding: var(--s2); background: #ffffff; border: 1px solid var(--edge); border-radius: var(--radius-small); }
.key { font-family: var(--font-mono); font-size: 1.0625rem; letter-spacing: 0.05em; word-spacing: 0.25em; }

/* ----------------------------------------------------------------- tables */
.table-wrap {
  background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius);
  overflow: auto; max-height: 72vh; max-height: 72dvh; container: table / inline-size;
}
.table-wrap:focus-visible { outline-offset: -0.1875rem; border-radius: var(--radius); }
table { border-collapse: separate; border-spacing: 0; width: 100%; }
.grid { min-width: 44rem; }
.grid th, .grid td { padding: var(--s3) var(--s4); text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule); }
.grid thead th {
  position: sticky; top: 0; z-index: 1; background: var(--surface); color: var(--ink-2);
  font-size: var(--fs-xs); font-weight: 600; border-bottom-color: var(--edge); white-space: nowrap;
}
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr:hover td { background: var(--surface); }
.grid td { font-variant-numeric: tabular-nums lining-nums; }
.grid .when { white-space: nowrap; color: var(--ink-2); font-size: var(--fs-sm); }
.rowlink { font-weight: 600; text-decoration-color: var(--edge); }
@container table (max-width: 40rem) {
  .grid th, .grid td { padding: var(--s2) 0.625rem; font-size: var(--fs-sm); }
}

/* --------------------------------------------------------------- dev outbox */
.mail { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius); padding: var(--s4) var(--s5); }
.mail + .mail { margin-top: var(--s3); }
.mail pre { white-space: pre-wrap; font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--ink-2); margin: var(--s2) 0 0; }

/* -------------------------------------------------------- narrower pages */
@container page (max-width: 40rem) {
  h1 { font-size: 1.5rem; }
  .codes { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr; }
}
@media (max-width: 37.5rem) {
  .wrap { padding: 0 var(--s4); }
  .brand-by { display: none; }
  .auth-card { padding: var(--s5) var(--s4); }
}

/* ----------------------------------------------------------------- motion
 * Only state changes move, and only briefly. Changing the mode or the text size is
 * instant: auth.js sets data-switching for that one frame. */
@media (prefers-reduced-motion: no-preference) {
  .button, .copy, .seg-item, .tabs a, .choices a, .textlink, .linkbutton, .app,
  input, select, textarea, .grid tbody td {
    transition: background-color 150ms, border-color 150ms, color 150ms, box-shadow 150ms;
  }
  .tip { opacity: 0; transition: opacity 150ms, display 150ms allow-discrete, overlay 150ms allow-discrete; }
  .tip:popover-open { opacity: 1; }
  .tip.is-open { opacity: 1; }
  @starting-style {
    .tip:popover-open { opacity: 0; }
  }
}
:root[data-switching] *, :root[data-switching] *::before, :root[data-switching] *::after { transition: none !important; }

/* ---------------------------------------------- high contrast (forced colours) */
@media (forced-colors: active) {
  :focus-visible, .masthead :focus-visible, .seg-item:focus-visible { outline-color: Highlight; }
  .masthead, .viewas, .tip, .seg, .chip, .badge, .app, .oneoff { border-color: CanvasText; }
  .viewas { border-bottom-width: 0.25rem; }
  .button, .copy { border-color: ButtonText; }
  .seg-item[aria-pressed="true"], .choices a[aria-current="page"] {
    forced-color-adjust: none; background: Highlight; color: HighlightText; border-color: Highlight;
  }
  .tabs a[aria-current="page"] { border-bottom-color: Highlight; }
  .sun, .badge::before, .notice::before { forced-color-adjust: none; background: CanvasText; box-shadow: none; }
  .button:disabled, .button[aria-disabled="true"] { color: GrayText; border-color: GrayText; }
}

/* ------------------------------------------------------------------ print */
@media print {
  .skip, .display, .tabs, .who, .tip, .page-tools, .copy { display: none; }
  .table-wrap { max-height: none; overflow: visible; }
  .grid thead th { position: static; }
}
