/*
 * IconFiber control plane: the one stylesheet of the server-rendered pages (sign in, register, password reset,
 * organisation chooser, invitations, access requests, billing, errors). Plain CSS, no build step; the layout
 * (resources/views/layouts/app.blade.php) links it from public/css/.
 *
 * The look is the approved design in docs/design/portal-sample/ as implemented by ui/ (ui/src/styles/tokens.css
 * and base.css). The token block below is a copy of tokens.css with the same names and values: when ui/ changes
 * its tokens, change them here too. Dark is the default; the light block applies when the visitor's system asks
 * for it (prefers-color-scheme). Colours are used only through the tokens.
 */

/* ---- Inter (self-hosted, OFL: public/fonts/OFL.txt). Only the faces a page needs are downloaded. ---- */
@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('../fonts/inter-latin-ext-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('../fonts/inter-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---- Tokens: dark (default) ---- */
:root {
  /* Surfaces: layered neutrals */
  --color-bg: #0a0e13;
  --color-sidebar: #0d1219;
  --color-surface: #10151c;
  --color-surface-2: #151b24;
  --color-elevated: #1c2430;
  --color-hover: rgb(255 255 255 / 0.05);
  --color-border: rgb(255 255 255 / 0.07);
  --color-border-strong: rgb(255 255 255 / 0.12);
  --color-control-bg: #0c1117;

  /* Text */
  --color-text: #e8ecf1;
  --color-text-2: #b7c0cc;
  --color-muted: #8e99a8;

  /* Brand and status colours */
  --color-primary: #4f8cff;
  --color-primary-hover: #7aa7ff;
  --color-on-primary: #06101f;
  /* Filled controls use the deeper blue so white text passes AA. */
  --color-primary-solid: #3a6fe6;
  --color-primary-solid-hover: #3366dd;
  --color-on-primary-solid: #ffffff;
  --color-primary-soft: rgb(79 140 255 / 0.14);
  --color-link: #7aa7ff;
  --color-good: #34d399;
  --color-warn: #fbbf24;
  --color-bad: #f87171;
  --color-info: #4f8cff;
  --color-violet: #a78bfa;
  --color-cyan: #22d3ee;
  --color-good-bg: rgb(52 211 153 / 0.13);
  --color-warn-bg: rgb(251 191 36 / 0.12);
  --color-bad-bg: rgb(248 113 113 / 0.13);
  --color-info-bg: rgb(79 140 255 / 0.14);
  --color-violet-bg: rgb(167 139 250 / 0.14);
  --color-cyan-bg: rgb(34 211 238 / 0.12);
  --color-neutral-bg: rgb(142 153 168 / 0.15);
  --color-good-border: rgb(52 211 153 / 0.28);
  --color-warn-border: rgb(251 191 36 / 0.28);
  --color-bad-border: rgb(248 113 113 / 0.3);
  --color-info-border: rgb(79 140 255 / 0.32);
  /* Text on the red tint (the sign-in mockup's error line): lighter than --color-bad in dark, the same in light. */
  --color-bad-text: #fca5a5;

  /* Brand gradient (logo mark, sign-in panel) */
  --brand-from: #4f8cff;
  --brand-to: #22d3ee;
  --gradient-brand: linear-gradient(135deg, var(--brand-from), var(--brand-to));
  --gradient-mesh:
    radial-gradient(60rem 36rem at 12% -10%, rgb(79 140 255 / 0.2), transparent 60%),
    radial-gradient(44rem 30rem at 100% 110%, rgb(34 211 238 / 0.12), transparent 60%);

  /* Elevation */
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.35);
  --shadow-md: 0 6px 18px rgb(0 0 0 / 0.38);
  --shadow-lg: 0 18px 48px rgb(0 0 0 / 0.55);
  --shadow: var(--shadow-lg);
  --shadow-primary: 0 1px 0 rgb(255 255 255 / 0.18) inset, 0 6px 20px rgb(58 111 230 / 0.32);
  --focus-glow: 0 0 0 3px rgb(79 140 255 / 0.28);

  /* Shape */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius: var(--radius-md);
  --radius-pill: 999px;
  --control-height: 36px;
  --control-height-sm: 30px;
  --control-height-lg: 42px;

  /* Type */
  --font-sans: 'Inter Variable', Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-md: 14px;
  --text-lg: 16px;
  --text-xl: 20px;
  --text-2xl: 26px;
  --text-3xl: 40px;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --leading-tight: 1.2;
  --leading-normal: 1.5;
  --tracking-tight: -0.02em;

  /* Motion and focus */
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --transition-fast: 120ms var(--ease);
  --transition-base: 180ms var(--ease);
  --focus-ring: 2px solid var(--color-primary);

  /* The chevron of native selects, as a theme colour (a data URI cannot read a CSS variable). */
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238e99a8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");

  color-scheme: dark;
}

