:root {
  --bg: #060a12;
  --bg-soft: #0a1120;
  --panel: rgba(14, 23, 41, 0.72);
  --panel-solid: #0e1729;
  --line: rgba(148, 163, 184, 0.13);
  --line-strong: rgba(148, 163, 184, 0.24);
  --text: #e8eefb;
  --muted: #8fa0ba;
  --dim: #64748b;
  --cyan: #22d3ee;
  --cyan-soft: rgba(34, 211, 238, 0.12);
  --violet: #a78bfa;
  --violet-soft: rgba(167, 139, 250, 0.12);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.12);
  --green: #34d399;
  --red: #fb7185;
  --radius: 18px;
  --shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.9);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  background: radial-gradient(1200px 700px at 15% -10%, rgba(34, 211, 238, 0.13), transparent 60%),
              radial-gradient(900px 600px at 90% 0%, rgba(167, 139, 250, 0.10), transparent 55%),
              var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.045) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 35%, transparent 85%);
  pointer-events: none;
  z-index: 0;
}

.bg-glow {
  position: fixed;
  top: -240px;
  left: 50%;
  width: 900px;
  height: 480px;
  transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(34, 211, 238, 0.16), transparent);
  filter: blur(30px);
  pointer-events: none;
  z-index: 0;
}

main, .topbar { position: relative; z-index: 1; }

/* ---------- top bar ---------- */

.topbar {
  max-width: 1340px;
  margin: 0 auto;
  padding: 26px 28px 8px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.brand { display: flex; align-items: center; gap: 14px; }

.logo {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 20px;
  color: #041018;
  background: linear-gradient(135deg, var(--cyan), #67e8f9 45%, var(--violet));
  box-shadow: 0 10px 30px -10px rgba(34, 211, 238, 0.65);
  flex: none;
}

.brand-text h1 {
  margin: 0;
  font-size: 21px;
  letter-spacing: 0.2px;
  font-weight: 650;
}

.brand-text h1 span {
  color: var(--muted);
  font-weight: 450;
  margin-left: 6px;
}

.brand-text p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

.actions { display: flex; align-items: center; gap: 14px; }

.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
}

.live-dot i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.14);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.85); }
}

.btn-refresh {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(34, 211, 238, 0.35);
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.16), rgba(34, 211, 238, 0.06));
  color: #c8f7ff;
  padding: 9px 14px;
  border-radius: 11px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: 0.18s ease;
}

.btn-refresh svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-refresh:hover { background: rgba(34, 211, 238, 0.2); border-color: rgba(34, 211, 238, 0.6); }
.btn-refresh:disabled { opacity: 0.55; cursor: wait; }
.btn-refresh.spinning svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- layout ---------- */

main > *,
.two-col > *,
.kpi-grid > * { min-width: 0; }

main {
  max-width: 1340px;
  margin: 0 auto;
  padding: 14px 28px 48px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  padding: 20px 22px;
}

.kpi {
  position: relative;
  overflow: hidden;
  padding: 18px 20px 14px;
  min-height: 132px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent, var(--cyan)), transparent);
  opacity: 0.55;
}

.kpi-label {
  color: var(--muted);
  font-size: 12.5px;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.kpi-label em {
  font-style: normal;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--dim);
}

.kpi-value {
  font-size: 32px;
  font-weight: 660;
  letter-spacing: -0.5px;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.kpi-value small { font-size: 15px; color: var(--muted); font-weight: 500; margin-left: 3px; }

.kpi-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--dim);
  font-size: 12px;
  margin-top: auto;
}

.delta { font-variant-numeric: tabular-nums; font-weight: 600; }
.delta.up { color: var(--red); }
.delta.down { color: var(--green); }
.delta.flat { color: var(--muted); }

.spark { width: 96px; height: 30px; flex: none; opacity: 0.9; }

/* ---------- panel head ---------- */

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-title h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 620;
  letter-spacing: 0.2px;
}

.panel-title p {
  margin: 3px 0 0;
  color: var(--dim);
  font-size: 12.5px;
}

