* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #0d1117;
  color: #c9d1d9;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.5;
  padding: 20px;
}

a {
  color: #58a6ff;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 16px;
  border-bottom: 1px solid #30363d;
  margin-bottom: 20px;
}

header h1 {
  font-size: 1.4rem;
  font-weight: 600;
  color: #f0f6fc;
}

.subtitle { color: #8b949e; font-size: 0.85rem; }

.header-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.82rem;
  color: #8b949e;
}

#status-msg { color: #58a6ff; }

#countdown {
  font-family: 'SF Mono', SFMono-Regular, Consolas, monospace;
  min-width: 30px;
  text-align: right;
}

#refresh-btn {
  background: #21262d;
  color: #c9d1d9;
  border: 1px solid #30363d;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  transition: all 0.15s;
}
#refresh-btn:hover { background: #30363d; }
#refresh-btn:disabled { opacity: 0.5; cursor: not-allowed; }

main {
  max-width: 1400px;
  margin: 0 auto;
}

.loading, .error, .empty {
  text-align: center;
  padding: 60px 20px;
  color: #8b949e;
  font-size: 0.85rem;
}
.error { color: #f85149; }

/* --- Category sections --- */

.category-section {
  margin-bottom: 24px;
}

.category-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 4px 8px;
}

.category-repos {
  border: 1px solid #30363d;
  border-radius: 10px;
  overflow: hidden;
}

/* --- Collapsible repo rows --- */

.repo-row {
  border-bottom: 1px solid #21262d;
}
.repo-row:last-child {
  border-bottom: none;
}

.repo-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s;
}
.repo-summary:hover {
  background: #161b22;
}

.repo-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.repo-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: #f0f6fc;
  white-space: nowrap;
}

.run-dots {
  display: flex;
  gap: 3px;
  align-items: center;
  margin-left: 4px;
}

.run-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-green { background: #3fb950; }
.dot-red { background: #f85149; }
.dot-yellow { background: #d29922; }
.dot-grey { background: #484f58; }
.dot-empty { background: #21262d; }

.repo-meta {
  margin-left: auto;
  font-size: 0.75rem;
  color: #8b949e;
  white-space: nowrap;
  flex-shrink: 0;
}

.expand-arrow {
  font-size: 0.7rem;
  color: #484f58;
  transition: transform 0.15s;
  flex-shrink: 0;
}
.repo-summary.expanded .expand-arrow {
  transform: rotate(90deg);
}

/* --- Expanded workflow detail --- */

.repo-detail {
  background: #161b22;
  border-top: 1px solid #21262d;
}

.workflow-row {
  padding: 8px 16px 8px 36px;
  border-bottom: 1px solid #1c2128;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px 16px;
  align-items: center;
}
.workflow-row:last-child { border-bottom: none; }
.workflow-row:hover { background: #1c2128; }

.workflow-main {
  display: flex;
  align-items: center;
  gap: 8px;
  grid-column: 1;
  min-width: 0;
}

.workflow-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  grid-column: 2;
  grid-row: 1 / 3;
  font-size: 0.75rem;
  color: #8b949e;
  white-space: nowrap;
}

.workflow-details {
  display: flex;
  align-items: center;
  gap: 10px;
  grid-column: 1;
  font-size: 0.75rem;
  color: #8b949e;
  min-width: 0;
}

.workflow-name {
  font-weight: 500;
  color: #c9d1d9;
  white-space: nowrap;
  font-size: 0.82rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 12px;
  flex-shrink: 0;
  font-weight: 700;
}
.status-badge.success { background: #23863626; color: #3fb950; }
.status-badge.failure { background: #f8514926; color: #f85149; }
.status-badge.in-progress { background: #388bfd26; color: #58a6ff; animation: pulse 1.5s ease-in-out infinite; }
.status-badge.cancelled, .status-badge.skipped { background: #21262d; color: #8b949e; }
.status-badge.unknown { background: #21262d; color: #8b949e; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.badge {
  font-size: 0.68rem;
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 500;
}
.badge.scheduled { background: #d2992226; color: #d29922; border: 1px solid #d2992250; }
.badge.event-push { background: #23863626; color: #3fb950; border: 1px solid #23863650; }
.badge.event-pull_request { background: #388bfd26; color: #58a6ff; border: 1px solid #388bfd50; }
.badge.event-schedule { background: #d2992226; color: #d29922; border: 1px solid #d2992250; }
.badge.event-workflow_dispatch { background: #a371f726; color: #a371f7; border: 1px solid #a371f750; }

.branch {
  color: #8b949e;
  font-family: 'SF Mono', SFMono-Regular, Consolas, monospace;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.commit-msg {
  color: #8b949e;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.time-ago { color: #8b949e; flex-shrink: 0; }

.duration, .avg-duration {
  color: #8b949e;
  flex-shrink: 0;
  font-family: 'SF Mono', SFMono-Regular, Consolas, monospace;
}
.avg-duration { font-style: italic; }

.failure-streak {
  color: #f85149;
  font-weight: 600;
  font-size: 0.68rem;
  background: #f8514926;
  padding: 1px 7px;
  border-radius: 10px;
  border: 1px solid #f8514950;
  white-space: nowrap;
}

.empty-workflow { display: flex; align-items: center; gap: 8px; }
.no-runs { color: #8b949e; font-size: 0.75rem; font-style: italic; }

/* --- PRs --- */

#prs-section {
  max-width: 1400px;
  margin: 0 auto;
  display: none;
  margin-top: 8px;
}

#prs-section h2 {
  font-size: 0.78rem;
  font-weight: 600;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  padding-top: 16px;
  border-top: 1px solid #30363d;
}

.pr-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  background: #0d1117;
  border-radius: 8px;
  margin-bottom: 4px;
  border: 1px solid #30363d;
  font-size: 0.75rem;
}
.pr-row:hover { background: #161b22; }

.pr-repo { color: #8b949e; font-weight: 500; flex-shrink: 0; min-width: 120px; }
.pr-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.pr-author { color: #8b949e; flex-shrink: 0; }

@media (max-width: 768px) {
  header { flex-direction: column; gap: 8px; }
  .workflow-row { grid-template-columns: 1fr; }
  .workflow-meta { grid-column: 1; grid-row: auto; flex-wrap: wrap; }
  .repo-summary { flex-wrap: wrap; }
  .repo-meta { margin-left: 0; width: 100%; }
}
