@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@500;700&family=Rajdhani:wght@400;500;600;700&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  background: #050b18;
  color: #cfe8ff;
  font-family: 'Rajdhani', 'Microsoft YaHei', sans-serif;
  overflow: hidden;
}

.screen {
  position: relative;
  width: 100vw;
  height: 100vh;
  padding: 14px 20px 10px;
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse at top, #0a1a33 0%, #050b18 55%, #020508 100%);
}

/* 背景网格装饰 */
.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(45, 140, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(45, 140, 255, 0.06) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
  mask-image: radial-gradient(ellipse at center, rgba(0,0,0,0.9) 0%, transparent 75%);
}

/* ============ 首屏加载动画 ============ */
.dashboard-loader {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at center, rgba(15, 47, 86, 0.96) 0%, rgba(5, 15, 31, 0.98) 42%, #020711 78%),
    #050b18;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.dashboard-loader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-orbit {
  position: relative;
  width: 72px;
  height: 72px;
  margin-bottom: 22px;
  border: 2px solid rgba(45, 140, 255, 0.16);
  border-top-color: #2d8cff;
  border-right-color: #00ffe7;
  border-radius: 50%;
  filter: drop-shadow(0 0 10px rgba(45, 140, 255, 0.65));
  animation: loader-spin 1.15s linear infinite;
}

.loader-orbit::before {
  content: '';
  position: absolute;
  inset: 8px;
  border: 2px solid rgba(0, 255, 231, 0.12);
  border-bottom-color: #00ffe7;
  border-left-color: #2d8cff;
  border-radius: 50%;
  animation: loader-spin-reverse 0.85s linear infinite;
}

.loader-core {
  position: absolute;
  inset: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: #00ffe7;
  box-shadow: 0 0 8px #00ffe7, 0 0 22px rgba(0, 255, 231, 0.8);
  animation: loader-pulse 1.1s ease-in-out infinite;
}

.loader-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 3px;
  color: #d6ecff;
  text-shadow: 0 0 12px rgba(45, 140, 255, 0.7);
}

.loader-subtitle {
  margin-top: 9px;
  font-size: 12px;
  letter-spacing: 1px;
  color: #6f9bc7;
}

@keyframes loader-spin {
  to { transform: rotate(360deg); }
}

@keyframes loader-spin-reverse {
  to { transform: rotate(-360deg); }
}

