/* ============================================================
   printington — "dispatch desk" mail + credentials vault client
   Design language
   ---------------
   · a dark plum-ink desk, lit by two soft pools of light
     (violet for structure, clay-amber for mail/money)
   · envelope geometry: flap-fold corners, perforation rules,
     stamp-like brand mark, letterpress micro-labels
   · monospace for every address, code, token, id and figure
   · serif reserved exclusively for email message bodies
   · 4px spacing rhythm, tight radius scale, hairline borders
   · one elevation ramp shared by every raised surface
   ============================================================ */

:root {
  color-scheme: dark;

  /* ── spacing rhythm (4px base) ── */
  --sp-1: 4px;  --sp-2: 8px;   --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px;  --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;

  /* ── radii: tight, papery ── */
  --r-xs: 4px;
  --radius-sm: 7px;
  --r: 10px;
  --radius: 13px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-pill: 999px;

  /* ── colour: plum-ink neutrals ── */
  --bg: #0b0912;
  --bg-2: #100d1a;
  --surface: rgba(255, 255, 255, 0.032);
  --surface-2: rgba(255, 255, 255, 0.058);
  --surface-3: rgba(255, 255, 255, 0.09);
  --surface-solid: #12101d;
  --sunken: rgba(0, 0, 0, 0.32);
  --sunken-2: rgba(0, 0, 0, 0.44);
  --glass-border: rgba(255, 255, 255, 0.085);
  --border: rgba(255, 255, 255, 0.075);
  --sep: rgba(255, 255, 255, 0.06);
  --line-strong: rgba(255, 255, 255, 0.17);
  --fg: #ece9f6;
  --fg-strong: #fbfaff;
  --fg-soft: #cbc6de;
  --muted: #a49db9;
  --muted-2: #8a839f;

  /* ── colour: accent (violet = structure) ── */
  --accent: #a78bfa;
  --accent-2: #8b5cf6;
  --accent-grad: linear-gradient(135deg, #b79dff 0%, #8b5cf6 100%);
  --accent-soft: rgba(167, 139, 250, 0.13);
  --accent-line: rgba(167, 139, 250, 0.38);
  --accent-ink: #150a2b;
  --ring: rgba(167, 139, 250, 0.62);

  /* ── colour: second accent (clay = mail + money) ── */
  --clay: #f0a552;
  --clay-2: #e07a3c;
  --clay-soft: rgba(240, 165, 82, 0.13);
  --clay-line: rgba(240, 165, 82, 0.38);

  /* ── colour: status ── */
  --danger: #f4736a;
  --danger-soft: rgba(244, 115, 106, 0.14);
  --danger-line: rgba(244, 115, 106, 0.42);
  --danger-ink: #ffb4ad;
  --ok: #45cf9b;
  --ok-soft: rgba(69, 207, 155, 0.13);
  --ok-line: rgba(69, 207, 155, 0.4);
  --warn: #e8b64c;
  --warn-soft: rgba(232, 182, 76, 0.12);
  --warn-line: rgba(232, 182, 76, 0.38);

  /* ── type ── */
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "JetBrains Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --reader: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;

  /* ── elevation ── */
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --elev-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --elev-2: 0 8px 22px -14px rgba(0, 0, 0, 0.55);
  --elev-3: 0 24px 56px -22px rgba(0, 0, 0, 0.7);

  /* ── motion ── */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 120ms;
  --t: 170ms;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55; -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: #c4b1ff; }
::selection { background: rgba(167, 139, 250, 0.3); color: var(--fg-strong); }
:focus-visible {
  outline: 2px solid var(--ring); outline-offset: 2px; border-radius: var(--r-xs);
}
code, pre, .mono { font-family: var(--mono); }

/* thin, unobtrusive scrollbars that match the surfaces */
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--surface-3); border-radius: var(--r-pill);
  border: 3px solid transparent; background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--line-strong); background-clip: content-box; }

/* ---- the desk: two pools of light + a perforation lattice ---- */
.bg-aurora, .bg-stars { position: fixed; inset: 0; z-index: -2; pointer-events: none; }
.bg-aurora {
  background:
    radial-gradient(760px 520px at 4% -10%, rgba(139, 92, 246, 0.26), transparent 62%),
    radial-gradient(680px 480px at 104% 4%, rgba(240, 165, 82, 0.12), transparent 58%),
    radial-gradient(900px 700px at 50% 118%, rgba(0, 0, 0, 0.6), transparent 66%),
    var(--bg);
}
/* a faint pin-prick lattice — texture, not a structural grid */
.bg-stars {
  z-index: -1; opacity: .3;
  background-image:
    radial-gradient(1px 1px at 18% 26%, rgba(255,255,255,.55), transparent),
    radial-gradient(1px 1px at 63% 58%, rgba(255,255,255,.4), transparent),
    radial-gradient(1px 1px at 37% 79%, rgba(255,255,255,.45), transparent),
    radial-gradient(1px 1px at 88% 21%, rgba(255,255,255,.35), transparent);
  background-size: 340px 340px, 300px 300px, 420px 420px, 260px 260px;
  animation: drift 150s linear infinite;
}
@keyframes drift { to { background-position: 340px 340px, -300px 300px, 420px -420px, -260px 260px; } }

/* ============================ layout ============================ */
.app-shell { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; }
.auth-shell { display: block; }

/* keyboard users can jump straight past the nav */
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 2000;
  padding: 10px 16px; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--accent-ink); font-weight: 700;
  transition: top var(--t) var(--ease);
}
.skip-link:focus { top: 12px; color: var(--accent-ink); }

.sidebar {
  position: sticky; top: 0; align-self: start; height: 100vh;
  display: flex; flex-direction: column; gap: var(--sp-2);
  padding: var(--sp-5) var(--sp-3);
  background: linear-gradient(180deg, #100d1a, #0c0a14);
  border-right: 1px solid var(--border);
}
.side-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 2px 8px var(--sp-4); color: var(--fg-strong); font-weight: 800;
  font-size: 1.08rem; letter-spacing: -0.02em;
}
.side-brand:hover { color: var(--fg-strong); }
/* the stamp — no raster asset, a rotated dashed seal holding the glyph */
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--r-xs); font-size: 16px;
  background: var(--accent-grad); color: var(--accent-ink);
  transform: rotate(-4deg);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14) inset;
}
.brand-text { letter-spacing: -0.02em; }
.brand-dot { color: var(--clay); }

.side-nav {
  display: flex; flex-direction: column; gap: 1px; flex: 1;
  overflow-y: auto; margin: 0 -4px; padding: 0 4px;
}
.side-games { margin-top: auto; }
.side-link {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 11px; border-radius: var(--radius-sm); color: var(--muted);
  font-weight: 600; font-size: 13.5px; position: relative;
  transition: background var(--t-fast), color var(--t-fast);
}
.side-link:hover { background: var(--surface-2); color: var(--fg); }
.side-link.active {
  color: var(--fg-strong);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}
.side-link.active::before {
  content: ""; position: absolute; left: -4px; top: 24%; bottom: 24%;
  width: 3px; border-radius: var(--r-pill); background: var(--accent);
}
.side-ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.side-link.active .side-ic { stroke: var(--accent); }
.side-link:focus-visible { outline-offset: -2px; }

