:root {
  color-scheme: light;
  --bg: #f6f6f8; --surface: #ffffff; --surface-2: #f1f1f4; --border: #e3e3e8; --border-strong: #cfd0d7;
  --text: #15161c; --muted: #5b5e69; --accent: #4f46e5; --accent-hover: #4338ca; --on-accent: #ffffff;
  --accent-soft: #eef0ff; --ok: #157f3c; --ok-soft: #e7f6ec; --warn: #a75a06; --warn-soft: #fdf3e2;
  --bad: #b42318; --bad-soft: #fdecea; --shadow: 0 1px 2px rgba(16, 17, 24, .05);
  --radius: 12px; --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e0f13; --surface: #16181e; --surface-2: #1d2027; --border: #2a2d36; --border-strong: #3a3e4a;
    --text: #ececf1; --muted: #a3a6b1; --accent: #8f96ff; --accent-hover: #a7acff; --on-accent: #0e0f13;
    --accent-soft: #23264a; --ok: #5ad48a; --ok-soft: #13291c; --warn: #f2b84b; --warn-soft: #2e2311;
    --bad: #ff8a80; --bad-soft: #341a19; --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e0f13; --surface: #16181e; --surface-2: #1d2027; --border: #2a2d36; --border-strong: #3a3e4a;
  --text: #ececf1; --muted: #a3a6b1; --accent: #8f96ff; --accent-hover: #a7acff; --on-accent: #0e0f13;
  --accent-soft: #23264a; --ok: #5ad48a; --ok-soft: #13291c; --warn: #f2b84b; --warn-soft: #2e2311;
  --bad: #ff8a80; --bad-soft: #341a19; --shadow: none;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: 13px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: var(--radius-sm); z-index: 10; }
.skip:focus { left: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: 0 24px; height: 60px; display: flex; align-items: center; gap: 28px; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--text); font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.brand .mark { color: var(--accent); }
.nav { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: var(--muted); font-weight: 500; padding: 7px 11px; border-radius: var(--radius-sm); white-space: nowrap; }
.nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); font-weight: 600; }
.me { display: flex; align-items: center; gap: 10px; }
.me a { color: var(--muted); font-weight: 500; }
.me a:hover { color: var(--text); }

