@import url("https://fonts.googleapis.com/css2?family=Exo+2:wght@300;400;500;600;700&family=Orbitron:wght@500;600;700&display=swap");

:root {
  /* 语义色板：金=信任/主操作 紫=技术强调 */
  --bg: #0f172a;
  --bg-deep: #0b1220;
  --panel: #151c2e;
  --card: #1b2334;
  --card-2: #222735;
  --line: #2a3448;
  --line-strong: #334155;
  --text: #f8fafc;
  --dim: #b6c3d3;
  --gold: #f59e0b;
  --gold-soft: #fbbf24;
  --violet: #8b5cf6;
  --green: #34d399;
  --red: #ef4444;
  --cyan: #22d3ee;
  --sky: #38bdf8;
  --rose: #fb7185;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 10px 30px rgba(2, 6, 16, 0.45);
  --ease: 180ms cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar: 232px;
}

* { box-sizing: border-box; }

html { font-size: 16px; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 600px at 15% -10%, rgba(245, 158, 11, 0.1), transparent 60%),
    radial-gradient(900px 500px at 95% 0%, rgba(139, 92, 246, 0.12), transparent 55%),
    var(--bg);
  color: var(--text);
  font: 400 15px/1.6 "Exo 2", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--gold-soft); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}

/* ---------- 骨架 ---------- */

.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 18px 14px;
  background: linear-gradient(180deg, rgba(27, 35, 52, 0.9), rgba(11, 18, 32, 0.95));
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 6px;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(140deg, #fbbf24, #f59e0b); color: #131a05;
  font-family: Orbitron, sans-serif; font-size: 14px; font-weight: 700;
}
.brand-name { font-family: Orbitron, sans-serif; font-size: 13px; letter-spacing: 0.16em; }
.brand-sub { display: block; font-family: "Exo 2", sans-serif; font-size: 11px; letter-spacing: 0.12em; color: var(--dim); }

.nav-link {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 10px;
  border-radius: var(--radius-sm); color: var(--dim); font-size: 14px;
  border: 1px solid transparent; transition: background var(--ease), color var(--ease);
}
.nav-link svg { width: 18px; height: 18px; flex: none; }
.nav-link:hover { background: rgba(148, 163, 184, 0.1); color: var(--text); text-decoration: none; }
.nav-link.on {
  background: rgba(245, 158, 11, 0.12); color: var(--gold-soft);
  border-color: rgba(245, 158, 11, 0.28); box-shadow: inset 2px 0 0 var(--gold);
}

.sidebar-foot { margin-top: auto; display: grid; gap: 8px; padding-top: 14px; }

.main { padding: 20px 26px 48px; min-width: 0; }

.topbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 18px; }
.topbar h1 { font-family: Orbitron, sans-serif; font-size: 19px; letter-spacing: 0.03em; margin: 0; }
.topbar .spacer { flex: 1; }