/* ---- Tokens: light (the visitor's system asks for it) ---- */
@media (prefers-color-scheme: light) {
  :root {
    --color-bg: #f6f7f9;
    --color-sidebar: #ffffff;
    --color-surface: #ffffff;
    --color-surface-2: #f9fafb;
    --color-elevated: #ffffff;
    --color-hover: #eef0f3;
    --color-border: #e6e8ec;
    --color-border-strong: #d9dde3;
    --color-control-bg: #ffffff;

    --color-text: #0f172a;
    --color-text-2: #3f4a5a;
    --color-muted: #5b6576;

    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-on-primary: #ffffff;
    --color-primary-solid: #2563eb;
    --color-primary-solid-hover: #1d4ed8;
    --color-on-primary-solid: #ffffff;
    --color-primary-soft: #eaf1ff;
    --color-link: #2563eb;
    --color-good: #047857;
    --color-warn: #b45309;
    --color-bad: #b91c1c;
    --color-info: #1d4ed8;
    --color-violet: #6d28d9;
    --color-cyan: #0e7490;
    --color-good-bg: #ecfdf5;
    --color-warn-bg: #fffbeb;
    --color-bad-bg: #fef2f2;
    --color-info-bg: #eaf1ff;
    --color-violet-bg: #f5f3ff;
    --color-cyan-bg: #ecfeff;
    --color-neutral-bg: #f1f5f9;
    --color-good-border: #a7f3d0;
    --color-warn-border: #fde68a;
    --color-bad-border: #fecaca;
    --color-info-border: #bfd3fe;
    --color-bad-text: #b91c1c;

    --brand-from: #2563eb;
    --brand-to: #06b6d4;
    --gradient-mesh:
      radial-gradient(60rem 36rem at 12% -10%, rgb(37 99 235 / 0.12), transparent 60%),
      radial-gradient(44rem 30rem at 100% 110%, rgb(6 182 212 / 0.1), transparent 60%);

    --shadow-sm: 0 1px 2px rgb(15 23 42 / 0.06);
    --shadow-md: 0 6px 18px rgb(15 23 42 / 0.09);
    --shadow-lg: 0 18px 48px rgb(15 23 42 / 0.18);
    --shadow: var(--shadow-lg);
    --shadow-primary: 0 1px 2px rgb(37 99 235 / 0.35);
    --focus-glow: 0 0 0 3px rgb(37 99 235 / 0.22);

    --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235b6576' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");

    color-scheme: light;
  }
}

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