.side-foot {
  display: flex; align-items: center; gap: var(--sp-2);
  padding-top: var(--sp-3); margin-top: var(--sp-2);
  border-top: 1px dashed var(--sep);
}
.side-user {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0;
  padding: 5px 8px; margin: 0 -8px; border-radius: var(--radius-sm);
  color: var(--fg); transition: background var(--t-fast);
}
.side-user:hover { background: var(--surface-2); color: var(--fg); }
.side-user-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.side-user-name { font-weight: 700; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user-role { color: var(--muted); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; font-family: var(--mono); }
.side-logout {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0; flex: none;
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.side-logout svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.side-logout:hover { background: var(--danger-soft); color: var(--danger-ink); border-color: var(--danger-line); }

.main { min-width: 0; padding: var(--sp-8) var(--sp-8) var(--sp-12); }
.main.solo { padding: 0; }
.page { max-width: 1200px; margin: 0 auto; }

/* ============================ typography ============================ */
h1 {
  font-size: clamp(1.5rem, 1.2rem + 1vw, 1.9rem);
  font-weight: 800; letter-spacing: -0.03em; line-height: 1.14; margin: 0 0 6px;
}
h2 {
  font-size: clamp(1.05rem, 1rem + 0.3vw, 1.2rem);
  font-weight: 700; letter-spacing: -0.018em; line-height: 1.3;
  margin: var(--sp-8) 0 var(--sp-3);
}
h3 { font-size: 1rem; font-weight: 700; letter-spacing: -0.012em; margin: 0 0 6px; }
/* headings that open a card/panel shouldn't inherit the page rhythm */
.card > h2:first-child, .panel > h2:first-child,
.card-head > h2:first-child, .pool-title > h1:first-child { margin-top: 0; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.error, .err { color: var(--danger-ink); }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
/* letterpress micro-label — mono, tracked out, preceded by a short rule */
.eyebrow, .mailbox-heading {
  font-family: var(--mono);
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--muted);
}
.mailbox-heading { margin: var(--sp-6) 0 0; }
/* the one-line stamp that opens every page */
.page-kicker {
  margin: 0 0 3px;
  font-family: var(--mono);
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--accent);
}
.page-kicker.clay { color: var(--clay); }
.note { font-size: 13px; }
.field-mono { font-family: var(--mono); }
.field-grow { flex: 1; min-width: 0; }
.row-gap { display: flex; gap: .5rem; }
/* the label's mono treatment is for chrome only — prose set inside a label
   (hints, inline help) falls back to the UI sans and sentence case. */
label .muted, label .note, label .hint,
label.import-refresh, label.ap-toggle {
  font-family: var(--sans);
  font-size: .9rem;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}
/* inert controls, e.g. "Coming soon" */
.btn.disabled, button.disabled {
  opacity: .5; pointer-events: none;
}
.badge {
  display: inline-flex; align-items: center;
  background: var(--clay-soft); color: var(--clay);
  padding: 2px 8px;
  border-radius: var(--r-xs); box-shadow: inset 0 0 0 1px var(--clay-line);
  font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: .08em; line-height: 1.7; text-transform: uppercase;
}
.badge.alt { background: var(--surface-2); color: var(--fg-soft); box-shadow: inset 0 0 0 1px var(--border); }
.badge.ok { background: var(--ok-soft); color: var(--ok); box-shadow: inset 0 0 0 1px var(--ok-line); }
.badge.warn { background: var(--warn-soft); color: var(--warn); box-shadow: inset 0 0 0 1px var(--warn-line); }
.badge.danger { background: var(--danger-soft); color: var(--danger-ink); box-shadow: inset 0 0 0 1px var(--danger-line); }

/* ============================ buttons ============================ */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--surface-2); color: var(--fg); border: 1px solid var(--border);
  cursor: pointer; padding: 8px 14px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 13.5px; font-family: inherit; line-height: 1.4;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
button:hover, .btn:hover {
  background: var(--surface-3); color: var(--fg-strong); border-color: var(--line-strong);
}
button:active, .btn:active { background: rgba(255, 255, 255, 0.14); }
.btn.small, button.small { padding: 5px 10px; font-size: 12.5px; border-radius: var(--r-xs); }

.primary, .btn.primary, button.primary {
  background: var(--accent); color: var(--accent-ink);
  border-color: transparent; font-weight: 700;
}
.primary:hover, .btn.primary:hover, button.primary:hover {
  color: var(--accent-ink); background: #b79dff; border-color: transparent;
}
.primary:active, .btn.primary:active, button.primary:active { background: #9b7bf5; }

.btn.danger, button.danger {
  background: var(--danger-soft); color: var(--danger-ink);
  border-color: var(--danger-line);
}
.btn.danger:hover, button.danger:hover {
  background: var(--danger); color: #2a0b09; border-color: transparent;
}
.btn.ghost, button.ghost, .btn.subtle, button.subtle {
  background: transparent; border-color: transparent; color: var(--muted);
}
.btn.ghost:hover, button.ghost:hover, .btn.subtle:hover, button.subtle:hover {
  background: var(--surface-2); color: var(--fg); border-color: transparent;
}
.link-btn {
  background: none; border: none; padding: 2px 4px; color: var(--accent);
  font-weight: 600;
}
.link-btn:hover { background: none; border: none; text-decoration: underline; }
.link-btn.danger { background: none; border: none; color: var(--danger-ink); text-decoration: underline; font-weight: 500; }
.link-btn.danger:hover { background: none; color: #ffd0cb; }
button:disabled, .btn:disabled, button[disabled] {
  opacity: 0.5; cursor: not-allowed;
}
button:disabled:hover, .btn:disabled:hover { background: var(--surface-2); border-color: var(--border); }
.admin-actions { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.admin-actions form { margin: 0; }

/* ============================ forms ============================ */
label {
  display: flex; flex-direction: column; gap: 6px;
  font-family: var(--mono);
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted);
}
input, select, textarea {
  background: var(--sunken); color: var(--fg);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 12px;
  font-size: 14px; font-family: inherit; line-height: 1.45;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:hover, select:hover, textarea:hover { border-color: var(--line-strong); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  background: rgba(0, 0, 0, 0.26);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--ring); outline-offset: 1px;
}
input[type="checkbox"] {
  width: 17px; height: 17px; padding: 0; flex: none;
  accent-color: var(--accent); cursor: pointer;
  border-radius: var(--r-xs);
}
input[type="file"] { padding: 7px 10px; font-size: 13px; cursor: pointer; }
select option { background: var(--surface-solid); color: var(--fg); }
textarea { resize: vertical; }

/* ============================ signed-out shell ============================ */
/* A letter on a desk: perforated top rule, postmark strip, flat panel. */
.auth-brand {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  position: fixed; top: 24px; left: 0; right: 0; z-index: 1;
  color: var(--fg-strong); font-weight: 800; font-size: 1.02rem;
  letter-spacing: -0.02em; pointer-events: none;
}
.auth-brand .brand-mark { width: 28px; height: 28px; font-size: 15px; }
.auth-card {
  max-width: 392px; margin: 13vh auto 0;
  position: relative;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.014));
  padding: 28px 26px 26px;
  border-radius: var(--r-lg); border: 1px solid var(--glass-border);
  box-shadow: var(--elev-3);
}
/* perforation across the head of the letter */
.auth-card::before {
  content: ""; position: absolute; left: 14px; right: 14px; top: 9px;
  border-top: 1px dashed var(--line-strong);
}
/* the postmark: a stamped slug above the title */
.auth-card::after {
  content: "printington"; position: absolute; top: 16px; right: 16px;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--muted-2);
  border: 1px solid var(--sep); border-radius: var(--r-xs);
  padding: 2px 6px; transform: rotate(-2deg);
}
@media (max-width: 430px) {
  .auth-card::after { display: none; }
  .auth-card h1 { padding-right: 0; }
}
.auth-card h1 { letter-spacing: -0.03em; padding-right: 92px; }
.auth-card > .muted:first-of-type { margin-bottom: 0; }
.auth-card form { display: flex; flex-direction: column; gap: var(--sp-4); margin-top: var(--sp-5); }
.auth-card input { font-family: var(--mono); }
.auth-card button[type="submit"], .auth-card > .btn { width: 100%; margin-top: 4px; padding: 10px 16px; }
.auth-card .backup-codes + .btn { margin-top: var(--sp-2); }
.auth-card > img {
  display: block; margin: var(--sp-2) auto; border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border); background: #fff; padding: 8px;
}
.auth-foot {
  max-width: 392px; margin: var(--sp-4) auto 0; display: flex;
  justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap;
  font-size: 13px; color: var(--muted);
}

/* ============================ shared card recipe ============================ */
/* Every raised surface in the app is one of these three recipes. */
.pool-tile, .panel, .card, .filterbar, table.data,
.vault-card, .bot-type, .bot-row, .mailbox, .mailrow,
.stat, .cred-card, .recip-list li, .session-step, .locked-item,
.session-batch-item, .device-box, .pay-box, .mkt-panel, .mkt-plot {
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
}

/* ============================ dashboard tiles ============================ */
.pool-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(244px, 1fr));
  gap: var(--sp-4); margin-top: var(--sp-6);
}
/* the empty state spans the whole grid */
.pool-empty { grid-column: 1 / -1; }
.pool-tile {
  padding: 17px; display: block; position: relative; overflow: hidden;
  color: var(--fg);
  transition: transform var(--t) var(--ease), border-color var(--t), background var(--t);
}
/* envelope flap fold */
.pool-tile::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: linear-gradient(300deg, rgba(167, 139, 250, 0.08), transparent 42%);
  opacity: 0; transition: opacity var(--t); pointer-events: none;
}
.pool-tile:hover {
  transform: translateY(-2px); border-color: var(--accent-line);
  background: var(--surface-2); color: var(--fg);
}
.pool-tile:hover::after { opacity: 1; }
.pool-owner { font-weight: 700; color: var(--fg-strong); display: flex; gap: var(--sp-2); align-items: center; }
.pool-meta {
  color: var(--muted); margin-top: 6px; font-size: 13px;
  display: flex; align-items: center; gap: 6px;
}
.pool-name { font-weight: 700; letter-spacing: -0.01em; font-family: var(--mono); }

