/* MX Relay Console — design tokens + components (out.md §12).
   Ported from the approved visual preview (artifact "MX Relay Console — Preview"):
   dark navy ground, glass cards, cyan accent, sidebar dots + footer, KPI cards,
   area chart, identity bars, reputation panel. Utility classes used by the other
   pages (.data table, .dns, .kv, login) are retained below. */
:root {
  --bg:#0f1420; --panel:rgba(30,40,60,0.55); --panel-solid:#161f2f;
  --edge:rgba(120,160,220,0.18); --ink:#e7edf7; --muted:#8fa1bd;
  --cyan:#35d0e0; --blue:#4f8cff; --green:#2ecc71; --amber:#f1c40f;
  --red:#e74c3c; --grey:#7f8c9b; --shadow:0 10px 30px rgba(0,0,0,.35);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg:#eef2f8; --panel:#ffffff; --panel-solid:#ffffff; --edge:#dde5f0;
    --ink:#16202e; --muted:#5a6b82; --shadow:0 8px 24px rgba(20,40,80,.08);
  }
}
:root[data-theme="dark"] {
  --bg:#0f1420; --panel:rgba(30,40,60,0.55); --panel-solid:#161f2f;
  --edge:rgba(120,160,220,0.18); --ink:#e7edf7; --muted:#8fa1bd;
  --shadow:0 10px 30px rgba(0,0,0,.35);
}
:root[data-theme="light"] {
  --bg:#eef2f8; --panel:#ffffff; --panel-solid:#ffffff; --edge:#dde5f0;
  --ink:#16202e; --muted:#5a6b82; --shadow:0 8px 24px rgba(20,40,80,.08);
}
* { box-sizing:border-box; }
body {
  margin:0; font:14px/1.55 system-ui,-apple-system,"Segoe UI",sans-serif;
  background:var(--bg); color:var(--ink); -webkit-font-smoothing:antialiased;
}

