/* Aight customer page. Same tokens and type as getaight.ai: paper, ink, one red stop.
   Spacing on a 4px scale: 4 / 8 / 12 / 16 / 24 / 32 / 48 / 64. */

:root {
  --paper: #F7F7F4;
  --paper-raised: #ffffff;
  --ink: #141f31;
  --ink-soft: #525e6e;
  --hairline: #E4E3DC;
  --hairline-strong: #8f8a7e;
  --stamp: #b0341f; /* the red stop in the wordmark, never for errors */
  --error: #8F1D1D;
  --ok: #1E7B44; /* the success rule on a notice, never on money */
  --sans: 'Public Sans', system-ui, sans-serif;
  --serif: 'Source Serif 4', Georgia, serif;
  --aight-serif: 'Source Serif 4', Georgia, serif; /* the Aight wordmark, whatever the page's brand */
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 2px; /* fields, tags, boxes */
  --radius-button: 4px;
  --header: 56px;
  --subnav: 44px;
}

* { box-sizing: border-box; }

html { background: var(--paper); }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  font-variant-numeric: tabular-nums lining-nums;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; }

h2 {
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-weight: 600;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin-bottom: 16px;
}

h3 {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.3;
  font-weight: 600;
  color: var(--ink);
  margin: 32px 0 8px;
}

/* The one small-label style: table heads and the labels over the numbers. Sentence case. */
.eyebrow, table.spend th, .figure .label {
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1;
  font-weight: 600;
  color: var(--ink-soft);
}

p { margin: 0 0 12px; max-width: 68ch; }

a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--hairline-strong);
  transition: color 120ms, background-color 120ms, border-color 120ms, text-decoration-color 120ms;
}

a:hover { text-decoration-color: var(--ink); }

a:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

code {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
}

pre {
  margin: 0;
  padding: 16px;
  background: var(--paper-raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
}

pre code { font-size: inherit; overflow-wrap: normal; }

.muted, .footnote, small { color: var(--ink-soft); font-size: 14px; line-height: 1.5; }

.error {
  color: var(--error);
  font-size: 14px;
  line-height: 1.5;
  margin: 4px 0 0;
}

/* Wordmark, as on the site */

.wordmark {
  display: inline-block;
  font-family: var(--aight-serif);
  font-optical-sizing: auto;
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1;
  text-decoration: none;
}

.wordmark .stop { color: var(--stamp); }

/* Feedback: one notice, three tones. Lives until the next navigation. */

.notice {
  color: var(--ink);
  background: var(--paper-raised);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--ink);
  padding: 12px 16px;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 15px;
  line-height: 1.5;
  margin: 0 0 16px;
  animation: notice-in 160ms ease-out;
}

.notice--info { border-left-color: var(--ink); }
.notice--success { border-left-color: var(--ok); }
.notice--error { border-left-color: var(--error); }

.notice p { margin: 0; max-width: none; }

.notice .key-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-top: 8px;
}

.notice .key-line code { font-size: 15px; }

@keyframes notice-in {
  from { opacity: 0; transform: translateY(-4px); }
}

/* Buttons and fields */

button {
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  border-radius: var(--radius-button);
  padding: 8px 20px;
  min-height: 40px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 120ms, background-color 120ms, border-color 120ms;
}

button:hover { background: #0d1524; border-color: #0d1524; }

button:active { transform: translateY(1px); }

button:disabled, button[disabled] { opacity: 0.45; cursor: not-allowed; }

button.is-loading { pointer-events: none; }

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

button.secondary {
  background: var(--paper-raised);
  color: var(--ink);
  border-color: var(--hairline-strong);
}

button.secondary:hover { background: var(--paper-raised); border-color: var(--ink); }

button.quiet {
  background: transparent;
  color: var(--ink);
  border-color: var(--hairline-strong);
  padding: 4px 12px;
  min-height: 32px;
  font-size: 14px;
}

button.quiet:hover { background: var(--paper-raised); border-color: var(--ink); }

button.danger { color: var(--error); }

button.danger:hover { background: transparent; border-color: var(--error); }

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
  margin-right: 8px;
}

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

