:root {
  color-scheme: light;
  --bg: #f5f2ec;
  --panel: #fffdf8;
  --ink: #14211f;
  --muted: #5f6b66;
  --line: #d7ded8;
  --field: #ffffff;
  --focus: #1c7d6f;
  --accent: #c66b34;
  --accent-strong: #9e4f24;
  --sage: #dfe8df;
  --shadow: 0 18px 45px rgba(34, 47, 42, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(120deg, rgba(223, 232, 223, 0.88), rgba(245, 242, 236, 0.25) 42%, rgba(198, 107, 52, 0.12)),
    radial-gradient(circle at 12% 18%, rgba(28, 125, 111, 0.13), transparent 28rem),
    var(--bg);
  color: var(--ink);
  font-family: "Aptos", "Avenir Next", "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

a {
  color: var(--focus);
}

[hidden] {
  display: none !important;
}

.accounts-shell,
.signup {
  width: min(1120px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(360px, 1.1fr);
  gap: 28px;
  align-items: center;
  padding: 36px 0;
}

.accounts-shell.single {
  max-width: 880px;
  grid-template-columns: 1fr;
}

.context {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  padding: 10px 4px 10px 0;
}

.brand {
  display: inline-flex;
  width: max-content;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(28, 125, 111, 0.28);
  border-radius: 8px;
  background: var(--panel);
  color: var(--focus);
  font-weight: 800;
  letter-spacing: 0;
}

h1 {
  max-width: 12ch;
  margin: 28px 0 18px;
  font-size: clamp(2.5rem, 7vw, 5.8rem);
  line-height: 0.94;
  letter-spacing: 0;
}

.single h1 {
  max-width: 14ch;
}

h2,
h3,
p {
  letter-spacing: 0;
}

.intro {
  max-width: 34rem;
  margin: 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.65;
}

.assurance {
  display: grid;
  gap: 12px;
  max-width: 29rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.assurance li {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 12px;
  align-items: start;
  color: #34413d;
  line-height: 1.45;
}

.assurance li::before {
  content: "";
  width: 10px;
  height: 10px;
  margin-top: 0.42em;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(198, 107, 52, 0.12);
}

.surface-card,
.signup-card {
  width: 100%;
  border: 1px solid rgba(116, 135, 125, 0.28);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 22px 24px;
}

.card-heading h2 {
  margin: 0;
  font-size: 1.08rem;
  letter-spacing: 0;
}

.status-pill {
  flex: 0 0 auto;
  border: 1px solid rgba(28, 125, 111, 0.22);
  border-radius: 999px;
  padding: 6px 10px;
  background: #eef5ef;
  color: #315d51;
  font-size: 0.78rem;
  font-weight: 700;
}

form,
.card-body,
.option-grid,
.action-list {
  display: grid;
  gap: 18px;
}

form,
.card-body {
  padding: 24px;
}

/* Panels that sit directly in a card without a padded wrapper — the session
   row, the verify/reauth/second-factor challenge panels, and the admin page's
   option-card sections. Forms and .card-body carry their own 24px padding;
   everything else placed straight into a card gets the same inset here so no
   content renders flush against the card border. */
.surface-card > .session-row,
.surface-card > .field:not(form),
.surface-card > .option-card {
  margin: 24px;
}

.field {
  display: grid;
  gap: 7px;
}

.admin-signin {
  display: grid;
  gap: 14px;
  margin: 24px;
  padding: 18px;
  border: 1px solid rgba(116, 135, 125, 0.24);
  border-radius: 8px;
  background: #fffefa;
}

.admin-signin h3,
.admin-signin p {
  margin: 0;
}

.admin-signin h3 {
  color: #26332f;
  font-size: 1rem;
  line-height: 1.25;
}

.admin-signin-copy,
.admin-signin-note {
  color: var(--muted);
  line-height: 1.45;
}

.admin-signin-copy {
  font-size: 0.95rem;
}

.admin-signin-note {
  font-size: 0.82rem;
}

#signin-status {
  min-height: 20px;
  margin: 0;
  color: #8b3f22;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.35;
}

label {
  color: #26332f;
  font-size: 0.92rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid #c9d2cb;
  border-radius: 7px;
  background: var(--field);
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
  transition: border-color 130ms ease, box-shadow 130ms ease, background 130ms ease;
}

/* Checkboxes and radios must not inherit text-input sizing. The generic
   `input` rule above sets width:100% and min-height:46px, which renders every
   checkbox as a giant full-width block. */
input[type="checkbox"],
input[type="radio"] {
  width: auto;
  min-height: 0;
  min-width: 0;
  padding: 0;
  inline-size: 1rem;
  block-size: 1rem;
  accent-color: var(--focus);
}

input:focus,
select:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 4px rgba(28, 125, 111, 0.16);
}

input[readonly] {
  background: #f3f6f2;
  color: #46534f;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

small {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

button,
.button {
  min-height: 46px;
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: #fffaf4;
  cursor: pointer;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
  transition: background 130ms ease, transform 130ms ease, border-color 130ms ease;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 13px;
}

button:hover,
.button:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
  transform: none;
}

.disabled-control,
.button[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.62;
  pointer-events: none;
  transform: none;
}

.button.secondary,
button.secondary {
  border: 1px solid rgba(28, 125, 111, 0.24);
  background: #eef5ef;
  color: #315d51;
}

.button.secondary:hover,
button.secondary:hover {
  border-color: rgba(28, 125, 111, 0.42);
  background: #e2ede5;
}

#recaptcha-container,
#admin-challenge-recaptcha,
#sign-sms-recaptcha {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

#status,
#prereq,
.status-message {
  min-height: 24px;
  margin: 0;
  color: #315d51;
  font-weight: 700;
}

#status,
#prereq {
  padding: 0 24px 24px;
}

.notice {
  border: 1px solid rgba(28, 125, 111, 0.22);
  border-radius: 8px;
  background: #eef5ef;
  padding: 14px 16px;
}

.option-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
  padding: 18px;
}

.option-card h3,
.option-card p {
  margin: 0;
}

.option-card p {
  color: var(--muted);
  line-height: 1.5;
}

.option-card.factor-complete {
  border-color: rgba(28, 125, 111, 0.36);
  background: #f0f6f0;
}

.factor-state {
  min-height: 1.2rem;
  color: #315d51;
  font-weight: 700;
}

.factor-actions {
  align-items: stretch;
}

.pairing-code {
  display: block;
  border: 1px solid rgba(28, 125, 111, 0.24);
  border-radius: 8px;
  background: #f3f6f2;
  color: #243b35;
  padding: 18px;
  font-size: clamp(1.15rem, 3vw, 1.6rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  overflow-wrap: anywhere;
}

.next-steps,
.success-panel {
  display: grid;
  gap: 14px;
  margin: 24px;
  padding: 20px;
  border: 1px solid rgba(28, 125, 111, 0.25);
  border-radius: 8px;
  background: #f0f6f0;
}

.next-steps h2,
.next-steps ol,
.success-panel h2,
.success-panel p {
  margin: 0;
}

.next-steps a {
  width: max-content;
}

.hub-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.hub-link {
  display: grid;
  gap: 8px;
  min-height: 130px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
  padding: 18px;
  color: var(--ink);
  text-decoration: none;
}

.hub-link strong {
  font-size: 1.04rem;
}

.hub-link span {
  color: var(--muted);
  line-height: 1.45;
}

@media (max-width: 860px) {
  .accounts-shell,
  .signup {
    min-height: auto;
    grid-template-columns: 1fr;
    gap: 22px;
    padding: 24px 0;
  }

  .context {
    align-self: auto;
    gap: 22px;
    padding: 0;
  }

  h1 {
    max-width: 11ch;
    margin-top: 20px;
    font-size: clamp(2.25rem, 11vw, 3.4rem);
    line-height: 1;
  }

  .intro {
    font-size: 1rem;
    line-height: 1.55;
  }

  .assurance {
    max-width: none;
  }

  .assurance li {
    line-height: 1.38;
  }
}

@media (max-width: 620px) {
  .hub-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .accounts-shell,
  .signup {
    width: min(100% - 20px, 1120px);
  }

  .card-heading,
  form,
  .card-body,
  #status,
  #prereq {
    padding-left: 16px;
    padding-right: 16px;
  }

  .card-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .next-steps,
  .success-panel,
  .surface-card > .session-row,
  .surface-card > .field:not(form),
  .surface-card > .option-card {
    margin: 16px;
  }

  .brand {
    font-size: 0.78rem;
  }
}

/* --------------------------------------------------------------------------
   Field-level validation errors.

   The server returns the offending field name alongside the message, so a
   rejection is shown against the control that caused it. Colour alone is not
   the signal — the message text and `aria-invalid` carry it for anyone who
   cannot distinguish the border.
   -------------------------------------------------------------------------- */

.field-error {
  display: block;
  margin: -0.35rem 0 0.15rem;
  color: var(--danger-ink, #8c2f1d);
  font-weight: 600;
}

.field-error[hidden] {
  display: none;
}

.accounts-shell [aria-invalid="true"] {
  border-color: var(--danger, #b4472f);
  box-shadow: 0 0 0 3px rgba(180, 71, 47, 0.16);
}

.accounts-shell [aria-invalid="true"]:focus {
  outline-color: var(--danger, #b4472f);
}

/* --------------------------------------------------------------------------
   A URL rendered for reading and copying, not for transcription.

   `.pairing-code` exists for short one-time codes that get read aloud, so it is
   deliberately oversized. A signup URL in that treatment fills the panel and is
   harder to scan, not easier — it wraps at a normal reading size instead.
   -------------------------------------------------------------------------- */

.link-box {
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------------------------
   Invite result summary, delivery status, and the send composer.
   -------------------------------------------------------------------------- */

.invite-summary {
  display: grid;
  grid-template-columns: minmax(7rem, auto) 1fr;
  gap: 6px 16px;
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}

.invite-summary dt {
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.invite-summary dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.delivery-status {
  margin: 8px 0 0;
  color: var(--muted);
}

/*
 * A refused send must not look like "Not sent yet." Both rendered in the same
 * muted grey, so the one state that needs the operator to do something was the
 * least visible text on the page. `pre-line` keeps the remedy on its own line.
 */
.delivery-status.failed {
  border: 1px solid rgba(160, 44, 44, 0.35);
  border-radius: 8px;
  background: #fdf1f1;
  color: #7a1f1f;
  padding: 12px 14px;
  white-space: pre-line;
}

#composer {
  max-width: min(38rem, 92vw);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px 24px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
}

#composer::backdrop {
  background: rgba(20, 33, 31, 0.45);
}

#composer textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  padding: 10px 12px;
  font: inherit;
  resize: vertical;
}

#composer menu {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin: 18px 0 0;
  padding: 0;
}

/* --------------------------------------------------------------------------
   Free-entry field revealed when "Add a new one…" is selected.
   -------------------------------------------------------------------------- */

.custom-target[hidden] {
  display: none;
}

.custom-target {
  margin-top: -6px;
  border-color: var(--accent);
}

#confirm-new-target {
  max-width: min(34rem, 92vw);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px 24px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
}

#confirm-new-target::backdrop {
  background: rgba(20, 33, 31, 0.45);
}

