/* Mail Desk in the look of the E. Market console (proxy-console/public: tokens.css, app.css).
   Colors only as tokens: light on :root, dark via [data-theme="dark"] (set by /theme.js before
   the first paint) or prefers-color-scheme for pages without that script. Geist and Geist Mono
   as in the console, self-hosted (CSP default-src 'self'): public/fonts, SIL OFL 1.1 (OFL.txt).
   Deliberate deviations from the console are marked "deviation:" below:
   - the inbox grid gives the live feed 2.3fr (the console 1.5fr for its map) and stacks at 1280px;
   - the drawer title is sans (a mail subject), not mono;
   - without /theme.js (every page loads it) the CSS alone falls back to light, the console to dark. */

@font-face {
  font-family: "Geist";
  src: url("/fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("/fonts/GeistMono-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ------------------------------------------------------------------ tokens: light */
:root {
  color-scheme: light;
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Consolas, Menlo, monospace;
  --r-lg: 20px; --r-md: 14px; --r-sm: 10px;
  --drawer-w: 520px;
  /* surfaces */
  --bg: #efeff1; --frame: #fafafa; --card: #ffffff; --card2: #f7f7f8; --card3: #fafafa; --hover: #f1f1f3;
  --active: #ececef; --sel-bg: #f4f4f5; --row-hover: #f7f7f8; --row-open: #f1f1f3; --row-new: #fffaeb;
  --drawer: #ffffff; --scrim: #18181b59; --shadow: #0000001f;
  /* lines */
  --line: #e3e3e7; --line2: #e9e9ec; --line3: #dadade; --line-strong: #c4c4cb; --sep: #c4c4cb;
  /* text */
  --text: #171717; --text-soft: #3f3f46; --text-dim: #52525b; --muted: #5c5c64; --faint: #6e6e76;
  --focus: #71717a; --focus-ring: #0000000d;
  /* states: red only for attention */
  --red: #c8281c; --red-bg: #fef3f2; --red-line: #fecdca; --red-text: #b42318; --red-glow: #c8281c55;
  --amber: #b45309; --amber-bg: #fffaeb; --amber-line: #fedf89;
  --green: #15803d; --green-bg: #f0fdf4; --green-line: #bbf7d0;
  --blue: #1d4ed8; --blue-bg: #eff6ff; --blue-line: #bfdbfe;
  --discord: #5865f2; --discord-hover: #4752c4; --discord-text: #ffffff;
  /* brand E. Market */
  --mark-bg: #0a0a0a; --mark-fg: #ffffff; --paper: #f3f2f0; --deco: #e8e7e5;
  --ok: #27272a; --alert-text: #7a4f4a;
  /* pills, dots, bars */
  --pill: #f4f4f5; --pill-line: #e4e4e7; --dot: #a1a1aa; --track: #ececef; --fill: #3f3f46; --spark: #8b8b93;
  /* buttons and fields */
  --btn-bg: #171717; --btn-text: #ffffff; --btn-hover: #000000;
  --ghost-bg: #ffffff; --ghost-line: #dadade; --ghost-hover: #f4f4f5;
  --seg-bg: #f1f1f3; --seg-on: #ffffff;
  --field: #ffffff; --field-line: #8d8d95;
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235c5c64' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  --toast-bg: #171717; --toast-text: #fafafa; --toast-err-bg: #fef3f2;
  --frame-bg: #ffffff; /* mail HTML is written for white */
  --qr-bg: #ffffff; /* QR codes scan best dark on white, in both themes */
}

/* ------------------------------------------------------------------ tokens: dark */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #08080a; --frame: #0b0b0d; --card: #111113; --card2: #161619; --card3: #131316; --hover: #1b1b1f;
    --active: #18181b; --sel-bg: #17171a; --row-hover: #151518; --row-open: #18181b; --row-new: #1d160b;
    --drawer: #0e0e10; --scrim: #000000aa; --shadow: #00000099;
    --line: #222226; --line2: #19191c; --line3: #2c2c31; --line-strong: #3a3a41; --sep: #3b3b42;
    --text: #ececee; --text-soft: #cfcfd4; --text-dim: #bdbdc3; --muted: #8d8d95; --faint: #84848d;
    --focus: #6e6e78; --focus-ring: #ffffff10;
    --red: #ff5c4d; --red-bg: #1c100f; --red-line: #4b211d; --red-text: #ffb3aa; --red-glow: #ff5c4d88;
    --amber: #f0a540; --amber-bg: #1d160b; --amber-line: #4a3514;
    --green: #4ade80; --green-bg: #0c1a12; --green-line: #1c3a26;
    --blue: #60a5fa; --blue-bg: #0b1526; --blue-line: #1e3a5f;
    --mark-bg: #f2f2f4; --mark-fg: #0a0a0a; --paper: #0b0b0d; --deco: #141417;
    --ok: #e9e9ec; --alert-text: #b9a9a7;
    --pill: #1d1d21; --pill-line: #29292e; --dot: #6b6b74; --track: #26262b; --fill: #d8d8dd; --spark: #6c6c74;
    --btn-bg: #f2f2f4; --btn-text: #0b0b0d; --btn-hover: #ffffff;
    --ghost-bg: #18181b; --ghost-line: #2a2a2f; --ghost-hover: #202024;
    --seg-bg: #111113; --seg-on: #202024;
    --field: #161619; --field-line: #63636b;
    --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238d8d95' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    --toast-bg: #f2f2f4; --toast-text: #0b0b0d; --toast-err-bg: #2a1311;
    --qr-bg: #ffffff;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #08080a; --frame: #0b0b0d; --card: #111113; --card2: #161619; --card3: #131316; --hover: #1b1b1f;
  --active: #18181b; --sel-bg: #17171a; --row-hover: #151518; --row-open: #18181b; --row-new: #1d160b;
  --drawer: #0e0e10; --scrim: #000000aa; --shadow: #00000099;
  --line: #222226; --line2: #19191c; --line3: #2c2c31; --line-strong: #3a3a41; --sep: #3b3b42;
  --text: #ececee; --text-soft: #cfcfd4; --text-dim: #bdbdc3; --muted: #8d8d95; --faint: #84848d;
  --focus: #6e6e78; --focus-ring: #ffffff10;
  --red: #ff5c4d; --red-bg: #1c100f; --red-line: #4b211d; --red-text: #ffb3aa; --red-glow: #ff5c4d88;
  --amber: #f0a540; --amber-bg: #1d160b; --amber-line: #4a3514;
  --green: #4ade80; --green-bg: #0c1a12; --green-line: #1c3a26;
  --blue: #60a5fa; --blue-bg: #0b1526; --blue-line: #1e3a5f;
  --mark-bg: #f2f2f4; --mark-fg: #0a0a0a; --paper: #0b0b0d; --deco: #141417;
  --ok: #e9e9ec; --alert-text: #b9a9a7;
  --pill: #1d1d21; --pill-line: #29292e; --dot: #6b6b74; --track: #26262b; --fill: #d8d8dd; --spark: #6c6c74;
  --btn-bg: #f2f2f4; --btn-text: #0b0b0d; --btn-hover: #ffffff;
  --ghost-bg: #18181b; --ghost-line: #2a2a2f; --ghost-hover: #202024;
  --seg-bg: #111113; --seg-on: #202024;
  --field: #161619; --field-line: #63636b;
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238d8d95' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  --toast-bg: #f2f2f4; --toast-text: #0b0b0d; --toast-err-bg: #2a1311;
  --qr-bg: #ffffff;
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { background: var(--bg); color: var(--text); }
body {
  margin: 0;
  padding: 16px;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
p { margin: 0; }
a { color: inherit; }
code, .mono { font-family: var(--mono); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[tabindex="-1"]:focus { outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 24px; top: -64px; z-index: 80; background: var(--btn-bg); color: var(--btn-text); padding: 10px 16px; border-radius: 12px; font-weight: 600; text-decoration: none; }
.skip:focus { top: 12px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.red { color: var(--red); }
.small { font-size: 12.5px; }
.ellipsis { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clip-fallback { position: fixed; top: -1000px; left: 0; opacity: 0; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* thin scrollbars in lists, tables, drawer and dialogs */
.side, .tblwrap, .drawer-body, .scroll-box, dialog, textarea { scrollbar-width: thin; scrollbar-color: var(--line3) transparent; }

/* ------------------------------------------------------------------ buttons and fields */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 36px; padding: 7px 16px;
  background: var(--ghost-bg); color: var(--text);
  border: 1px solid var(--ghost-line); border-radius: 999px;
  font-weight: 500; text-decoration: none; white-space: nowrap; cursor: pointer;
}
.btn:hover { background: var(--ghost-hover); }
.btn svg.i { width: 16px; height: 16px; }
.btn-primary { padding: 9px 18px; background: var(--btn-bg); color: var(--btn-text); border: 0; font-weight: 600; border-radius: 14px; }
.btn-primary:hover { background: var(--btn-hover); }
.btn-sm { min-height: 28px; padding: 4px 12px; font-size: 12.5px; }
.btn-ghost { background: none; border-color: transparent; }
.btn-ghost:hover { background: var(--hover); }
.btn-block { display: flex; width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: default; }
.btn-discord { background: var(--discord); border-color: var(--discord); color: var(--discord-text); font-weight: 600; border-radius: 10px; min-height: 44px; }
.btn-discord:hover { background: var(--discord-hover); border-color: var(--discord-hover); }
.btn-discord svg { width: 20px; height: 20px; flex: none; }

.iconbtn { position: relative; display: grid; place-items: center; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 10px; }
.iconbtn:hover { color: var(--text); background: var(--hover); }
.iconbtn svg.i { width: 20px; height: 20px; }
.theme-btn svg { display: none; }
.theme-btn[data-mode="system"] .t-system, .theme-btn[data-mode="light"] .t-light, .theme-btn[data-mode="dark"] .t-dark { display: block; }
.lang-btn { min-width: 32px; }
.lang-btn .lang-text { font: 600 11px/1 var(--sans); letter-spacing: .03em; }
.foot .lang-btn { min-width: 0; }
.foot .lang-btn .lang-text { font-size: 9px; }

.x { flex: none; display: grid; place-items: center; width: 32px; height: 32px; padding: 0; background: none; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); cursor: pointer; }
.x:hover { color: var(--text); background: var(--hover); }
.x svg.i { width: 16px; height: 16px; }
.x-sm { display: grid; place-items: center; width: 22px; height: 22px; padding: 0; background: none; border: 0; border-radius: 999px; color: var(--muted); cursor: pointer; }
.x-sm:hover { color: var(--text); background: var(--hover); }
.x-sm svg.i { width: 13px; height: 13px; }

.link-like { padding: 0; border: 0; background: none; color: var(--text); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; cursor: pointer; text-align: left; font: inherit; overflow-wrap: anywhere; }
.link-like:hover { text-decoration-color: currentColor; }

.sel, .field-in,
input[type="text"], input[type="search"], input[type="datetime-local"], input:not([type]), select, textarea {
  min-height: 36px; padding: 7px 12px; min-width: 0;
  background: var(--field); color: var(--text);
  border: 1px solid var(--field-line); border-radius: 12px;
}
select, .sel { appearance: none; -webkit-appearance: none; padding-right: 34px; background-image: var(--chev); background-repeat: no-repeat; background-position: right 12px center; cursor: pointer; }
.sel { padding: 9px 34px 9px 14px; border-radius: 14px; background-color: var(--card); }
textarea { min-height: 96px; padding: 10px 12px; resize: vertical; font-family: var(--mono); font-size: 12.5px; line-height: 1.5; background: var(--card3); }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--focus-ring), 0 0 0 1px var(--focus); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; white-space: nowrap; cursor: pointer; font-size: 13.5px; }
.check input { margin: 0; width: 16px; height: 16px; accent-color: var(--text); }

/* segmented control: buttons (range) or radios (feed state) */
.seg { display: inline-flex; margin: 0; padding: 4px; min-width: 0; background: var(--seg-bg); border: 1px solid var(--line); border-radius: 14px; }
.seg button, .seg span { display: inline-flex; align-items: center; min-height: 28px; padding: 6px 14px; border: 0; border-radius: 10px; background: none; color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg button:hover, .seg label:hover span { color: var(--text); }
.seg button[aria-pressed="true"], .seg input:checked + span { background: var(--seg-on); color: var(--text); box-shadow: inset 0 0 0 1px var(--line3); }
.seg label { position: relative; display: inline-flex; }
.seg input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: -2px; }
.seg-sm { padding: 2px; border-radius: 10px; }
.seg-sm button { min-height: 24px; padding: 2px 10px; font-size: 12.5px; border-radius: 8px; }

/* inline tags: status, match, unmatched, verified sender */
.badge { display: inline-flex; align-items: center; gap: 6px; flex: none; padding: 1px 9px; border-radius: 999px; font-size: 11.5px; line-height: 1.6; white-space: nowrap; background: var(--pill); color: var(--text); border: 1px solid var(--pill-line); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--dot); flex: none; }
.badge.plain::before { display: none; }
.st-available::before { background: var(--green); }
.st-disabled { color: var(--muted); }
.b-shared::before { background: var(--blue); }
.b-manual::before { background: var(--text-soft); }
.b-unmatched { color: var(--red); border-color: var(--red-line); background: var(--red-bg); }
.b-unmatched::before { background: var(--red); }
.b-warn { color: var(--amber); border-color: var(--amber-line); background: var(--amber-bg); }
.b-warn::before { background: var(--amber); }
.b-owner::before { background: var(--text); }
.b-verified { color: var(--green); border-color: var(--green-line); background: var(--green-bg); }
.b-verified::before { background: var(--green); }
.b-unverified { color: var(--amber); border-color: var(--amber-line); background: var(--amber-bg); }
.b-unverified::before { background: var(--amber); }
.b-unchecked { color: var(--muted); }
/* mail category on feed rows: orders stand out, sign-ups stay quiet; other mails get none */
.b-order { color: var(--blue); border-color: var(--blue-line); background: var(--blue-bg); }
.b-order::before { background: var(--blue); }
.b-account::before { background: var(--text-dim); }
/* stack count and tag labels: quiet, no dot (class "plain") */
.b-stack { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.b-tag { color: var(--text-soft); background: var(--card2); border-color: var(--line3); }
.row-tags { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.stack-accts { margin-top: 3px; }

/* filter chip (account filter on the feed) */
.chip-filter { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; max-width: 100%; padding: 4px 6px 4px 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--sel-bg); font-size: 13px; }
.chip-filter strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* ------------------------------------------------------------------ app frame */
/* overflow:clip, not hidden: hidden makes .app the scroll container and the sidebar stops sticking */
.app { max-width: 1600px; margin: 0 auto; display: grid; grid-template-columns: 268px minmax(0, 1fr); background: var(--frame); border: 1px solid var(--line2); border-radius: 24px; overflow: hidden; overflow: clip; min-height: calc(100vh - 32px); }

/* sidebar */
.side { position: sticky; top: 16px; align-self: start; height: calc(100vh - 32px); overflow-y: auto; display: flex; flex-direction: column; gap: 22px; min-width: 0; padding: 18px 14px; }
.team { display: flex; align-items: center; gap: 12px; padding: 6px 8px; }
.emark { display: block; flex: none; width: 36px; height: 36px; }
.emark rect { fill: var(--mark-bg); }
.emark path { fill: var(--mark-fg); }
.team .wm { display: block; font-weight: 500; font-size: 17px; line-height: 1.2; letter-spacing: -.02em; }
.team small { color: var(--muted); font-size: 12.5px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 11px; color: var(--muted); text-decoration: none; font-size: 14.5px; }
.nav a:hover { background: var(--hover); color: var(--text); }
.nav a[aria-current="page"] { background: var(--active); color: var(--text); }
.nav .nl { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav .count { margin-left: auto; font-family: var(--mono); font-size: 11.5px; color: var(--faint); }
.nav .count.bad { color: var(--red); }
.side h4 { margin: 0 0 6px; padding: 0 10px; font-size: 12.5px; font-weight: 500; color: var(--faint); }
.domsec { display: flex; flex-direction: column; }
.domlist { display: flex; flex-direction: column; gap: 1px; }
.domlist button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border: 0; border-radius: 10px; background: none; color: var(--text); cursor: pointer; font-size: 14px; text-align: left; min-width: 0; }
.domlist button:hover { background: var(--hover); }
.domlist button[aria-pressed="true"] { background: var(--active); }
.domlist .d { width: 7px; height: 7px; border-radius: 50%; background: var(--dot); flex: none; }
.domlist .d.ok { background: var(--ok); }
.domlist .d.bad { background: var(--red); box-shadow: 0 0 8px var(--red-glow); }
.domlist .dn { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.domlist small { margin-left: auto; color: var(--faint); font-family: var(--mono); font-size: 11.5px; }

/* main column */
.main { min-width: 0; display: flex; flex-direction: column; border-left: 1px solid var(--line2); }
.top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 16px 24px; border-bottom: 1px solid var(--line2); }
.crumbs { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--muted); font-size: 15px; white-space: nowrap; }
.crumbs b { color: var(--text); font-weight: 500; }
.crumbs .sep { color: var(--sep); }
.search { margin: 0 0 0 auto; display: flex; align-items: center; gap: 10px; flex: 1 1 300px; min-width: 300px; max-width: 380px; padding: 8px 10px 8px 12px; background: var(--card); border: 1px solid var(--field-line); border-radius: 12px; }
.search svg.i { width: 16px; height: 16px; color: var(--muted); stroke-width: 1.8; }
.search input { flex: 1; min-width: 0; min-height: 0; padding: 0; background: none; border: 0; border-radius: 0; color: var(--text); }
.search input:focus-visible { box-shadow: none; outline: none; }
.search:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.search kbd { font-family: var(--mono); font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; white-space: nowrap; background: none; min-width: 0; }
.topacts { display: flex; align-items: center; gap: 14px; flex: none; }
/* dismissible search-token hint: its own line under the search box */
.search-hint { flex: 1 1 100%; order: 6; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.search-hint span { min-width: 0; overflow-wrap: anywhere; }
.search-hint b { color: var(--text-soft); font-weight: 600; }
.who { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; white-space: nowrap; max-width: 220px; min-width: 0; }
.who .nm { overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.logout { color: var(--muted); font-size: 13.5px; text-decoration: none; background: none; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; white-space: nowrap; cursor: pointer; }
.logout:hover { color: var(--text); background: var(--hover); }

.head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 16px; row-gap: 12px; padding: 22px 24px 6px; }
.head-l { min-width: 0; }
.head h1 { font-size: 30px; font-weight: 600; letter-spacing: -.02em; }
.meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--text); font-size: 13px; white-space: nowrap; }
.pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
.pill.dim { color: var(--muted); }
.pill.dim i { background: var(--dot); }
.pill.warn { color: var(--amber); border-color: var(--amber-line); background: var(--amber-bg); }
.pill.warn i { background: var(--amber); }
.pill.bad { color: var(--red); border-color: var(--red-line); background: var(--red-bg); }
.pill.bad i { background: var(--red); }
.ext { color: var(--muted); font-family: var(--mono); font-size: 13px; }
.ext.stale { color: var(--amber); }
.ext.bad { color: var(--red); }
.controls { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

.view { display: flex; flex-direction: column; gap: 16px; padding: 16px 24px 28px; min-width: 0; }
.view:focus { outline: none; }
.panel { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* cards */
.card { min-width: 0; background: var(--card); border: 1px solid var(--line2); border-radius: var(--r-lg); }
.card-h { display: flex; align-items: center; gap: 12px; row-gap: 8px; flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--line2); }
.card-h .ic { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 8px; color: var(--muted); }
.card-h .ic svg.i { width: 16px; height: 16px; }
.card-h h3 { font-size: 16px; font-weight: 600; white-space: nowrap; }
.card-h .sub { color: var(--muted); font-family: var(--mono); font-size: 13px; }
.card-h .more { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 13.5px; }
.card-h .more:hover { color: var(--text); }
.card-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-b { padding: 16px 20px 20px; }
.card-b > p + * { margin-top: 14px; }
.card-b h2 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.note { padding: 12px 16px; color: var(--muted); font-size: 13px; }
.note.quiet { padding: 28px 20px; text-align: center; }
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--line2); }
.filters .field-in { flex: 0 1 180px; }
.empty { padding: 28px 20px; color: var(--muted); text-align: center; }
.empty strong { display: block; margin-bottom: 4px; color: var(--text); font-size: 15px; font-weight: 600; }
.list-foot { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 56px; padding: 12px 16px; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 16px; }

