/* GitHub dark (Primer) tokens */
:root {
  --bg: #0d1117;
  --bg-inset: #010409;
  --bg-subtle: #151b23;
  --bg-muted: #212830;
  --border: #3d444d;
  --border-muted: #262c36;
  --fg: #f0f6fc;
  --fg-default: #e6edf3;
  --fg-muted: #9198a1;
  --accent: #4493f8;
  --open: #3fb950;
  --merged: #ab7df8;
  --closed: #f85149;
  --draft: #9198a1;
  --attention-bg: rgba(187, 128, 9, 0.15);
  --attention-border: rgba(187, 128, 9, 0.4);
  --danger-bg: rgba(248, 81, 73, 0.1);
  --danger-border: rgba(248, 81, 73, 0.4);
  --control-bg: #212830;
  --control-hover: #2a313c;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 6px;
  --radius-lg: 12px;
  --page: 1200px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg-default);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
h1, h2 { margin: 0; font-weight: 600; }
.muted { color: var(--fg-muted); }
button, select, input { font: inherit; color: var(--fg-default); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 4px; }

/* State colour: icons and numbers share one token per state */
[data-state="all"], [data-tone="all"] { --tone: var(--accent); }
[data-state="active"], [data-tone="active"], .state-active { --tone: var(--open); }
[data-state="draft"], [data-tone="draft"], .state-draft { --tone: var(--draft); }
[data-state="merged"], [data-tone="merged"], .state-merged { --tone: var(--merged); }
[data-state="closed"], [data-tone="closed"], .state-closed { --tone: var(--closed); }

.icon { display: inline-flex; flex: none; color: var(--tone, currentColor); }
.icon svg { width: 16px; height: 16px; fill: currentColor; }

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(1, 4, 9, 0.85);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border-muted);
}
.header-inner,
.container { max-width: var(--page); margin: 0 auto; padding-left: 32px; padding-right: 32px; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 14px; }
.brand:hover { color: inherit; }
.brand-logo { display: block; height: 22px; width: auto; }
.brand-divider { width: 1px; height: 20px; background: var(--border); }
.brand-title { color: var(--fg-muted); font-size: 14px; font-weight: 500; letter-spacing: 0.01em; }
.header-status { display: flex; align-items: center; gap: 16px; font-size: 12px; }
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--fg-muted); font-weight: 500; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--fg-muted); }
.live[data-state="live"] { color: var(--fg-default); }
.live[data-state="live"] .live-dot { background: var(--open); animation: pulse 2.4s ease-out infinite; }
.live[data-state="reconnecting"] .live-dot { background: #d29922; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(63, 185, 80, 0.55); }
  70%, 100% { box-shadow: 0 0 0 6px rgba(63, 185, 80, 0); }
}

.container { padding-top: 28px; padding-bottom: 56px; }

/* Banner */
.banner {
  margin-bottom: 20px;
  padding: 10px 14px;
  border: 1px solid var(--attention-border);
  border-radius: var(--radius);
  background: var(--attention-bg);
  font-size: 13px;
}
.banner[data-kind="error"] { border-color: var(--danger-border); background: var(--danger-bg); }

/* Filters */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px; }
.filter-group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filter-label { color: var(--fg-muted); font-size: 12px; font-weight: 500; }
.hint { margin: 10px 0 24px; font-size: 12px; min-height: 18px; }

