:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --panel: #141922;
  --panel-2: #181e29;
  --line: #242c3a;
  --line-soft: #1b222e;
  --text: #e8ebf2;
  --muted: #8c95a8;
  --dim: #626b7d;
  --teal: #39d0c3;
  --teal-soft: rgba(57, 208, 195, 0.12);
  --amber: #f0a64a;
  --green: #43d17c;
  --red: #ef6b6b;
  --radius: 14px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1100px 600px at 15% -10%, rgba(57, 208, 195, 0.09), transparent 60%),
    radial-gradient(900px 520px at 92% 0%, rgba(240, 166, 74, 0.05), transparent 55%),
    var(--bg);
  color: var(--text);
}

body { min-height: 100vh; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.app { min-height: 100vh; display: flex; flex-direction: column; }

/* ---- top bar ---- */
.topbar {
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(11, 13, 18, 0.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

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

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(140deg, #39d0c3, #1f8f86);
  color: #06231f;
  font-weight: 800;
  font-size: 19px;
}

.brand-name { font-size: 17px; font-weight: 700; letter-spacing: 0.2px; }
.brand-sub {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.12em;
}

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

.coin-switch {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.coin-switch button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  transition: 0.16s;
}

.coin-switch button.active {
  background: var(--teal-soft);
  color: var(--teal);
  box-shadow: inset 0 0 0 1px rgba(57, 208, 195, 0.28);
}

.conn { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.conn i { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); display: block; }
.conn.ok i { background: var(--green); box-shadow: 0 0 8px rgba(67, 209, 124, 0.7); }
.conn.warn i { background: var(--amber); box-shadow: 0 0 8px rgba(240, 166, 74, 0.7); }
.conn.err i { background: var(--red); box-shadow: 0 0 8px rgba(239, 107, 107, 0.7); }

.updated { font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }

.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 9px;
  font-size: 13px;
  transition: 0.16s;
}
.btn:hover { border-color: rgba(57, 208, 195, 0.45); color: var(--teal); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 10px; font-size: 12px; border-radius: 7px; }

/* ---- 语音提醒按钮 ---- */
.btn.voice { display: inline-flex; align-items: center; gap: 7px; }
.btn.voice .voice-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--dim); display: block; flex: none;
}
.btn.voice.on {
  border-color: rgba(57, 208, 195, 0.5);
  color: var(--teal);
  background: var(--teal-soft);
}
.btn.voice.on .voice-dot {
  background: var(--teal);
  animation: voicePulse 1.8s infinite;
}
@keyframes voicePulse {
  0%   { box-shadow: 0 0 0 0 rgba(57, 208, 195, 0.55); }
  70%  { box-shadow: 0 0 0 7px rgba(57, 208, 195, 0); }
  100% { box-shadow: 0 0 0 0 rgba(57, 208, 195, 0); }
}

