:root {
  --bg: #070b12;
  --bg-elevated: #0d121c;
  --surface: #111827;
  --surface-hover: #151f31;
  --surface-2: #1a2438;
  --border: rgba(148, 163, 184, 0.12);
  --border-strong: rgba(148, 163, 184, 0.22);
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #22d3ee;
  --accent-dim: rgba(34, 211, 238, 0.12);
  --accent-glow: rgba(34, 211, 238, 0.35);
  --danger: #fb7185;
  --danger-bg: rgba(251, 113, 133, 0.12);
  --ok: #34d399;
  --ok-bg: rgba(52, 211, 153, 0.12);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, 0.12);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --font: "Plus Jakarta Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sidebar-w: 260px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(34, 211, 238, 0.14), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 10%, rgba(167, 139, 250, 0.1), transparent 50%);
  background-attachment: fixed;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  background: rgba(13, 18, 28, 0.82);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.35rem 0.65rem 1.75rem;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-dim), rgba(167, 139, 250, 0.15));
  border: 1px solid var(--border-strong);
  color: var(--accent);
}

.brand strong { display: block; font-size: 1rem; font-weight: 700; }
.brand span { font-size: 0.72rem; color: var(--text-muted); }

.nav { display: flex; flex-direction: column; gap: 0.35rem; flex: 1; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}

.nav-link svg { width: 18px; height: 18px; opacity: 0.75; }
.nav-link:hover { background: var(--surface-hover); color: var(--text); }
.nav-link.active { background: var(--accent-dim); color: var(--accent); }
.nav-link.active svg { opacity: 1; color: var(--accent); }

.sidebar-foot { padding: 1rem 0.65rem 0; border-top: 1px solid var(--border); }
.version { margin: 0; font-size: 0.72rem; color: var(--text-muted); font-family: var(--mono); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 11, 18, 0.6);
  backdrop-filter: blur(12px);
}

.topbar-title { font-weight: 700; font-size: 1.05rem; }
.topbar-meta { font-size: 0.82rem; color: var(--text-muted); font-family: var(--mono); }

.content { padding: 2rem; max-width: 960px; }

.page-header { margin-bottom: 1.75rem; }
.page-header h1 { margin: 0 0 0.35rem; font-size: 1.65rem; font-weight: 700; }
.page-header .subtitle { margin: 0; color: var(--text-secondary); font-size: 0.95rem; }

.card {
  padding: 1.35rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}

.error-card {
  border-color: rgba(251, 113, 133, 0.35);
  background: linear-gradient(180deg, rgba(251, 113, 133, 0.08), rgba(17, 24, 39, 0.9));
  color: var(--danger);
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #22d3ee, #06b6d4);
  color: #042f2e;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.62rem 1.15rem;
  cursor: pointer;
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.88rem;
}

button.secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

button:disabled { opacity: 0.5; cursor: not-allowed; }

.form-row { display: grid; gap: 0.45rem; margin-bottom: 0.75rem; }
label { font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); }

input {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  width: 100%;
  font-family: var(--font);
  font-size: 0.9rem;
}

input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.toolbar { display: flex; gap: 0.65rem; flex-wrap: wrap; align-items: center; }
.muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.mono, code { font-family: var(--mono); }

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  font-size: 0.88rem;
  z-index: 1000;
}

.toast[hidden] { display: none; }

.feeds-hint { margin: 0 0 1.25rem; font-size: 0.85rem; max-width: 52rem; }

.switch { position: relative; width: 52px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }

.switch-slider {
  position: absolute;
  inset: 0;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
}

.switch-slider::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--text-secondary);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.switch input:checked + .switch-slider {
  background: var(--accent-dim);
  border-color: rgba(34, 211, 238, 0.4);
}

.switch input:checked + .switch-slider::before {
  transform: translateY(-50%) translateX(24px);
  background: var(--accent);
}

.feed-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 1.25rem 1.35rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 0.85rem;
}

.feed-card.disabled { opacity: 0.55; pointer-events: none; }

.feed-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: stretch;
}

.sbom-upload-card { max-width: 560px; }
.sbom-upload-zone {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-elevated, var(--bg));
}
.sbom-file-name { font-size: 0.85rem; }

.file-upload { cursor: pointer; margin: 0; }
.file-upload-btn {
  display: block;
  text-align: center;
  width: 100%;
}

.feed-meta h3 { margin: 0 0 0.25rem; font-size: 1rem; }
.feed-meta p { margin: 0; font-size: 0.85rem; color: var(--text-secondary); }

.feed-credentials {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}
.feed-credentials-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text-secondary);
}
.feed-credentials-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.feed-api-key-input {
  flex: 1 1 12rem;
  min-width: 10rem;
  padding: 0.4rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.85rem;
}
.feed-api-key-delete {
  border-color: var(--danger);
  color: var(--danger);
}
.feed-api-key-delete:hover {
  background: var(--danger-bg);
}
.feed-credentials-hint,
.feed-credentials-saved {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
}

.feed-stats {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--mono);
  flex-wrap: wrap;
}

.feed-status {
  display: inline-flex;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
}

.feed-status.success { background: var(--ok-bg); color: var(--ok); }
.feed-status.running { background: var(--accent-dim); color: var(--accent); }
.feed-status.error { background: var(--danger-bg); color: var(--danger); }
.feed-status.idle { background: rgba(100, 116, 139, 0.15); color: var(--text-muted); }

.auto-sync-panel { margin-bottom: 1rem; padding: 1.1rem 1.25rem; }
.auto-sync-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.auto-sync-title { margin: 0 0 0.35rem; font-size: 1.05rem; }
.auto-sync-hint { margin: 0; font-size: 0.85rem; max-width: 52rem; }
.auto-sync-table input[type="number"] {
  width: 5rem;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
}
.auto-sync-unit { margin-left: 0.35rem; font-size: 0.85rem; }
.switch-sm { transform: scale(0.85); transform-origin: left center; }

.feed-grid { display: grid; gap: 0.85rem; }

.queue-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.queue-section { margin-bottom: 1.75rem; }

.queue-section-title {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.queue-hint {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
}

.queue-current {
  padding: 1rem 1.25rem;
}

.queue-current-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.queue-current-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.queue-table-wrap { padding: 0; overflow-x: auto; }

.queue-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.queue-table th,
.queue-table td {
  padding: 0.65rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.queue-table th {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.queue-table tbody tr:last-child td { border-bottom: none; }

.queue-empty,
.queue-empty-cell {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.queue-empty-cell {
  text-align: center;
  padding: 1.25rem !important;
}

.queue-badge {
  display: inline-flex;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.queue-badge.outside {
  background: var(--warn-bg);
  color: var(--warn);
}

.queue-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 120px;
}

.queue-current .queue-progress-wrap {
  margin-top: 0.75rem;
}

.queue-progress {
  height: 6px;
  background: rgba(100, 116, 139, 0.2);
  border-radius: 999px;
  overflow: hidden;
}

.queue-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #67e8f9);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.queue-progress-pct {
  font-size: 0.75rem;
  color: var(--accent);
}

.queue-progress-msg {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.queue-progress-empty {
  color: var(--text-muted);
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .content { padding: 1.25rem; }
  .topbar { padding: 1rem 1.25rem; }
}
