/* ============================================================
   用量星图 · 深空主题
   在 styles.css 之后加载:覆盖设计令牌与组件样式
   设计意象:仿真旋涡星系(模型即旋臂,当日花费是臂上的星) / 斜俯视三维投影 / 玻璃观测舱
   ============================================================ */

:root {
  --bg: #04060f;
  --text: #e9eeff;
  --dim: #9399b8;
  --dimmer: #5d6280;
  --accent: #8b9dff;
  --cyan: #6ee7ff;
  --magenta: #f472b6;
  --aurora: #3ecf8e;
  --amber: #f5b53f;
  --red: #f4647e;
  --glass: linear-gradient(165deg, rgba(23, 28, 55, 0.66), rgba(9, 12, 27, 0.58));
  --glass-border: rgba(139, 157, 255, 0.14);
  --glass-border-strong: rgba(139, 157, 255, 0.3);
}

/* ---------- 深空底色:三层星云 + 固定渐变 ---------- */
body {
  background:
    radial-gradient(ellipse 62% 46% at 16% -10%, rgba(122, 105, 255, 0.16), transparent 66%),
    radial-gradient(ellipse 46% 42% at 92% 8%, rgba(110, 231, 255, 0.09), transparent 64%),
    radial-gradient(ellipse 58% 52% at 50% 118%, rgba(244, 114, 182, 0.1), transparent 62%),
    linear-gradient(180deg, #06081a 0%, var(--bg) 34%);
  background-attachment: fixed;
  color: var(--text);
}

/* 静态星云层(覆盖 styles.css 的顶部氛围光);运动交给星场画布,这层不再做全屏动画 */
body::before {
  content: "";
  position: fixed;
  inset: -20% -10%;
  pointer-events: none;
  background:
    radial-gradient(ellipse 34% 26% at 24% 22%, rgba(139, 157, 255, 0.1), transparent 70%),
    radial-gradient(ellipse 26% 30% at 78% 64%, rgba(110, 231, 255, 0.06), transparent 70%),
    radial-gradient(ellipse 30% 24% at 58% 88%, rgba(180, 139, 255, 0.07), transparent 70%);
}

#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
header, main { position: relative; z-index: 1; }

/* ---------- 顶栏:更深的玻璃观测带 ---------- */
header {
  background: rgba(4, 6, 15, 0.72);
  border-bottom: 1px solid rgba(139, 157, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.brand .name {
  background: linear-gradient(100deg, #f2f5ff 30%, #a8b6ff 75%, #7ee7ff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 0.02em;
}
.brand .tag { color: var(--dimmer); }

.nav-link {
  color: var(--dim);
  text-decoration: none;
  font-size: 12.5px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 4px 13px;
  background: rgba(139, 157, 255, 0.05);
  transition: color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.nav-link:hover {
  color: #fff;
  border-color: var(--glass-border-strong);
  box-shadow: 0 0 14px rgba(139, 157, 255, 0.22);
}

.conn-status {
  border-color: var(--glass-border);
  background: rgba(139, 157, 255, 0.04);
  color: var(--dim);
}

/* ---------- 布局:无卡片,信息悬浮于深空 ---------- */
main {
  max-width: none;
  padding: 0 36px 30px;
  gap: 0;
}

/* ---------- 仿真旋涡星系:canvas 渲染,斜俯视三维投影 ---------- */
.hero {
  position: relative;
  min-height: max(620px, calc(100vh - 66px));
  display: grid;
  place-items: center;
}
.gwrap {
  position: relative;
  width: min(140vmin, 1300px);
  aspect-ratio: 3 / 2;
  transition: transform 0.3s ease-out;
}
#galaxy {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* 恒星卡片:点击拉近后在右侧展开 */
.star-card {
  position: absolute;
  right: 3vw;
  top: 50%;
  transform: translateY(-50%);
  width: 268px;
  padding: 18px 18px 14px;
  border-radius: 14px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), 0 0 40px rgba(139, 157, 255, 0.08);
  z-index: 5;
}
.star-card.hidden { display: none; }
.star-card-close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: none;
  background: none;
  color: var(--dimmer);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
}
.star-card-close:hover { color: var(--text); }
.sc-model {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.03em;
  word-break: break-all;
  padding-right: 18px;
}
.sc-date {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dimmer);
  margin-top: 4px;
}
.sc-spend {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  margin-top: 10px;
}
.sc-sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dim);
  margin-top: 4px;
}

/* 总花费读数:悬于星系左上,不干扰画面 */
.hero-meta {
  position: absolute;
  left: 2vw;
  top: 8vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  z-index: 4;
}
.hero-stats {
  display: flex;
  align-items: baseline;
  gap: 9px;
  pointer-events: none;
}
.hs-value {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.hs-label {
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--dimmer);
}
.hs-sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dimmer);
}

/* 悬停读出:归于左上信息区 */
.hud-readout {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
  min-height: 18px;
  pointer-events: none;
}

