:root {
  --bg: #070b12;
  --bg-2: #0b111b;
  --card: #111a27;
  --card-2: #0d1622;
  --panel: rgba(255, 255, 255, 0.02);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #eaf0f6;
  --muted: #8a97a8;
  --muted-2: #5f6c7d;
  --brand: #1d9bf0;
  --brand-2: #7c5cff;
  --brand-hover: #3aa8f2;
  --danger: #f4212e;
  --danger-soft: #ff6b73;
  --ok: #00ba7c;
  --warn: #f5c518;
  --grad: linear-gradient(135deg, #1d9bf0 0%, #7c5cff 100%);
  --grad-soft: linear-gradient(135deg, rgba(29, 155, 240, 0.16), rgba(124, 92, 255, 0.16));
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 6px 20px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(29, 155, 240, 0.14), transparent 60%),
    radial-gradient(800px 500px at 100% 0%, rgba(124, 92, 255, 0.12), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); }
code { font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace; }
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }

.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 28px 22px; flex: 1; }
.container.center { display: flex; align-items: center; justify-content: center; min-height: calc(100vh - 60px); }

.gradient-text {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ── Cards ─────────────────────────────────────────── */
.card {
  background: linear-gradient(180deg, var(--card) 0%, var(--card-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 30px;
  box-shadow: var(--shadow);
}

.hero { max-width: 540px; text-align: center; }
.card.form { max-width: 400px; width: 100%; }

h1 { font-size: 27px; line-height: 1.2; margin: 6px 0 12px; font-weight: 800; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.logo, .success-badge, .error-badge {
  width: 66px; height: 66px; border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px; font-size: 30px; font-weight: 800;
}
.logo { background: #000; color: #fff; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.success-badge { background: rgba(0, 186, 124, 0.14); color: var(--ok); border: 1px solid rgba(0,186,124,.3); }
.error-badge { background: rgba(244, 33, 46, 0.14); color: var(--danger); border: 1px solid rgba(244,33,46,.3); }

.x-mark { font-weight: 800; }

/* ── Buttons ───────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  background: rgba(255, 255, 255, 0.04); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 10px 16px; font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: transform .12s ease, background .15s ease, border-color .15s ease, opacity .15s;
  white-space: nowrap; user-select: none;
}
.btn:hover { background: rgba(255, 255, 255, 0.08); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 8px 24px rgba(29,155,240,.3); }
.btn-primary:hover { background: var(--grad); filter: brightness(1.08); border-color: transparent; }
.btn-lg { padding: 14px 24px; font-size: 16px; margin: 10px 0 6px; }
.btn-sm { padding: 8px 12px; font-size: 13px; }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger-soft); border-color: rgba(244, 33, 46, 0.28); }
.btn-danger:hover { background: rgba(244, 33, 46, 0.12); border-color: rgba(244,33,46,.5); }
.btn-icon { padding: 9px; border-radius: 10px; }
.btn .spinner { width: 15px; height: 15px; }

/* ── Chips / perms ─────────────────────────────────── */
.perms { margin: 22px 0 8px; }
.perms-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted-2); margin-bottom: 10px; }
.perms-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip {
  background: rgba(255,255,255,.04); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 12px; font-size: 12px; color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ── Notices ───────────────────────────────────────── */
.notice { border-radius: 12px; padding: 12px 14px; margin: 14px 0; font-size: 14px; text-align: left; }
.notice-warn { background: rgba(245, 197, 24, 0.09); border: 1px solid rgba(245, 197, 24, 0.28); color: #ecd27a; }
.notice-error { background: rgba(244, 33, 46, 0.1); border: 1px solid rgba(244, 33, 46, 0.3); color: #ff8b91; }

/* ── Forms ─────────────────────────────────────────── */
.form label { display: block; text-align: left; font-size: 13px; color: var(--muted); margin: 16px 0 0; font-weight: 500; }
.input, .form input {
  width: 100%; margin-top: 7px; padding: 12px 14px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 11px;
  color: var(--text); font-size: 15px; font-family: inherit; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .form input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29,155,240,.18); }
.form .btn { width: 100%; margin-top: 20px; }

/* ── Account / avatar ──────────────────────────────── */
.account-row { display: flex; align-items: center; gap: 13px; }
.center-row { justify-content: center; margin: 14px 0; }
.avatar { width: 50px; height: 50px; border-radius: 50%; object-fit: cover; background: #000; border: 1px solid var(--border); }
.avatar-fallback { display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; background: var(--grad); }
.account-name { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 6px; }

/* ── Topbar ────────────────────────────────────────── */
.topbar {
  border-bottom: 1px solid var(--border);
  background: rgba(7, 11, 18, 0.72);
  backdrop-filter: saturate(160%) blur(12px);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; padding: 14px 22px; max-width: 1080px; margin: 0 auto; }
.brand { font-weight: 800; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; font-size: 16px; }
.brand-badge { width: 32px; height: 32px; border-radius: 9px; background: #000; display: flex; align-items: center; justify-content: center; font-weight: 800; box-shadow: var(--shadow-sm); }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.inline { display: inline; margin: 0; }

/* ── Dashboard header ──────────────────────────────── */
.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin: 6px 0 22px; flex-wrap: wrap; }
.dash-head .eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--brand); font-weight: 700; margin-bottom: 6px; }
.dash-head h1 { font-size: 30px; }
.dash-head p { margin: 8px 0 0; }

.share { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--border); padding: 8px 8px 8px 14px; border-radius: 999px; }
.share code { color: var(--text); font-size: 13px; }
.share .muted { white-space: nowrap; }

/* ── Stats ─────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat {
  background: linear-gradient(180deg, var(--card) 0%, var(--card-2) 100%);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 18px 20px; display: flex; align-items: center; gap: 14px;
  box-shadow: var(--shadow-sm);
}
.stat-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--grad-soft); color: var(--brand); flex-shrink: 0; }
.stat-icon svg { width: 22px; height: 22px; }
.stat-num { font-size: 26px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 12.5px; color: var(--muted); margin-top: 5px; }

/* ── Toolbar (search) ──────────────────────────────── */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.search { position: relative; flex: 1; min-width: 220px; max-width: 360px; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--muted-2); }
.search input { padding-left: 40px; margin: 0; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted-2); font-weight: 700; }

/* ── Account grid ──────────────────────────────────── */
.accounts { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 18px; }

.account {
  position: relative; overflow: hidden;
  padding: 22px;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.account::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--grad); opacity: 0; transition: opacity .2s;
}
.account:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: 0 22px 60px rgba(0,0,0,.5); }
.account:hover::before { opacity: 1; }