html {
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: var(--weight-semibold);
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

h1 {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
}

h2 {
  font-size: var(--text-lg);
}

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

p {
  margin: 0.5rem 0;
  color: var(--color-text-2);
}

strong {
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

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

a:hover {
  color: var(--color-primary-hover);
}

/* A link inside a sentence is never told apart by colour alone. */
p a,
li a,
.alert a {
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentcolor 45%, transparent);
}

p a:hover,
li a:hover,
.alert a:hover {
  text-decoration-color: currentcolor;
}

::selection {
  background: var(--color-primary-soft);
}

:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

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

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -64px;
  z-index: 10;
  padding: 10px 16px;
  border-radius: var(--radius);
  background: var(--color-primary-solid);
  color: var(--color-on-primary-solid);
  font-weight: var(--weight-semibold);
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentcolor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

form.inline {
  display: inline;
  margin: 0;
}

/* ---- Buttons ---- */
/* `.btn` is the secondary button. Variants: `.btn-primary`, `.btn-ghost`, `.btn-link`; sizes `.btn-sm`, `.btn-lg`; `.btn-block`. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2, 8px);
  min-height: var(--control-height);
  padding: 0 16px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius);
  background: var(--color-surface-2);
  box-shadow: var(--shadow-sm);
  color: var(--color-text);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition:
    background var(--transition-fast),
    border-color var(--transition-fast),
    color var(--transition-fast),
    box-shadow var(--transition-fast);
}

.btn:hover:not(:disabled, [aria-disabled='true']) {
  background: var(--color-hover);
  color: var(--color-text);
  text-decoration: none;
}

.btn .icon {
  width: 16px;
  height: 16px;
}

.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-primary {
  border-color: var(--color-primary-solid);
  background: var(--color-primary-solid);
  box-shadow: var(--shadow-primary);
  color: var(--color-on-primary-solid);
  font-weight: var(--weight-semibold);
}

.btn-primary:hover:not(:disabled, [aria-disabled='true']) {
  border-color: var(--color-primary-solid-hover);
  background: var(--color-primary-solid-hover);
  color: var(--color-on-primary-solid);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--color-text-2);
}

.btn-ghost:hover:not(:disabled, [aria-disabled='true']) {
  background: var(--color-hover);
  color: var(--color-text);
}

.btn-sm {
  min-height: var(--control-height-sm);
  padding: 0 12px;
  font-size: var(--text-xs);
}

.btn-lg {
  min-height: 44px;
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}

.btn-block {
  width: 100%;
}

.btn-google {
  gap: 10px;
}

.btn-google .icon {
  width: 18px;
  height: 18px;
  fill: initial;
  stroke: none;
}

/* A text button that reads as a link (the slug suggestion, "Sign out" inside a sentence). */
button.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-link);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentcolor 45%, transparent);
  text-underline-offset: 3px;
}

button.link:hover {
  color: var(--color-primary-hover);
  text-decoration-color: currentcolor;
}

/* ---- Forms ---- */
form.stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.field__row a {
  font-size: var(--text-sm);
  text-decoration: none;
}

label,
.label {
  display: block;
  color: var(--color-text-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

input[type='text'],
input[type='email'],
input[type='password'],
select,
textarea {
  width: 100%;
  min-height: var(--control-height-lg);
  padding: 8px 14px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius);
  background-color: var(--color-control-bg);
  color: var(--color-text);
  font: inherit;
  font-size: var(--text-md);
  transition:
    border-color var(--transition-fast),
    box-shadow var(--transition-fast);
}

input::placeholder,
textarea::placeholder {
  color: var(--color-muted);
}

input[type='text']:hover,
input[type='email']:hover,
input[type='password']:hover,
select:hover,
textarea:hover {
  border-color: var(--color-muted);
}

input[type='text']:focus,
input[type='email']:focus,
input[type='password']:focus,
select:focus,
textarea:focus {
  border-color: var(--color-primary);
  box-shadow: var(--focus-glow);
  /* Transparent, not none: a forced-colours (high contrast) mode still draws it. */
  outline: 2px solid transparent;
}

input[aria-invalid='true'],
select[aria-invalid='true'],
textarea[aria-invalid='true'] {
  border-color: var(--color-bad);
}

textarea {
  min-height: 7rem;
  resize: vertical;
}

select {
  padding-right: 38px;
  appearance: none;
  background-image: var(--select-chevron);
  background-position: right 12px center;
  background-repeat: no-repeat;
  background-size: 16px;
  cursor: pointer;
}

select option {
  background: var(--color-surface);
  color: var(--color-text);
}

input[type='checkbox'],
input[type='radio'] {
  width: 16px;
  height: 16px;
  margin: 0;
  flex: none;
  accent-color: var(--color-primary-solid);
}

.hint {
  min-height: 1.3em;
  margin: 0;
  color: var(--color-muted);
  font-size: var(--text-sm);
}

/* The slug check (an inline script sets `hint ok` / `hint bad`). */
.hint.ok {
  color: var(--color-good);
}

.hint.bad {
  color: var(--color-bad-text);
}

.error {
  margin: 0;
  color: var(--color-bad-text);
  font-size: var(--text-sm);
}

/* A checkbox with its text. */
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--color-text-2);
  font-size: var(--text-md);
  font-weight: var(--weight-regular);
  cursor: pointer;
}

