:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f2f2ef;
  --border: rgba(11, 11, 11, 0.09);
  --border-strong: rgba(11, 11, 11, 0.16);
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #8a8983;
  --accent: #4b5bdc;
  --accent-ink: #ffffff;
  --accent-soft: rgba(75, 91, 220, 0.10);
  --good: #0ca30c;
  --good-ink: #006300;
  --good-soft: rgba(12, 163, 12, 0.10);
  --warn: #fab219;
  --warn-ink: #8a5a00;
  --warn-soft: rgba(250, 178, 25, 0.16);
  --crit: #d03b3b;
  --crit-ink: #b42626;
  --crit-soft: rgba(208, 59, 59, 0.10);
  --info-soft: rgba(11, 11, 11, 0.05);
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --chart-surface: #fcfcfb;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111110;
    --surface: #1a1a19;
    --surface-2: #222220;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    --text: #f0efec;
    --text-2: #c3c2b7;
    --text-3: #8a8983;
    --accent: #7b88f0;
    --accent-ink: #0b0b0b;
    --accent-soft: rgba(123, 136, 240, 0.14);
    --good-ink: #3cc43c;
    --good-soft: rgba(12, 163, 12, 0.16);
    --warn-ink: #fab219;
    --warn-soft: rgba(250, 178, 25, 0.14);
    --crit-ink: #f07070;
    --crit-soft: rgba(208, 59, 59, 0.18);
    --info-soft: rgba(255, 255, 255, 0.06);
    --grid: #2c2c2a;
    --axis: #383835;
    --chart-surface: #1a1a19;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -0.01em; margin: 0; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 13px; font-weight: 600; margin: 0 0 8px; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0 0 10px; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 12.5px; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  border-right: 1px solid var(--border); background: var(--surface);
  padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.logo { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), #9b6bf2); display: grid; place-items: center; }
