/* AnAccount — hand-written, no build step (keeps install a plain file copy). */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e2e5ea;
  --text: #1c2230;
  --muted: #646d7e;
  --primary: #3949ab;
  --primary-hover: #303f9f;
  --primary-text: #ffffff;
  --danger: #c62828;
  --danger-bg: #fdecec;
  --danger-solid: #c62828;        /* button background (white text) */
  --danger-solid-hover: #a91f1f;
  --success: #2e7d32;
  --success-bg: #e9f5ea;
  --warn: #8a5a00;
  --warn-bg: #fff6e0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151c;
    --surface: #1b1f29;
    --surface-2: #222734;
    --border: #2f3544;
    --text: #e6e8ee;
    --muted: #9aa3b5;
    --primary: #7986cb;
    --primary-hover: #8c98d6;
    --primary-text: #10131a;
    --danger: #ef9a9a;
    --danger-bg: #3a1f22;
    --danger-solid: #b71c1c;
    --danger-solid-hover: #9a1616;
    --success: #a5d6a7;
    --success-bg: #1d3320;
    --warn: #ffd180;
    --warn-bg: #3a3020;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.35rem; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
p { margin: 0 0 .75rem; }
code, .mono { font-family: var(--mono); font-size: .88em; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---------- layout */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: .7rem 16px;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.brand { font-weight: 700; color: var(--text); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.topbar .spacer { flex: 1; }
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; }
.tabs a {
  padding: .35rem .7rem;
  border-radius: 6px;
  color: var(--muted);
  font-size: .92rem;
}
.tabs a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.tabs a.active { background: var(--surface-2); color: var(--text); font-weight: 600; }
.page { max-width: 1040px; margin: 0 auto; padding: 1.5rem 16px 3rem; }
.page-narrow { max-width: 720px; }
.stack > * + * { margin-top: 1rem; }

.guest {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 16px;
}
.guest-box { width: 100%; max-width: 420px; }
.guest-box.wide { max-width: 560px; }
.guest-brand { text-align: center; font-weight: 700; font-size: 1.1rem; margin-bottom: 1rem; }
.below { text-align: center; margin-top: 1rem; }
.below-row { display: flex; justify-content: space-between; gap: 1rem; }
/* Several accounts in one browser: chooser, lock screen, account menu. */
.account-list { list-style: none; margin: 1.25rem 0 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.account-list > li + li { border-top: 1px solid var(--border); }
.account-option { display: flex; align-items: center; gap: .85rem; padding: .8rem 1rem; color: var(--text); width: 100%; background: none; border: 0; font: inherit; text-align: left; cursor: pointer; }
.account-option:hover { background: var(--surface-2); text-decoration: none; }
.account-option-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.account-option-text > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-option-lock { color: var(--muted); flex: none; }
.lock-head { text-align: center; margin-bottom: 1rem; }
.lock-head .avatar { margin: 0 auto .75rem; display: flex; }
.lock-head img.avatar { display: block; }
.lock-head h1 { margin-bottom: .1rem; }
.lock-head p { margin: 0; }
.passcode-input { text-align: center; font-size: 1.6rem; letter-spacing: .8em; padding-left: .8em; }
.account-menu { position: relative; }
.account-menu > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .5rem; }
.account-menu > summary::-webkit-details-marker { display: none; }
.account-menu-panel { position: absolute; right: 0; top: calc(100% + .5rem); z-index: 20; width: 300px; max-width: calc(100vw - 32px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0, 0, 0, .25); }
.account-menu-panel .account-list { margin: 0; border: 0; border-radius: 0; }
.account-menu-panel .account-list > li { border-top: 1px solid var(--border); }
.account-menu-current { padding: 1rem; display: flex; align-items: center; gap: .85rem; }
.account-menu-signout { margin-top: .35rem; }
.account-switcher { margin-bottom: .75rem; }
.account-switcher > summary { display: inline-flex; max-width: 100%; padding: .45rem .75rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); }
.account-switcher > summary:hover { border-color: var(--primary); }
.account-switcher > summary > .muted { overflow-wrap: anywhere; }
.account-switcher-caret { color: var(--muted); flex: none; }
.account-switcher .account-menu-panel { left: 0; right: auto; }
.avatar-30, .avatar-40, .avatar-64 { aspect-ratio: 1; flex: none; }
.avatar-30 { width: 30px; height: 30px; }
.avatar-40 { width: 40px; height: 40px; }
.avatar-64 { width: 64px; height: 64px; }
.avatar-initial.avatar-30 { font-size: .9rem; }
.avatar-initial.avatar-40 { font-size: 1.1rem; }
.avatar-initial.avatar-64 { font-size: 1.75rem; }
.back-to-product { display: inline-flex; align-items: center; gap: .5rem; margin-bottom: 1rem; font-size: .9rem; color: var(--muted); max-width: 100%; }
.back-to-product:hover { color: var(--text); text-decoration: none; }
.back-to-product img { height: 20px; width: auto; max-width: 80px; border-radius: 4px; }
.back-to-product span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Sign in / sign up: one bordered frame that fits the screen — brand column
   on the left, the form column (the only scrollbar) on the right; the
   "New here?" and footer links sit below the frame. */