.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px;
  border-radius: 999px; border: 1px solid var(--line-strong); background: var(--card);
  color: var(--dim); font-size: 12px; letter-spacing: 0.04em;
}
.badge.ok { color: var(--green); border-color: rgba(52, 211, 153, 0.4); background: rgba(52, 211, 153, 0.1); }
.badge.warn { color: var(--gold-soft); border-color: rgba(245, 158, 11, 0.4); background: rgba(245, 158, 11, 0.1); }
.badge.bad { color: var(--red); border-color: rgba(239, 68, 68, 0.45); background: rgba(239, 68, 68, 0.1); }
.badge .dot-live { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.flash {
  margin-bottom: 14px; padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1px solid rgba(52, 211, 153, 0.4); background: rgba(52, 211, 153, 0.1);
  color: var(--green); font-size: 14px;
}
.flash.err { border-color: rgba(239, 68, 68, 0.45); background: rgba(239, 68, 68, 0.1); color: #fca5a5; }

/* ---------- 网格与卡片 ---------- */

.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: 1.5fr 1fr; }
.cols-2e { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1080px) {
  .cols-2, .cols-2e, .cols-3 { grid-template-columns: 1fr; }
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar-foot { margin: 0 0 0 auto; padding: 0; }
  .main { padding: 16px; }
}

.card {
  background: linear-gradient(180deg, var(--card), var(--panel));
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.card-head h2 {
  margin: 0; font-size: 12px; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--dim); font-weight: 600; font-family: "Exo 2", sans-serif;
}
.card-head .meta { font-size: 12px; color: var(--dim); }
.card-body { padding: 14px 16px; }
.card-body.flush { padding: 0; }

/* ---------- KPI ---------- */

.kpis { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); margin-bottom: 18px; }
.kpi {
  padding: 14px 16px 10px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line); overflow: hidden;
}
.kpi-label::before {
  content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  margin-right: 8px; background: var(--line-strong); vertical-align: middle;
}
.kpi.k-hot .kpi-label::before { background: var(--gold); }
.kpi.k-money .kpi-label::before { background: var(--cyan); }
.kpi.k-bad .kpi-label::before { background: var(--red); }
.kpi-label { font-size: 12px; color: var(--dim); letter-spacing: 0.03em; }
.kpi-value { font-family: "Segoe UI", Roboto, Arial, sans-serif; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 24px; line-height: 1.25; margin: 4px 0 2px; }
.kpi.k-hot .kpi-value { color: var(--gold-soft); }
.kpi.k-money .kpi-value { color: var(--cyan); }
.kpi.k-bad .kpi-value { color: #fca5a5; }
.spark { display: block; width: 100%; height: 30px; }

/* ---------- 图表 ---------- */

.chart { width: 100%; }
.h-140 { height: 140px; }
.h-160 { height: 160px; }
.h-170 { height: 170px; }
.h-200 { height: 200px; }
.h-240 { height: 240px; }
.h-280 { height: 280px; }

.legend { display: flex; flex-wrap: wrap; gap: 12px; padding: 0 16px 12px; font-size: 12px; color: var(--dim); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.legend .dash { height: 0; border-top: 2px dashed currentColor; border-radius: 0; }

.segmented { display: inline-flex; gap: 2px; padding: 3px; background: var(--bg-deep); border: 1px solid var(--line); border-radius: 999px; }
.segmented button {
  min-height: 30px; padding: 0 12px; border: 0; border-radius: 999px; background: transparent;
  color: var(--dim); font-size: 12px; cursor: pointer; transition: all var(--ease);
}
.segmented button[aria-pressed="true"] { background: rgba(245, 158, 11, 0.16); color: var(--gold-soft); }

/* ---------- 表格 ---------- */

.table-wrap { overflow: auto; max-height: 460px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  position: sticky; top: 0; z-index: 1; background: var(--card-2);
  padding: 10px 14px; text-align: left; font-weight: 600; font-size: 11px;
  letter-spacing: 0.03em; text-transform: uppercase; color: var(--dim);
  border-bottom: 1px solid var(--line-strong); white-space: nowrap;
}
tbody td { padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr:hover td { background: rgba(148, 163, 184, 0.06); }
.num { font-variant-numeric: tabular-nums; text-align: right; }

.empty { padding: 22px 16px; color: var(--dim); font-size: 13px; text-align: center; }

/* ---------- 状态与标签 ---------- */

.tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; letter-spacing: 0.04em; }
.tag.probe { background: rgba(245, 158, 11, 0.16); color: var(--gold-soft); }
.tag.whale { background: rgba(239, 68, 68, 0.16); color: #fca5a5; }
.tag.record { background: rgba(148, 163, 184, 0.12); color: var(--dim); }

.st { font-size: 11px; letter-spacing: 0.03em; }
.st.CONFIRMED { color: var(--green); }
.st.MISS, .st.FAILED, .st.EXPIRED { color: #fca5a5; }
.st.POISONED, .st.FUNDED, .st.INSUFFICIENT, .st.SETTLED { color: var(--gold-soft); }
.st.NEW, .st.MATCHED, .st.ENERGY_DONE { color: var(--sky); }

.pill {
  display: inline-flex; align-items: center; height: 22px; padding: 0 9px;
  border-radius: 999px; border: 1px solid var(--line-strong); background: var(--card-2);
  color: var(--dim); font-size: 11px;
}

.mono { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 12px; }
.addr { color: var(--dim); }
.muted { color: var(--dim); }

/* ---------- 表单 ---------- */

.form-grid { display: grid; gap: 14px; grid-template-columns: 168px 1fr; align-items: center; padding: 16px; }
.form-grid > label { font-size: 13px; color: var(--dim); }
.field { display: grid; gap: 6px; }

input, select, textarea, button {
  font: inherit; font-size: 14px; color: var(--text);
  background: var(--bg-deep); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: 9px 12px; min-height: 40px;
}
input::placeholder { color: #b6c3d3; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); }

button { cursor: pointer; transition: background var(--ease), border-color var(--ease), color var(--ease); }
button:hover { border-color: var(--gold); color: var(--gold-soft); }

.btn-primary {
  background: linear-gradient(180deg, #f7b234, var(--gold)); color: #1a1205;
  border: 1px solid #d99408; font-weight: 600;
}
.btn-primary:hover { color: #1a1205; filter: brightness(1.06); }

.btn-ghost { background: transparent; }
.btn-danger:hover { border-color: var(--red); color: #fca5a5; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 16px; }
.toolbar .grow { flex: 1; min-width: 220px; }

/* ---------- 时间线 ---------- */

.timeline { padding: 8px 16px 16px; }
.tl {
  display: grid; grid-template-columns: 16px 120px 1fr 90px; gap: 10px; align-items: center;
  padding: 10px 0; border-bottom: 1px dashed var(--line);
}
.tl:last-child { border-bottom: 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); }
.dot.ok { background: var(--green); }
.dot.fail, .dot.expired { background: var(--red); }
.dot.activate { background: var(--gold); }

/* ---------- 键值 ---------- */

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 10px 14px; padding: 16px; font-size: 13px; }
.kv > span:nth-child(odd) { color: var(--dim); }

code { background: var(--bg-deep); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; font-size: 12px; }

/* ---------- 杂项 ---------- */

.pager { display: flex; gap: 10px; align-items: center; padding: 12px 16px; color: var(--dim); font-size: 13px; }

.section-title {
  display: flex; align-items: baseline; gap: 10px; margin: 22px 0 12px;
  font-family: Orbitron, sans-serif; font-size: 13px; letter-spacing: 0.03em; color: var(--dim);
}

footer { margin-top: 26px; color: #b6c3d3; font-size: 12px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── 登录页 ───────────────────────────────────────────────── */
.login-body {
  min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 0%, #1b2540 0%, #0b1020 60%);
}
.login-card {
  width: min(360px, 92vw); display: grid; gap: 10px;
  padding: 26px 24px 20px; border-radius: var(--radius);
  border: 1px solid #24304a; background: #131a2b;
}
.login-card .brand { margin-bottom: 6px; }
.login-card label { font-size: 13px; color: #94a3b8; }
.login-card input { min-height: 38px; }
.login-card .btn-primary { margin-top: 6px; min-height: 40px; }
.login-hint { font-size: 12px; margin: 4px 0 0; }
.inline-form { display: inline; }
.flash.bad { border-color: rgba(239, 68, 68, 0.45); background: rgba(239, 68, 68, 0.1); color: #fca5a5; }

/* ── 设置页分页签 ─────────────────────────────────────────── */
.tabs {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-bottom: 14px; border-bottom: 1px solid #24304a; padding-bottom: 0;
}
.tab {
  border: 1px solid transparent; border-bottom: none; background: transparent;
  color: #94a3b8; padding: 9px 16px; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-size: 14px; cursor: pointer;
}
.tab:hover { color: #e2e8f0; background: rgba(148, 163, 184, 0.08); }
.tab.on {
  color: #f8fafc; background: #151c2e;
  border-color: #24304a; box-shadow: inset 0 2px 0 #22d3ee;
}
.tab-panel[hidden] { display: none; }

/* ── 流水线看板 ───────────────────────────────────────────── */
.pipe { display: grid; grid-template-columns: 128px 1fr; gap: 18px; padding: 6px 16px 10px; align-items: start; }
.pipe-ring { position: relative; width: 120px; height: 120px; }
.pipe-ring svg { width: 120px; height: 120px; transform: rotate(-90deg); }
.pipe-ring circle { fill: none; stroke-width: 8; stroke-linecap: round; }
.pipe-ring .ring-bg { stroke: #1e293b; }
.pipe-ring .ring-fg { stroke: #22d3ee; transition: stroke-dashoffset 0.5s ease, stroke 0.3s; }
.pipe-ring-text {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 18px; font-weight: 600; color: #e2e8f0;
}
.pipe-steps { display: grid; gap: 6px; }
.pipe-step {
  display: grid; grid-template-columns: 26px 1fr auto 60px; align-items: center; gap: 10px;
  padding: 7px 12px; border-radius: var(--radius-sm); border: 1px solid #1e293b;
  background: #131a2b; font-size: 14px; color: #94a3b8;
}
.pipe-step.current { border-color: #22d3ee; background: rgba(34, 211, 238, 0.1); color: #e2e8f0; }
.pipe-step.done { color: #cbd5e1; }
.pipe-no {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px;
  background: #1e293b; color: #94a3b8; font-size: 12px;
}
.pipe-step.current .pipe-no { background: #22d3ee; color: #0b1020; }
.pipe-step.done .pipe-no { background: #1f3d33; color: #34d399; }
.pipe-budget { color: #64748b; font-size: 12px; }
.pipe-ms { text-align: right; font-variant-numeric: tabular-nums; }
.pipe-foot {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 0 16px 14px; font-size: 12px;
}
.meta.live { color: #34d399; }
