:root {
  color-scheme: light;
  --bg: #f9f9f7; --surface: #fcfcfb; --surface-2: #f0efec; --border: rgba(11,11,11,0.10); --grid: #e1e0d9; --axis: #c3c2b7;
  --text: #0b0b0b; --text-2: #52514e; --muted: #898781;
  --accent: #2a78d6; --accent-ink: #ffffff;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --good: #0ca30c; --warn: #fab219; --serious: #ec835a; --critical: #d03b3b; --good-text: #006300;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0d0d; --surface: #1a1a19; --surface-2: #242423; --border: rgba(255,255,255,0.10); --grid: #2c2c2a; --axis: #383835;
    --text: #f0efec; --text-2: #c3c2b7; --muted: #898781; --accent: #3987e5;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767; --good-text: #0ca30c;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0d; --surface: #1a1a19; --surface-2: #242423; --border: rgba(255,255,255,0.10); --grid: #2c2c2a; --axis: #383835;
  --text: #f0efec; --text-2: #c3c2b7; --muted: #898781; --accent: #3987e5;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767; --good-text: #0ca30c;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; flex: 0 0 220px; background: var(--surface); border-right: 1px solid var(--border); padding: 16px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { font-weight: 700; font-size: 16px; padding: 6px 10px 14px; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.nav a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text-2); }
.nav a.active, .nav a:hover { background: var(--surface-2); color: var(--text); }
.sidebar .spacer { flex: 1; }
.sidebar .foot { font-size: 12px; color: var(--muted); padding: 8px 10px; }
.main { flex: 1; min-width: 0; padding: 24px 28px 48px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.topbar h1 { font-size: 20px; margin: 0; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card h2 { font-size: 14px; margin: 0 0 12px; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile .label { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.tile .label i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.tile .value { font-size: 26px; font-weight: 600; margin-top: 4px; }
.tile .sub { font-size: 12px; color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
tr.row { cursor: pointer; } tr.row:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.badge.good::before, .badge.delivered::before, .badge.received::before, .badge.verified::before, .badge.active::before { background: var(--good); }
.badge.sent::before, .badge.queued::before, .badge.processing::before, .badge.pending::before { background: var(--s1); }
.badge.deferred::before, .badge.warn::before { background: var(--warn); }
.badge.bounced::before, .badge.failed::before, .badge.spam::before, .badge.critical::before, .badge.disabled::before, .badge.inactive::before { background: var(--critical); }
.btn { border: 1px solid var(--border); background: var(--surface); padding: 7px 12px; border-radius: 8px; cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.danger { color: var(--critical); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
input[type=text], input[type=password], input[type=email], input[type=number], select, textarea { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { width: 100%; min-height: 90px; }
.form { display: grid; gap: 10px; }
.form label { display: grid; gap: 4px; font-size: 12px; color: var(--text-2); }
.form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
pre { background: var(--surface-2); padding: 10px 12px; border-radius: 8px; overflow: auto; margin: 0; white-space: pre-wrap; word-break: break-all; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
@media (max-width: 960px) { .grid2, .grid3 { grid-template-columns: 1fr; } .sidebar { display: none; } .main { padding: 16px; } .form .row2 { grid-template-columns: 1fr; } }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow: auto; z-index: 50; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: min(900px, 100%); padding: 20px 22px; }
.modal h3 { margin: 0 0 12px; }
.login { max-width: 360px; margin: 12vh auto; }
.chart-wrap { position: relative; }
.chart-wrap svg { width: 100%; height: 260px; display: block; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.tooltip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.15); display: none; min-width: 140px; }
.tooltip b { display: block; margin-bottom: 4px; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 6px 0 6px 18px; border-left: 2px solid var(--grid); position: relative; margin-left: 6px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 11px; width: 10px; height: 10px; border-radius: 50%; background: var(--s1); }
.timeline li.ok::before { background: var(--good); } .timeline li.bad::before { background: var(--critical); } .timeline li.warn::before { background: var(--warn); }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 8px; z-index: 100; max-width: 420px; }
.check { display: inline-flex; align-items: center; gap: 6px; }
.check.ok { color: var(--good-text); } .check.no { color: var(--critical); }
.iframe { width: 100%; height: 420px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.tabs button { background: none; border: none; padding: 6px 10px; border-radius: 6px; cursor: pointer; color: var(--text-2); }
.tabs button.active { background: var(--surface-2); color: var(--text); }
.dns-table td:nth-child(3) { word-break: break-all; max-width: 420px; }
.copy { cursor: pointer; color: var(--accent); font-size: 12px; }
.logbox { background: var(--surface-2); border-radius: 8px; padding: 10px; max-height: 480px; overflow: auto; font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; white-space: pre; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; font-size: 12px; }
