/*
 * Reckon Suite portal — login, signup, verification and password reset.
 *
 * The design is ported from the Reckon Bill prototype's AuthCard, but written
 * as plain CSS against the same semantic tokens rather than Tailwind: this
 * service has no bundler, and adding one to ship four static forms would buy
 * nothing. The token VALUES are copied verbatim from the prototype's
 * globals.css so the portal and the product apps stay visually identical —
 * when those change, change them here too.
 *
 * Dark is the default (:root); [data-theme="light"] overrides only what
 * differs, exactly as the prototype does.
 */

:root {
  --accent: #3b69a9;
  --accent-strong: #4c7bc7;
  --canvas: #121212;
  --surface: #1e1e1e;
  --border: #27272a;
  --body: #f4f4f5;
  --muted: #a1a1aa;
  --overlay: 255, 255, 255;
  --primary: var(--accent);
  --primary-fg: #ffffff;
  --danger: #ef4444;
  color-scheme: dark;
}

[data-theme="light"] {
  --accent: #1a3865;
  --accent-strong: #142c50;
  --canvas: #ffffff;
  --surface: #ffffff;
  --border: #e2e8f0;
  --body: #0f172a;
  --muted: #64748b;
  --overlay: 15, 23, 42;
  --danger: #ef4444;
  color-scheme: light;
}

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  background: var(--canvas);
  color: var(--body);
  font-family: "General Sans", ui-sans-serif, system-ui, -apple-system,
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.shell {
  width: 100%;
  max-width: 28rem;
}

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 2rem;
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.25), 0 8px 10px -6px rgb(0 0 0 / 0.25);
}

/* ── Header ─────────────────────────────────────────────────────────────── */

.card-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.mark {
  display: flex;
  height: 3rem;
  width: 3rem;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: rgb(var(--overlay) / 0.05);
  color: var(--body);
}

.mark svg {
  height: 1.75rem;
  width: 1.75rem;
}

h1 {
  margin: 1rem 0 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--body);
}

.sub {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  color: var(--muted);
}

/* ── Theme toggle ───────────────────────────────────────────────────────── */

.theme-toggle {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  height: 1.75rem;
  width: 1.75rem;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0.375rem;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.theme-toggle:hover {
  background: rgb(var(--overlay) / 0.1);
  color: var(--body);
}

.theme-toggle svg {
  height: 1rem;
  width: 1rem;
}

/* Each icon shows only in the theme it switches AWAY from. */
.icon-sun {
  display: none;
}

[data-theme="light"] .icon-sun {
  display: block;
}

[data-theme="light"] .icon-moon {
  display: none;
}

/* ── Form ───────────────────────────────────────────────────────────────── */

form {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}

input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--canvas);
  padding: 0.625rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  color: var(--body);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input::placeholder {
  color: rgb(var(--overlay) / 0.4);
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgb(59 105 169 / 0.3);
}

/* One-time codes read as digits, not prose. */
input.code {
  text-align: center;
  letter-spacing: 0.4em;
  font-size: 1.125rem;
  font-variant-numeric: tabular-nums;
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 2.5rem;
}

.reveal {
  position: absolute;
  top: 50%;
  right: 0.5rem;
  transform: translateY(-50%);
  display: flex;
  height: 1.75rem;
  width: 1.75rem;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0.375rem;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.reveal:hover {
  background: rgb(var(--overlay) / 0.1);
  color: var(--body);
}

.reveal svg {
  height: 1rem;
  width: 1rem;
}

button[type="submit"] {
  margin-top: 0.5rem;
  width: 100%;
  border: 0;
  border-radius: 0.5rem;
  background: var(--primary);
  padding: 0.625rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary-fg);
  cursor: pointer;
  transition: opacity 0.15s;
}

button[type="submit"]:hover:not(:disabled) {
  opacity: 0.9;
}

button[type="submit"]:disabled {
  opacity: 0.6;
  cursor: default;
}

/* ── Links and footers ──────────────────────────────────────────────────── */

a {
  color: var(--accent);
  font-weight: 500;
  text-decoration: none;
  transition: opacity 0.15s;
}

a:hover {
  opacity: 0.8;
}

.alt {
  margin: 1.5rem 0 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
}

.footnote {
  margin: 1.5rem 0 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
}

/* ── Alerts ─────────────────────────────────────────────────────────────── */

.alert {
  margin-top: 1.25rem;
  border-radius: 0.5rem;
  padding: 0.625rem 0.75rem;
  font-size: 0.8125rem;
}

.alert-error {
  border: 1px solid rgb(239 68 68 / 0.3);
  background: rgb(239 68 68 / 0.1);
  color: var(--danger);
}

.alert-info {
  border: 1px solid var(--border);
  background: rgb(var(--overlay) / 0.05);
  color: var(--muted);
}