/* A radio as a selectable card (hosting region, domain pack). */
.choices {
  display: grid;
  gap: 8px;
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius);
  background: var(--color-control-bg);
  color: var(--color-text-2);
  font-size: var(--text-md);
  font-weight: var(--weight-regular);
  cursor: pointer;
  transition:
    border-color var(--transition-fast),
    background var(--transition-fast);
}

.choice input {
  margin-top: 2px;
}

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

.choice:has(input:checked) {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
}

.choice:has(input:focus-visible) {
  border-color: var(--color-primary);
  box-shadow: var(--focus-glow);
}

.choice.disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.choice strong {
  display: block;
}

.choice .muted {
  display: block;
  font-size: var(--text-sm);
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--color-muted);
  font-size: var(--text-xs);
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
}

.actions p {
  margin: 0;
}

/* ---- Alerts (status and errors) ---- */
.alert {
  --alert-fg: var(--color-info);
  --alert-bg: var(--color-info-bg);
  --alert-border: var(--color-info-border);
  --alert-text: var(--color-text-2);

  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 16px 0;
  padding: 12px 14px;
  border: 1px solid var(--alert-border);
  border-radius: 12px;
  background: var(--alert-bg);
  color: var(--alert-text);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.alert--good {
  --alert-fg: var(--color-good);
  --alert-bg: var(--color-good-bg);
  --alert-border: var(--color-good-border);
}

.alert--warn {
  --alert-fg: var(--color-warn);
  --alert-bg: var(--color-warn-bg);
  --alert-border: var(--color-warn-border);
}

.alert--bad {
  --alert-fg: var(--color-bad);
  --alert-bg: var(--color-bad-bg);
  --alert-border: var(--color-bad-border);
  --alert-text: var(--color-bad-text);
}

.alert--neutral {
  --alert-fg: var(--color-muted);
  --alert-bg: var(--color-neutral-bg);
  --alert-border: var(--color-border-strong);
}

.alert__icon {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  color: var(--alert-fg);
}

.alert__body {
  min-width: 0;
  flex: 1;
  overflow-wrap: anywhere;
}

.alert__body p {
  margin: 0;
  color: inherit;
}

.alert__body strong {
  color: var(--color-text);
}

.alert ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.alert li + li {
  margin-top: 4px;
}

/* ---- Pills ---- */
.pill {
  --pill-fg: var(--color-text-2);
  --pill-bg: var(--color-neutral-bg);

  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--pill-bg);
  color: var(--pill-fg);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: 1.4;
  white-space: nowrap;
}

.pill--dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentcolor;
}

.pill--good {
  --pill-fg: var(--color-good);
  --pill-bg: var(--color-good-bg);
}

.pill--warn {
  --pill-fg: var(--color-warn);
  --pill-bg: var(--color-warn-bg);
}

.pill--bad {
  --pill-fg: var(--color-bad);
  --pill-bg: var(--color-bad-bg);
}

.pill--info {
  --pill-fg: var(--color-info);
  --pill-bg: var(--color-info-bg);
}

.pill--violet {
  --pill-fg: var(--color-violet);
  --pill-bg: var(--color-violet-bg);
}

/* ---- Avatar (initials; the colour comes from the name) ---- */
.avatar {
  display: inline-grid;
  width: var(--av-size, 32px);
  height: var(--av-size, 32px);
  flex: none;
  place-items: center;
  overflow: hidden;
  font-size: calc(var(--av-size, 32px) * 0.38);
  font-weight: var(--weight-bold);
  letter-spacing: 0;
  line-height: 1;
  user-select: none;
}

.avatar--circle {
  border-radius: 50%;
}

.avatar--square {
  border-radius: calc(var(--av-size, 32px) * 0.25);
}

.avatar--solid {
  background: var(--av);
  color: #fff;
}

.avatar--soft {
  background: color-mix(in srgb, var(--av) 18%, var(--color-surface));
  color: color-mix(in srgb, var(--av) 45%, var(--color-text));
}

