:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2230;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #2f81f7;

  --c-created-issue: #4493f8;
  --c-closed-issue: #3fb950;
  --c-created-pr: #e3b341;
  --c-merged-pr: #a371f7;
  --c-closed-pr: #f85149;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 980px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.header h1 {
  margin: 0 0 4px;
  font-size: 26px;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

/* Controls */
.controls {
  display: grid;
  grid-template-columns: 2fr 1fr 2fr auto;
  gap: 14px;
  align-items: end;
  margin: 28px 0 8px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
}

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

.field label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.field label .hint {
  font-weight: 400;
  opacity: 0.75;
}

input, select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  width: 100%;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 129, 247, 0.25);
}

.btn-primary {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 22px;
  border-radius: 8px;
  cursor: pointer;
  height: 41px;
  white-space: nowrap;
  transition: filter 0.15s ease;
}

.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: 0.6; cursor: progress; }

/* Status */
.status {
  min-height: 20px;
  margin: 14px 2px;
  font-size: 14px;
  color: var(--muted);
}

.status.error { color: var(--c-closed-pr); }
.status.loading::after {
  content: "";
  display: inline-block;
  width: 12px; height: 12px;
  margin-left: 8px;
  border: 2px solid var(--muted);
  border-top-color: transparent;
  border-radius: 50%;
  vertical-align: -2px;
  animation: spin 0.7s linear infinite;
}

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

/* Results */
.results {
  margin-top: 8px;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.results-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.chart-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.chart-toggle button {
  background: var(--panel-2);
  border: none;
  color: var(--muted);
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
}

.chart-toggle button.active {
  background: var(--accent);
  color: #fff;
}

/* Totals */
.totals {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.total-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 8px;
  padding: 10px 12px;
  /* button resets */
  font: inherit;
  color: inherit;
  text-align: left;
  width: 100%;
  cursor: pointer;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.total-card:hover { background: #232a3a; }

.total-card:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(47, 129, 247, 0.35);
}

.total-card.off { opacity: 0.45; }
.total-card.off .num { text-decoration: line-through; }

.total-card .num {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
}

.total-card .lbl {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.chart-wrap {
  position: relative;
  height: 420px;
}

@media (max-width: 760px) {
  .controls { grid-template-columns: 1fr 1fr; }
  .field-repo, .field-token { grid-column: 1 / -1; }
  .btn-primary { grid-column: 1 / -1; }
  .totals { grid-template-columns: repeat(2, 1fr); }
  .chart-wrap { height: 340px; }
}