#confirm-new-target #confirm-new-message {
  white-space: pre-line;
}

#confirm-new-target menu {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin: 18px 0 0;
  padding: 0;
}

/* --------------------------------------------------------------------------
   Cross-page navigation and the flow overview on the hub.
   -------------------------------------------------------------------------- */

.page-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 10px 0 0;
  font-size: 0.9rem;
}

.page-nav a {
  color: var(--focus);
}

.flow-list {
  margin: 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 22px;
}

.flow-list > li > strong {
  display: block;
  font-size: 1.05rem;
}

.flow-actor {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 2px 0 6px;
}

.hub-link.inline {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 8px;
}

.api-list {
  display: grid;
  grid-template-columns: minmax(12rem, auto) 1fr;
  gap: 8px 18px;
  margin: 0;
}

.api-list dt {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
}

.api-list dd {
  margin: 0;
  color: var(--muted);
}

@media (max-width: 40rem) {
  .api-list {
    grid-template-columns: 1fr;
  }
  .api-list dd {
    margin: 0 0 10px;
  }
}

/* --------------------------------------------------------------------------
   Mode toggle: new invite vs restart an existing account.

   Fields that do not apply are disabled rather than hidden, so the form does
   not reflow under the cursor and it stays visible what the other mode asks
   for.
   -------------------------------------------------------------------------- */

