/* iLivin Studio CRM stylesheet: the admin, and the base the signing page
   builds on (sign.css adds to it). Colours come from tokens.css only.
   Breakpoints: 1440, 1024, 720, 420 (max-width) and nothing else.
   Every grid track is minmax(0, 1fr); a bare 1fr lets long content push
   the page wider than a phone. See DESIGN.md. */

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

html {
  background: var(--canvas);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: anywhere;
}

[hidden] {
  display: none !important;
}

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

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

/* Contract -> Header hierarchy: titles are the interface sans. Page title
   22px / 600; card title 15px / 600 / 1.15 (the title token). */
h1,
h2,
h3 {
  font-family: var(--font-body);
  font-weight: 600;
  text-wrap: balance;
}

h1 {
  font-size: var(--text-3xl);
  line-height: 1.15;
}

h2 {
  font-size: var(--text-title);
  line-height: 1.15;
  letter-spacing: -0.005em;
}

h3 {
  font-size: var(--text-md);
  line-height: 1.3;
}

strong {
  font-weight: 600;
}

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  transition: text-decoration-color var(--motion-fast) var(--ease);
}

a:hover {
  text-decoration-color: currentColor;
}

/* Contract -> Buttons: the focus ring is a box-shadow, never an outline.
   Its colour is Departure 11. A bare link gets a small radius so the ring
   has corners; :where() keeps that below every component's own radius. */
:focus-visible {
  outline: none;
  box-shadow: var(--focus-shadow);
}

:where(a, summary):focus-visible {
  border-radius: var(--radius-xs);
}

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

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

/* ---------- Text registers ---------- */

.eyebrow,
.label {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.4;
  text-transform: uppercase;
}

.eyebrow,
.label,
.btn,
.stamp,
.capsule,
.tab,
dt,
th {
  overflow-wrap: normal;
}

h1,
h2 {
  overflow-wrap: break-word;
}

.eyebrow {
  letter-spacing: 0.12em;
}

.label {
  letter-spacing: 0.06em;
}

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

.small {
  font-size: var(--text-sm);
}

.mono {
  font-family: var(--font-mono);
  letter-spacing: 0;
}

.num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.strong {
  font-weight: 600;
}

.nowrap {
  white-space: nowrap;
}

.tone-ok {
  color: var(--ok-text);
}

.tone-warn {
  color: var(--warn-text);
}

.tone-danger {
  color: var(--danger-text);
}

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

/* ---------- Shell ---------- */

.shell {
  display: grid;
  grid-template-columns: var(--side-width) minmax(0, 1fr);
  min-height: 100vh;
}

.side {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  height: 100vh;
  padding: var(--space-6) var(--space-4) var(--space-5);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: 0 var(--space-3);
  color: var(--ink);
  text-decoration: none;
}

.logo {
  display: inline-flex;
  height: 28px;
}

.logo img {
  width: auto;
  height: 100%;
}

.logo img {
  overflow: visible;
}

.logo .on-light {
  display: block;
}

.logo .on-dark {
  display: none;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-label {
  padding: 0 var(--space-3) var(--space-1);
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 36px;
  padding: 6px var(--space-3);
  border-radius: var(--radius-key);
  color: var(--muted);
  font-size: var(--text-md);
  font-weight: 500;
  text-decoration: none;
}

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

.nav-link[aria-current="page"] {
  background: var(--nav-active);
  color: var(--ink);
  font-weight: 600;
}

.side-foot {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: auto;
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
}

.side-user {
  padding: 0 var(--space-3);
}

.mobile-bar {
  display: none;
}

.main {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  width: 100%;
  max-width: calc(var(--content-width) + var(--gutter) * 2);
  min-width: 0;
  margin: 0 auto;
  padding: var(--space-8) var(--gutter) var(--space-12);
}

.test-banner {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-tray);
  background: var(--warn-soft);
}

/* ---------- Page head ---------- */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
}

.page-title {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.page-actions,
.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.between {
  justify-content: space-between;
}

.back-link {
  align-self: flex-start;
  color: var(--muted);
  font-size: var(--text-md);
}

/* ---------- Layout helpers ---------- */

.stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-6);
}

.stack > * {
  min-width: 0;
}

.stack-sm {
  gap: var(--space-3);
}

.grid-main {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  align-items: start;
  gap: var(--space-6);
}

.grid-half {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: start;
  gap: var(--space-6);
}

.grid-main > *,
.grid-half > * {
  min-width: 0;
}

.spaced {
  margin-top: var(--space-4);
}

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

/* ---------- Card ---------- */

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--card);
  box-shadow: var(--shadow-soft);
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-5) var(--space-5) 0;
}

