/* AgentInbox dashboard. The colours, type and components follow the
   landing page (site/styles.css); the base tokens are copied from it.
   No JavaScript, no web fonts, no images: system fonts and CSS only. */

:root {
  color-scheme: light dark;
  --bg: #faf8f5;
  --surface: #ffffff;
  --surface-alt: #f2efe9;
  --surface-hover: #f8f5f0;
  --ink: #16181d;
  --muted: #545a65;
  --line: #e2ddd3;
  --line-strong: #cdc6b9;
  --accent: #c2410c;
  --accent-ink: #9a3412;
  --accent-soft: #fbe7dc;
  --on-accent: #ffffff;
  --ok: #166534;
  --ok-soft: #dcfce7;
  --wait: #854d0e;
  --wait-soft: #fef3c7;
  --bad: #991b1b;
  --bad-soft: #fee2e2;
  --focus: #c2410c;
  --shadow: 0 1px 2px rgb(22 24 29 / 0.05), 0 1px 1px rgb(22 24 29 / 0.03);
  --shadow-lg: 0 10px 30px -12px rgb(22 24 29 / 0.18), 0 2px 6px rgb(22 24 29 / 0.05);

  /* Chart colours, for inline SVG (see "Overview building blocks").
     Checked with the dataviz palette validator, all pairs, against
     --surface in both themes. */
  --chart-1: #c2410c;
  --chart-2: #2b5fb8;
  --chart-3: #11998e;
  --chart-grid: #e2ddd3;

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* Type scale */
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.375rem;
  --fs-2xl: 1.75rem;
  --fs-3xl: 2.125rem;

  --radius: 14px;
  --radius-sm: 9px;
  --sidebar: 14.5rem;
  --content: 78rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1013;
    --surface: #161a20;
    --surface-alt: #12151a;
    --surface-hover: #1b2027;
    --ink: #eceef1;
    --muted: #a7adb8;
    --line: #272c35;
    --line-strong: #3a414d;
    --accent: #fb8c4e;
    --accent-ink: #fdac7c;
    --accent-soft: #2c1a10;
    --on-accent: #1a0c04;
    --ok: #86efac;
    --ok-soft: #0f2a19;
    --wait: #fcd34d;
    --wait-soft: #2a220c;
    --bad: #fca5a5;
    --bad-soft: #2f1414;
    --focus: #fb8c4e;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.35);
    --shadow-lg: 0 12px 32px -12px rgb(0 0 0 / 0.6), 0 2px 6px rgb(0 0 0 / 0.3);
    --chart-1: #e8692a;
    --chart-2: #3f82e8;
    --chart-3: #14a08f;
    --chart-grid: #272c35;
  }
}

/* ---------------------------------------------------------------- Base */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Airmail stripe along the top edge. */
body::before {
  content: "";
  display: block;
  height: 6px;
  background: repeating-linear-gradient(
    -45deg,
    var(--accent) 0 14px,
    transparent 14px 22px,
    var(--ink) 22px 36px,
    transparent 36px 44px
  );
}

h1, h2, h3 { line-height: 1.2; letter-spacing: -0.015em; overflow-wrap: anywhere; font-weight: 650; }
h1 { font-size: var(--fs-2xl); letter-spacing: -0.025em; margin: 0; font-weight: 700; }
h2 { font-size: var(--fs-lg); margin: 2.5rem 0 0.85rem; }
h3 { font-size: var(--fs-md); margin: 1.75rem 0 0.65rem; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
p { margin: 0 0 1rem; }
ol, ul { padding-left: 1.25rem; }
a { color: var(--accent-ink); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent); text-decoration-thickness: 2px; }
b, strong { font-weight: 650; }

code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.05em 0.35em;
  overflow-wrap: anywhere;
}

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

.muted { color: var(--muted); }
.error { color: var(--bad); overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }

