@font-face {
  font-family: Helvetica;
  src: url(../fonts/Helvetica.ttf);
}
@font-face {
  font-family: GoogleSans;
  src: url(../fonts/GoogleSans-Regular.ttf);
}

:root {
  --font-display: Helvetica, Georgia, "Times New Roman", serif;
  --font-body: GoogleSans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Light theme (default) */
  --canvas: #ffffff;
  --ink: #14231c;
  --muted: #5b6b62;
  --border: #dee7e1;
  --surface-input: #f6f9f7;
  --danger: #b8382c;
  --danger-tint: #fbeae7;

  --accent: #1f7a4d;
  --accent-strong: #17603b;
  --accent-tint: #e7f5ec;
  --accent-contrast: #ffffff;

  --panel-bg: #eff7f1;
  --panel-ink: #14231c;
  --panel-muted: #4f6b5a;
  --panel-line: #d8e8dc;

  --illus-stem-1: #2f6b47;
  --illus-stem-2: #3e8759;
  --illus-stem-3: #245c3e;
  --illus-leaf-1: #1f7a4d;
  --illus-leaf-2: #278a59;
  --illus-leaf-3: #2f6b47;
  --illus-leaf-4: #1b5c3c;
  --illus-baseline: #cfe3d6;

  --radius-sm: 8px;
  --radius-md: 12px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #0b1220;
    --ink: #e7edf7;
    --muted: #9aa9c2;
    --border: #29364d;
    --surface-input: #141f33;
    --danger: #ff7a6b;
    --danger-tint: #331e1b;

    --accent: #34b872;
    --accent-strong: #48cf87;
    --accent-tint: #123321;
    --accent-contrast: #06150d;

    --panel-bg: #14243c;
    --panel-ink: #f3fbf6;
    --panel-muted: #a8b8d2;
    --panel-line: #304462;

    --illus-stem-1: #5fae81;
    --illus-stem-2: #7fc49a;
    --illus-stem-3: #4c9873;
    --illus-leaf-1: #2c7a4f;
    --illus-leaf-2: #3e9a69;
    --illus-leaf-3: #5fae81;
    --illus-leaf-4: #245c3e;
    --illus-baseline: #304462;
  }
}
:root[data-theme="dark"] {
  --canvas: #0b1220;
  --ink: #e7edf7;
  --muted: #9aa9c2;
  --border: #29364d;
  --surface-input: #141f33;
  --danger: #ff7a6b;
  --danger-tint: #331e1b;

  --accent: #34b872;
  --accent-strong: #48cf87;
  --accent-tint: #123321;
  --accent-contrast: #06150d;

  --panel-bg: #14243c;
  --panel-ink: #f3fbf6;
  --panel-muted: #a8b8d2;
  --panel-line: #304462;

  --illus-stem-1: #5fae81;
  --illus-stem-2: #7fc49a;
  --illus-stem-3: #4c9873;
  --illus-leaf-1: #2c7a4f;
  --illus-leaf-2: #3e9a69;
  --illus-leaf-3: #5fae81;
  --illus-leaf-4: #245c3e;
  --illus-baseline: #304462;
}

/* ============ Reset ============ */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
  min-height: 100vh;
}
img {
  max-width: 100%;
  display: block;
}
button {
  font: inherit;
}
input {
  font: inherit;
  color: inherit;
}

a {
  color: var(--accent-strong);
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============ Layout shell ============ */
.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.brand-panel {
  background: var(--panel-bg);
  color: var(--panel-ink);
  padding: 1.5rem 1.5rem 1.75rem;
  border-bottom: 1px solid var(--panel-line);
  transition:
    background 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease;
}
.panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand-mark {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: 0.01em;
}
.brand-mark svg {
  width: 26px;
  height: 26px;
  flex: none;
}
.brand-copy {
  display: none;
}


.theme-toggle {
  appearance: none;
  border: 1px solid var(--panel-line);
  background: transparent;
  color: var(--panel-ink);
  width: 38px;
  height: 38px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
}
.theme-toggle:hover {
  background: rgba(127, 127, 127, 0.14);
}
.theme-toggle svg {
  width: 18px;
  height: 18px;
}
.theme-toggle .icon-sun {
  display: none;
}
.theme-toggle .icon-moon {
  display: block;
}
.theme-toggle.is-dark .icon-sun {
  display: block;
}
.theme-toggle.is-dark .icon-moon {
  display: none;
}

.form-panel {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 1.75rem 1.25rem 3rem;
}
.form-wrap {
  width: 100%;
  max-width: 26rem;
}

.auth-brandbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 2rem;
}
.auth-brandbar .theme-toggle {
  position: absolute;
  top: 0;
  right: 0;
}
.auth-brand {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}
.auth-brand img {
  width: 4rem;
  height: 3.5rem;
  object-fit: contain;
  flex: none;
  border-radius: 6px;
}
.auth-brand-copy {
  display: grid;
  gap: 0.05rem;
}
.auth-brand-copy strong {
  font-size: 0.95rem;
  line-height: 1.25;
}
.auth-brand-copy > span {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  line-height: 1.3;
  text-transform: uppercase;
}

