:root {
  --bg: var(--tg-theme-bg-color, #0f1115);
  --bg-secondary: var(--tg-theme-secondary-bg-color, #171a21);
  --text: var(--tg-theme-text-color, #eef0f4);
  --hint: var(--tg-theme-hint-color, #8a8f99);
  --accent: #2dd4bf;
  --accent-dim: #1c8f83;
  --warn: #ff8a65;
  --border: rgba(255, 255, 255, 0.08);
  --radius: 14px;
  --mono: 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

#app { padding: 12px 14px 28px; max-width: 560px; margin: 0 auto; }

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}

.topbar h1 {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

.topbar .period {
  font-size: 13px;
  color: var(--hint);
  font-family: var(--mono);
}

.account-select {
  width: 100%;
  background: var(--bg-secondary);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-family: var(--sans);
  font-size: 14px;
  margin-bottom: 12px;
  appearance: none;
}

.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.metric-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.metric-card .label {
  font-size: 11px;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.metric-card .value {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

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

.section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.section h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 12px;
}

.chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 84px;
}

.chart .bar {
  flex: 1;
  background: var(--accent-dim);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  position: relative;
  transition: background 0.15s;
}

.chart .bar:last-child { background: var(--accent); }

.wh-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.wh-row:last-child { border-bottom: none; }

.wh-row .qty {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.wh-row .bar-bg {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  margin: 0 10px;
  overflow: hidden;
}

.wh-row .bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}

.state {
  text-align: center;
  padding: 40px 16px;
  color: var(--hint);
  font-size: 14px;
}

.state.error { color: var(--warn); }

.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.8s linear infinite;
}

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