.logo svg { width: 15px; height: 15px; }
.brand small { display: block; font-weight: 450; font-size: 11.5px; color: var(--text-3); letter-spacing: 0; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px;
  color: var(--text-2); font-weight: 500; text-decoration: none;
}
.nav a svg { width: 16px; height: 16px; opacity: .8; flex: none; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.side .spacer { flex: 1; }
.main { padding: 28px 36px 60px; max-width: 1180px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px 12px; }
  .brand { padding: 4px 10px; width: 100%; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .side .spacer { display: none; }
  .main { padding: 20px 16px 48px; }
}

/* ---------- cards & grids ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1000px) { .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .grid.cols-2, .grid.cols-4 { grid-template-columns: 1fr; } }
.stack > * + * { margin-top: 16px; }

.stat .label { color: var(--text-2); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 28px; font-weight: 650; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot.good { background: var(--good); } .dot.warn { background: var(--warn); } .dot.crit { background: var(--crit); } .dot.neutral { background: var(--text-3); }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--crit-ink); }
.btn.danger:hover { background: var(--crit-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn svg { width: 15px; height: 15px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-weight: 550; font-size: 12.5px; margin-bottom: 6px; color: var(--text-2); }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=search], select, textarea {
  width: 100%; height: 36px; padding: 0 11px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; outline: none;
}
textarea { height: auto; padding: 9px 11px; min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.hint { font-size: 12px; color: var(--text-3); margin-top: 5px; }

.choice { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; margin-bottom: 16px; }
@media (max-width: 600px) { .choice { grid-template-columns: 1fr; } }
.choice label { border: 1px solid var(--border-strong); border-radius: 10px; padding: 12px 14px; cursor: pointer; display: block; }
.choice label:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.choice input { margin: 0 8px 0 0; accent-color: var(--accent); }
.choice b { font-weight: 600; }
.choice p { margin: 6px 0 0; font-size: 12.5px; color: var(--text-2); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 550; color: var(--text-3); font-size: 12px; padding: 8px 20px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 20px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
td.nowrap { white-space: nowrap; }
.trunc { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 550; white-space: nowrap; background: var(--info-soft); color: var(--text-2); }
.pill svg { width: 12px; height: 12px; }
.pill.ok, .pill.delivered { background: var(--good-soft); color: var(--good-ink); }
.pill.warn, .pill.deferred, .pill.partial, .pill.queued, .pill.sending { background: var(--warn-soft); color: var(--warn-ink); }
.pill.error, .pill.bounced, .pill.failed, .pill.suppressed { background: var(--crit-soft); color: var(--crit-ink); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- DNS records ---------- */
.record { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.record + .record { margin-top: 10px; }
.record .head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.record .head b { font-weight: 600; }
.record .msg { color: var(--text-2); font-size: 13px; margin: 8px 0 0; }
.kv { display: grid; grid-template-columns: 64px 1fr auto; gap: 6px 10px; align-items: start; margin-top: 10px; }
.kv .k { color: var(--text-3); font-size: 12px; padding-top: 6px; }
.kv .v { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border-radius: 6px; padding: 5px 8px; word-break: break-all; }
.kv .found { color: var(--text-2); }
.copy { height: 28px; }

.score { --p: 0; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-weight: 650; font-size: 13px;
  background: conic-gradient(var(--c, var(--good)) calc(var(--p) * 1%), var(--surface-2) 0); position: relative; flex: none; }
.score::before { content: ""; position: absolute; inset: 5px; background: var(--surface); border-radius: 50%; }
.score span { position: relative; font-variant-numeric: tabular-nums; }

.domain-card { display: flex; align-items: center; gap: 16px; cursor: pointer; transition: border-color .15s; }
.domain-card:hover { border-color: var(--border-strong); }
.domain-card .name { font-weight: 600; font-size: 15px; }
.domain-card .meta { flex: 1; min-width: 0; }

/* ---------- checks list ---------- */
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.checks li:last-child { border-bottom: 0; }
.checks .icon { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; flex: none; margin-top: 1px; }
.checks .icon svg { width: 12px; height: 12px; }
.icon.ok { background: var(--good-soft); color: var(--good-ink); }
.icon.warn { background: var(--warn-soft); color: var(--warn-ink); }
.icon.error { background: var(--crit-soft); color: var(--crit-ink); }
.icon.info { background: var(--info-soft); color: var(--text-3); }
.checks b { font-weight: 600; display: block; }
.checks .m { color: var(--text-2); font-size: 13px; word-break: break-word; }

/* ---------- chart ---------- */
.chart { position: relative; background: var(--chart-surface); border-radius: 8px; }
.chart svg { display: block; width: 100%; height: 200px; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--text-2); margin-top: 8px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tooltip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; box-shadow: var(--shadow); min-width: 140px; z-index: 5; }
.tooltip .t { font-weight: 600; margin-bottom: 4px; }
.tooltip .r { display: flex; justify-content: space-between; gap: 14px; color: var(--text-2); }
.tooltip .r b { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- drawer & modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.32); z-index: 20; animation: fade .15s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); background: var(--surface); z-index: 21; overflow-y: auto; padding: 22px 24px 40px; box-shadow: -8px 0 32px rgba(0,0,0,.12); animation: slide .18s ease-out; }
.modal { position: fixed; z-index: 21; left: 50%; top: 12vh; transform: translateX(-50%); width: min(520px, calc(100vw - 32px)); background: var(--surface); border-radius: 14px; padding: 22px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.25); animation: fade .15s; max-height: 80vh; overflow-y: auto; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }

.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 14px 22px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 7px; bottom: -7px; width: 1px; background: var(--border-strong); }
.timeline li:last-child::before { display: none; }
.timeline li i { position: absolute; left: 1px; top: 4px; width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); box-shadow: 0 0 0 3px var(--surface); }
.timeline li i.delivered { background: var(--good); } .timeline li i.deferred { background: var(--warn); } .timeline li i.bounced, .timeline li i.suppressed { background: var(--crit); }

pre.code { background: var(--surface-2); border-radius: 10px; padding: 14px 16px; overflow-x: auto; margin: 0 0 14px; line-height: 1.55; }
.secret { display: flex; gap: 8px; align-items: center; background: var(--good-soft); border-radius: 10px; padding: 12px; }
.secret code { flex: 1; word-break: break-all; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 500; z-index: 40; box-shadow: var(--shadow); animation: fade .15s; max-width: calc(100vw - 32px); }
.toast.err { background: var(--crit); color: #fff; }
.empty { text-align: center; padding: 40px 20px; color: var(--text-2); }
.empty svg { width: 36px; height: 36px; color: var(--text-3); margin-bottom: 8px; }
.callout { border-radius: 10px; padding: 12px 14px; background: var(--accent-soft); color: var(--text); font-size: 13px; }
.callout.warn { background: var(--warn-soft); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs button { background: none; border: 0; padding: 8px 12px; font: inherit; font-weight: 550; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--text); border-color: var(--accent); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(380px, 100%); padding: 28px; }
.login .brand { padding: 0 0 18px; }
.spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

details.vals { margin-top: 8px; }
details.vals summary { cursor: pointer; color: var(--text-3); font-size: 12.5px; }
.managed-list .record { padding: 12px 16px; }
