* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: "Berkeley Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.shell {
  width: min(1540px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 14px;
}

h1 {
  margin: 0;
  font-size: clamp(22px, 3vw, 42px);
  font-weight: 700;
  letter-spacing: 0;
  text-transform: lowercase;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  min-width: 0;
  border: 1px solid var(--rule);
  background: var(--panel-strong);
  padding: 12px;
}

.metric-label {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.metric-value {
  display: block;
  margin-top: 8px;
  overflow: hidden;
  color: var(--ink);
  font-size: clamp(15px, 2vw, 24px);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.chart-panel {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--rule);
  background: var(--panel);
}

.chart-panel.wide {
  grid-column: 1 / -1;
}

.chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  border-bottom: 1px solid var(--rule);
  padding: 12px 14px 10px;
}

.chart-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  white-space: nowrap;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 12px;
  min-width: 0;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.3;
  white-space: nowrap;
}

.chart-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--swatch);
}

.chart-panel canvas {
  display: block;
  flex: 0 0 auto;
  width: 100%;
  height: 282px;
  cursor: crosshair;
}

.chart-panel.wide canvas {
  height: 372px;
}

@media (max-width: 980px) {
  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .status-strip {
    justify-content: flex-start;
  }

  .metric-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }

  .chart-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .chart-legend {
    justify-content: flex-start;
  }

  .chart-panel canvas {
    height: 260px;
  }

  .chart-panel.wide canvas {
    height: 340px;
  }
}

@media (max-width: 560px) {
  .metric-strip {
    grid-template-columns: 1fr;
  }
}