/* ---- Brand mark ---- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: calc(var(--brand-size, 28px) * 0.36);
  color: var(--color-text);
  line-height: 1;
}

.brand__mark {
  width: var(--brand-size, 28px);
  height: var(--brand-size, 28px);
  flex: none;
}

.brand__word {
  font-size: calc(var(--brand-size, 28px) * 0.57);
  font-weight: var(--weight-bold);
  letter-spacing: -0.01em;
}

a.brand-link {
  display: inline-flex;
  border-radius: var(--radius);
  color: var(--color-text);
  text-decoration: none;
}

a.brand-link:hover {
  color: var(--color-text);
}

/* ---- Session bar (who is signed in, Sign out) ---- */
.who {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  min-width: 0;
  color: var(--color-text-2);
  font-size: var(--text-sm);
}

.who__name {
  max-width: 20ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Layout: centred card (invitations, chooser, errors, access requests, ...) and page (billing) ---- */
.shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: var(--color-bg);
  background-image: var(--gradient-mesh);
  background-repeat: no-repeat;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 60px;
  padding: 12px 24px;
}

.stage {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px 20px 48px;
}

.stage--page {
  justify-content: flex-start;
  padding-top: 8px;
}

.stage > * {
  width: 100%;
}

.flash {
  max-width: 480px;
}

.stage--page .flash {
  max-width: 920px;
}

.flash .alert {
  margin: 0;
  box-shadow: var(--shadow-sm);
}

.card {
  max-width: 480px;
  padding: 32px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
}

.card--md {
  max-width: 560px;
}

.card__brand {
  margin-bottom: 24px;
}

.card h1 + p,
.page__head h1 + p {
  margin-top: 8px;
}

.card > p:first-of-type {
  line-height: 1.6;
}

.foot {
  padding: 0 24px 24px;
  color: var(--color-muted);
  font-size: var(--text-xs);
  text-align: center;
}

/* A round icon in a tinted square above the title of a state page. */
.hero {
  --hero-fg: var(--color-info);
  --hero-bg: var(--color-info-bg);

  display: grid;
  width: 44px;
  height: 44px;
  margin-bottom: 16px;
  place-items: center;
  border-radius: 12px;
  background: var(--hero-bg);
  color: var(--hero-fg);
}

.hero .icon {
  width: 22px;
  height: 22px;
}

.hero--good {
  --hero-fg: var(--color-good);
  --hero-bg: var(--color-good-bg);
}

.hero--warn {
  --hero-fg: var(--color-warn);
  --hero-bg: var(--color-warn-bg);
}

.hero--bad {
  --hero-fg: var(--color-bad);
  --hero-bg: var(--color-bad-bg);
}

.hero--neutral {
  --hero-fg: var(--color-muted);
  --hero-bg: var(--color-neutral-bg);
}

.quote {
  margin: 16px 0;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-primary);
  border-radius: var(--radius);
  background: var(--color-surface-2);
  color: var(--color-text);
  font-size: var(--text-md);
}

.quote .muted {
  display: block;
  margin-top: 4px;
  font-size: var(--text-sm);
}

/* ---- Layout: split (sign in, register, password, verify, new organisation) ---- */
.split {
  display: grid;
  grid-template-columns: minmax(0, min(640px, 44%)) minmax(0, 1fr);
  min-height: 100vh;
}

.split__brand {
  border-right: 1px solid var(--color-border);
  background-color: var(--color-sidebar);
  background-image: var(--gradient-mesh);
  background-repeat: no-repeat;
}

.split__panel {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100vh;
  min-height: 460px;
  padding: 56px;
  overflow: hidden;
}

.split__art {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 72%;
  pointer-events: none;
}

.split__art .nodes {
  fill: var(--color-sidebar);
  stroke: var(--color-primary);
  stroke-width: 2;
}

.split__art .halo {
  fill: none;
  stroke: var(--color-cyan);
  stroke-opacity: 0.35;
}

.split__logo,
.split__pitch,
.split__foot {
  position: relative;
}

.split__pitch {
  max-width: 460px;
  margin-bottom: clamp(0px, 24vh, 240px);
}