/* Screen-reader-only: announces async errors without showing a duplicate. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
 * The account page — launcher + settings. Ported from the prototype's hub.
 * ═══════════════════════════════════════════════════════════════════════════ */

body[data-page="account"] {
  display: block;
  padding: 0;
}

.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.topbar-inner,
main.wide {
  max-width: 64rem;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 3.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--body);
  font-size: 0.875rem;
  font-weight: 600;
}

.brand:hover {
  opacity: 1;
}

.brand-mark svg {
  display: block;
  height: 1.75rem;
  width: 1.75rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* The toggle is absolutely positioned inside the card; in the bar it flows. */
.topbar .theme-toggle {
  position: static;
}

.who {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 9999px;
  background: rgb(var(--overlay) / 0.05);
  padding: 0.25rem 0.75rem 0.25rem 0.25rem;
}

.avatar {
  display: flex;
  height: 1.5rem;
  width: 1.5rem;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  background: rgb(var(--overlay) / 0.1);
  font-size: 10px;
  font-weight: 500;
  color: var(--body);
}

.who-name {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--body);
}

.icon-btn {
  display: flex;
  height: 1.75rem;
  width: 1.75rem;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0.375rem;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.icon-btn:hover {
  background: rgb(var(--overlay) / 0.1);
  color: var(--body);
}

.icon-btn svg {
  height: 1rem;
  width: 1rem;
}

main.wide {
  padding-top: 2.5rem;
  padding-bottom: 4rem;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

main.wide h1 {
  margin: 0;
  font-size: 1.125rem;
}

main.wide h2 {
  margin: 0 0 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--body);
}

.hero .sub {
  margin-top: 0.25rem;
}

/* ── App cards ──────────────────────────────────────────────────────────── */

.app-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
}

.app-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--surface);
  padding: 1.25rem;
  color: var(--body);
  font-weight: 400;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.app-card:hover {
  opacity: 1;
  transform: translateY(-2px);
  border-color: rgb(59 105 169 / 0.4);
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.2), 0 4px 6px -4px rgb(0 0 0 / 0.2);
}

.app-card:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgb(59 105 169 / 0.4);
}

.app-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.badge {
  display: flex;
  height: 2.5rem;
  width: 2.5rem;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: rgb(var(--overlay) / 0.1);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.025em;
  color: var(--body);
}

.badge svg {
  height: 1.125rem;
  width: 1.125rem;
}

.chev {
  height: 1rem;
  width: 1rem;
  color: var(--muted);
  transition: transform 0.2s, color 0.2s;
}

.app-card:hover .chev {
  transform: translateX(2px);
  color: var(--body);
}

.app-card h3 {
  margin: 1rem 0 0;
  font-size: 1rem;
  font-weight: 600;
}

.app-card .purpose {
  margin: 0.25rem 0 0;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.app-card .blurb {
  margin: 0.5rem 0 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.app-card .open {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 1rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent);
}

.app-card .open svg {
  height: 0.875rem;
  width: 0.875rem;
}

/* ── Settings panels ────────────────────────────────────────────────────── */

.settings {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.settings h2 {
  margin-bottom: 0.25rem;
}

.panel {
  display: grid;
  gap: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--surface);
  padding: 1.5rem;
}

@media (min-width: 720px) {
  .panel {
    grid-template-columns: 16rem 1fr;
  }
}

.panel-head h3 {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--body);
}

.panel-head p {
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

.panel-form {
  margin: 0;
  max-width: 28rem;
}

.two {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr 1fr;
}

input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.panel-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.panel-actions .alert {
  margin: 0;
}

.btn {
  align-self: flex-start;
  width: auto;
  margin-top: 0;
  padding: 0.5rem 1rem;
}

.btn-ghost {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: transparent;
  padding: 0.375rem 0.75rem;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.btn-ghost:hover:not(:disabled) {
  background: rgb(var(--overlay) / 0.1);
  color: var(--body);
}

.btn-ghost:disabled {
  opacity: 0.5;
  cursor: default;
}

.alert-ok {
  border: 1px solid var(--border);
  background: rgb(var(--overlay) / 0.05);
  color: var(--body);
}

/* ── Sessions ───────────────────────────────────────────────────────────── */

.sessions {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  overflow: hidden;
}

.session {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
}

.session + .session {
  border-top: 1px solid var(--border);
}

.session-main {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
}

.session-device {
  font-size: 0.875rem;
  color: var(--body);
}

.session-meta {
  font-size: 0.75rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pill {
  display: inline-block;
  margin-left: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: rgb(var(--overlay) / 0.05);
  padding: 0.0625rem 0.375rem;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  vertical-align: middle;
}

.session.gone {
  opacity: 0.4;
}
