:root {
  --bg: #f6f7f9; --panel: #fff; --text: #1f2328; --muted: #667085; --line: #e4e7ec;
  --accent: #1d5fd1; --accent-ink: #fff; --hover: #eef3fc; --unread: #fff; --read: #f8f9fb;
  --danger: #c4320a; --warn: #b54708; --ok: #067647;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418; --panel: #191d23; --text: #e6e8eb; --muted: #98a2b3; --line: #2a3039;
    --accent: #6ea0ff; --accent-ink: #0b1220; --hover: #20283a; --unread: #1d222a; --read: #161a20;
    --danger: #ff8a65; --warn: #fdb022; --ok: #47cd89;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--accent); text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; }
input, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type=checkbox], input[type=file] { width: auto; border: 0; padding: 0; }
button, .btn { display: inline-block; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 14px; cursor: pointer; color: var(--text); font-size: 14px; }
button:hover, .btn:hover { background: var(--hover); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; padding: 9px 22px; }
button.danger { color: var(--danger); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); }
form.inline { display: inline; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 10px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 18px; color: var(--text); white-space: nowrap; }
.brand span, .login h1 span { color: var(--accent); margin-left: 2px; }
.search { flex: 1; max-width: 560px; }
.search input { background: var(--bg); border-color: transparent; }
.me { margin-left: auto; text-align: right; font-size: 14px; line-height: 1.2; }
.me small { display: block; color: var(--muted); }
.menu-btn { display: none; }

.layout { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 57px); }
.side { padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; }
.side a { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-radius: 0 18px 18px 0;
  color: var(--text); }
.side a:hover { background: var(--hover); }
.side a.on { background: var(--hover); color: var(--accent); font-weight: 600; }
.side a b { font-size: 13px; }
.side a i { font-style: normal; color: var(--muted); font-size: 13px; }
.side hr { border: 0; border-top: 1px solid var(--line); margin: 10px 4px; width: auto; }
.side .compose-btn { justify-content: center; background: var(--accent); color: var(--accent-ink); border-radius: 14px;
  padding: 12px; margin-bottom: 12px; font-weight: 600; }