label {
  display: block;
  font-size: 14px;
  color: var(--ink-soft);
  margin: 16px 0 4px;
}

input, select, textarea {
  font: inherit;
  font-size: 15px;
  width: 100%;
  padding: 10px 12px;
  min-height: 40px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  background: var(--paper-raised);
  color: var(--ink);
}

/* Focus is the outline alone; the border keeps its colour, so there is no double frame. */

input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--error); }

input:disabled, select:disabled, textarea:disabled { background: var(--paper); color: var(--ink-soft); }

textarea { resize: vertical; min-height: 96px; line-height: 1.5; }

/* Login */

body.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

.login-card { width: 100%; max-width: 380px; }

.login-card .wordmark { margin-bottom: 16px; }

.login-card h1 {
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-weight: 600;
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}

.login-card .notice { margin-top: 16px; }

.login-card form { margin-top: 16px; }

.login-card .error { margin-top: 16px; }

.login-card button[type="submit"] {
  width: 100%;
  margin-top: 24px;
}

/* Shell: the 56px header and the 44px section nav, both sticky and flat */

header.top {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header);
  background: var(--paper);
  border-bottom: 1px solid var(--hairline);
}

header.top .inner, nav.sections .inner, body.dashboard main, footer.powered {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 24px;
}

header.top .inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.identity { display: flex; align-items: center; min-width: 0; }

.identity .mark { width: 24px; height: 24px; object-fit: contain; flex: none; }

.identity .wordmark { font-size: 18px; flex: none; }

h1.name {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 15px;
  line-height: 1;
  letter-spacing: 0;
  margin-left: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

h1.name .brand-wordmark { display: block; height: 18px; width: auto; }

.print-date { display: none; }

header.top form { margin: 0; }

nav.sections {
  position: sticky;
  top: var(--header);
  z-index: 19;
  height: var(--subnav);
  background: var(--paper);
  border-bottom: 1px solid var(--hairline);
  overflow-x: auto;
  scrollbar-width: none;
}

nav.sections::-webkit-scrollbar { display: none; }

nav.sections ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  height: var(--subnav);
}

nav.sections li { margin-right: 24px; flex: none; }

nav.sections a {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: var(--subnav);
  padding: 0 4px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-soft);
  text-decoration: none;
  white-space: nowrap;
}

nav.sections a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--ink);
  transform: scaleX(0);
  transition: transform 200ms cubic-bezier(.2, .7, .2, 1);
}

nav.sections a:hover { color: var(--ink); }

nav.sections a.is-active { color: var(--ink); }

nav.sections a.is-active::after { transform: scaleX(1); }

/* Sections */

section {
  padding: 48px 0;
  border-top: 1px solid var(--hairline);
  scroll-margin-top: calc(var(--header) + var(--subnav) + 12px);
}

main > section:first-child { border-top: 0; }

/* The last section is at least 55vh tall so it can scroll up into the nav's
   observer band (which ends 45% down the viewport) and take the underline. */
section:last-child { padding-bottom: 96px; min-height: 55vh; }

/* Numbers: money is always ink. One number leads; the other two sit under it. */

.figure { display: flex; flex-direction: column; gap: 4px; }

.figure .value {
  font-family: var(--sans);
  font-feature-settings: "tnum", "lnum";
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--ink);
}

.figure.lead .value { font-size: 44px; line-height: 1.1; font-weight: 600; letter-spacing: -0.02em; }

.figure.lead .sub { color: var(--ink-soft); font-size: 14px; margin-top: 4px; }

.numbers .row {
  display: flex;
  gap: 48px;
  margin-top: 24px;
}

.numbers .row .figure .value { font-size: 20px; line-height: 1.2; font-weight: 500; letter-spacing: -0.01em; }

.numbers .last-request { margin-top: 16px; }

/* Try a model */

form.try label:first-of-type { margin-top: 8px; }

form.try select { max-width: 320px; }

form.try .actions {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-top: 16px;
}

form.try .actions .muted { margin: 0; }