.range-tabs {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--line);
  background: rgba(8, 14, 26, 0.6);
  border-radius: 10px;
  flex: none;
}

.range-tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 7px;
  cursor: pointer;
  transition: 0.15s ease;
}

.range-tabs button:hover { color: var(--text); }
.range-tabs button.active {
  color: #06121a;
  background: linear-gradient(180deg, #67e8f9, var(--cyan));
  font-weight: 650;
}

/* ---------- charts ---------- */

.chart-box { position: relative; height: 300px; }
.chart-box.tall { height: 430px; }

.main-panel .chart-box { margin-top: 2px; }

.two-col {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 18px;
}

/* ---------- table ---------- */

.table-tools { display: flex; align-items: center; gap: 10px; }

.table-tools input {
  width: 190px;
  border: 1px solid var(--line);
  background: rgba(8, 14, 26, 0.65);
  color: var(--text);
  border-radius: 9px;
  padding: 8px 11px;
  font: inherit;
  font-size: 12.5px;
  outline: none;
  transition: 0.15s ease;
}

.table-tools input:focus { border-color: rgba(34, 211, 238, 0.55); box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.1); }
.table-tools input::placeholder { color: var(--dim); }

.pill {
  font-size: 11.5px;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  max-height: 610px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #0c1526;
  color: var(--muted);
  font-weight: 560;
  text-align: right;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-strong);
}

thead th:first-child { text-align: left; }
thead th span { color: var(--dim); font-weight: 400; font-size: 10.5px; }

tbody td {
  padding: 9px 14px;
  text-align: right;
  border-bottom: 1px solid rgba(148, 163, 184, 0.07);
  color: #cbd5e1;
}

tbody td:first-child { text-align: left; color: var(--text); font-weight: 520; }
tbody tr:hover { background: rgba(34, 211, 238, 0.045); }

.bar-cell { position: relative; }
.bar-cell .mini {
  position: absolute;
  left: 8px;
  bottom: 4px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--cyan), rgba(34, 211, 238, 0.1));
  opacity: 0.75;
}

.hot { color: var(--amber); font-weight: 650; }
.cool { color: var(--cyan); }

.pager {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.pager button {
  min-width: 32px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(8, 14, 26, 0.6);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.pager button:hover:not(:disabled) { color: var(--text); border-color: var(--line-strong); }
.pager button.active { background: rgba(34, 211, 238, 0.16); color: #a5f3fc; border-color: rgba(34, 211, 238, 0.45); }
.pager button:disabled { opacity: 0.35; cursor: default; }

/* ---------- footer ---------- */

footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  color: var(--dim);
  font-size: 11.5px;
  padding: 4px 4px 0;
}

footer b { color: var(--muted); font-weight: 500; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: rgba(11, 18, 32, 0.95);
  border: 1px solid var(--line-strong);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 11px;
  font-size: 12.5px;
  opacity: 0;
  pointer-events: none;
  transition: 0.25s ease;
  z-index: 20;
  box-shadow: var(--shadow);
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { border-color: rgba(52, 211, 153, 0.45); }
.toast.err { border-color: rgba(251, 113, 133, 0.5); }

/* ---------- error ---------- */

.error-box {
  margin: 40px auto;
  max-width: 620px;
  text-align: center;
  color: var(--muted);
  line-height: 1.9;
}

.error-box code {
  display: inline-block;
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid var(--line);
  padding: 6px 10px;
  border-radius: 8px;
  color: #cbd5e1;
  font-size: 12px;
}

/* ---------- responsive ---------- */

@media (max-width: 1080px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .topbar { flex-direction: column; padding: 20px 16px 6px; }
  .actions { width: 100%; justify-content: space-between; }
  main { padding: 10px 16px 36px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-value { font-size: 28px; }
  .panel { padding: 16px; }
  .panel-head { flex-direction: column; }
  .range-tabs { align-self: flex-start; }
  .chart-box.tall { height: 330px; }
  .chart-box { height: 260px; }
  .table-tools { width: 100%; }
  .table-tools input { flex: 1; width: auto; }
  .brand-text h1 { font-size: 18px; }
}