.mode-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  padding: 0;
  border: 0;
  background: none;
  font-size: 0.95rem;
}

.mode-toggle input {
  margin: 0;
  flex: none;
}

.mode-toggle strong {
  font-weight: 600;
}

.target-note {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.88rem;
}

.field-muted {
  opacity: 0.45;
}

.accounts-shell :disabled {
  cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   Fields that only apply when creating a new invite.

   `disabled` on the fieldset is what actually switches them off — this only
   makes that visible. Greying the fieldset covers its labels too, which the
   previous per-control approach could not: the labels are siblings of their
   inputs, not parents.
   -------------------------------------------------------------------------- */

.new-account-fields {
  border: 0;
  padding: 0;
  margin: 0;
  min-inline-size: 0;
  /* The form is a grid (`.field`); a fieldset is one grid item, so its
     children lose that spacing unless it declares the same layout. */
  display: grid;
  gap: 7px;
}

.new-account-fields.is-off {
  opacity: 0.45;
}

.new-account-fields.is-off * {
  cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   Enrollment/account pages: session rows and authentication step-up panels.
   -------------------------------------------------------------------------- */

.session-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  /* Inset comes from the direct-card-children rule beside form/.card-body. */
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.session-row button {
  padding: 4px 12px;
  font-size: 0.85rem;
}

/* Enrolled-factor rows (dentist account page and admin security section):
   label on the left, Remove button in one consistent right-hand column —
   never hugging the text, and never at a different x per row. */
#factor-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

#factor-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
}

#mfa-challenge-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.auth-step-up {
  border: 1px solid rgba(28, 125, 111, 0.28);
  border-left: 6px solid var(--focus);
  border-radius: 8px;
  background: #f0f6f0;
  padding: 16px;
}

