/* ---------- Tokens · XPKeep brand (see docs/BRAND.md) ---------- */
:root {
  color-scheme: dark;
  /* Brand - sampled from the logo, cyan highlight -> core blue -> violet */
  --brand-cyan: #74c0fd;
  --brand-sky: #519cfd;
  --brand-blue: #3b68fc;
  --brand-indigo: #5c67fd;
  --brand-violet: #8269fc;
  --brand-gradient: linear-gradient(135deg, #5aa8fd 0%, #3b68fc 48%, #8269fc 100%);
  --brand-glow: 0 8px 28px -10px rgba(76, 96, 252, .65);
  /* Surfaces - the logo's deep navy */
  --bg: #080a1a;
  --sidebar: #060715;
  --surface: #0e1126;
  --surface-2: #151935;
  --hover: #13172f;
  --line: #1d2244;
  --line-strong: #2b3260;
  /* Text */
  --ink: #eef0ff;
  --ink-2: #a7aed3;
  --ink-3: #6d739c;
  /* Accent (interactive) */
  --accent: #5466fd;
  --accent-hover: #6878ff;
  --accent-soft: rgba(84, 102, 253, .16);
  --accent-ink: #a9b5ff;
  /* Status */
  --green: #34c77b;  --green-soft: rgba(52, 199, 123, .14);  --green-ink: #6ee7a8;
  --amber: #f5a524;  --amber-soft: rgba(245, 165, 36, .13);  --amber-ink: #fbcb73;
  --red: #f04452;    --red-soft: rgba(240, 68, 82, .14);     --red-ink: #ff8b94;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  --r: 8px;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14.5px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.35rem; font-weight: 650; letter-spacing: -0.015em; margin: 0; line-height: 1.3; }
h2 { font-size: .95rem; font-weight: 600; margin: 0 0 14px; }
p { margin: 0 0 12px; }
code, .mono { font-family: var(--mono); font-size: .92em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--ink-3); }
.small { font-size: .85rem; }
.empty { color: var(--ink-3); text-align: center; padding: 56px 20px; margin: 0; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--sidebar); border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; gap: 14px; position: sticky; top: 0; height: 100vh; overflow-x: hidden; overflow-y: auto; min-width: 0; }
.main { padding: 28px 32px 64px; max-width: 1180px; width: 100%; }

.logo { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 650; font-size: .98rem; padding: 4px 6px; }
.logo:hover { text-decoration: none; }
.logo-mark { display: block; height: 22px; width: auto; flex: none; filter: drop-shadow(0 2px 8px rgba(76, 96, 252, .45)); }
.logo-word { display: block; height: 15px; width: auto; }
.logo-center .logo-mark { height: 38px; }
.logo-center .logo-word { height: 26px; }
.logo-tag { margin-left: auto; font-size: .7rem; font-weight: 600; color: var(--ink-3); background: var(--surface-2); padding: 2px 7px; border-radius: 5px; }

