/* IBM Plex Sans — variable font, covers 100–900 */
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/static/fonts/plex-sans-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/static/fonts/plex-sans-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* IBM Plex Mono — static weights */
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/static/fonts/plex-mono-400-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/static/fonts/plex-mono-400-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/static/fonts/plex-mono-500-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/static/fonts/plex-mono-500-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/static/fonts/plex-mono-600-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/static/fonts/plex-mono-600-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* ============================================================================
   Mail Ops — dashboard stylesheet

   An instrument panel for a five-domain sending fleet. Two typefaces, both
   self-hosted: IBM Plex Sans for the interface, IBM Plex Mono for anything
   that is an identifier — addresses, domains, IPs, timestamps, ids. The mono
   is not decoration: `l`/`1` and `O`/`0` are the failure mode in a bounce log.

   Every sending domain carries its own colour, defined once below and reused
   on mail rows, pool cards and the brand mark, so a glance says which domain
   did what.
   ========================================================================= */

/* ── Tokens ─────────────────────────────────────────────────────────────── */
:root {
  /* surfaces — one cool near-black family in four steps of depth. Depth comes
     from the step between them, not from a shadow. */
  --bg:        #0b0f15;
  --bg-deep:   #070a0e;
  --panel:     #111820;
  --panel-hi:  #18202a;
  --raise:     #1d2833;
  --line:      #1f2834;
  --line-soft: #171e27;

  /* ink */
  --text:      #e9eff5;
  --muted:     #8b99a7;
  --faint:     #5a6773;

  /* signal — the accent belongs to interaction and to nothing else. */
  --accent:     #4f8ff0;
  --accent-hi:  #6ba1f5;
  --accent-dim: #16283f;
  --ok:        #3fae6d;
  --warn:      #c9964e;
  --bad:       #d95f5c;
  --reply:     #8b78d8;

  /* geometry — radius tightens as the element gets smaller */
  --r-card: 8px;
  --r-ctl:  7px;
  --r-chip: 5px;
  --gap:    16px;

  /* one orchestrated load sequence, nothing scattered */
  --ease: cubic-bezier(.22, .61, .36, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  /* Light falls from above. Shadows are tinted to the surface, never pure
     black at low opacity — that is the tell of a default. */
  --shadow-1: 0 1px 0 rgba(255, 255, 255, .028), 0 14px 34px -26px #000;
}

/* ── Domain identity ──────────────────────────────────────────────────────
   Five sending domains have to stay five apart at a glance, so the hues are
   held — but pulled down to the same muted register as the rest of the panel.
   A vivid set of five turns the list into a paint box and the data stops
   reading as data. Generic rule first; the named domains below win by source
   order, so a domain without a slot falls back to grey, never to a wrong
   colour. */
[data-dom] { --dom: var(--faint); }
[data-dom="serviceantwort.de"]     { --dom: #cfa35c; }
[data-dom="servicemitteilung.com"] { --dom: #4aa9a2; }
[data-dom="vorgang-direkt.de"]     { --dom: #c9756a; }
[data-dom="vorgangshinweis.de"]    { --dom: #9484d2; }
[data-dom="antwort-direkt.de"]     { --dom: #5f9dd4; }

/* ── Base ───────────────────────────────────────────────────────────────── */
/* The whole app toggles views with .hidden; nothing else may outrank it. */
.hidden { display: none !important; }
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* One light source, one material.
   The panel is lit from above — a single wide wash in the accent hue, far too
   faint to name but enough that the black stops being paper. Over it sits a
   fixed grain: a few percent opacity that breaks the flat-vector look, which
   is the difference between a surface and a rectangle of colour. Both layers
   are pointer-events:none and sit under .wrap. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(125% 62% at 50% -12%,
              rgba(79, 143, 240, .06), rgba(79, 143, 240, 0) 62%);
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: .02;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Identifiers read in mono wherever they appear, without touching markup. */
code, kbd, samp,
.mr-from, .mr-date, .tel-v, .token-box, .hm-mono {
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-feature-settings: 'zero' 1;   /* slashed zero: no O/0 mix-ups */
}

a { color: var(--accent); }

::selection { background: var(--accent-dim); color: #fff; }

/* ── Layout ─────────────────────────────────────────────────────────────── */
/* One column, one margin. The whole panel is 1240px of aligned edge: every
   heading, field and table starts on the same line, which is the difference
   between an instrument and a pile of boxes. */
.wrap {
  position: relative;
  z-index: 2;              /* the two material layers above paint beneath this */
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 28px 88px;
}

/* ── Masthead ───────────────────────────────────────────────────────────── */
.masthead {
  position: sticky;
  top: 0;
  z-index: 40;
  background: linear-gradient(var(--bg) 72%, rgba(11, 15, 21, .88));
  backdrop-filter: blur(6px);
  border-bottom: 1px solid transparent;
  padding: 22px 0 0;
  margin-bottom: 26px;
  transition: border-color .25s var(--ease);
}
.masthead.is-stuck { border-bottom-color: var(--line); }

.masthead-main {
  display: flex;
  align-items: center;
  gap: 14px;
}

h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -.014em;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 11px;
}

/* The brand mark is five bars — one per sending domain, in that domain's
   colour. It is the whole product in 22 px. */
.mark {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  flex: 0 0 auto;
  background: linear-gradient(90deg,
    #cfa35c 0 20%, #4aa9a2 20% 40%, #c9756a 40% 60%,
    #9484d2 60% 80%, #5f9dd4 80% 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16);
}

.wordmark { font-weight: 600; }

.sub {
  color: var(--muted);
  font-size: 12.5px;
  margin: 0;
  line-height: 1.55;
}
.masthead .sub { margin-top: 6px; }

/* ── Telemetry strip ─────────────────────────────────────────────────────
   Four numbers that answer "is anything wrong right now". They sit in the
   masthead so they are readable from every tab.
   No box around them: the strip is delimited by two hairlines, and the numbers
   carry the emphasis. A label is a label — it does not need capitals and
   letter-spacing to be read. */
.telemetry {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin-top: 16px;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  overflow: hidden;
}
.tel {
  flex: 1 1 130px;
  min-width: 116px;
  padding: 11px 18px 12px;
  border-right: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background .2s var(--ease);
}
.tel:last-child { border-right: 0; }
.tel:hover { background: rgba(255, 255, 255, .014); }

.tel-k {
  font-size: 11px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--faint);
  font-weight: 500;
}
.tel-v {
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -.02em;
  color: var(--text);
  line-height: 1.2;
}
.tel-v small { font-size: 11.5px; font-weight: 500; color: var(--muted); letter-spacing: 0; }

/* A number that changed gets one short bloom, then settles. */
@keyframes telbloom {
  from { color: var(--accent); }
  to   { color: inherit; }
}
.tel-v.changed { animation: telbloom .9s var(--ease); }

.tel.is-ok   .tel-v { color: var(--ok); }
.tel.is-warn .tel-v { color: var(--warn); }
.tel.is-bad  .tel-v { color: var(--bad); }
.tel.is-off  .tel-v { color: var(--faint); }

/* ── Tabs ────────────────────────────────────────────────────────────────
   Underline indicator rather than pills: nine pills turned the header into
   a bag of buttons. The indicator is a glass rule — the active tab is the
   only place on the page where the accent is allowed to sit on its own. */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.tab {
  position: relative;
  padding: 8px 15px 12px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 450;
  user-select: none;
  transition: color .16s var(--ease);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); font-weight: 550; }
.tab.active::after {
  content: '';
  position: absolute;
  left: 12px; right: 12px; bottom: -1px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--accent);
  box-shadow: 0 0 12px -1px rgba(79, 143, 240, .7);
}
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Ungelesen-Zähler am Tab "Inbox". Er hängt am Tab und nicht am Inhalt, damit
   die Zahl auch sichtbar ist, während ein anderer Tab offen ist. */
.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 19px;
  height: 18px;
  margin-left: 8px;
  padding: 0 6px;
  border-radius: 9px;
  background: var(--accent);
  color: #07101c;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  vertical-align: 1px;
  font-variant-numeric: tabular-nums;
}
/* Nur beim Anstieg (neue Mail) — Lesen senkt die Zahl und bleibt ruhig. */
.tab-count.is-new { animation: tabcount .65s var(--ease); }

/* "unread" im Kopf der Inbox und der aktive Filter: beides ist klickbar. */
.unread-toggle { cursor: pointer; }
.unread-toggle:hover { color: var(--accent); }
.filterchip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 10px;
  border: 1px solid rgba(79, 143, 240, .42);
  border-radius: var(--r-chip);
  background: var(--accent-dim);
  color: #9dc0f8;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: border-color .16s var(--ease), color .16s var(--ease);
}
.filterchip b { font-weight: 600; opacity: .8; }
.filterchip:hover { border-color: var(--accent); color: var(--text); }
@keyframes tabcount {
  0%   { transform: scale(.55); box-shadow: 0 0 0 0 rgba(79,143,240,.6); }
  55%  { transform: scale(1.16); box-shadow: 0 0 0 8px rgba(79,143,240,0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(79,143,240,0); }
}

/* ── Cards ──────────────────────────────────────────────────────────────── */
/* One panel face. The lit top edge is the whole trick: a one-pixel gradient
   where the surface catches the light from above, so the panel reads as a
   physical face rather than a filled rectangle. */
.card {
  position: relative;
  /* The horizontal inset lives in a variable because `.sendbar` has to bleed
     to the card's edge — and the inset shrinks in the narrow media queries. */
  --card-x: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 26px var(--card-x) 30px;
  margin-bottom: var(--gap);
  box-shadow: var(--shadow-1);
}
.card::before {
  content: '';
  position: absolute;
  left: 14px; right: 14px; top: 0;
  height: 1px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .075), transparent);
}

/* ── Compose: a form in sections, not one long undifferentiated stack ───── */
/* Each section states what it is; the rule between them is the only divider.
   The card's own bottom padding moves into `.sendbar`, so the primary action
   sits on the card edge instead of floating in the middle of the form. */
/* `.card.compose` (0,2,0) outranks the media queries' `.card` (0,1,0) whatever
   their order — the compose card keeps its bottom padding at 0 so `.sendbar`
   can own that edge. */
.card.compose { padding-bottom: 0; }
.sect { padding-bottom: 26px; }
.sect + .sect { border-top: 1px solid var(--line-soft); padding-top: 24px; }
.sect-h { margin-bottom: 14px; }
.sect-t {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -.005em;
  color: var(--text);
}
.sect-d {
  margin: 3px 0 0;
  max-width: 64ch;
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
}
.sect > *:last-child { margin-bottom: 0; }
/* Helper text sits under the field it belongs to; the negative pull removes
   the gap that field already carries, so the two read as one unit. */
.sub-tight { margin: -6px 0 14px; }
.sub-tight:empty { display: none; }
.actbar { align-items: center; }
.b-act { width: auto; padding: 9px 16px; }
.file-narrow { max-width: 320px; padding: 8px; }
.preview-box {
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  padding: 16px;
  margin: 12px 0 0;
}

/* The compose header bar — same shape and rhythm as the inbox's `.mailbar`:
   a title on the left, quiet live status on the right. */
.composebar {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.composebar .grow { flex: 1 1 auto; }
.cbar-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.012em;
  color: var(--text);
}
.cbar-status {
  margin: 0;
  min-width: 0;
  max-width: 72%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
/* Nothing detected yet → nothing in the bar, not an empty box. */
.cbar-status:empty { display: none; }

/* To / Subject / From sit in the same recessed well as the inbox list; the
   label column is fixed, so all three fields start on one axis and the block
   reads as a mail header. The fields give up their own box — the well is the
   only surface here, and hover / focus carries the state, as a mail row does. */
.mailhead {
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  overflow: hidden;
  background: var(--bg-deep);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .45);
  margin-bottom: 24px;
}
.mh-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-soft);
  transition: background .12s var(--ease), box-shadow .12s var(--ease);
}
.mh-row:last-child { border-bottom: 0; }
.mh-row:hover, .mh-row:focus-within { background: var(--panel-hi); }
.mh-row:focus-within { box-shadow: inset 3px 0 0 var(--accent); }
/* The From row already marks itself with the sender domain's colour on the
   select's left edge — a second accent bar beside it would just be noise. */
