:root {
  --bg: #f4f5f7; --panel: #fff; --ink: #1d2330; --muted: #6b7385; --line: #e3e6ec;
  --accent: #2d5bff; --accent-soft: #e8eeff; --ok: #15803d; --ok-soft: #e6f6ec;
  --warn: #b45309; --warn-soft: #fdf3e2; --bad: #b91c1c; --bad-soft: #fdeaea;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 "Inter", system-ui, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* layout */
.top { background: #141925; color: #fff; }
.top .wrap { display: flex; align-items: center; gap: 24px; height: 56px; }
.brand { font-weight: 700; font-size: 17px; color: #fff; letter-spacing: .2px; }
.brand span { color: #8aa4ff; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a { color: #c5cbd8; padding: 6px 12px; border-radius: 6px; white-space: nowrap; }
.nav a:hover, .nav a.on { background: #263046; color: #fff; text-decoration: none; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 24px; padding-bottom: 48px; }
h1 { font-size: 22px; margin: 0 0 18px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.head h1 { margin: 0; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g2 { grid-template-columns: 1fr 1fr; }
.g-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 900px) { .g4 { grid-template-columns: 1fr 1fr; } .g2, .g-side { grid-template-columns: 1fr; } }

/* stats */
.stat .lbl { color: var(--muted); font-size: 13px; }
.stat .val { font-size: 26px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--muted); font-size: 13px; }
.val.ok { color: var(--ok); }

/* pipeline */
.pipe { display: flex; gap: 8px; flex-wrap: wrap; }
.pipe a { flex: 1; min-width: 110px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); }
.pipe a:hover { border-color: var(--accent); text-decoration: none; }
.pipe a.on { border-color: var(--accent); background: var(--accent-soft); }
.pipe b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.pipe small { color: var(--muted); }

/* table */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
th a { color: inherit; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tr:hover td { background: #fafbfc; }
td .dom { font-weight: 600; color: var(--ink); }

/* badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef0f4; color: #4a5263; }
.b-emailing, .b-sent { background: var(--accent-soft); color: var(--accent); }
.b-replied, .b-negotiating { background: var(--warn-soft); color: var(--warn); }
.b-deal, .b-live { background: var(--ok-soft); color: var(--ok); }
.b-rejected, .b-bounced, .b-unsubscribed { background: var(--bad-soft); color: var(--bad); }
.pos { color: var(--ok); } .neg { color: var(--bad); }

/* forms */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px; font: inherit; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }
.field { margin-bottom: 14px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn { display: inline-block; padding: 9px 16px; border-radius: 7px; border: 1px solid var(--accent); background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.danger { background: #fff; color: var(--bad); border-color: #f1c4c4; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input { max-width: 300px; }
.filters select { max-width: 180px; }
.inline { display: inline; }
.inline select { width: auto; padding: 4px 8px; font-size: 13px; }

.profit-box { padding: 12px 14px; border-radius: 8px; background: var(--ok-soft); margin-bottom: 14px; display: flex; justify-content: space-between; }
.profit-box.neg { background: var(--bad-soft); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.feed li:last-child { border: 0; }
.feed time { display: block; color: var(--muted); font-size: 12px; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.error { background: var(--bad-soft); color: var(--bad); }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 14px; }
.empty { text-align: center; padding: 40px; color: var(--muted); }
code { background: #eef0f4; padding: 1px 6px; border-radius: 4px; font-size: 13px; }

.login { max-width: 360px; margin: 12vh auto; }

/* ---- v2 ---- */
.nav .count { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: #e5484d; color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.top .wrap { gap: 16px; }
.status-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid var(--line); background: var(--panel); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: #c4c9d4; }
.dot.on { background: #22a35a; box-shadow: 0 0 0 3px #22a35a22; }
.dot.off { background: #e5484d; }
.status-bar .grow { flex: 1; }
.hint { background: var(--warn-soft); color: #7a4a06; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.hint a { color: inherit; text-decoration: underline; }
.meter { height: 6px; background: #eef0f4; border-radius: 99px; overflow: hidden; margin-top: 6px; }
.meter i { display: block; height: 100%; background: var(--accent); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--ink); margin-bottom: 12px; }
.check input { width: auto; }
.thread { display: flex; flex-direction: column; gap: 12px; }
.msg { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: #fff; max-width: 92%; }
.msg.in { align-self: flex-start; border-left: 3px solid var(--warn); }
.msg.out { align-self: flex-end; background: #f6f8ff; border-right: 3px solid var(--accent); }
.msg.auto, .msg.bounce { opacity: .6; }
.msg .meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; display: flex; gap: 8px; flex-wrap: wrap; }
.msg .body { white-space: pre-wrap; font-size: 14px; word-break: break-word; }
.msg details summary { cursor: pointer; font-size: 12px; color: var(--muted); margin-top: 6px; }
.compose textarea[name=body] { min-height: 220px; font-family: inherit; }
.inbox-row { display: block; padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--ink); }
.inbox-row:hover { background: #fafbfc; text-decoration: none; }
.inbox-row.unread { background: #f6f8ff; }
.inbox-row.unread .dom::before { content: "● "; color: var(--accent); }
.inbox-row .top-line { display: flex; justify-content: space-between; gap: 10px; }
.inbox-row .snippet { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); font-size: 14px; }
.tabs a.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.tabs a:hover { text-decoration: none; }
.secret-set { font-size: 12px; color: var(--ok); }
.vars code { margin-right: 4px; }
pre.preview { white-space: pre-wrap; background: #f6f8ff; padding: 12px; border-radius: 8px; font: inherit; font-size: 14px; }
.sticky { position: sticky; top: 12px; }