.card-head-text {
  display: flex;
  flex: 1 1 160px;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.card-body {
  padding: var(--space-5);
}

.card-head + .card-body {
  padding-top: var(--space-4);
}

/* Contract -> Buttons -> Spacing, and the Quiet-count footer: a card's
   actions sit in one row under a hairline, 8px apart, at the right. A
   leading label (a count, or one fact) is pushed left. */
.card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: var(--text-sm);
}

.card-foot > .foot-label {
  flex: 1 1 160px;
  min-width: 0;
  margin-right: auto;
}

/* Contract -> Trays -> Container: 20px padding, the tray radius, the tray
   fill, text and edge (--ilivin-tray-glow, never omitted). The on-tray tone
   remap is in crm-tokens.css. */
.tray {
  padding: var(--space-5);
  border-radius: var(--radius-tray);
  background: var(--recess);
  color: var(--ilivin-tray-fg);
  box-shadow: var(--ilivin-tray-glow);
}

/* ---------- Buttons: keycaps act ---------- */

/* Contract -> Buttons. The keycap: text at 5% over the card colour, a 16%
   hairline, a 2px base edge (text at 34%; the tone on a tone button), the
   resting shadow, 36px tall (40px on touch), 12px side padding, a 6px icon
   gap, Hanken 12px / 600. A label may wrap at phone widths instead of
   clipping (Departure 17). */
.btn {
  --btn-edge: var(--key-edge);
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--key-line);
  border-bottom: 2px solid var(--btn-edge);
  border-radius: var(--radius-key);
  background: var(--key);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition: background-color var(--motion-fast) var(--ease), border-color var(--motion-fast) var(--ease), box-shadow var(--motion-fast) var(--ease), transform var(--motion-fast) var(--ease);
}

.btn:hover {
  border-color: var(--key-line-hover);
  border-bottom-color: var(--btn-edge);
  background: var(--key-hover);
}

.btn:active {
  box-shadow: none;
  transform: translateY(1px);
}

.btn:focus-visible {
  box-shadow: var(--focus-shadow);
}

/* Disabled: 50%, no shadow, kept in place with its reason in `title`. */
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  box-shadow: none;
  cursor: default;
  pointer-events: none;
}

/* A submitted form's button while the request is on its way. */
.btn[aria-busy="true"] {
  opacity: 0.5;
  cursor: progress;
}

.btn-primary {
  --btn-edge: var(--action-edge);
  border-color: var(--action);
  border-bottom-color: var(--btn-edge);
  background: var(--action);
  color: var(--on-action);
}

.btn-primary:hover {
  border-color: var(--action-hover);
  border-bottom-color: var(--btn-edge);
  background: var(--action-hover);
}

/* A second-rank key: the same hairline and base edge, so it is still a
   rectangle that acts (Contract -> Chips, shape grammar), without the
   surface or the lift. */
.btn-quiet {
  background: transparent;
  box-shadow: none;
  color: var(--muted);
}

.btn-quiet:hover {
  background: var(--key);
  color: var(--ink);
}

/* Contract -> Buttons, tone-danger: the tone on the label and the base edge;
   the surface stays the keycap's. */
.btn-danger {
  --btn-edge: var(--danger);
  color: var(--danger-key);
}

/* Contract -> Buttons: the size a button runs in a peer card's foot. */
.btn-sm {
  min-height: 34px;
  padding: 0 8px;
}

.btn-lg {
  min-height: 48px;
  padding: 0 20px;
  font-size: var(--text-md);
}

.btn-block {
  width: 100%;
}

.btn-icon {
  width: var(--ilivin-action-button-size);
  min-height: var(--ilivin-action-button-size);
  padding: 0;
}