.mh-row:has(select[data-dom]):focus-within { box-shadow: none; }
.mh-k {
  flex: 0 0 58px;
  margin: 0;
  padding-top: 8px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--faint);
}
.mh-f { flex: 1 1 auto; min-width: 0; }
.mh-row input, .mh-row textarea, .mh-row select {
  width: 100%;
  margin: 0;
  padding: 7px 2px;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  font-size: 13.5px;
}
.mh-row select { padding-right: 30px; }
/* No box of its own on hover or focus — the row is what reacts. Deliberately
   no `border-color` here: the shared focus rule and the select's own
   `[data-dom]` edge settle that between themselves, and overriding the colour
   would erase the sender domain's marker while the field is focused. */
.mh-row input:focus, .mh-row textarea:focus, .mh-row select:focus {
  outline: none;
  background: transparent;
  box-shadow: none;
}
.mh-row textarea { min-height: 52px; line-height: 1.5; }

/* The one primary action of the view, anchored to the card's bottom edge. */
.sendbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin: 0 calc(-1 * var(--card-x));
  padding: 18px var(--card-x) 20px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, .015), rgba(0, 0, 0, .1));
}
.sendbar .track {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}
.sendbar .track input { margin: 0; }
.send-btn {
  width: auto;
  margin-left: auto;
  padding: 12px 40px;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: .005em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16), 0 12px 28px -16px rgba(79, 143, 240, .95);
}
.sendbar + #sendResult:not(:empty) { padding: 0 0 22px; }

