:root {
  --bg: #0b1220;
  --bg-soft: #121b2d;
  --card: #16203499;
  --line: #24334d;
  --fg: #e8eef7;
  --fg-dim: #9db0c9;
  --ok: #3ddc84;
  --warn: #ffc857;
  --bad: #ff6b6b;
  --accent: #4f8cff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

#topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(11, 18, 32, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
}

#topbar .title h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

#topbar .sub {
  color: var(--fg-dim);
  font-size: 12px;
  word-break: break-all;
}

#tabs {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.tab {
  flex: 1 1 auto;
  min-width: 110px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--fg-dim);
  font-size: 14px;
  cursor: pointer;
}

.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

main {
  padding: 14px;
  max-width: 1100px;
  margin: 0 auto;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.card-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  padding: 8px 14px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--fg);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.98);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn.danger {
  background: #3a1f28;
  border-color: #6b3440;
  color: #ffb3b3;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.hint {
  color: var(--fg-dim);
  font-size: 12.5px;
  margin: 8px 0 0;
}

.muted {
  color: var(--fg-dim);
  font-size: 13px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.grid label {
  display: block;
  font-size: 12px;
  color: var(--fg-dim);
}

input[type='number'] {
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #0e1626;
  color: var(--fg);
  font-size: 14px;
}

.dd {
  position: relative;
  margin-top: 4px;
}

.dd-btn {
  width: 100%;
  padding: 8px 28px 8px 10px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #0e1626;
  color: var(--fg);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  position: relative;
  min-height: 36px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  -webkit-tap-highlight-color: rgba(79, 140, 255, 0.3);
  touch-action: manipulation;
}

.dd-btn::after {
  content: '';
  position: absolute;
  right: 10px;
  top: 50%;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid var(--fg-dim);
  transform: translateY(-50%);
}

.dd.open .dd-btn {
  border-color: var(--accent);
}

.dd-list {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  background: #0e1626;
  border: 1px solid var(--accent);
  border-radius: 9px;
  margin-top: 2px;
  max-height: 240px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.dd.open .dd-list {
  display: block;
}

.dd-opt {
  padding: 8px 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--fg);
  border-bottom: 1px solid #1a2740;
  -webkit-tap-highlight-color: rgba(79, 140, 255, 0.3);
  touch-action: manipulation;
}

.dd-opt:last-child {
  border-bottom: none;
}

.dd-opt:active,
.dd-opt:hover {
  background: #162034;
}

.dd-opt.sel {
  background: #1a2d4a;
  color: var(--accent);
  font-weight: 600;
}

.summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.pill {
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
}

.pill.ok {
  border-color: #2c6b4a;
  color: var(--ok);
}

.pill.bad {
  border-color: #6b3040;
  color: var(--bad);
}

.pill.warn {
  border-color: #6b5a2c;
  color: var(--warn);
}

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

th,
td {
  text-align: left;
  padding: 7px 9px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  word-break: break-word;
}

th {
  color: var(--fg-dim);
  font-weight: 500;
  font-size: 12px;
}

td.k {
  color: var(--fg-dim);
  width: 34%;
}

td.sect {
  background: #101a2c;
  color: var(--accent);
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: 0.02em;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.dot.ok {
  background: var(--ok);
}

.dot.bad {
  background: var(--bad);
}

.dot.warn {
  background: var(--warn);
}

.test {
  border-top: 1px solid var(--line);
}

.test:first-child {
  border-top: none;
}

.test-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.test-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.test-id {
  color: var(--fg-dim);
  font-size: 11.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.metrics {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.metric {
  background: #0e1626;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 11px;
  min-width: 104px;
}

.metric .label {
  color: var(--fg-dim);
  font-size: 11px;
}

.metric .value {
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.metric .value.good {
  color: var(--ok);
}

.metric .value.mid {
  color: var(--warn);
}

.metric .value.poor {
  color: var(--bad);
}

.notes {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--fg-dim);
  font-size: 12.5px;
}

.notes li {
  margin-bottom: 3px;
}

.progress {
  position: relative;
  margin-top: 12px;
  height: 26px;
  border-radius: 8px;
  background: #0e1626;
  border: 1px solid var(--line);
  overflow: hidden;
}

.progress .bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, #2f5fd0, #4f8cff);
  transition: width 0.2s linear;
}

.progress span {
  position: relative;
  display: block;
  padding: 4px 10px;
  font-size: 12px;
  color: #dce7f7;
}

.log {
  margin: 10px 0 0;
  max-height: 240px;
  overflow: auto;
  background: #070c16;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.6;
  color: #b8c8de;
  white-space: pre-wrap;
  word-break: break-all;
}

.rank-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin-top: 10px;
  background: #0e1626;
}

.rank-item.top {
  border-color: #2c6b4a;
}

.rank-item.na {
  opacity: 0.62;
}

.rank-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.rank-no {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.rank-name {
  font-weight: 600;
  font-size: 14px;
}

.rank-score {
  margin-left: auto;
  font-size: 12px;
  color: var(--fg-dim);
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

@media (max-width: 700px) {
  .two-col {
    grid-template-columns: 1fr;
  }
}

.list-box {
  background: #0b1220;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.list-box h4 {
  margin: 0 0 6px;
  font-size: 12.5px;
  color: var(--fg-dim);
  font-weight: 500;
}

.list-box ul {
  margin: 0;
  padding-left: 18px;
  font-size: 12.5px;
  color: #cdd9ea;
}

.conclusion {
  margin: 12px 0 0;
  padding: 12px;
  border-radius: 10px;
  background: #0d1a14;
  border: 1px solid #24463a;
  font-size: 13.5px;
}

.conclusion p {
  margin: 0 0 7px;
}

.conclusion p:last-child {
  margin-bottom: 0;
}

#stage {
  display: none;
}

body.running .btn {
  pointer-events: none;
}

body.running #btnCancel {
  pointer-events: auto;
}
