:root {
  color-scheme: dark;
  --bg: #090d14;
  --surface: #10151d;
  --surface-2: #171b24;
  --sidebar: #282933;
  --line: #29313d;
  --line-soft: rgba(255, 255, 255, 0.06);
  --text: #f4f7fb;
  --muted: #9ba6b8;
  --muted-2: #6f7c91;
  --blue: #86c6ff;
  --blue-2: #13314d;
  --green: #70d7a1;
  --amber: #ffd27c;
  --red: #ff8f8f;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 188px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 12px 18px;
  background: var(--sidebar);
  border-right: 1px solid #1b2029;
}

.brand {
  margin: 0 2px 22px;
  color: var(--muted);
  font-size: 13px;
}

.nav-item {
  display: block;
  min-height: 28px;
  padding: 5px 8px;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  line-height: 18px;
}

.nav-item + .nav-item {
  margin-top: 8px;
}

.nav-item.active {
  background: #5b5f6d;
  font-weight: 700;
}

.sidebar-note {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--muted);
  font-size: 12px;
}

.sidebar-note strong {
  display: block;
  margin-top: 6px;
  color: var(--text);
  font-size: 15px;
}

main {
  min-width: 0;
  padding: 30px 30px 26px;
}

.view {
  max-width: 1440px;
  margin: 0 auto;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  gap: 16px;
  align-items: end;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 12px;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 2.4vw, 40px);
  line-height: 1.08;
  font-weight: 800;
}

.hero-copy {
  max-width: 760px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.status-card,
.result-summary > div,
.detail-metrics > div,
.info-panel {
  background: rgba(20, 25, 34, 0.86);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

.status-card {
  padding: 12px;
}

.status-card span,
.result-summary span,
.detail-metrics span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.status-card strong {
  font-size: 16px;
}

.query-grid {
  display: grid;
  grid-template-columns: 92px 104px 118px 164px 104px minmax(230px, 1fr) minmax(130px, 0.6fr) 76px;
  gap: 10px;
  align-items: end;
  margin-top: 20px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

fieldset {
  margin: 0;
  border: 0;
  padding: 0;
}

.subject-picker {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, auto));
  gap: 4px 7px;
  align-items: center;
  min-height: 36px;
}

.subject-picker legend {
  grid-column: 1 / -1;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.subject-picker label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 18px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.subject-picker input {
  width: 14px;
  min-height: 14px;
  accent-color: var(--blue);
}

input,
select {
  width: 100%;
  min-height: 36px;
  border: 1px solid #252b35;
  border-radius: 7px;
  padding: 6px 9px;
  background: #252932;
  color: var(--text);
}

input:focus,
select:focus {
  border-color: var(--blue);
  outline: 2px solid rgba(134, 198, 255, 0.18);
}

button {
  min-height: 36px;
  border: 1px solid #3f4656;
  border-radius: 7px;
  padding: 6px 11px;
  background: #131922;
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: var(--blue);
}

.result-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.result-summary > div,
.detail-metrics > div {
  min-height: 64px;
  padding: 11px 13px;
}

.result-summary strong,
.detail-metrics strong {
  font-size: 21px;
  line-height: 1.1;
}

.section-bar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.section-bar h2,
.section-title h2,
.info-panel h2 {
  margin: 0;
  font-size: 18px;
}

.section-bar p,
.section-title p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.actions {
  display: flex;
  align-items: end;
  gap: 10px;
}

.actions label {
  width: 172px;
}

.ghost {
  background: transparent;
}

.table-panel {
  margin-top: 12px;
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(13, 18, 25, 0.86);
  max-height: min(56vh, 620px);
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  border-bottom: 1px solid var(--line-soft);
  padding: 8px 10px;
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #1a1f29;
  color: var(--muted);
  font-weight: 500;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: rgba(134, 198, 255, 0.09);
}

.open-cell {
  width: 34px;
}

.row-button {
  width: 18px;
  min-height: 18px;
  border-radius: 5px;
  padding: 0;
  background: transparent;
}

.numeric {
  font-variant-numeric: tabular-nums;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 5px;
  padding: 2px 7px;
  background: #232b36;
  color: var(--muted);
  font-size: 12px;
}

.tag.blue {
  background: rgba(134, 198, 255, 0.14);
  color: var(--blue);
}

.tag.amber {
  background: rgba(255, 210, 124, 0.14);
  color: var(--amber);
}

.tag.green {
  background: rgba(112, 215, 161, 0.14);
  color: var(--green);
}

.url-links {
  display: flex;
  gap: 6px;
}

.url-links a,
.detail-links a {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid #324054;
  border-radius: 6px;
  padding: 3px 8px;
  color: var(--blue);
  text-decoration: none;
  font-size: 12px;
}

.url-links a.fallback,
.detail-links a.fallback {
  color: var(--amber);
}

.warning-strip {
  margin-top: 14px;
  padding: 10px 13px;
  border: 1px solid rgba(134, 198, 255, 0.2);
  border-radius: 8px;
  background: var(--blue-2);
  color: #d9ecff;
  font-size: 12px;
}

.empty {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.detail-view {
  border-top: 1px solid var(--line);
  padding-top: 30px;
}

.back-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  min-height: 34px;
  margin-bottom: 22px;
  padding: 0;
  border-color: rgba(255, 255, 255, 0.34);
  border-radius: 999px;
  color: #f7f7f7;
}

.back-button span {
  width: 10px;
  height: 10px;
  border-left: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateX(2px) rotate(45deg);
}

.back-button:hover {
  border-color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
}

.detail-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}

.detail-header h1 {
  font-size: clamp(30px, 3vw, 42px);
}

.detail-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 460px;
}

