/* Nelsyn login. Tokens from _brand/BRAND.md. */
:root {
  --bg: #ffffff; --ink: #14113d; --muted: #555a78; --line: #e2e5f2;
  --accent: #5b4be0; --wordmark: #1c1745;
  --navy: #0b1736; --navy-card: #101f49; --navy-ink: #f1f3ff; --navy-muted: #a9b2d8;
  --m1: #2b7fdb; --m2: #4a63df; --m3: #5d52e2; --m4: #7040e0;
  --good: #1fa874; --risk: #e08a1e; --off: #d9453b;
  --radius: 20px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Tomorrow", system-ui, sans-serif; font-size: 16px; line-height: 1.6;
}
h1, h2, h3 {
  font-family: "Archivo", sans-serif; font-weight: 800; font-stretch: 125%;
  font-variation-settings: "wdth" 125; letter-spacing: -0.015em; line-height: 1.1; margin: 0 0 0.75rem;
}
h1 { font-size: clamp(1.9rem, 5vw, 2.75rem); }
h2 { font-size: 1.3rem; margin-top: 2.5rem; }
p { margin: 0 0 1rem; max-width: 65ch; }
a { color: var(--accent); }
code, .mono { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.92em; }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---- Logo ---------------------------------------------------------- */
.logo { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.logo svg { flex: none; }
.logo .lock { display: inline-flex; flex-direction: column; gap: 6px; }
.logo .wm {
  font-family: "Archivo", sans-serif; font-weight: 800; font-stretch: 125%;
  font-variation-settings: "wdth" 125; font-size: 26px; line-height: .82; letter-spacing: -.025em; color: var(--wordmark);
}
.logo .wm .y { background: linear-gradient(180deg, #6a4ce8, #3f7fe6); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo .tech { display: flex; justify-content: space-between; padding: 0 1px 0 2px; font: 500 7px/1 "JetBrains Mono", monospace; color: #5b4be0; }

/* ---- Forms and buttons -------------------------------------------- */
label { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 0.35rem; }
input[type=text], input[type=email], input[type=password], input[type=url], select, textarea {
  width: 100%; font: inherit; padding: 0.7rem 0.95rem; border: 1px solid var(--line);
  border-radius: 12px; color: var(--ink); background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
input[type=color] { width: 4rem; height: 2.6rem; padding: 0.2rem; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.field { margin-bottom: 1.1rem; }
.field .help { color: var(--muted); font-size: 0.85rem; margin-top: 0.3rem; }
.errorlist { list-style: none; padding: 0; margin: 0.35rem 0 0; color: var(--off); font-size: 0.9rem; }
.check { display: flex; gap: 0.6rem; align-items: center; font-weight: 400; }
.check input { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
.btn {
  display: inline-block; font: inherit; font-weight: 600; text-decoration: none; text-align: center;
  background: var(--accent); color: #fff; border: 0; border-radius: 999px;
  padding: 0.75rem 1.5rem; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn-quiet { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1px var(--line); }
.btn-danger { background: var(--off); }
.btn-wide { width: 100%; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }
.link-btn.danger { color: var(--off); }
form.inline { display: inline; margin: 0; }

/* ---- Sign-in screens ----------------------------------------------- */
.auth {
  --ring: var(--accent);
  min-height: 100vh; min-height: 100dvh; background: var(--navy); color: var(--navy-ink);
  display: grid; place-items: center; padding: 2rem 16px; position: relative; overflow: hidden;
}
.auth-rings { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.auth-rings circle { fill: none; stroke-width: 1.5; }
.auth.nelsyn .auth-rings circle:nth-child(1) { stroke: #4a8fea; }
.auth.nelsyn .auth-rings circle:nth-child(2) { stroke: #5b70ec; }
.auth.nelsyn .auth-rings circle:nth-child(3) { stroke: #6c5cee; }
.auth.nelsyn .auth-rings circle:nth-child(4) { stroke: #8050ee; }
.auth.client .auth-rings circle { stroke: var(--ring); }
.auth.client .auth-rings circle:nth-child(1) { opacity: .35; }
.auth.client .auth-rings circle:nth-child(2) { opacity: .5; }
.auth.client .auth-rings circle:nth-child(3) { opacity: .7; }
.auth.client .auth-rings circle:nth-child(4) { opacity: .9; }
@media (prefers-reduced-motion: no-preference) {
  .auth-rings { animation: settle 1.4s cubic-bezier(.2,.7,.2,1) both; transform-origin: 30% 70%; }
  @keyframes settle { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
}
.auth-card {
  position: relative; width: 100%; max-width: 26rem; background: #fff; color: var(--ink);
  border-radius: 28px; padding: 2.25rem 2rem 2rem; box-shadow: 0 30px 80px rgba(3, 8, 30, .45);
}
.auth-card h1 { font-size: 1.75rem; margin-bottom: 0.4rem; }
.auth-card .lede { color: var(--muted); margin-bottom: 1.5rem; }
.auth-head { margin-bottom: 1.75rem; min-height: 2.5rem; display: flex; align-items: center; }
.auth-head img { max-height: 3rem; max-width: 12rem; }
.auth-head .client-name { font-family: "Archivo", sans-serif; font-weight: 800; font-stretch: 125%; font-size: 1.35rem; color: var(--accent); }
.auth-foot { position: relative; margin-top: 1.5rem; display: flex; align-items: center; gap: 0.5rem; color: var(--navy-muted); font-size: 0.85rem; }
.auth-foot svg { width: 22px; height: 20px; }
.alert { border-radius: 12px; padding: 0.75rem 1rem; margin-bottom: 1.25rem; font-size: 0.95rem; }
.alert-error { background: #fdeceb; color: #8f2219; }
.alert-ok { background: #e6f6ef; color: #0f6143; }
.qr { display: flex; justify-content: center; margin: 0.5rem 0 1rem; }
.qr svg { width: 200px; height: 200px; }
.key { text-align: center; font-family: "JetBrains Mono", monospace; font-size: 0.95rem; letter-spacing: 0.05em; background: #f4f5fb; border-radius: 12px; padding: 0.6rem; margin-bottom: 1.25rem; word-break: break-all; }
.steps { padding-left: 1.2rem; margin: 0 0 1.25rem; color: var(--muted); }
.steps li { margin-bottom: 0.35rem; }
.codes { list-style: none; padding: 0; margin: 0 0 1.25rem; display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.codes li { font-family: "JetBrains Mono", monospace; background: #f4f5fb; border-radius: 10px; padding: 0.5rem; text-align: center; }
.code-input { font-family: "JetBrains Mono", monospace !important; font-size: 1.4rem !important; letter-spacing: 0.3em; text-align: center; }

/* ---- App pages ----------------------------------------------------- */
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 2rem; padding: 1rem 16px; border-bottom: 1px solid var(--line); }
.topbar nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem; flex: 1; }
.topbar nav a { color: var(--muted); text-decoration: none; font-weight: 500; padding: 0.25rem 0; }
.topbar nav a:hover, .topbar nav a[aria-current=page] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }
.topbar .who { display: flex; align-items: center; gap: 1rem; color: var(--muted); font-size: 0.92rem; }
.page { max-width: 60rem; margin: 0 auto; padding: 2.5rem 16px 5rem; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: 1.5rem; }
.page-head h1 { margin: 0; }
.page-head p { margin: 0.4rem 0 0; color: var(--muted); }
.back { display: inline-block; margin-bottom: 1rem; color: var(--muted); text-decoration: none; }
.back:hover { color: var(--accent); }
.messages { list-style: none; padding: 0; margin: 0 0 1.5rem; }
.messages li { border-radius: 12px; padding: 0.75rem 1rem; background: #eeedfc; color: #2c2380; margin-bottom: 0.5rem; }
.messages li.success { background: #e6f6ef; color: #0f6143; }

.panel { border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.25rem; }
.panel h2 { margin-top: 0; }
.panel-grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); }
.panel-grid .panel { margin: 0; }

.sites { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.site {
  display: flex; flex-direction: column; gap: 0.2rem; padding: 1.1rem 1.25rem; border-radius: var(--radius);
  border: 1px solid var(--line); text-decoration: none; color: var(--ink); border-left: 6px solid var(--site, var(--accent));
}
.site:hover { box-shadow: 0 0 0 2px var(--site, var(--accent)); }
.site strong { font-family: "Archivo", sans-serif; font-stretch: 125%; font-weight: 800; }
.site span { color: var(--muted); font-size: 0.88rem; }
.site .manage { margin-top: 0.4rem; display: flex; gap: 1rem; font-size: 0.9rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.75rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; font-size: 0.85rem; color: var(--muted); }
td a { text-decoration: none; font-weight: 600; }
.table-wrap { overflow-x: auto; }
.tag { display: inline-block; font-size: 0.8rem; font-weight: 600; padding: 0.1rem 0.6rem; border-radius: 999px; background: #eeedfc; color: #3b2fb4; white-space: nowrap; }
.tag-nelsyn { background: var(--navy); color: #fff; }
.tag-off { background: #fdeceb; color: #8f2219; }
.row-nelsyn td { color: var(--muted); }

.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.danger-zone { border-color: #f3c4c0; }
.link-box { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.link-box input { flex: 1 1 18rem; font-family: "JetBrains Mono", monospace; font-size: 0.85rem; }
.secret { font-family: "JetBrains Mono", monospace; font-size: 0.85rem; background: #f4f5fb; border-radius: 12px; padding: 0.75rem 1rem; word-break: break-all; }
.devices { list-style: none; padding: 0; margin: 0; }
.devices li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
.devices li:last-child { border-bottom: 0; }
.pager { display: flex; gap: 1rem; margin-top: 1rem; }
.swatch { display: inline-block; width: 0.9rem; height: 0.9rem; border-radius: 50%; vertical-align: -2px; margin-right: 0.4rem; }

@media (max-width: 560px) {
  .auth-card { padding: 1.75rem 1.25rem 1.5rem; border-radius: 22px; }
  .topbar .who { width: 100%; justify-content: space-between; }
}