.split__title {
  margin: 0;
  color: var(--color-text);
  font-size: clamp(30px, 3.1vw, var(--text-3xl));
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  line-height: 1.15;
}

.split__text {
  margin: 16px 0 0;
  color: var(--color-muted);
  font-size: var(--text-lg);
  line-height: 1.6;
}

.split__foot {
  margin: 0;
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.split__form {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 72px 48px;
  background: var(--color-bg);
}

.split__form .who {
  position: absolute;
  top: 16px;
  right: 24px;
}

.auth {
  display: flex;
  flex-direction: column;
  gap: 22px;
  width: 100%;
  max-width: 400px;
}

.auth > * {
  margin: 0;
}

.auth__head {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth__head p {
  margin: 0;
  color: var(--color-muted);
  font-size: var(--text-md);
}

.auth__head h1 {
  font-size: var(--text-2xl);
}

/* A longer, more important paragraph under the title (verify email). */
.auth__head .lead {
  color: var(--color-text-2);
}

.auth .alert {
  margin: 0;
}

.auth__foot {
  margin: 0;
  color: var(--color-muted);
  font-size: var(--text-sm);
  text-align: center;
}

.auth .actions {
  margin-top: 0;
}

/* ---- Organisation chooser ---- */
.section-title {
  margin: 28px 0 10px;
  color: var(--color-muted);
  font-size: 11px;
  font-weight: var(--weight-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.orgs {
  display: grid;
  gap: 10px;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
}

.section-title + .orgs {
  margin-top: 0;
}

.org {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface-2);
  transition:
    border-color var(--transition-fast),
    background var(--transition-fast);
}

.org:hover,
.org:focus-within {
  border-color: var(--color-border-strong);
  background: var(--color-hover);
}

.org__enter {
  margin: 0;
}

.org__main,
.org__row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
}

.org__main {
  border: 0;
  border-radius: var(--radius-lg);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.org__text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.org__name {
  color: var(--color-text);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.org__sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.org__region {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.org__region .icon {
  width: 14px;
  height: 14px;
}

.org__chev {
  width: 20px;
  height: 20px;
  margin-left: auto;
  color: var(--color-muted);
  transition:
    color var(--transition-fast),
    transform var(--transition-fast);
}

.org__main:hover .org__chev,
.org__main:focus-visible .org__chev {
  color: var(--color-primary);
  transform: translateX(2px);
}

.org__aside {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}

.org__aside form {
  margin: 0;
}

.org__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  padding: 0 16px 14px 70px;
  font-size: var(--text-sm);
}

.org__meta p {
  margin: 0;
}

.org__links {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}

.billing-notice {
  color: var(--color-warn);
  font-weight: var(--weight-medium);
}

/* ---- Tables and panels (billing) ---- */
.page {
  width: 100%;
}

.page__main {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 920px;
  margin: 0 auto;
}

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

.page__head p {
  margin: 0;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  margin-bottom: 10px;
  color: var(--color-muted);
  font-size: var(--text-sm);
  text-decoration: none;
}

.back:hover {
  color: var(--color-text);
}

.back .icon {
  width: 16px;
  height: 16px;
}

.panel {
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.panel__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--color-border);
}

.panel__head h2 {
  font-size: 15px;
}

.panel__body {
  padding: 18px 20px;
}

.panel__body > :first-child {
  margin-top: 0;
}

.panel__body > :last-child {
  margin-bottom: 0;
}

.panel__foot {
  padding: 12px 20px;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.panel__foot p {
  margin: 0;
  color: inherit;
}

.panel .alert {
  margin: 0;
}

.panel__body .alert {
  margin-bottom: 14px;
}

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

.facts p {
  margin: 0;
}

.plan-name {
  display: block;
  color: var(--color-text);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.01em;
}

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

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

th,
td {
  padding: 12px 20px;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  vertical-align: middle;
}

thead th {
  background: var(--color-surface-2);
  color: var(--color-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}

tbody tr:last-child td,
tbody tr:last-child th {
  border-bottom: 0;
}

tbody tr:hover td,
tbody tr:hover th {
  background: var(--color-hover);
}

tfoot td {
  border-bottom: 0;
  background: var(--color-surface-2);
}

tfoot tr:first-child td {
  border-top: 1px solid var(--color-border);
}

th.num,
td.num {
  text-align: right;
  white-space: nowrap;
}

/* A date under the invoice number: shown on phones only, where the Issued column is left out. */
.sub-sm {
  display: none;
}

/* The usage table: a label and "{used} of {limit}". */
table.usage th {
  background: transparent;
  color: var(--color-text);
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  white-space: normal;
}

table.usage td {
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

table.usage tr[data-state='warning'] td {
  color: var(--color-warn);
}

table.usage tr[data-state='exceeded'] td {
  color: var(--color-bad-text);
}

.plans {
  margin: 0;
  padding: 0;
  list-style: none;
}

.plans li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
}

.plans li:last-child {
  border-bottom: 0;
}

.plans form {
  margin: 0;
}

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

.plan__text span {
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.plan__text strong {
  font-size: var(--text-lg);
}

.panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--color-border);
}

.panel__actions form {
  margin: 0;
}

.invoice-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 32px;
  margin: 0 0 4px;
  padding: 0;
  list-style: none;
}

.invoice-meta li {
  color: var(--color-text-2);
}

/* ---- Status page (resources/views/status/show.blade.php): the notices under the regions table ---- */
.status-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.status-list li {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
}

.status-list li:last-child {
  border-bottom: 0;
}

.status-list__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

.status-list__head strong {
  font-size: var(--text-lg);
}

.status-list p {
  margin: 0;
}

.status-list__body {
  color: var(--color-text-2);
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.status-list__meta {
  color: var(--color-muted);
  font-size: var(--text-sm);
}

/* ---- Phones ---- */
@media (max-width: 900px) {
  .split {
    /* The strip keeps its own height; the form takes the rest (auto rows would share the spare height). */
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  /* The brand panel collapses to a strip across the top. */
  .split__brand {
    border-right: 0;
    border-bottom: 1px solid var(--color-border);
  }

  .split__panel {
    position: relative;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    height: auto;
    min-height: 0;
    padding: 18px 20px;
  }

  .split__art {
    left: auto;
    width: 70%;
    height: 100%;
    opacity: 0.7;
  }

  .split__pitch,
  .split__foot {
    display: none;
  }

  .split__form {
    align-items: stretch;
    justify-content: flex-start;
    padding: 28px 20px 48px;
  }

  .split__form .who {
    position: static;
    justify-content: flex-end;
    margin-bottom: 16px;
  }

  .auth {
    max-width: 480px;
    margin: 0 auto;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding: 8px 12px;
  }

  .stage {
    padding: 8px 12px 32px;
  }

  .card {
    padding: 24px 20px;
  }

  h1,
  .auth__head h1 {
    font-size: 22px;
  }

  .org__meta {
    padding-left: 16px;
  }

  .org__row {
    flex-wrap: wrap;
  }

  /* A button (Retry) goes under the name; a status pill stays beside it. */
  .org__aside:has(form) {
    width: 100%;
    margin-left: 54px;
    justify-content: flex-start;
  }

  .panel__head,
  .panel__body,
  .panel__actions,
  .plans li {
    padding-right: 16px;
    padding-left: 16px;
  }

  .plans li {
    flex-direction: column;
    align-items: stretch;
  }

  .plans li .btn {
    width: 100%;
  }

  th,
  td {
    padding: 10px 8px;
  }

  th:first-child,
  td:first-child {
    padding-left: 16px;
  }

  th:last-child,
  td:last-child {
    padding-right: 16px;
  }

  /* The invoice list: number with its date, total, status, link. */
  .col-issued {
    display: none;
  }

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

  .invoice-meta {
    flex-direction: column;
    gap: 4px;
  }

  .who__name {
    display: none;
  }

  .actions .btn {
    flex: 1 1 auto;
  }
}

/* Touch screens: controls stay at least 44 px tall. */
@media (pointer: coarse) {
  .btn,
  .btn-sm {
    min-height: 44px;
  }

  .check,
  .choice {
    min-height: 44px;
  }
}

/* Honour the visitor's motion setting: no decorative movement, instant state changes. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
