:root {
  --bg: #070708;
  --bg-elev: #0e0e11;
  --bg-elev-2: #121216;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #f4f4f5;
  --muted: rgba(244, 244, 245, 0.62);
  --faint: rgba(244, 244, 245, 0.4);
  --green: #6ee7b7;
  --green-2: #34d399;
  --green-dim: rgba(110, 231, 183, 0.12);
  --blue: #93c5fd;
  --amber: #fcd34d;
  --red: #f87171;
  --radius: 14px;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  --sidebar-w: 232px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; transition: color 0.15s ease; }
button { font: inherit; cursor: pointer; }
::selection { background: rgba(110, 231, 183, 0.25); color: #fff; }

/* ---------- App shell ---------- */
.app {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--bg-elev);
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: 1.02rem;
  border-bottom: 1px solid var(--line);
}
.brand-mark {
  width: 28px;
  height: 28px;
  display: inline-flex;
  flex-shrink: 0;
}
.brand-mark svg {
  width: 100%;
  height: 100%;
  border-radius: 8px;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 10px;
  flex: 1;
}
.side-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}
.side-link svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}
.side-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}
.side-link.active {
  color: var(--green);
  background: var(--green-dim);
}

.side-foot {
  padding: 12px 10px 16px;
  border-top: 1px solid var(--line);
}
.org-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
}
.org-avatar {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #1f2937, #111827);
  color: var(--green);
  font-weight: 700;
  font-size: 0.72rem;
  border: 1px solid var(--line-strong);
}
.org-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.org-meta strong {
  font-size: 0.82rem;
  font-weight: 600;
}
.org-meta span {
  font-size: 0.7rem;
  color: var(--faint);
}

/* ---------- Main column ---------- */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(7, 7, 8, 0.85);
  backdrop-filter: blur(14px);
}
.topbar-title h1 {
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.topbar-sub {
  font-size: 0.8rem;
  color: var(--faint);
}
.topbar-actions {
  display: flex;
  gap: 10px;
}

.content {
  padding: 24px 28px 48px;
  max-width: 1120px;
  width: 100%;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 10px;
  padding: 9px 16px;
  font-weight: 600;
  font-size: 0.88rem;
  transition: transform 0.15s ease, filter 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  border: 1px solid transparent;
}
.btn-ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--muted);
}
.btn-ghost:hover {
  color: var(--text);
  border-color: var(--line-strong);
}
.btn-primary {
  background: linear-gradient(180deg, #7aedc0, var(--green-2));
  color: #04140e;
  box-shadow: 0 8px 24px rgba(52, 211, 153, 0.18);
}
.btn-primary:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}
.btn-primary svg {
  width: 15px;
  height: 15px;
}

@media (max-width: 860px) {
  .sidebar { display: none; }
  .topbar { padding: 14px 16px; }
  .content { padding: 18px 16px 40px; }
}

/* ---------- Stat cards ---------- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.stat-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.stat-card:hover {
  border-color: rgba(110, 231, 183, 0.25);
  transform: translateY(-2px);
}
.stat-value {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--green);
  line-height: 1;
  margin-bottom: 8px;
}
.stat-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}
.stat-hint {
  font-size: 0.78rem;
  color: var(--faint);
  font-family: var(--mono);
}

@media (max-width: 900px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Panel ---------- */
.panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 {
  font-size: 1.02rem;
  letter-spacing: -0.02em;
}
.panel-sub {
  font-size: 0.8rem;
  color: var(--faint);
  margin-top: 2px;
}
.link-btn {
  font-size: 0.85rem;
  color: var(--green);
  font-weight: 600;
}
.link-btn:hover { color: var(--text); }

.stats-row + .panel { margin-top: 20px; }

/* ---------- Data table ---------- */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 640px;
}
.data-table th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--faint);
  font-weight: 600;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}
.data-table td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background 0.15s ease; }
.data-table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }

.change-name {
  color: var(--text);
  font-weight: 500;
}
.mono-cell {
  font-family: var(--mono);
  font-size: 0.82rem;
}
.muted-cell {
  color: var(--faint);
  font-size: 0.82rem;
}

/* ---------- Provider chip ---------- */
.provider-chip {
  display: inline-flex;
  align-items: center;
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--muted);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  padding: 4px 10px;
  border-radius: 999px;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-open {
  color: var(--green);
  background: rgba(110, 231, 183, 0.12);
  border-color: rgba(110, 231, 183, 0.28);
}
.badge-progress {
  color: var(--amber);
  background: rgba(252, 211, 77, 0.08);
  border-color: rgba(252, 211, 77, 0.25);
}
.badge-merged {
  color: var(--blue);
  background: rgba(147, 197, 253, 0.1);
  border-color: rgba(147, 197, 253, 0.25);
}