.guest-split-page { height: 100vh; height: 100dvh; min-height: 0; flex-direction: column; }
.guest-split-foot { flex: none; }
.guest-split {
  display: flex;
  flex: 0 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 1040px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.guest-aside { flex: 1 1 0; min-width: 0; padding: 3rem; display: flex; flex-direction: column; justify-content: center; border-right: 1px solid var(--border); background: var(--surface-2); }
.guest-main { flex: 0 1 480px; min-width: 0; padding: 2.5rem 2rem 1.5rem; overflow-y: auto; }
.guest-aside .back-to-product { align-self: flex-start; margin-bottom: 2rem; }
.aside-logo { display: block; height: 72px; width: auto; max-width: 240px; border-radius: 12px; margin-bottom: 1.25rem; }
.aside-site-logo { margin-bottom: 1.25rem; }
.aside-site-logo img { height: 64px; max-width: 280px; }
.aside-name { font-weight: 700; font-size: 2.4rem; line-height: 1.15; letter-spacing: -.02em; margin: 0 0 .75rem; overflow-wrap: anywhere; }
.aside-text { color: var(--muted); font-size: 1.05rem; max-width: 46ch; }
@media (max-width: 820px) {
  /* Stacked: the page scrolls instead of the form column. */
  .guest-split-page { height: auto; min-height: 100vh; justify-content: flex-start; }
  .guest-split { flex: none; flex-direction: column; max-width: 480px; }
  .guest-aside { flex: none; padding: 1.5rem; border-right: 0; border-bottom: 1px solid var(--border); }
  .guest-main { flex: none; padding: 1.5rem; overflow: visible; }
  .guest-aside .back-to-product { margin-bottom: 1rem; }
  .aside-logo, .aside-site-logo img { height: 48px; }
  .aside-name { font-size: 1.6rem; }
}
.sent-mark { text-align: center; margin-bottom: .75rem; }
.sent-mark svg { display: block; margin: 0 auto .5rem; }
.sent-mark-title { font-weight: 700; font-size: 1.25rem; color: var(--success); margin: 0; }
.center { text-align: center; }
.mt { margin-top: 1rem; }
.mb-0 { margin-bottom: 0; }
.mb { margin-bottom: 1rem; }
.toggle-row .hint { display: block; font-weight: 400; }
.danger-zone { border-color: var(--danger); }
.avatar { border-radius: 50%; object-fit: cover; flex: none; background: var(--surface-2); }
.avatar-lg { width: 96px; height: 96px; }
.avatar-sm { width: 28px; height: 28px; }
.avatar-initial { display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 2rem; color: var(--muted); border: 1px solid var(--border); }
.avatar-row { display: flex; gap: 1.25rem; align-items: flex-start; flex-wrap: wrap; }
.avatar-row > div { flex: 1 1 260px; }
.site-logo { display: inline-flex; align-items: center; }
.site-logo img { height: 28px; width: auto; max-width: 200px; display: block; }
.site-logo-lg img { height: 44px; max-width: 280px; margin: 0 auto; }
.guest-brand .site-logo { justify-content: center; }
.footer-links { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; margin-top: 1.5rem; font-size: .85rem; }
.footer-links a { color: var(--muted); }
.brand-preview { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; margin-top: .5rem; }
.brand-preview .tile { padding: .75rem 1rem; border-radius: var(--radius); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; min-height: 64px; }
.brand-preview .tile.light { background: #ffffff; }
.brand-preview .tile.dark { background: #12151c; }
.brand-preview img { max-height: 44px; max-width: 220px; display: block; }
input[type=color] { width: 3rem; height: 2.4rem; padding: .15rem; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); flex: none; }
.color-row { display: flex; gap: .5rem; align-items: center; }
.recovery-item { padding: .9rem 0; border-top: 1px solid var(--border); }
.recovery-item h3 { margin: 0 0 .4rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.danger-zone .toggle-row .btn { flex: none; }
.hidden { display: none; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}
/* `~` (not `+`) so a script/comment between cards can't remove the gap. */
.card ~ .card { margin-top: 1rem; }
.card > :last-child { margin-bottom: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.card-head h2 { margin: 0; }

/* ---------- forms */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.field { margin-bottom: .9rem; }
.hint { font-size: .82rem; color: var(--muted); margin-top: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=tel],
input[type=number], input[type=search], input[type=date], select, textarea {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
textarea { min-height: 5rem; font-family: var(--mono); font-size: .88rem; }
.check { display: flex; align-items: flex-start; gap: .5rem; font-weight: 400; }
.check input { margin-top: .25rem; }
.code-input { font-family: var(--mono); font-size: 1.3rem; letter-spacing: .3em; text-align: center; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; }
.row > .field { flex: 1 1 160px; }
.phone-input { display: flex; gap: .4rem; }
.phone-input select { width: auto; flex: 0 0 6.5rem; }
.phone-input input { flex: 1; min-width: 0; }
.form-fields .toggle-row select { width: auto; min-width: 11rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .55rem 1rem;
  border-radius: 7px;
  border: 1px solid transparent;
  background: var(--primary);
  color: var(--primary-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--primary-hover); text-decoration: none; }
.btn-block { width: 100%; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger-solid); color: #fff; }
.btn-danger:hover { background: var(--danger-solid-hover); }
.btn-small { padding: .3rem .65rem; font-size: .85rem; }
.btn-link { background: none; border: 0; color: var(--primary); padding: 0; font: inherit; cursor: pointer; }
.btn-link:hover { text-decoration: underline; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.inline { display: inline; }

/* ---------- feedback */
.alert { padding: .7rem .9rem; border-radius: 7px; margin-bottom: 1rem; font-size: .92rem; }
.alert p { margin: 0; }
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-warn { background: var(--warn-bg); color: var(--warn); }
.badge {
  display: inline-block;
  padding: .1rem .5rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.badge-success { background: var(--success-bg); color: var(--success); border-color: transparent; }
.badge-danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.badge-warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }

/* ---------- data */
.table-wrap { overflow-x: auto; margin: 0 -1.25rem; padding: 0 1.25rem; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: .8rem 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.list > li:last-child { border-bottom: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.stat .num { font-size: 1.6rem; font-weight: 700; }
.stat .label { color: var(--muted); font-size: .85rem; }
dl.meta { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0; }
dl.meta dt { color: var(--muted); font-size: .88rem; }
dl.meta dd { margin: 0; overflow-wrap: anywhere; }
.secret-box {
  font-family: var(--mono);
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: 7px;
  padding: .6rem .75rem;
  overflow-wrap: anywhere;
}
pre.secret-box { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .85rem; line-height: 1.6; }
.code-block { position: relative; }
.code-block .secret-box { padding-right: 4.5rem; }
.code-copy { position: absolute; top: 50%; right: .4rem; transform: translateY(-50%); }
.code-block pre + .code-copy { top: .4rem; transform: none; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: .4rem; font-family: var(--mono); }
.qr { background: #fff; display: inline-block; padding: .5rem; border-radius: 8px; line-height: 0; }
.toggle-row { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; padding: .9rem 0; border-bottom: 1px solid var(--border); }
.toggle-row:last-child { border-bottom: 0; }
.toggle-row input[type=checkbox] { width: 1.15rem; height: 1.15rem; margin-top: .2rem; flex: none; }
.scope-list { margin: .5rem 0 1rem; padding-left: 1.2rem; }
.pagination { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: 1rem; }
.pagination a, .pagination span { padding: .3rem .6rem; border: 1px solid var(--border); border-radius: 6px; font-size: .85rem; }
.pagination .current { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
pre.log { background: #111827; color: #e5e7eb; padding: .75rem; border-radius: 7px; height: 14rem; overflow: auto; font-size: .78rem; white-space: pre-wrap; }
.steps { color: var(--muted); font-size: .85rem; display: flex; justify-content: space-between; margin-bottom: .75rem; }

@media (max-width: 560px) {
  .card { padding: 1rem; }
  .table-wrap { margin: 0 -1rem; padding: 0 1rem; }
  .codes { grid-template-columns: 1fr; }
}
.text-warn { color: var(--warn); }

/* Admin floating progress bar (background tasks) */
.task-bar { position: fixed; right: 16px; bottom: 16px; z-index: 50; width: min(380px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(16, 24, 40, .18); overflow: hidden; }
.task-bar[hidden] { display: none; }
.task-bar-head { display: flex; align-items: center; gap: .5rem; width: 100%; padding: .6rem .85rem; background: var(--surface-2); border: 0; color: var(--text); font: inherit; font-size: .88rem; text-align: left; cursor: pointer; }
.task-bar-summary { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-bar-chevron { transition: transform .15s; }
.task-bar.collapsed .task-bar-chevron { transform: rotate(180deg); }
.task-bar.collapsed .task-bar-body { display: none; }
.task-bar-body { max-height: 50vh; overflow-y: auto; padding: .25rem .85rem .75rem; }
.task-row { padding-top: .6rem; }
.task-row + .task-row { border-top: 1px solid var(--border); margin-top: .6rem; }
.task-row-top { display: flex; align-items: center; justify-content: space-between; font-size: .88rem; }
.task-row progress { width: 100%; height: 8px; margin: .35rem 0 .15rem; accent-color: var(--primary); }
.task-row-text { font-size: .8rem; color: var(--muted); }
.task-done .task-row-text { color: var(--success); }
.task-failed .task-row-text, .task-stalled .task-row-text { color: var(--warn); }
.task-dismiss { border: 0; background: none; color: var(--muted); font-size: 1.1rem; line-height: 1; cursor: pointer; padding: 0 .2rem; }
.task-dismiss:hover { color: var(--text); }

/* Email template rich-text editor (public/js/rich-text.js) */
.rte { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); overflow: hidden; }
.rte[hidden] { display: none; }
.rte-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; padding: .4rem; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.rte-toolbar .spacer { flex: 1; }
.rte-toolbar select { width: auto; padding: .25rem .4rem; font-size: .82rem; }
.rte-group { display: inline-flex; gap: 2px; }
.rte-toolbar button, .rte-color { min-width: 30px; height: 30px; padding: 0 .4rem; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--text); font: inherit; font-size: .88rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.rte-toolbar button:hover, .rte-color:hover { background: var(--surface); border-color: var(--border); }
.rte-toolbar button[aria-pressed="true"] { background: var(--primary); color: var(--primary-text); }
.rte-toolbar button:disabled, .rte-toolbar select:disabled { opacity: .4; cursor: default; }
.rte-color { position: relative; font-weight: 700; text-decoration: underline; text-decoration-color: var(--danger); text-decoration-thickness: 3px; }
.rte-color input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; padding: 0; border: 0; }
.rte-area { min-height: 260px; max-height: 60vh; overflow-y: auto; padding: .75rem 1rem; outline: none; line-height: 1.55; }
.rte-area:focus { box-shadow: inset 0 0 0 2px var(--primary); }
.rte-area[hidden], .rte textarea[hidden] { display: none; }
.rte textarea { border: 0; border-radius: 0; min-height: 260px; font-family: var(--mono); font-size: .82rem; }
.rte-area > :first-child, .email-sample > :first-child { margin-top: 0; }
.rte-area blockquote, .email-sample blockquote { margin: .5rem 0; padding-left: .9rem; border-left: 3px solid var(--border); color: var(--muted); }
.rte-area hr, .email-sample hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
.rte-area [align="center"], .email-sample [align="center"] { text-align: center; }
.rte-area [align="right"], .email-sample [align="right"] { text-align: right; }
.rte-area [align="justify"], .email-sample [align="justify"] { text-align: justify; }
.email-sample { font-size: .92rem; padding: .75rem 1rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); margin-bottom: .75rem; }
.email-sample img { max-width: 36px; height: auto; }