/* Contract -> Actions And Controls: MDI glyphs, 16px before a label. */
.icon {
  flex: none;
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* Contract -> Buttons, All buttons: on a coarse pointer a named button is
   40px tall and a square icon action keeps 44px. */
@media (pointer: coarse) {
  .btn,
  .btn-sm {
    min-height: 40px;
  }

  .btn-icon {
    width: 44px;
    min-height: 44px;
  }

  .capsule,
  .tab,
  .nav-link {
    min-height: 40px;
  }
}

/* ---------- Capsules choose ---------- */

.capsules {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.capsule {
  appearance: none;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 12px;
  border: 1px solid var(--capsule-line);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1;
  text-decoration: none;
  text-transform: none;
  white-space: nowrap;
  transition: border-color var(--motion-fast) var(--ease);
}

.capsule:hover {
  border-color: var(--capsule-line-hover);
}

.capsule[aria-current="true"],
.capsule[aria-pressed="true"],
.capsule:has(input:checked) {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--card);
}

.capsule input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* Contract -> Chips: an option capsule adds a check when chosen. Drawn, so
   it needs no glyph: two sides of a turned box. */
.capsule:has(input:checked)::before {
  content: "";
  width: 4px;
  height: 8px;
  margin: -2px 2px 0;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.capsule:has(input:focus-visible) {
  box-shadow: var(--focus-shadow);
}

/* ---------- Tabs navigate ---------- */

.tabs {
  display: flex;
  gap: var(--space-4);
  padding: 0 2px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}

.tab {
  display: inline-flex;
  flex: none;
  align-items: center;
  min-height: 32px;
  margin-bottom: -1px;
  padding: 0 2px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.15;
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--motion-fast) var(--ease);
}

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

/* The strip clips an outer ring, so a tab's focus ring sits inside it. */
.tab:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.tab[aria-current] {
  border-bottom-color: var(--accent);
  color: var(--ink);
}

/* ---------- Stamps state ---------- */

/* Contract -> Chips: the state stamp. A 48px minimum so a column of them
   aligns. */
.stamp {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  min-height: 18px;
  padding: 2px 6px;
  border: 1px solid currentColor;
  border-radius: var(--radius-stamp);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: 650;
  letter-spacing: 0.1em;
  line-height: 1.2;
  text-transform: uppercase;
  white-space: nowrap;
}

.stamp-info {
  color: var(--info-text);
}

.stamp-ok {
  color: var(--ok-text);
}

.stamp-warn {
  color: var(--warn-text);
}

.stamp-danger {
  color: var(--danger-text);
}

/* Contract -> Chips: only the marks that need someone fill. The tone mixed
   80% into the text colour, written in the stamp ink. */
.stamp-solid.stamp-warn {
  border-color: var(--warn-solid);
  background: var(--warn-solid);
  color: var(--on-solid);
}

.stamp-solid.stamp-danger {
  border-color: var(--danger-solid);
  background: var(--danger-solid);
  color: var(--on-solid);
}

/* Contract -> Chips, Count: a small solid stamp for an unhandled number. */
.count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--radius-stamp);
  background: var(--warn-solid);
  color: var(--on-solid);
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stamp-struck {
  text-decoration: line-through;
}

/* ---------- Alerts ---------- */

/* The body of an alert is ink, never muted: muted text is 3.4:1 on the
   dark warn ground. */
.alert {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  border-left: 3px solid var(--muted);
  border-radius: var(--radius-tray);
  background: var(--recess);
  color: var(--ink);
}

.alert-row {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3) var(--space-5);
}

.alert-text {
  display: flex;
  flex: 1 1 280px;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.alert-title {
  font-weight: 600;
}

.alert-ok {
  border-left-color: var(--ok);
  background: var(--ok-soft);
}

.alert-info {
  border-left-color: var(--info);
  background: var(--info-soft);
}

.alert-warn {
  border-left-color: var(--warn);
  background: var(--warn-soft);
}

.alert-danger {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}

/* ---------- Facts have no shape ---------- */

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: var(--space-4) var(--space-5);
}

.fact {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.fact-value {
  font-weight: 500;
}

.facts-rows {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}

.facts-rows .fact {
  flex-direction: row;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}

.facts-rows .fact:last-child {
  border-bottom: 0;
}

/* Contract -> Fact rows: a muted Mono key beside the value. Sentence case
   here, as on a tray, because these keys are phrases. */
.facts-rows dt {
  flex: none;
  max-width: 60%;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.4;
}

.facts-rows .fact-value {
  min-width: 0;
  text-align: right;
}

/* ---------- Metrics ---------- */

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-4);
}

/* Contract -> Buttons -> Tile buttons: a bordered surface that opens what
   it summarises, on the canvas. Hover brightens the edge; no fill change,
   lift or base edge, so it never reads as a button. */
.metric {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--ilivin-glass-border);
  border-radius: var(--ilivin-radius-lg);
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
  transition: border-color var(--motion-fast) var(--ease);
}

.metric:hover {
  border-color: var(--muted);
}