/* ============================ create / rename lists ============================ */
.new-list { position: relative; }
.new-list > summary { list-style: none; display: inline-flex; }
.new-list > summary::-webkit-details-marker { display: none; }
.new-list-form, .rename-form {
  display: flex; gap: var(--sp-2); margin-top: 10px; position: absolute; right: 0; z-index: 20;
  background: var(--surface-solid); border: 1px solid var(--glass-border);
  border-radius: var(--r); padding: var(--sp-3);
  box-shadow: var(--elev-3); width: min(340px, 80vw);
}
.rename-form { left: 0; }
.new-list-form input, .rename-form input { flex: 1; }

.pool-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.pool-title h1 { display: inline; }
.back-link, .icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--fg-soft);
  padding: 7px 10px; border-radius: var(--radius-sm); cursor: pointer; flex: none;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.back-link { width: 34px; height: 34px; padding: 0; font-size: 18px; }
.back-link:hover, .icon-btn:hover {
  background: var(--surface-3); color: var(--accent); border-color: var(--accent-line);
}
.rename-list { position: relative; }
.rename-list > summary { list-style: none; }
.rename-list > summary::-webkit-details-marker { display: none; }

/* ============================ pool page ============================ */
.pool-head { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: var(--sp-4); }
.pool-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.pool-actions form { margin: 0; }
.panel { padding: 14px 18px; margin: var(--sp-4) 0; }
.panel summary { cursor: pointer; font-weight: 700; }
.inline-form { display: flex; gap: var(--sp-3); align-items: flex-end; flex-wrap: wrap; margin-top: var(--sp-3); }
.filterbar {
  display: flex; gap: var(--sp-3); align-items: flex-end; flex-wrap: wrap;
  margin: var(--sp-5) 0 var(--sp-4);
  padding: 13px 15px;
}
.filterbar label { min-width: 130px; }
.share-create { display: inline-flex; align-items: center; gap: 8px; }

/* ============================ tables ============================ */
table.data {
  width: 100%; border-collapse: separate; border-spacing: 0;
  overflow: hidden;
}
table.data th, table.data td {
  padding: 11px 14px; text-align: left;
  border-bottom: 1px solid var(--sep); vertical-align: middle;
}
table.data thead th {
  background: var(--surface-2); color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.13em; white-space: nowrap;
  box-shadow: inset 0 -1px 0 var(--glass-border);
}
table.data tbody tr:last-child td { border-bottom: none; }
/* hover lives on the cells so rows carrying an inline background keep the cue */
table.data tbody tr:hover td { background: rgba(255, 255, 255, 0.026); }
table.data tbody td:first-child { color: var(--fg-strong); }
table.data.compact td { padding: 6px 12px; }
table.data tbody tr:last-child td.muted { text-align: left; }
.accounts td select, .accounts td input { height: 34px; }
.accounts .flag-cell select { padding: 5px 8px; }
.accounts .flag-select { max-width: 150px; }
.mark-badge {
  display: inline-block; padding: 2px 8px; border: 1px solid var(--muted);
  border-radius: var(--r-pill); font-size: .82em; font-weight: 600;
}
.bal-form { margin: 0; }
.accounts .rownum {
  color: var(--muted-2); text-align: right; width: 1%; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.row-actions { white-space: nowrap; }
.row-actions form { display: inline-block; margin: 0 0 0 8px; }
.row-actions .btn { min-width: 104px; text-align: center; }
.acct-table { width: 100%; border-collapse: collapse; margin-top: var(--sp-4); font-size: 14px; }
.acct-table th, .acct-table td {
  text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--sep); vertical-align: top;
}
.acct-table th {
  font-family: var(--mono);
  font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.13em; color: var(--muted);
}
.acct-table tr:last-child td { border-bottom: none; }

/* ============================ device / token ============================ */
.device-box { margin-top: var(--sp-4); padding: var(--sp-4); background: var(--surface-2); }
.device-box.ok { border-color: var(--ok-line); background: var(--ok-soft); }
.device-box.error { border-color: var(--danger-line); background: var(--danger-soft); }
.device-code {
  font-family: var(--mono);
  font-size: 1.8rem; font-weight: 700; letter-spacing: 4px; color: var(--accent);
}
.token {
  width: 100%; font-family: var(--mono); font-size: 13px;
  line-height: 1.55; word-break: break-all; resize: vertical; padding: var(--sp-3);
  background: var(--sunken-2); color: #d9ccff; border-radius: var(--radius-sm);
}

/* HTMX indicator */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: block; }
.htmx-swapping { opacity: .55; transition: opacity var(--t-fast); }

/* ============================ avatars ============================ */
.avatar { border-radius: var(--r-xs); object-fit: cover; vertical-align: middle; flex: none; }
.avatar-fallback {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-grad); color: var(--accent-ink); font-weight: 800; text-transform: uppercase;
  font-family: var(--mono);
}
.card {
  padding: 20px 22px; margin-top: var(--sp-4);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.012));
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-3);
}
.card-head h2 { margin: 0; }
.avatar-settings { display: flex; gap: var(--sp-5); align-items: center; flex-wrap: wrap; }
.avatar-settings .inline-form { margin-top: 0; }

/* ============================ chat ============================ */
.chat-panel { margin-top: var(--sp-3); }
.chat-msgs {
  background: var(--sunken); border-radius: var(--radius);
  padding: var(--sp-4); height: 360px; overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--sp-4);
}
.chat-msg { display: flex; gap: 10px; align-items: flex-start; }
.chat-body { min-width: 0; flex: 1; }
.chat-meta { display: flex; align-items: center; gap: var(--sp-2); font-size: 12px; }
.chat-author { font-weight: 700; color: var(--fg-strong); }
.chat-via {
  color: var(--muted); font-weight: 600; font-size: 11px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-xs); padding: 1px 7px; letter-spacing: 0.01em;
}
.chat-time { color: var(--muted-2); font-family: var(--mono); font-size: 11px; }
.chat-del {
  background: none; border: none; color: var(--muted-2); padding: 0 6px;
  font-size: 15px; line-height: 1; margin-left: auto;
}
.chat-del:hover { background: none; color: var(--danger); border-color: transparent; }
.chat-text {
  word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap;
  margin-top: 3px; color: var(--fg-soft);
}
.chat-empty { margin: auto; color: var(--muted); }
.chat-notice { color: var(--danger-ink); font-size: 13px; margin: 0; }
.chat-form { display: flex; gap: 10px; margin-top: var(--sp-3); }
.chat-form input { flex: 1; }

/* ============================ 2FA nudge ============================ */
.nudge {
  display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap;
  background: var(--accent-soft); border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  padding: 13px 16px; margin-bottom: var(--sp-5);
}
.nudge span { flex: 1; min-width: 200px; color: var(--fg-soft); }
.nudge-x {
  background: none; border: none; color: var(--muted);
  padding: 0 6px; font-size: 20px; line-height: 1;
}
.nudge-x:hover { background: none; color: var(--fg); border-color: transparent; }
.backup-codes {
  list-style: none; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-2); margin: var(--sp-4) 0;
}
.backup-codes code {
  display: block; font-size: 1rem; letter-spacing: 1px; text-align: center;
  background: var(--sunken); border: 1px solid var(--border);
  border-radius: var(--r-xs); padding: 8px 6px; color: var(--accent);
}

.api-key-once {
  margin-top: var(--sp-3); padding: var(--sp-3) 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--accent-line); background: var(--accent-soft);
}
.api-key-secret {
  display: block; margin: var(--sp-2) 0; padding: 8px 10px; word-break: break-all;
  font-family: var(--mono); font-size: 13px;
  background: rgba(0, 0, 0, 0.36); border-radius: var(--r-xs); border: 1px solid var(--border);
}
.api-keys-table { width: 100%; margin-top: var(--sp-4); border-collapse: collapse; }
.api-keys-table th {
  color: var(--muted); font-weight: 600; font-size: 10.5px;
  font-family: var(--mono); text-transform: uppercase; letter-spacing: .12em;
  border-bottom: 1px solid var(--glass-border); padding: 7px 8px; text-align: left;
}
.api-keys-table td { border-bottom: 1px solid var(--sep); vertical-align: middle; padding: 7px 8px; }
.api-keys-table tr:last-child td { border-bottom: none; }
.api-docs {
  font-family: var(--mono); line-height: 1.6;
  overflow: auto; font-size: 12px; background: var(--sunken);
  padding: var(--sp-3); border-radius: var(--radius-sm);
  margin: var(--sp-2) 0 0; border: 1px solid var(--border); color: var(--fg-soft);
}

