:root {
    --bg: #f5f6fa; --card: #ffffff; --soft: #f0f2f8; --line: #e4e7ef;
    --text: #151a2d; --muted: #667089; --accent: #4f46e5; --accent-soft: #eeedfd;
    --ok: #0a7a52; --ok-soft: #e3f6ed; --wait: #96600a; --wait-soft: #fdf0d8; --bad: #bd2b3d; --bad-soft: #fdeaec;
    --shadow: 0 1px 2px rgba(20, 25, 50, .05), 0 8px 24px rgba(20, 25, 50, .05);
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0d1018; --card: #151a26; --soft: #1c2231; --line: #272e40;
        --text: #e9ecf5; --muted: #929cb4; --accent: #8b84ff; --accent-soft: #25264a;
        --ok: #4fd6a0; --ok-soft: #12332a; --wait: #f0bb55; --wait-soft: #36290f; --bad: #ff8291; --bad-soft: #3a1a22;
        --shadow: none; color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --bg: #0d1018; --card: #151a26; --soft: #1c2231; --line: #272e40;
    --text: #e9ecf5; --muted: #929cb4; --accent: #8b84ff; --accent-soft: #25264a;
    --ok: #4fd6a0; --ok-soft: #12332a; --wait: #f0bb55; --wait-soft: #36290f; --bad: #ff8291; --bad-soft: #3a1a22;
    --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
body { background: var(--bg); color: var(--text); font: 14px/1.55 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif; }
h1 { font-size: 24px; letter-spacing: -.02em; }
h2 { font-size: 16px; }
a { color: var(--accent); }
code, pre { font-family: "Cascadia Mono", Consolas, ui-monospace, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }

.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--card); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 20px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: var(--text); text-decoration: none; }
.mark { width: 32px; height: 32px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; }
nav { display: grid; gap: 4px; }
nav a { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 500; }
nav a:hover { background: var(--soft); color: var(--text); }
nav a.on { background: var(--accent-soft); color: var(--accent); }
nav svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.side-foot { margin-top: auto; display: grid; gap: 6px; }
.who { font-weight: 600; padding: 0 4px; overflow-wrap: anywhere; }
.side-foot .btn { width: 100%; }
.main { padding: 28px 32px 48px; min-width: 0; }

.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.pad { padding: 20px; display: grid; gap: 14px; align-content: start; justify-items: start; }
.narrow { max-width: 440px; }
.narrow .stack { width: 100%; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--card); color: var(--text); padding: 8px 14px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input, select { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; min-width: 0; }
input[type="checkbox"] { accent-color: var(--accent); }
.stack { display: grid; gap: 14px; }
.stack label { display: grid; gap: 6px; font-weight: 600; }
.switch { display: flex; gap: 8px; align-items: center; color: var(--muted); font-weight: 600; }

.alert, .banner { border-radius: 12px; padding: 11px 14px; margin-bottom: 16px; font-weight: 500; overflow-wrap: anywhere; }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.banner { background: var(--accent-soft); color: var(--accent); }

.endpoint { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; border: 1px dashed var(--line); background: var(--card); border-radius: 14px; padding: 10px 12px 10px 16px; margin-bottom: 16px; }
.endpoint code { flex: 1; min-width: 200px; overflow-wrap: anywhere; }
.tag { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 18px; box-shadow: var(--shadow); }
.stat span { color: var(--muted); font-weight: 600; font-size: 12.5px; }
.stat b { display: block; font-size: 28px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat.good b { color: var(--ok); }
.stat.wait b { color: var(--wait); }
.stat.fail b { color: var(--bad); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filters input[type="search"] { flex: 1; min-width: 220px; }

.split { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.list { overflow: hidden; }
.item { display: grid; grid-template-columns: 86px minmax(0, 1fr) 46px 78px; gap: 12px; align-items: center; width: 100%; text-align: left; background: transparent; color: inherit; font: inherit; border: 0; border-bottom: 1px solid var(--line); padding: 12px 16px; cursor: pointer; }
.item:hover { background: var(--soft); }
.item.on { background: var(--accent-soft); }
.item b { display: block; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item small { display: block; color: var(--muted); font-size: 12px; }
.method { font-size: 11.5px; font-weight: 700; color: var(--muted); }
.pill { display: inline-block; text-align: center; padding: 3px 10px; border-radius: 99px; font-size: 11.5px; font-weight: 700; background: var(--soft); color: var(--muted); }
.pill.sent { background: var(--ok-soft); color: var(--ok); }
.pill.pending, .pill.sending { background: var(--wait-soft); color: var(--wait); }
.pill.failed { background: var(--bad-soft); color: var(--bad); }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; }
.empty { padding: 48px 24px; text-align: center; display: grid; gap: 6px; }

.detail { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
#detailBody { padding: 18px; display: grid; gap: 12px; }
.detail-head, .block-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.block-head span { font-weight: 700; }
.block-head .btn { padding: 4px 10px; font-size: 12px; }
dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; width: 100%; }
dt { color: var(--muted); }
dd { overflow-wrap: anywhere; }
pre { background: var(--soft); border-radius: 12px; padding: 12px 14px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 300px; overflow: auto; }
#detailBody .alert { margin: 0; }
#resendForm .btn { width: 100%; }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }

dialog { margin: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--text); padding: 22px; width: min(420px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(8, 10, 20, .55); }

body.center { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: min(400px, 100%); padding: 28px; display: grid; gap: 10px; }
.login .alert { margin: 0; }
.login form { margin-top: 8px; }

@media (max-width: 1100px) {
    .split { grid-template-columns: minmax(0, 1fr); }
    .detail { position: static; max-height: none; }
}
@media (max-width: 780px) {
    .shell { grid-template-columns: minmax(0, 1fr); }
    .side { position: static; height: auto; flex-direction: column; gap: 12px; border-right: 0; border-bottom: 1px solid var(--line); padding: 14px; }
    nav { grid-auto-flow: column; grid-auto-columns: 1fr; }
    nav a { justify-content: center; gap: 6px; padding: 8px 4px; }
    .side-foot { margin: 0; grid-template-columns: 1fr 1fr; }
    .who { display: none; }
    .main { padding: 18px 14px 40px; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filters > * { flex: 1 1 40%; }
    .item { grid-template-columns: 70px minmax(0, 1fr) 74px; gap: 8px; padding: 11px 12px; }
    .method { display: none; }
}
