:root {
  --bg: #f6f7fb; --card: #ffffff; --ink: #111827; --muted: #6b7280; --line: #e5e7eb;
  --brand: #4f46e5; --brand-ink: #ffffff; --brand-soft: #eef2ff;
  --ok: #059669; --ok-soft: #ecfdf5; --warn: #b45309; --warn-soft: #fffbeb;
  --bad: #dc2626; --bad-soft: #fef2f2; --info: #0369a1; --info-soft: #f0f9ff;
  --radius: 14px; --shadow: 0 1px 2px rgba(17,24,39,.06), 0 4px 16px rgba(17,24,39,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
h1 { font-size: 22px; margin: 8px 0 2px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h2.mt { margin-top: 22px; }
code { font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; background: #f3f4f6; padding: 1px 5px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--bad); min-height: 1.2em; margin: 8px 0 0; }
.msg { min-height: 1.2em; margin: 8px 0 0; font-size: 14px; }
.msg.ok { color: var(--ok); } .msg.bad { color: var(--bad); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin: 0 0 12px; }
input, select { display: block; width: 100%; margin-top: 5px; padding: 9px 11px; font: inherit; color: inherit; background: #fff; border: 1px solid #d1d5db; border-radius: 10px; }
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }
.btn { font: inherit; font-weight: 600; border: 1px solid transparent; border-radius: 10px; padding: 9px 16px; cursor: pointer; }
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: #f9fafb; }
.btn.danger { background: #fff; border-color: #fecaca; color: var(--bad); }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; text-align: center; }
.login-card label { text-align: left; margin-top: 18px; }
.login-card .btn { width: 100%; }
.brand-mark { width: 52px; height: 52px; margin: 0 auto; display: grid; place-items: center; border-radius: 14px; background: linear-gradient(135deg, #4f46e5, #db2777); color: #fff; font-weight: 800; font-size: 26px; }
.brand-mark.sm { width: 34px; height: 34px; font-size: 18px; border-radius: 10px; margin: 0; }

.top { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; min-width: 0; }
.brand small { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 99px; background: #f3f4f6; color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.tabs { display: flex; gap: 4px; padding: 10px 16px 0; overflow-x: auto; }
.tabs button { font: inherit; font-weight: 600; background: none; border: 0; padding: 8px 14px; border-radius: 10px 10px 0 0; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }
main { padding: 16px; max-width: 1200px; margin: 0 auto; display: block; }
main section > * + * { margin-top: 16px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { border-radius: var(--radius); padding: 14px 16px; border: 1px solid var(--line); background: #fff; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); }
.stat.c1 { border-top: 4px solid #4f46e5; } .stat.c2 { border-top: 4px solid #059669; }
.stat.c3 { border-top: 4px solid #d97706; } .stat.c4 { border-top: 4px solid #dc2626; }
.stat.c5 { border-top: 4px solid #db2777; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.grid2.wide-left { grid-template-columns: 1.6fr 1fr; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 820px) { .grid2, .grid2.wide-left { grid-template-columns: 1fr; } }
@media (max-width: 520px) { .row3 { grid-template-columns: 1fr; } .top { flex-wrap: wrap; } }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0 0 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--line); }
table.list td { padding: 9px 8px; border-bottom: 1px solid #f3f4f6; vertical-align: top; overflow-wrap: anywhere; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: #fafafa; }
table.list tr.sel td { background: var(--brand-soft); }
.st { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.st.sent { background: var(--ok-soft); color: var(--ok); }
.st.queued, .st.sending { background: var(--info-soft); color: var(--info); }
.st.failed, .st.bounced, .st.complained { background: var(--bad-soft); color: var(--bad); }
.st.blocked { background: var(--warn-soft); color: var(--warn); }
.switch { position: relative; width: 42px; height: 24px; display: inline-block; margin: 0; }
.switch input { opacity: 0; width: 0; height: 0; margin: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: #d1d5db; border-radius: 99px; transition: .15s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.filters select, .filters input { width: auto; flex: 1 1 160px; margin: 0; }
.detail { margin-top: 14px; padding: 14px; border-radius: 12px; background: #f9fafb; border: 1px solid var(--line); font-size: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
pre.snip { background: #0f172a; color: #e2e8f0; padding: 12px 14px; border-radius: 12px; overflow-x: auto; font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; margin: 6px 0 14px; }
.snip-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.snip-tabs button { font: inherit; font-size: 13px; border: 1px solid var(--line); background: #fff; padding: 4px 10px; border-radius: 8px; cursor: pointer; }
.snip-tabs button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.supp { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.supp li { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 7px 0; border-bottom: 1px solid #f3f4f6; overflow-wrap: anywhere; }

.modal { position: fixed; inset: 0; background: rgba(17,24,39,.45); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal-card { max-width: 560px; width: 100%; }
.keybox { display: flex; gap: 8px; align-items: center; margin: 14px 0; padding: 10px; background: var(--warn-soft); border: 1px solid #fde68a; border-radius: 12px; }
.keybox code { flex: 1; background: none; overflow-wrap: anywhere; font-size: 13px; }