/* ---- layout ---- */
.main {
  flex: 1;
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 26px 28px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.error {
  border: 1px solid rgba(239, 107, 107, 0.4);
  background: rgba(239, 107, 107, 0.08);
  color: #ffb3b3;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 13px;
}

/* ---- 掉线告警条 ---- */
.alert {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid rgba(239, 107, 107, 0.45);
  background: linear-gradient(90deg, rgba(239, 107, 107, 0.16), rgba(239, 107, 107, 0.04));
  color: #ffc4c4;
  font-size: 13px;
  animation: alertIn 0.25s ease;
}
.alert[hidden] { display: none; }
.alert.ok {
  border-color: rgba(67, 209, 124, 0.4);
  background: linear-gradient(90deg, rgba(67, 209, 124, 0.14), rgba(67, 209, 124, 0.03));
  color: #b6f0cd;
}
.alert-badge {
  flex: none;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(239, 107, 107, 0.22);
  color: #ff9d9d;
}
.alert.ok .alert-badge { background: rgba(67, 209, 124, 0.18); color: #7fe0a6; }
.alert-text { flex: 1; font-weight: 600; }
.alert-time { font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }
.alert .btn { flex: none; }
.alert-close {
  border: 0;
  background: transparent;
  color: var(--dim);
  font-size: 20px;
  line-height: 1;
  padding: 0 2px;
  flex: none;
}
.alert-close:hover { color: var(--red); }
@keyframes alertIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

/* ---- 告警记录 ---- */
.alert-log {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 0 16px;
}
.alert-log summary {
  cursor: pointer;
  padding: 13px 0;
  font-size: 13px;
  color: var(--muted);
  list-style: none;
}
.alert-log summary::-webkit-details-marker { display: none; }
.alert-log summary::before { content: "▸ "; color: var(--dim); }
.alert-log[open] summary::before { content: "▾ "; }
.alert-log summary span { color: var(--dim); margin-left: 6px; }
.alert-log ul {
  list-style: none;
  margin: 0;
  padding: 0 0 13px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 260px;
  overflow: auto;
}
.alert-log li { display: flex; gap: 12px; font-size: 12.5px; color: var(--muted); }
.alert-log li .lg-time {
  flex: none;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.alert-log li.lv-warn { color: #ffb0b0; }
.alert-log li.lv-ok { color: #9ce8bb; }
.alert-log li.dim { color: var(--dim); }

/* ---- KPI ---- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
}

.kpi {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 98px;
}

.kpi.accent { border-color: rgba(57, 208, 195, 0.35); box-shadow: 0 0 0 1px rgba(57, 208, 195, 0.08) inset; }
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.3px;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  white-space: nowrap;
}
.kpi-value.small { font-size: 18px; letter-spacing: 0; }
.kpi.accent .kpi-value { color: var(--teal); }
.kpi-hint { font-size: 11px; color: var(--dim); }

/* ---- panel ---- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px 12px;
  flex-wrap: wrap;
}

.panel-head h2 { margin: 0; font-size: 15px; font-weight: 700; }
.panel-head p { margin: 4px 0 0; font-size: 12px; color: var(--muted); }

.seg {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 9px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
}
.seg button.active { background: var(--teal-soft); color: var(--teal); }

/* ---- chart ---- */
.chart-wrap { position: relative; padding: 4px 10px 12px; height: 262px; }
.chart-wrap.sm { height: 196px; }
.chart-wrap canvas { width: 100%; height: 100%; display: block; }
.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--dim);
  font-size: 13px;
}
.chart-empty[hidden] { display: none; }

/* ---- profit stats ---- */
.profit-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.profit-stats > div {
  min-width: 104px;
  padding: 7px 12px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.profit-stats span { font-size: 11px; color: var(--muted); }
.profit-stats strong {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--amber);
  white-space: nowrap;
}

/* ---- tools ---- */
.tools { display: flex; gap: 10px; flex-wrap: wrap; }

.tools input, .tools select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9px;
  padding: 7px 11px;
  font-size: 13px;
  outline: none;
  min-width: 150px;
}
.tools input:focus, .tools select:focus { border-color: rgba(57, 208, 195, 0.5); }
.tools input::placeholder { color: var(--dim); }

/* ---- table ---- */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }

thead th {
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  background: #10151d;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--teal); }
th.sorted { color: var(--teal); }
th.sorted::after { content: " ↓"; font-size: 10px; }
th.sorted.asc::after { content: " ↑"; }

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}
tbody tr:hover { background: rgba(57, 208, 195, 0.045); }
tbody tr.offline { opacity: 0.55; }

td.col-name, th.col-name { font-weight: 600; }
td.empty { text-align: center; color: var(--dim); padding: 30px 0; }
td.strong { font-weight: 700; color: var(--teal); }
td .zero { color: var(--dim); }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.status i { width: 7px; height: 7px; border-radius: 50%; display: block; background: var(--dim); }
.status.active { color: var(--green); }
.status.active i { background: var(--green); }
.status.unactive { color: var(--dim); }
.status.unactive i { background: var(--dim); }
.status.invalid { color: var(--red); }
.status.invalid i { background: var(--red); }

.delta-up { color: var(--teal); }
.delta-down { color: var(--amber); }

/* ---- pager ---- */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--line-soft);
}
.pager-btns { display: flex; gap: 8px; }

/* ---- footer ---- */
.foot {
  text-align: center;
  font-size: 11px;
  color: var(--dim);
  padding: 18px 20px 26px;
}

@media (max-width: 1120px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .topbar { height: auto; padding: 14px 16px; flex-wrap: wrap; }
  .main { padding: 18px 14px 30px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-value { font-size: 20px; }
  .chart-wrap { height: 210px; }
  .tools input, .tools select { min-width: 0; flex: 1; }
  .btn.voice span { display: none; }
  .btn.voice { padding: 7px 11px; }
  .alert { flex-wrap: wrap; }
  .alert-text { flex-basis: 100%; order: 3; }
}