.detail-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.chart-section {
  margin-top: 24px;
}

.group-section-title {
  margin-top: 24px;
}

.group-table-panel {
  max-height: 320px;
}

.group-table-panel table {
  min-width: 820px;
}

.chart {
  position: relative;
  min-height: 300px;
  margin-top: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(13, 18, 25, 0.62);
  overflow: hidden;
}

.chart svg {
  display: block;
  width: 100%;
  height: auto;
}

.chart .grid {
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 1;
}

.chart .axis-label,
.chart .point-label {
  fill: var(--text);
  font-size: 12px;
}

.chart .tick-label {
  fill: var(--muted);
  font-size: 11px;
}

.chart .range-line {
  stroke: rgba(134, 198, 255, 0.35);
  stroke-width: 10;
  stroke-linecap: round;
}

.chart .best-line {
  fill: none;
  stroke: var(--blue);
  stroke-width: 2.5;
}

.chart .worst-line {
  fill: none;
  stroke: var(--amber);
  stroke-width: 2;
  stroke-dasharray: 6 5;
}

.chart .point {
  fill: var(--blue);
  stroke: var(--bg);
  stroke-width: 2;
  cursor: pointer;
}

.chart .worst-point {
  fill: var(--amber);
}

.chart .hover-target {
  fill: transparent;
  cursor: pointer;
}

.chart-tooltip {
  position: absolute;
  z-index: 4;
  width: 220px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(9, 13, 20, 0.96);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.36);
  color: var(--text);
  font-size: 12px;
  line-height: 1.55;
  pointer-events: none;
}

.chart-tooltip strong {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
}

.chart-tooltip span {
  display: block;
  color: var(--muted);
}

.legend {
  display: flex;
  gap: 12px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.legend i {
  display: inline-block;
  width: 16px;
  height: 3px;
  margin-right: 6px;
  vertical-align: middle;
  background: var(--blue);
}

.legend i.worst {
  background: var(--amber);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
  margin-top: 22px;
}

.info-panel {
  padding: 18px;
}

.info-panel p {
  color: var(--muted);
  line-height: 1.8;
}

dl {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 10px 12px;
  margin: 16px 0 0;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  color: var(--text);
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    display: flex;
    align-items: center;
    gap: 16px;
    height: auto;
    padding: 14px;
  }

  .sidebar nav {
    display: flex;
    gap: 8px;
  }

  .sidebar-note {
    margin: 0 0 0 auto;
    padding: 0;
    border: 0;
  }

  main {
    padding: 36px 20px;
  }

  .query-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .subject-picker {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1121px) and (max-width: 1360px) {
  main {
    padding: 24px 22px;
  }

  .query-grid {
    grid-template-columns: 90px 100px 112px 150px 100px minmax(210px, 1fr) 76px;
  }

  .query-grid > label:last-of-type {
    grid-column: span 2;
  }
}

@media (max-width: 760px) {
  .hero,
  .detail-header,
  .section-bar {
    display: grid;
  }

  .query-grid,
  .result-summary,
  .detail-metrics,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  main {
    padding: 22px 12px;
  }

  .hero {
    gap: 12px;
  }

  h1 {
    font-size: 26px;
  }

  .table-panel {
    max-height: 58vh;
  }

  .actions,
  .detail-links {
    justify-content: flex-start;
  }
}
