:root {
  --bg: #0d1117;
  --card-bg: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --text-faint: #484f58;
  --accent: #f78166;
  --success: #3fb950;
  --nav-accent: #2f81f7;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

header { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 1rem; }
header label { font-size: 0.85rem; color: var(--text-muted); }
.hidden { display: none; }

header input#month {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 0.7rem;
}
header input#month:hover { border-color: var(--text-faint); }
header input#month:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(247, 129, 102, 0.25);
}
header input#month::-webkit-calendar-picker-indicator {
  filter: invert(0.8);
  cursor: pointer;
}

header button#refresh {
  background: var(--accent);
  color: #0d1117;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
header button#refresh:hover { background: #ff9376; border-color: #ff9376; }
header button#refresh:active { background: #e56c52; border-color: #e56c52; }

.spinner {
  width: 2rem; height: 2rem; border: 3px solid var(--border); border-top-color: var(--text);
  border-radius: 50%; animation: spin 0.8s linear infinite;
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
}
.spinner.hidden { display: none; }
@keyframes spin {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

.warning { background: #3d1f1f; color: #ffb4a9; padding: 0.5rem 1rem; margin-bottom: 1rem; border-radius: 6px; }
.hint { color: var(--text-muted); margin-bottom: 1rem; }
.back-link { display: inline-block; color: var(--text-muted); text-decoration: none; font-size: 0.8rem; margin-bottom: 1rem; }
.back-link:hover { color: var(--text); }

details { margin-bottom: 0.5rem; }
summary { cursor: pointer; font-weight: bold; padding: 0.5rem; user-select: none; color: var(--text); }
summary:hover { background-color: var(--card-bg); }
table { border-collapse: collapse; width: 100%; }
td, th { text-align: left; padding: 0.25rem 0.5rem; border-bottom: 1px solid var(--border); color: var(--text); }
details table td:first-child { padding-left: 2rem; }

.chart-container { margin-bottom: 0; }
.chart-svg { display: block; }
.chart-gridline { stroke: var(--border); stroke-width: 1; }
.chart-axis-label { font-size: 0.7rem; fill: var(--text-muted); }
.chart-line { fill: none; stroke-width: 2; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 0.5rem; }
.chart-legend-item { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; color: var(--text); }
.chart-legend-swatch { width: 0.75rem; height: 0.75rem; border-radius: 2px; display: inline-block; vertical-align: middle; }

.chart-metric-toggle { display: flex; gap: 0.25rem; }
.chart-metric-toggle button {
  font-size: 0.75rem; padding: 0.2rem 0.6rem; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text-muted); cursor: pointer;
}
.chart-metric-toggle button.active { background: var(--text); color: var(--bg); border-color: var(--text); }

body { display: flex; flex-direction: column; min-height: 100vh; }

.app-body { display: flex; flex: 1; min-height: 0; }

.topbar {
  height: 48px;
  flex-shrink: 0;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.topbar-logo { flex-shrink: 0; }
.topbar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0.75rem;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-item {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  border-left: 3px solid transparent;
}
.sidebar-item:hover { background: var(--card-bg); color: var(--text); }
.sidebar-item.active {
  background: var(--card-bg);
  color: var(--text);
  border-left-color: var(--nav-accent);
  font-weight: 600;
}

.main-content { flex: 1; padding: 2rem; min-width: 0; }

.overview-row { display: flex; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.overview-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 6px; padding: 0.9rem 1rem; flex: 1 1 220px; }
.card h4, .overview-card h4 { margin: 0 0 0.4rem; font-size: 0.75rem; color: var(--text-muted); font-weight: 600; }
.overview-big { font-size: 1.4rem; font-weight: 600; color: var(--text); }
.overview-sub { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.25rem; }
.overview-progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-top: 0.5rem; }
.overview-progress-fill { height: 100%; background: var(--success); }

.section-title { font-size: 1rem; font-weight: 600; margin: 1.5rem 0 0.75rem; color: var(--text); }
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 6px; padding: 1rem 1.25rem; margin-bottom: 1rem; }

.tabs { display: flex; gap: 1.1rem; border-bottom: 1px solid var(--border); margin-bottom: 0.9rem; }
.tab { background: none; border: none; font-size: 0.8rem; padding: 0.4rem 0; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.usage-headline { font-size: 1.25rem; font-weight: 600; color: var(--text); margin-bottom: 0.4rem; }

.repo-bar { height: 10px; border-radius: 4px; overflow: hidden; display: flex; margin-bottom: 0.75rem; background: var(--border); }
.repo-bar-segment { height: 100%; }
.repo-list-item { display: flex; justify-content: space-between; font-size: 0.8rem; padding: 0.4rem 0; border-bottom: 1px solid var(--border); color: var(--text); }
.repo-list-item:last-child { border-bottom: none; }
.repo-list-right { display: flex; align-items: center; gap: 0.75rem; }
.repo-list-details-link { color: var(--nav-accent); text-decoration: none; font-size: 0.8rem; }
.repo-list-details-link:hover { text-decoration: underline; }

.runner-badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  margin: 0.1rem 0.3rem 0.1rem 0;
}

.settings-list { display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1rem; margin: 0 0 1rem; }
.settings-list dt { color: var(--text-muted); font-size: 0.8rem; }
.settings-list dd { margin: 0; color: var(--text); font-size: 0.85rem; }
h1 { font-size: 1.3rem; margin: 0 0 1rem; color: var(--text); }

.runner-group { margin-bottom: 0.75rem; }
.runner-group:last-child { margin-bottom: 0; }
.runner-group-header { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--text); padding: 0.3rem 0; font-weight: 600; }
.runner-sub-list { margin-left: 1rem; }
.runner-sub-item { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--text-muted); padding: 0.2rem 0; border-bottom: 1px solid var(--border); }
.runner-sub-item:last-child { border-bottom: none; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.topbar-logout { margin-right: 12px; font-size: 13px; color: inherit; opacity: 0.8; text-decoration: none; }
.topbar-logout:hover { opacity: 1; text-decoration: underline; }