/* ── Forms ──────────────────────────────────────────────────────────────── */
label {
  display: block;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--muted);
  margin-bottom: 7px;
}
label b, label strong { color: var(--text); }

input, textarea, button, select { width: 100%; font: inherit; }
input[type=checkbox], input[type=radio] { width: auto; }

input, textarea, select {
  background: var(--bg-deep);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--r-ctl);
  padding: 10px 12px;
  margin-bottom: 16px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .3);
  transition: border-color .16s var(--ease), background .16s var(--ease),
              box-shadow .16s var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, textarea:hover, select:hover { border-color: #283240; }
input:focus, textarea:focus, select:focus, .editor:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-deep);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .3),
              0 0 0 3px rgba(79, 143, 240, .16);
}
textarea { min-height: 100px; resize: vertical; line-height: 1.55; }

/* Native selects get the platform arrow; give them room and a custom one. */
select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%238b98a5' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 32px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────
   Default = primary. `.secondary` = quiet. `.danger` = irreversible.
   Every button answers the press: it lifts one pixel on hover and settles
   below its resting line on click. That physical reply is what makes a panel
   feel alive — not a transition on every element on the page. */
button {
  background: var(--accent);
  border: 1px solid transparent;
  color: #fff;
  border-radius: var(--r-ctl);
  padding: 10px 18px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: .002em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .13);
  transition: background .16s var(--ease), transform .1s var(--ease),
              border-color .16s var(--ease), opacity .16s var(--ease);
}
button:hover { background: var(--accent-hi); }
button:active { background: var(--accent); transform: translateY(1px); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: .4; cursor: not-allowed; transform: none; }
button:disabled:hover { background: var(--accent); }

