:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-border: #30363d;
  --text: #c9d1d9;
  --text-muted: #8b949e;
  --text-white: #f0f6fc;
  --primary: #238636;
  --primary-hover: #2ea043;
  --danger: #da3633;
  --accent: #58a6ff;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

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

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 820px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem;
  width: 100%;
  flex: 1;
}

header {
  margin-bottom: 2rem;
  text-align: center;
}

header h1 {
  color: var(--text-white);
  font-size: 2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

header p {
  color: var(--text-muted);
  font-size: 1.05rem;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 9999px;
  background: rgba(88, 166, 255, 0.15);
  color: var(--accent);
  border: 1px solid rgba(88, 166, 255, 0.3);
  margin-left: 0.5rem;
  vertical-align: middle;
}

.card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.card-title {
  color: var(--text-white);
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.field {
  margin-bottom: 1.25rem;
}

.field:last-child {
  margin-bottom: 0;
}

label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-white);
  margin-bottom: 0.4rem;
}

.helper-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.helper-text a {
  color: var(--accent);
  text-decoration: none;
}

.helper-text a:hover {
  text-decoration: underline;
}

input[type="text"],
input[type="password"],
select {
  width: 100%;
  background-color: var(--bg);
  border: 1px solid var(--surface-border);
  border-radius: 6px;
  padding: 0.65rem 0.85rem;
  color: var(--text-white);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s ease;
}

input:focus,
select:focus {
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 0.15s ease, opacity 0.15s ease;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background-color: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
}

.btn-scan {
  background-color: #1f6feb;
  color: #fff;
}

.btn-scan:hover:not(:disabled) {
  background-color: #388bfd;
}

.btn-optimize {
  background-color: #238636;
  color: #fff;
  animation: pulse-glow 2s infinite;
}

.btn-optimize:hover:not(:disabled) {
  background-color: #2ea043;
}

@keyframes pulse-glow {
  0% { box-shadow: 0 0 0 0 rgba(46, 160, 67, 0.5); }
  70% { box-shadow: 0 0 0 10px rgba(46, 160, 67, 0); }
  100% { box-shadow: 0 0 0 0 rgba(46, 160, 67, 0); }
}

.btn-secondary {
  background-color: transparent;
  border-color: var(--surface-border);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--surface-border);
  color: var(--text-white);
}

.btn-github {
  background-color: #24292f;
  color: #fff;
  border: 1px solid #444c56;
}

.btn-github:hover:not(:disabled) {
  background-color: #32383f;
}

.user-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  padding: 0.75rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--surface-border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--surface-border);
}

.progress-container {
  margin-top: 1rem;
  background: var(--bg);
  border-radius: 6px;
  height: 10px;
  overflow: hidden;
  border: 1px solid var(--surface-border);
}

.progress-bar {
  background-color: var(--primary);
  height: 100%;
  width: 0%;
  transition: width 0.3s ease;
}

.log-box {
  background: var(--bg);
  border: 1px solid var(--surface-border);
  border-radius: 6px;
  padding: 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  max-height: 240px;
  overflow-y: auto;
  white-space: pre-wrap;
  margin-top: 1rem;
  color: var(--text-muted);
}

.log-entry {
  margin-bottom: 0.25rem;
}

.log-info { color: var(--text); }
.log-success { color: #3fb950; font-weight: 500; }
.log-warn { color: #d29922; }
.log-error { color: #f85149; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.stat-box {
  background: var(--bg);
  padding: 0.85rem;
  border-radius: 6px;
  border: 1px solid var(--surface-border);
  text-align: center;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-white);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 0.25rem;
}

.alert-banner {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

.alert-error {
  background: rgba(218, 54, 51, 0.15);
  border: 1px solid rgba(218, 54, 51, 0.4);
  color: #ff7b72;
}

.alert-success {
  background: rgba(46, 160, 67, 0.15);
  border: 1px solid rgba(46, 160, 67, 0.4);
  color: #7ee787;
}

footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--surface-border);
}

/* Repository Cards & Search */
.repo-list-container {
  background: var(--bg);
  border: 1px solid var(--surface-border);
  border-radius: 6px;
  max-height: 280px;
  overflow-y: auto;
  padding: 0.6rem;
  margin-top: 0.5rem;
}

.repo-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.5rem;
}

.repo-card-item {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 6px;
  padding: 0.75rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.4rem;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
  user-select: none;
}

.repo-card-item:hover {
  border-color: var(--accent);
  background: rgba(88, 166, 255, 0.05);
  transform: translateY(-1px);
}

.repo-card-item.selected {
  border-color: #3fb950;
  background: rgba(46, 160, 67, 0.12);
  box-shadow: 0 0 0 1px #3fb950;
}

.repo-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.repo-card-name {
  color: var(--text-white);
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.repo-badge {
  font-size: 0.68rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-weight: 500;
  border: 1px solid var(--surface-border);
  color: var(--text-muted);
}

.repo-badge.private {
  border-color: #d29922;
  color: #e3b341;
}

.repo-card-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.repo-meta-branch {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.selected-repo-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  background: var(--bg);
  border: 1px solid rgba(46, 160, 67, 0.4);
  padding: 0.65rem 0.9rem;
  border-radius: 6px;
}

.repo-loading-text {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* Report Table */
.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  text-align: left;
}

.report-table th,
.report-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--surface-border);
}

.report-table th {
  color: var(--text-muted);
  background: var(--bg);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.72rem;
}

.report-table td code {
  font-family: var(--font-mono);
  color: var(--text-white);
}

.badge-skipped {
  color: #3fb950;
  font-weight: 500;
}
