:root {
  color-scheme: dark;
  --bg: #071014;
  --surface: #0c171c;
  --surface-2: #101e23;
  --surface-3: #14262b;
  --border: rgba(154, 201, 203, 0.14);
  --border-strong: rgba(66, 204, 186, 0.28);
  --text: #e7f0ef;
  --muted: #82979a;
  --dim: #53676a;
  --cyan: #3bc8d4;
  --cyan-soft: rgba(59, 200, 212, 0.13);
  --green: #6bc58a;
  --green-soft: rgba(107, 197, 138, 0.13);
  --amber: #e6b85c;
  --amber-soft: rgba(230, 184, 92, 0.14);
  --red: #ef6a65;
  --red-soft: rgba(239, 106, 101, 0.12);
  --blue: #5c8fd9;
  --purple: #a88ac7;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #03090c;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  color: var(--text);
  letter-spacing: 0;
}

button, input, select { font: inherit; letter-spacing: 0; }
button { color: inherit; }

.is-hidden { opacity: 0; pointer-events: none; }

.viewport {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: opacity 320ms ease;
}

.app-shell {
  position: absolute;
  width: 1920px;
  height: 1080px;
  transform-origin: center center;
  background:
    linear-gradient(rgba(69, 122, 126, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(69, 122, 126, 0.025) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px;
  overflow: hidden;
}

.topbar {
  height: 76px;
  padding: 0 30px;
  display: grid;
  grid-template-columns: 430px 1fr 190px;
  align-items: center;
  gap: 24px;
  background: rgba(7, 16, 20, 0.98);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand h1 { margin: 0; font-size: 20px; line-height: 1.15; font-weight: 650; }
.brand p { margin: 6px 0 0; font-size: 10px; color: var(--muted); letter-spacing: 1.8px; }

.brand-symbol, .boot-mark {
  position: relative;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border: 1px solid rgba(59, 200, 212, 0.42);
  background: rgba(59, 200, 212, 0.06);
}

.brand-symbol span, .boot-mark span {
  position: absolute;
  width: 17px;
  height: 24px;
  left: 9px;
  top: 8px;
  border-radius: 50% 50% 55% 45%;
  transform: rotate(32deg);
  border: 2px solid var(--cyan);
}

.brand-symbol i, .boot-mark i {
  position: absolute;
  width: 14px;
  height: 7px;
  right: 5px;
  bottom: 8px;
  border-left: 2px solid var(--green);
  border-bottom: 2px solid var(--green);
  transform: rotate(-28deg) skew(-18deg);
}

.main-nav { display: flex; align-self: stretch; justify-content: center; gap: 6px; }
.nav-item {
  position: relative;
  min-width: 112px;
  padding: 0 20px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
}
.nav-item::after {
  content: "";
  position: absolute;
  left: 26px;
  right: 26px;
  bottom: -1px;
  height: 3px;
  background: var(--cyan);
  transform: scaleX(0);
  transition: transform 180ms ease;
}
.nav-item:hover { color: var(--text); background: rgba(255,255,255,0.025); }
.nav-item.is-active { color: #f2fbfa; background: linear-gradient(to top, rgba(59,200,212,0.08), transparent 70%); }
.nav-item.is-active::after { transform: scaleX(1); }

.archive-status { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.archive-status b, .archive-status small { display: block; text-align: left; }
.archive-status b { font-size: 13px; font-weight: 550; }
.archive-status small { color: var(--muted); margin-top: 4px; font-size: 11px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(107,197,138,0.1); }

.querybar {
  height: 88px;
  padding: 14px 30px 12px;
  display: grid;
  grid-template-columns: 340px 1fr;
  grid-template-rows: 42px 18px;
  gap: 2px 24px;
  background: rgba(10, 22, 26, 0.94);
  border-bottom: 1px solid var(--border);
}

.query-title { grid-row: 1 / span 2; display: flex; align-items: center; gap: 15px; }
.query-title > span { color: var(--cyan); font-size: 25px; font-weight: 300; font-variant-numeric: tabular-nums; }
.query-title h2 { margin: 0; font-size: 19px; font-weight: 650; }
.query-title p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

.query-controls { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.query-controls label { height: 36px; display: flex; align-items: center; gap: 8px; padding-left: 11px; color: var(--muted); font-size: 12px; background: var(--surface); border: 1px solid var(--border); }
.query-controls input, .query-controls select {
  height: 34px;
  padding: 0 10px;
  border: 0;
  border-left: 1px solid var(--border);
  outline: 0;
  color: var(--text);
  background: #0a1519;
  font-size: 12px;
}
.query-controls input { width: 130px; color-scheme: dark; }
.query-controls select { min-width: 105px; cursor: pointer; }
.date-separator { color: var(--dim); font-size: 12px; }
.query-button {
  height: 36px;
  min-width: 110px;
  border: 1px solid rgba(59,200,212,0.45);
  background: rgba(59,200,212,0.13);
  color: #dffbfc;
  cursor: pointer;
  transition: background 160ms ease;
}
.query-button:hover { background: rgba(59,200,212,0.22); }
.query-button:disabled { opacity: 0.58; cursor: wait; }
.query-icon { display: inline-block; width: 9px; height: 9px; margin-right: 8px; border: 2px solid currentColor; border-radius: 50%; position: relative; }
.query-icon::after { content: ""; position: absolute; width: 5px; height: 2px; right: -5px; bottom: -3px; transform: rotate(45deg); background: currentColor; }

.query-meta { display: flex; justify-content: flex-end; align-items: center; gap: 10px; color: var(--dim); font-size: 11px; }
.query-meta i { width: 2px; height: 2px; border-radius: 50%; background: var(--dim); }

.page-root { height: 886px; padding: 18px 30px 14px; overflow: hidden; }
.page { height: 100%; animation: pageIn 280ms ease both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.app-footer { height: 30px; padding: 0 30px; display: flex; align-items: center; justify-content: space-between; color: var(--dim); border-top: 1px solid var(--border); font-size: 10px; background: rgba(4, 11, 14, 0.98); }

.grid { display: grid; gap: 14px; }
.cols-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }.span-3 { grid-column: span 3; }.span-4 { grid-column: span 4; }.span-5 { grid-column: span 5; }.span-6 { grid-column: span 6; }.span-7 { grid-column: span 7; }.span-8 { grid-column: span 8; }.span-9 { grid-column: span 9; }.span-12 { grid-column: span 12; }

.panel, .kpi-card {
  background: linear-gradient(145deg, rgba(16,30,35,0.98), rgba(10,21,25,0.98));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: 4px;
  min-width: 0;
  position: relative;
  overflow: hidden;
}
.panel::before, .kpi-card::before { content: ""; position: absolute; left: 0; top: 0; width: 34px; height: 1px; background: var(--cyan); opacity: 0.7; }
.panel { padding: 15px 17px; }
.panel-title { height: 30px; display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.panel-title h3 { margin: 0; font-size: 14px; font-weight: 600; }
.panel-title p { margin: 4px 0 0; font-size: 10px; color: var(--muted); }
.panel-title .panel-tag { color: var(--muted); border: 1px solid var(--border); padding: 4px 7px; font-size: 10px; white-space: nowrap; }
.chart { width: 100%; height: calc(100% - 30px); min-height: 0; }

.kpi-row { height: 112px; margin-bottom: 14px; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.kpi-card { padding: 15px 17px; }
.kpi-label { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; }
.kpi-label em { font-style: normal; font-size: 10px; padding: 3px 6px; border: 1px solid var(--border); }
.kpi-value { margin-top: 10px; font-size: 29px; font-weight: 650; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 12px; color: var(--muted); margin-left: 5px; font-weight: 400; }
.kpi-foot { margin-top: 9px; display: flex; justify-content: space-between; color: var(--dim); font-size: 10px; }
.trend-up { color: var(--green) !important; }.trend-down { color: var(--red) !important; }.text-cyan { color: var(--cyan) !important; }.text-green { color: var(--green) !important; }.text-amber { color: var(--amber) !important; }.text-red { color: var(--red) !important; }

.overview-main { height: 392px; margin-bottom: 14px; }
.overview-bottom { height: 322px; }
.environment-top { height: 350px; margin-bottom: 14px; }
.environment-bottom { height: 364px; }
.growth-top { height: 345px; margin-bottom: 14px; }
.growth-bottom { height: 369px; }
.device-main { height: 345px; margin-bottom: 14px; }
.device-bottom { height: 369px; }
.event-layout { height: 820px; }
.report-layout { height: 728px; }
.report-left-stack { display: grid; grid-template-rows: 165px 190px 1fr; gap: 14px; min-height: 0; }
.report-left-stack > .panel { min-height: 0; }
.report-list-panel { padding-bottom: 10px; }

.insight-list { margin-top: 8px; display: grid; gap: 9px; }
.insight-item { padding: 12px 12px 12px 15px; background: rgba(255,255,255,0.025); border-left: 2px solid var(--cyan); }
.insight-item.warn { border-left-color: var(--amber); }
.insight-item.good { border-left-color: var(--green); }
.insight-item strong { display: block; font-size: 12px; font-weight: 600; margin-bottom: 5px; }
.insight-item p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.65; }

.score-wrap { height: calc(100% - 30px); display: grid; grid-template-columns: 44% 56%; align-items: center; }
.score-ring { width: 150px; height: 150px; margin: 0 auto; position: relative; border-radius: 50%; background: conic-gradient(var(--green) 0 87%, rgba(255,255,255,0.06) 87%); }
.score-ring::after { content: ""; position: absolute; inset: 13px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border); }
.score-ring .score-inner { position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.score-inner strong { font-size: 38px; line-height: 1; }
.score-inner small { color: var(--muted); font-size: 11px; margin-top: 7px; }
.score-stats { display: grid; gap: 11px; padding-right: 12px; }
.score-stat { display: grid; grid-template-columns: 76px 1fr 35px; align-items: center; gap: 8px; font-size: 10px; color: var(--muted); }
.score-stat b { color: var(--text); text-align: right; font-size: 11px; }
.progress { height: 5px; background: rgba(255,255,255,0.055); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--cyan); }

.metric-stack { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 8px; }
.metric-box { padding: 13px; background: rgba(255,255,255,0.025); border: 1px solid rgba(255,255,255,0.035); }
.metric-box span { display: block; color: var(--muted); font-size: 10px; }
.metric-box b { display: block; margin-top: 7px; font-size: 20px; }
.metric-box small { color: var(--dim); font-size: 9px; }

.section-tabs { display: inline-flex; height: 29px; border: 1px solid var(--border); }
.section-tabs button { min-width: 68px; padding: 0 12px; border: 0; border-right: 1px solid var(--border); background: transparent; color: var(--muted); cursor: pointer; font-size: 11px; }
.section-tabs button:last-child { border-right: 0; }
.section-tabs button.is-active { color: #eafafa; background: var(--cyan-soft); }

.growth-summary { height: calc(100% - 30px); display: grid; grid-template-columns: 190px 1fr; align-items: center; gap: 15px; }
.growth-figure { text-align: center; }
.growth-figure .big-number { font-size: 48px; font-weight: 650; color: var(--green); }
.growth-figure span { display: block; color: var(--muted); font-size: 11px; margin-top: 6px; }
.growth-facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.growth-fact { padding: 12px; background: rgba(255,255,255,0.026); }
.growth-fact span { color: var(--muted); font-size: 10px; display: block; }
.growth-fact b { font-size: 15px; margin-top: 5px; display: block; }

.data-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.data-table th { height: 35px; color: var(--muted); background: rgba(255,255,255,0.025); font-size: 10px; font-weight: 500; text-align: left; padding: 0 10px; border-bottom: 1px solid var(--border); }
.data-table td { height: 39px; padding: 0 10px; color: #c7d4d3; font-size: 11px; border-bottom: 1px solid rgba(154,201,203,0.07); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: rgba(59,200,212,0.035); }
.state-pill { display: inline-flex; align-items: center; min-width: 52px; justify-content: center; padding: 4px 7px; border: 1px solid; font-size: 10px; }
.state-pill.good { color: var(--green); background: var(--green-soft); border-color: rgba(107,197,138,0.25); }
.state-pill.warn { color: var(--amber); background: var(--amber-soft); border-color: rgba(230,184,92,0.25); }
.state-pill.bad { color: var(--red); background: var(--red-soft); border-color: rgba(239,106,101,0.25); }
.state-pill.info { color: var(--cyan); background: var(--cyan-soft); border-color: rgba(59,200,212,0.25); }

.event-list, .report-list { height: calc(100% - 34px); overflow: auto; padding-right: 4px; scrollbar-color: var(--surface-3) transparent; }
.event-card, .report-card { width: 100%; padding: 13px 14px; text-align: left; border: 1px solid transparent; border-bottom-color: var(--border); background: transparent; cursor: pointer; }
.event-card:hover, .report-card:hover { background: rgba(255,255,255,0.025); }
.event-card.is-active, .report-card.is-active { background: var(--cyan-soft); border-color: rgba(59,200,212,0.24); }
.event-head, .report-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.event-head strong, .report-head strong { font-size: 12px; font-weight: 600; }
.event-card p, .report-card p { margin: 8px 0 0; color: var(--muted); font-size: 10px; line-height: 1.6; }
.event-card small, .report-card small { color: var(--dim); font-size: 9px; }

.event-detail { height: 100%; display: grid; grid-template-rows: 118px 248px 196px 1fr; gap: 12px; }
.event-hero { padding: 17px 19px; border: 1px solid var(--border); background: rgba(255,255,255,0.022); }
.event-hero-top { display: flex; justify-content: space-between; }
.event-hero h3 { margin: 8px 0 7px; font-size: 19px; }
.event-hero p { margin: 0; color: var(--muted); font-size: 11px; }
.event-metrics { display: flex; gap: 28px; margin-top: 13px; }
.event-metrics span { color: var(--dim); font-size: 10px; }
.event-metrics b { color: var(--text); margin-left: 6px; font-size: 11px; }

.event-flow { display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; gap: 18px; height: calc(100% - 30px); }
.flow-node { position: relative; min-height: 90px; padding: 14px; border: 1px solid var(--border); background: rgba(255,255,255,0.025); }
.flow-node:not(:last-child)::after { content: ""; position: absolute; top: 45px; right: -19px; width: 19px; border-top: 1px solid rgba(59,200,212,0.45); }
.flow-node:not(:last-child)::before { content: ""; position: absolute; top: 41px; right: -19px; border-left: 5px solid rgba(59,200,212,0.6); border-top: 4px solid transparent; border-bottom: 4px solid transparent; }
.flow-node em { font-style: normal; color: var(--cyan); font-size: 9px; }
.flow-node strong { display: block; margin: 8px 0 5px; font-size: 11px; }
.flow-node small { color: var(--muted); font-size: 9px; line-height: 1.55; }

.evidence-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 9px; }
.evidence-item { padding: 12px; background: rgba(255,255,255,0.025); }
.evidence-item span { color: var(--dim); font-size: 9px; }
.evidence-item b { display: block; margin-top: 6px; font-size: 11px; }

.report-detail { height: 100%; display: grid; grid-template-rows: 115px 164px 1fr; gap: 12px; }
.report-summary { padding: 17px 19px; border: 1px solid var(--border); background: rgba(255,255,255,0.022); }
.report-summary h3 { margin: 9px 0 7px; font-size: 18px; }
.report-summary p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.report-columns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.report-section { padding: 14px; border: 1px solid var(--border); background: rgba(255,255,255,0.02); }
.report-section h4 { margin: 0 0 10px; color: var(--muted); font-size: 10px; font-weight: 500; }
.report-section p { margin: 0; font-size: 11px; line-height: 1.75; }
.report-evidence { padding: 15px; border: 1px solid var(--border); overflow: hidden; }
.report-evidence h4 { margin: 0 0 12px; font-size: 12px; }

.loading-page { height: 100%; display: grid; grid-template-rows: 112px 1fr 300px; gap: 14px; }
.skeleton-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; }
.skeleton { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--border); }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(121,194,194,0.08), transparent); animation: shimmer 1.15s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }

.boot-screen { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; background: #050d11; transition: opacity 380ms ease, visibility 380ms ease; }
.boot-screen.is-complete { opacity: 0; visibility: hidden; }
.boot-mark { width: 64px; height: 64px; margin-bottom: 25px; transform: scale(1.35); }
.boot-screen h1 { margin: 0; font-size: 23px; font-weight: 600; }
.boot-screen p { width: 360px; margin: 19px 0 10px; color: var(--muted); font-size: 12px; }
.boot-progress { width: 360px; height: 3px; background: rgba(255,255,255,0.06); }
.boot-progress b { display: block; width: 0; height: 100%; background: var(--cyan); transition: width 280ms ease; }
.boot-meta { width: 360px; margin-top: 9px; display: flex; justify-content: space-between; color: var(--dim); font-size: 9px; letter-spacing: 1px; }

.empty-state { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); }
.empty-state b { font-size: 14px; color: var(--text); margin-bottom: 7px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