/* ---------- Dashboard two-column ---------- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-top: 20px;
  align-items: start;
}

/* ---------- Activity feed ---------- */
.feed-list {
  list-style: none;
  padding: 6px 0;
}
.feed-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}
.feed-item:last-child { border-bottom: 0; }
.feed-icon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 7px;
  flex-shrink: 0;
}
.feed-pr { background: var(--green); box-shadow: 0 0 0 3px var(--green-dim); }
.feed-detect { background: var(--amber); box-shadow: 0 0 0 3px rgba(252, 211, 77, 0.12); }
.feed-merge { background: var(--blue); box-shadow: 0 0 0 3px rgba(147, 197, 253, 0.12); }
.feed-warn { background: var(--red); box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.12); }
.feed-connect { background: var(--faint); }

.feed-body { flex: 1; min-width: 0; }
.feed-text {
  font-size: 0.86rem;
  color: var(--text);
  font-weight: 500;
  line-height: 1.35;
}
.feed-meta {
  font-size: 0.76rem;
  color: var(--faint);
  margin-top: 2px;
  font-family: var(--mono);
}
.feed-time {
  font-size: 0.72rem;
  color: var(--faint);
  white-space: nowrap;
  flex-shrink: 0;
}

@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

/* ---------- Clickable rows ---------- */
.clickable-row { cursor: pointer; }
.clickable-row:hover { background: rgba(110, 231, 183, 0.03); }