.reply {
  margin-top: 24px;
  padding: 16px;
  background: var(--paper-raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.reply + .muted { margin-top: 8px; }

/* Tables: top-ups, keys, spend by model, spend by key */

/* position: relative keeps the table's visually-hidden header (position:
   absolute) inside this scroll box; otherwise it lands at the table's far
   edge in page coordinates and widens the page on a phone. */
.table-wrap { overflow-x: auto; position: relative; }

table.spend {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

table.spend th, table.spend td {
  padding: 10px 0 10px 16px;
  border-bottom: 1px solid var(--hairline);
  text-align: left;
  vertical-align: middle;
}

table.spend th:first-child, table.spend td:first-child { padding-left: 0; }

table.spend th { padding-top: 0; padding-bottom: 8px; }

table.spend tbody td { transition: background-color 120ms; }

table.spend tbody tr:hover td { background: var(--paper-raised); }

table.spend .num {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.01em;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums lining-nums;
}

table.spend th.num { font-family: var(--sans); font-size: 12px; letter-spacing: 0; }

table.spend .act { text-align: right; white-space: nowrap; }

table.spend .act form { margin: 0; display: inline; }

table.spend tr.refused td:first-child { font-family: var(--sans); }

table.spend tr.stopped td { color: var(--ink-soft); }

table.spend td.status-off { color: var(--ink-soft); }

.table-wrap + .footnote, .table-wrap + form.show-all { margin-top: 16px; }

form.show-all { margin: 0 0 16px; }

table.keys .name-cell { max-width: 240px; }

table.keys .key-name {
  display: inline-block;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

table.keys .masked { color: var(--ink-soft); font-size: 13px; }

table.keys .limit-inline { display: none; }

table.topups { max-width: 560px; }

.tag {
  display: inline-block;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-soft);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 0 8px;
  margin-left: 8px;
  vertical-align: middle;
}

/* Create a key */

form.create { margin-top: 24px; }

form.create h3 { margin-top: 0; }

form.create .fields {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 0 24px;
  align-items: start;
}

form.create button { margin-top: 16px; }

form.create + .footnote { margin-top: 8px; }

/* Models: a plain list, one per line, parted by hairlines: name, what it is
   for, and the price. */

ul.models {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 14px;
}

ul.models li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--hairline);
}

ul.models li:first-child { border-top: 1px solid var(--hairline); }

ul.models li code { font-size: 13px; }

ul.models .use { color: var(--ink-soft); }

ul.models .price { margin-left: auto; color: var(--ink); font-variant-numeric: tabular-nums; }

ul.models + .footnote { margin-top: 16px; }

dl.details { margin: 0 0 8px; display: grid; grid-template-columns: max-content 1fr; gap: 12px 24px; }

dl.details dt { color: var(--ink-soft); font-size: 14px; padding-top: 4px; }
dl.details dd { margin: 0; }

.key-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}

.key-actions { display: inline-flex; gap: 8px; }

/* Code examples fold away */

details { margin-bottom: 8px; }

details > summary { list-style: none; cursor: pointer; display: inline-block; }

details > summary::-webkit-details-marker { display: none; }

details > summary h3 { display: inline-block; margin-top: 0; }

details > summary h3::after {
  content: "";
  display: inline-block;
  width: 0.45em;
  height: 0.45em;
  margin-left: 0.6em;
  border-right: 1.5px solid var(--ink-soft);
  border-bottom: 1.5px solid var(--ink-soft);
  transform: translateY(-0.05em) rotate(-45deg);
}

details[open] > summary h3::after { transform: translateY(-0.2em) rotate(45deg); }

details[open] > summary { margin-bottom: 8px; }

details pre { margin-bottom: 8px; }

/* Error pages sit on the same shell */

body.error-page main > section { border-top: 0; }

/* Small screens */