.skip {
  position: absolute;
  left: 1rem;
  top: 1rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  transform: translateY(-200%);
}
.skip:focus { transform: none; }

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

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.015em;
  text-decoration: none;
  border-radius: 8px;
}
.brand:hover { color: var(--ink); }
.brand-mark { width: 1.85rem; height: 1.85rem; flex: none; }
.brand-mark rect { fill: var(--accent); }
.brand-mark path {
  fill: none;
  stroke: var(--on-accent);
  stroke-width: 2.2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

/* -------------------------------------------- Signed-in shell: sidebar */

/* Narrow screens: a compact top bar with the brand and sign-out on the
   first row and the navigation as a row that scrolls sideways. */
.sidebar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "brand name out"
    "nav nav nav";
  align-items: center;
  gap: 0.6rem 0.75rem;
  padding: 0.75rem 1rem 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.sidebar .brand { grid-area: brand; }
.who { display: contents; }
.who-name {
  grid-area: name;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--muted);
}
.who-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.who .btn { grid-area: out; }

.sidenav {
  grid-area: nav;
  display: flex;
  align-items: center;
  gap: 0.25rem 1rem;
  margin: 0 -1rem;
  padding: 0 1rem 0.6rem;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.nav-group { display: flex; align-items: center; gap: 0.25rem; flex: none; }
.nav-heading {
  margin: 0 0.25rem 0 0;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.nav { display: flex; gap: 0.15rem; margin: 0; padding: 0; list-style: none; }
.nav a {
  display: block;
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.nav a:hover { color: var(--ink); background: var(--surface-alt); }
.nav a[aria-current="page"] {
  color: var(--accent-ink);
  background: var(--accent-soft);
  font-weight: 650;
}

@media (max-width: 30rem) {
  .sidebar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand out"
      "name name"
      "nav nav";
  }
  .who-name { justify-self: start; }
}

.content {
  width: 100%;
  min-width: 0;
  max-width: var(--content);
  padding: 1.5rem 1rem 4rem;
}

@media (min-width: 40rem) {
  .content { padding: 2rem 2rem 4rem; }
}

/* Wide screens: a sidebar that stays put while the page scrolls. */
@media (min-width: 60rem) {
  .shell {
    display: grid;
    grid-template-columns: var(--sidebar) minmax(0, 1fr);
    align-items: start;
  }
  .sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    padding: 1.4rem 0.9rem 1rem;
    border-bottom: 0;
    border-right: 1px solid var(--line);
  }
  .sidebar .brand { padding: 0.2rem 0.5rem; margin-bottom: 1.75rem; }
  .sidenav {
    display: block;
    margin: 0;
    padding: 0;
    overflow: visible;
  }
  .nav-group { display: block; margin-bottom: 1.5rem; }
  .nav-heading { margin: 0 0 0.4rem; padding: 0 0.7rem; }
  .nav { flex-direction: column; gap: 0.1rem; }
  .nav a { position: relative; padding: 0.5rem 0.7rem; }
  .nav a[aria-current="page"]::before {
    content: "";
    position: absolute;
    left: -0.9rem;
    top: 0.45rem;
    bottom: 0.45rem;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--accent);
  }
  .who {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
    margin-top: auto;
    padding: 1rem 0.5rem 0;
    border-top: 1px solid var(--line);
  }
  .who-name { justify-self: auto; flex-wrap: wrap; overflow-wrap: anywhere; }
  .who-email { white-space: normal; overflow: visible; overflow-wrap: anywhere; color: var(--ink); font-weight: 500; }
  .content { padding: 2.25rem 2.75rem 5rem; }
}

