*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-hover: #22263a;
  --border: #2e3347;
  --text: #e2e8f0;
  --text-muted: #8892a4;
  --accent: #6366f1;
  --accent-hover: #5254cc;
  --success: #22c55e;
  --error: #ef4444;
  --warning: #f59e0b;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.35);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.layout { display: flex; flex-direction: column; min-height: 100vh; }

.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 960px;
  margin: 0 auto;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: 22px; }
.logo-text { font-weight: 700; font-size: 18px; letter-spacing: -0.3px; }

.main {
  max-width: 960px;
  margin: 32px auto;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}

.nav-tabs { display: flex; gap: 4px; }
.nav-tab {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  border: none;
  background: transparent;
  transition: background 0.15s, color 0.15s;
}
.nav-tab:hover { color: var(--text); background: var(--surface-hover); }
.nav-tab-active { color: var(--text) !important; background: var(--bg) !important; }

.tab-panel { display: none; }
.tab-panel-active { display: flex; flex-direction: column; gap: 20px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.badge {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 100px;
  padding: 2px 8px;
  min-width: 22px;
  text-align: center;
}

/* Buttons */
.btn {
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 18px;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  padding: 8px 16px;
  transition: all 0.15s;
}
.btn-outline:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-ghost {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 5px 10px;
  font-size: 15px;
  cursor: pointer;
}
.btn-ghost:hover { color: var(--error); background: rgba(239,68,68,0.1); border-radius: 6px; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }

/* Pagination */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 0 4px;
  border-top: 1px solid var(--border);
  margin-top: 10px;
}
.page-info { font-size: 13px; color: var(--text-muted); min-width: 160px; text-align: center; }

/* Project cards */
.project-list { display: flex; flex-direction: column; gap: 10px; }
.project-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.project-header { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.project-icon { font-size: 22px; flex-shrink: 0; }
.project-info { flex: 1; min-width: 0; }
.project-name { display: block; font-size: 15px; font-weight: 600; }
.project-meta { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-footer { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.project-detail { font-size: 12px; color: var(--text-muted); }
.project-actions { display: flex; gap: 6px; align-items: center; }
.project-progress { margin: 8px 0; display: flex; align-items: center; gap: 10px; }
.progress-text { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.upload-progress { flex: 1; height: 4px; background: var(--border); border-radius: 4px; overflow: hidden; }
.upload-bar { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.4s ease; }
.bar-pulse { animation: pulse 1.5s ease-in-out infinite; }

/* Status badges */
.status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 100px;
  white-space: nowrap;
  flex-shrink: 0;
}
.status-ok   { background: rgba(34,197,94,0.15);  color: var(--success); }
.status-sync { background: rgba(99,102,241,0.15); color: var(--accent); }
.status-warn { background: rgba(245,158,11,0.15); color: var(--warning); }
.status-error{ background: rgba(239,68,68,0.15);  color: var(--error); }
.status-idle { background: rgba(136,146,164,0.15);color: var(--text-muted); }

/* Project-name badge on repo rows */
.project-source-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 100px;
  background: rgba(99,102,241,0.12);
  color: var(--accent);
  white-space: nowrap;
}
/* Collapsed team entries (not yet fully indexed) — muted amber style */
.project-source-badge--team {
  background: rgba(234,179,8,0.12);
  color: #a16207;
}

/* Teams browser */
.team-list { display: flex; flex-direction: column; gap: 8px; }
.team-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.team-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
.team-header:hover { background: var(--surface-hover); }
.team-header-left { display: flex; align-items: center; gap: 10px; }
.team-name { font-size: 14px; font-weight: 600; }
.team-desc { font-size: 12px; color: var(--text-muted); }
.team-chevron { font-size: 12px; color: var(--text-muted); transition: transform 0.2s; }
.team-chevron-open { transform: rotate(90deg); }
.team-body { display: none; border-top: 1px solid var(--border); }
.team-body-open { display: block; }
.team-body-toolbar { display: flex; justify-content: flex-end; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--bg-subtle, #f9fafb); }
.repo-list { display: flex; flex-direction: column; }
.repo-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.repo-item:last-child { border-bottom: none; }
.repo-item:hover { background: rgba(99,102,241,0.04); }
.repo-info { flex: 1; min-width: 0; }
.repo-name { font-size: 13px; font-weight: 500; }
.repo-meta { font-size: 11px; color: var(--text-muted); }
.repo-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.repo-already { font-size: 11px; color: var(--success); padding: 4px 10px; }

/* Form */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 8px; }
.form-label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--text-muted); font-weight: 500; }
.form-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}
.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--text-muted); opacity: 0.6; }
.form-actions { margin-top: 16px; display: flex; gap: 10px; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted); }
.modal-close:hover { color: var(--error); }
.modal-form { display: flex; flex-direction: column; gap: 14px; }
.modal-footer { margin-top: 20px; display: flex; gap: 10px; justify-content: flex-end; }

/* Misc */
.empty-msg { color: var(--text-muted); font-size: 14px; text-align: center; padding: 24px 0; }
.loading { color: var(--text-muted); font-size: 13px; padding: 12px 0; }
.link { color: var(--accent); cursor: pointer; text-decoration: underline; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 14px;
  max-width: 360px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  z-index: 400;
}
.toast-show { opacity: 1; transform: translateY(0); }
.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--error); }
.toast-info    { border-left: 3px solid var(--accent); }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

@media (max-width: 640px) {
  .main { padding: 0 16px; margin: 16px auto; }
  .form-grid { grid-template-columns: 1fr; }
  .project-footer { flex-direction: column; align-items: flex-start; }
}
