:root {
  color-scheme: dark;
  --bg: #101216;
  --panel: #191d24;
  --panel-2: #222832;
  --text: #eef3f6;
  --muted: #93a3ad;
  --line: #313946;
  --accent: #f2a900;
  --good: #5ad17a;
  --bad: #ff6f61;
  --accent-soft: rgba(242, 169, 0, 0.14);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(242, 169, 0, 0.18), transparent 30rem),
    linear-gradient(180deg, #151820 0%, var(--bg) 44rem);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
canvas {
  font: inherit;
}

a {
  color: inherit;
}

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.topbar,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.topbar {
  margin-bottom: 22px;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.05;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 3.9vw, 3.8rem);
  white-space: nowrap;
}

h2 {
  font-size: 1.45rem;
}

.panel-subtitle {
  margin: 8px 0 0;
  font-size: 0.94rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(25, 29, 36, 0.86);
  color: var(--muted);
  white-space: nowrap;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(242, 169, 0, 0.14);
}

.status-pill.is-live .status-dot {
  background: var(--good);
  box-shadow: 0 0 0 4px rgba(90, 209, 122, 0.14);
}

.status-pill.is-error .status-dot {
  background: var(--bad);
  box-shadow: 0 0 0 4px rgba(255, 111, 97, 0.14);
}

.summary-grid,
.fees-strip {
  display: grid;
  gap: 12px;
}

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

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

.metric,
.fees-strip > div,
.chart-panel {
  border: 1px solid var(--line);
  background: rgba(25, 29, 36, 0.88);
  backdrop-filter: blur(16px);
}

.metric {
  min-height: 118px;
  padding: 16px;
  border-radius: 8px;
}

.metric-label,
.metric small,
.fees-strip span,
#updatedAt,
.panel-subtitle {
  color: var(--muted);
}

.metric-label,
.fees-strip span {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(1.35rem, 2.25vw, 2rem);
  line-height: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

#memoryUsage {
  font-size: clamp(1.08rem, 1.6vw, 1.42rem);
  line-height: 1.08;
  white-space: normal;
}

#secondaryMetric {
  font-size: clamp(1.08rem, 1.6vw, 1.42rem);
  line-height: 1.08;
  letter-spacing: 0;
}

.metric small {
  display: block;
  margin-top: 7px;
  font-size: 0.84rem;
}

.metric-progress {
  margin-top: 9px;
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.metric-progress__fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #3cb371, #77e2a3);
  transition: width 260ms ease, background-color 220ms ease;
}

.metric-progress__fill.is-medium {
  background: linear-gradient(90deg, #f2a900, #ffd56f);
}

.metric-progress__fill.is-high {
  background: linear-gradient(90deg, #ef4444, #f87171);
}

.chart-panel {
  margin: 12px 0;
  padding: 18px;
  border-radius: 8px;
}

.refresh-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.legend-toggle {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
}

.legend-toggle:hover,
.legend-toggle:focus-visible {
  border-color: rgba(242, 169, 0, 0.62);
  color: var(--text);
}

#refreshButton {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-2);
  cursor: pointer;
}

#refreshButton:hover {
  border-color: rgba(242, 169, 0, 0.62);
}

#refreshButton svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

#historyRefreshButton {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-2);
  cursor: pointer;
}

#historyRefreshButton:hover {
  border-color: rgba(242, 169, 0, 0.62);
}

#historyRefreshButton svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.chart-wrap {
  position: relative;
  margin-top: 18px;
  min-height: 420px;
}

canvas {
  display: block;
  width: 100%;
  height: 420px;
  border: 1px solid #2b333f;
  border-radius: 8px;
  background: #12161c;
}

.chart-tooltip {
  position: absolute;
  z-index: 3;
  display: none;
  min-width: 190px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 16, 21, 0.95);
  color: var(--text);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.34);
  pointer-events: none;
}

.chart-tooltip strong {
  display: block;
  margin-bottom: 4px;
}

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

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 14px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.84rem;
}

.legend-item:hover,
.legend-item:focus-visible,
.legend-item.is-active {
  color: var(--text);
}

.legend-item.is-muted {
  opacity: 0.36;
}

.legend-swatch {
  width: 11px;
  height: 11px;
  border-radius: 3px;
}

.block-table-wrap {
  margin-top: 18px;
  overflow-x: auto;
}

.block-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
}

.block-table caption {
  padding-bottom: 8px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
  text-align: left;
}

.block-table th,
.block-table td {
  border-top: 1px solid rgba(238, 243, 246, 0.1);
  padding: 10px 8px;
  text-align: right;
}

