/* Design tokens */
:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --surface-3: #475569;
  --border: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-subtle: #cbd5e1;
  --text-heading: #f8fafc;
  --blue: #3b82f6;
  --blue-dark: #2563eb;
  --blue-dim: #1e40af;
  --red-bg: #451a1a;
  --red-border: #dc2626;
  --red-text: #fca5a5;
  --green: #22c55e;
  --green-light: #86efac;
}

/* Reset */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* Base */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--blue); text-decoration: none; }

/* ── Auth layout (card-centered) ── */
body.auth-layout {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.card {
  background: var(--surface);
  border-radius: 12px;
  padding: 2.5rem;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.25);
}

.card.card-wide { max-width: 640px; }
.card.card-center { text-align: center; }
.card.card-narrow { max-width: 480px; }

/* ── Account layout (page-width) ── */
body.account-layout {
  padding: 2rem;
}

.page {
  max-width: 900px;
  margin: 0 auto;
}

/* ── Typography ── */
.brand {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
}

h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text-heading);
}

.subtitle { color: var(--text-muted); margin-bottom: 1.5rem; font-size: 0.875rem; }
.lede { color: var(--text-subtle); margin-bottom: 1.5rem; font-size: 0.9375rem; line-height: 1.5; }
.muted { color: var(--text-muted); font-size: 0.875rem; line-height: 1.5; }
.link { text-align: center; margin-top: 1.5rem; font-size: 0.875rem; color: var(--text-muted); }
.small-explainer { color: var(--text-muted); font-size: 0.8125rem; margin-bottom: 1.5rem; }

/* ── Forms ── */
label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
  color: var(--text-subtle);
}

input[type="email"],
input[type="text"] {
  width: 100%;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-heading);
  font-size: 1rem;
  margin-bottom: 1.25rem;
}

input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

input.input-otp {
  font-size: 1.5rem;
  letter-spacing: 0.5em;
  text-align: center;
}

button {
  width: 100%;
  padding: 0.75rem;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

button:hover { background: var(--blue-dark); }
button:disabled { background: var(--surface-3); cursor: progress; }

.error-message {
  background: var(--red-bg);
  border: 1px solid var(--red-border);
  color: var(--red-text);
  padding: 0.75rem;
  border-radius: 8px;
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
}

/* ── Login page ── */
.btn-passkey {
  background: var(--bg);
  color: var(--text-heading);
  border: 1px solid var(--border);
  margin-bottom: 1rem;
}

.btn-passkey:hover {
  background: var(--surface);
  border-color: var(--blue);
}

.btn-google {
  display: block;
  width: 100%;
  padding: 0.625rem 1rem;
  background: var(--bg);
  color: var(--text-heading);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  font-size: 0.9375rem;
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  margin-bottom: 1rem;
  box-sizing: border-box;
}

.btn-google:hover {
  background: var(--surface);
  border-color: var(--blue);
}

.or-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: #64748b;
  font-size: 0.75rem;
  margin: 1rem 0;
}

.or-divider::before,
.or-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border);
}

.or-divider::before { margin-right: 0.75rem; }
.or-divider::after { margin-left: 0.75rem; }

#passkey-error:empty { display: none; }

#passkey-error {
  background: var(--red-bg);
  border: 1px solid var(--red-border);
  color: var(--red-text);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
}

/* ── Consent page ── */
.app-name { color: var(--blue); font-weight: 600; }

.consent-list { list-style: none; margin-bottom: 2rem; }
.consent-list li { padding: 0.625rem 0; border-bottom: 1px solid var(--border); font-size: 0.875rem; }

.button-row { display: flex; gap: 0.75rem; }
.button-row button { flex: 1; }

button.allow { background: var(--blue); color: white; }
button.allow:hover { background: var(--blue-dark); }
button.deny { background: var(--surface-2); color: var(--text-muted); }
button.deny:hover { background: var(--surface-3); }

/* ── Passkeys page (table) ── */
.passkey-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
}

.passkey-table th {
  text-align: left;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
}

.passkey-table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--surface);
  font-size: 0.875rem;
}

.passkey-table tr:hover { background: var(--bg); }

#register-status { margin-top: 1rem; font-size: 0.875rem; }
.success { color: var(--green-light); }
.error { color: var(--red-text); }

/* ── Passkey interstitial ── */
.reasons {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.reasons li { margin-left: 1.25rem; }

.actions { display: flex; flex-direction: column; gap: 0.75rem; }

.btn {
  display: block;
  width: 100%;
  padding: 0.75rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  border: none;
}

.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-secondary { background: transparent; color: var(--text-subtle); border: 1px solid var(--surface-3); }
.btn-secondary:hover { border-color: var(--text-muted); }
.btn-tertiary { background: transparent; color: var(--text-muted); font-weight: 400; font-size: 0.875rem; }
.btn-tertiary:hover { color: var(--text-subtle); }

/* ── Passkey nudge banner ── */
.passkey-nudge {
  background: var(--blue-dim);
  border: 1px solid var(--blue);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.nudge-body { flex: 1; min-width: 240px; }
.nudge-title { font-weight: 600; color: var(--text-heading); margin-bottom: 0.25rem; }
.nudge-desc { color: var(--text-subtle); font-size: 0.875rem; }

.nudge-actions { display: flex; gap: 0.5rem; align-items: center; }

.btn-nudge-primary {
  background: var(--blue);
  color: white;
  padding: 0.5rem 0.875rem;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  display: inline-block;
}

.btn-nudge-dismiss {
  background: transparent;
  color: var(--text-subtle);
  border: 1px solid var(--surface-3);
  padding: 0.5rem 0.875rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  width: auto;
}

/* ── Account sessions table ── */
.sessions-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: 8px;
  overflow: hidden;
}

.sessions-table th,
.sessions-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.sessions-table th {
  background: var(--surface-2);
  font-weight: 600;
  color: var(--text-subtle);
}

.sessions-table tr:last-child td { border-bottom: none; }

.sessions-table .ua-cell {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.current-badge { color: var(--green); font-weight: 600; }

.info { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 1rem; }

.btn-revoke {
  background: var(--red-border);
  color: white;
  border: none;
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  width: auto;
}

/* ── Utility ── */
.form-inline { display: inline; }
.form-no-margin { margin: 0; }
.table-empty-msg { text-align: center; color: var(--text-muted); padding: 2rem; }

/* ── Account home ── */
.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.profile-email {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 0.25rem;
}

.profile-name {
  font-size: 0.9rem;
  color: var(--text-subtle);
  margin-bottom: 0.5rem;
}

.profile-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.account-nav {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  margin-bottom: 1.5rem;
}

.account-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-heading);
  font-size: 0.9375rem;
  transition: background 0.15s;
}

.account-nav-item:hover { background: var(--surface-2); }

.account-nav-icon { font-size: 1.1rem; flex-shrink: 0; }

.account-nav-count {
  margin-left: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.1rem 0.6rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.logout-link { margin-top: 0.75rem; }

/* ── Consent screen ── */
.redirect-hint {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  text-align: center;
}

/* ── Recovery hint ── */
.recovery-hint { margin-top: 0.75rem; font-size: 0.8125rem; }