/* ------------------------------------------------------------------ stat cards */
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); overflow: hidden; background: var(--card); border: 1px solid var(--line2); border-radius: var(--r-lg); }
/* title, number with the bars right next to it, the line below over the full width */
.kpi { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto auto; align-content: start; column-gap: 10px; min-width: 0; padding: 18px 20px; border-right: 1px solid var(--line2); }
.kpi:last-child { border-right: 0; }
.kpi .lab { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.kpi .lab svg.i { width: 16px; height: 16px; }
.kpi .val { grid-column: 1; grid-row: 2; align-self: end; margin-top: 10px; font-size: 34px; font-weight: 600; letter-spacing: -.02em; white-space: nowrap; line-height: 1.15; }
.kpi .val small { margin-left: 2px; color: var(--muted); font-size: 15px; font-weight: 500; letter-spacing: 0; }
.kpi .val.bad { color: var(--red); }
.kpi .spk { grid-column: 2; grid-row: 2; align-self: end; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.kpi .spark-cap { color: var(--muted); font-size: 11px; line-height: 1; }
.kpi svg.spark { display: block; width: 112px; height: 44px; }
.kpi .delta { grid-column: 1 / -1; grid-row: 3; margin-top: 6px; min-height: 38px; color: var(--muted); font-size: 13px; }
.kpi .delta b { color: var(--text); font-weight: 500; }
.kpi .delta b.bad { color: var(--red); }
.kpi .delta b.warn { color: var(--amber); }
.spark-bar { fill: var(--spark); }
.spark-hi { fill: var(--red); }
.spark-now { fill: var(--text); }

/* inbox grid: feed and "Needs attention". deviation: 2.3fr / 300px and stacked at 1280px (console
   1.5fr / 360px, 1100px): the feed with its code buttons is the main content here */
.g2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
/* Unmatched, Orders and Sign-ups: the feed alone. The view fixes the state (Unmatched) or the
   category (Orders, Sign-ups), so that control is hidden there */
body[data-view="unmatched"] .kpis, body[data-view="unmatched"] .attn-card,
body[data-view="orders"] .kpis, body[data-view="orders"] .attn-card,
body[data-view="signups"] .kpis, body[data-view="signups"] .attn-card { display: none; }
body[data-view="unmatched"] .g2, body[data-view="orders"] .g2, body[data-view="signups"] .g2 { grid-template-columns: minmax(0, 1fr); }
body[data-view="unmatched"] #feed-state, body[data-view="inbox"] #feed-state label:last-child,
body[data-view="orders"] #feed-state label:last-child, body[data-view="signups"] #feed-state label:last-child { display: none; }
body[data-view="orders"] #feed-category, body[data-view="signups"] #feed-category,
body[data-view="orders"] label[for="feed-category"], body[data-view="signups"] label[for="feed-category"] { display: none; }

/* needs attention */
.alert { margin: 16px; padding: 16px; border: 1px solid var(--red-line); border-radius: 16px; background: var(--red-bg); }
.alert.warn { border-color: var(--amber-line); background: var(--amber-bg); }
.alert h4 { font-size: 15.5px; font-weight: 600; color: var(--text); }
.alert p { margin: 6px 0 14px; color: var(--alert-text); font-size: 13.5px; overflow-wrap: anywhere; }
.alert.warn p { color: var(--text-soft); }
.alert .acts { display: flex; gap: 10px; flex-wrap: wrap; }
.alert .acts { align-items: center; }
.alert .btn-primary { border-radius: 999px; }
.alert .when { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.attn { list-style: none; margin: 0; padding: 0 16px 14px; display: flex; flex-direction: column; gap: 6px; }
.attn li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; border-radius: 10px; font-size: 13.5px; }
.attn li[tabindex] { cursor: pointer; }
.attn li[tabindex]:hover, .attn li[tabindex]:focus-visible { background: var(--hover); }
.attn .sv { flex: none; width: 6px; height: 6px; margin-top: 7px; border-radius: 50%; background: var(--amber); }
.attn .sv.r { background: var(--red); }
.attn small { display: block; color: var(--muted); overflow-wrap: anywhere; }
.attn .t { min-width: 0; }

/* ------------------------------------------------------------------ tables */
/* A table that scrolls sideways shows a shadow at the edge where more follows (background
   local/scroll, as in the console). Tables that never scroll show only the card color. */
.tblwrap, .scroll-box {
  background:
    linear-gradient(to right, var(--card) 30%, transparent) left center / 40px 100% no-repeat local,
    linear-gradient(to left, var(--card) 30%, transparent) right center / 40px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, var(--shadow), transparent) left center / 14px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, var(--shadow), transparent) right center / 14px 100% no-repeat scroll;
  background-color: var(--card);
}
.tblwrap { position: relative; overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 13.5px; }
.grid th { padding: 9px 12px; text-align: left; font-size: 12.5px; font-weight: 500; color: var(--muted); white-space: nowrap; border-bottom: 1px solid var(--line2); }
.grid td { padding: 10px 12px; vertical-align: top; min-width: 0; overflow-wrap: anywhere; border-bottom: 1px solid var(--line2); }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr { scroll-margin-top: 16px; scroll-margin-bottom: 16px; }
.grid tbody tr.clickable { cursor: pointer; }
.grid tbody tr.clickable:hover td { background: var(--row-hover); }
.grid tbody tr:focus-visible { outline: none; }
.grid tbody tr:focus-visible td { background: var(--row-hover); box-shadow: inset 0 2px 0 var(--focus), inset 0 -2px 0 var(--focus); }
.grid tbody tr:focus-visible td:first-child { box-shadow: inset 2px 0 0 var(--focus), inset 0 2px 0 var(--focus), inset 0 -2px 0 var(--focus); }
.grid tbody tr:focus-visible td:last-child { box-shadow: inset -2px 0 0 var(--focus), inset 0 2px 0 var(--focus), inset 0 -2px 0 var(--focus); }
.grid tbody tr.is-open td { background: var(--row-open); }
.grid tbody tr.is-new td { animation: flash-new 3s ease-out; }
@keyframes flash-new { 0%, 40% { background: var(--row-new); } 100% { background: transparent; } }
/* first and last column line up with the card title (not on phones, where feed rows are cards) */
@media (min-width: 721px) {
  .card .grid th:first-child, .card .grid td:first-child { padding-left: 20px; }
  .card .grid th:last-child, .card .grid td:last-child { padding-right: 20px; }
}