/* --- shell --------------------------------------------------------------- */
.shell { display:flex; min-height:100vh; }
.sidebar {
  width:216px; flex:none; padding:22px 14px;
  background:linear-gradient(180deg,#121a2b,#0d1320);
  border-right:1px solid var(--edge); display:flex; flex-direction:column; gap:22px;
}
:root[data-theme="light"] .sidebar { background:linear-gradient(180deg,#f7fafe,#eef3fa); }
@media (prefers-color-scheme:light){ :root:not([data-theme="dark"]) .sidebar{ background:linear-gradient(180deg,#f7fafe,#eef3fa);} }
.brand { font-weight:800; font-size:18px; letter-spacing:.4px; color:var(--cyan); display:flex; align-items:center; gap:7px; }
.brand .mark { display:inline-grid; place-items:center; width:26px; height:26px; border-radius:8px;
  background:linear-gradient(135deg,var(--cyan),var(--blue)); color:#04121a; font-size:15px; }
.sidebar nav { display:flex; flex-direction:column; gap:3px; }
.sidebar nav a { display:flex; align-items:center; gap:10px; padding:9px 12px; border-radius:10px;
  color:var(--muted); text-decoration:none; font-weight:500; }
.sidebar nav a:hover { color:var(--ink); background:rgba(120,160,220,.10); }
.sidebar nav a.on { color:var(--ink); background:rgba(79,140,255,.18); box-shadow:inset 0 0 0 1px var(--edge); }
.sidebar nav .dot { width:6px; height:6px; border-radius:50%; background:currentColor; opacity:.55; flex:none; }
.sidebar nav a.on .dot { background:var(--cyan); opacity:1; }
.sidebar .foot { margin-top:auto; font-size:11px; color:var(--muted); line-height:1.5; }

.content { flex:1; min-width:0; padding:0 28px 40px; }
.topbar { display:flex; align-items:center; justify-content:space-between; padding:20px 0 14px; }
.topbar h1 { font-size:21px; margin:0; letter-spacing:-.01em; }
.crumb { color:var(--muted); font-size:12px; letter-spacing:.06em; text-transform:uppercase; margin-bottom:3px; }
.account { display:flex; align-items:center; gap:12px; }
.account button { background:var(--panel-solid); border:1px solid var(--edge); color:var(--ink);
  border-radius:9px; padding:6px 10px; cursor:pointer; font-size:14px; line-height:1; }
.account button:hover { border-color:var(--cyan); }
.account-user { display:inline-flex; align-items:center; gap:7px; font-size:13px; color:var(--ink); }
.account-user .av { width:22px; height:22px; border-radius:50%; background:linear-gradient(135deg,var(--cyan),var(--blue)); }
.account-menu { color:var(--muted); text-decoration:none; font-size:13px; }
.account-menu:hover { color:var(--ink); }
.refresh { display:flex; align-items:center; gap:6px; color:var(--muted); font-size:12px; letter-spacing:.03em; }
.refresh select { background:var(--panel-solid); border:1px solid var(--edge); color:var(--ink);
  border-radius:8px; padding:5px 8px; font:inherit; font-size:12px; cursor:pointer; }
.refresh select:hover { border-color:var(--cyan); }
.refresh select:focus-visible { outline:2px solid var(--cyan); outline-offset:1px; }

/* --- cards --------------------------------------------------------------- */
.card { background:var(--panel); border:1px solid var(--edge); border-radius:16px;
  padding:18px 20px; box-shadow:var(--shadow); backdrop-filter:blur(8px); margin-bottom:18px; }
.card h2 { font-size:12px; margin:0 0 14px; color:var(--muted); font-weight:600;
  letter-spacing:.06em; text-transform:uppercase; }
.banner { background:rgba(241,196,15,.12); border-color:rgba(241,196,15,.35); color:var(--amber); }
/* Informational (not a warning) — used by the abuse monitor to state that it only watches. */
.banner.info { background:rgba(79,140,255,.10); border-color:rgba(79,140,255,.30); color:var(--blue); }

/* KPI cards */
.kpi-row { display:grid; grid-template-columns:repeat(4,1fr); gap:16px; margin-bottom:18px; }
.kpi { display:flex; flex-direction:column; gap:8px; }
.kpi-label { color:var(--muted); font-size:12px; letter-spacing:.04em; text-transform:uppercase; }
.kpi-val { font-size:30px; font-weight:750; font-variant-numeric:tabular-nums; letter-spacing:-.02em; }
.kpi-sub { font-size:12px; color:var(--muted); }
.kpi.accent .kpi-val { color:var(--cyan); }

/* Even halves by default (analytics, detail pages). Dashboard uses .wide for a broader
   left column, and BOTH dashboard rows use it so the column seam lines up vertically. */
.grid-2 { display:grid; grid-template-columns:1fr 1fr; gap:18px; margin-bottom:18px; }
.grid-2.wide { grid-template-columns:1.4fr 1fr; }
.kpi-row > .card, .grid-2 > .card { margin-bottom:0; }

/* charts */
canvas { width:100%; display:block; }
.chart-meta { display:flex; justify-content:space-between; align-items:baseline; margin-top:10px; font-size:12px; color:var(--muted); }
.chart-meta b { color:var(--ink); font-size:15px; font-variant-numeric:tabular-nums; }

/* top-identity list with proportional bars */
.card ul { list-style:none; margin:0; padding:0; }
.card li { padding:3px 0; }
.ident { padding:9px 0; border-bottom:1px solid var(--edge); }
.ident:last-child { border-bottom:0; }
.ident .item { display:flex; align-items:center; justify-content:space-between; gap:9px; }
.ident .id { display:flex; align-items:center; gap:9px; min-width:0; }
.ident .swatch { width:8px; height:8px; border-radius:2px; flex:none; }
.ident .name { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.ident .n { font-variant-numeric:tabular-nums; font-weight:600; color:var(--ink); }
.ident .bar { height:5px; border-radius:3px; background:linear-gradient(90deg,var(--cyan),var(--blue)); margin-top:5px; }

/* bounce rows */
.bounce { display:flex; gap:12px; padding:9px 0; border-bottom:1px solid var(--edge); font-size:13px; }
.bounce:last-child { border-bottom:0; }
.bounce time { color:var(--muted); font-variant-numeric:tabular-nums; white-space:nowrap; }
.bounce .line { color:var(--ink); min-width:0; overflow-wrap:anywhere; }

/* severity indicators (bounces) — hard=permanent 5xx, soft=temporary 4xx, info=role/report */
.sev-dot { width:9px; height:9px; border-radius:50%; flex:none; display:inline-block; margin-top:4px; }
.chip.sev-hard, .sev-dot.sev-hard { background:rgba(231,76,60,.16); color:var(--red); }
.chip.sev-soft, .sev-dot.sev-soft { background:rgba(241,196,15,.16); color:var(--amber); }
.chip.sev-info, .sev-dot.sev-info { background:rgba(79,140,255,.16); color:var(--blue); }
.sev-dot.sev-hard { background:var(--red); }
.sev-dot.sev-soft { background:var(--amber); }
.sev-dot.sev-info { background:var(--blue); }

/* reputation panel */
.rep { display:flex; flex-direction:column; gap:12px; }
.rep .line { display:flex; align-items:center; justify-content:space-between; gap:10px; }
.rep .k { color:var(--muted); font-size:13px; }

/* --- tables / detail pages (identities, analytics, audit) ---------------- */
.data { width:100%; border-collapse:collapse; }
.data th,.data td { text-align:left; padding:9px 10px; border-bottom:1px solid var(--edge); }
.data th { color:var(--muted); font-weight:600; }
.chip { padding:2px 10px; border-radius:999px; font-size:11px; font-weight:600; letter-spacing:.02em; }
.chip-active,.chip-Healthy,.chip.healthy { background:rgba(46,204,113,.16); color:var(--green); }
.chip-Deferred,.chip.deferred { background:rgba(241,196,15,.16); color:var(--amber); }
.chip-Bounced,.chip.bounced { background:rgba(231,76,60,.16); color:var(--red); }
.chip-Disabled { background:rgba(127,140,155,.20); color:var(--grey); }
.dns { background:#0b1120; color:#c8d6ee; padding:12px; border-radius:10px; overflow:auto; }
.kv { display:grid; grid-template-columns:150px 1fr; gap:6px 12px; }
.kv dt { color:var(--muted); }
.muted { color:var(--muted); }
.ok  { color:var(--green); font-weight:600; }
.warn { color:var(--amber); font-weight:600; }
.err { color:var(--red); font-size:13px; }

/* --- forms / wizard (Phase 2) -------------------------------------------- */
.form { display:flex; flex-direction:column; gap:16px; max-width:460px; }
.field { display:flex; flex-direction:column; gap:5px; }
.field label { color:var(--muted); font-size:12px; letter-spacing:.04em; text-transform:uppercase; }
.field input { background:#0b1120; border:1px solid var(--edge); color:var(--ink);
  border-radius:9px; padding:10px 12px; font:inherit; }
:root[data-theme="light"] .field input { background:#fff; }
.field input:focus-visible { outline:2px solid var(--cyan); outline-offset:1px; border-color:var(--cyan); }
.field .help { color:var(--muted); font-size:12px; }
.field .help b { color:var(--ink); font-variant-numeric:tabular-nums; }
.btn { align-self:flex-start; background:var(--blue); color:#fff; border:none; border-radius:9px;
  padding:10px 18px; font:inherit; font-weight:600; cursor:pointer; }
.btn:hover { filter:brightness(1.08); }
.btn:focus-visible { outline:2px solid var(--cyan); outline-offset:2px; }
.btn.secondary { background:transparent; color:var(--ink); border:1px solid var(--edge); }
.btn-row { display:flex; gap:10px; align-items:center; margin-top:2px; }
.notice { border-radius:12px; padding:12px 15px; margin-bottom:16px; font-size:13px; border:1px solid var(--edge); }
.notice.dry { background:rgba(79,140,255,.12); border-color:rgba(79,140,255,.35); color:var(--blue); }
.notice.done { background:rgba(46,204,113,.12); border-color:rgba(46,204,113,.35); color:var(--green); }
.pagehead-actions { display:flex; justify-content:flex-end; margin-bottom:14px; }
.dns .k { color:var(--muted); }

/* --- loading animations -------------------------------------------------- */
.kpi-val.loading { animation:mxr-pulse 1.4s ease-in-out infinite; }
.loading-msg { animation:mxr-pulse 1.4s ease-in-out infinite; }
.loading-msg::after {
  content:""; display:inline-block; width:1.2em; text-align:left;
  animation:mxr-dots 1.4s steps(1, end) infinite;
}
@keyframes mxr-pulse { 0%,100% { opacity:.4; } 50% { opacity:.9; } }
@keyframes mxr-dots { 0%{content:"";} 25%{content:".";} 50%{content:"..";} 75%{content:"...";} 100%{content:"";} }

/* --- login / two-factor / change-password -------------------------------- */
.login-wrap { min-height:100vh; display:grid; place-items:center; }
.login { width:320px; display:flex; flex-direction:column; gap:12px; }
.login .brand { justify-content:center; margin-bottom:6px; }
.login label { display:flex; flex-direction:column; gap:4px; color:var(--muted); font-size:12px; }
.login input { background:#0b1120; border:1px solid var(--edge); color:var(--ink); border-radius:8px; padding:9px 10px; }
:root[data-theme="light"] .login input { background:#fff; }
.login button { background:var(--blue); color:#fff; border:none; border-radius:8px; padding:10px; cursor:pointer; font-weight:600; }
.login .err { color:var(--red); font-size:13px; margin:0; }
.login .hint { color:var(--muted); font-size:13px; margin:0 0 4px; }
.login .alt { color:var(--muted); font-size:12px; text-align:center; text-decoration:none; }
.login .alt:hover { color:var(--cyan); }

@media (max-width:880px){
  .sidebar { display:none; }
  .content { padding:0 16px 32px; }
  .kpi-row { grid-template-columns:1fr 1fr; }
  .grid-2,.grid-2.wide { grid-template-columns:1fr; }
  .grid-2 > .card { margin-bottom:18px; }
}