.metric-value {
  font-size: var(--text-2xl);
  font-weight: var(--ilivin-hero-number-weight);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.metric.is-zero .metric-value {
  color: var(--muted);
}

.figure {
  font-size: var(--text-4xl);
  font-weight: var(--ilivin-hero-number-xl-weight);
  line-height: 0.94;
  font-variant-numeric: tabular-nums;
}

/* ---------- Aged-debt bar ---------- */

/* Contract -> Progress indicators: one bar family. The track is 12px, 8px
   corners, ink at 7% with a 6% inset ring and 2px padding; the fill sits
   inside at 4px corners. A share bar's segments are 4px apart. */
.agebar,
.meter-track,
.progress-track {
  display: flex;
  height: var(--ilivin-bar-height);
  padding: 2px;
  border-radius: var(--radius-key);
  background-color: var(--track);
  box-shadow: inset 0 0 0 1px var(--track-ring);
}

.agebar {
  gap: 4px;
}

.agebar-seg {
  min-width: 6px;
  border-radius: var(--radius-xs);
}

.age-0 {
  background: var(--age-0);
}

.age-1 {
  background: var(--age-1);
}

.age-2 {
  background: var(--age-2);
}

.age-3 {
  background: var(--age-3);
}

.age-4 {
  background: var(--age-4);
}

.age-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--space-3) var(--space-4);
}

.age-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}

.age-key {
  display: flex;
  align-items: center;
  gap: 6px;
}

.age-swatch {
  flex: none;
  width: 12px;
  height: 8px;
  border-radius: var(--radius-xs);
}

.age-amount {
  font-size: var(--text-lg);
  font-weight: var(--ilivin-hero-number-md-weight);
  font-variant-numeric: tabular-nums;
}

.age-item.is-zero .age-amount {
  color: var(--muted);
}

.age-item.is-zero .age-swatch {
  opacity: 0.35;
}

/* ---------- Meter (GST turnover watch) ---------- */

.meter {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.meter-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-1) var(--space-3);
}

/* Contract -> Trays -> Type ramp: the readout above a bar is the md tier. */
.meter-value {
  font-size: var(--ilivin-hero-number-md);
  font-weight: var(--ilivin-hero-number-md-weight);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* The last fifth of the track (from $60,000) is tinted. */
.meter-track {
  position: relative;
  background-image: linear-gradient(to right, transparent 0 80%, var(--warn-soft) 80% 100%);
}

.meter-fill {
  display: block;
  max-width: 100%;
  border-radius: var(--radius-xs);
  background: var(--ink);
}

/* Contract -> Progress indicators: a threshold is a 2px hairline marker on
   the track with a micro label. */
.meter-tick {
  position: absolute;
  top: -2px;
  bottom: -2px;
  left: 80%;
  width: 2px;
  background: var(--warn);
}

.meter.is-warn .meter-fill {
  background: var(--warn);
}

.meter.is-over .meter-fill {
  background: var(--danger);
}

.meter-scale {
  position: relative;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.meter-scale-mark {
  position: absolute;
  left: 80%;
  transform: translateX(-50%);
}

/* ---------- Steps (onboarding) ---------- */

.steps {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--space-2);
  counter-reset: step;
}

.step {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
  padding-top: var(--space-2);
  border-top: 2px solid var(--border-strong);
  color: var(--muted);
  font-size: var(--text-sm);
  counter-increment: step;
}

.step::before {
  content: "Step " counter(step);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.step-name {
  color: var(--ink);
  font-weight: 600;
}

.step.is-done {
  border-top-color: var(--ok);
}

.step.is-done::before {
  content: "Done";
  color: var(--ok-text);
}

.step.is-current {
  border-top-color: var(--accent);
}

/* Contract -> Chips, Navigate: the current one is primary text over a 2px
   Clay rule. */
.step.is-current::before {
  content: "Now";
  color: var(--ink);
}

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--space-4);
}

.form-grid > * {
  min-width: 0;
}

.span-2 {
  grid-column: span 2;
}

.span-3 {
  grid-column: span 3;
}

.span-4 {
  grid-column: span 4;
}

.span-5 {
  grid-column: span 5;
}

.span-6 {
  grid-column: span 6;
}

.span-7 {
  grid-column: span 7;
}

.span-8 {
  grid-column: span 8;
}

.span-9 {
  grid-column: span 9;
}

.span-12 {
  grid-column: span 12;
}

/* Contract -> Dialog and popup anatomy: field labels are 10px uppercase
   Mono, micro tracking. */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.4;
  text-transform: uppercase;
}

.field .capsules,
.field .hint,
.field .field-error {
  font-family: var(--font-body);
  letter-spacing: 0;
  text-transform: none;
}

.field-optional {
  font-weight: 400;
}

/* Contract -> Inputs and controls: the 10px control radius, 40px height,
   the warm 94% field fill, Hanken 14px. The edge is Departure 11 (3:1), not
   the contract's divider. */
/* :where() keeps the field rule at one class, so every state and variant
   below (read-only, invalid, .money, the client pages) overrides it. */