.side .compose-btn:hover { background: var(--accent); opacity: .92; }
.quota { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.quota.warn { color: var(--warn); font-weight: 700; }
main { padding: 16px 24px 48px; min-width: 0; max-width: 1100px; }

.banner { background: #fff4e5; color: #7a4100; border: 1px solid #f6d7a7; padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }
@media (prefers-color-scheme: dark) { .banner { background: #2f2312; color: #fcd9a5; border-color: #5c4318; } }
.flash { background: var(--hover); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; }
.error { background: color-mix(in srgb, var(--danger) 12%, var(--panel)); color: var(--danger); border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; }
.hint, .empty { color: var(--muted); }
.pagehead { margin: 4px 0 14px; font-size: 20px; }

.list { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.list li + li { border-top: 1px solid var(--line); }
.list a { display: grid; grid-template-columns: 200px 1fr auto; gap: 14px; padding: 11px 16px; color: var(--text); background: var(--read); }
.list li.unread a { background: var(--unread); }
.list li.unread .who, .list li.unread .what b, .list li.unread .when { font-weight: 700; }
.list a:hover { background: var(--hover); }
.who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who small { color: var(--muted); margin-left: 4px; }
.what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.what b { font-weight: 500; }
.snip { color: var(--muted); }
.when { color: var(--muted); font-size: 13px; white-space: nowrap; }
.pager { display: flex; justify-content: space-between; padding: 12px 4px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.subject { font-size: 21px; margin: 6px 0 14px; overflow-wrap: anywhere; }
.msg { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; }
.msg > header { padding: 12px 16px; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; cursor: pointer; }
.msg .addr, .msg .date, .msg .rcpts { color: var(--muted); font-size: 13px; }
.msg .rcpts { grid-column: 1 / -1; overflow-wrap: anywhere; }
.msg .snip-line { display: none; grid-column: 1 / -1; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg.collapsed .snip-line { display: block; }
.msg.collapsed .rcpts, .msg.collapsed .msg-body { display: none; }
.msg-body { padding: 0 16px 14px; }
.tag { font-size: 11px; background: var(--hover); border-radius: 4px; padding: 1px 6px; margin-left: 6px; }
.tag.spam { color: var(--danger); }
.html-body { width: 100%; border: 0; min-height: 80px; background: #fff; border-radius: 6px; display: block; }
.text-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.images-note { font-size: 13px; color: var(--muted); background: var(--bg); padding: 6px 10px; border-radius: 6px; margin-bottom: 8px; }
.images-note button { padding: 2px 10px; font-size: 13px; margin-left: 6px; }
.files { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.files li { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 14px; }
.files small { color: var(--muted); }
.msg-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }
.msg-actions .quiet { margin-left: auto; color: var(--muted); font-size: 13px; }
.delivery { list-style: none; margin: 0 0 10px; padding: 8px 12px; background: var(--bg); border-radius: 8px; font-size: 13px; }
.delivery b { color: var(--ok); }
.delivery li.bad b { color: var(--danger); }

.compose { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.compose .row { display: flex; align-items: center; gap: 10px; }
.compose .lbl { flex: 0 0 64px; color: var(--muted); font-size: 14px; }
.compose .from-fixed { font-size: 14px; }
.compose textarea { min-height: 260px; resize: vertical; line-height: 1.5; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.check small { color: var(--muted); }
.orig-preview { font-size: 13px; color: var(--muted); border-left: 3px solid var(--line); padding-left: 10px; }
.orig-preview .text-body { max-height: 240px; overflow: auto; margin-top: 6px; }
.send-row { display: flex; align-items: center; gap: 14px; }
.count { font-size: 13px; color: var(--muted); }
.count.over { color: var(--danger); font-weight: 600; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 16px; }
.form { display: flex; flex-direction: column; gap: 12px; max-width: 520px; }
.form label, .login label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.form h3 { margin: 0; }
.form button { align-self: flex-start; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }
.login h1 { margin: 0 0 4px; font-size: 22px; text-align: center; }

.meter-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; max-width: 640px; }
.meter-card .big { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; }
.meter-card .big small { font-size: 16px; color: var(--muted); font-weight: 400; }
.meter { height: 10px; background: var(--bg); border-radius: 6px; overflow: hidden; margin: 8px 0 12px; }
.meter span { display: block; height: 100%; background: var(--accent); }
.meter span.warn { background: var(--warn); }
.grid { border-collapse: collapse; width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; font-size: 14px; }
.grid.narrow { max-width: 420px; }
.grid th, .grid td { text-align: left; padding: 7px 10px; border-top: 1px solid var(--line); }
.grid th { color: var(--muted); font-weight: 500; border-top: 0; }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.grid .clip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
h3 { margin: 26px 0 10px; font-size: 16px; }

@media (max-width: 760px) {
  .top { gap: 10px; padding: 8px 12px; }
  .menu-btn { display: inline-block; padding: 6px 10px; }
  .me { display: none; }
  .brand { font-size: 16px; }
  .layout { grid-template-columns: 1fr; }
  .side { display: none; position: fixed; inset: 49px 0 auto 0; z-index: 4; background: var(--panel); border-bottom: 1px solid var(--line);
    box-shadow: 0 8px 24px rgba(0,0,0,.15); }
  .side.open { display: flex; }
  main { padding: 12px 12px 40px; }
  .list a { grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 12px; }
  .list .what { grid-column: 1 / -1; grid-row: 2; }
  .compose .row { flex-direction: column; align-items: stretch; gap: 4px; }
  .compose .lbl { flex: none; }
  .grid .clip { max-width: 120px; }
}

/* mailbox switcher, tags, bulk */
.boxes { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 4px 10px; }
.side .boxes a { border-radius: 14px; padding: 4px 11px; font-size: 13px; border: 1px solid var(--line); gap: 4px; }
.side .boxes a.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.box-tag { display: inline-block; font-size: 11px; font-weight: 500; color: var(--muted); border: 1px solid var(--line);
  border-radius: 4px; padding: 0 5px; margin-right: 6px; vertical-align: 2px; }
.subject .box-tag { font-size: 12px; margin-left: 8px; }
.pagehead small { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 6px; }
select { font: inherit; color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
.pill { font-size: 12px; border-radius: 10px; padding: 1px 8px; background: var(--hover); white-space: nowrap; }
.pill.running, .pill.sent { color: var(--ok); }
.pill.paused, .pill.queued { color: var(--warn); }
.pill.failed, .pill.cancelled { color: var(--danger); }
.pill.skipped, .pill.done, .pill.test { color: var(--muted); }
.err { color: var(--danger); }
.meter-card.slim { padding: 10px 16px; margin-bottom: 14px; }
.preview summary { cursor: pointer; font-weight: 600; }
.card h3 small, .card h3 { margin-top: 0; }
code { background: var(--hover); border-radius: 4px; padding: 0 4px; font-size: 13px; }
@media (max-width: 760px) { .grid { display: block; overflow-x: auto; } }