.account-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.handle { color: var(--muted); font-size: 13.5px; }
.verified { color: var(--brand); display: inline-flex; }
.verified svg { width: 17px; height: 17px; }

.badge { font-size: 11px; padding: 5px 10px; border-radius: 999px; white-space: nowrap; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; border: 1px solid transparent; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { background: rgba(0, 186, 124, 0.13); color: var(--ok); border-color: rgba(0,186,124,.28); }
.badge-warn { background: rgba(245, 197, 24, 0.1); color: #e6c34d; border-color: rgba(245,197,24,.25); }
.badge-danger { background: rgba(244, 33, 46, 0.12); color: var(--danger-soft); border-color: rgba(244,33,46,.28); }

.meta { margin: 18px 0; display: grid; gap: 9px; font-size: 13px; }
.meta-row { display: flex; align-items: center; gap: 8px; }
.meta-row .label { color: var(--muted-2); min-width: 92px; display: inline-flex; align-items: center; gap: 6px; }
.meta-row .label svg { width: 14px; height: 14px; }
.scopes { display: flex; flex-wrap: wrap; gap: 5px; }
.scope-chip { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: rgba(255,255,255,.05); border: 1px solid var(--border); color: #b9c4d0; font-family: ui-monospace, monospace; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ── Result / token panel ──────────────────────────── */
.result { margin-top: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-2); overflow: hidden; }
.result[hidden] { display: none; }
.result-head { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; border-bottom: 1px solid var(--border); background: rgba(255,255,255,.02); }
.result-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.result-actions { display: flex; gap: 4px; }
.icon-btn { background: transparent; border: 1px solid transparent; border-radius: 8px; color: var(--muted); cursor: pointer; padding: 5px; display: inline-flex; transition: background .15s, color .15s; }
.icon-btn:hover { background: rgba(255,255,255,.06); color: var(--text); }
.icon-btn svg { width: 15px; height: 15px; }
.result-body { padding: 12px; font-size: 12px; color: #c8d3df; max-height: 320px; overflow: auto; white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; margin: 0; }

.token-field { display: flex; align-items: center; gap: 8px; padding: 12px; }
.token-value { flex: 1; font-family: ui-monospace, monospace; font-size: 12.5px; color: #d7e0ea; background: #0a0e15; border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.token-meta { padding: 0 12px 12px; font-size: 12px; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; }

/* ── Empty state ───────────────────────────────────── */
.empty { text-align: center; padding: 54px 30px; }
.empty-icon { width: 70px; height: 70px; margin: 0 auto 18px; border-radius: 20px; background: var(--grad-soft); color: var(--brand); display: flex; align-items: center; justify-content: center; }
.empty-icon svg { width: 34px; height: 34px; }
.empty h2 { font-size: 19px; margin-bottom: 8px; }
.no-results { text-align: center; color: var(--muted); padding: 30px; display: none; }

/* ── Modal ─────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(3, 6, 11, 0.72);
  backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 60; opacity: 0; pointer-events: none; transition: opacity .18s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: linear-gradient(180deg, var(--card) 0%, var(--card-2) 100%);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  width: 100%; max-width: 480px; box-shadow: var(--shadow); transform: translateY(10px) scale(.98);
  transition: transform .18s; overflow: hidden;
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 20px; }
.modal-user { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.modal-user .avatar { width: 40px; height: 40px; }
.modal textarea {
  width: 100%; min-height: 120px; resize: vertical; padding: 13px 14px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); font-size: 15px; font-family: inherit; line-height: 1.5;
}
.modal textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29,155,240,.18); }
.modal-foot { display: flex; align-items: center; justify-content: space-between; padding: 0 20px 20px; }
.counter { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.counter.over { color: var(--danger-soft); }

/* ── Spinner ───────────────────────────────────────── */
.spinner { display: inline-block; border: 2px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ─────────────────────────────────────────── */
.toast-wrap { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 10px; align-items: center; z-index: 80; }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: #0c131d; border: 1px solid var(--border-strong); color: var(--text);
  padding: 11px 16px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow);
  animation: toast-in .22s ease; max-width: 90vw;
}
.toast svg { width: 17px; height: 17px; flex-shrink: 0; }
.toast.ok svg { color: var(--ok); }
.toast.err svg { color: var(--danger-soft); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

.footer { text-align: center; color: var(--muted-2); font-size: 12px; padding: 22px; border-top: 1px solid var(--border); }

@media (max-width: 560px) {
  .accounts { grid-template-columns: 1fr; }
  .card { padding: 22px; }
  .dash-head h1 { font-size: 25px; }
}