.input,
.field :where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"])),
.field select,
.field textarea {
  width: 100%;
  min-height: var(--ilivin-control-height);
  padding: 8px 12px;
  border: var(--ilivin-control-border-width) solid var(--field-border);
  border-radius: var(--radius-control);
  background: var(--field);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-md);
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.4;
  text-transform: none;
  font-variant-numeric: tabular-nums;
  transition: border-color var(--motion-base) var(--ease), box-shadow var(--motion-base) var(--ease);
}

/* Departure: iOS zooms the page on any input under 16px. */
@media (hover: none) {
  .input,
  .field :where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"])),
  .field select,
  .field textarea {
    font-size: 16px;
  }
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

/* Focus: a Clay edge, a Clay caret and the ring. */
.input:focus-visible,
.field :where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"])):focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--focus-shadow-field);
  caret-color: var(--accent);
}

/* Departure 11: the contract's 72% placeholder is 3.17:1 on the light field. */
.input::placeholder,
.field input::placeholder,
.field textarea::placeholder {
  color: var(--muted);
  opacity: 1;
}

.input[readonly],
.field input[readonly] {
  border-style: dashed;
  background: var(--recess);
}

/* Contract -> Inputs: a disabled control keeps its layout and falls to 50%. */
.input:disabled,
.field input:disabled,
.field select:disabled,
.field textarea:disabled {
  opacity: 0.5;
  cursor: default;
}

.hint {
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 400;
}

.field-error {
  color: var(--danger-text);
  font-size: var(--text-sm);
  font-weight: 500;
}

.field.has-error input,
.field.has-error select,
.field.has-error textarea,
.field [aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: var(--ilivin-control-invalid-ring);
}

.money {
  position: relative;
  display: block;
}

.money::before {
  content: "$";
  position: absolute;
  top: 50%;
  left: 12px;
  color: var(--muted);
  font-weight: 400;
  transform: translateY(-50%);
}

.money input {
  padding-left: 24px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: var(--text-md);
  font-weight: 400;
  cursor: pointer;
}

.check input {
  flex: none;
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

/* Contract -> Inputs and controls: a binary setting is a toggle. A 44 x 24
   track (the divider colour off, Clay on) and a 20px Linen knob. It is a
   real checkbox with role="switch", so the form posts without JavaScript
   (Departure 15). */
.toggle {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--ilivin-control-height);
  color: var(--ink);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: var(--text-md);
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.4;
  text-transform: none;
}

.toggle input {
  appearance: none;
  position: relative;
  flex: none;
  width: 44px;
  height: 24px;
  margin: 0;
  border: 1px solid var(--field-border);
  border-radius: var(--radius-pill);
  background: var(--border);
  cursor: pointer;
  transition: background-color var(--motion-base) var(--ease), border-color var(--motion-base) var(--ease);
}

.toggle input::before {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--ilivin-linen);
  box-shadow: 0 0 0 1px var(--field-border);
  transition: transform var(--motion-base) var(--ease);
}

.toggle input:checked {
  border-color: var(--ilivin-clay);
  background: var(--ilivin-clay);
}

.toggle input:checked::before {
  box-shadow: none;
  transform: translateX(20px);
}

.toggle input:disabled {
  opacity: 0.5;
  cursor: default;
}

.toggle-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