.form-wrap .headline,
.form-wrap .subhead {
  text-align: center;
}
.form-wrap > .eyebrow-tabs {
  display: flex;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}
.eyebrow-tabs {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-input);
  border: 1px solid var(--border);
  border-radius: 999px;
  margin-bottom: 1.75rem;
}
.eyebrow-tabs button {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.92rem;
  transition:
    background 0.18s ease,
    color 0.18s ease;
}
.eyebrow-tabs button[aria-selected="true"] {
  background: var(--accent);
  color: var(--accent-contrast);
}

h1.headline {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.7rem, 4.5vw, 2.1rem);
  line-height: 1.15;
  margin: 0 0 0.4rem;
}
.subhead {
  color: var(--muted);
  margin: 0 0 1.75rem;
  font-size: 0.98rem;
}

.panel {
  display: none;
}
.panel.active {
  display: block;
  animation: rise 0.35s ease both;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.field {
  margin-bottom: 1.1rem;
}
.field label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}
.field-hint {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.35rem;
}
.input-row {
  position: relative;
  display: flex;
  align-items: center;
}
.field input {
  width: 100%;
  background: var(--surface-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
  font-size: 0.98rem;
  color: var(--ink);
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
}
.field input::placeholder {
  color: var(--muted);
  opacity: 0.85;
}
.field input:focus {
  border-color: var(--accent);
  background: var(--canvas);
  outline: none;
}
.field input[aria-invalid="true"] {
  border-color: var(--danger);
  background: var(--danger-tint);
}
.field.has-error .error-msg {
  display: block;
}
.error-msg {
  display: none;
  color: var(--danger);
  font-size: 0.82rem;
  margin-top: 0.4rem;
}

.toggle-visibility {
  position: absolute;
  right: 0.5rem;
  background: none;
  border: none;
  padding: 0.4rem;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  border-radius: 6px;
}
.toggle-visibility:hover {
  color: var(--ink);
}
.toggle-visibility svg {
  width: 19px;
  height: 19px;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: -0.2rem 0 1.4rem;
  font-size: 0.88rem;
}
.checkbox-line {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 1.4rem;
}
.checkbox-line input {
  margin-top: 0.2rem;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  flex: none;
}
.checkbox-line a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--border);
}

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition:
    background 0.15s ease,
    transform 0.08s ease;
}
.btn-primary:hover {
  background: var(--accent-strong);
}
.btn-primary:active {
  transform: translateY(1px);
}

.switch-line {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.switch-line button {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent-strong);
  font-weight: 600;
  cursor: pointer;
  font-size: inherit;
  text-decoration: underline;
  text-decoration-color: var(--border);
}

.success-state {
  display: none;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--accent-tint);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}
.success-state.active {
  display: block;
  animation: rise 0.35s ease both;
}
.success-state svg {
  width: 30px;
  height: 30px;
  color: var(--accent-strong);
  margin-bottom: 0.7rem;
}
.success-state h2 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 500;
  margin: 0 0 0.35rem;
}
.success-state p {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
}
.success-state button {
  margin-top: 1.1rem;
  background: none;
  border: 1px solid var(--border);
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.88rem;
}

.growth-graphic {
  display: none;
}

/* Illustration colors follow theme tokens */
#growthSvg #stemPath {
  stroke: var(--illus-stem-1);
}
#growthSvg #stemPath2 {
  stroke: var(--illus-stem-2);
}
#growthSvg #stemPath3 {
  stroke: var(--illus-stem-3);
}
#growthSvg #leafPath1 {
  fill: var(--illus-leaf-1);
}
#growthSvg #leafPath2 {
  fill: var(--illus-leaf-2);
}
#growthSvg #leafPath3 {
  fill: var(--illus-leaf-3);
}
#growthSvg #leafPath4 {
  fill: var(--illus-leaf-4);
}
#growthSvg .baseline {
  stroke: var(--illus-baseline);
}

/* ============ Desktop split layout ============ */
@media (min-width: 960px) {
  .shell {
    flex-direction: row;
  }

  .brand-panel {
    width: 42%;
    max-width: 30rem;
    padding: 3rem 3.25rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
    border-bottom: none;
    border-right: 1px solid var(--panel-line);
  }
  .brand-copy {
    display: block;
    max-width: 24rem;
  }
  .brand-copy h2 {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 2.1rem;
    line-height: 1.2;
    margin: 2.5rem 0 0.9rem;
  }
  .brand-copy p {
    color: var(--panel-muted);
    font-size: 1.02rem;
    max-width: 22rem;
  }
  .growth-graphic {
    display: block;
    margin-top: auto;
    padding-top: 2rem;
  }
  .growth-graphic svg {
    width: 100%;
    height: auto;
    max-width: 15rem;
  }

  .form-panel {
    align-items: center;
    padding: 3rem 4rem;
  }
  .form-wrap {
    max-width: 24rem;
  }
}