main { max-width: 1180px; margin: 0 auto; padding: 36px 24px 48px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.page-head p { color: var(--muted); margin-top: 6px; }
.stack { display: grid; gap: 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 22px 24px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 20px 24px 0; }
.card-head .sub { color: var(--muted); font-size: 13px; font-family: var(--mono); }
.card-body { padding: 18px 24px 22px; }
.divider { border: 0; border-top: 1px solid var(--border); margin: 0; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; }
.stat { padding: 4px 18px 4px 0; }
.stat + .stat { padding-left: 18px; border-left: 1px solid var(--border); }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat .value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.split { display: grid; grid-template-columns: 1.4fr 1fr; gap: 28px; margin-top: 22px; }
.split h3 { color: var(--muted); font-weight: 600; margin-bottom: 8px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.nowrap { white-space: nowrap; }
.compact th, .compact td { padding: 6px 0; }
.compact th + th, .compact td + td { padding-left: 14px; }
.card > .table-wrap table th:first-child, .card > .table-wrap table td:first-child { padding-left: 24px; }
.card > .table-wrap table th:last-child, .card > .table-wrap table td:last-child { padding-right: 24px; }

/* Badges + chips */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-family: var(--mono); font-size: 12px; padding: 1px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); white-space: nowrap; }
.chip b { font-weight: 600; }
.sendline { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.sendline .n { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Forms */
form { margin: 0; }
label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 6px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 6px; }
input[type=text], input[type=email], input[type=password], input[type=search], select {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 9px 12px; min-height: 40px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.field + .field { margin-top: 16px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.checks label { display: inline-flex; align-items: center; gap: 7px; font-weight: 500; margin: 0; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600; font-size: 14px;
  min-height: 38px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer;
  background: var(--accent); color: var(--on-accent); white-space: nowrap; }
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.danger { background: var(--surface); color: var(--bad); border-color: var(--border-strong); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.small { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn.block { width: 100%; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); font-weight: 500; cursor: pointer; }
.linkbtn:hover { color: var(--text); text-decoration: underline; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline { display: inline-flex; gap: 8px; align-items: center; }
.inline select { width: auto; min-height: 32px; padding: 4px 8px; font-size: 13px; }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; padding: 16px 24px; border-bottom: 1px solid var(--border); }
.filters .field { margin: 0; min-width: 160px; }
.filters .field + .field { margin: 0; }
.filters label { font-size: 12.5px; color: var(--muted); font-weight: 600; }

.notice { border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; border: 1px solid var(--border); background: var(--surface-2); }
.notice.bad { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.notice.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.notice.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.secret { font-family: var(--mono); font-size: 15px; font-weight: 600; letter-spacing: .04em; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px dashed var(--border-strong); word-break: break-all; user-select: all; }
.qr-box { display: flex; justify-content: center; }
.qr-box svg { display: block; max-width: 100%; height: auto; background: #fff; border-radius: var(--radius-sm); }

.empty { text-align: center; padding: 44px 24px; }
.empty h3 { font-size: 15px; }
.empty p { color: var(--muted); max-width: 460px; margin: 6px auto 0; }

.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 24px; border-top: 1px solid var(--border); font-size: 13.5px; }
.pager .muted { font-variant-numeric: tabular-nums; }

/* Auth pages */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.auth-box { width: 100%; max-width: 380px; }
.auth-box .brand { font-size: 18px; margin-bottom: 26px; }
.auth-box h1 { font-size: 22px; }
.auth-box .lead { color: var(--muted); margin: 6px 0 22px; }
.auth-box .card { padding: 26px; }
.auth-foot { display: flex; justify-content: center; margin-top: 22px; }

/* Theme switch */
.theme { display: inline-flex; padding: 2px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.theme button { font: inherit; font-size: 12.5px; font-weight: 500; color: var(--muted); background: none; border: 0; padding: 3px 10px; border-radius: 999px; cursor: pointer; }
.theme button:hover { color: var(--text); }
.theme button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); font-weight: 600; }

footer.site { max-width: 1180px; margin: 0 auto; padding: 0 24px 36px; display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }

table.dense { font-size: 13.5px; }
table.dense th, table.dense td { padding: 10px 10px; }
td.attrs { min-width: 180px; }
.sendtable th { width: 84px; padding-top: 9px; vertical-align: top; font-size: 13px; }
.sendtable td { padding-top: 6px; padding-bottom: 6px; }
.compact tbody tr:last-child th, .compact tbody tr:last-child td { border-bottom: 0; }
.compact tbody th { border-bottom: 1px solid var(--border); }
.grid-2 > .field + .field { margin-top: 0; }
.split > *, .stack > *, .grid-2 > *, main { min-width: 0; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; }
details summary { cursor: pointer; color: var(--muted); margin-top: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* Campaigns: editors, previews, facts */
textarea, input[type=number], input[type=time], input[type=date], input[type=datetime-local], input[type=url] {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 9px 12px; min-height: 40px; }
textarea { resize: vertical; line-height: 1.45; }
textarea:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); }
.field > .label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 6px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-3 > .field + .field { margin-top: 0; }
.checks.col { flex-direction: column; gap: 8px; }
fieldset.lang { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px 16px; margin: 0; display: grid; gap: 12px; }
fieldset.lang .field + .field { margin-top: 0; }
fieldset.lang legend { padding: 0 6px; display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13.5px; }
fieldset.lang.add { border-style: dashed; }
fieldset.lang legend .inline { margin-left: 8px; font-weight: 500; }
.editor { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.preview { display: grid; gap: 8px; }
.preview + .preview { padding-top: 14px; border-top: 1px solid var(--border); }
.preview-head { display: flex; gap: 8px; align-items: center; }
.notif { background: var(--surface-2); border: 1px solid var(--border); border-radius: 16px; padding: 11px 14px 12px; font-size: 14px; line-height: 1.35; }
.np-app { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .02em; margin-bottom: 4px; }
.np-icon { width: 16px; height: 16px; border-radius: 4px; background: var(--accent); display: inline-block; }
.np-time { margin-left: auto; text-transform: none; }
.np-title, .np-sub { font-weight: 650; }
.np-body { white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.counts { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.count b { color: var(--text); font-weight: 600; }
.count.bad, .count.bad b { color: var(--bad); }
.count.warn { color: var(--warn); }
.clamp { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
ul.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.notice ul { margin: 6px 0 0; padding-left: 20px; }
.section-title { margin: 12px 0 0; }
dl.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 24px; margin: 22px 0 0; padding-top: 18px; border-top: 1px solid var(--border); }
dl.facts dt { color: var(--muted); font-size: 12.5px; font-weight: 600; }
dl.facts dd { margin: 2px 0 0; }
.cond + .cond { margin-top: 8px; }
td.langs { min-width: 170px; }
.card-head + .table-wrap { margin-top: 12px; }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 16px; }
  .stat:nth-child(4) { padding-left: 0; border-left: 0; }
  .split, .grid-2, .grid-3, .editor, dl.facts { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar-inner { height: auto; flex-wrap: wrap; gap: 6px 14px; padding: 10px 16px; }
  .nav { order: 3; flex-basis: 100%; margin: 0 -6px; }
  .me { margin-left: auto; }
  main { padding: 24px 16px 40px; }
  h1 { font-size: 23px; }
  .card-head, .card-body, .card-pad { padding-left: 16px; padding-right: 16px; }
  .filters, .pager { padding-left: 16px; padding-right: 16px; }
  .card > .table-wrap table th:first-child, .card > .table-wrap table td:first-child { padding-left: 16px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat, .stat + .stat { padding: 0; border-left: 0; }
  footer.site { padding: 0 16px 28px; flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