.auth-step-up .warning {
  margin: 0;
  line-height: 1.45;
}

.auth-step-up input {
  max-width: 18rem;
}

.auth-step-up > button,
.auth-step-up .otp-entry button {
  width: max-content;
}

/* --------------------------------------------------------------------------
   Authenticator (TOTP) setup: two bounded steps.

   The panel used to be a flat 7px-gap stack — instructions, key, copy button,
   deep link, label, input and confirm all at equal weight, every control full
   width. Order matters here (add the key BEFORE the code exists), so the
   boundaries are drawn around the two actions, not around each control.
   -------------------------------------------------------------------------- */

.totp-steps {
  display: grid;
  gap: 12px;
  margin-top: 4px;
}

.setup-step {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  padding: 14px 16px;
}

.step-marker {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--sage);
  color: #315d51;
  font-size: 0.9rem;
  font-weight: 800;
}

.step-body {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.step-body h4 {
  margin: 0;
  font-size: 0.98rem;
}

.step-body h4 label {
  font-size: inherit;
}

.step-body p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.step-hint {
  font-size: 0.85rem;
}

.totp-qr-row {
  display: grid;
  grid-template-columns: minmax(128px, 168px) minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.totp-qr {
  display: grid;
  place-items: center;
  width: 168px;
  max-width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.totp-qr:empty {
  display: none;
}

.totp-qr svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* The key and its copy button belong together; neither is a form action. */
.key-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.key-row .pairing-code {
  padding: 12px 14px;
  font-size: clamp(1rem, 2.2vw, 1.2rem);
  letter-spacing: 0.06em;
}

.key-row button {
  white-space: nowrap;
}

/* A 6-digit code is 6 digits: a compact monospace box beside its confirm
   button, not a full-width text field above a full-width button. */
.otp-entry {
  display: grid;
  grid-template-columns: minmax(0, 11ch) auto;
  gap: 10px;
  align-items: center;
}

.otp-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.3em;
  text-align: center;
  padding-left: calc(12px + 0.3em);
}

.otp-input::placeholder {
  color: #c2ccc4;
  font-weight: 400;
}

@media (max-width: 520px) {
  .field-grid {
    grid-template-columns: 1fr;
  }

  .key-row {
    grid-template-columns: 1fr;
  }

  .totp-qr-row {
    grid-template-columns: 1fr;
  }

  .setup-step {
    grid-template-columns: 24px 1fr;
    padding: 12px;
  }
}

/* Pending CLI approval details (daudit_link.html): what is being authorized. */
.approval-details {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.35rem 1rem;
  margin: 0.75rem 0;
}

.approval-details dt {
  font-weight: 600;
  color: var(--muted, #555);
}

.approval-details dd {
  margin: 0;
  overflow-wrap: anywhere;
}

#cli-delegation-details ul {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}