/* --------------------------------------------------------- Page header */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  margin: 0 0 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}
.page-title { min-width: 0; flex: 1 1 20rem; }
.page-intro { margin: 0.45rem 0 0; color: var(--muted); max-width: 65ch; }
.page-actions { margin: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* ------------------------------------------- Signed-out: a single card */

.solo {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: calc(100vh - 6px);
  padding: 0 1rem 3rem;
}
.solo-head { padding: 3rem 0 1.75rem; }
.solo-head .brand { font-size: 1.25rem; }
.solo-head .brand-mark { width: 2.25rem; height: 2.25rem; }
/* Signed in on a single-card page (OAuth consent): who is signed in. */
.solo-head { display: flex; flex-direction: column; align-items: center; gap: 0.85rem; }
.solo-who {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.4rem 0.75rem;
  max-width: 100%;
  font-size: var(--fs-sm);
  overflow-wrap: anywhere;
  text-align: center;
}
.solo-main { width: 100%; max-width: 30rem; }
.solo-main > h1 { text-align: center; font-size: var(--fs-2xl); margin-bottom: 1.25rem; }
.solo .card { box-shadow: var(--shadow-lg); padding: 1.75rem; }
.solo .narrow { max-width: none; }
.solo .form-card > .btn:only-of-type { width: 100%; }
.message-card > :last-child { margin-bottom: 0; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.6rem;
  padding: 0.5rem 1.1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}
.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow), inset 0 1px 0 rgb(255 255 255 / 0.12);
}
.btn-primary:hover { color: var(--on-accent); background: var(--accent-ink); }
.btn-ghost {
  border-color: var(--line-strong);
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.btn-ghost:hover { color: var(--ink); background: var(--surface-alt); border-color: var(--muted); }
.btn-small { min-height: 2rem; padding: 0.3rem 0.75rem; font-size: var(--fs-sm); border-radius: 8px; }
.btn:active { transform: translateY(1px); }

/* --------------------------------------------------------------- Pills */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.1rem 0.55rem 0.1rem 0.5rem;
  border: 1px solid color-mix(in srgb, currentColor 22%, transparent);
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: 0.01em;
  white-space: nowrap;
  vertical-align: 0.05em;
}
.pill::before {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.pill-wait { color: var(--wait); background: var(--wait-soft); }
.pill-ok { color: var(--ok); background: var(--ok-soft); }
.pill-bad { color: var(--bad); background: var(--bad-soft); }

/* --------------------------------------------------------------- Cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin: 0 0 1.5rem;
}
.card > :last-child { margin-bottom: 0; }
.narrow { max-width: 34rem; }
.card-title { font-size: var(--fs-xl); margin: 0 0 1.1rem; }
.card-title a { color: var(--ink); text-decoration: none; }
.card-title a:hover { color: var(--accent-ink); text-decoration: underline; }
.empty-card { color: var(--muted); text-align: center; padding: 2.5rem 1.5rem; }

@media (max-width: 30rem) {
  .card { padding: 1.1rem; }
  .agent .facts { padding: 0.85rem; }
}

/* Actions under the facts of a card: each a button with its explanation. */
.card-actions {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}
.card-actions:not(:has(*)) { display: none; }
.card-actions > * { margin: 0; }
.action {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin: 1rem 0;
}
.card-actions > .action { margin: 0; }
.action > .muted { flex: 1 1 18rem; font-size: var(--fs-sm); max-width: 70ch; }
.note { font-size: var(--fs-sm); }

/* An agent: a card with its facts in a tinted band, then its sections. */
.agent h3 {
  margin: 1.75rem 0 0.6rem;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.agent .facts {
  padding: 1rem 1.25rem;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 10px;
}

/* Facts: label and value pairs. */
.facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr));
  gap: 1rem 1.75rem;
  margin: 0 0 1.25rem;
}
.facts dt {
  margin-bottom: 0.2rem;
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.facts dd { margin: 0; overflow-wrap: anywhere; font-weight: 500; }
.facts dd .pill { margin-right: 0.35rem; }
.facts.wide { grid-template-columns: 1fr; gap: 0; }
.facts.wide > div {
  display: grid;
  grid-template-columns: 9.5rem minmax(0, 1fr);
  gap: 0.25rem 1.25rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
}
.facts.wide > div:first-child { padding-top: 0; }
.facts.wide > div:last-child { border-bottom: 0; padding-bottom: 0; }
.facts.wide dt { margin: 0; padding-top: 0.15rem; }
.facts.wide dd { font-weight: 400; }
@media (max-width: 30rem) {
  .facts.wide > div { grid-template-columns: 1fr; }
}

/* Numbered steps on the empty home page. */
.onboarding h2 { font-size: var(--fs-xl); }
.steps { list-style: none; counter-reset: step; padding: 0; margin: 0 0 1.5rem; }
.steps li {
  counter-increment: step;
  position: relative;
  padding: 0.3rem 0 0.3rem 2.6rem;
  margin-bottom: 0.6rem;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.15rem;
  display: grid;
  place-items: center;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: var(--fs-sm);
  font-weight: 700;
}

/* Notices */
.notice {
  padding: 0.8rem 1rem;
  border: 1px solid color-mix(in srgb, currentColor 25%, transparent);
  border-left-width: 4px;
  border-radius: 10px;
  overflow-wrap: anywhere;
}
.notice-bad { color: var(--bad); background: var(--bad-soft); }

/* --------------------------------------------------------------- Forms */

label { display: block; font-weight: 600; font-size: 0.9375rem; margin-bottom: 0.4rem; }
input[type="email"], input[type="text"], select {
  min-height: 2.6rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 0.9375rem;
  transition: border-color 0.12s, box-shadow 0.12s;
}
input[type="email"], .card > input[type="text"] { width: 100%; }
input[type="email"]:hover, input[type="text"]:hover, select:hover { border-color: var(--muted); }
input[type="email"]:focus, input[type="text"]:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
input:focus-visible, select:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
input[type="radio"], input[type="checkbox"] { accent-color: var(--accent); width: 1rem; height: 1rem; margin: 0; }

.card input[type="email"] { margin-bottom: 1.25rem; }
.card > input[type="text"] { margin-bottom: 0.35rem; }
.form-card > label:not(.choice) { margin-top: 0.25rem; }
.form-card > input + .muted, .form-card > .address + .muted { font-size: var(--fs-sm); margin-top: 0.4rem; }
.form-card > .muted { font-size: var(--fs-sm); }
.form-card > .error { font-size: var(--fs-sm); margin-top: -0.5rem; }
.form-card > .btn + .btn { margin-left: 0.5rem; }

.address { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-bottom: 0.35rem; }
.address input[type="text"] { flex: 1 1 10rem; min-width: 0; }
.address > span { color: var(--muted); font-weight: 500; }

fieldset { border: 0; margin: 1.25rem 0; padding: 0; min-width: 0; }
legend { font-weight: 600; font-size: 0.9375rem; margin-bottom: 0.5rem; padding: 0; }
label.choice {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0 0.5rem 0.5rem 0;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-weight: 500;
  cursor: pointer;
  flex-wrap: wrap;
  overflow-wrap: anywhere;
}
label.choice:hover { border-color: var(--muted); }
label.choice:has(:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}
fieldset p:has(> label.choice) { margin: 0; }
/* Consent: radio in its own column, the address and status pill beside it. */
fieldset p > label.choice {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  row-gap: 0.35rem;
  margin-right: 0;
}
fieldset p > label.choice > .pill { grid-column: 2; justify-self: start; }

pre.key {
  margin: 0 0 1.25rem;
  padding: 1rem 1.1rem;
  background: var(--accent-soft);
  color: var(--ink);
  border: 1px dashed var(--accent);
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 0.95rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: all;
}
.key-card h2 { margin-top: 2rem; }
/* The key with its copy button to the right; the status is for screen
   readers only. */
.key-copy { display: flex; align-items: flex-start; gap: 0.5rem; margin: 0 0 1.25rem; }
.key-copy pre.key { flex: 1; min-width: 0; margin: 0; }
.key-copy .btn { flex: none; margin-top: 0.6rem; white-space: nowrap; }
.key-copy .btn[hidden] { display: none; }
/* The prompt's copy button sits under the prompt. */
.prompt-copy { margin: -0.75rem 0 1.25rem; }
.prompt-copy .btn[hidden] { display: none; }
.key-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* A row of filters or a small inline form. */
.search {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 1rem;
}
.search label { margin: 0; }
.search input[type="email"] { width: 20rem; max-width: 100%; margin: 0; }
.search input[type="email"], .search input[type="text"], .search select { min-height: 2.25rem; padding: 0.3rem 0.65rem; }
.search input[type="text"] { flex: 0 1 14rem; min-width: 0; }
.toolbar {
  padding: 0.8rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}
.search.action {
  padding: 1rem;
  background: var(--surface-alt);
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
}
td form { margin: 0; }

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

.table {
  max-width: 100%;
  overflow-x: auto;
  /* Shadows at an edge where more of the table is scrolled out of view. */
  background:
    linear-gradient(to right, var(--surface) 40%, transparent) left / 2.5rem 100% no-repeat local,
    linear-gradient(to left, var(--surface) 40%, transparent) right / 2.5rem 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgb(0 0 0 / 0.22), transparent) left / 0.9rem 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgb(0 0 0 / 0.22), transparent) right / 0.9rem 100% no-repeat scroll,
    var(--surface);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 0 0 1.5rem;
}
.card .table { border-radius: 10px; box-shadow: none; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}
th, td {
  text-align: left;
  vertical-align: middle;
  padding: 0.75rem 0.875rem;
  border-bottom: 1px solid var(--line);
}
th {
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
  background: var(--surface-alt);
}
tbody tr { transition: background-color 0.1s; }
tbody tr:hover { background: var(--surface-hover); }
tbody tr:last-child td { border-bottom: 0; }
th.num, td.num { text-align: right; }
td:last-child:has(> form) { text-align: right; }
th:first-child, td:first-child { padding-left: 1.1rem; }
th:last-child, td:last-child { padding-right: 1.1rem; }
td.empty {
  padding: 2.25rem 1rem;
  text-align: center;
  color: var(--muted);
}
tbody tr:has(> td.empty):hover { background: transparent; }
/* Cells stay on one line; a table wider than its wrapper scrolls
   instead. Errors and subjects wrap. */
