/* ==========================================================================
   Node Console — 原创深色玻璃拟态 UI
   ========================================================================== */

:root {
  --bg: #060912;
  --bg-2: #0b1120;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e9eefb;
  --muted: #8e9bb5;
  --muted-2: #64708a;
  --cyan: #22d3ee;
  --indigo: #6366f1;
  --violet: #a855f7;
  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.75);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ---------------------------------------------------------------- 背景装饰 */

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(1100px 600px at 12% -10%, rgba(99, 102, 241, 0.22), transparent 60%),
    radial-gradient(900px 520px at 88% 8%, rgba(34, 211, 238, 0.16), transparent 60%),
    radial-gradient(760px 520px at 60% 108%, rgba(168, 85, 247, 0.16), transparent 62%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 55%, var(--bg) 100%);
}
.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 50% 30%, #000 0%, transparent 78%);
  -webkit-mask-image: radial-gradient(circle at 50% 30%, #000 0%, transparent 78%);
}

/* -------------------------------------------------------------------- 卡片 */

.card {
  background: linear-gradient(180deg, var(--surface), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* 浅色背景 → 白卡片主题（由 /api/bg 的 tone 驱动） */
html[data-tone="light"] .bgscrim {
  background:
    radial-gradient(1000px 700px at 50% 38%, rgba(255, 255, 255, 0.06), rgba(226, 232, 240, 0.40) 74%),
    linear-gradient(180deg, rgba(248, 250, 252, 0.22), rgba(226, 232, 240, 0.40));
}
html[data-tone="light"] .login-card {
  background: rgba(255, 255, 255, 0.80);
  border-color: rgba(255, 255, 255, 0.95);
  box-shadow: 0 30px 70px -26px rgba(15, 23, 42, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}
html[data-tone="light"] .brand { color: #111827; }
html[data-tone="light"] .login-card .sub { color: #64748b; }
html[data-tone="light"] .login-card .field {
  background: rgba(255, 255, 255, 0.86);
  border-color: rgba(15, 23, 42, 0.10);
}
html[data-tone="light"] .login-card .field:focus-within {
  border-color: rgba(99, 102, 241, 0.65);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.13);
}
html[data-tone="light"] .login-card .field-ico { color: #94a3b8; }
html[data-tone="light"] .login-card .field input { color: #0f172a; }
html[data-tone="light"] .login-card .field input::placeholder { color: #9aa3b2; }
html[data-tone="light"] .login-card .foot {
  color: #94a3b8;
  border-top-color: rgba(15, 23, 42, 0.08);
}
html[data-tone="light"] .login-card .error { color: #dc2626; }

.login-card {
  transition: background 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease;
}
.brand, .login-card .sub, .login-card .field input, .login-card .foot {
  transition: color 0.5s ease;
}

/* -------------------------------------------------- 登录：全屏背景轮换 */

.login-body {
  min-height: 100vh;
  background: linear-gradient(180deg, #060912, #0b1120);
  overflow-x: hidden;
}

.bglayer {
  position: fixed;
  inset: -2%;
  z-index: 0;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  opacity: 0;
  transform: scale(1.03);
  transition: opacity 1.1s ease;
  will-change: opacity, transform;
}
.bglayer.show { opacity: 1; animation: kenburns 30s ease-in-out infinite alternate; }

@keyframes kenburns {
  from { transform: scale(1.03) translate3d(0, 0, 0); }
  to { transform: scale(1.13) translate3d(-1.4%, -1.2%, 0); }
}

html { background: #060912; }
html[data-tone="light"] { background: #eef1f5; }

.bgscrim {
  position: fixed;
  inset: 0;
  z-index: 1;
  background:
    radial-gradient(1000px 700px at 50% 38%, rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.46) 74%),
    linear-gradient(180deg, rgba(4, 7, 14, 0.30), rgba(4, 7, 14, 0.52));
}

.login-shell {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.login-card {
  width: 100%;
  max-width: 396px;
  padding: 34px 30px 24px;
  background: rgba(10, 14, 26, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.13);
  box-shadow: 0 30px 80px -24px rgba(0, 0, 0, 0.92), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  animation: rise 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
  font-size: 17px;
}
.brand .logo {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(140deg, var(--cyan), var(--indigo) 55%, var(--violet));
  box-shadow: 0 8px 24px -8px rgba(99, 102, 241, 0.9);
  flex: none;
}
.brand .logo svg { width: 19px; height: 19px; display: block; }

.login-card .brand { justify-content: center; }
.login-card .sub {
  text-align: center;
  color: var(--muted);
  margin: 10px 0 24px;
  font-size: 13.5px;
}

.field {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 13px;
  margin-bottom: 13px;
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
}
.field:focus-within {
  border-color: rgba(99, 102, 241, 0.75);
  background: rgba(99, 102, 241, 0.07);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}
.field-ico { color: var(--muted-2); display: grid; place-items: center; flex: none; }
.field-ico svg { width: 17px; height: 17px; display: block; }
.field input {
  flex: 1;
  background: none;
  border: 0;
  outline: 0;
  color: var(--text);
  font-size: 15px;
  padding: 13px 0;
  font-family: inherit;
  min-width: 0;
}
.field input::placeholder { color: var(--muted-2); }

/* -------------------------------------------------------------------- 按钮 */

.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: transform 0.12s, background 0.18s, border-color 0.18s, opacity 0.18s;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; display: block; }
.btn:hover { background: rgba(255, 255, 255, 0.11); border-color: rgba(255, 255, 255, 0.24); }
.btn:active { transform: translateY(1px) scale(0.995); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn.primary {
  border-color: transparent;
  background: linear-gradient(120deg, var(--cyan), var(--indigo) 52%, var(--violet));
  color: #fff;
  box-shadow: 0 12px 28px -12px rgba(99, 102, 241, 0.95);
}
.btn.primary:hover { filter: brightness(1.08); }

.btn.block { width: 100%; padding: 13px 16px; }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface); }

.error {
  min-height: 20px;
  margin-top: 12px;
  color: var(--red);
  font-size: 13px;
  text-align: center;
}
.foot {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--muted-2);
  font-size: 12px;
}

/* -------------------------------------------------------------------- 布局 */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 26px;
  border-bottom: 1px solid var(--border);
  background: rgba(6, 9, 18, 0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.wrap {
  max-width: 1060px;
  margin: 0 auto;
  padding: 26px 26px 60px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* -------------------------------------------------------------------- hero */

.hero {
  padding: 26px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 26px;
  flex-wrap: wrap;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  inset: -40% -10% auto auto;
  width: 340px;
  height: 340px;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.2), transparent 66%);
  pointer-events: none;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px 5px 10px;
}
.status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted-2);
  flex: none;
}
.status.up { color: var(--green); border-color: rgba(52, 211, 153, 0.32); background: rgba(52, 211, 153, 0.09); }
.status.up .dot { background: var(--green); box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.16); animation: pulse 2s infinite; }
.status.down { color: var(--red); border-color: rgba(248, 113, 113, 0.32); background: rgba(248, 113, 113, 0.09); }
.status.down .dot { background: var(--red); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18); }
  50% { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0.05); }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.hero h1 {
  margin: 13px 0 4px;
  font-size: 27px;
  letter-spacing: -0.3px;
  font-weight: 700;
}
.hero .muted { margin: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 15px; }
.chip {
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
}
.chip.accent {
  color: #cfe9ff;
  border-color: rgba(99, 102, 241, 0.42);
  background: linear-gradient(120deg, rgba(34, 211, 238, 0.15), rgba(168, 85, 247, 0.15));
}

.hero-right { flex: none; position: relative; }
.orbit { width: 116px; height: 116px; display: block; }

/* -------------------------------------------------------------------- 统计 */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 14px;
}
.stat { padding: 15px 17px; }
.stat .k {
  color: var(--muted-2);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.stat .v {
  margin-top: 7px;
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.stat .v.mono { font-family: var(--mono); font-size: 12.5px; }

.bar {
  margin-top: 10px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--cyan), var(--indigo), var(--violet));
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------------------------------------------------------------- 订阅区 */

.actions { padding: 22px 24px 24px; }
.actions h2 { margin: 0 0 4px; font-size: 17px; }
.actions .hint { color: var(--muted-2); font-size: 12.5px; margin: 14px 0 0; }

.suburl {
  display: flex;
  gap: 10px;
  margin: 14px 0 14px;
}
.suburl input {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 12.5px;
  color: #b9c6e2;
  background: rgba(0, 0, 0, 0.34);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 13px;
  outline: 0;
}
.suburl input:focus { border-color: rgba(99, 102, 241, 0.7); }

.btns { display: flex; flex-wrap: wrap; gap: 10px; }

.rows { margin-top: 6px; }
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.row:first-child { border-top: 0; }
.row .rk { color: var(--muted); font-size: 13.5px; }
.row .rv { font-family: var(--mono); font-size: 12.5px; color: #b9c6e2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* -------------------------------------------------------------------- 弹窗 */

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 5, 12, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: rise 0.22s ease;
}
.modal-card {
  width: 100%;
  max-width: 396px;
  padding: 22px;
  text-align: center;
}
.modal-card h3 { margin: 0 0 4px; font-size: 16.5px; }
.modal-card .muted { margin: 0 0 16px; font-size: 13px; }

.qr {
  display: grid;
  place-items: center;
  padding: 14px;
  background: #fff;
  border-radius: var(--radius-sm);
  margin: 0 auto 14px;
  width: max-content;
  max-width: 100%;
  overflow: hidden;
}
.qr svg { display: block; width: 232px; height: 232px; }

.tabs {
  display: flex;
  gap: 6px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 14px;
}
.tabs button {
  flex: 1;
  appearance: none;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 6px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
}
.tabs button[aria-selected="true"] {
  background: linear-gradient(120deg, rgba(34, 211, 238, 0.22), rgba(168, 85, 247, 0.22));
  color: var(--text);
}

/* -------------------------------------------------------------------- 提示 */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 9px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: rgba(12, 17, 30, 0.94);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  animation: rise 0.24s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.ok { border-color: rgba(52, 211, 153, 0.45); }
.toast.err { border-color: rgba(248, 113, 113, 0.5); }

/* ---------------------------------------------------------------- 用户卡片 */

.ucard { position: relative; overflow: hidden; padding: 0; min-height: 152px; }
.ucard-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transform: scale(1.08);
  filter: blur(3px) saturate(125%);
  opacity: 0;
  transition: opacity 0.8s ease, background-image 0.4s ease;
}
.ucard-bg.on { opacity: 1; }
.ucard-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, rgba(6, 9, 18, 0.90) 0%, rgba(6, 9, 18, 0.66) 46%, rgba(6, 9, 18, 0.30) 100%);
}
.ucard-inner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px;
}
.uavatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 22px;
  color: #fff;
  background: linear-gradient(140deg, var(--cyan), var(--indigo) 55%, var(--violet));
  box-shadow: 0 12px 28px -10px rgba(99, 102, 241, 0.95), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  flex: none;
}
.uinfo { flex: 1; min-width: 0; }
.uname { font-weight: 700; font-size: 16.5px; }
.urole { color: var(--muted); font-size: 13px; margin-top: 3px; }
.uquota { text-align: right; flex: none; }
.uquota .uk { display: block; color: rgba(255, 255, 255, 0.72); font-size: 12px; letter-spacing: 0.2px; }
.uquota b { font-size: 17px; font-weight: 700; color: #fff; }

@media (max-width: 620px) {
  .ucard-inner { padding: 18px; gap: 13px; }
  .uavatar { width: 48px; height: 48px; font-size: 19px; }
  .uquota b { font-size: 15px; }
}

/* ---------------------------------------------------------------- 流量统计 */

.traffic { padding: 22px 24px 20px; }
.traffic h2 { margin: 0; font-size: 17px; }

.t-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.t-head .muted { font-size: 12.5px; }

.t-main {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.t-used { display: flex; align-items: baseline; gap: 9px; }
.t-used b {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.6px;
  background: linear-gradient(120deg, #7dd3fc, #a78bfa 60%, #f0abfc);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.t-used span { color: var(--muted-2); font-size: 14px; }
.t-pct { color: var(--muted); font-size: 14px; font-weight: 600; }

.bar.big { height: 10px; margin-top: 14px; }
.bar.big > i { box-shadow: 0 0 18px -3px rgba(99, 102, 241, 0.85); }
.bar.big > i.warn { background: linear-gradient(90deg, var(--amber), #f97316); box-shadow: 0 0 18px -3px rgba(251, 191, 36, .8); }
.bar.big > i.crit { background: linear-gradient(90deg, #f97316, var(--red)); box-shadow: 0 0 18px -3px rgba(248, 113, 113, .85); }

.t-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}
.t-foot b { color: #c3cfe6; font-weight: 600; }

@media (max-width: 620px) {
  .t-used b { font-size: 26px; }
}

/* -------------------------------------------------------------------- misc */

.muted { color: var(--muted); }
.hidden { display: none !important; }

.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.05), rgba(255,255,255,0.11), rgba(255,255,255,0.05));
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: 6px;
  color: transparent;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (max-width: 620px) {
  .wrap, .topbar { padding-left: 15px; padding-right: 15px; }
  .hero { padding: 20px; }
  .hero h1 { font-size: 22px; }
  .hero-right { display: none; }
  .qr svg { width: 200px; height: 200px; }
}
