:root {
  --bg-0: #05040f;
  --bg-1: #0b0828;
  --bg-2: #160d3d;
  --ink: #f4f1ff;
  --muted: rgba(222, 214, 255, 0.62);
  --faint: rgba(222, 214, 255, 0.38);
  --line: rgba(196, 181, 253, 0.18);
  --line-strong: rgba(196, 181, 253, 0.42);
  --glass: rgba(20, 15, 48, 0.62);
  --panel: rgba(17, 13, 40, 0.72);
  --field: rgba(9, 7, 26, 0.62);
  --teal: #5eead4;
  --violet: #a78bfa;
  --pink: #f472b6;
  --bad: #ff9d94;
  --warn: #f2c879;
  --ok: #8bd7aa;
  --font: "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: radial-gradient(120% 90% at 50% 0%, var(--bg-2) 0%, var(--bg-1) 45%, var(--bg-0) 100%) fixed;
  background-color: var(--bg-0);
}
[hidden] { display: none !important; }
button { font-family: var(--font); }

.backdrop { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.backdrop .orb { position: absolute; width: 46vmax; height: 46vmax; border-radius: 50%; filter: blur(70px); opacity: 0.34; animation: drift 22s ease-in-out infinite alternate; }
.backdrop .orb-a { left: -14vmax; top: -10vmax; background: radial-gradient(circle, rgba(124, 92, 255, 0.9), transparent 65%); }
.backdrop .orb-b { right: -16vmax; top: 18vh; background: radial-gradient(circle, rgba(94, 234, 212, 0.5), transparent 65%); animation-duration: 28s; animation-delay: -6s; }
.backdrop .orb-c { left: 22vw; bottom: -26vmax; background: radial-gradient(circle, rgba(244, 114, 182, 0.45), transparent 65%); animation-duration: 25s; animation-delay: -12s; }
.backdrop .grid {
  position: absolute; inset: 45% -20% -30%;
  background-image: linear-gradient(rgba(167, 139, 250, 0.10) 1px, transparent 1px), linear-gradient(90deg, rgba(167, 139, 250, 0.10) 1px, transparent 1px);
  background-size: 56px 56px; transform: perspective(600px) rotateX(62deg); transform-origin: top center;
  mask-image: linear-gradient(to bottom, transparent, #000 35%, transparent 95%);
  animation: grid 9s linear infinite;
}
@keyframes drift { to { transform: translate3d(6vmax, 4vmax, 0) scale(1.12); } }
@keyframes grid { to { background-position: 0 56px, 0 0; } }

/* ---------- sign in ---------- */
.signin { position: relative; z-index: 1; min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.card {
  position: relative; width: min(440px, 100%); padding: 34px 34px 22px;
  border: 1px solid var(--line); border-radius: 22px; background: var(--glass);
  backdrop-filter: blur(22px) saturate(140%);
  box-shadow: 0 30px 80px rgba(3, 2, 12, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  animation: rise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.card::before {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1px; pointer-events: none;
  background: linear-gradient(140deg, rgba(94, 234, 212, 0.55), rgba(167, 139, 250, 0.12) 40%, rgba(244, 114, 182, 0.45));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
}
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(0.98); } }
.card-head { display: flex; align-items: center; gap: 16px; margin-bottom: 26px; }
.logo { width: 58px; height: 58px; border-radius: 14px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 10px 30px rgba(124, 92, 255, 0.45); }
.card-head h1 {
  margin: 0 0 6px; font-size: 25px; font-weight: 800; letter-spacing: 0.06em;
  background: linear-gradient(90deg, #fff 0%, #e4dcff 60%, #c4b5fd 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.card-head p { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.chip { display: inline-block; margin-right: 8px; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; color: #0b0828; background: linear-gradient(90deg, var(--teal), var(--violet)); }

.tabs { position: relative; display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 20px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: rgba(5, 4, 15, 0.45); }
.tabs button { position: relative; z-index: 1; height: 36px; border: 0; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); background: transparent; cursor: pointer; transition: color 0.25s ease; }
.tabs button[aria-selected="true"] { color: var(--ink); }
.tab-ink { position: absolute; top: 4px; left: 4px; width: calc(50% - 4px); height: 36px; border-radius: 9px; background: linear-gradient(135deg, rgba(124, 92, 255, 0.55), rgba(94, 234, 212, 0.25)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12); transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1); }
.tabs[data-active="activate"] .tab-ink { transform: translateX(100%); }

.form { display: grid; gap: 14px; }
.form label, .field { display: grid; gap: 7px; }
.form label span, .field span { font-size: 12.5px; font-weight: 600; letter-spacing: 0.08em; color: var(--muted); }
input {
  height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 11px;
  font: 500 15px var(--font); color: var(--ink); background: var(--field); outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
input::placeholder { color: var(--faint); }
input:hover { border-color: var(--line-strong); }
input:focus { border-color: var(--violet); background: rgba(14, 10, 38, 0.8); box-shadow: 0 0 0 4px rgba(167, 139, 250, 0.18); }

.primary {
  position: relative; height: 46px; margin-top: 6px; padding: 0 18px; border: 0; border-radius: 12px;
  font-weight: 700; font-size: 15px; letter-spacing: 0.18em; color: #fff;
  background: linear-gradient(100deg, #14b8a6 0%, #7c3aed 52%, #db2777 100%); background-size: 160% 100%;
  box-shadow: 0 12px 30px rgba(124, 58, 237, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  cursor: pointer; overflow: hidden; transition: background-position 0.5s ease, transform 0.15s ease, opacity 0.2s ease;
}
.primary:hover { background-position: 100% 0; }
.primary:active { transform: translateY(1px); }
.primary:focus-visible, .ghost:focus-visible, .tabs button:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }
.primary:disabled { opacity: 0.7; cursor: progress; }
.primary.busy span { opacity: 0; }
.primary.busy::after { content: ""; position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px; border: 2px solid rgba(255, 255, 255, 0.35); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; }
.primary.small { height: 36px; margin: 0; font-size: 13px; letter-spacing: 0.06em; }
@keyframes spin { to { transform: rotate(360deg); } }

.message { min-height: 20px; margin: 14px 0 0; font-size: 13px; line-height: 1.5; color: var(--bad); text-align: center; }
.card-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 12px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--faint); }
.secure { display: inline-flex; align-items: center; gap: 7px; }
.secure i { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 10px var(--teal); }

/* ---------- dashboard ---------- */
.dashboard { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 22px 20px 48px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { width: 40px; height: 40px; border-radius: 10px; }
.brand strong { font-size: 19px; letter-spacing: 0.04em; }
.who { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.ghost { height: 32px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--ink); background: rgba(95, 84, 140, 0.25); cursor: pointer; }
.ghost:hover { background: rgba(124, 92, 255, 0.3); }
.ghost.small { height: 28px; font-size: 12px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stats article { padding: 16px 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); backdrop-filter: blur(14px); }
.stats small { display: block; color: var(--muted); font-size: 12.5px; letter-spacing: 0.1em; }
.stats strong { display: block; margin-top: 6px; font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; background: linear-gradient(90deg, #fff, #c4b5fd); -webkit-background-clip: text; background-clip: text; color: transparent; }

.panel { margin-bottom: 18px; padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); backdrop-filter: blur(14px); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.panel-head h2 { margin: 0; font-size: 17px; letter-spacing: 0.06em; }
.tools { display: flex; align-items: center; gap: 12px; }
.tools input { height: 36px; width: 220px; font-size: 14px; }
.muted { color: var(--muted); font-size: 12.5px; }

.series { display: grid; gap: 14px; }
.series-card { border: 1px solid var(--line); border-radius: 14px; background: rgba(9, 7, 26, 0.45); overflow: hidden; }
.series-card > header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: linear-gradient(90deg, rgba(124, 92, 255, 0.18), transparent); }
.series-card h3 { margin: 0; font-size: 15px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 9px 16px; text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; letter-spacing: 0.06em; white-space: nowrap; }
td { padding: 10px 16px; border-top: 1px solid rgba(196, 181, 253, 0.08); white-space: nowrap; }
tbody tr:hover td { background: rgba(124, 92, 255, 0.07); }
.ep { font-weight: 700; }
.num { font-variant-numeric: tabular-nums; }
.warn { color: var(--warn); }
.mono { font-family: Consolas, "Cascadia Mono", monospace; }
.progress { display: inline-block; width: 120px; height: 7px; margin-right: 10px; vertical-align: middle; border-radius: 999px; background: rgba(196, 181, 253, 0.14); overflow: hidden; }
.progress i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), var(--violet), var(--pink)); transition: width 0.6s ease; }
.who-cell { font-weight: 600; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; color: var(--muted); border: 1px solid var(--line); }
.pill.live { color: #fff; border-color: rgba(244, 114, 182, 0.6); background: rgba(244, 114, 182, 0.16); }
.pill.ok { color: var(--ok); border-color: rgba(139, 215, 170, 0.45); }
.pill.warn { color: var(--warn); border-color: rgba(242, 200, 121, 0.45); }
.empty { margin: 8px 0; color: var(--muted); text-align: center; }

.dialog { width: min(440px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line-strong); border-radius: 18px; color: var(--ink); background: rgba(20, 15, 48, 0.98); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); }
.dialog::backdrop { background: rgba(3, 2, 12, 0.7); backdrop-filter: blur(4px); }
.dialog-body { display: grid; gap: 14px; padding: 22px; }
.dialog h3 { margin: 0; font-size: 17px; }
.dialog p { margin: 0; line-height: 1.6; color: var(--muted); }
.dialog .code { padding: 14px; border-radius: 12px; font: 700 22px Consolas, "Cascadia Mono", monospace; letter-spacing: 0.12em; text-align: center; color: #fff; background: rgba(124, 92, 255, 0.2); border: 1px dashed var(--violet); user-select: all; }
.dialog footer { display: flex; justify-content: flex-end; gap: 10px; }
.dialog .message { margin: 0; text-align: left; }

@media (max-width: 760px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tools input { width: 100%; }
  .tools { width: 100%; }
}
@media (max-width: 520px) {
  .card { padding: 26px 20px 18px; border-radius: 18px; }
  .card-head h1 { font-size: 21px; }
  .dashboard { padding: 16px 16px 40px; }
}
@media (prefers-reduced-motion: reduce) {
  .backdrop .orb, .backdrop .grid, .card { animation: none; }
}