button.secondary {
  background: var(--panel-hi);
  color: var(--text);
  border-color: var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .045);
}
button.secondary:hover { background: var(--raise); border-color: var(--raise); }

button.danger {
  background: transparent;
  color: var(--bad);
  border-color: #402220;
  box-shadow: none;
}
button.danger:hover { background: rgba(217, 95, 92, .1); border-color: #5e2e2c; }

/* ── Rows ───────────────────────────────────────────────────────────────── */
.row { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.row > * { margin-bottom: 0; }

/* ── Messages ───────────────────────────────────────────────────────────── */
.msg {
  font-size: 13px;
  margin-top: 12px;
  padding: 11px 14px;
  border-radius: var(--r-ctl);
  background: var(--panel-hi);
  color: var(--muted);
  border-left: 3px solid var(--line);
}
.msg.ok   { background: rgba(63, 174, 109, .10); color: #83d3a2; border-left-color: var(--ok); }
.msg.err  { background: rgba(217, 95, 92, .10); color: #f0a09e; border-left-color: var(--bad); }
.msg.warn { background: rgba(201, 150, 78, .10); color: #ddb583; border-left-color: var(--warn); }
.msg b { color: var(--text); }

/* ── Badges, chips, status ──────────────────────────────────────────────── */
.badge, .status-badge, .kind-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-chip);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
  background: var(--panel-hi);
  color: var(--muted);
}

.badge.ok, .status-opened { background: rgba(63, 174, 109, .14);  color: #7bd3a2; }
.badge.warn                { background: rgba(201, 150, 78, .14); color: #ddb583; }
.badge.bad                 { background: rgba(217, 95, 92, .14);  color: #f0a09e; }

.status-accepted { background: rgba(79, 143, 240, .14); color: #9cbcfa; }
.status-replied  { background: rgba(139, 120, 216, .16); color: #b8a9ef; }
.status-bounced, .status-failed { background: rgba(217, 95, 92, .14); color: #f0a09e; }
.status-dryrun   { background: rgba(139, 153, 167, .14); color: var(--muted); }
.status-unknown  { background: rgba(201, 150, 78, .14); color: #ddb583; }

.kind-chip { border: 1px solid var(--line); background: transparent; font-weight: 500; }

/* The domain chip: colour comes from the row's data-dom. */
.mailrow .kind-chip[data-dom],
.kind-chip[data-dom] {
  border-color: color-mix(in srgb, var(--dom) 55%, transparent);
  color: var(--dom);
  background: color-mix(in srgb, var(--dom) 12%, transparent);
}

.kind-reply  { border-color: rgba(139, 120, 216, .5); color: var(--reply); }
.kind-bounce { border-color: rgba(217, 95, 92, .55);  color: var(--bad); }

/* ── Tables ─────────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}
/* Sentence case, no tracking. A header is read, not decoded — capitals and
   letter-spacing make a table shout its column names and hide the data. */
th {
  color: var(--faint);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
  border-bottom-color: var(--line);
  white-space: nowrap;
}
tbody tr:hover > td, table tr:hover > td { background: rgba(255, 255, 255, .017); }
tr:last-child > td { border-bottom: 0; }

/* Numeric columns line up only in a tabular figure. */
td.num, th.num, .tel-v { font-variant-numeric: tabular-nums; }

.detail-row > td { background: var(--bg-deep); border-bottom-color: var(--line); }
tr.selected > td { background: rgba(79, 143, 240, .10); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.scroll-hint { display: none; }

/* Progress bar (campaign list) — was unstyled markup before. */
.bar {
  display: block;
  width: 100%;
  min-width: 90px;
  height: 5px;
  border-radius: 999px;
  background: var(--bg-deep);
  overflow: hidden;
  margin-top: 6px;
}
.bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #3a6fc4, var(--accent-hi));
  transition: width .4s var(--ease-out);
}

/* ── Editor & toolbar ───────────────────────────────────────────────────── */
.toolbar { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 8px; }
.toolbar button {
  width: auto;
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 500;
  background: var(--panel-hi);
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: var(--r-chip);
  box-shadow: none;
}
.toolbar button:hover { background: var(--raise); color: var(--text); }
.toolbar button.on { background: var(--accent); color: #fff; }
.toolbar button:disabled { opacity: .3; }

.editor {
  min-height: 150px;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  padding: 15px;
  margin-bottom: 16px;
  outline: none;
  overflow: auto;
  line-height: 1.6;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .3);
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.editor:focus {
  border-color: var(--accent);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .3),
              0 0 0 3px rgba(79, 143, 240, .16);
}
.editor:empty::before { content: attr(data-placeholder); color: var(--faint); }
.editor a { color: #6ea8ff; }
.editor img { max-width: 100%; height: auto; }

.ed-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.html-btn {
  width: auto;
  padding: 4px 11px;
  font-size: 11.5px;
  font-weight: 550;
  letter-spacing: 0;
  background: var(--panel-hi);
  color: var(--muted);
  border: 1px solid var(--line);
  box-shadow: none;
}
.html-btn:hover { background: var(--raise); color: var(--text); }

/* ── Attachments ────────────────────────────────────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  padding: 6px 10px;
  font-size: 12.5px;
}
.chip .x { cursor: pointer; color: var(--faint); font-weight: 700; padding: 0 2px; }
.chip .x:hover { color: var(--bad); }

input[type=file] { border: 1px dashed #283240; padding: 7px; cursor: pointer; background: var(--bg-deep); }
input[type=file]::file-selector-button,
input[type=file]::-webkit-file-upload-button {
  background: var(--panel-hi);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--r-chip);
  padding: 7px 14px;
  margin-right: 12px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
input[type=file]::file-selector-button:hover { background: var(--raise); }

/* ── Link popover ───────────────────────────────────────────────────────── */
.linkpop {
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  padding: 14px;
  margin-bottom: 12px;
}
.linkpop .hint { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.linkpop .row { margin-bottom: 0; align-items: center; }

/* ── Header user area ───────────────────────────────────────────────────── */
.userbox {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12.5px;
  color: var(--muted);
}
.userbox button {
  width: auto;
  padding: 5px 12px;
  font-size: 12px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}
.userbox button:hover { background: var(--panel-hi); color: var(--text); }

.eye {
  width: auto;
  padding: 9px 12px;
  background: var(--panel-hi);
  color: var(--muted);
  border: 1px solid var(--line);
  font-size: 13px;
}
.eye:hover { background: var(--raise); }

/* ── Token box ──────────────────────────────────────────────────────────── */
.token-box {
  background: var(--bg-deep);
  padding: 12px 14px;
  border-radius: var(--r-ctl);
  border: 1px solid var(--line);
  word-break: break-all;
  margin-bottom: 14px;
  font-size: 12.5px;
  color: var(--text);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .35);
}

/* ── Mail wells ─────────────────────────────────────────────────────────── */
.mail-preview {
  max-height: 260px;
  overflow: auto;
  padding: 16px;
  background: var(--bg-deep);
  border-radius: var(--r-ctl);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .45);
}
.mail-preview img { max-width: 100%; }
.mail-preview-frame {
  width: 100%;
  height: 280px;
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  background: #fff;
}

/* Incoming mail is rendered like a mail client, not like the app: light
   background, dark text. A light-themed mail on the dark theme is unreadable. */
.mail-reader-body {
  background: #fff;
  color: #1c2126;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  overflow: auto;
  max-height: 72vh;
  line-height: 1.6;
  box-shadow: 0 18px 40px -32px #000;
}
.mail-reader-body img { max-width: 100%; height: auto; }
.mail-reader-body a { color: #0b57d0; }

/* ── Inbox ──────────────────────────────────────────────────────────────── */
.mailbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.mailbar .grow { flex: 1 1 auto; }

.foldbtn {
  width: auto;
  padding: 6px 15px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  font-weight: 600;
  font-size: 13px;
  border-radius: 999px;
}
.foldbtn:hover { color: var(--text); background: var(--panel-hi); }
.foldbtn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.foldcnt { font-size: 11px; font-weight: 700; opacity: .8; margin-left: 3px; }

.maillist {
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  overflow: hidden;
  background: var(--bg-deep);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .45);
}

/* The left edge carries the receiving domain's colour — the one thing you
   need to know about a mail that arrived in five different mailboxes. */
.mailrow {
  position: relative;
  padding: 9px 16px 9px 18px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  transition: background .12s var(--ease);
}
.mailrow::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--dom, transparent);
}
.mailrow:last-child { border-bottom: 0; }
.mailrow:hover { background: var(--panel-hi); }

/* Unread has to be readable at a glance from across the room, the way Gmail
   and Yahoo do it: unread is heavy and bright, read is light and grey. The
   difference is the weight of the subject line, not a coloured dot alone —
   IBM Plex Sans carries 700 without turning into a slab. */
.mailrow.unread { background: #1e2b3a; }
.mailrow.unread:hover { background: #243347; }
.mailrow.unread .mr-subj { font-weight: 700; color: #fff; letter-spacing: -.005em; }
.mailrow.unread .mr-from { color: var(--text); font-weight: 600; }
.mailrow.read .mr-subj { font-weight: 400; color: var(--muted); }
.mailrow.read .mr-from { color: var(--faint); font-weight: 400; }
.mailrow.unread .mr-subj::before {
  content: '';
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--dom, var(--accent));
  margin-right: 9px;
  vertical-align: middle;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--dom, var(--accent)) 30%, transparent);
}

/* ── One mail at a time ──────────────────────────────────────────────────
   Reading opens IN the panel instead of below the list: list or mail, never
   both stacked. Without this the reader appeared under the list and the
   operator had to scroll down to it. */
#inboxView.reading #inboxTable,
#inboxView.reading #inboxPager,
#repliesView.reading #repliesTable { display: none; }
#inboxView.reading #inboxReader,
#repliesView.reading #repliesReader { margin-top: 0; animation: rise .3s var(--ease) both; }

/* ── Pager: ten mails a page ────────────────────────────────────────────── */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.pager-info { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.pager-gap { color: var(--faint); font-size: 12.5px; padding: 0 2px; align-self: center; }
.pager-btns { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.pager-btns button {
  width: auto;
  padding: 7px 13px;
  font-size: 12.5px;
  font-weight: 600;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}
.pager-btns button:hover:not(:disabled) { color: var(--text); background: var(--panel-hi); }
.pager-btns button:disabled { opacity: .4; cursor: default; }
.pager-btns .page-num { min-width: 36px; padding: 7px 9px; font-variant-numeric: tabular-nums; }
.pager-btns .page-num.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  opacity: 1;              /* the current page is disabled but must read as on */
}

/* Two lines, not three: subject + date on top, sender + domain below. Every
   line is nowrap with an ellipsis, so all ten rows are exactly the same
   height — a list that jumps by a line wherever a subject is long reads as
   broken, and the operator scans by position, not by reading. */
.mr-top {
  display: flex;
  align-items: baseline;
  gap: 14px;
  min-width: 0;
}
.mr-subj {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mr-date {
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--faint);
  font-size: 11px;
  white-space: nowrap;
}
.mr-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-top: 3px;
}
.mr-from {
  flex: 0 1 auto;
  min-width: 0;
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* The domain chip is a label, not a headline: it sits after the sender on the
   second line and stays quiet until you look for it. */
.mr-chip {
  flex: 0 0 auto;
  font-size: 10.5px;
  padding: 1px 7px;
}

/* ── Sent: the inbox's rows, plus the delivery facts ──────────────────────
   Subject leads and the recipient follows, exactly as in the inbox — this
   list only adds what the inbox has no use for: the delivery state as a badge
   on the first line and the two counters on the second. Same well, same
   hairlines, same domain-coloured left edge. */
.sentrow .mr-subj { font-weight: 600; color: var(--text); letter-spacing: -.005em; }
.sentrow .mr-from { color: var(--muted); }
.sr-status { flex: 0 0 auto; margin-left: auto; }
.sr-status .status-badge { vertical-align: middle; }
.sr-metrics {
  flex: 0 0 auto;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/* A number in bright text, an absence in grey — the same reading as before,
   just without a table cell around every one of them. */
.sr-m { color: var(--text); font-weight: 600; }
.sr-m.dim { color: var(--faint); font-weight: 400; }

/* The opened row keeps the domain edge, so the mail below the line is still
   recognisably the same mail rather than a panel that arrived from nowhere. */
.sentdetail {
  position: relative;
  padding: 14px 16px 16px 18px;
  background: var(--panel-hi);
  border-bottom: 1px solid var(--line);
}
.sentdetail::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--dom, transparent);
}
.sentdetail:last-child { border-bottom: 0; }
.sentdetail .mail-preview-frame { margin-top: 2px; }

#inboxReader {
  margin-top: 20px;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}
.readhead { }
.readsubj { font-size: 19px; font-weight: 600; letter-spacing: -.015em; margin-bottom: 12px; }

.readmeta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  background: var(--bg-deep);
  padding: 14px 16px;
}
.readmeta b { color: var(--text); }
.readmeta .hm { display: flex; gap: 14px; padding: 2px 0; }
.readmeta .hm-k {
  flex: 0 0 82px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding-top: 2px;
}
.readmeta .hm > span:last-child { color: var(--text); word-break: break-word; }

.replyas {
  background: color-mix(in srgb, var(--reply) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--reply) 30%, transparent);
  border-left: 3px solid var(--reply);
  border-radius: 0 var(--r-ctl) var(--r-ctl) 0;
  padding: 11px 15px;
  margin-bottom: 16px;
  font-size: 12.5px;
  color: var(--muted);
}
.replyas b { color: var(--text); }

#replyBox { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 20px; }

/* ── Template list ──────────────────────────────────────────────────────── */
.tpl-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; }
.tpl-actions button { width: auto; padding: 7px 14px; font-size: 12.5px; margin-right: 0; }

/* ── Load sequence ───────────────────────────────────────────────────────
   One orchestrated entrance for the first paint, then nothing. */
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* The masthead is position:sticky — it fades only, because a transform on a
   sticky element breaks its own stickiness while the animation runs. */
.masthead { animation: fade .35s var(--ease) both; }
.tabs, #mainView > .card:not(.hidden) { animation: rise .45s var(--ease) both; }
.tabs { animation-delay: .06s; }
#mainView > .card:not(.hidden) { animation-delay: .12s; }

/* The four measured values assemble in sequence as the panel comes up. The
   cells are children of the sticky masthead, so only they move — a transform
   on the sticky element itself would break its stickiness. */
.tel { animation: rise .5s var(--ease-out) both; }
.tel:nth-child(1) { animation-delay: .05s; }
.tel:nth-child(2) { animation-delay: .1s; }
.tel:nth-child(3) { animation-delay: .15s; }
.tel:nth-child(4) { animation-delay: .2s; }

/* The compose sender select wears its domain's colour on the left edge. */
select[data-dom] { border-left: 3px solid var(--dom); padding-left: 10px; }

/* Skeletons for anything that is still loading. */
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton {
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--panel-hi) 25%, var(--raise) 50%, var(--panel-hi) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

/* ── Reduced motion ─────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* ── Narrow screens ──────────────────────────────────────────────────────
   One layout that reflows, driven by viewport width. Nothing is hidden. */
@media (max-width: 900px) {
  .wrap { padding: 0 14px 56px; }
  .masthead { padding: 14px 0 12px; margin-bottom: 16px; }
  h1 { font-size: 17px; }
  .card { --card-x: 15px; padding: 15px; }
  .send-btn { padding: 11px 30px; }
  .telemetry { margin-top: 12px; }
  .tel { flex: 1 1 50%; min-width: 0; padding: 8px 12px; border-bottom: 1px solid var(--line); }
  .tel:nth-child(2n) { border-right: 0; }
  .tel:nth-last-child(-n+2) { border-bottom: 0; }
  .tel-v { font-size: 16px; }

  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: 0 0 auto; padding: 9px 12px 11px; }

  .row { gap: 8px; margin-bottom: 12px; }
  .row > * { flex: 1 1 100% !important; min-width: 0 !important; }

  .ed-head { flex-wrap: wrap; gap: 6px; }
  .ed-head > * { min-width: 0; }
  .userbox { margin-left: 0; width: 100%; justify-content: space-between; }

  /* 16px stops iOS Safari from zooming the page when a field is focused. */
  input, textarea, select, button { font-size: 16px; }
  button, select, input[type=file] { min-height: 44px; }
  input[type=checkbox], input[type=radio] { width: 22px; height: 22px; min-height: 22px; }
  label { padding: 3px 0; }
  .toolbar button { padding: 9px 11px; font-size: 15px; }
  .eye { padding: 12px 14px; font-size: 16px; }
  .userbox button, .html-btn, .tpl-actions button { width: auto; padding: 9px 12px; font-size: 14px; }

  th, td { padding: 8px; font-size: 13px; }
  th { font-size: 11px; }
  .table-wrap { margin: 0 -15px; padding: 0 15px; }
  .table-wrap th, .table-wrap td { white-space: nowrap; }
  .table-wrap td.sub, .table-wrap td.wrap { white-space: normal; min-width: 140px; }
  .badge, .status-badge, .kind-chip { white-space: nowrap; }
  .scroll-hint { display: block; font-size: 11px; color: var(--faint); margin: -2px 0 6px; }

  .mail-preview-frame { height: 300px; }
  .mail-reader-body { padding: 16px; max-height: none; }
  .readsubj { font-size: 17px; }
  .readmeta .hm { flex-direction: column; gap: 0; }
  .readmeta .hm-k { flex: none; padding-bottom: 1px; }
  .editor { min-height: 180px; }
  .chip { font-size: 12px; }
}

@media (max-width: 400px) {
  .wrap { padding: 0 10px 48px; }
  h1 { font-size: 16px; }
  .card { --card-x: 12px; padding: 12px; }
  .table-wrap { margin: 0 -12px; padding: 0 12px; }
  th, td { padding: 7px 6px; }

  /* Too tight for the label beside the button — the action takes the full
     width on its own line instead of squeezing both. */
  .send-btn { width: 100%; margin-left: 0; padding: 12px 20px; }
}

/* ── Print ──────────────────────────────────────────────────────────────── */
@media print {
  .masthead, .tabs, button { display: none !important; }
  body { background: #fff; color: #000; }
  .card { border-color: #ccc; break-inside: avoid; }
}
