:root {
  --bg-0: #0a0c12;
  --bg-1: #11141d;
  --bg-2: #161a25;
  --bg-3: #1c2130;
  --line: #232a3a;
  --text: #e5e8ef;
  --muted: #8a93a6;
  --primary: #6c8cff;
  --primary-2: #5772e6;
  --success: #34d399;
  --warning: #f5b85a;
  --danger: #f37070;
  --info: #5dd6f2;
  --shadow: 0 12px 40px -16px rgba(0, 0, 0, 0.6);
  --radius: 14px;
  --radius-sm: 8px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(900px 600px at 0% -10%, rgba(108,140,255,0.15), transparent 60%),
    radial-gradient(700px 500px at 100% 0%, rgba(93,214,242,0.08), transparent 60%),
    var(--bg-0);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.mono { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.center { text-align: center; }
.row { display: flex; align-items: center; }
.row.gap { gap: 12px; }

/* ----- Sidebar ----- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 248px;
  background: linear-gradient(180deg, var(--bg-1), var(--bg-0));
  border-right: 1px solid var(--line);
  padding: 22px 14px;
  display: flex; flex-direction: column; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), #8aa9ff);
  color: #0a0c12; font-weight: 800; font-size: 18px;
  box-shadow: 0 8px 24px -8px rgba(108,140,255,0.6);
}
.brand-mark.large { width: 48px; height: 48px; font-size: 22px; border-radius: 12px; }
.brand-title { font-weight: 700; }
.brand-sub { color: var(--muted); font-size: 12px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border-radius: var(--radius-sm); color: var(--muted); font-weight: 500;
  transition: background .15s, color .15s, transform .15s;
}
.nav-link .ico { width: 18px; text-align: center; opacity: 0.85; }
.nav-link:hover { background: var(--bg-2); color: var(--text); }
.nav-link.active {
  background: linear-gradient(180deg, rgba(108,140,255,0.18), rgba(108,140,255,0.06));
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(108,140,255,0.25);
}
.sidebar-footer { margin-top: auto; }
.nav-link.muted { color: var(--muted); }

/* ----- Content layout ----- */
.content {
  margin-left: 248px;
  padding: 28px 36px 60px;
  min-height: 100vh;
}
.topbar {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 22px; gap: 24px; flex-wrap: wrap;
}
.topbar h1 { font-size: 22px; font-weight: 700; }
.topbar-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ----- Buttons & inputs ----- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .05s, border-color .15s;
}
.btn:hover { background: var(--bg-3); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, var(--primary), var(--primary-2));
  color: #0a0c12; border-color: transparent;
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.warn {
  background: linear-gradient(180deg, #f37070, #cd4f4f);
  color: #0a0c12; border-color: transparent;
}
.btn.ghost { background: transparent; }
.btn.block { width: 100%; justify-content: center; }
.btn .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success); box-shadow: 0 0 0 4px rgba(52,211,153,0.18);
}