.side-account { display: flex; align-items: center; gap: 10px; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); min-width: 0; }
.side-account-addr { font-family: var(--mono); font-size: .8rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-cta { margin: 0; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; color: var(--ink-2); font-size: .93rem; width: 100%; }
.side-link:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.side-link.active { background: var(--accent-soft); color: var(--ink); }
.side-link.active .side-icon { color: var(--accent-ink); }
.side-icon { display: grid; place-items: center; color: var(--ink-3); }
.side-label { flex: 1; text-align: left; }
.side-count { font-size: .75rem; font-weight: 600; color: var(--ink-2); background: var(--surface-2); border-radius: 999px; padding: 1px 8px; }
.side-link.active .side-count { background: var(--accent); color: #fff; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.side-foot form { margin: 0; }
.side-button { background: none; border: 0; font: inherit; cursor: pointer; }
.side-status { display: flex; align-items: center; gap: 8px; font-size: .82rem; padding: 10px; border-radius: var(--r); }
.side-status.is-locked { background: var(--green-soft); color: var(--green-ink); }
.side-status.is-open { background: var(--amber-soft); color: var(--amber-ink); }

/* ---------- Auth (signed out) ---------- */
.auth-shell { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 64px 16px; }
.logo-center { margin-bottom: 28px; font-size: 1.05rem; }
.auth-shell > main { width: 100%; max-width: 400px; }
.auth { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 28px; }
.auth h1 { font-size: 1.3rem; margin-bottom: 6px; }
.auth .lead { color: var(--ink-2); margin-bottom: 22px; }
.auth form { margin-bottom: 18px; }
.auth .foot { font-size: .84rem; color: var(--ink-3); margin: 0; }

/* ---------- Page head ---------- */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head form { margin: 0; }
.crumb { display: inline-flex; font-size: .85rem; color: var(--ink-3); margin-bottom: 10px; }
.crumb:hover { color: var(--ink); text-decoration: none; }
.address-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.address-line .addr { font-family: var(--mono); font-size: 1.05rem; color: var(--ink); word-break: break-all; }
.addr .domain { color: var(--ink-3); }
.head-meta { display: flex; gap: 14px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar form { margin: 0; }

/* ---------- Panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 20px; margin-bottom: 16px; }
.panel.flush { padding: 0; overflow-x: auto; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; }
.panel-head form { margin: 0; }

/* ---------- Forms ---------- */
label { display: block; font-size: .85rem; font-weight: 550; color: var(--ink-2); margin-bottom: 14px; }
.hint { font-weight: 400; color: var(--ink-3); }
input, select, textarea {
  display: block; width: 100%; margin-top: 6px; font: inherit; font-size: .94rem; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: 6px; padding: 9px 11px;
}
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[readonly], textarea[readonly] { background: var(--surface-2); }
textarea { resize: vertical; line-height: 1.5; }
.form-narrow { max-width: 440px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.affix { display: flex; margin-top: 6px; }
.affix input { margin: 0; border-radius: 6px 0 0 6px; font-family: var(--mono); }
.affix span { display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 6px 6px 0; background: var(--surface-2); color: var(--ink-3); font-family: var(--mono); font-size: .88rem; }
.search { position: relative; display: flex; align-items: center; }
.search-icon { position: absolute; left: 11px; color: var(--ink-3); display: grid; pointer-events: none; }
.search input { margin: 0; width: 280px; padding-left: 34px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-size: .9rem; font-weight: 550; line-height: 1.2; white-space: nowrap; cursor: pointer;
  padding: 9px 15px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink);
}
.btn:hover { background: var(--hover); border-color: var(--ink-3); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #c9373a; border-color: #c9373a; }
.btn-quiet { background: transparent; border-color: transparent; color: var(--ink-2); padding-left: 8px; padding-right: 8px; }
.btn-quiet:hover { background: var(--hover); border-color: transparent; color: var(--ink); }
.btn-quiet.danger { color: var(--red-ink); }
.btn-sm { padding: 5px 10px; font-size: .83rem; }
.btn-block { width: 100%; }

/* ---------- Notices + status ---------- */
.notice { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-radius: var(--r); padding: 12px 16px; margin-bottom: 16px; border: 1px solid transparent; }
.notice p { margin: 0; }
.notice strong { font-weight: 600; }
.notice-ok { background: var(--green-soft); border-color: rgba(59, 165, 93, .3); color: var(--green-ink); }
.notice-warn { background: var(--amber-soft); border-color: rgba(240, 160, 32, .3); color: var(--amber-ink); }
.notice-error { background: var(--red-soft); border-color: rgba(237, 66, 69, .3); color: var(--red-ink); }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 550; padding: 2px 9px 2px 8px; border-radius: 999px; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-sold { background: var(--amber-soft); color: var(--amber-ink); }
.status-locked { background: var(--green-soft); color: var(--green-ink); }
.status-off { background: var(--red-soft); color: var(--red-ink); }
.pill { display: inline-block; font-size: .72rem; font-weight: 650; padding: 1px 7px; border-radius: 999px; }
.pill-new { background: var(--accent); color: #fff; }

/* ---------- Avatars ---------- */
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; flex: none; font-size: .9rem; font-weight: 650; color: #fff; background: #4e5566; }
.avatar-sm { width: 28px; height: 28px; font-size: .78rem; }
.avatar-lg { width: 42px; height: 42px; font-size: 1rem; }
.avatar[data-hue="0"] { background: #5865f2; }
.avatar[data-hue="1"] { background: #e8414a; }
.avatar[data-hue="2"] { background: #2d9b5a; }
.avatar[data-hue="3"] { background: #d97a17; }
.avatar[data-hue="4"] { background: #9b51e0; }
.avatar[data-hue="5"] { background: #0f8fb8; }
.avatar[data-hue="6"] { background: #c2397a; }
.avatar[data-hue="7"] { background: #5f6b7d; }

/* ---------- Mail list ---------- */
.mail-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--line); color: var(--ink-2); position: relative; }
.mail-row:last-child { border-bottom: 0; }
.mail-row:hover { background: var(--hover); text-decoration: none; }
.mail-text { display: flex; flex-direction: column; min-width: 0; }
.mail-row .from, .mail-row .subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-row .from { color: var(--ink); font-size: .93rem; }
.mail-row .subject { font-size: .87rem; }
.mail-row time { font-size: .8rem; color: var(--ink-3); white-space: nowrap; }
.mail-row.unread .from { font-weight: 650; }
.mail-row.unread .subject { color: var(--ink); }
.mail-row.unread::before { content: ""; position: absolute; left: 6px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--accent); }
.mail-row.unread time { color: var(--accent-ink); font-weight: 600; }
.live { display: inline-flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--ink-3); }
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }

/* ---------- Reader ---------- */
.reader { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 22px; }
.msg-subject { font-size: 1.3rem; margin-bottom: 18px; word-break: break-word; }
.msg-from { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; }
.msg-from-text { min-width: 0; word-break: break-all; }
.mail-frame { display: block; width: 100%; height: 66vh; min-height: 380px; border: 0; border-radius: var(--r); background: #fff; }
.msg-att { margin: 12px 0 0; }
.msg-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.msg-toolbar .crumb { margin: 0; }
.msg-toolbar form { margin: 0; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: 12px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.table th { font-size: .75rem; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--hover); }
.table .addr { font-family: var(--mono); font-size: .88rem; color: var(--ink); }
.table .num { font-family: var(--mono); font-size: .86rem; color: var(--ink-2); }
.table time { color: var(--ink-3); font-size: .85rem; white-space: nowrap; }
.table-log { width: 100%; border-collapse: collapse; }
.table-log td { padding: 10px 0; font-size: .86rem; border-top: 1px solid var(--line); vertical-align: top; color: var(--ink-2); }
.table-log tr:first-child td { border-top: 0; padding-top: 0; }
.table-log td:first-child { width: 112px; padding-right: 12px; }
.table-log time { color: var(--ink-3); font-size: .82rem; }
.table-log tr.by-admin td:nth-child(2) { color: var(--amber-ink); }

/* ---------- Mailbox detail ---------- */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: start; }
.kv { display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; gap: 10px 12px; align-items: center; margin: 0 0 16px; }
.kv dt { color: var(--ink-3); font-size: .85rem; }
.kv dd { margin: 0; font-family: var(--mono); font-size: .93rem; word-break: break-all; }
.kv dd input { margin: 0; padding: 0; border: 0; background: transparent; font: inherit; color: inherit; box-shadow: none; }
.kv .acts { display: flex; gap: 2px; }
.secret { letter-spacing: .04em; }
.handover { font-family: var(--mono); font-size: .83rem; line-height: 1.6; }
.side .panel { padding: 18px; }
.action-list { list-style: none; margin: 0; padding: 0; }
.action-list li { padding: 14px 0; border-top: 1px solid var(--line); }
.action-list li:first-child { border-top: 0; padding-top: 0; }
.action-list .desc { display: block; font-size: .82rem; color: var(--ink-3); margin: 3px 0 10px; }
.action-list form { margin: 0; }
.confirm-row { display: flex; gap: 6px; }
.confirm-row input { margin: 0; font-family: var(--mono); }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .side-account, .side-status, .logo-tag { display: none; }
  .side-cta { width: auto; order: 3; }
  .side-nav { flex-direction: row; overflow-x: auto; width: 100%; order: 4; scrollbar-width: none; }
  .side-nav::-webkit-scrollbar { display: none; }
  .side-link { width: auto; white-space: nowrap; }
  .side-foot { margin: 0 0 0 auto; }
  .side-foot .side-label { display: none; }
  .main { padding: 20px 16px 48px; }
  .grid-2 { grid-template-columns: 1fr; }
  .search, .search input { width: 100%; }
  .table th:nth-child(n+4), .table td:nth-child(n+4) { display: none; }
  .kv { grid-template-columns: 1fr auto; }
  .kv dt { grid-column: 1 / -1; margin-bottom: -6px; }
}

/* ---------- Motion ---------- */
a, .btn, .side-link, .mail-row, .code-chip, input, select, textarea { transition: background-color .12s ease, border-color .12s ease, color .12s ease, box-shadow .12s ease, opacity .12s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.mail-row.is-new { animation: rise .35s ease both; background: var(--accent-soft); }
.btn.is-busy { opacity: .6; cursor: progress; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Mail rows: overlay link + code chip ---------- */
.mail-row .row-link { position: absolute; inset: 0; z-index: 0; border-radius: inherit; }
.mail-row .row-link:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.mail-row > :not(.row-link) { position: relative; z-index: 1; pointer-events: none; }
.mail-row > .code-chip { pointer-events: auto; }
.mail-row { grid-template-columns: auto minmax(0, 1fr) auto auto; }
.code-chip { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: .85rem; font-weight: 600; letter-spacing: .06em;
  color: var(--accent-ink); background: var(--accent-soft); border: 1px solid rgba(88, 101, 242, .35); border-radius: 6px; padding: 4px 9px; cursor: pointer; }
.code-chip:hover { background: rgba(88, 101, 242, .26); border-color: var(--accent); }
.code-chip.copied { color: var(--green-ink); background: var(--green-soft); border-color: rgba(59, 165, 93, .45); }
.code-chip-lg { margin-left: auto; font-size: 1rem; padding: 8px 14px; }
.btn.copied { color: var(--green-ink); }

/* ---------- Live state ---------- */
.live[data-state="error"] { color: var(--amber-ink); }
.live[data-state="error"]::before { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }

/* ---------- Dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; color: var(--ink-3); font-size: .8rem; }
a.stat:hover { border-color: var(--line-strong); background: var(--hover); text-decoration: none; }
.stat-n { font-size: 1.6rem; font-weight: 700; color: var(--ink); letter-spacing: -0.02em; line-height: 1.1; }
.health { display: flex; gap: 12px; align-items: flex-start; border-radius: 10px; padding: 12px 16px; margin-bottom: 18px; font-size: .9rem; border: 1px solid var(--line); background: var(--surface); }
.health svg { flex: none; margin-top: 2px; }
.health-ok svg { color: var(--green-ink); }
.health-off, .health-pending { color: var(--ink-2); }
.health-error, .health-stale { border-color: rgba(240, 160, 32, .35); background: var(--amber-soft); color: var(--amber-ink); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters select { width: auto; margin: 0; min-width: 150px; }
.pager { display: flex; justify-content: space-between; align-items: center; margin: -4px 0 16px; }
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 9px 14px; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--accent); }

/* ---------- Forms extras ---------- */
.panel-accent { border-color: rgba(88, 101, 242, .35); box-shadow: inset 3px 0 0 var(--accent); }
details summary { cursor: pointer; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: "›"; display: inline-block; width: 14px; color: var(--ink-3); transition: transform .12s ease; }
details[open] summary::before { transform: rotate(90deg); }
details[open] summary { margin-bottom: 12px; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
label.check input { width: auto; margin: 0; accent-color: var(--accent); }
.meta-list { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--line); font-size: .85rem; }
.meta-list dt { color: var(--ink-3); }
.meta-list dd { margin: 0; }
.choice-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 14px 0 16px; }
.choice { position: relative; display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--bg); cursor: pointer; }
.choice:hover { border-color: var(--ink-3); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.choice-title { color: var(--ink); font-weight: 600; font-size: .92rem; }
.choice-sub { color: var(--ink-3); font-weight: 400; font-size: .78rem; }

/* ---------- Claim (first sign-in) ---------- */
.claim { max-width: 460px; margin: 40px auto; text-align: left; }
.claim-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; background: var(--accent-soft); color: var(--accent-ink); margin-bottom: 18px; }
.claim h1 { font-size: 1.5rem; margin-bottom: 8px; }
.claim .lead { color: var(--ink-2); margin-bottom: 22px; }

@media (max-width: 1100px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters select { flex: 1; }
  .mail-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .mail-row > .code-chip { grid-column: 2 / 3; justify-self: start; }
  .msg-from { flex-wrap: wrap; }
  .code-chip-lg { margin-left: 0; }
}
.meta-list-top { margin: 0 0 18px; padding-top: 0; border-top: 0; }
.qr-box { display: flex; justify-content: center; margin: 4px 0 16px; }
.qr { width: 216px; height: 216px; padding: 0; border-radius: 12px; overflow: hidden; background: #fff; display: grid; place-items: center; box-shadow: 0 0 0 1px var(--line-strong); }
.qr svg { width: 100%; height: 100%; display: block; }
.qr-manual { margin-bottom: 18px; }
.qr-manual .kv { margin-top: 12px; }

/* ======================= V2 components ======================= */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.text-amber { color: var(--amber-ink); }
.panel { box-shadow: 0 1px 0 rgba(255,255,255,.02) inset, 0 8px 24px -16px rgba(0,0,0,.6); }
.panel-title-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.panel-title-row h2 { margin: 0; }
.panel-success { border-color: rgba(59, 165, 93, .4); box-shadow: inset 3px 0 0 var(--green); }
.panel-success h2 { display: flex; align-items: center; gap: 8px; color: var(--green-ink); }
.panel-accent h2 { display: flex; align-items: center; gap: 8px; }
.addr-lg { font-size: 1.25rem !important; font-weight: 600; }
.chip { font-size: .78rem; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; }

/* Sidebar */
.side-group { margin: 2px 0 6px 14px; padding-left: 8px; border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.side-group .side-link { font-size: .88rem; padding: 6px 10px; }
.side-health { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--ink-2); padding: 8px 10px; border-radius: 6px; background: var(--surface); border: 1px solid var(--line); }
.side-health:hover { text-decoration: none; border-color: var(--line-strong); }
.side-health .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
.side-health-ok .dot { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.side-health-unverified .dot, .side-health-stale .dot, .side-health-pending .dot { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.side-health-error .dot, .side-health-off .dot { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }

/* Dashboard */
.stat { position: relative; overflow: hidden; }
.stat-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent-soft); color: var(--accent-ink); margin-bottom: 4px; }
.stat-amber .stat-icon { background: var(--amber-soft); color: var(--amber-ink); }
.stat-green .stat-icon { background: var(--green-soft); color: var(--green-ink); }
a.stat:hover { transform: translateY(-1px); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quick { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); color: var(--ink); font-size: .88rem; font-weight: 550; }
.quick:hover { border-color: var(--accent); background: var(--accent-soft); text-decoration: none; }
.quick-icon { color: var(--accent-ink); display: grid; }
.quarantine-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); color: var(--ink-2); font-size: .88rem; }
.quarantine-row span:first-child { display: flex; align-items: center; gap: 8px; }
.quarantine-row:hover { border-color: var(--line-strong); background: var(--hover); text-decoration: none; }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.mini-list li:first-child { border-top: 0; padding-top: 0; }
.mini-list a { display: flex; flex-direction: column; color: var(--ink); min-width: 0; }
.mini-list a:hover { text-decoration: none; color: var(--accent-ink); }

/* Accounts list */
.segmented { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.segmented a { padding: 6px 12px; border-radius: 6px; color: var(--ink-2); font-size: .86rem; }
.segmented a span { color: var(--ink-3); font-size: .78rem; margin-left: 4px; }
.segmented a:hover { color: var(--ink); text-decoration: none; background: var(--hover); }
.segmented a.active { background: var(--surface-2); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.4); }
.table-wrap { overflow-x: auto; }
.table .col-check { width: 36px; padding-right: 0; }
.table .col-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.table .col-actions { width: 1%; text-align: right; white-space: nowrap; }
.table-accounts tbody tr:has(input:checked) { background: var(--accent-soft); }
.icon-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 6px; border: 1px solid transparent; background: transparent; color: var(--ink-3); cursor: pointer; }
.icon-btn:hover { color: var(--ink); background: var(--surface-2); border-color: var(--line); text-decoration: none; }
.icon-btn.copied { color: var(--green-ink); }
.col-actions form { display: inline; margin: 0; }
.bulk-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 18px; background: var(--accent-soft); border-bottom: 1px solid rgba(88,101,242,.35); font-size: .88rem; }
.bulk-bar[hidden] { display: none; }
.bulk-edit { position: relative; }
.bulk-edit summary { list-style: none; }
.bulk-edit summary::before { content: none; }
.bulk-edit-body { position: absolute; z-index: 5; top: calc(100% + 6px); left: 0; width: 320px; padding: 14px; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: 0 16px 40px -12px rgba(0,0,0,.7); }
.bulk-field { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 4px 8px; font-weight: 500; }
.bulk-field input[type=checkbox] { width: auto; margin: 0; accent-color: var(--accent); }
.bulk-field input:not([type=checkbox]) { grid-column: 1 / -1; margin-top: 2px; }
.pager .active-size { color: var(--ink); font-weight: 650; }

/* Empty + loading states */
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 48px 20px; color: var(--ink-3); }
.empty-state svg { color: var(--ink-3); opacity: .8; margin-bottom: 4px; }
.empty-state p { margin: 0; color: var(--ink); font-weight: 600; }
.empty-state .btn { margin-top: 10px; }
.btn.is-busy::after { content: ""; width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Diagnostics */
.checklist { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); }
.checklist li.is-ok svg { color: var(--green-ink); }
.checklist li.is-fail { border-color: rgba(237,66,69,.35); }
.checklist li.is-fail svg { color: var(--red-ink); }
.checklist svg { flex: none; margin-top: 2px; }
.probe-details { margin-top: 14px; }
.steps { margin: 0; padding-left: 18px; color: var(--ink-2); display: flex; flex-direction: column; gap: 6px; }
.claim-icon-warn { background: var(--amber-soft); color: var(--amber-ink); }

/* Customer: latest code hero */
.code-hero { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 18px 20px; margin-bottom: 16px;
  border-radius: 12px; border: 1px solid rgba(88,101,242,.4); background: linear-gradient(135deg, rgba(88,101,242,.18), rgba(88,101,242,.04)); }
.code-hero-label { font-size: .8rem; color: var(--ink-2); }
.code-hero-from { display: flex; align-items: center; gap: 10px; }
.code-hero .code-value { font-family: var(--mono); font-size: 1.9rem; font-weight: 700; letter-spacing: .14em; color: #fff; line-height: 1.1; }
.code-hero .btn { padding: 11px 18px; }

/* Toast */
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 50; display: flex; align-items: center; gap: 10px; max-width: 360px;
  padding: 12px 16px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--ink);
  box-shadow: 0 20px 40px -12px rgba(0,0,0,.7); animation: rise .25s ease both; font-size: .9rem; }
.toast svg { color: var(--accent-ink); flex: none; }

@media (max-width: 1100px) { .dash-grid { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .side-group { flex-direction: row; margin: 0; padding: 0; border: 0; }
  .side-health { display: none; }
  .bulk-edit-body { width: calc(100vw - 48px); }
  .table-accounts th:nth-child(n+4), .table-accounts td:nth-child(n+4) { display: none; }
  .table-accounts td.col-actions, .table-accounts th.col-actions { display: table-cell; }
  .code-hero .code-value { font-size: 1.6rem; }
  .code-hero .btn { width: 100%; }
  .toast { left: 16px; right: 16px; max-width: none; }
}

/* ======================= Brand polish (XPKeep identity) ======================= */
::selection { background: rgba(84, 102, 253, .35); }
h1 { letter-spacing: -0.02em; }

/* Buttons: primary carries the logo gradient + soft glow */
.btn { border-radius: 8px; transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .15s ease, filter .15s ease; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand-gradient); border-color: transparent; color: #fff; box-shadow: var(--brand-glow), inset 0 1px 0 rgba(255,255,255,.18); }
.btn-primary:hover { background: var(--brand-gradient); border-color: transparent; filter: brightness(1.12); box-shadow: 0 10px 30px -10px rgba(76, 96, 252, .85), inset 0 1px 0 rgba(255,255,255,.22); }
.btn-primary[disabled] { filter: grayscale(.5); box-shadow: none; }
.btn:not(.btn-primary):not(.btn-quiet):not(.btn-danger) { background: var(--surface-2); border-color: var(--line-strong); }
.btn:not(.btn-primary):not(.btn-quiet):not(.btn-danger):hover { border-color: rgba(116, 140, 253, .55); background: #1a1f40; }

/* Sidebar: deep navy, gradient edge, active indicator */
.sidebar { background: linear-gradient(180deg, #070820 0%, var(--sidebar) 60%); border-right-color: var(--line); }
.logo { gap: 9px; padding: 6px 6px 10px; }
.side-link { position: relative; }
.side-link.active { background: linear-gradient(90deg, rgba(84, 102, 253, .22), rgba(130, 105, 252, .08)); }
.side-link.active::before { content: ""; position: absolute; left: -12px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand-gradient); }
.side-count { background: rgba(167, 174, 211, .1); }
.side-link.active .side-count { background: var(--brand-gradient); }
.logo-tag { background: rgba(84, 102, 253, .14); color: var(--accent-ink); border: 1px solid rgba(84, 102, 253, .3); }

/* Cards: hairline gradient edge on top, quiet depth */
.panel, .stat, .reader { background: linear-gradient(180deg, rgba(255,255,255,.018), transparent 40%), var(--surface); border-color: var(--line); }
.panel { box-shadow: inset 0 1px 0 rgba(255,255,255,.03), 0 12px 32px -20px rgba(0, 0, 0, .8); }
.stat { border-radius: 12px; }
.stat::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px; background: linear-gradient(90deg, transparent, rgba(116, 140, 253, .45), transparent); opacity: .7; }
a.stat:hover { border-color: rgba(116, 140, 253, .4); background: linear-gradient(180deg, rgba(84, 102, 253, .08), transparent 60%), var(--surface); }
.stat-icon { background: rgba(84, 102, 253, .16); }
.panel-accent { border-color: rgba(84, 102, 253, .4); box-shadow: inset 3px 0 0 var(--brand-blue), 0 12px 32px -20px rgba(0,0,0,.8); }

/* Badges: one consistent pill style */
.status { border: 1px solid transparent; letter-spacing: .01em; }
.status-stock { background: rgba(167, 174, 211, .1); color: var(--ink-2); border-color: rgba(167, 174, 211, .16); }
.status-sold { border-color: rgba(245, 165, 36, .3); }
.status-locked { border-color: rgba(52, 199, 123, .3); }
.status-off { border-color: rgba(240, 68, 82, .3); }
.pill-new { background: var(--brand-gradient); }
.chip { background: rgba(167, 174, 211, .07); border-color: var(--line); }
.code-chip { border-color: rgba(116, 140, 253, .4); }
.code-hero { border-color: rgba(116, 140, 253, .45); background:
  radial-gradient(120% 140% at 0% 0%, rgba(116, 192, 253, .16), transparent 55%),
  radial-gradient(120% 140% at 100% 100%, rgba(130, 105, 252, .18), transparent 55%), var(--surface); }
.code-hero .code-value { background: linear-gradient(90deg, #ffffff, #c9d2ff); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Inputs */
input, select, textarea { background: #090b1d; border-color: var(--line-strong); }
input:focus, select:focus, textarea:focus { border-color: var(--brand-indigo); box-shadow: 0 0 0 3px rgba(84, 102, 253, .22); }

/* Auth screens: brand backdrop */
.auth-shell { background: radial-gradient(70% 55% at 50% 0%, rgba(84, 102, 253, .2), transparent 72%), var(--bg); background-attachment: fixed; }
.logo-center { flex-direction: row; gap: 12px; margin-bottom: 32px; }
.auth { border-radius: 16px; box-shadow: 0 30px 60px -30px rgba(0, 0, 0, .9), inset 0 1px 0 rgba(255,255,255,.04); }
.claim-icon { background: linear-gradient(135deg, rgba(116, 192, 253, .18), rgba(130, 105, 252, .22)); color: #c9d2ff; }

/* Empty states: brand tile icon */
.empty-state svg { width: 44px; height: 44px; padding: 11px; border-radius: 12px; color: var(--accent-ink); opacity: 1;
  background: linear-gradient(135deg, rgba(116, 192, 253, .12), rgba(130, 105, 252, .16)); border: 1px solid rgba(116, 140, 253, .25); }

/* Loading: shimmer while a mail body loads, spinner on busy buttons */
@keyframes shimmer { to { background-position: -200% 0; } }
.mail-frame.is-loading { background: linear-gradient(90deg, #f3f4fb 0%, #e6e8f5 40%, #f3f4fb 80%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.skeleton { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), #1c2145, var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }

/* Toast + notices in brand colours */
.toast { border-color: rgba(116, 140, 253, .4); background: linear-gradient(180deg, #161b3a, #11152c); }
.notice-ok { background: rgba(52, 199, 123, .1); }

@media (max-width: 760px) {
  .side-link.active::before { display: none; }
  .logo-word { height: 13px; }
  .logo-mark { height: 19px; }
}