td { overflow-wrap: normal; white-space: nowrap; }
td.wrap, td.error { white-space: normal; min-width: 14rem; }
td.error:empty { min-width: 0; }
td a { font-weight: 500; text-decoration: none; }
td a:hover { text-decoration: underline; }
td code { overflow-wrap: normal; white-space: nowrap; }
td form, td .btn { white-space: nowrap; }
td.error { font-size: var(--fs-sm); }

/* Pager */
.pager { display: flex; justify-content: flex-end; margin: -0.5rem 0 1.5rem; }
.pager .btn::after { content: "→" / ""; }

/* Tabs: a segmented control of filters. */
.tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  max-width: 100%;
  margin: 0 0 1.25rem;
  padding: 0.25rem;
  list-style: none;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 11px;
}
.tabs a {
  display: block;
  padding: 0.35rem 0.9rem;
  border-radius: 8px;
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 500;
  text-decoration: none;
}
.tabs a:hover { color: var(--ink); background: var(--surface-hover); }
.tabs a[aria-current="page"] {
  background: var(--surface);
  color: var(--ink);
  font-weight: 650;
  box-shadow: var(--shadow), inset 0 -2px 0 var(--accent);
}

/* ------------------------------------------- Overview building blocks

   Section heading: a heading with an optional note on the right.
     <div class="section-head">
       <h2>Mail</h2>
       <p class="section-note">Last 30 days</p>        (optional)
     </div>

   Card grid: responsive columns for KPI cards or panels.
     <div class="card-grid"> ... </div>                cards of at least 13rem
     <div class="card-grid card-grid-wide"> ... </div> cards of at least 22rem
     A child with class "span-2" takes two columns where there is room.

   KPI card: a label, a big value, an optional sub-line and an optional
   tone (kpi-ok, kpi-wait or kpi-bad) that colours a bar, a dot and the
   sub-line. The tone only adds to the words; say the state in text too.
     <div class="kpi kpi-bad">                         or <a class="kpi" href="...">
       <p class="kpi-label">Deliveries failed</p>
       <p class="kpi-value">12</p>
       <p class="kpi-sub">3 in the last day</p>        (optional)
     </div>

   Panel: a card with a header (title and optional note on the right) and
   a body that a table or a chart sits in.
     <section class="panel">
       <header class="panel-head">
         <h2 class="panel-title">Mail per day</h2>
         <p class="panel-note">UTC</p>                 (optional)
       </header>
       <div class="panel-body"> ... </div>
     </section>
     A .table directly in .panel-body loses its own border; add
     "panel-body-flush" to the body to drop its padding as well.

   Charts in inline SVG: CSS cannot be put in style attributes, so colour
   marks with these classes; they follow the light and dark theme.
     <svg class="chart" viewBox="..." role="img" aria-label="...">
     .chart-grid (lines), .chart-axis (text), .chart-1 / .chart-2 /
     .chart-3 (series: fill for bars and areas), .chart-line together
     with a series class (a stroked line), .chart-ok / .chart-wait /
     .chart-bad (status fills). Pair a chart with a table or a text
     summary of the same numbers. */

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin: 2.5rem 0 0.9rem;
}
.section-head:first-child { margin-top: 0; }
.section-head > h2 { margin: 0; }
.section-note { margin: 0; color: var(--muted); font-size: var(--fs-sm); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr));
  gap: 1rem;
  margin: 0 0 1.5rem;
}
.card-grid-wide { grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); }
.card-grid > * { margin: 0; min-width: 0; }
@media (min-width: 48rem) {
  .card-grid > .span-2 { grid-column: span 2; }
}

