:root {
  --ink: #0b0f12;
  --muted: #707070;
  --soft: #f7f7f7;
  --panel: #fff;
  --line: #0b0f12;
  --hairline: #e2e2e2;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { min-height: 100%; }

body {
  min-height: 100svh;
  background: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(14px, 2.8vh, 28px) clamp(12px, 4vw, 24px);
  line-height: 1.45;
}

.container {
  width: 100%;
  max-width: 920px;
}

header {
  display: flex;
  justify-content: center;
  margin-bottom: clamp(16px, 2.8vh, 28px);
}

.brand {
  text-align: center;
}

h1 {
  font-size: clamp(25px, 4vw, 34px);
  font-weight: 520;
  line-height: 1.05;
}

#meta {
  min-height: 18px;
  margin-top: 5px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 400;
}

#results {
  display: block;
  animation: fadeInUp 0.22s ease;
}

.metrics-board {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  border: 1px solid var(--line);
  background: var(--panel);
  margin-bottom: clamp(16px, 2.7vh, 26px);
}

.metric {
  grid-column: span 3;
  min-width: 0;
  min-height: clamp(96px, 14vh, 112px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: clamp(20px, 3vh, 30px) clamp(10px, 2.4vw, 22px);
  text-align: center;
  background: #fff;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transition: background 0.15s ease;
}

.metric-secondary {
  grid-column: span 4;
  min-height: clamp(78px, 11vh, 90px);
  padding-top: clamp(16px, 2.4vh, 22px);
  padding-bottom: clamp(16px, 2.4vh, 22px);
}

.metrics-board > .metric:nth-child(4),
.metrics-board > .metric:nth-child(7) {
  border-right: 0;
}

.metrics-board > .metric:nth-child(n+5) {
  border-bottom: 0;
}

.metric-label {
  max-width: 100%;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  line-height: 1.2;
  overflow-wrap: anywhere;
  text-transform: uppercase;
}

.metric-value {
  max-width: 100%;
  margin-bottom: 6px;
  font-size: clamp(34px, 5.6vw, 50px);
  font-weight: 230;
  line-height: 0.95;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.metric-unit {
  min-height: 15px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
}

.metric-secondary .metric-label { font-size: 9px; margin-bottom: 8px; }
.metric-secondary .metric-value { font-size: clamp(26px, 4vw, 34px); margin-bottom: 5px; }
.metric-secondary .metric-unit { font-size: 11px; }

#graph-wrap {
  background: var(--soft);
  padding: clamp(14px, 2.6vh, 22px);
  margin-bottom: clamp(14px, 2.4vh, 22px);
  border: 1px solid var(--hairline);
}

#graph {
  width: 100%;
  height: clamp(96px, 15vh, 136px);
  display: block;
}

.legend {
  display: flex;
  gap: clamp(18px, 4vw, 32px);
  justify-content: center;
  margin-top: 12px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.legend span { display: flex; align-items: center; gap: 8px; }
.legend i { width: 16px; height: 2px; }
.legend-down { background: var(--ink); }
.legend-up { background: #666; }

#progress-bar {
  height: 2px;
  background: #e4e9e8;
  margin-bottom: clamp(18px, 2.6vh, 28px);
  overflow: hidden;
}

#progress-bar div {
  height: 100%;
  width: 0;
  background: var(--ink);
  transition: width 0.2s linear;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-bottom: 14px;
}

button {
  min-height: 44px;
  padding: 0 28px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  text-transform: uppercase;
}

button:hover:not(:disabled) {
  background: var(--ink);
  color: #fff;
}

button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

#go {
  min-height: 48px;
  padding: 0 42px;
  font-size: 13px;
  background: var(--ink);
  color: #fff;
}

#go:hover:not(:disabled) {
  background: #fff;
  color: var(--ink);
}

footer {
  margin-top: clamp(12px, 2.4vh, 22px);
  padding-top: 12px;
  border-top: 1px solid #e4e9e8;
  text-align: center;
}

footer code {
  display: inline-block;
  max-width: 100%;
  overflow-x: auto;
  white-space: nowrap;
  background: #fff;
  padding: 6px 12px;
  border: 1px solid #e4e9e8;
  color: var(--muted);
  font-family: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, monospace;
  font-size: 11px;
  user-select: all;
}

@media (max-width: 720px) {
  body {
    padding: 12px;
  }

  header {
    justify-content: center;
    margin-bottom: 12px;
  }

  .brand {
    text-align: center;
  }

  .metrics-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 12px;
  }

  .metric,
  .metric-secondary {
    grid-column: span 1;
    min-height: 88px;
    padding: 14px 10px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  .metrics-board > .metric:nth-child(n) {
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  .metrics-board > .metric:nth-child(2n) {
    border-right: 0;
  }

  .metrics-board > .metric:nth-child(7) {
    grid-column: 1 / -1;
    border-right: 0;
    border-bottom: 0;
  }

  .metric-label {
    margin-bottom: 7px;
    font-size: 9px;
  }

  .metric-value {
    font-size: clamp(28px, 10vw, 38px);
  }

  .metric-secondary .metric-value {
    font-size: clamp(24px, 8vw, 30px);
  }

  #graph-wrap {
    padding: 12px;
    margin-bottom: 12px;
  }

  #graph {
    height: 102px;
  }

  .legend {
    margin-top: 9px;
    font-size: 10px;
  }

  #progress-bar {
    margin-bottom: 14px;
  }

  button,
  #go {
    min-height: 42px;
    padding: 0 22px;
    font-size: 11px;
  }

  footer {
    margin-top: 14px;
    padding-top: 12px;
  }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.metric-value.animate {
  animation: fadeInUp 0.4s ease;
}