/* ============================ modal overlay ============================ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 6, 14, 0.78); backdrop-filter: blur(4px);
  animation: fade-in var(--t) var(--ease);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  position: relative; width: min(720px, 94vw); max-height: 88vh; overflow-y: auto;
  background: linear-gradient(180deg, #15121f, #0e0c17);
  border: 1px solid var(--glass-border); border-radius: var(--r-xl);
  padding: 26px 28px; box-shadow: var(--elev-3);
  animation: pop-in 200ms var(--ease);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-close {
  position: absolute; top: 12px; right: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0;
  background: transparent; border: 1px solid transparent; color: var(--muted);
  font-size: 22px; line-height: 1; cursor: pointer; border-radius: var(--r-xs);
}
.modal-close:hover { color: var(--fg-strong); background: var(--surface-2); border-color: transparent; }
.session-body { margin-top: var(--sp-3); }
.session-title {
  margin: 0 0 3px; font-size: 1.4rem; font-weight: 800; letter-spacing: -0.02em;
}
.session-sub { margin: 0 0 var(--sp-5); color: var(--muted); }
/* Summed balance of the rows currently shown, sitting above the table. */
.table-total {
  display: flex; align-items: baseline; gap: var(--sp-2); flex-wrap: wrap;
  margin: 0 0 10px; padding: 9px 14px;
  border: 1px solid var(--border); border-left: 2px solid var(--clay);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: .9em; font-weight: 700; color: var(--fg-soft);
}
.table-total strong {
  font-size: 1.15em; letter-spacing: -0.01em; color: var(--clay);
}
/* The exact figure and its toggle sit at the far right, away from the summary. */
.table-total .muted { font-weight: 500; }
.table-total .total-exact {
  margin-left: auto; font-variant-numeric: tabular-nums;
  font-weight: 600; color: var(--fg-strong); font-family: var(--mono);
}
.table-total .total-toggle {
  margin-left: auto; padding: 3px 10px; border-radius: var(--r-xs);
  border: 1px solid var(--border); background: none; font-family: var(--mono);
  color: var(--muted); font-size: .85em; font-weight: 600; cursor: pointer;
}
/* Once the figure is showing it owns the auto margin, so the button hugs it. */
.table-total .total-exact:not([hidden]) + .total-toggle { margin-left: 0; }
.table-total .total-toggle:hover { color: var(--fg-strong); border-color: var(--line-strong); background: var(--surface-2); }

/* Optional "auto-flag by balance" rule inside the donut-check form. */
.bal-rule {
  margin: var(--sp-4) 0 4px; padding: 12px 14px 10px;
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
  background: var(--surface);
}
.bal-rule legend { padding: 0 6px; font-size: .85em; font-weight: 700; color: var(--fg-soft); }
.bal-rule-row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.bal-rule-row + .bal-rule-row { margin-top: var(--sp-2); }
.bal-rule-op { flex: 0 0 6.5em; font-weight: 600; color: var(--fg-soft); }
.bal-rule-row select { flex: 0 1 auto; min-width: 0; }
.bal-rule-row input { flex: 0 1 90px; min-width: 60px; }
.bal-rule-hint { display: block; margin-top: var(--sp-2); font-size: .8em; }

.session-steps { list-style: none; margin: 0; padding: 0; }
.session-step {
  display: flex; align-items: center; gap: var(--sp-3); padding: 11px 14px; margin-bottom: var(--sp-2);
  background: var(--surface-2); border-radius: var(--radius-sm); color: var(--fg-soft);
}
.session-step:last-child { margin-bottom: 0; }
.session-step .step-icon { width: 20px; text-align: center; font-weight: 700; flex: none; }
.session-step .step-label { min-width: 0; }
.session-step.is-done { border-color: var(--ok-line); background: var(--ok-soft); }
.session-step.is-done .step-icon { color: var(--ok); }
.session-step.is-failed { border-color: var(--danger-line); background: var(--danger-soft); }
.session-step.is-failed .step-icon { color: var(--danger); }
.session-step.is-running { border-color: var(--accent-line); background: var(--accent-soft); }
.session-step.is-running .step-icon { color: var(--accent); }
.session-step .step-detail { margin-left: auto; color: var(--danger-ink); font-size: 13px; }
.session-step .step-note { margin-left: auto; color: var(--muted); font-size: 13px; }
.spin, .session-step .spin, .locked-item .spin {
  display: inline-block; width: 13px; height: 13px; border: 2px solid var(--accent);
  border-top-color: transparent; border-radius: 50%; animation: session-spin 0.7s linear infinite;
}
@keyframes session-spin { to { transform: rotate(360deg); } }
.session-result { margin-top: var(--sp-5); }
.session-result.ok .token { width: 100%; }
.session-result .token-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-2); }
.session-result .token-head p { margin: 0; }
.session-result.error { color: var(--danger-ink); }

/* ============================ bulk get-sessions ============================ */
.bulk-actions { display: flex; gap: var(--sp-2); align-items: center; margin: 0 0 10px; flex-wrap: wrap; }
.bulk-actions .inline-form { margin: 0; }
.batch-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); margin-bottom: var(--sp-4); flex-wrap: wrap;
}
.batch-bar p { margin: 0; }
.batch-total { margin-top: 3px; font-size: 15px; }
.batch-bar-actions { display: flex; align-items: center; gap: var(--sp-2); }
.sb-setall { margin: 0; }
.sb-setall select, .sb-flag select {
  background: var(--sunken); color: var(--fg-soft); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 5px 8px; font-size: 13px;
}
.sb-balance { margin-left: auto; font-variant-numeric: tabular-nums; font-size: 13px; }
.sb-flag { margin: 0 0 0 8px; }
.session-batch-list { list-style: none; margin: 0; padding: 0; max-height: 60vh; overflow-y: auto; }
.session-batch-item {
  padding: 12px 14px; margin-bottom: var(--sp-2);
  background: var(--surface-2); border-radius: var(--radius-sm);
}
.sb-head { display: flex; align-items: center; gap: var(--sp-2); }
.sb-icon { width: 16px; display: inline-flex; justify-content: center; }
.sb-name { font-weight: 700; }
.sb-err { color: var(--danger-ink); font-size: 12px; margin-left: auto; }
.sb-token-row { display: flex; gap: var(--sp-2); align-items: flex-start; margin-top: var(--sp-2); }
.sb-token { flex: 1; }

/* ============================ locked / donut checker ============================ */
.locked-progress { margin-bottom: var(--sp-4); }
.locked-bar {
  height: 6px; background: rgba(255, 255, 255, 0.06);
  border-radius: var(--r-pill); overflow: hidden; margin-bottom: 6px;
}
.locked-bar span {
  display: block; height: 100%; background: var(--accent);
  transition: width 300ms var(--ease);
}
.locked-progress .ok { color: var(--ok); }
.locked-progress .locked { color: var(--warn); font-weight: 600; }
.locked-progress .err { color: var(--danger-ink); }
.locked-list { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow-y: auto; }
.locked-item {
  display: flex; align-items: center; gap: var(--sp-3); padding: 9px 12px;
  margin-bottom: 6px; background: var(--surface-2); border-radius: var(--radius-sm); color: var(--fg-soft);
}
.locked-item .item-icon { width: 20px; text-align: center; flex: none; font-weight: 700; }
.locked-item .item-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.locked-item .item-detail { margin-left: auto; font-size: 13px; color: var(--muted); }
.locked-item.is-ok .item-icon { color: var(--ok); }
.locked-item.is-locked, .locked-item.is-ip_locked {
  border-color: var(--warn-line); background: var(--warn-soft);
}
.locked-item.is-locked .item-icon { color: var(--danger); }
.locked-item.is-locked .item-detail,
.locked-item.is-ip_locked .item-icon, .locked-item.is-ip_locked .item-detail { color: var(--warn); }
.locked-item.is-error { border-color: var(--danger-line); background: var(--danger-soft); }
.locked-item.is-error .item-icon, .locked-item.is-error .item-detail { color: var(--danger); }
.tag.ip-locked {
  display: inline-block; margin-left: 6px; padding: 1px 8px;
  font-size: 11px; font-weight: 600; border-radius: var(--r-xs);
  background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-line);
  white-space: nowrap;
}
.locked-summary {
  margin-top: var(--sp-4); display: flex; align-items: center;
  justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap;
}
.locked-summary p { margin: 0; }

/* Wide tables scroll horizontally instead of overflowing the page. */
#accounts-live { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ============================ payment modal ============================ */
.pay-box { background: var(--surface-2); padding: 14px 16px; }
.pay-row {
  display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3);
  padding: 8px 0; border-bottom: 1px dashed var(--border); flex-wrap: wrap;
}
.pay-row:last-child { border-bottom: none; }
.pay-amount { font-family: var(--mono); font-size: 1.12rem; color: var(--clay); }
.pay-addr-row { align-items: flex-start; }
.pay-addr { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.pay-addr code {
  font-family: var(--mono); font-size: 13px;
  word-break: break-all; padding: 4px 8px;
  background: var(--sunken); border-radius: var(--r-xs); border: 1px solid var(--border);
}
.pay-hint { margin-top: var(--sp-3); display: flex; align-items: center; gap: var(--sp-2); }
.pay-warn { margin-top: 6px; font-size: 12px; }
.pay-status { padding: var(--sp-4); border-radius: var(--radius-sm); text-align: center; }
.pay-status.ok { background: var(--ok-soft); border: 1px solid var(--ok-line); color: var(--ok); }
.pay-status.err { background: var(--danger-soft); border: 1px solid var(--danger-line); color: var(--danger-ink); }
.pay-admin-row { display: flex; gap: var(--sp-6); margin-top: var(--sp-3); flex-wrap: wrap; }

/* ============================ responsive ============================ */
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky; top: 0; height: auto; flex-direction: row; align-items: center;
    gap: var(--sp-1); padding: 10px 12px; overflow-x: auto; z-index: 50;
  }
  .side-brand { padding: 0 8px 0 4px; }
  .brand-text { display: none; }
  .side-nav { flex-direction: row; flex: 1; overflow: visible; }
  .side-link span:not(.side-ic) { display: none; }
  .side-link { padding: 9px 10px; }
  .side-link.active::before { display: none; }
  .side-foot { border-top: none; padding-top: 0; margin-top: 0; }
  .side-user-info { display: none; }
  .main { padding: var(--sp-5) var(--sp-4) var(--sp-10); }
}