/* feed */
.feed .c-time { width: 92px; }
.feed .c-acct { width: 27%; }
.feed .c-from { width: 18%; }
.feed .c-code { width: 236px; }
.feed td.c-time { color: var(--muted); font-family: var(--mono); font-size: 12.5px; white-space: nowrap; padding-top: 12px; }
.acct-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.acct-line + .acct-line { margin-top: 3px; }
.acct-email { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.acct-none { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.from-name, .subj { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subj { font-weight: 500; }
.from-addr, .snippet { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12.5px; }
.c-subj .badge { margin-top: 4px; }
/* category badge in front of the subject, on the same line */
.subj-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.subj-line .subj { flex: 1 1 auto; min-width: 0; }
.c-subj .subj-line .badge { margin-top: 0; }
.from-inline { display: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12.5px; }
/* a narrow feed card (next to "Needs attention", tablets): sender moves into the subject cell */
.feed-card { container-type: inline-size; }
@container (max-width: 820px) {
  .feed .c-from { display: none; }
  .feed .from-inline { display: block; }
  .feed .c-acct { width: 34%; }
  .feed .c-code { width: 206px; }
}

/* accounts */
.accts .c-email { width: 27%; }
.accts .c-fwd { width: 23%; }
.accts .c-status { width: 120px; }
.accts .c-last { width: 96px; }
.accts .c-num { width: 56px; text-align: right; }
.accts .c-cat { width: 12%; }
.fwd-inline { display: none; }
.cell-fwd { display: flex; align-items: center; gap: 6px; min-width: 0; }
.cell-fwd span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12.5px; color: var(--text-dim); }
td.c-last, td.c-at { color: var(--muted); }

/* audit, inboxes */
.audit .c-at { width: 150px; }
.audit .c-actor { width: 140px; }
.audit .c-action { width: 130px; }
.audit td.c-detail { font-family: var(--mono); font-size: 12px; color: var(--text-dim); }
.inboxes .c-address { width: 40%; }
.inboxes .c-num { width: 64px; text-align: right; }
/* rules */
.rules .c-rule-type { width: 110px; }
.rules .c-rule-action { width: 120px; }
.rules .c-rule-at { width: 110px; }
.rules .c-rule-x { width: 90px; text-align: right; }
.rules td.c-rule-pattern code { overflow-wrap: anywhere; font-size: 12.5px; color: var(--text-dim); }
.rules td.c-rule-action { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.health-detail { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.addr-cell { display: flex; align-items: center; gap: 8px; min-width: 0; }
.addr-cell code { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }

/* ------------------------------------------------------------------ codes */
.codes { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.code { display: flex; flex-direction: column; gap: 3px; max-width: 100%; }
.code-btn { display: inline-flex; align-items: center; gap: 10px; max-width: 100%; padding: 5px 12px 5px 14px; background: var(--card2); color: var(--text); border: 1px solid var(--line3); border-radius: 12px; cursor: pointer; }
.code-btn:hover { background: var(--card); border-color: var(--line-strong); }
.code-value { flex: 0 0 auto; font-family: var(--mono); font-size: 21px; font-weight: 600; letter-spacing: .06em; line-height: 1.2; white-space: nowrap; font-variant-numeric: tabular-nums; }
.code-btn svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; color: var(--muted); }
.code-btn .i-check { display: none; color: var(--green); }
.code.copied .code-btn .i-check { display: block; }
.code.copied .code-btn .i-copy { display: none; }
.code.copied .code-btn, .code.copied .link-copy { border-color: var(--green); }
.code.is-fresh .code-btn { background: var(--btn-bg); color: var(--btn-text); border-color: var(--btn-bg); }
.code.is-fresh .code-btn:hover { background: var(--btn-hover); }
.code.is-fresh .code-btn svg { color: inherit; opacity: .75; }
.conf-medium .code-value { font-size: 15px; font-weight: 600; }
.conf-medium.is-fresh .code-btn { background: var(--card2); color: var(--text); border-color: var(--line-strong); }
.conf-medium.is-fresh .code-btn svg { color: var(--muted); opacity: 1; }
.code-link .btn { max-width: 100%; }
.code-link .btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.code-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.code-meta .state { font-family: var(--mono); font-size: 11.5px; }
.code.is-fresh .code-meta .state { color: var(--text); font-weight: 600; }
.code.is-ending .code-meta .state { color: var(--amber); }
.code.is-expired .code-value { color: var(--faint); }
.code.is-used .code-value { color: var(--faint); text-decoration: line-through; text-decoration-thickness: 1px; }
.code.is-used .code-meta .state { color: var(--text-soft); font-weight: 500; }
.conf-tag { padding: 0 6px; border-radius: 6px; border: 1px solid var(--amber-line); background: var(--amber-bg); color: var(--amber); font-size: 11px; font-weight: 500; }
.v-detail .code-value { font-size: 32px; }
.v-detail.conf-medium .code-value { font-size: 21px; }
.v-detail .code-btn { padding: 8px 16px 8px 18px; border-radius: 14px; }
.v-detail .code-meta { font-size: 12.5px; }
.codes-detail { flex-direction: row; flex-wrap: wrap; gap: 14px 24px; }
/* newest code of an account shown read only (its mail is not in the loaded list) */
.newest-plain { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.newest-plain .code-value { font-size: 24px; color: var(--text); }

/* ------------------------------------------------------------------ drawer */
/* below 1840px the drawer covers the list: a scrim dims it and closes the drawer on click */
.scrim { display: none; position: fixed; inset: 0; z-index: 39; background: var(--scrim); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 40; display: flex; flex-direction: column; width: min(var(--drawer-w), 100vw); background: var(--drawer); border-left: 1px solid var(--line); box-shadow: -24px 0 60px var(--shadow); }
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 22px 14px; border-bottom: 1px solid var(--line2); }
.drawer-head h2 { flex: 1 1 auto; min-width: 0; padding-top: 4px; font-size: 20px; font-weight: 500; letter-spacing: -.01em; overflow-wrap: anywhere; }
.drawer-body { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px)); }
.d-section { padding: 16px 22px; border-bottom: 1px solid var(--line2); }
.d-section:last-child { border-bottom: 0; }
.d-section h3, .d-section summary { font-size: 12.5px; font-weight: 500; color: var(--faint); }
.d-section > h3 { margin-bottom: 10px; }
.d-section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.meta-grid { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 6px 12px; margin: 0; font-size: 13.5px; }
.meta-grid dt { color: var(--muted); }
.meta-grid dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.inline-copy { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; flex-wrap: wrap; }
.cat-field { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.cat-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sel-sm { min-height: 30px; padding: 3px 30px 3px 10px; border-radius: 10px; font-size: 13px; background-position: right 10px center; }
.acct-list { display: flex; flex-direction: column; gap: 10px; }
.acct-item { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.acct-item .sub { flex-basis: 100%; color: var(--muted); font-size: 12.5px; font-family: var(--mono); }
.frame-wrap { height: 520px; min-height: 200px; max-height: 85vh; overflow: hidden; resize: vertical; background: var(--frame-bg); border: 1px solid var(--line); border-radius: 12px; }
.frame-wrap iframe { display: block; width: 100%; height: 100%; border: 0; background: var(--frame-bg); }
.mail-text { margin: 0; max-height: 520px; overflow: auto; padding: 12px 14px; background: var(--card3); border: 1px solid var(--line); border-radius: 12px; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.links { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.links li { display: flex; align-items: center; gap: 8px; min-width: 0; }
.links code { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--text-dim); }
details.headers summary { cursor: pointer; }
details.headers dl { display: grid; grid-template-columns: minmax(90px, max-content) minmax(0, 1fr); gap: 4px 12px; margin: 10px 0 0; font-family: var(--mono); font-size: 11.5px; }
details.headers dt { color: var(--muted); }
details.headers dd { margin: 0; overflow-wrap: anywhere; }
details.headers dd div + div { margin-top: 2px; }
.d-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 16px 22px; }
.inline-form { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.inline-form input { flex: 1 1 220px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; align-items: end; }
.row-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.notice { margin: 14px 22px 0; padding: 9px 12px; border: 1px solid var(--amber-line); border-radius: 12px; background: var(--amber-bg); color: var(--amber); font-size: 13px; }
.notice.error { border-color: var(--red-line); background: var(--red-bg); color: var(--red-text); }
.pad { padding: 16px 22px; }
.mini-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line2); border-radius: 12px; overflow: hidden; }
.mini-list li + li { border-top: 1px solid var(--line2); }
.mini-item { display: flex; align-items: center; gap: 8px; padding-right: 10px; }
.mini-item .code { flex: none; max-width: 45%; }
.mini-item .code-value { font-size: 15px; }
.mini-row { flex: 1 1 auto; min-width: 0; display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 4px 10px; align-items: center; padding: 9px 12px; border: 0; background: none; color: var(--text); text-align: left; cursor: pointer; font-size: 13px; }
.mini-row:hover { background: var(--row-hover); }
.mini-row .t { color: var(--muted); font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.mini-row .s { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-row strong { font-weight: 600; }

/* ------------------------------------------------------------------ import */
.drop { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 120px; padding: 16px; border: 1.5px dashed var(--line3); border-radius: 16px; background: var(--card3); color: var(--muted); text-align: center; cursor: pointer; }
.drop.is-over { border-color: var(--line-strong); background: var(--sel-bg); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.drop strong { color: var(--text); font-weight: 600; }
#import-result .card { padding: 16px 20px 20px; }
#import-result h2 { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 1px; margin: 16px 0; overflow: hidden; background: var(--line2); border: 1px solid var(--line2); border-radius: 14px; }
.stat { padding: 12px 14px; background: var(--card); }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat.is-bad .v { color: var(--red); }
.stat.is-good .v { color: var(--text); }
.sub-title { margin: 18px 0 8px; font-size: 13.5px; font-weight: 600; }
.scroll-box { max-height: 320px; overflow: auto; border: 1px solid var(--line2); border-radius: 12px; }
.plain { table-layout: auto !important; }
.plain td { white-space: nowrap; }
/* the first column (line number) stays while the rest scrolls */
.plain th:first-child, .plain td:first-child { position: sticky; left: 0; z-index: 1; background: var(--card); box-shadow: 1px 0 0 var(--line2); }

/* ------------------------------------------------------------------ dialogs */
dialog { width: min(600px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; background: var(--drawer); color: var(--text); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 24px 60px var(--shadow); }
/* the rgba line only for browsers whose ::backdrop does not inherit the tokens */
dialog::backdrop { background: rgba(10, 10, 12, .45); background: var(--scrim); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 18px 20px 12px; }
.dlg-head h2 { font-size: 18px; font-weight: 600; }
.dlg-body { display: flex; flex-direction: column; gap: 12px; padding: 4px 20px 16px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; padding: 14px 20px 18px; border-top: 1px solid var(--line2); }
.keys { display: grid; grid-template-columns: max-content 1fr; gap: 10px 16px; margin: 0; }
.keys dt { white-space: nowrap; color: var(--muted); }
.keys dd { margin: 0; }
kbd { display: inline-block; min-width: 22px; padding: 1px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--card2); font-family: var(--mono); font-size: 11.5px; text-align: center; color: var(--text); }
.form-error { margin-top: 12px; padding: 9px 12px; border: 1px solid var(--red-line); border-radius: 10px; background: var(--red-bg); color: var(--red-text); font-size: 13px; }
.form-info { margin-top: 12px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card2); color: var(--text-soft); font-size: 13px; }

/* ------------------------------------------------------------------ toasts */
.toasts { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); z-index: 60; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; width: max-content; max-width: calc(100vw - 32px); pointer-events: none; }
.toast { padding: 10px 16px; border-radius: 12px; background: var(--toast-bg); color: var(--toast-text); font-weight: 500; box-shadow: 0 10px 30px var(--shadow); overflow-wrap: anywhere; pointer-events: auto; }
.toast.warn { border-left: 3px solid var(--amber); }
.toast.error { background: var(--toast-err-bg); color: var(--red-text); border: 1px solid var(--red-line); }

/* ------------------------------------------------------------------ sign in pages (login, two factor, notices) */
body[data-page="login"], body[data-page="totp"], body[data-page="notice"] { min-height: 100vh; padding: 0; background: var(--paper); display: grid; grid-template-rows: 1fr auto; position: relative; overflow-x: hidden; }
/* shapes like the E. Market banners: three bars left like the E, two circles right like the dot */
body[data-page="login"]::before, body[data-page="totp"]::before, body[data-page="notice"]::before { content: ""; position: fixed; z-index: -1; pointer-events: none; left: 0; top: calc(46% - 17.5vmin); width: 20.8vmin; height: 7.8vmin; border-radius: 0 999px 999px 0; background: var(--deco); box-shadow: -8.3vmin 13.6vmin 0 var(--deco), 0 27.2vmin 0 var(--deco); }
body[data-page="login"]::after, body[data-page="totp"]::after, body[data-page="notice"]::after { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; background: radial-gradient(circle at calc(100% - 22vmin) 14vmin, var(--deco) 6vmin, transparent calc(6vmin + 1px)), radial-gradient(circle at calc(100% - 7vmin) 88%, var(--deco) 30vmin, transparent calc(30vmin + 1px)); }
.auth { width: 100%; max-width: 372px; margin: 0 auto; padding: 12vh 16px 40px; align-self: start; }
.auth-card { display: flex; flex-direction: column; }
.lockup { display: flex; align-items: center; justify-content: center; gap: 7px; margin: 0 0 34px; }
.lockup .emark { width: 38px; height: 38px; }
.lockup .wm { font-weight: 500; font-size: 29px; line-height: 1; letter-spacing: -.02em; }
.lockup .tag { margin-left: 8px; padding: 3px 10px; border: 1px solid var(--line3); border-radius: 999px; color: var(--muted); font-size: 12.5px; }
.auth-card h1 { text-align: center; font-size: 24px; font-weight: 600; letter-spacing: -.025em; }
.auth-card > p, .auth-card section > p { margin-top: 8px; color: var(--muted); text-align: center; text-wrap: balance; }
.auth-card .btn-block { margin-top: 28px; }
.auth-card .btn-block:not(.btn-discord) { min-height: 44px; border-radius: 10px; }
.auth-foot { margin-top: 22px; text-align: center; font-size: 12.5px; color: var(--faint); }
.auth-foot .link-like { color: var(--muted); }
.steps { margin: 16px 0 0; padding-left: 20px; color: var(--text-soft); font-size: 13.5px; }
.steps li + li { margin-top: 4px; }
.qr { display: flex; justify-content: center; margin: 20px 0 10px; }
.qr img { width: 200px; height: 200px; padding: 10px; border: 1px solid var(--line); border-radius: 16px; background: var(--qr-bg); image-rendering: pixelated; }
.secret { margin-top: 8px; font-size: 13px; text-align: center; }
.secret summary { cursor: pointer; color: var(--muted); }
.secret-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; text-align: left; }
.secret-row code { flex: 1 1 auto; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); letter-spacing: .08em; overflow-wrap: anywhere; }
.otp-form { margin-top: 26px; }
.otp-form .field > span { color: var(--text-soft); font-size: 13px; }
.otp-input { width: 100%; height: 52px; font-family: var(--mono); font-size: 26px; letter-spacing: .4em; text-align: center; border-radius: 12px; }
.foot { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px)); color: var(--faint); font-size: 12px; }
.foot .iconbtn { padding: 5px; color: var(--faint); }
.foot .iconbtn svg.i { width: 15px; height: 15px; }

