:root {
  --bg-page:        #f3f4f6;
  --bg-card:        #ffffff;
  --bg-surface:     #f9fafb;
  --border:         #e5e7eb;
  --border-focus:   #1c64f2;
  --text-primary:   #111827;
  --text-secondary: #374151;
  --text-muted:     #6b7280;
  --text-placeholder: #9ca3af;
  --accent:         #1c64f2;
  --accent-hover:   #1a56db;
  --accent-light:   #eff6ff;
  --accent-text:    #1d4ed8;
  --error-bg:       #fef2f2;
  --error-border:   #fecaca;
  --error-text:     #dc2626;
  --success:        #16a34a;
  --success-light:  #f0fdf4;
  --success-border: #bbf7d0;
  --danger:         #dc2626;
  --danger-border:  #fecaca;
}

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

html, body { height: 100%; overflow: hidden; }

body {
  background: var(--bg-page);
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  display: flex;
  flex-direction: column;
}

/* ── Nav ── */
.topnav {
  background: #fff;
  border-bottom: 1px solid var(--border);
  height: 68px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
}
.nav-logo { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.nav-logo-img { height: 36px; width: auto; display: block; }
.nav-spacer { flex: 1; }
.nav-link { font-size: 14px; color: var(--text-muted); text-decoration: none; font-weight: 500; transition: color 0.15s; }
.nav-link:hover { color: var(--text-primary); }
.nav-btn {
  font-size: 13.5px; font-weight: 600; color: #fff; background: var(--accent);
  border: none; border-radius: 6px; padding: 7px 14px; cursor: pointer;
  display: flex; align-items: center; gap: 4px; transition: background 0.15s; text-decoration: none;
}
.nav-btn:hover { background: var(--accent-hover); }

/* ── Layout ── */
.page-body {
  flex: 1; min-height: 0; display: flex; align-items: flex-start; justify-content: center;
  padding: 36px 24px 20px; overflow-y: auto;
}
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  padding: 28px 32px; width: 100%; max-width: 440px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
}
.card--wide { max-width: 480px; padding: 32px; text-align: center; }
.card--auth { max-width: 720px; }

/* ── Typography ── */
h1 { font-size: 22px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.3px; margin-bottom: 8px; }
.subtitle { font-size: 14px; color: var(--text-muted); margin-bottom: 18px; line-height: 1.55; }

/* ── Steps ── */
.steps { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; margin-bottom: 18px; }
.steps-title { font-size: 11.5px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }
.step { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 6px; font-size: 13.5px; color: var(--text-secondary); line-height: 1.5; }
.step:last-child { margin-bottom: 0; }
.step-num {
  min-width: 18px; height: 18px; background: #fff; border: 1px solid var(--border);
  border-radius: 50%; font-size: 10px; font-weight: 700; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center; margin-top: 0.5px; flex-shrink: 0;
}
.step strong { color: var(--text-primary); font-weight: 600; }

/* Credential pages centre their heading block over the two-column form. */
.card--auth h1,
.card--auth .subtitle { text-align: center; }

/* ── Error box ── */
.error-box {
  background: var(--error-bg); border: 1px solid var(--error-border); border-radius: 7px;
  padding: 10px 14px; font-size: 13px; color: var(--error-text);
  margin-bottom: 16px; display: flex; align-items: flex-start; gap: 8px;
}
.error-box.hidden { display: none; }

/* ── Form ── */
.field { margin-bottom: 14px; }
label { display: block; font-size: 13.5px; font-weight: 600; color: var(--text-secondary); margin-bottom: 5px; }
input, select {
  width: 100%; background: #fff; border: 1px solid #d1d5db; border-radius: 7px;
  padding: 9px 13px; font-size: 14px; color: var(--text-primary);
  font-family: inherit; outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder { color: var(--text-placeholder); }
input:focus, select:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(28,100,242,0.12); }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; cursor: pointer;
}
.password-wrap { position: relative; }
.password-wrap input { padding-right: 42px; }
.toggle-eye {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--text-placeholder);
  padding: 0; line-height: 1; transition: color 0.15s;
}
.toggle-eye:hover { color: var(--text-muted); }

