/* RelayHold user portal — same design language as relayhold.com */

:root {
  --bg: #070b14;
  --bg-raise: #0d1424;
  --bg-glass: rgba(19, 30, 54, 0.55);
  --line: rgba(88, 118, 170, 0.18);
  --line-bright: rgba(88, 118, 170, 0.4);
  --text: #e6ecf5;
  --muted: #8b96ad;
  --accent: #2c8cff;
  --accent-deep: #1a5fd8;
  --grad: linear-gradient(120deg, #2c8cff 0%, #1a5fd8 100%);
  --grad-text: linear-gradient(120deg, #6db4ff 0%, #2c8cff 60%, #1a5fd8 100%);
  --radius: 18px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  --glow: 0 0 42px rgba(44, 140, 255, 0.35);
  --font: "Segoe UI", "Inter", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  --side-w: 250px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* author display rules above would otherwise defeat the hidden attribute */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(44, 140, 255, 0.35); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: rgba(88, 118, 170, 0.12);
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 8px;
}
code.breakable { word-break: break-all; }

/* ---- ambient background -------------------------------------------------- */

.bg-field { position: fixed; inset: 0; z-index: -2; overflow: hidden; pointer-events: none; }
.orb {
  position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.5;
  animation: drift 16s ease-in-out infinite alternate;
}
.orb.a { width: 560px; height: 560px; left: -160px; top: -120px;
         background: radial-gradient(circle, rgba(44,140,255,0.5), transparent 65%); }
.orb.b { width: 640px; height: 640px; right: -220px; top: 18%;
         background: radial-gradient(circle, rgba(26,95,216,0.45), transparent 65%);
         animation-delay: -6s; }
.orb.c { width: 480px; height: 480px; left: 22%; bottom: -180px;
         background: radial-gradient(circle, rgba(44,140,255,0.32), transparent 65%);
         animation-delay: -11s; }
@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(60px, -40px, 0) scale(1.12); }
}
.grid-lines {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(rgba(88, 118, 170, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(88, 118, 170, 0.055) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, black 30%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, black 30%, transparent 78%);
}

/* ---- shared surfaces ------------------------------------------------------ */

.glass {
  background: var(--bg-glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card { padding: 26px 28px; }
.card-title { font-size: 1.05rem; margin-bottom: 10px; }
.dim { color: var(--muted); font-size: 0.92rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 12px; border: 1px solid transparent;
  padding: 11px 20px; cursor: pointer;
  font: 600 0.95rem var(--font); color: var(--text);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; }
.btn.primary {
  background: var(--grad); color: #fff;
  box-shadow: 0 8px 24px rgba(26, 95, 216, 0.35);
}
.btn.primary:hover { box-shadow: var(--glow); }
.btn.ghost { background: transparent; border-color: var(--line-bright); }
.btn.ghost:hover { background: rgba(88, 118, 170, 0.08); }
.btn.wide { width: 100%; }

/* ---- forms ---------------------------------------------------------------- */

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 11px 14px;
  background: rgba(7, 11, 20, 0.6);
  border: 1px solid var(--line-bright); border-radius: 12px;
  color: var(--text); font: 400 0.95rem var(--font);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(44, 140, 255, 0.18);
}
.field.inline { display: flex; align-items: center; gap: 14px; margin-bottom: 0; flex: 1; }
.field.inline > span { margin-bottom: 0; white-space: nowrap; }
.form-error {
  background: rgba(211, 47, 47, 0.12); border: 1px solid rgba(211, 47, 47, 0.4);
  color: #ff9a9a; border-radius: 12px; padding: 10px 14px;
  font-size: 0.88rem; margin-bottom: 14px;
}

/* ---- login / oauth -------------------------------------------------------- */

.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.auth-card { width: 100%; max-width: 430px; padding: 38px 36px; }
.auth-brand { display: flex; gap: 16px; align-items: center; margin-bottom: 28px; }
.auth-brand img { width: 52px; height: 52px; flex: none; }
.auth-brand h1 { font-size: 1.35rem; background: var(--grad-text);
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-brand p { color: var(--muted); font-size: 0.9rem; }
.auth-foot { margin-top: 22px; color: var(--muted); font-size: 0.84rem; text-align: center; }
.oauth-info { margin-bottom: 20px; }
.oauth-actions { display: flex; flex-direction: column; gap: 10px; }

/* ---- app shell ------------------------------------------------------------ */

#app-view { display: flex; min-height: 100vh; }

.side {
  width: var(--side-w); flex: none; margin: 18px 0 18px 18px;
  padding: 22px 16px; display: flex; flex-direction: column;
  position: sticky; top: 18px; height: calc(100vh - 36px);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 18px;
  color: var(--text); font-weight: 700; font-size: 1.1rem; }
.brand img { width: 34px; height: 34px; }
.brand:hover { text-decoration: none; }

.side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.side-nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 12px;
  color: var(--muted); font-weight: 600; font-size: 0.93rem;
  transition: background 0.15s ease, color 0.15s ease;
}
.side-nav a svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
.side-nav a:hover { color: var(--text); background: rgba(88, 118, 170, 0.08); text-decoration: none; }
.side-nav a.active { color: #6db4ff; background: rgba(44, 140, 255, 0.12); }
.count {
  margin-left: auto; font-size: 0.74rem; font-weight: 700;
  background: rgba(44, 140, 255, 0.16); color: #6db4ff;
  border-radius: 999px; padding: 1px 8px;
}

.side-foot { border-top: 1px solid var(--line); padding-top: 14px;
  display: flex; flex-direction: column; gap: 10px; }
.user-card { display: flex; align-items: center; gap: 12px; padding: 0 6px; }
.user-meta { min-width: 0; display: flex; flex-direction: column; }
.user-meta b { font-size: 0.93rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta span { font-size: 0.78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-link { font-size: 0.82rem; padding: 0 6px; }

.avatar {
  width: 38px; height: 38px; flex: none; border-radius: 12px;
  background: var(--grad); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.05rem;
  box-shadow: 0 6px 18px rgba(26, 95, 216, 0.35);
}
.avatar.big { width: 72px; height: 72px; font-size: 1.9rem; border-radius: 20px; }

/* ---- main area ------------------------------------------------------------ */

.main { flex: 1; padding: 36px 40px 60px; min-width: 0; max-width: 1160px; }
.page-head { margin-bottom: 26px; }
.page-head h2 { font-size: 1.7rem; }
.page-head .dim { max-width: 640px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }

.profile-card { display: flex; align-items: center; gap: 22px; }
.profile-meta h3 { font-size: 1.25rem; margin-bottom: 2px; }
.role-pill {
  display: inline-block; margin-top: 10px; font-size: 0.75rem; font-weight: 700;
  background: rgba(44, 140, 255, 0.14); color: #6db4ff;
  border: 1px solid rgba(44, 140, 255, 0.35);
  padding: 2px 12px; border-radius: 999px;
}
.stats-card { display: flex; align-items: stretch; }
.stat { flex: 1; text-align: center; padding: 8px 6px; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat b { display: block; font-size: 1.9rem; background: var(--grad-text);
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat span { font-size: 0.8rem; color: var(--muted); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 10px 18px; margin-top: 14px; }
.kv .k { color: var(--muted); font-size: 0.88rem; align-self: center; }

/* ---- tables --------------------------------------------------------------- */

.table-card { padding: 10px 0; overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.tbl th {
  text-align: left; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); padding: 12px 18px; border-bottom: 1px solid var(--line);
}
.tbl td { padding: 13px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: rgba(88, 118, 170, 0.05); }
.tbl.slim td, .tbl.slim th { padding: 9px 14px; }
.loading-cell { text-align: center; padding: 30px 0 !important; }
.empty-note { padding: 18px 28px; }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 2px; }
.dot.on { background: #34d17b; box-shadow: 0 0 10px rgba(52, 209, 123, 0.7); }
.dot.off { background: #5a6377; }

/* ---- address book --------------------------------------------------------- */

.ab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 18px; }
.ab-card { padding: 20px 22px; display: flex; flex-direction: column; gap: 8px; }
.ab-card .ab-top { display: flex; align-items: center; gap: 12px; }
.ab-card h4 { font-size: 1.02rem; }
.ab-card .ab-id { color: var(--muted); font-family: var(--mono); font-size: 0.86rem; }
.ab-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 0.74rem; font-weight: 600; color: #6db4ff;
  background: rgba(44, 140, 255, 0.12); border: 1px solid rgba(44, 140, 255, 0.25);
  padding: 1px 10px; border-radius: 999px;
}
.ab-actions { margin-top: 6px; display: flex; gap: 8px; }
.ab-actions .btn { padding: 8px 16px; font-size: 0.85rem; }

/* ---- web client ----------------------------------------------------------- */

.wc-connect { display: flex; gap: 14px; align-items: center; margin-bottom: 18px; padding: 18px 22px; }
.wc-frame-wrap {
  height: calc(100vh - 300px); min-height: 480px; overflow: hidden;
  padding: 6px;
}
#wc-frame { width: 100%; height: 100%; border: none; border-radius: 12px; background: #fff; }

/* ---- toast ---------------------------------------------------------------- */

#toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--bg-raise); border: 1px solid var(--line-bright);
  color: var(--text); padding: 12px 22px; border-radius: 12px;
  box-shadow: var(--shadow), var(--glow); font-size: 0.92rem; z-index: 50;
  max-width: min(90vw, 480px); text-align: center;
}
#toast.err { border-color: rgba(211, 47, 47, 0.6); box-shadow: var(--shadow); }

/* ---- responsive ------------------------------------------------------------ */

@media (max-width: 980px) {
  #app-view { flex-direction: column; }
  .side { width: auto; margin: 12px 12px 0; position: static; height: auto; }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
  .main { padding: 24px 16px 48px; }
  .grid-2 { grid-template-columns: 1fr; }
  .stats-card { flex-direction: column; gap: 12px; }
  .stat + .stat { border-left: none; border-top: 1px solid var(--line); padding-top: 12px; }
  .kv { grid-template-columns: 1fr; gap: 4px 0; }
  .kv .k { margin-top: 8px; }
  .wc-frame-wrap { min-height: 420px; }
}