@media (max-width: 640px) {
  header.top .inner, nav.sections .inner, body.dashboard main, footer.powered { padding: 0 20px; }
  h1.name { max-width: 55vw; }
  .figure.lead .value { font-size: 36px; }
  .numbers .row { gap: 32px; }
  button, nav.sections a, button.quiet, .key-actions button { min-height: 44px; }
  table.keys .col-created, table.keys .col-limit,
  table.spend .col-tokens,
  table.topups .col-rate { display: none; }
  table.keys .limit-inline { display: block; color: var(--ink-soft); font-size: 13px; }
  textarea { min-height: 120px; font-size: 16px; }
  input, select { font-size: 16px; }
  dl.details { grid-template-columns: 1fr; gap: 4px; }
  dl.details dd { margin-bottom: 12px; }
  form.create .fields { grid-template-columns: 1fr; }
  form.try .actions { flex-wrap: wrap; }
}

/* Print: the statement, one A4 page. What is not a statement stays off the
   paper: the tariff (model prices), the copy-paste code, the default key's
   address, and the lines about managing keys. */

@media print {
  html, body { background: #ffffff; color: #000000; font-size: 11pt; line-height: 1.4; }
  header.top { position: static; height: auto; border-bottom: 1px solid #000000; padding: 0 0 6px; }
  header.top .inner { padding: 0; height: auto; }
  .print-date { display: inline; font-size: 9pt; color: #000000; }
  nav.sections, #try, #developers, button, form, footer.powered, .notice,
  #models-h, ul.models, ul.models + .footnote, #default-key-h, dl.details, dl.details + .footnote,
  #keys > p, #keys .footnote, table.keys .masked, table.keys .masked + br, .last-request { display: none !important; }
  #keys .table-wrap + .footnote { display: block !important; }
  section { padding: 12px 0; border-color: #000000; }
  section:last-child { padding-bottom: 12px; min-height: 0; }
  h2 { font-size: 14pt; margin-bottom: 6px; }
  h3 { font-size: 11pt; margin: 10px 0 4px; }
  p { margin-bottom: 4px; }
  .figure.lead .value { font-size: 20pt; }
  .numbers .row { margin-top: 8px; }
  .numbers .row .figure .value { font-size: 14pt; }
  table.spend { font-size: 9pt; break-inside: avoid; }
  table.spend .num { font-size: 9pt; }
  table.spend th, table.spend td { border-color: #000000; padding: 3px 0 3px 12px; }
  table.spend tbody tr:hover td { background: transparent; }
  .figure .value, .muted, .footnote, table.spend td.status-off, table.keys .masked, .figure.lead .sub { color: #000000; }
  .muted, .footnote { font-size: 9pt; }
  dl.details { gap: 4px 16px; }
  a { text-decoration: none; color: #000000; }
  @page { size: A4; margin: 16mm; }
}

/* Motion: three transitions, one spinner, and none of them for people who ask */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
  .spinner { animation: none; border-right-color: currentColor; opacity: 0.5; }
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Customer branding: the activity page only, never the login page.
   The --brand-* variables (and --sans/--serif/--paper when the pack sets a
   font or background) come from an inline <style> the app builds from the
   customer's brand.env. --brand-text and --brand-large are the brand
   colour already checked for contrast on the page (see brand_context in app.py).
   Money stays ink under a brand: the colour goes on the header name, links
   and the "default" tag only. */

h1.brand-name { color: var(--brand-large); }

body.branded main a { color: var(--brand-text); font-weight: 500; text-decoration-color: currentColor; }

body.branded nav.sections a { color: var(--ink-soft); }

body.branded nav.sections a.is-active, body.branded nav.sections a:hover { color: var(--ink); }

body.branded nav.sections a::after { background: var(--brand-text); }

body.branded .tag { color: var(--brand-text); border-color: var(--brand-text); font-weight: 600; }

body.branded main button:not(.quiet):not(.secondary) {
  background: var(--brand-button);
  border-color: var(--brand-button);
  color: #ffffff;
}

body.branded main button:not(.quiet):not(.secondary):hover {
  background: var(--brand-button-hover);
  border-color: var(--brand-button-hover);
}

body.branded section:last-child { padding-bottom: 64px; }

footer.powered {
  padding-bottom: 32px;
  font-size: 14px;
  color: var(--ink-soft);
}

footer.powered .wordmark { font-size: 14px; margin: 0; vertical-align: baseline; }