.block-table th:first-child,
.block-table td:first-child {
  text-align: left;
}

.block-table th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.block-table td {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.block-table td::before {
  display: none;
}

.fees-strip > div {
  min-height: 86px;
  padding: 16px;
  border-radius: 8px;
}

.fees-strip strong {
  display: block;
  margin-top: 8px;
  font-size: 1.7rem;
}

.throughput-panel {
  margin-top: 12px;
}

#throughputUpdatedAt {
  color: var(--muted);
  font-size: 0.84rem;
}

#historyUpdatedAt {
  color: var(--muted);
  font-size: 0.84rem;
}

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

.history-windows button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  padding: 6px 11px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.history-windows button.is-active,
.history-windows button:hover,
.history-windows button:focus-visible {
  border-color: rgba(242, 169, 0, 0.62);
  color: var(--text);
}

.throughput-wrap {
  margin-top: 12px;
}

.history-wrap {
  position: relative;
}

.history-controls {
  margin-top: 10px;
  align-items: center;
  gap: 10px;
}

.throughput-head {
  margin-top: 18px;
}

.history-actions {
  margin-left: auto;
}

#throughputChart {
  height: 220px;
  min-height: 220px;
}

#historyChart {
  height: 300px;
  min-height: 300px;
}

@media (max-width: 1080px) {
  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.chart-panel {
  min-width: 0;
}

.panel-head--single-row {
  align-items: center;
}

.button {
  appearance: none;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  transform: translateY(-1px);
}

.button--primary {
  background: var(--accent);
  color: #151515;
}

.button--secondary,
.button--ghost {
  border-color: var(--line);
  background: #252a33;
  color: var(--text);
}

.button--ghost {
  background: transparent;
}

.button__icon {
  position: relative;
  flex: 0 0 auto;
}

.button__icon--file {
  width: 14px;
  height: 16px;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.button__icon--file::after {
  content: "";
  position: absolute;
  top: -2px;
  right: -2px;
  width: 6px;
  height: 6px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  background: currentColor;
}

.button__icon--magnet {
  width: 14px;
  height: 16px;
  border: 3px solid currentColor;
  border-top: 0;
  border-radius: 0 0 8px 8px;
}

.button__icon--magnet::before,
.button__icon--magnet::after {
  content: "";
  position: absolute;
  top: 0;
  width: 3px;
  height: 4px;
  background: currentColor;
}

.button__icon--magnet::before {
  left: -3px;
}

.button__icon--magnet::after {
  right: -3px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100vw - 20px, 1180px);
    padding-top: 18px;
  }

  .topbar,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    white-space: normal;
  }

  .panel-head--single-row {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .topbar__right {
    width: 100%;
  }

  .topbar__right {
    justify-content: flex-start;
  }

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

  .chart-panel {
    padding: 12px;
  }

  .refresh-group {
    width: 100%;
    justify-content: flex-start;
    gap: 8px;
  }

  .legend-toggle {
    flex: 1 1 220px;
    min-width: 0;
  }

  #updatedAt {
    flex-basis: 100%;
  }

  .chart-wrap,
  canvas {
    height: 340px;
    min-height: 340px;
  }

  #throughputChart {
    height: 200px;
    min-height: 200px;
  }

  #historyChart {
    height: 240px;
    min-height: 240px;
  }

  .block-table-wrap {
    overflow-x: visible;
  }

  .block-table {
    min-width: 0;
  }

  .block-table thead {
    display: none;
  }

  .block-table,
  .block-table tbody,
  .block-table tr,
  .block-table td {
    display: block;
  }

  .block-table tr {
    border-top: 1px solid rgba(238, 243, 246, 0.12);
    padding: 10px 0;
  }

  .block-table td {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    border-top: 0;
    padding: 5px 0;
    text-align: right;
  }

  .block-table td::before {
    display: inline;
    color: var(--muted);
    content: attr(data-label);
    font-size: 0.78rem;
    font-weight: 700;
    text-align: left;
    text-transform: uppercase;
  }

}

@media (max-width: 480px) {
  .summary-grid,
  .fees-strip {
    grid-template-columns: 1fr;
  }

  #memoryUsage {
    font-size: clamp(1.2rem, 7vw, 1.7rem);
  }

  .status-pill,
  .button {
    width: 100%;
    justify-content: center;
  }

  .legend-toggle {
    width: 100%;
    flex-basis: 100%;
  }

  #updatedAt {
    width: 100%;
  }

}