input, textarea, select {
  width: 100%;
  padding: 10px 12px; background: var(--bg-1);
  border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; font-size: 13px; font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 80px; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: rgba(108,140,255,0.55);
  box-shadow: 0 0 0 4px rgba(108,140,255,0.15);
}
label {
  display: block; margin-bottom: 14px; color: var(--muted);
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em;
}
label input, label textarea { margin-top: 6px; }
.inline-input { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.inline-input span { color: var(--muted); font-size: 12px; }
.inline-input input { width: 130px; padding: 7px 10px; }

/* ----- Cards & grids ----- */
.card {
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.card-head h2 { font-size: 15px; }
.card-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.grid-cards {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 20px;
}
.grid-2col {
  display: grid; gap: 16px; grid-template-columns: 1fr 1fr; align-items: start;
}
@media (max-width: 980px) { .grid-2col { grid-template-columns: 1fr; } }

.card.stat .card-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em; }
.card.stat .card-value { font-size: 28px; font-weight: 700; margin-top: 6px; }
.card.stat .card-sub { margin-top: 8px; color: var(--muted); font-size: 12px; display: flex; gap: 6px; flex-wrap: wrap; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: var(--bg-3); color: var(--text);
}
.pill-active { background: rgba(108,140,255,0.18); color: #b8c8ff; }
.pill-deferred { background: rgba(245,184,90,0.18); color: var(--warning); }
.pill-hold { background: rgba(243,112,112,0.18); color: var(--danger); }
.pill-info { background: rgba(93,214,242,0.18); color: var(--info); }
.pill-ok { background: rgba(52,211,153,0.18); color: var(--success); }
.pill-fail { background: rgba(243,112,112,0.18); color: var(--danger); }

/* ----- Tables ----- */
table.kv { width: 100%; border-collapse: collapse; }
table.kv th { text-align: left; color: var(--muted); font-weight: 500; padding: 8px 12px; font-size: 12px; }
table.kv td { padding: 8px 12px; border-top: 1px solid var(--line); }
table.kv tr:first-child td, table.kv tr:first-child th { border-top: none; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; padding: 10px 12px; color: var(--muted);
  font-weight: 500; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--line);
}
table.data td { padding: 11px 12px; border-bottom: 1px solid rgba(35,42,58,0.6); vertical-align: top; }
table.data tr:hover td { background: rgba(108,140,255,0.04); }
.kv-stack > div { padding: 10px 0; border-top: 1px solid var(--line); }
.kv-stack > div:first-child { border-top: none; }

/* ----- Log box ----- */
.logbox {
  margin: 0; padding: 16px; border-radius: 10px;
  background: #07090f; border: 1px solid var(--line);
  font-family: "JetBrains Mono", monospace; font-size: 12px;
  color: #cad1e1;
  max-height: 360px; overflow: auto;
  white-space: pre-wrap; word-break: break-word;
}
.logbox.tall { max-height: calc(100vh - 240px); }
.logbox .l-sent { color: #7ee8c4; }
.logbox .l-deferred { color: var(--warning); }
.logbox .l-bounced, .logbox .l-error { color: #ff9c9c; }
.logbox .l-qid { color: #b8c8ff; font-weight: 600; }

/* ----- Send result ----- */
.result-pane { font-size: 13px; }
.result-pane .row-status { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.result-pane .res-key { color: var(--muted); width: 110px; display: inline-block; }
.result-pane pre { font-family: "JetBrains Mono", monospace; font-size: 12px; background: #07090f; padding: 12px; border-radius: 10px; border: 1px solid var(--line); white-space: pre-wrap; }

/* ----- Probes ----- */
.probe {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 14px; margin-top: 10px;
  background: rgba(255,255,255,0.02);
}
.probe-label { font-weight: 600; }
.probe-status { font-size: 12px; color: var(--muted); margin-top: 4px; }
.probe-detail { font-family: "JetBrains Mono", monospace; font-size: 12px; margin-top: 8px; color: #cad1e1; }

/* ----- Login ----- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(700px 500px at 30% 20%, rgba(108,140,255,0.18), transparent 60%),
    radial-gradient(500px 400px at 80% 80%, rgba(93,214,242,0.10), transparent 60%),
    var(--bg-0);
}
.login-card {
  width: 100%; max-width: 380px;
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--line); border-radius: 16px;
  padding: 28px; box-shadow: var(--shadow);
}
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.login-title { font-weight: 700; font-size: 18px; }
.login-host { color: var(--muted); font-size: 12px; }
.login-form label { display: block; font-size: 12px; }
.login-foot { margin-top: 18px; color: var(--muted); font-size: 11.5px; text-align: center; }

/* ----- Flashes ----- */
.flashes { margin-bottom: 14px; }
.flash {
  padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg-2);
  margin-bottom: 8px; font-size: 13px;
}
.flash-error { border-color: rgba(243,112,112,0.5); background: rgba(243,112,112,0.08); color: #ffb3b3; }
.flash-success { border-color: rgba(52,211,153,0.5); background: rgba(52,211,153,0.08); color: #b6f1d8; }

/* ----- Form ----- */
.form { display: flex; flex-direction: column; gap: 0; }
.form label { margin-bottom: 14px; }
.form .row.gap label { flex: 1; }