/* ------------------------------------------------------------------ responsive */
/* very wide screens: the drawer sits next to the list instead of over it. Below 1840px
   docking would squeeze the stat cards and the feed table (sidebar 268 + drawer 520) */
@media (min-width: 1840px) {
  body.drawer-open .app { margin-right: calc(var(--drawer-w) - 16px); }
}
@media (max-width: 1839px) {
  body.drawer-open .scrim { display: block; }
}
@media (max-width: 1400px) {
  .kpi { padding: 16px 18px; }
  .kpi svg.spark { width: 84px; height: 36px; }
  .feed .c-code { width: 214px; }
}
@media (max-width: 1280px) {
  .g2 { grid-template-columns: minmax(0, 1fr); }
  .attn-card { order: -1; }
  .attn-card.is-calm .card-h { border-bottom: 0; }
  .attn-card.is-calm .note.quiet { padding: 0 20px 16px; text-align: left; }
  .crumbs > span { display: none; }
}
@media (max-width: 1240px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(2) { border-right: 0; }
  .kpi:nth-child(-n+2) { border-bottom: 1px solid var(--line2); }
  .accts .c-cat { display: none; }
}
@media (max-width: 1180px) {
  .search { min-width: 220px; }
}
@media (max-width: 1140px) {
  .head { grid-template-columns: minmax(0, 1fr); }
  .controls { justify-content: flex-start; }
  .who { display: none; }
}
@media (max-width: 1024px) {
  .feed .c-from { width: 20%; }
  .feed .c-acct { width: 28%; }
}
@media (max-width: 860px) {
  body[data-page="app"] { padding: 10px; }
  .app { grid-template-columns: minmax(0, 1fr); border-radius: 18px; min-height: calc(100vh - 20px); }
  .side { position: static; height: auto; overflow: visible; gap: 12px; padding: 12px; border-bottom: 1px solid var(--line2); }
  .main { border-left: 0; }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; }
  .nav a { flex: none; white-space: nowrap; padding: 8px 10px; }
  .nav .count { display: none; }
  .domsec { display: none; }
  .top { padding: 12px 14px; gap: 10px; }
  .top .search { order: 5; flex: 1 1 100%; max-width: none; min-width: 0; margin-left: 0; }
  .topacts { margin-left: auto; }
  .head { padding: 18px 14px 4px; }
  .head h1 { font-size: 26px; }
  .view { padding: 12px 14px 22px; }
  .feed .c-code { width: 190px; }
  .accts .col-opt { display: none; }
  .accts .c-email { width: auto; }
  .fwd-inline { display: block; }
  .audit .c-actor, .inboxes .col-opt { display: none; }
  .drawer { width: 100vw; border-left: 0; }
  .card-tools { margin-left: 0; flex: 1 1 100%; }
}
@media (max-width: 720px) {
  /* feed rows become cards */
  .feed thead { display: none; }
  .feed, .feed tbody { display: block; }
  .feed tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "acct time" "from from" "subj subj" "code code"; gap: 3px 12px; padding: 12px 16px; border-bottom: 1px solid var(--line2); }
  .feed tbody tr:last-child { border-bottom: 0; }
  .feed td { display: block; width: auto !important; padding: 0; border: 0; }
  .feed tbody tr.clickable:hover td, .grid.feed tbody tr.is-open td, .grid.feed tbody tr:focus-visible td { background: none; box-shadow: none; }
  .feed tbody tr.clickable:hover, .feed tbody tr.is-open { background: var(--row-hover); }
  .feed tbody tr:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
  .feed tbody tr.is-new { animation: flash-new 3s ease-out; }
  .feed tbody tr.is-new td { animation: none; }
  .feed td.c-time { grid-area: time; padding-top: 0; text-align: right; }
  .feed td.c-acct { grid-area: acct; }
  .feed td.c-from { display: block; grid-area: from; }
  .feed td.c-from .from-addr { display: none; }
  .feed td .from-inline { display: none; }
  .feed td.c-subj { grid-area: subj; }
  .feed td.c-code { grid-area: code; margin-top: 6px; }
  .feed td.c-code:empty { display: none; }
  .filters .sel { flex: 1 1 calc(50% - 5px); }
  .filters .seg { flex: 1 1 100%; overflow-x: auto; }
  .audit .c-at { width: 100px; }
  .audit .c-action { width: 100px; }
  .accts .c-status { width: 108px; }
  .accts .c-last { width: 78px; }
  .meta-grid { grid-template-columns: 92px minmax(0, 1fr); }
  .v-detail .code-value { font-size: 28px; }
  .frame-wrap { height: 60vh; }
  .pager { justify-content: space-between; }
}
/* phone: numbers 2 x 2 without bars (the number and its line are enough there), every
   section visible, three to a row (partner 7, owner 10) with the icon over the name,
   only the view name in the top bar */