/* vault */
.vault-add { display: flex; gap: 10px; flex-wrap: wrap; }
.vault-add input { flex: 1; min-width: 160px; }
.vault-add-bar { margin-bottom: var(--sp-4); }
.vault-add-bar .primary { display: inline-flex; align-items: center; gap: var(--sp-2); }
.modal-overlay[hidden] { display: none; }
.vault-add-card .stack-form { max-width: none; }
.suffix-field { display: flex; align-items: stretch; }
.suffix-field input { flex: 1; min-width: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.suffix-tag {
  display: flex; align-items: center; padding: 0 var(--sp-3); color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border); border-left: none;
  border-top-right-radius: var(--radius-sm); border-bottom-right-radius: var(--radius-sm); white-space: nowrap;
}
.import-refresh {
  display: flex; align-items: flex-start; gap: var(--sp-2); margin: var(--sp-4) 0;
  color: var(--muted); font-size: .9rem; max-width: 620px; cursor: pointer;
}
.import-refresh input { margin-top: 3px; }
.vault-export-bar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; margin: var(--sp-3) 0 4px;
}
.vault-selall {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  color: var(--muted); font-size: .9rem; cursor: pointer;
}
.vault-export-btns { display: inline-flex; gap: var(--sp-2); flex-wrap: wrap; }
.vault-row { display: flex; align-items: center; gap: var(--sp-3); }
.vault-row .vault-sel { flex: none; width: 18px; height: 18px; cursor: pointer; }
.vault-row .vault-card { flex: 1; min-width: 0; }
.vault-card {
  display: flex; align-items: center; gap: var(--sp-3); padding: 13px 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.012));
  color: var(--fg);
  transition: border-color var(--t), background var(--t), transform var(--t) var(--ease);
}
.vault-card:hover {
  border-color: var(--accent-line); background: var(--surface-2);
  transform: translateY(-1px); color: var(--fg);
}
.vault-detail { display: grid; grid-template-columns: 220px 1fr; gap: var(--sp-5); align-items: start; }
.vault-content { min-width: 0; }
.vault-side { display: flex; flex-direction: column; gap: 10px; }
.vault-pane[hidden] { display: none; }
.vault-back {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
  padding: 7px 12px; border-radius: var(--radius-sm); background: var(--surface-2);
  border: 1px solid var(--border); color: var(--muted); font-size: .9rem; line-height: 1;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.vault-back:hover { color: var(--accent); border-color: var(--accent-line); background: var(--surface-3); }
.vault-side-title { font-size: 1.05rem; margin: 6px 0; overflow-wrap: anywhere; letter-spacing: -0.015em; font-family: var(--mono); }
.vault-subnav { display: flex; flex-direction: column; gap: 3px; }
.vault-tab {
  text-align: left; padding: 9px 12px; border-radius: var(--radius-sm);
  background: transparent; border: 1px solid transparent;
  color: var(--muted); cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.vault-tab:hover { color: var(--fg); background: var(--surface-2); }
.vault-tab.active {
  color: var(--accent); background: var(--accent-soft);
  border-color: var(--accent-line); font-weight: 600;
}
.vault-del { margin-top: var(--sp-2); }
.cred-grid { display: grid; gap: var(--sp-4); }
.cred-card { background: var(--surface); padding: 16px 18px; }
.cred-h { display: flex; align-items: center; gap: var(--sp-2); margin: 0 0 var(--sp-3); font-size: 1rem; }
.cred-h-ic { font-size: 1rem; line-height: 1; }
.cred-row { margin-bottom: var(--sp-3); }
.cred-row:last-child { margin-bottom: 0; }
.cred-label {
  display: block; font-family: var(--mono);
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .13em; color: var(--muted); margin-bottom: 5px;
}
.cred-field {
  display: flex; align-items: center; gap: var(--sp-2);
  background: var(--sunken); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 12px;
}
.cred-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cred-val {
  flex: 1; font-family: var(--mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cred-btn {
  flex: none; display: inline-flex; width: 30px; height: 30px; padding: 0;
  align-items: center; justify-content: center; border-radius: var(--r-xs);
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--muted); cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}
.cred-btn:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.cred-btn.copied { color: #7ee2a8; border-color: rgba(34, 197, 94, 0.4); }
.cred-btn svg {
  width: 15px; height: 15px; fill: none; stroke: currentColor;
  stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}
.vault-edit { margin-top: var(--sp-4); }
.vault-edit > summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.cred-notes { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--fg); }
.vault-inbox-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); }
/* live TOTP */
.totp-live { display: flex; align-items: center; gap: var(--sp-4); }
.totp-code {
  font-family: var(--mono); font-size: 1.95rem;
  letter-spacing: .18em; color: var(--accent);
}
.totp-ring { width: 42px; height: 42px; transform: rotate(-90deg); }
.totp-ring-bg { fill: none; stroke: var(--border); stroke-width: 3; }
.totp-ring-fg {
  fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round;
  stroke-dasharray: 100.5; transition: stroke-dashoffset 1s linear;
}
.totp-secs { color: var(--muted); font-variant-numeric: tabular-nums; font-family: var(--mono); }

@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .main { padding: var(--sp-4) var(--sp-3) var(--sp-10); }
  .vault-detail { grid-template-columns: 1fr; }

  /* Stack the pool header + make action buttons full-width & tappable. */
  .pool-head { flex-direction: column; align-items: stretch; }
  .pool-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
  .pool-actions .btn, .pool-actions button { width: 100%; }
  .pool-actions form { display: contents; }

  /* Keep the wide accounts table usable: let it scroll, shrink cells. */
  table.accounts { min-width: 680px; }
  table.data th, table.data td { padding: 9px 10px; }
  .row-actions .btn { min-width: 0; }

  /* Filters + inline forms stack full-width. */
  .filterbar { flex-direction: column; align-items: stretch; }
  .filterbar label, .filterbar input, .filterbar select, .filterbar button { width: 100%; }
  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form input, .inline-form select, .inline-form button { width: 100%; }

  /* Dashboard tiles: single column. */
  .pool-grid { grid-template-columns: 1fr; }

  /* Modals fill the screen comfortably. */
  .modal-card { padding: 20px 16px; width: 96vw; max-height: 92vh; border-radius: var(--r-lg); }
  .batch-bar { flex-direction: column; align-items: stretch; }
  .batch-bar-actions { justify-content: space-between; }

  /* Bulk actions + new-list popovers span the width. */
  .bulk-actions { flex-wrap: wrap; }
  .new-list-form, .rename-form { position: static; width: 100%; }
  .chat-msgs { height: 300px; }
  .backup-codes { grid-template-columns: 1fr; }
}

/* ============================ email / temp-mail ============================ */
.mail-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-2);
}
.mail-head p { margin: 5px 0 0; max-width: 640px; color: var(--muted); }
.mail-head code, .mailbox-addr code { font-family: var(--mono); font-size: .92em; }

