:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #637083;
  --line: #d9dee7;
  --field: #ffffff;
  --field-border: #b8c1cf;
  --blue: #2563eb;
  --teal: #0f766e;
  --green: #15803d;
  --amber: #b45309;
  --red: #b91c1c;
  --shadow: 0 10px 28px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.token-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 18px;
  background: var(--bg);
}

.token-screen.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.token-panel {
  width: min(460px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.token-panel h1 {
  margin-bottom: 10px;
  font-size: 32px;
}

.token-copy,
.token-hint {
  color: var(--muted);
  line-height: 1.45;
}

.token-copy {
  margin: 0 0 20px;
}

.token-hint {
  margin: 14px 0 0;
  font-size: 12px;
}

.token-actions {
  margin-top: 14px;
}

.page-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1.1;
}

h2 {
  font-size: 16px;
  line-height: 1.2;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 148px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.status-pill.ok {
  border-color: #a7f3d0;
  background: #ecfdf5;
  color: var(--green);
}

.status-pill.error {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--red);
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(6, minmax(118px, 1fr));
  gap: 12px;
  align-items: end;
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.summary-card {
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.summary-card p {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.summary-card strong {
  display: block;
  color: var(--ink);
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1;
  letter-spacing: 0;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
button {
  width: 100%;
  min-height: 42px;
  border-radius: 6px;
  font: inherit;
}

input,
select {
  border: 1px solid var(--field-border);
  background: var(--field);
  color: var(--ink);
  padding: 0 11px;
}

button {
  border: 1px solid var(--blue);
  background: var(--blue);
  color: #ffffff;
  cursor: pointer;
  font-weight: 750;
}

button.secondary {
  width: auto;
  min-height: 34px;
  padding: 0 12px;
  border-color: var(--line);
  background: #ffffff;
  color: var(--ink);
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.header-download {
  min-width: 132px;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -3px;
  animation: spin 0.8s linear infinite;
}

button .spinner {
  margin-right: 8px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

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

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.chart-wrap {
  position: relative;
}

.chart-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.plotly-chart {
  display: block;
  width: 100%;
  height: 380px;
}

.plotly-chart.rate-chart {
  height: 240px;
}

.plotly-chart.event-chart {
  height: 340px;
}

.plotly-chart .modebar {
  display: none;
}

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

@media (max-width: 980px) {
  .page-shell {
    width: min(100% - 20px, 1440px);
    padding-top: 14px;
  }

  .page-header {
    align-items: flex-start;
    flex-direction: column;
  }

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

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

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

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .toolbar {
    grid-template-columns: 1fr;
  }

  .summary-cards {
    grid-template-columns: 1fr;
  }
}