@media (min-width: 960px) and (min-height: 760px) {
  .brand-panel {
    padding: 4rem 3.5rem;
  }
}


/* =====================================================================
   ADDITIONS — backend-connected pages (2FA, reset, dashboard, etc.)
   Everything above this line is the original stylesheet, unchanged.
   ===================================================================== */

[hidden] {
  display: none !important;
}
.error-msg.is-visible {
  display: block;
}

/* ---- Form-level alert (server errors) ---- */
.form-alert {
  border: 1px solid var(--danger);
  background: var(--danger-tint);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
  font-size: 0.9rem;
  margin-bottom: 1.1rem;
}
.form-alert.is-success {
  border-color: var(--accent);
  background: var(--accent-tint);
  color: var(--accent-strong);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.btn-primary.auto {
  width: auto;
  padding-inline: 1.4rem;
}

.back-link {
  display: inline-block;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  color: var(--muted);
  text-decoration: none;
}
.back-link:hover {
  color: var(--ink);
  text-decoration: underline;
}

/* ---- One-time code input ---- */
.field input.otp-input {
  text-align: center;
  font-size: 1.5rem;
  letter-spacing: 0.35em;
  font-variant-numeric: tabular-nums;
  padding-block: 0.85rem;
}
.field input.otp-input.is-backup {
  font-size: 1.15rem;
  letter-spacing: 0.12em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---- Status panels (success / error) ---- */
.success-state .button-link,
.btn-secondary {
  display: inline-block;
  margin-top: 1.1rem;
  background: none;
  border: 1px solid var(--border);
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: none;
}
.btn-secondary {
  margin-top: 0;
}
.btn-secondary:hover,
.success-state .button-link:hover {
  background: var(--surface-input);
}
.btn-danger {
  color: var(--danger);
  border-color: var(--danger);
}
.success-state.is-error {
  background: var(--danger-tint);
  border-color: var(--danger);
}
.success-state.is-error svg {
  color: var(--danger);
}

/* ---- Signed-in app layout ---- */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.85rem 1.25rem;
  padding-top: calc(0.85rem + env(safe-area-inset-top, 0px));
  background: var(--panel-bg);
  color: var(--panel-ink);
  border-bottom: 1px solid var(--panel-line);
}
.topbar .brand-mark {
  color: inherit;
  text-decoration: none;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.topnav {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}
.topnav a,
.topnav button {
  appearance: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--panel-muted);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  text-decoration: none;
}
.topnav a:hover,
.topnav button:hover {
  color: var(--panel-ink);
  background: rgba(127, 127, 127, 0.14);
}
.topnav a[aria-current="page"] {
  background: var(--accent-tint);
  color: var(--accent-strong);
}

.page {
  width: 100%;
  max-width: 40rem;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.4rem;
  margin-bottom: 1.25rem;
  background: var(--canvas);
}
.card h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.25rem;
  margin: 0 0 0.3rem;
}
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
}
.card-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}
.badge {
  flex: none;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.badge.on {
  background: var(--accent-tint);
  color: var(--accent-strong);
  border-color: var(--accent);
}
.badge.off {
  background: var(--surface-input);
  color: var(--muted);
}
.notice {
  border: 1px solid var(--accent);
  background: var(--accent-tint);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  font-size: 0.92rem;
  margin-bottom: 1.25rem;
}
.notice.warn {
  border-color: var(--danger);
  background: var(--danger-tint);
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

/* ---- 2FA setup ---- */
.steps {
  padding-left: 1.2rem;
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.93rem;
}
.steps li {
  margin-bottom: 0.35rem;
}
.qr-box {
  display: flex;
  justify-content: center;
  margin: 1rem 0;
}
.qr-box img {
  width: 12rem;
  height: 12rem;
  background: #fff; /* QR codes need a light background in dark mode too */
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.manual-key {
  margin-bottom: 1.4rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.manual-key summary {
  cursor: pointer;
}
.manual-key .key-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
}
.manual-key code,
.code-grid code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--surface-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.6rem;
  color: var(--ink);
  word-break: break-all;
}
.code-grid {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}
.code-grid code {
  display: block;
  text-align: center;
  font-size: 0.98rem;
  letter-spacing: 0.04em;
}
.check-line {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  font-size: 0.9rem;
  margin: 1.1rem 0;
}
.check-line input {
  margin-top: 0.2rem;
  accent-color: var(--accent);
}

/* ---- Legal pages ---- */
.legal {
  max-width: 44rem;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

@media (max-width: 420px) {
  .code-grid {
    grid-template-columns: 1fr;
  }
}

/* ---- "Admin sign in" link on the login page ---- */
.admin-link {
  text-align: center;
  margin: 2.2rem 0 0;
  font-size: 0.75rem;
}
.admin-link a {
  color: var(--muted);
  text-decoration: none;
}
.admin-link a:hover {
  color: var(--ink);
  text-decoration: underline;
}