/* 时间控制台:悬浮于星系右上的玻璃浮块 */
.range-bar {
  position: absolute;
  right: 2vw;
  top: 8vh;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 46vw;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* ---------- 移动端:浮块归于文档流 ---------- */
@media (max-width: 900px) {
  main { padding: 0 16px 24px; }
  .hero { min-height: 0; padding: 18px 0 30px; display: flex; flex-direction: column; gap: 12px; }
  .gwrap { width: min(96vmin, 560px); aspect-ratio: 1; }
  .hero-meta { position: static; order: -1; align-items: center; text-align: center; }
  .range-bar { position: static; justify-content: center; max-width: none; }
  .star-card {
    right: 50%;
    top: auto;
    bottom: 96px;
    transform: translateX(50%);
    width: min(300px, 82vw);
  }
}

/* ---------- 控件:星尘玻璃 ---------- */
.range-switch {
  background: rgba(7, 10, 23, 0.66);
  border-color: var(--glass-border);
}
.range-switch button { color: var(--dimmer); }
.range-switch button:hover { color: var(--dim); }
.range-switch button.active {
  background: linear-gradient(135deg, rgba(139, 157, 255, 0.32), rgba(110, 231, 255, 0.16));
  color: #fff;
  box-shadow: 0 0 14px rgba(139, 157, 255, 0.35);
}

.range-bar input[type="date"] {
  background: rgba(7, 10, 23, 0.66);
  color: var(--text);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12.5px;
  color-scheme: dark;
  transition: border-color 0.14s;
}
.range-bar input[type="date"]:focus { border-color: var(--glass-border-strong); outline: none; }

.ghost-btn {
  background: rgba(139, 157, 255, 0.07);
  border-color: var(--glass-border);
  color: var(--text);
}
.ghost-btn:hover {
  background: rgba(139, 157, 255, 0.14);
  border-color: var(--glass-border-strong);
  box-shadow: 0 0 12px rgba(139, 157, 255, 0.18);
}

/* ---------- 登录舱:悬浮于星海的密封舱 ---------- */
.login-mask { background: rgba(2, 3, 9, 0.72); backdrop-filter: blur(14px); }
.login-box {
  position: relative;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow:
    inset 0 1px 0 rgba(190, 205, 255, 0.08),
    0 0 60px rgba(139, 157, 255, 0.14),
    0 30px 80px rgba(0, 0, 0, 0.6);
}
.login-box .brand-mark { position: relative; width: 40px; height: 40px; margin: 0 auto; }
/* 环绕徽标的星轨 */
.login-box .brand-mark::before {
  content: "";
  position: absolute;
  inset: -13px;
  border: 1px dashed rgba(139, 157, 255, 0.28);
  border-radius: 50%;
  animation: orbit-spin 26s linear infinite;
}
.login-box .brand-mark::after {
  content: "";
  position: absolute;
  top: -15.5px;
  left: 50%;
  width: 5px;
  height: 5px;
  margin-left: -2.5px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
  animation: orbit-sat 26s linear infinite;
  transform-origin: 2.5px 33px;
}
@keyframes orbit-spin { to { transform: rotate(360deg); } }
@keyframes orbit-sat { to { transform: rotate(360deg); } }
.login-title {
  background: linear-gradient(100deg, #f2f5ff 30%, #a8b6ff 75%, #7ee7ff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.login-box input {
  background: rgba(7, 10, 23, 0.7);
  border-color: var(--glass-border);
  color: var(--text);
}
.login-box input:focus { border-color: var(--glass-border-strong); box-shadow: 0 0 12px rgba(139, 157, 255, 0.15); }
.login-box button {
  background: linear-gradient(120deg, #8b9dff, #6ea8ff 60%, #6ee7ff);
  color: #060a1c;
  box-shadow: 0 4px 22px rgba(110, 160, 255, 0.35);
}
.login-box button:hover { filter: brightness(1.12); }

/* ---------- 其余 ---------- */
.range-sep { color: var(--dimmer); }

.loading {
  position: fixed;
  inset: 0;
  background: rgba(2, 3, 9, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.loading .spinner {
  width: 42px;
  height: 42px;
  border: 2px solid rgba(139, 157, 255, 0.18);
  border-top-color: var(--cyan);
  border-radius: 50%;
  box-shadow: 0 0 20px rgba(110, 231, 255, 0.2);
  animation: u-spin 0.9s linear infinite;
}
@keyframes u-spin { to { transform: rotate(360deg); } }

/* ---------- 入场:星体浮现 ---------- */
@media (prefers-reduced-motion: no-preference) {
  main > * {
    animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.3, 1) both;
  }
  main > *:nth-child(1) { animation-delay: 0.03s; }
  main > *:nth-child(2) { animation-delay: 0.1s; }
  main > *:nth-child(3) { animation-delay: 0.17s; }
  main > *:nth-child(4) { animation-delay: 0.24s; }
  main > *:nth-child(5) { animation-delay: 0.31s; }
  main > *:nth-child(6) { animation-delay: 0.38s; }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .login-box .brand-mark::before,
  .login-box .brand-mark::after { animation: none; }
}