/* A group of radio or tick cards under one question. */
.choices {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.choices legend {
  margin-bottom: var(--space-2);
  padding: 0;
  font-size: var(--text-md);
  font-weight: 600;
}

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

.search {
  min-width: 0;
  max-width: 280px;
}

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

.table-wrap {
  overflow-x: auto;
}

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

.data-table th {
  padding: 0 var(--space-3) var(--space-2) 0;
  border-bottom: 1px solid var(--border-strong);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table td {
  padding: var(--space-3) var(--space-3) var(--space-3) 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table th:last-child,
.data-table td:last-child {
  padding-right: 0;
}

.data-table .th-num,
.data-table .cell-amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.data-table .cell-amount {
  font-weight: 600;
}

.data-table .cell-actions {
  text-align: right;
  white-space: nowrap;
}

.data-table tfoot td {
  border-top: 1px solid var(--border-strong);
  border-bottom: 0;
  font-weight: 600;
}

.row-link {
  color: var(--ink);
  font-weight: 600;
}

.sub {
  display: block;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 400;
}

.late {
  color: var(--danger-text);
}

tr[data-row-href] {
  cursor: pointer;
}

tr[data-row-href]:hover td {
  background: var(--recess);
}

.phone-only {
  display: none;
}

/* ---------- Simple rows (lists inside cards) ---------- */

.rows {
  display: flex;
  flex-direction: column;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}

.row:first-child {
  padding-top: 0;
}

.row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.row-main {
  display: flex;
  flex: 1 1 200px;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

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

/* A contact's support link, shown on demand on the client page. */
.support-link-value {
  flex-basis: 100%;
  overflow-wrap: anywhere;
}

/* ---------- Line items ---------- */

.lines {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.lines th {
  padding: 0 var(--space-2) var(--space-2) 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-align: left;
  text-transform: uppercase;
}

.lines td {
  padding: 0 var(--space-2) var(--space-2) 0;
  vertical-align: top;
}

.lines th:last-child,
.lines td:last-child {
  padding-right: 0;
}

.lines .line-qty {
  width: 84px;
}

.lines .line-unit {
  width: 132px;
}

.lines .line-amount {
  width: 120px;
  padding-top: 12px;
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.lines th.line-amount {
  padding-top: 0;
}

.lines .line-remove {
  width: 36px;
}

.lines textarea.input {
  display: block;
  min-height: 40px;
  resize: vertical;
  field-sizing: content;
}

.lines .input-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.line-label {
  display: none;
}

.totals {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.total-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
}

.total-row .num {
  font-weight: 600;
}

.total-row.is-grand {
  font-size: var(--text-md);
  font-weight: 600;
}

.total-row.is-grand .num {
  font-weight: var(--ilivin-hero-number-weight);
}

.total-row.is-grand:has(~ .total-row:not([hidden])) {
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-strong);
}

.total-row.is-grand .num {
  font-size: var(--text-2xl);
}

.sticky-rail {
  position: sticky;
  top: var(--space-6);
}

/* ---------- Merge fields ---------- */

/* Contract -> Chips, Group: a dashed neutral stamp. It states; it is never
   pressed. In the template editor the key beside it does the inserting. */
.merge-token {
  display: inline-block;
  padding: 0 6px;
  border: 1px dashed var(--key-edge);
  border-radius: var(--radius-stamp);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

/* ---------- Drop zone ---------- */

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-6) var(--space-4);
  border: 1px dashed var(--field-border);
  border-radius: var(--radius-tray);
  background: var(--recess);
  text-align: center;
  cursor: pointer;
}

.dropzone.is-over,
.dropzone:has(.dropzone-input:focus-visible) {
  border-color: var(--accent);
  box-shadow: var(--focus-shadow-field);
}

.dropzone-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* ---------- Thread (tickets): admin ticket page and the support page ---------- */

.thread {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* A message is a tray (Contract -> Trays -> Container). */
.entry {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-5);
  border-radius: var(--radius-tray);
  background: var(--recess);
  color: var(--ilivin-tray-fg);
  box-shadow: var(--ilivin-tray-glow);
}

/* Written by the person reading: no tray, a neutral rule on the left. Not
   Clay: Clay is the primary action, focus and the current tab only. */
.entry-own {
  border-left: 2px solid var(--field-border);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

/* Internal note: never shown or sent to a client. The contract's dashed
   "group" mark, as a box. */
.entry-internal {
  border: 1px dashed var(--field-border);
  background: transparent;
  box-shadow: none;
}

.entry-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-3);
}

.entry-author {
  font-weight: 600;
}

.entry-time {
  margin-left: auto;
  color: var(--muted);
  font-size: var(--text-sm);
}

.entry-body {
  white-space: pre-line;
}

.entry-event {
  padding: 0 var(--space-5);
  color: var(--muted);
  font-size: var(--text-sm);
}

.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.thumb {
  display: flex;
  align-items: flex-end;
  width: 96px;
  height: 72px;
  padding: var(--space-1) 6px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-key);
  background: var(--card);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  line-height: 1.3;
  text-decoration: none;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---------- Empty state ---------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-8) var(--space-4);
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
}

/* ---------- Disclosure and danger zone ---------- */

.disclosure > summary {
  color: var(--muted);
  font-size: var(--text-md);
  cursor: pointer;
}

.disclosure[open] > summary {
  margin-bottom: var(--space-3);
}

/* ---------- Confirm dialog ---------- */

/* Contract -> Canvas (Dialog/popup shell) and Dialog and popup anatomy.
   24px corners, min(440px, 94vw), at most 90dvh, the card fill, the glass
   edge, one warm shadow, a 62% Ink backdrop with a 4px blur. A head with
   the 22px title and a 36px close key; a body; a quiet separated foot with
   Cancel then the action. On a phone it is a bottom sheet. */
.dialog {
  width: 94vw;
  max-width: min(440px, 94vw);
  max-height: 90dvh;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--ilivin-glass-border);
  border-radius: var(--radius-dialog);
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: var(--scrim);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.dialog-form {
  display: flex;
  flex-direction: column;
  max-height: 90dvh;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-5);
}

