/* Relay dashboard. One accent (violet), neutral near-black ground, muted status tones. 4px spacing rhythm. */
@font-face {
  font-family: "Geist";
  src: url("/assets/fonts/geist.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0a0a0c;
  --surface: #111114;
  --surface-2: #17171b;
  --surface-3: #1e1e23;
  --line: #232329;
  --line-2: #2e2e36;
  --text: #ededf0;
  --muted: #a0a0ab;
  --faint: #6c6c77;
  --accent: #8b7cff;
  --accent-strong: #7461ff;
  --accent-soft: rgba(139, 124, 255, .14);
  --ok: #4aa97f;
  --ok-soft: rgba(74, 169, 127, .13);
  --warn: #cf9f4a;
  --warn-soft: rgba(207, 159, 74, .13);
  --bad: #db6a61;
  --bad-soft: rgba(219, 106, 97, .13);
  --neutral-soft: rgba(160, 160, 171, .12);

  --fs-xs: 12px; --fs-sm: 13px; --fs-md: 14px; --fs-lg: 16px; --fs-xl: 20px; --fs-2xl: 28px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s12: 48px;
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sidebar: 224px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 400 var(--fs-md)/1.5 "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "tnum" 1, "cv11" 1;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: var(--fs-2xl); font-weight: 650; letter-spacing: -.02em; line-height: 1.2; }
h2 { font-size: var(--fs-lg); font-weight: 600; letter-spacing: -.01em; }
h3 { font-size: var(--fs-md); font-weight: 600; }
.mono { font-family: var(--mono); font-size: var(--fs-sm); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- shell */
.boot { min-height: 100vh; }
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--line);
  padding: var(--s5) var(--s3); display: flex; flex-direction: column; gap: var(--s1); background: var(--bg);
}
.brand { display: flex; align-items: center; gap: var(--s2); padding: 0 var(--s2) var(--s5); font-weight: 650; font-size: var(--fs-lg); letter-spacing: -.01em; }
.brand img { width: 24px; height: 24px; }
.nav a {
  display: flex; align-items: center; gap: var(--s3); padding: 7px var(--s3); border-radius: var(--r-sm);
  color: var(--muted); font-weight: 500;
}
.nav a svg { width: 16px; height: 16px; flex: none; opacity: .8; }
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a.on { color: var(--text); background: var(--surface-3); }
.nav a.on svg { color: var(--accent); opacity: 1; }
.side-foot { margin-top: auto; padding: var(--s3); border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: var(--s2); color: var(--muted); font-size: var(--fs-sm); }
.menu-btn { display: none; }

.main { min-width: 0; padding: var(--s8) var(--s8) var(--s12); max-width: 1240px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s6); flex-wrap: wrap; }
.page-head p { color: var(--muted); margin-top: var(--s1); }
.finding { font-size: var(--fs-xl); font-weight: 550; letter-spacing: -.01em; line-height: 1.35; max-width: 60ch; }
.finding em { font-style: normal; color: var(--accent); }

/* ---------------------------------------------------------------- panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); min-width: 0; }
.panel-h { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-h .sub { color: var(--muted); font-size: var(--fs-sm); }
.panel-b { padding: var(--s5); }
.panel-b.flush { padding: 0; }
.stack { display: flex; flex-direction: column; gap: var(--s4); }
.stack-lg { display: flex; flex-direction: column; gap: var(--s6); }
.row { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s4); }
.grid-main { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--s4); align-items: start; }

/* stat strip */
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.stat { padding: var(--s4) var(--s5); border-right: 1px solid var(--line); min-width: 0; }
.stat:last-child { border-right: 0; }
.stat .k { color: var(--muted); font-size: var(--fs-sm); display: flex; align-items: center; gap: var(--s2); }
.stat .v { font-size: var(--fs-xl); font-weight: 600; margin-top: 2px; letter-spacing: -.01em; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }

/* chart */
.chart { width: 100%; height: 240px; display: block; }
.chart text { fill: var(--faint); font-size: 11px; }
.chart .grid line { stroke: var(--line); }
.chart-wrap { padding: var(--s4) var(--s5) var(--s2); position: relative; }
.tip {
  position: absolute; pointer-events: none; background: var(--surface-3); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  padding: var(--s2) var(--s3); font-size: var(--fs-sm); min-width: 150px; z-index: 5;
}
.tip .t { color: var(--muted); margin-bottom: var(--s1); }
.tip .l { display: flex; justify-content: space-between; gap: var(--s4); }
.legend { display: flex; gap: var(--s4); flex-wrap: wrap; color: var(--muted); font-size: var(--fs-sm); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------------------------------------------------------------- health list */
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s3) var(--s5); border-bottom: 1px solid var(--line); }
.checks li:last-child { border-bottom: 0; }
.checks .name { flex: 1; min-width: 0; }
.checks .name .d { color: var(--muted); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.bar { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

/* ---------------------------------------------------------------- chips */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 99px;
  font-size: var(--fs-xs); font-weight: 550; white-space: nowrap; background: var(--neutral-soft); color: var(--muted);
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.plain::before { display: none; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; max-width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th { text-align: left; font-weight: 500; color: var(--faint); padding: var(--s2) var(--s5); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: var(--s3) var(--s5); border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover td { background: var(--surface-2); }
td.trunc { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.nowrap, th.nowrap { white-space: nowrap; }
td.right, th.right { text-align: right; }
.empty { padding: var(--s8) var(--s5); text-align: center; color: var(--muted); }

/* ---------------------------------------------------------------- forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); height: 34px; padding: 0 var(--s4);
  border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text);
  font-weight: 550; font-size: var(--fs-sm); cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-3); border-color: #3a3a44; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn.primary:hover { background: #8272ff; }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.sm { height: 28px; padding: 0 var(--s3); font-size: var(--fs-xs); }
.btn svg { width: 14px; height: 14px; }
.input, select.input, textarea.input {
  height: 34px; padding: 0 var(--s3); border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--bg);
  min-width: 0; font-size: var(--fs-sm);
}
textarea.input { height: auto; padding: var(--s2) var(--s3); resize: vertical; font-family: var(--mono); line-height: 1.6; }
.input:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: var(--fs-sm); color: var(--muted); }
.field .hint { font-size: var(--fs-xs); color: var(--faint); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s3); align-items: end; }
.check { display: inline-flex; align-items: center; gap: var(--s2); font-size: var(--fs-sm); cursor: pointer; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 2px; }
.seg button { border: 0; background: transparent; color: var(--muted); height: 28px; padding: 0 var(--s3); border-radius: 4px; font-size: var(--fs-sm); cursor: pointer; }
.seg button.on { background: var(--surface-3); color: var(--text); }
.err { color: var(--bad); font-size: var(--fs-sm); }
.toolbar { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; padding: var(--s3) var(--s5); border-bottom: 1px solid var(--line); }
.toolbar .input { flex: 1 1 200px; }
.toolbar select.input { flex: 0 1 180px; }

/* secret reveal box */
.secret { border: 1px solid var(--accent); background: var(--accent-soft); border-radius: var(--r-md); padding: var(--s4); display: flex; flex-direction: column; gap: var(--s2); }
.secret .val { display: flex; gap: var(--s2); align-items: center; }
.secret code { flex: 1; min-width: 0; overflow-wrap: anywhere; font-family: var(--mono); font-size: var(--fs-sm); background: var(--bg); padding: var(--s2) var(--s3); border-radius: var(--r-sm); }
.secret p { font-size: var(--fs-sm); }

/* DNS records */
.rec { display: grid; grid-template-columns: 64px minmax(0, 1fr) minmax(0, 2fr) 96px; gap: var(--s3); padding: var(--s3) var(--s5); border-bottom: 1px solid var(--line); align-items: start; }
.rec:last-child { border-bottom: 0; }
.rec .type { font-family: var(--mono); font-size: var(--fs-xs); color: var(--muted); padding-top: 5px; }
.copy { display: flex; align-items: flex-start; gap: 6px; min-width: 0; }
.copy code { font-family: var(--mono); font-size: var(--fs-xs); overflow-wrap: anywhere; word-break: break-all; padding-top: 5px; min-width: 0; }
.icon-btn { flex: none; width: 26px; height: 26px; border-radius: var(--r-sm); border: 1px solid var(--line); background: transparent; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { color: var(--text); border-color: var(--line-2); }
.icon-btn svg { width: 13px; height: 13px; }
.icon-btn.done { color: var(--ok); }
.rec-head { display: grid; grid-template-columns: 64px minmax(0, 1fr) minmax(0, 2fr) 96px; gap: var(--s3); padding: var(--s2) var(--s5); color: var(--faint); font-size: var(--fs-xs); border-bottom: 1px solid var(--line); }

/* definition lists */
.kv { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: var(--s2) var(--s4); font-size: var(--fs-sm); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: var(--s2) var(--s5) var(--s4); }
.timeline li { position: relative; padding: var(--s3) 0 var(--s3) var(--s6); }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 0; bottom: 0; width: 1px; background: var(--line-2); }
.timeline li:first-child::before { top: 18px; }
.timeline li:last-child::before { bottom: calc(100% - 18px); }
.timeline li i { position: absolute; left: 1px; top: 15px; width: 9px; height: 9px; border-radius: 50%; background: var(--faint); box-shadow: 0 0 0 3px var(--surface); }
.timeline li i.ok { background: var(--ok); } .timeline li i.warn { background: var(--warn); } .timeline li i.bad { background: var(--bad); } .timeline li i.accent { background: var(--accent); }
.timeline .t { display: flex; gap: var(--s2); align-items: baseline; flex-wrap: wrap; }
.timeline .t b { font-weight: 600; }
.timeline .d { color: var(--muted); font-size: var(--fs-sm); overflow-wrap: anywhere; }

/* project cards */
.proj-h { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.avatar { width: 32px; height: 32px; border-radius: var(--r-sm); background: var(--surface-3); display: grid; place-items: center; font-weight: 650; color: var(--accent); flex: none; }

/* dialogs */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: grid; place-items: center; padding: var(--s4); z-index: 50; }
.modal { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-lg); }
.modal .panel-b { display: flex; flex-direction: column; gap: var(--s4); }
.modal-f { display: flex; justify-content: flex-end; gap: var(--s2); padding: var(--s4) var(--s5); border-top: 1px solid var(--line); }

.toast { position: fixed; bottom: var(--s6); left: 50%; transform: translateX(-50%); background: var(--surface-3); border: 1px solid var(--line-2); padding: var(--s2) var(--s4); border-radius: var(--r-md); font-size: var(--fs-sm); z-index: 60; max-width: calc(100vw - 32px); }
.toast.bad { border-color: var(--bad); color: var(--bad); }

/* sign in */
.login { min-height: 100vh; display: grid; place-items: center; padding: var(--s4); }
.login-card { width: min(360px, 100%); display: flex; flex-direction: column; gap: var(--s5); }
.login-card .brand { padding: 0; }
.login-card form { display: flex; flex-direction: column; gap: var(--s3); }
.login-card .input { height: 40px; }
.login-card .btn { height: 40px; }
.code-input { letter-spacing: .3em; font-variant-numeric: tabular-nums; }

/* first-admin setup (/setup) */
.setup-card { width: min(400px, 100%); padding: var(--s8) 0; }
.setup-card h1 { font-size: var(--fs-xl); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s2); }
.btn.block { width: 100%; }
.steps { display: flex; align-items: center; gap: var(--s3); font-size: var(--fs-xs); color: var(--faint); }
.steps-bar { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s1); flex: 1; }
.steps-bar i { height: 3px; border-radius: 2px; background: var(--line-2); }
.steps-bar i.on { background: var(--accent); }
.qr-wrap { display: flex; flex-direction: column; gap: var(--s4); padding: var(--s4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.qr { align-self: center; width: min(216px, 100%); aspect-ratio: 1; padding: var(--s2); background: #fff; border-radius: var(--r-md); }
.qr svg { display: block; width: 100%; height: 100%; }
.qr-key { display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-xs); }
.cmd { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.cmd code { flex: 1; min-width: 0; font-family: var(--mono); font-size: var(--fs-sm); background: var(--bg); border: 1px solid var(--line); padding: var(--s2) var(--s3); border-radius: var(--r-sm); overflow-wrap: anywhere; }
.qr-key .cmd code { font-size: var(--fs-xs); word-spacing: -.1em; }
.cmd .icon-btn { width: 34px; height: 34px; }
.setup-actions { justify-content: space-between; flex-wrap: nowrap; }
.setup-actions .btn.primary { flex: 1; }

.spark { width: 100%; height: 56px; display: block; }
.loading { color: var(--faint); padding: var(--s8) 0; }
details.att summary { cursor: pointer; color: var(--muted); font-size: var(--fs-sm); list-style: none; }
details.att summary::-webkit-details-marker { display: none; }
.att-log { margin-top: var(--s2); display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-xs); color: var(--muted); }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat:nth-child(3) { border-right: 0; }
  .stat:nth-child(n+4) { border-top: 1px solid var(--line); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: sticky; top: 0; height: auto; z-index: 20; flex-direction: row; align-items: center; padding: var(--s3) var(--s4); border-right: 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
  .brand { padding: 0; flex: 1; }
  .menu-btn { display: inline-flex; }
  .nav { display: none; width: 100%; flex-direction: column; padding-top: var(--s2); }
  .side.open .nav { display: flex; }
  .side-foot { display: none; }
  .side.open .side-foot { display: flex; width: 100%; border-top: 1px solid var(--line); }
  .main { padding: var(--s5) var(--s4) var(--s12); }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  h1 { font-size: 24px; }
  .finding { font-size: var(--fs-lg); }
  .rec, .rec-head { grid-template-columns: minmax(0, 1fr); gap: var(--s2); padding: var(--s3) var(--s4); }
  .rec-head { display: none; }
  .panel-h, .panel-b, .toolbar { padding-left: var(--s4); padding-right: var(--s4); }
  .checks li { padding-left: var(--s4); padding-right: var(--s4); }
  /* tables become stacked cards */
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); }
  table.cards tr:last-child { border-bottom: 0; }
  table.cards td { border: 0; padding: 2px 0; max-width: none; white-space: normal; }
  table.cards td[data-l]::before { content: attr(data-l); color: var(--faint); display: inline-block; min-width: 88px; font-size: var(--fs-xs); }
  table.cards td.right { text-align: left; }
  td.trunc { overflow-wrap: anywhere; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .kv dd { margin-bottom: var(--s2); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { border-right: 1px solid var(--line) !important; border-top: 1px solid var(--line); padding: var(--s3) var(--s4); }
  .stat:nth-child(2n) { border-right: 0 !important; }
  .stat:nth-child(-n+2) { border-top: 0; }
  .toolbar select.input { flex: 1 1 140px; }
}
.recs-after { border-top: 1px solid var(--line); }
.hook-title { min-width: 0; }
.hook-url { font-size: var(--fs-md); overflow-wrap: anywhere; }
.hook-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.hook-stats .stat:nth-child(3) { border-right: 0; }
.side .menu-btn { display: none; }
.btn.ghost.danger { color: var(--bad); }
.btn.ghost.danger:hover { background: var(--bad-soft); }
td.right .row { justify-content: flex-end; }
tr.dim td { opacity: .55; }
.rec .stack { gap: var(--s1); }
.rec .note { color: var(--faint); font-size: var(--fs-xs); }
.kv dd .mono, .kv dd.mono { word-break: break-all; }
.align-end { align-items: flex-end; }
details.recs > summary { cursor: pointer; list-style: none; padding: var(--s3) var(--s5); color: var(--muted); font-size: var(--fs-sm); border-top: 1px solid var(--line); display: flex; align-items: center; gap: var(--s2); }
details.recs > summary::-webkit-details-marker { display: none; }
details.recs > summary::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .15s; }
details.recs[open] > summary::before { transform: rotate(45deg); }
details.recs[open] > summary { border-bottom: 1px solid var(--line); }
details.recs > summary:hover { color: var(--text); }
.split { gap: var(--s8); }
@media (max-width: 860px) {
  .side .menu-btn { display: inline-flex; }
  details.recs > summary { padding-left: var(--s4); padding-right: var(--s4); }
  .split { gap: var(--s6); }
}
.pad-b { padding-bottom: 8px; }
@media (max-width: 860px) {
  table.cards.msgs tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px var(--s3); }
  table.cards.msgs td { width: auto; }
  table.cards.msgs td::before { display: none !important; }
  table.cards.msgs .c-to { grid-row: 1; grid-column: 1; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  table.cards.msgs .c-status { grid-row: 1; grid-column: 2; }
  table.cards.msgs .c-subj { grid-row: 2; grid-column: 1 / -1; color: var(--muted); }
  table.cards.msgs .c-time { grid-row: 3; grid-column: 1 / -1; font-size: var(--fs-xs); }
  table.cards.msgs .c-hide { display: none; }
  .chart { height: 200px; }
}
