/* Brain Cloud — authorization pages (setup, login, consent, logout).
   Neutral palette, one accent, system fonts, no external assets, no inline styles (CSP). */

:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f8f9fa;
  --border: #d8dce2;
  --text: #1b1f24;
  --muted: #5a636e;
  --accent: #2d6a64;
  --accent-hover: #24554f;
  --accent-text: #ffffff;
  --accent-soft: #e6f0ef;
  --danger-bg: #fcecec;
  --danger-border: #eab4b4;
  --danger-text: #8b1d1d;
  --warn-bg: #fdf5e4;
  --warn-border: #ead29c;
  --warn-text: #6b4a07;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(16 24 32 / 6%), 0 8px 24px rgb(16 24 32 / 6%);
  color-scheme: light dark;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --surface: #181c21;
    --surface-2: #1e2329;
    --border: #2e353d;
    --text: #e6e9ed;
    --muted: #9aa4af;
    --accent: #5fb3a9;
    --accent-hover: #7cc4bb;
    --accent-text: #0d1512;
    --accent-soft: #1d2b29;
    --danger-bg: #2a1718;
    --danger-border: #6b2e30;
    --danger-text: #f2b8b8;
    --warn-bg: #2a2314;
    --warn-border: #6a5423;
    --warn-text: #efd9a6;
    --shadow: none;
  }
}

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

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

a {
  color: var(--accent);
  text-underline-offset: 2px;
}

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

code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.875em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.05em 0.35em;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
}

.skip:focus {
  left: 16px;
  top: 16px;
  z-index: 10;
  background: var(--surface);
  padding: 8px 12px;
  border-radius: var(--radius);
}

.shell {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 4px 20px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--accent);
  box-shadow: inset 0 0 0 5px var(--accent-soft);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 18px;
}

h1 {
  font-size: 1.35rem;
  line-height: 1.3;
  margin: 0 0 8px;
}

.section-title {
  font-size: 0.95rem;
  text-transform: none;
  margin: 20px 0 8px;
}

.lead {
  margin: 0 0 18px;
  color: var(--muted);
}

.muted {
  color: var(--muted);
  font-size: 0.925rem;
}

.block {
  display: block;
}

.foot {
  margin: 16px 4px 0;
  color: var(--muted);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

/* forms */
.form {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

label {
  font-weight: 600;
  font-size: 0.925rem;
}

input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 44px;
}

input[readonly] {
  background: var(--surface-2);
  color: var(--muted);
}

input:focus-visible,
.btn:focus-visible,
a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.help {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: var(--accent-text);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-block {
  width: 100%;
}

.actions {
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  margin: 18px 0 0;
}

.actions-single {
  flex-direction: column;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 4px;
  color: var(--muted);
  font-size: 0.85rem;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border);
}

/* messages */
.alert {
  border-radius: 8px;
  padding: 10px 12px;
  margin: 0 0 16px;
  border: 1px solid;
  font-size: 0.95rem;
}

.alert-error {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-text);
}

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

.warn {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.9rem;
}

/* consent and help */
.facts {
  margin: 0;
  display: grid;
  gap: 10px;
}

.fact {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.fact dt {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 2px;
}

.fact dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.client-name {
  font-size: 1.05rem;
}

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  vertical-align: middle;
}

.scopes,
.plain {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.scopes li {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-left: 3px solid var(--accent);
  padding: 2px 0 2px 10px;
}

.scopes code,
.wrap {
  align-self: flex-start;
  overflow-wrap: anywhere;
}

.plain li {
  padding-left: 0;
}

/* TOTP enrollment */
.steps {
  margin: 0 0 16px;
  padding-left: 20px;
  color: var(--muted);
  font-size: 0.925rem;
}

.qr {
  margin: 0 0 18px;
  display: grid;
  gap: 10px;
  justify-items: center;
  text-align: center;
}

.qr-image {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  line-height: 0;
}

.qr-image svg {
  width: 200px;
  height: 200px;
}

.qr figcaption {
  display: grid;
  gap: 4px;
}

.secret {
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  overflow-wrap: anywhere;
  user-select: all;
}

@media (min-width: 560px) {
  .shell {
    padding-top: 56px;
  }

  .card {
    padding: 28px 28px;
  }

  .actions {
    flex-direction: row;
    justify-content: flex-end;
  }

  .actions-single {
    flex-direction: column;
  }
}

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