.dialog-copy {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.dialog-title {
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: 1.15;
}

.dialog-body {
  color: var(--muted);
  overflow-y: auto;
}

.dialog-close {
  appearance: none;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--dialog-close);
  color: var(--muted);
  cursor: pointer;
}

.dialog-close:hover {
  background: var(--dialog-close-hover);
  color: var(--ink);
}

.dialog-close .icon {
  width: 18px;
  height: 18px;
}

.dialog-foot {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--dialog-foot);
}

.dialog-foot .btn {
  min-width: 80px;
}

/* ---------- Auth pages ---------- */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-6) var(--space-4);
}

.auth-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  width: min(100%, 400px);
  padding: var(--space-8);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--card);
  box-shadow: var(--shadow-soft);
}

/* ---------- Breakpoints ---------- */

@media (max-width: 1024px) {
  .grid-main,
  .grid-half {
    grid-template-columns: minmax(0, 1fr);
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sticky-rail {
    position: static;
  }

  .steps {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-4) var(--space-2);
  }
}

@media (max-width: 720px) {
  .shell {
    display: block;
  }

  .mobile-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    min-height: 56px;
    padding: var(--space-2) var(--space-4);
    border-bottom: 1px solid var(--line);
    background: var(--canvas);
  }

  .mobile-bar .logo {
    height: 24px;
  }

  .side {
    position: static;
    height: auto;
    padding: var(--space-4);
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .side .brand {
    display: none;
  }

  /* With JavaScript the menu is closed until the Menu key is pressed.
     Without it the nav simply sits at the top of the page. */
  .js .side {
    display: none;
  }

  .js .nav-open .side {
    position: fixed;
    inset: 56px 0 0;
    z-index: 19;
    display: flex;
    background: var(--canvas);
  }

  .nav-link {
    min-height: 40px;
  }

  .main {
    gap: var(--space-5);
    padding: var(--space-5) var(--space-4) var(--space-10);
  }

  .btn,
  .btn-sm {
    min-height: 40px;
  }

  .btn-icon {
    width: 44px;
    min-height: 44px;
  }

  .capsule,
  .tab {
    min-height: 40px;
  }

  /* Contract -> Canvas: on a phone a dialog is a bottom sheet. */
  .dialog {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    margin: auto auto 0;
    border-bottom: 0;
    border-radius: var(--radius-dialog) var(--radius-dialog) 0 0;
  }

  .dialog-foot .btn {
    flex: 1 1 0;
  }

  .card-head {
    padding: var(--space-4) var(--space-4) 0;
  }

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

  .card-foot {
    padding: var(--space-3) var(--space-4);
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .form-grid > * {
    grid-column: 1;
  }

  .form-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .search {
    max-width: none;
  }

  .phone-only {
    display: block;
  }

  .age-list {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .age-item {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    min-height: 44px;
    border-bottom: 1px solid var(--border);
  }

  .age-item:last-child {
    border-bottom: 0;
  }

  .age-count {
    margin-left: auto;
  }

  .steps {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .step {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px var(--space-3);
    padding: var(--space-2) 0 var(--space-2) var(--space-3);
    border-top: 0;
    border-left: 2px solid var(--border-strong);
  }

  .step::before {
    min-width: 48px;
  }

  .step.is-done {
    border-left-color: var(--ok);
  }

  .step.is-current {
    border-left-color: var(--accent);
  }

  .step-note {
    flex-basis: 100%;
  }

  /* Tables become stacked rows. Cells with a role class take a fixed
     place; any other cell stacks underneath as "LABEL value". */
  .data-table.responsive thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .data-table.responsive,
  .data-table.responsive tbody,
  .data-table.responsive tfoot {
    display: block;
  }

  .data-table.responsive tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-1) var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--border);
  }

  .data-table.responsive tr:first-child {
    padding-top: 0;
  }

  .data-table.responsive tr:last-child {
    padding-bottom: 0;
    border-bottom: 0;
  }

  .data-table.responsive td {
    display: block;
    grid-column: 1 / -1;
    padding: 0;
    border: 0;
  }

  .data-table.responsive td.cell-primary {
    grid-row: 1;
    grid-column: 1;
  }

  .data-table.responsive td.cell-amount {
    grid-row: 1;
    grid-column: 2;
  }

  .data-table.responsive td.cell-meta {
    grid-row: 2;
    grid-column: 1;
    color: var(--muted);
    font-size: var(--text-sm);
  }

  .data-table.responsive td.cell-state {
    grid-row: 2;
    grid-column: 2;
    justify-self: end;
  }

  .data-table.responsive.no-amount td.cell-state {
    grid-row: 1;
  }

  .data-table.responsive td[data-label]::before {
    content: attr(data-label);
    display: inline-block;
    min-width: 104px;
    padding-right: var(--space-2);
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .data-table.responsive td.cell-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    padding-top: var(--space-2);
    text-align: left;
    white-space: normal;
  }

  .data-table.responsive td.desktop-cell {
    display: none;
  }

  .data-table.responsive tr[data-row-href]:hover td {
    background: transparent;
  }

  /* Line items: one block per line. */
  .lines thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .lines,
  .lines tbody {
    display: block;
  }

  .lines tr {
    display: grid;
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr) minmax(0, 1fr) 44px;
    gap: var(--space-2);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--border);
  }

  .lines tr:first-child {
    padding-top: 0;
  }

  .lines td {
    display: block;
    width: auto;
    padding: 0;
  }

  .lines .line-desc {
    grid-row: 1;
    grid-column: 1 / 4;
  }

  .lines .line-qty {
    grid-row: 2;
    grid-column: 1;
  }

  .lines .line-unit {
    grid-row: 2;
    grid-column: 2;
  }

  .lines .line-qty,
  .lines .line-unit,
  .lines .line-amount {
    width: auto;
  }

  .lines .line-amount {
    grid-row: 2;
    grid-column: 3 / 5;
    padding-top: 0;
  }

  .lines .line-remove {
    grid-row: 1;
    grid-column: 4;
    align-self: end;
    width: auto;
  }

  .line-label {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .lines .line-amount .line-value {
    display: block;
    padding-top: 12px;
  }

  .auth-card {
    padding: var(--space-6);
  }
}