.segmented {
  display: inline-flex;
  padding: 2px;
  background: var(--control-bg);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
}
.segmented button {
  padding: 3px 12px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--fg-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.segmented button:hover { color: var(--fg-default); }
.segmented button[aria-pressed="true"] { background: var(--bg); color: var(--fg); box-shadow: 0 0 0 1px var(--border); }

.chips { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 3px 11px;
  border: 1px solid var(--border-muted);
  border-radius: 2em;
  background: transparent;
  color: var(--fg-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.chip:hover { color: var(--fg-default); border-color: var(--border); }
.chip[aria-pressed="true"] { background: rgba(68, 147, 248, 0.12); border-color: rgba(68, 147, 248, 0.5); color: var(--accent); }

.select, input[type="date"] {
  padding: 4px 8px;
  background: var(--control-bg);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
  font-size: 12px;
  color-scheme: dark;
}
.select:hover, input[type="date"]:hover { border-color: var(--border); }
.custom-range { display: inline-flex; align-items: center; gap: 6px; }
.btn {
  padding: 4px 10px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.btn:hover { background: var(--control-bg); }

/* Stats strip: one panel, five cells */
.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 24px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-lg);
}
.stat { padding: 20px 24px 22px; }
.stat + .stat { border-left: 1px solid var(--border-muted); }
.stat-label { display: flex; align-items: center; gap: 8px; color: var(--fg-muted); font-size: 13px; font-weight: 500; }
.stat-value {
  margin-top: 10px;
  color: var(--tone);
  font-size: 32px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  transition: opacity 0.3s;
}
.stale .stat-value, .stale .repo-table td.num { opacity: 0.55; }

/* Boxes */
.box {
  background: var(--bg);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  overflow: hidden;
}
.box-header { padding: 14px 20px; border-bottom: 1px solid var(--border-muted); }
.box-header h2 { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--fg); }
.section-icon { color: var(--tone, var(--fg-muted)); }
.counter {
  min-width: 20px;
  padding: 0 7px;
  border-radius: 2em;
  background: var(--bg-muted);
  color: var(--fg-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 20px;
  text-align: center;
}
.counter:empty { display: none; }

.columns { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 24px; }
.columns .box { margin-bottom: 0; }

/* Repo table */
.table-wrap { overflow-x: auto; }
.repo-table { width: 100%; border-collapse: collapse; }
.repo-table th, .repo-table td { padding: 12px 20px; text-align: left; white-space: nowrap; }
.repo-table th {
  color: var(--fg-muted);
  font-size: 12px;
  font-weight: 500;
  border-bottom: 1px solid var(--border-muted);
}
.repo-table th .icon { vertical-align: -3px; margin-right: 6px; }
.repo-table td { border-bottom: 1px solid var(--border-muted); }
.repo-table tbody tr:last-child td { border-bottom: 0; }
.repo-table tbody tr { transition: background 0.15s; }
.repo-table tbody tr:hover { background: var(--bg-subtle); }
.repo-table .num { text-align: right; width: 14%; }
.repo-table td.num { color: var(--tone); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.repo-name { display: inline-flex; align-items: baseline; gap: 10px; }
.repo-label { color: var(--fg); font-weight: 600; }
.repo-slug { color: var(--fg-muted); font-size: 12px; }
.repo-name:hover .repo-label { color: var(--accent); }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; max-height: 640px; overflow-y: auto; }
.list li { display: flex; gap: 10px; padding: 12px 20px; border-bottom: 1px solid var(--border-muted); }
.list li:last-child { border-bottom: 0; }
.list li:hover { background: var(--bg-subtle); }
.list .empty { justify-content: center; padding: 36px 20px; color: var(--fg-muted); }
.list .icon { padding-top: 2px; }
.item-body { min-width: 0; flex: 1; }
.item-title { color: var(--fg); font-weight: 600; overflow-wrap: anywhere; }
.item-title a:hover { color: var(--accent); }
.item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 4px; color: var(--fg-muted); font-size: 12px; }
.avatar { width: 16px; height: 16px; border-radius: 50%; background: var(--bg-muted); }
.person { display: inline-flex; align-items: center; gap: 5px; }
.person b { color: var(--fg-default); font-weight: 500; }
.branch {
  padding: 1px 6px;
  border-radius: var(--radius);
  background: rgba(68, 147, 248, 0.1);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  overflow-wrap: anywhere;
}
.label {
  display: inline-block;
  padding: 0 7px;
  border: 1px solid var(--border);
  border-radius: 2em;
  color: var(--fg-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
  white-space: nowrap;
}
.repo-tag { color: var(--fg-muted); font-weight: 500; }
.feed .item-title { font-weight: 400; }
.feed .verb { color: var(--fg-muted); }

@media (max-width: 960px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat[data-state="all"] { grid-column: 1 / -1; }
  .stat + .stat { border-left: 0; }
  .stat { border-top: 1px solid var(--border-muted); }
  .stat[data-state="all"] { border-top: 0; }
  .stat:nth-child(odd):not([data-state="all"]) { border-left: 1px solid var(--border-muted); }
  .columns { grid-template-columns: 1fr; }
  .header-inner, .container { padding-left: 16px; padding-right: 16px; }
  #updated { display: none; }
  .repo-slug { display: none; }
  .repo-table th, .repo-table td { padding-left: 14px; padding-right: 14px; }
}

/* Loading states ------------------------------------------------------------ */

/* Thin indeterminate bar under the header: any load, foreground or background. */
.progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; overflow: hidden; opacity: 0; transition: opacity 0.2s; }
[data-busy] .progress { opacity: 1; }
.progress::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 30%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: indeterminate 1.1s ease-in-out infinite;
}
@keyframes indeterminate { from { left: -30%; } to { left: 100%; } }

/* Filters are locked while a filter change loads. */
.filters[aria-busy="true"] { cursor: progress; }
.filters button:disabled, .filters select:disabled, .filters input:disabled { cursor: progress; }
.filters[aria-busy="true"] .segmented button:not([aria-pressed="true"]),
.filters[aria-busy="true"] .chip,
.filters[aria-busy="true"] .select,
.filters[aria-busy="true"] input { opacity: 0.55; }

/* Skeletons */
.sk, [data-loading] .stat-value, [data-loading] .repo-table td.num::after {
  background: linear-gradient(90deg, var(--bg-muted) 25%, #2d3540 37%, var(--bg-muted) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 4px;
}
@keyframes shimmer { from { background-position: 100% 50%; } to { background-position: 0 50%; } }

[data-loading] .stat-value { color: transparent; width: 88px; max-width: 70%; }

.repo-table td.num { position: relative; }
[data-loading] .repo-table td.num { color: transparent; }
[data-loading] .repo-table td.num::after {
  content: "";
  position: absolute;
  right: 20px;
  top: 50%;
  width: 28px;
  height: 12px;
  margin-top: -6px;
}

[data-loading] #open-list, [data-loading] #feed { opacity: 0.4; pointer-events: none; transition: opacity 0.2s; }

.skeleton-row { align-items: flex-start; }
.skeleton-row:hover { background: transparent !important; }
.sk { display: block; }
.sk-icon { width: 16px; height: 16px; border-radius: 50%; flex: none; }
.sk-body { flex: 1; display: flex; flex-direction: column; gap: 8px; padding-top: 2px; }
.sk-line { height: 10px; width: 70%; }
.sk-line.short { width: 40%; }

.spinner {
  display: none;
  width: 12px;
  height: 12px;
  margin-left: 2px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
[data-loading] .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .progress::before, .sk, [data-loading] .stat-value, [data-loading] .repo-table td.num::after, .spinner { animation-duration: 3s; }
}