/* claim bar */
.claim-card { padding: 16px 18px; }
.claim-row { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; margin: 0; }
.claim-field {
  flex: 1; min-width: 220px; display: flex; align-items: center; gap: 2px;
  flex-direction: row; background: var(--sunken);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 12px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.claim-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.claim-field input { flex: 1; min-width: 80px; border: none; background: none; padding: 11px 0; font-family: var(--mono); }
.claim-field input:focus { outline: none; box-shadow: none; }
.claim-suffix { color: var(--muted); font-weight: 600; white-space: nowrap; font-family: var(--mono); }

/* mailbox cards on /email */
.mailbox-list {
  list-style: none; margin: var(--sp-3) 0 0; padding: 0;
  display: grid; gap: var(--sp-3);
}
.mailbox {
  position: relative; overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.012));
  transition: border-color var(--t), background var(--t);
}
/* the clay spine reads as a sealed envelope edge */
.mailbox::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--clay); opacity: 0.35; transition: opacity var(--t); z-index: 1;
}
.mailbox:hover { border-color: var(--accent-line); background: var(--surface-2); }
.mailbox:hover::before, .mailbox[open]::before { opacity: 1; }
.mailbox-summary {
  position: relative; display: flex; align-items: center; gap: var(--sp-3);
  padding: 14px 58px 14px 18px; cursor: pointer; list-style: none; user-select: none;
}
.mailbox-summary::-webkit-details-marker { display: none; }
.mailbox-summary:hover .mailbox-chev { color: var(--accent); }
.mailbox-del-form { position: absolute; top: 12px; right: 14px; margin: 0; z-index: 2; }
.mailbox-body { padding: 6px 18px 16px; border-top: 1px solid var(--glass-border); }
.mailbox-loading { color: var(--muted); font-size: 13px; padding: 14px 2px; }
.mailbox[open] .mailbox-chev { transform: rotate(90deg); color: var(--accent); }
.mailbox-icon {
  width: 42px; height: 42px; border-radius: var(--radius-sm); flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--clay-soft); color: var(--clay);
  box-shadow: inset 0 0 0 1px var(--clay-line);
}
.mailbox-icon svg {
  width: 21px; height: 21px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.mailbox-main { min-width: 0; flex: 1; }
.mailbox-addr {
  font-weight: 700; font-size: 14.5px; display: block; font-family: var(--mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mailbox-sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; display: flex; align-items: center; gap: 6px; }
.count-pill {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px;
  height: 20px; padding: 0 7px; border-radius: var(--r-xs);
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-line);
}
.mailbox-copy {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0; border-radius: var(--radius-sm); line-height: 1;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.mailbox-copy:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.mailbox-copy svg {
  width: 16px; height: 16px; fill: none; stroke: currentColor;
  stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}
.mailbox-copy .ic-check { display: none; }
.mailbox-copy.copied { background: rgba(34, 197, 94, 0.16); color: #7ee2a8; border-color: rgba(34, 197, 94, 0.4); }
.mailbox-copy.copied .ic-copy { display: none; }
.mailbox-copy.copied .ic-check { display: inline; }
.mailbox-chev {
  flex: none; color: var(--muted); display: inline-flex;
  transition: transform 200ms var(--ease), color var(--t-fast);
}
.mailbox-chev svg {
  width: 18px; height: 18px; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.mailbox-del {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0; border-radius: var(--radius-sm); line-height: 1;
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.mailbox-del svg {
  width: 18px; height: 18px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.mailbox-del:hover { background: var(--danger-soft); color: var(--danger-ink); border-color: var(--danger-line); }
.mailbox-empty, .mail-empty {
  list-style: none; padding: 52px 20px; text-align: center; color: var(--muted);
  border: 1px dashed var(--glass-border); border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.01);
}
.mailbox-empty-ic, .mail-empty-ic {
  width: 42px; height: 42px; fill: none; stroke: var(--muted-2);
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; opacity: .8;
}
.mailbox-empty p, .mail-empty p { margin: var(--sp-3) 0 0; }
.btn-ic {
  width: 16px; height: 16px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

/* inbox header + message rows */
.inbox-head { display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: 6px; }
.inbox-title { min-width: 0; }
.inbox-title h1 { font-size: clamp(1.3rem, 1.15rem + 0.7vw, 1.6rem); overflow-wrap: anywhere; }
.inbox-title h1 .muted { font-weight: 700; }
.inbox-count { color: var(--muted); font-size: 13px; }

.maillist { list-style: none; margin: var(--sp-4) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.mailrow {
  border-radius: var(--radius-sm);
  transition: border-color var(--t-fast), transform var(--t-fast) var(--ease), background var(--t-fast);
}
.mailrow:hover {
  border-color: var(--accent-line); transform: translateX(2px); background: var(--surface-2);
}
.mailrow-link { display: flex; align-items: center; gap: var(--sp-4); padding: 12px 16px; color: var(--fg); min-width: 0; }
.mailrow-link:hover { color: var(--fg); }
.mail-ava {
  width: 40px; height: 40px; border-radius: var(--r-xs); flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--accent); font-weight: 700;
  text-transform: uppercase; font-family: var(--mono);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}
.mailrow-main { min-width: 0; flex: 1; }
.mailrow-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.mailrow-from { font-weight: 700; color: var(--fg-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mailrow-time { color: var(--muted); font-size: 12px; white-space: nowrap; flex: none; font-family: var(--mono); }
.mailrow-subject { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.mailrow-snippet {
  display: block; color: var(--muted); font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px;
}
.mail-empty { padding: 52px 20px; margin-top: var(--sp-4); }

/* single-message reading view */
.msg-card { margin-top: var(--sp-4); }
.msg-head {
  display: flex; align-items: center; gap: var(--sp-4); padding-bottom: var(--sp-4);
  margin-bottom: var(--sp-4); border-bottom: 1px solid var(--border);
}
.msg-headmain { min-width: 0; flex: 1; }
.msg-from { font-weight: 700; color: var(--fg-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 14px; }
.msg-meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.msg-del { margin: 0; flex: none; }
/* email bodies read as letters — the one place a serif is used */
.msg-body {
  white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; margin: 0;
  background: var(--sunken); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: var(--sp-5);
  font-family: var(--reader); font-size: 15.5px; line-height: 1.66; color: var(--fg);
}
.mail-text { color: var(--fg-soft); white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--reader); font-size: 15px; line-height: 1.66; }
.msg-html { margin-top: var(--sp-4); }
.msg-html > summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.msg-attach { margin-top: var(--sp-5); }
.msg-attach h3 { margin: 0 0 10px; }
.attach-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.attach-item {
  display: inline-flex; align-items: center; gap: var(--sp-2); padding: 9px 13px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--fg);
  transition: border-color var(--t-fast), background var(--t-fast);
}
.attach-item:hover { border-color: var(--accent-line); background: var(--surface-3); color: var(--fg); }
.attach-name { font-weight: 600; }
.attach-size { color: var(--muted); font-size: 12px; font-family: var(--mono); }

/* inbox refresh footer */
.maillist-foot { display: flex; align-items: center; gap: var(--sp-3); margin-top: var(--sp-4); flex-wrap: wrap; }
.refresh-btn { display: inline-flex; align-items: center; gap: 7px; }
.refresh-ic {
  width: 15px; height: 15px; fill: none; stroke: currentColor;
  stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}
.refresh-btn.htmx-request .refresh-ic { animation: spin 0.7s linear infinite; }
.js-inbox.htmx-request { opacity: .6; transition: opacity var(--t-fast); }
.maillist-hint { font-size: 12px; color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }

/* pop-in message modal */
.msg-modal { max-width: 720px; width: 100%; }
.msg-modal-subject {
  margin: 0 34px var(--sp-4) 0; font-size: clamp(1.18rem, 1.05rem + 0.5vw, 1.36rem);
  letter-spacing: -0.02em; overflow-wrap: anywhere;
}
.msg-modal .msg-body { max-height: 46vh; overflow: auto; }
.msg-modal-foot { margin-top: var(--sp-5); display: flex; justify-content: flex-end; }
.msg-modal-foot form { margin: 0; }

@media (max-width: 640px) {
  .claim-row { flex-direction: column; align-items: stretch; }
  .claim-row .primary, .claim-row .btn { width: 100%; }
  .mailbox-chev { display: none; }
}

/* --- wallet page --- */
.stack-form { display: flex; flex-direction: column; gap: .8rem; max-width: 480px; }
.stack-form label { display: flex; flex-direction: column; gap: .3rem; }
.stack-form button { align-self: flex-start; }

/* --- games / flappy --- */
.games-head { margin-bottom: var(--sp-4); }
.games-kicker {
  margin: 0 0 5px; font-family: var(--mono);
  font-size: 10.5px; font-weight: 600; letter-spacing: .2em;
  text-transform: uppercase; color: var(--clay);
}
.games-head h1 { margin-bottom: 6px; }
.games-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: var(--sp-5); align-items: start;
}
.games-play { padding: 10px; }
.games-admin {
  display: flex; align-items: center; gap: var(--sp-5); flex-wrap: wrap; padding: 4px 8px 10px;
}
.games-hotkey kbd {
  display: inline-block; min-width: 1.2em; padding: 1px 6px;
  border: 1px solid var(--border); border-radius: var(--r-xs);
  background: var(--surface-2); font: 600 11px var(--mono);
}
.ap-toggle { display: flex; align-items: center; gap: var(--sp-3); cursor: pointer; user-select: none; }
.ap-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.ap-switch {
  width: 40px; height: 22px; border-radius: var(--r-pill); flex: none;
  background: var(--surface-2); border: 1px solid var(--border); position: relative;
  transition: background var(--t), border-color var(--t);
}
.ap-switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%; background: var(--muted);
  transition: transform var(--t) var(--ease), background var(--t);
}
.ap-toggle input:checked + .ap-switch { background: var(--accent); border-color: transparent; }
.ap-toggle input:checked + .ap-switch::after { transform: translateX(18px); background: var(--accent-ink); }
.ap-toggle input:focus-visible + .ap-switch { outline: 2px solid var(--ring); outline-offset: 2px; }
.ap-copy { display: flex; flex-direction: column; line-height: 1.25; }
.ap-copy strong { font-size: 13px; }
.game-stage {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  min-height: 580px; height: min(74vh, 760px);
}
.game-stage iframe { width: 100%; height: 100%; border: 0; display: block; background: var(--bg); }
.games-board { padding: 18px 16px 16px; }
.board-head h2 { margin: 0 0 4px; }
.board-sub { margin: 0 0 var(--sp-4); font-size: 13px; }
.switch { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.switch button {
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
  border-radius: var(--r-xs); padding: 6px 11px; font-weight: 600; font-size: 12px;
  font-family: var(--mono); letter-spacing: .06em; text-transform: uppercase;
  cursor: pointer;
  transition: color var(--t-fast), background var(--t-fast), border-color var(--t-fast);
}
.switch button:hover { color: var(--fg); border-color: var(--accent-line); background: var(--surface-3); }
.switch button.is-on { color: var(--accent-ink); background: var(--accent); border-color: transparent; }

.podium {
  display: grid; grid-template-columns: 1fr 1.12fr 1fr; align-items: end;
  gap: var(--sp-2); margin: var(--sp-4) 0 var(--sp-4);
}
.podium-card {
  position: relative; display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 14px 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  min-height: 168px;
}
.podium-card.place-1 {
  min-height: 196px; padding-top: 20px;
  background: linear-gradient(180deg, rgba(240, 165, 82, 0.12), var(--surface));
  border-color: rgba(240, 165, 82, 0.35);
}
.podium-card.place-2 { border-color: rgba(148, 163, 184, 0.28); }
.podium-card.place-3 { border-color: rgba(240, 165, 82, 0.24); }
.podium-card.is-empty { opacity: .55; }
.podium-card.is-you { outline: 1px solid var(--accent-line); }
.podium-trophy {
  position: relative; width: 44px; height: 44px; border-radius: var(--r-sm);
  display: grid; place-items: center; margin-bottom: var(--sp-2);
}
.place-1 .podium-trophy { background: var(--clay); color: #2a1704; }
.place-2 .podium-trophy { background: #94a3b8; color: #111827; }
.place-3 .podium-trophy { background: #e07a3c; color: #2a1704; }
.podium-trophy svg {
  width: 22px; height: 22px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round;
}
.podium-badge {
  position: absolute; top: -7px; right: -8px;
  background: var(--surface-solid); color: var(--fg); border-radius: var(--r-xs);
  font-family: var(--mono); font-size: 9px; font-weight: 700; letter-spacing: .06em;
  padding: 2px 5px; text-transform: uppercase;
}
.place-1 .podium-badge { background: var(--clay); color: #2a1704; }
.place-2 .podium-badge { background: #cbd5e1; color: #0f172a; }
.place-3 .podium-badge { background: #e07a3c; color: #2a1704; }
.podium-name {
  margin: var(--sp-2) 0 0; font-weight: 700; font-size: 13px; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.podium-label {
  margin: 2px 0 0; font-family: var(--mono);
  font-size: 10px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted);
}
.podium-score { margin: var(--sp-2) 0 0; width: 100%; border-radius: var(--radius-sm); padding: 7px 6px; font-weight: 800; font-variant-numeric: tabular-nums; }
.place-1 .podium-score { background: var(--clay); color: #2a1704; }
.place-2 .podium-score { background: #64748b; color: #f8fafc; }
.place-3 .podium-score { background: var(--clay-2); color: #2a1704; }
.podium-ghost { background: var(--surface-2) !important; color: var(--muted) !important; }

.lb-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.lb-table th {
  text-align: left; color: var(--muted); font-family: var(--mono);
  font-size: 10.5px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  padding: 8px 10px; border-bottom: 1px solid var(--glass-border);
}
.lb-table th:last-child, .lb-table td:last-child { text-align: right; }
.lb-table td { padding: 10px; border-bottom: 1px solid var(--sep); }
.lb-table tr:last-child td { border-bottom: 0; }
.lb-table tbody tr { transition: background var(--t-fast); }
.lb-table tbody tr:hover td { background: rgba(255, 255, 255, 0.026); }
.lb-table tr.is-you { background: var(--accent-soft); }
.lb-rank { color: var(--muted); font-weight: 700; width: 42px; }
.lb-player { display: flex; align-items: center; gap: var(--sp-2); font-weight: 700; }
.lb-player .avatar, .lb-player .avatar-fallback { flex: none; }
.lb-score { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--clay); }
.flappy-empty { color: var(--muted); text-align: center; padding: 18px 8px 6px; margin: 0; }
@media (max-width: 1040px) {
  .games-layout { grid-template-columns: 1fr; }
  .game-stage { min-height: 500px; }
}

/* ── Bots ──────────────────────────────────────────────────────────── */
.bot-type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(258px, 1fr)); gap: var(--sp-4); }
.bot-type { display: flex; flex-direction: column; gap: 10px; padding: var(--sp-4); transition: border-color var(--t), transform var(--t) var(--ease); }
.bot-type:hover { border-color: var(--accent-line); transform: translateY(-2px); }
.bot-type.disabled { opacity: .55; }
.bot-type-ic {
  width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); background: var(--accent-soft);
}
.bot-type-ic svg {
  width: 21px; height: 21px; fill: none; stroke: var(--accent);
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.bot-type h3 { margin: 0 0 4px; }
.bot-type-body { flex: 1; color: var(--muted); font-size: 13.5px; }
.bot-type .btn { align-self: flex-start; }

.bot-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.bot-row {
  display: flex; align-items: center; gap: var(--sp-3); padding: 12px 14px;
  text-decoration: none; color: inherit;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.bot-row:hover { background: var(--surface-2); border-color: var(--accent-line); }
.bot-row-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.bot-dot { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.bot-dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.bot-dot.warn { background: var(--warn); box-shadow: 0 0 8px var(--warn); }

.banner { padding: 12px 14px; border-radius: var(--radius-sm); margin: 0 0 var(--sp-4); border: 1px solid var(--border); }
.banner-error { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger-ink); }
.bot-dot.off { background: var(--muted-2); }

.recip-coin { margin-bottom: var(--sp-5); }
.recip-coin h3 { margin: 0 0 6px; }
.recip-list { list-style: none; padding: 0; margin: 0 0 6px; display: flex; flex-direction: column; gap: 6px; }
.recip-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--surface-2); border-radius: var(--radius-sm); }
.recip-label { font-weight: 600; min-width: 6rem; }
.recip-addr {
  font-family: var(--mono); color: var(--muted);
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.recip-avatar { width: 26px; height: 26px; border-radius: var(--r-xs); flex: none; object-fit: cover; }
.recip-avatar-blank { background: var(--surface-2); border: 1px solid var(--border); }

.range-tabs { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.range-tab {
  padding: 4px 10px; border: 1px solid var(--border); border-radius: var(--r-xs);
  background: var(--surface); color: var(--muted); font-size: .8rem;
  font-family: var(--mono); cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.range-tab:hover { background: var(--surface-2); color: var(--fg); }
.range-tab.active {
  background: var(--accent); color: var(--accent-ink);
  border-color: transparent; font-weight: 700;
}
.lb-user { display: inline-flex; align-items: center; gap: var(--sp-2); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(146px, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-2); }
.stat { padding: var(--sp-4); display: flex; flex-direction: column; gap: 4px; }
.stat-num { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em; color: var(--fg-strong); font-family: var(--mono); }

.spark { display: flex; align-items: flex-end; gap: 4px; height: 90px; padding: 8px 0; }
.spark-bar { flex: 1; min-height: 2px; background: var(--accent); border-radius: 2px 2px 0 0; opacity: .85; }

.mini-table { width: 100%; border-collapse: collapse; margin-top: 4px; }
.mini-table th, .mini-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--sep); }
.mini-table th { color: var(--muted); font-weight: 600; font-size: .85rem; }
.mini-table tr:last-child td { border-bottom: none; }
.email-status { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.email-status li { display: flex; align-items: center; gap: var(--sp-2); color: var(--fg-soft); }
.email-status .ok { color: var(--ok); }
.email-status .err { color: var(--danger-ink); }

/* ── Bot analytics terminal ──────────────────────────────────────── */
.mkt-terminal { padding: 18px 20px 16px; font-variant-numeric: tabular-nums; }
.mkt-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-4);
}
.mkt-sym-row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.mkt-kicker { font-family: var(--mono); font-size: 10px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.mkt-sym { font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; color: var(--fg); }
.mkt-chip, .mkt-live, .mkt-idle {
  font-family: var(--mono);
  font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  padding: 2px 7px; border-radius: var(--r-xs);
  border: 1px solid var(--border); color: var(--muted);
}
.mkt-live { color: #06251a; background: var(--ok); border-color: transparent; }
.mkt-idle { color: var(--muted); }
.mkt-ticker { display: flex; align-items: baseline; gap: var(--sp-3); flex-wrap: wrap; margin-top: 4px; }
.mkt-px {
  font-size: 2.1rem; font-weight: 700; letter-spacing: -.04em; line-height: 1.1;
  font-family: var(--mono);
}
.mkt-chg { font-family: var(--mono); font-weight: 700; font-size: 1rem; }
.mkt-chg-abs { margin-left: 8px; font-weight: 600; opacity: .85; }
.mkt-up .mkt-chg { color: var(--ok); }
.mkt-down .mkt-chg { color: var(--danger); }
.mkt-flat .mkt-chg { color: var(--muted); }
.mkt-sub { margin: 6px 0 0; color: var(--muted); font-size: 12px; }

.mkt-ranges {
  display: inline-flex; gap: 0; border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden; background: var(--sunken);
}
.mkt-ranges .range-tab {
  border: 0; border-radius: 0; border-right: 1px solid var(--border);
  background: transparent; color: var(--muted); padding: 7px 12px;
  font-size: 11px; font-weight: 600; letter-spacing: .08em;
}
.mkt-ranges .range-tab:last-child { border-right: 0; }
.mkt-ranges .range-tab:hover { background: var(--surface-2); color: var(--fg); }
.mkt-ranges .range-tab.active { background: var(--surface-3); color: var(--fg); border-color: var(--border); }

.mkt-kpis {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px; background: var(--border); border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden; margin-bottom: var(--sp-3);
}
.mkt-kpi { background: var(--bg-2); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mkt-kpi-l {
  font-family: var(--mono);
  font-size: 10px; font-weight: 600; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted);
}
.mkt-kpi-v {
  font-family: var(--mono);
  font-weight: 700; font-size: 1.02rem; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.mkt-kpi-s { font-size: 11px; color: var(--muted); }

.mkt-plot { position: relative; height: 280px; margin: 4px 0 var(--sp-2); background: rgba(0, 0, 0, 0.2); }
.mkt-svg {
  position: absolute; left: 48px; right: 56px; top: 10px; bottom: 26px;
  width: calc(100% - 104px); height: calc(100% - 36px); overflow: visible;
}
.mkt-y { position: absolute; left: 0; top: 10px; bottom: 26px; width: 46px; pointer-events: none; }
.mkt-y span {
  position: absolute; right: 6px; transform: translateY(-50%);
  font-size: 10px; color: var(--muted); font-family: var(--mono);
}
.mkt-x { position: absolute; left: 48px; right: 56px; bottom: 6px; height: 16px; pointer-events: none; }
.mkt-x span {
  position: absolute; transform: translateX(-50%);
  font-size: 10px; color: var(--muted); font-family: var(--mono);
}
.mkt-overlay { position: absolute; left: 48px; right: 8px; top: 10px; bottom: 26px; pointer-events: none; }
.mkt-ltag {
  position: absolute; right: 0; transform: translateY(-50%);
  font-family: var(--mono);
  font-size: 10px; font-weight: 700; color: #150a2b;
  background: var(--accent); padding: 2px 6px; border-radius: 2px;
  z-index: 2;
}
.mkt-up .mkt-ltag { background: var(--ok); color: #06251a; }
.mkt-down .mkt-ltag { background: var(--danger); color: #2a0b09; }
.mkt-cols { position: absolute; left: 48px; right: 56px; top: 10px; bottom: 26px; }
.mkt-col { position: absolute; top: 0; bottom: 0; }
.mkt-col:hover { background: rgba(255, 255, 255, 0.04); }
.mkt-tip {
  display: none; position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  background: var(--surface-solid); border: 1px solid var(--glass-border); color: var(--fg);
  font-family: var(--mono);
  font-size: 11px; font-weight: 600; padding: 4px 8px; border-radius: var(--r-xs);
  white-space: nowrap; z-index: 3; box-shadow: var(--elev-3); pointer-events: none;
}
.mkt-col:hover .mkt-tip { display: block; }
.mkt-col:first-child .mkt-tip { left: 0; transform: none; }
.mkt-col:last-child .mkt-tip { left: auto; right: 0; transform: none; }

.mkt-sectors { margin: 4px 0 var(--sp-4); }
.mkt-stack { display: flex; height: 6px; border-radius: var(--r-pill); overflow: hidden; background: rgba(255, 255, 255, 0.05); }
.mkt-stack i { display: block; height: 100%; }
.mkt-legend { list-style: none; padding: 0; margin: var(--sp-2) 0 0; display: flex; flex-wrap: wrap; gap: 10px 16px; }
.mkt-legend li { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.mkt-legend i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.mkt-legend b { color: var(--fg); font-weight: 700; font-family: var(--mono); }

.mkt-board { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .95fr); gap: var(--sp-4); }
.mkt-panel { min-width: 0; padding: 10px 12px 8px; background: rgba(0, 0, 0, 0.18); }
.mkt-panel-h {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--sp-2); margin-bottom: 6px;
}
.mkt-panel-h h3 { margin: 0; font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; }
.mkt-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mkt-table th {
  text-align: left; color: var(--muted); font-family: var(--mono);
  font-size: 10px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  padding: 6px 8px; border-bottom: 1px solid var(--glass-border);
}
.mkt-table td { padding: 8px; border-bottom: 1px solid var(--sep); vertical-align: middle; }
.mkt-table tr:last-child td { border-bottom: 0; }
.mkt-table tr:hover td { background: rgba(255, 255, 255, 0.024); }
.mkt-rank { width: 28px; color: var(--muted); font-weight: 700; }
.mkt-num { font-family: var(--mono); white-space: nowrap; }
.mkt-usd { font-weight: 700; }
.mkt-tape .mkt-usd { color: var(--ok); }
.mkt-table th.mkt-r, .mkt-table td.mkt-num { text-align: right; }
.mkt-name { font-weight: 600; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mkt-depth {
  display: block; height: 3px; margin-top: 5px; border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.06); overflow: hidden;
}
.mkt-depth i { display: block; height: 100%; background: var(--accent); border-radius: var(--r-pill); }
.mkt-up .mkt-depth i { background: var(--ok); }
.mkt-down .mkt-depth i { background: var(--danger); }
.mkt-tape { max-height: 340px; overflow: auto; }
.mkt-empty { color: var(--muted); text-align: center; padding: 22px 8px; margin: 0; }
.mkt-sessions { margin-top: var(--sp-4); }

@media (max-width: 840px) {
  .mkt-px { font-size: 1.6rem; }
  .mkt-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mkt-plot { height: 220px; }
  .mkt-board { grid-template-columns: 1fr; }
  .mkt-svg, .mkt-cols, .mkt-x, .mkt-overlay { right: 12px; }
  .mkt-svg { width: calc(100% - 60px); }
  .mkt-ltag { display: none; }
}

/* ── Order macro (live grid) ─────────────────────────────────────── */
.order-macro-grid { display: flex; flex-direction: column; gap: var(--sp-3); }
.om-aggregate {
  display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap;
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 13.5px; color: var(--fg-soft);
}
.om-aggregate strong { color: var(--fg-strong); font-variant-numeric: tabular-nums; }
.om-aggregate button { margin-left: auto; }
.om-console {
  padding: 0; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); overflow: hidden;
}
.om-console.is-running, .om-console.is-starting { border-color: var(--accent-line); }
.om-console.is-paused { border-color: var(--warn-line); }
.om-console-head {
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); font-size: 13px;
}
.om-console-head strong { color: var(--fg-strong); }
.om-console-head button { margin-left: auto; }
.om-log {
  margin: 0; padding: 12px; font-size: 12px; line-height: 1.6;
  font-family: var(--mono);
  color: var(--fg-soft); background: var(--sunken);
}
.om-lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--sp-4); }
.om-lists h4 {
  margin: 0 0 6px; font-family: var(--mono);
  font-size: 10.5px; font-weight: 600;
  letter-spacing: .13em; text-transform: uppercase;
}
.om-summary {
  display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap;
  padding: 12px 14px; border-radius: var(--radius);
  background: var(--ok-soft); border: 1px solid var(--ok-line);
}
.om-summary p { margin: 0; flex: 1; min-width: 180px; }
.om-summary .btn { margin-left: auto; }
.om-summary .err { color: var(--danger-ink); }

@media (max-width: 640px) {
  .om-aggregate { gap: var(--sp-2); }
  .om-aggregate button, .om-summary .btn { margin-left: 0; width: 100%; }
}

/* ── Small shared pieces ──────────────────────────────────────────── */
.attach-ic { font-size: 15px; line-height: 1; }
.rowsel { cursor: pointer; }
.vault-add-form .primary { align-self: stretch; }

/* ============================ motion & print ============================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .bg-stars { animation: none; }
}