@media (max-width: 420px) {
  .page-actions .btn {
    flex: 1 1 auto;
  }
}

/* ---------- Jump tabs: in-page anchors, single-column layouts only ---------- */

.jump {
  display: none;
}

@media (max-width: 1024px) {
  .jump {
    display: flex;
  }

  .jump-target {
    scroll-margin-top: 72px;
  }
}


/* ---------- Split: text on the left, its action on the right ---------- */

.split {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3) var(--space-5);
}

.thumb:has(img) {
  padding: 0;
}

/* ---------- Credits: balance, progress, sizes ---------- */

.credits {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.balance {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2);
}

.balance-number {
  font-size: var(--text-4xl);
  font-weight: var(--ilivin-hero-number-xl-weight);
  line-height: 0.94;
  font-variant-numeric: tabular-nums;
}

.balance-unit {
  color: var(--muted);
  font-size: var(--ilivin-hero-number-unit-sm);
}

.progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* The track is the shared one (Aged-debt bar, above). */
.progress-fill {
  display: block;
  max-width: 100%;
  border-radius: var(--radius-xs);
  background: var(--ink);
}

.progress.is-full .progress-fill {
  background: var(--ok);
}

.progress-text {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
}

.plus {
  color: var(--ok-text);
}

.lines .line-credits {
  width: 120px;
}

@media (max-width: 720px) {
  .lines.lines-credits tr {
    grid-template-columns: minmax(0, 1fr) 96px 44px;
  }

  .lines.lines-credits .line-desc {
    grid-row: 1;
    grid-column: 1 / 3;
  }

  .lines.lines-credits .line-credits {
    grid-row: 2;
    grid-column: 2 / 4;
    width: auto;
  }

  .lines.lines-credits .line-remove {
    grid-row: 1;
    grid-column: 3;
  }
}

/* Which wordmark shows: the maintained brand files, one per mode. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo .on-light {
    display: none;
  }

  :root:not([data-theme="light"]) .logo .on-dark {
    display: block;
  }
}

:root[data-theme="dark"] .logo .on-light {
  display: none;
}

:root[data-theme="dark"] .logo .on-dark {
  display: block;
}

/* A field on a tray needs no rule of its own: --field is the card colour at
   94%, so on a tray it reads a step brighter than the slab. */

/* A bare file input: the browser's control in body type, with its button
   drawn as the keycap. */
.field input[type="file"] {
  max-width: 100%;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

.field input[type="file"]::file-selector-button {
  min-height: 34px;
  margin-right: var(--space-3);
  padding: 0 8px;
  border: 1px solid var(--key-line);
  border-bottom: 2px solid var(--key-edge);
  border-radius: var(--radius-key);
  background: var(--key);
  color: var(--ink);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
}

/* Contract -> Motion: nothing moves under reduced motion. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