@keyframes loader-pulse {
  0%, 100% { transform: scale(0.72); opacity: 0.6; }
  50% { transform: scale(1.15); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .loader-orbit,
  .loader-orbit::before,
  .loader-core { animation-duration: 2.4s; }
}

/* ============ 头部 ============ */
.header {
  position: relative;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(300px, 1fr);
  align-items: center;
  gap: 16px;
  height: 64px;
  flex-shrink: 0;
  z-index: 2;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.header-title {
  justify-self: center;
  font-family: 'Orbitron', sans-serif;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 4px;
  background: linear-gradient(180deg, #ffffff 10%, #7fd3ff 60%, #2d8cff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 25px rgba(45, 140, 255, 0.5);
  white-space: nowrap;
}

.header-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  white-space: nowrap;
}

.header-decoration {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, #2d8cff, #00ffe7);
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
  box-shadow: 0 0 18px rgba(45, 140, 255, 0.8);
  flex-shrink: 0;
}

.header-sub {
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: 'Orbitron', sans-serif;
  font-size: 12px;
  letter-spacing: 2px;
  color: #4d9fff;
  opacity: 0.85;
  white-space: nowrap;
}

.time-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  flex: 0 0 auto;
}

.clock {
  display: block;
  font-family: 'Orbitron', sans-serif;
  font-size: 19px;
  line-height: 1;
  color: #7fe8ff;
  letter-spacing: 1px;
  white-space: nowrap;
}

.date {
  display: block;
  font-size: 10px;
  line-height: 1.2;
  color: #7ea8d8;
  white-space: nowrap;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  font-size: 11px;
  color: #00ffb0;
  border: 1px solid rgba(0, 255, 176, 0.4);
  padding: 4px 8px;
  border-radius: 14px;
  background: rgba(0, 255, 176, 0.08);
  white-space: nowrap;
}

.currency-badge {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  padding: 4px 8px;
  border: 1px solid rgba(127, 232, 255, 0.35);
  border-radius: 14px;
  background: rgba(45, 140, 255, 0.08);
  color: #7fe8ff;
  font-size: 11px;
  white-space: nowrap;
}

.currency-badge.is-warning {
  border-color: rgba(255, 95, 109, 0.5);
  background: rgba(255, 95, 109, 0.1);
  color: #ff8891;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #00ffb0;
  box-shadow: 0 0 8px #00ffb0;
  animation: blink 1.4s infinite;
  flex-shrink: 0;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.user-block {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
}

.user-display {
  min-width: 0;
  max-width: 112px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
  color: #9fc6ec;
  white-space: nowrap;
}

.logout-btn {
  flex-shrink: 0;
  font-size: 12px;
  color: #ff8891;
  background: rgba(255, 95, 109, 0.1);
  border: 1px solid rgba(255, 95, 109, 0.35);
  border-radius: 14px;
  padding: 4px 10px;
  cursor: pointer;
  transition: filter 0.2s;
  font-family: 'Rajdhani', sans-serif;
  white-space: nowrap;
}
.logout-btn:hover { filter: brightness(1.2); }

/* ============ KPI 行 ============ */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
  margin: 10px 0 14px;
  flex-shrink: 0;
  z-index: 2;
}

.kpi-card {
  position: relative;
  background: linear-gradient(160deg, rgba(20, 40, 70, 0.75), rgba(10, 20, 40, 0.55));
  border: 1px solid rgba(77, 159, 255, 0.25);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
  box-shadow: inset 0 0 20px rgba(45, 140, 255, 0.06);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #4d9fff, transparent);
  animation: sweep 3s linear infinite;
}

@keyframes sweep {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.kpi-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  background: rgba(45, 140, 255, 0.12);
  border: 1px solid rgba(77, 159, 255, 0.3);
}

.kpi-info { min-width: 0; }

.kpi-label {
  font-size: 12px;
  color: #8fb8e6;
  letter-spacing: 1px;
  white-space: nowrap;
}

.kpi-value {
  font-family: 'Orbitron', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 12px rgba(77, 159, 255, 0.6);
  white-space: nowrap;
}

.kpi-value .unit {
  font-size: 12px;
  color: #7fe8ff;
  margin-left: 4px;
  font-family: 'Rajdhani', sans-serif;
}

.kpi-trend {
  font-size: 11px;
  margin-top: 2px;
}
.kpi-trend.up { color: #00ffb0; }
.kpi-trend.down { color: #ff5f6d; }

/* ============ 主体布局 ============ */
.main-grid {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1.5fr) minmax(0, 1.25fr);
  gap: 14px;
  min-width: 0;
  min-height: 0;
  z-index: 2;
}

.col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  min-height: 0;
}

.panel {
  position: relative;
  background: linear-gradient(160deg, rgba(15, 32, 58, 0.65), rgba(8, 16, 32, 0.55));
  border: 1px solid rgba(77, 159, 255, 0.2);
  border-radius: 10px;
  padding: 10px 14px 6px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel::after {
  content: '';
  position: absolute;
  width: 12px; height: 12px;
  top: -1px; left: -1px;
  border-top: 2px solid #4d9fff;
  border-left: 2px solid #4d9fff;
  border-radius: 3px 0 0 0;
}

.panel-title {
  font-size: 14px;
  font-weight: 600;
  color: #d6ecff;
  letter-spacing: 1px;
  padding-left: 10px;
  position: relative;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.panel-title::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 4px; height: 14px;
  background: linear-gradient(180deg, #00ffe7, #2d8cff);
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(45, 140, 255, 0.8);
}

.chart {
  flex: 1;
  min-height: 0;
  width: 100%;
}

/* 账单趋势摘要：独立占位，避免覆盖图表绘图区 */
.trend-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  flex-shrink: 0;
  margin: 2px 0 4px;
  padding: 6px 8px;
  font-size: 11px;
  background: rgba(6, 14, 28, 0.55);
  border: 1px solid rgba(77,159,255,0.25);
  border-radius: 8px;
}
.trend-stats .row {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: #9fc6ec;
}
.trend-stats .row b {
  max-width: 100%;
  overflow: hidden;
  color: #7fe8ff;
  font-family: 'Orbitron', sans-serif;
  font-size: 12px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============ 实时滚动表格 ============ */
.ticker-wrap {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.ticker-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.ticker-table thead th {
  position: sticky;
  top: 0;
  background: rgba(10, 22, 42, 0.9);
  color: #6fb4ff;
  text-align: left;
  padding: 6px 8px;
  font-weight: 600;
  border-bottom: 1px solid rgba(77, 159, 255, 0.25);
  z-index: 1;
}

.ticker-table tbody tr {
  border-bottom: 1px solid rgba(77, 159, 255, 0.08);
  animation: fadeIn 0.6s ease;
}

.ticker-table tbody td {
  padding: 6px 8px;
  color: #cfe8ff;
}

.ticker-table tbody tr:hover { background: rgba(45, 140, 255, 0.08); }

.tag {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
}
.tag.cost { background: rgba(45,140,255,0.15); color: #7fe8ff; }
.tag.warn { background: rgba(255, 95, 109, 0.15); color: #ff8891; }
.tag.recharge { background: rgba(0,255,176,0.15); color: #00ffb0; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 滚动条美化 */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb { background: rgba(77,159,255,0.4); border-radius: 2px; }
::-webkit-scrollbar-track { background: transparent; }

.dashboard-error {
  grid-column: 1 / -1;
  align-self: center;
  padding: 32px;
  color: #ff8891;
  font-size: 16px;
  text-align: center;
}

/* 响应式缩放：保持 1024px 及以上视口的单屏布局 */
@media (max-width: 1440px) {
  .screen { padding: 10px 12px 8px; }

  .header {
    grid-template-columns: minmax(40px, 1fr) auto minmax(286px, 1fr);
    gap: 10px;
    height: 54px;
  }

  .header-sub { display: none; }
  .header-decoration { width: 28px; height: 28px; }
  .header-title { font-size: 23px; letter-spacing: 2px; }
  .header-actions { gap: 7px; }
  .clock { font-size: 17px; }
  .date { font-size: 9px; }
  .live-badge { min-width: 20px; justify-content: center; padding: 5px 6px; }
  .live-badge span { display: none; }
  .user-block { gap: 4px; }
  .user-display { max-width: 82px; font-size: 11px; }
  .logout-btn { padding: 3px 8px; font-size: 11px; }

  .kpi-row { gap: 8px; margin: 6px 0 8px; }
  .kpi-card { padding: 8px 10px; gap: 8px; }
  .kpi-icon { width: 34px; height: 34px; font-size: 18px; }
  .kpi-value { font-size: 17px; }
  .kpi-label { font-size: 11px; letter-spacing: 0; }
  .kpi-trend { font-size: 10px; }

  .main-grid, .col { gap: 8px; }
  .panel { padding: 8px 10px 5px; }
  .panel-title { font-size: 12px; }
  .ticker-table { font-size: 11px; }
  .ticker-table thead th, .ticker-table tbody td { padding: 4px 6px; }
}

@media (max-width: 1080px) {
  .header-title { font-size: 21px; letter-spacing: 1px; }
  .header-actions { gap: 5px; }
  .live-badge { gap: 4px; padding-inline: 6px; }
  .user-display { max-width: 82px; }
  .kpi-card { padding-inline: 7px; }
  .kpi-icon { width: 30px; height: 30px; font-size: 16px; }
  .kpi-value { font-size: 15px; }
  .kpi-value .unit { font-size: 10px; margin-left: 2px; }
}