.kpi {
  --tone: transparent;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 1.1rem 1.25rem 1.15rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 3px 0 0 var(--tone);
  color: var(--ink);
  text-decoration: none;
}
.kpi > p { margin: 0; }
a.kpi:hover { color: var(--ink); border-color: var(--accent); }
a.kpi:focus-visible { outline-offset: 2px; border-radius: var(--radius); }
.kpi-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 500;
}
.kpi-value {
  font-size: var(--fs-3xl);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.kpi-sub { color: var(--muted); font-size: var(--fs-sm); }
.kpi-small { padding-top: 0.85rem; padding-bottom: 0.9rem; }
.kpi-small .kpi-value { font-size: var(--fs-xl); }
.kpi-ok { --tone: var(--ok); }
.kpi-wait { --tone: var(--wait); }
.kpi-bad { --tone: var(--bad); }
.kpi-ok .kpi-label::before, .kpi-wait .kpi-label::before, .kpi-bad .kpi-label::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--tone);
  flex: none;
}
.kpi-ok .kpi-sub, .kpi-wait .kpi-sub, .kpi-bad .kpi-sub { color: var(--tone); font-weight: 500; }

.panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 0 0 1.5rem;
}
.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--line);
}
.panel-title { margin: 0; font-size: var(--fs-md); font-weight: 650; }
.panel-note { margin: 0; color: var(--muted); font-size: var(--fs-sm); }
.panel-body { flex: 1; min-width: 0; padding: 1.25rem; }
.panel-body > :last-child { margin-bottom: 0; }
.panel-body > .table { border: 0; border-radius: 0; box-shadow: none; }
.panel-body-flush { padding: 0; }
.panel-body-flush > .table { border-radius: 0 0 var(--radius) var(--radius); }