/* ── Button ── */
.btn {
  width: 100%; padding: 11px 16px; background: var(--accent); border: none; border-radius: 7px;
  color: #fff; font-size: 15px; font-weight: 600; font-family: inherit; cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s; margin-top: 6px;
}
.btn:hover    { background: var(--accent-hover); box-shadow: 0 2px 8px rgba(28,100,242,0.25); }
.btn:active   { transform: scale(0.99); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }
.btn-inner { display: flex; align-items: center; justify-content: center; gap: 8px; }
.spinner {
  width: 15px; height: 15px; border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff; border-radius: 50%; animation: spin 0.6s linear infinite; display: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Misc ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.footer-note { font-size: 12.5px; color: var(--text-placeholder); text-align: center; line-height: 1.6; }
.footer-note a { color: var(--accent); text-decoration: none; font-weight: 500; }
.footer-note a:hover { text-decoration: underline; }

/* ── Credential columns (CDS + CMS side by side, stacks on narrow viewports) ── */
.cred-columns {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px; margin-top: 16px;
}

/* ── Credential group (one per service: CDS, CMS) ── */
.cred-group {
  border: 1px solid var(--border); border-radius: 8px; padding: 14px;
  background: var(--bg-surface);
}
.cred-group-header { display: flex; flex-wrap: nowrap; align-items: center; gap: 7px; margin-bottom: 10px; }
.cred-group-title {
  font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-secondary); white-space: nowrap;
}
.cred-help-btn {
  width: 17px; height: 17px; flex-shrink: 0; border-radius: 50%;
  border: 1px solid var(--border); background: #fff; color: var(--text-muted);
  font-family: inherit; font-size: 11px; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.cred-help-btn:hover,
.cred-help-btn[aria-expanded="true"] {
  color: var(--accent); border-color: var(--accent); background: var(--accent-light);
}

/* Tooltip sitting directly above its "!", toggled by credential-help.js. */
.cred-help { position: relative; display: flex; }
.cred-help-tip {
  position: absolute; bottom: calc(100% + 9px); left: 50%; transform: translateX(-50%);
  width: 230px; max-width: calc(100vw - 32px); z-index: 30;
  background: var(--text-primary); color: #fff; border-radius: 8px; padding: 9px 11px;
  font-size: 12.5px; font-weight: 400; line-height: 1.45;
  letter-spacing: 0; text-transform: none;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
}
.cred-help-tip strong { font-weight: 700; }
.cred-help-tip::after {
  content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: var(--text-primary);
}

/* Help rail: both service cards, permanently parked at the right edge. Fixed,
   so the centred form keeps the full width it had without them. */
.help-rail {
  position: fixed; right: 24px; top: 50%; transform: translateY(-50%);
  width: 300px; display: flex; flex-direction: column; gap: 14px; z-index: 10;
}
.help-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
}
.help-card-title {
  font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-secondary); margin-bottom: 10px;
}
.help-card .steps { margin-bottom: 0; }
.help-note { font-size: 13.5px; color: var(--text-secondary); line-height: 1.55; }
.help-note strong { color: var(--text-primary); font-weight: 600; }
.cred-group .field:last-child { margin-bottom: 0; }

/* ── Responsive (phones / narrow viewports) ── */
@media (max-width: 1080px) {
  .page-body { flex-wrap: wrap; }
  .help-rail {
    position: static; transform: none; width: 100%; max-width: 720px;
    margin-top: 16px;
  }
}

@media (max-width: 600px) {
  .topnav { padding: 0 16px; gap: 12px; height: 60px; }
  .nav-logo-img { height: 28px; }
  .nav-btn { padding: 6px 12px; font-size: 13px; }
  .page-body { padding: 16px 12px; }
  .card, .card--wide, .card--auth { padding: 18px 16px; }
  h1 { font-size: 19px; }
  .subtitle { font-size: 13px; }
  .cred-columns { grid-template-columns: 1fr; }
}

/* Footer carrying the privacy / docs / support links. These have to be reachable
   from the pages a user actually sees — the connector directory checks for them. */
.page-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  align-items: center;
  padding: 1.25rem 1rem;
  font-size: 0.8125rem;
  color: #6b7280;
  background: #fff;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.page-footer a {
  color: #6b7280;
  text-decoration: none;
}

.page-footer a:hover,
.page-footer a:focus-visible {
  color: #111827;
  text-decoration: underline;
}