@media (max-width: 560px) {
  .crumbs > span { display: none; }
  .nav { flex-wrap: wrap; overflow: visible; gap: 2px; }
  .nav a { flex: 1 1 calc(33.333% - 2px); min-width: 0; flex-direction: column; gap: 4px; padding: 8px 2px; font-size: 10.5px; text-align: center; white-space: normal; }
  .nav .nl { max-width: 100%; }
  .head h1 { font-size: 24px; }
  .kpi { padding: 14px; border-right: 0; border-bottom: 1px solid var(--line2); }
  .kpi:nth-child(odd) { border-right: 1px solid var(--line2); }
  .kpi:nth-last-child(-n+2) { border-bottom: 0; }
  .kpi .spk { display: none; }
  .kpi .lab { font-size: 13px; gap: 6px; }
  .kpi .val { font-size: 28px; margin-top: 8px; }
  .kpi .val small { font-size: 13px; }
  .kpi .delta { font-size: 12px; min-height: 0; }
  .card-h { padding: 14px 16px; }
  .card-h h3 { white-space: normal; }
  .head .controls .btn { flex: 1 1 auto; }
  .alert { margin: 12px; }
  .attn { padding: 0 12px 12px; }
  .drawer-head { padding: 16px 16px 12px; }
  .d-section { padding: 14px 16px; }
  .d-actions { padding: 14px 16px; }
  .notice { margin: 12px 16px 0; }
}
/* sign in pages on phones, as the console's login: no bars, the circles move to the corners */
@media (max-width: 640px) {
  body[data-page="login"]::before, body[data-page="totp"]::before, body[data-page="notice"]::before { display: none; }
  body[data-page="login"]::after, body[data-page="totp"]::after, body[data-page="notice"]::after { background: radial-gradient(circle at calc(100% - 15vmin) 11vmin, var(--deco) 5vmin, transparent calc(5vmin + 1px)), radial-gradient(circle at calc(100% + 6vmin) calc(100% + 4vmin), var(--deco) 36vmin, transparent calc(36vmin + 1px)); }
}
@media (max-width: 420px) {
  .auth { padding-top: 9vh; }
  .auth-card h1 { font-size: 22px; }
  .lockup { gap: 6px; margin-bottom: 30px; }
  .lockup .wm { font-size: 26px; }
  .lockup .emark { width: 34px; height: 34px; }
}
/* touch only: there is no Ctrl or Cmd K there */
@media (hover: none) and (pointer: coarse) {
  .search kbd { display: none; }
}
@media (pointer: coarse) {
  .seg button, .seg span { min-height: 36px; }
  .x-sm { width: 32px; height: 32px; }
}
@media (prefers-reduced-motion: no-preference) {
  .pulse { animation: pulse 2.4s ease-in-out infinite; }
  @keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: .9; } }
}
@media (prefers-reduced-motion: reduce) {
  .grid tbody tr.is-new td, .feed tbody tr.is-new { animation: none; background: var(--row-new); }
}