.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid { stroke: var(--chart-grid); stroke-width: 1; fill: none; }
.chart-axis { fill: var(--muted); font-family: var(--font); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart-1 { fill: var(--chart-1); }
.chart-2 { fill: var(--chart-2); }
.chart-3 { fill: var(--chart-3); }
.chart-ok { fill: var(--ok); }
.chart-wait { fill: var(--wait); }
.chart-bad { fill: var(--bad); }
.chart-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-line.chart-1 { stroke: var(--chart-1); }
.chart-line.chart-2 { stroke: var(--chart-2); }
.chart-line.chart-3 { stroke: var(--chart-3); }
.chart-y { text-anchor: end; }
.chart-x { text-anchor: middle; }
.chart-area { fill-opacity: 0.14; }
/* A 2px gap in the surface colour between bars and stacked segments. */
.chart-bar { stroke: var(--surface); stroke-width: 2; }
.chart-dot { stroke: var(--surface); stroke-width: 2; }
/* A band per day that carries the day's figures as its tooltip (<title>). */
.chart-hit { fill: transparent; }
.chart-hit:hover { fill: color-mix(in srgb, var(--ink) 7%, transparent); }
/* Narrow screens: the chart keeps a legible size and scrolls sideways. */
.chart-frame { overflow-x: auto; scrollbar-width: thin; }
.chart-frame > .chart { min-width: 20rem; }
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.1rem;
  margin: 0 0 0.75rem;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: var(--fs-sm);
}
.chart-legend li { display: flex; align-items: center; gap: 0.4rem; }
.chart-key { width: 0.75rem; height: 0.75rem; border-radius: 3px; flex: none; }
.chart-key.chart-1 { background: var(--chart-1); }
.chart-key.chart-2 { background: var(--chart-2); }
.chart-key.chart-3 { background: var(--chart-3); }
.chart-empty { margin: 0; padding: 2.5rem 0.5rem; color: var(--muted); text-align: center; }
.chart-data { margin: 0 0 1.5rem; }
.chart-data > summary { cursor: pointer; font-weight: 600; margin-bottom: 0.75rem; }
.chart-data .table { max-height: 28rem; overflow-y: auto; }

/* ---------------------------------------------------------------- Mail */

pre.body {
  margin: 0 0 1.5rem;
  padding: 1.25rem 1.4rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-family: var(--mono);
  font-size: 0.875rem;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.card pre.body { background: var(--surface-alt); box-shadow: none; border-radius: 10px; }
iframe.mail {
  display: block;
  width: 100%;
  height: 70vh;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