/* ---------- Break detail ---------- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.86rem;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 18px;
}
.back-link svg { width: 15px; height: 15px; }
.back-link:hover { color: var(--green); }

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}
.detail-title .provider-chip { margin-bottom: 10px; }
.detail-title h1 {
  font-size: 1.7rem;
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.detail-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--faint);
  font-size: 0.86rem;
  margin-bottom: 28px;
}
.dot-sep {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--faint);
}

/* ---------- Diff card ---------- */
.diff-panel { margin-bottom: 20px; }
.code-diff {
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.7;
}
.diff-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
}
.diff-row code {
  font-family: inherit;
  word-break: break-all;
}
.diff-sig {
  font-weight: 700;
  width: 14px;
  flex-shrink: 0;
  text-align: center;
}
.diff-row.del { background: rgba(248, 113, 113, 0.05); color: #fca5a5; }
.diff-row.del .diff-sig { color: var(--red); }
.diff-row.add { background: rgba(110, 231, 183, 0.05); color: #a7f3d0; }
.diff-row.add .diff-sig { color: var(--green); }

/* ---------- Affected repos ---------- */
.repo-list { list-style: none; }
.repo-row {
  display: grid;
  grid-template-columns: 1.6fr 0.7fr 0.8fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.repo-row:last-child { border-bottom: 0; }
.repo-name { display: flex; align-items: center; gap: 12px; min-width: 0; }
.repo-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.repo-icon svg { width: 15px; height: 15px; }
.repo-name strong { display: block; font-size: 0.9rem; color: var(--text); }
.repo-calls { font-size: 0.74rem; color: var(--faint); font-family: var(--mono); }

.pr-link {
  font-family: var(--mono);
  font-size: 0.84rem;
  color: var(--green);
  font-weight: 600;
}
.pr-link:hover { color: var(--text); }
.pr-none { font-family: var(--mono); font-size: 0.8rem; color: var(--faint); }

.checks { display: inline-flex; gap: 5px; }
.check-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
}
.check-dot.ok { background: var(--green); }
.check-dot.fail { background: var(--red); }

.repo-status { text-align: right; }
.badge-failed {
  color: var(--red);
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.28);
}

@media (max-width: 900px) {
  .repo-row { grid-template-columns: 1fr auto; gap: 10px; }
  .repo-checks { display: none; }
}

/* ---------- Filter bar ---------- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 200px;
  min-width: 180px;
}
.search-wrap svg {
  position: absolute;
  left: 12px;
  width: 15px;
  height: 15px;
  color: var(--faint);
  pointer-events: none;
}
.search-wrap input {
  width: 100%;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9px;
  padding: 9px 12px 9px 36px;
  font: inherit;
  font-size: 0.86rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search-wrap input::placeholder { color: var(--faint); }
.search-wrap input:focus {
  border-color: rgba(110, 231, 183, 0.45);
  box-shadow: 0 0 0 3px var(--green-dim);
}
.select {
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 9px;
  padding: 9px 12px;
  font: inherit;
  font-size: 0.84rem;
  outline: none;
  cursor: pointer;
}
.select:focus { border-color: rgba(110, 231, 183, 0.45); }

.empty-cell {
  text-align: center;
  color: var(--faint);
  padding: 32px 20px;
  font-size: 0.88rem;
}

/* ---------- Timeline ---------- */
.timeline {
  list-style: none;
  padding: 8px 0;
}
.tl-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.tl-item:last-child { border-bottom: 0; }
.tl-item .feed-icon { margin-top: 6px; }
.tl-body { flex: 1; min-width: 0; }
.tl-text {
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 500;
  line-height: 1.4;
}
.tl-meta {
  font-size: 0.76rem;
  color: var(--faint);
  margin-top: 3px;
  font-family: var(--mono);
}

/* ---------- Page head ---------- */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.page-title {
  font-size: 1.5rem;
  letter-spacing: -0.03em;
  line-height: 1.2;
}
.page-sub {
  font-size: 0.86rem;
  color: var(--faint);
  margin-top: 3px;
}

/* ---------- Repo cards ---------- */
.repo-card-list { list-style: none; }
.repo-card-row {
  display: grid;
  grid-template-columns: 1.6fr 1.4fr 0.6fr 0.6fr 0.7fr;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.repo-card-row:last-child { border-bottom: 0; }
.repo-card-row:hover { background: rgba(255, 255, 255, 0.02); }
.repo-health {
  display: block;
  font-size: 0.74rem;
  margin-top: 3px;
}
.repo-health.ok { color: var(--green); }
.repo-health.bad { color: var(--red); }

.chip-stack { display: inline-flex; gap: 5px; flex-wrap: wrap; }
.mini-chip {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  padding: 3px 8px;
  border-radius: 999px;
}
.repo-stat {
  display: flex;
  flex-direction: column;
}
.repo-stat strong {
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  color: var(--text);
}
.repo-stat span {
  font-size: 0.72rem;
  color: var(--faint);
}
.repo-last {
  font-size: 0.8rem;
  color: var(--faint);
  text-align: right;
  font-family: var(--mono);
}

@media (max-width: 900px) {
  .repo-card-row { grid-template-columns: 1fr auto; }
  .repo-providers, .repo-stat, .repo-last { display: none; }
}

/* ---------- Settings ---------- */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
.settings-list { list-style: none; }
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.setting-row:last-child { border-bottom: 0; }
.setting-main { display: flex; flex-direction: column; gap: 2px; }
.setting-main strong { font-size: 0.92rem; }
.setting-detail {
  font-size: 0.76rem;
  color: var(--faint);
  font-family: var(--mono);
}

/* ---------- Switch ---------- */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  transition: background 0.2s ease;
}
.slider::before {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.2s ease, background 0.2s ease;
}
.switch input:checked + .slider { background: var(--green-dim); border-color: rgba(110, 231, 183, 0.4); }
.switch input:checked + .slider::before {
  transform: translateX(18px);
  background: var(--green);
}
.switch input:disabled + .slider { opacity: 0.5; cursor: default; }

@media (max-width: 900px) {
  .settings-grid { grid-template-columns: 1fr; }
}

/* ---------- Onboarding ---------- */
.onboard {
  display: flex;
  justify-content: center;
  padding: 32px 16px 60px;
}
.onboard-card {
  width: 100%;
  max-width: 520px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 36px 32px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow);
}
.onboard-mark {
  width: 44px;
  height: 44px;
  margin-bottom: 12px;
}
.onboard-title {
  font-size: 1.5rem;
  letter-spacing: -0.03em;
  line-height: 1.2;
}
.onboard-sub {
  font-size: 0.92rem;
  color: var(--muted);
  margin-bottom: 18px;
}
.onboard-step { margin-bottom: 16px; }
.step-label {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 10px;
}
.step-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  color: var(--green);
  background: var(--green-dim);
  border: 1px solid rgba(110, 231, 183, 0.3);
  font-family: var(--mono);
}
.btn-wide { width: 100%; justify-content: center; }
.btn-wide svg { width: 16px; height: 16px; }

.onboard-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.onboard-chip {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--muted);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  padding: 8px 14px;
  border-radius: 999px;
  transition: 0.15s ease;
}
.onboard-chip:hover { color: var(--text); border-color: var(--line-strong); }
.onboard-chip.selected {
  color: var(--green);
  border-color: rgba(110, 231, 183, 0.4);
  background: var(--green-dim);
}

.gate-checks { display: flex; gap: 8px; flex-wrap: wrap; }
.gate {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.gate.on {
  color: var(--green);
  background: rgba(110, 231, 183, 0.12);
  border-color: rgba(110, 231, 183, 0.28);
}
.gate.off {
  color: var(--faint);
  background: rgba(255, 255, 255, 0.02);
  border-color: var(--line);
}

#finish-onboard { margin-top: 12px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  z-index: 100;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  border: 1px solid rgba(110, 231, 183, 0.35);
  color: var(--green);
  font-size: 0.86rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Connected button ---------- */
.btn.connected {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(110, 231, 183, 0.35);
  box-shadow: none;
  cursor: default;
}
.btn.connected svg { width: 16px; height: 16px; }
