:root {
  --bg: #0b0d10;
  --bg-elevated: #111419;
  --bg-hover: #14171c;
  --panel: #111419;
  --panel-border: #23262d;
  --line: #23262d;
  --line-strong: #2d323c;
  --fg: #e6e6e6;
  --fg-muted: #8b93a1;
  --fg-subtle: #5c6370;
  --accent: #6ea8fe;
  --accent-hover: #8bb8fe;
  --accent-dim: #1e3a5f;
  --success: #4ade80;
  --success-dim: #0f3d1e;
  --warning: #fbbf24;
  --warning-dim: #3d2f08;
  --danger: #f87171;
  --danger-dim: #3d1616;
  --info: #60a5fa;
  --info-dim: #102a43;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --transition: 150ms ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--fg); font-family: var(--font-sans); font-size: 13px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.neutron-app { display: grid; grid-template-columns: 280px 1fr; grid-template-rows: auto 1fr; height: 100vh; overflow: hidden; }

/* Sidebar */
.neutron-sidebar { grid-row: 1 / -1; background: var(--panel); border-right: 1px solid var(--panel-border); display: flex; flex-direction: column; min-width: 260px; }
.neutron-brand { padding: 16px; border-bottom: 1px solid var(--panel-border); display: flex; align-items: center; gap: 10px; }
.neutron-title { font-size: 14px; font-weight: 600; letter-spacing: 0.02em; }
.neutron-title span { color: var(--accent); }

.neutron-nav { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-section { margin-top: 8px; }
.nav-section:first-child { margin-top: 0; }
.nav-section-title { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--fg-subtle); padding: 8px 10px 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--radius-md); color: var(--fg-muted); cursor: pointer; transition: var(--transition); font-size: 13px; }
.nav-item:hover { background: var(--bg-hover); color: var(--fg); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }
.nav-item.active .nav-icon { color: var(--accent); }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; color: var(--fg-subtle); }
.nav-badge { margin-left: auto; font-size: 10px; padding: 2px 6px; border-radius: 999px; background: var(--line); color: var(--fg-subtle); }
.nav-item.active .nav-badge { background: var(--accent); color: #04122b; }

.neutron-repo-selector { padding: 12px; border-top: 1px solid var(--panel-border); }
.repo-select-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-subtle); margin-bottom: 8px; display: block; }
.repo-select { width: 100%; background: var(--bg); border: 1px solid var(--line); color: var(--fg); padding: 8px 10px; border-radius: var(--radius-md); font-family: inherit; font-size: 13px; }
.repo-select:focus { outline: none; border-color: var(--accent); }

/* Header */
.neutron-header { grid-column: 2; background: var(--panel); border-bottom: 1px solid var(--panel-border); padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; min-height: 56px; }
.neutron-breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--fg-muted); }
.neutron-breadcrumb .sep { color: var(--fg-subtle); }
.neutron-breadcrumb .current { color: var(--fg); font-weight: 500; }
.neutron-actions { display: flex; gap: 8px; }

/* Main Content */
.neutron-main { grid-column: 2; overflow: auto; padding: 24px; }
.neutron-view { display: none; }
.neutron-view.active { display: block; animation: fadeIn 200ms ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Cards */
.neutron-card { background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius-lg); overflow: hidden; }
.neutron-card-header { padding: 16px 20px; border-bottom: 1px solid var(--panel-border); display: flex; align-items: center; justify-content: space-between; }
.neutron-card-title { font-size: 14px; font-weight: 600; }
.neutron-card-subtitle { font-size: 12px; color: var(--fg-muted); margin-top: 2px; }
.neutron-card-body { padding: 20px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: var(--radius-md); font-size: 13px; font-weight: 500; font-family: inherit; cursor: pointer; transition: var(--transition); border: 1px solid transparent; white-space: nowrap; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #04122b; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-hover); color: var(--fg); border-color: var(--line); }
.btn-secondary:hover:not(:disabled) { background: var(--line); }
.btn-danger { background: var(--danger-dim); color: var(--danger); border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger); color: #04122b; }
.btn-ghost { background: transparent; color: var(--fg-muted); }
.btn-ghost:hover:not(:disabled) { color: var(--fg); background: var(--bg-hover); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 8px; }
.btn-icon svg { width: 16px; height: 16px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 500; color: var(--fg); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea { width: 100%; background: var(--bg); border: 1px solid var(--line); color: var(--fg); padding: 10px 12px; border-radius: var(--radius-md); font-family: inherit; font-size: 13px; transition: var(--transition); }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.form-textarea { min-height: 100px; resize: vertical; font-family: var(--font-mono); }
.form-help { font-size: 11px; color: var(--fg-subtle); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Risk Toggle */
.risk-toggle { display: flex; gap: 8px; }
.risk-option { flex: 1; }
.risk-option input { position: absolute; opacity: 0; pointer-events: none; }
.risk-option label { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 8px; border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--bg); cursor: pointer; transition: var(--transition); }
.risk-option input:checked + label { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }
.risk-option label:hover { border-color: var(--line-strong); }
.risk-label { font-size: 12px; font-weight: 500; }
.risk-desc { font-size: 10px; color: var(--fg-subtle); text-align: center; }

/* Status Indicators */
.status-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; }
.status-badge.success { background: var(--success-dim); color: var(--success); }
.status-badge.success::before { background: var(--success); }
.status-badge.warning { background: var(--warning-dim); color: var(--warning); }
.status-badge.warning::before { background: var(--warning); }
.status-badge.danger { background: var(--danger-dim); color: var(--danger); }
.status-badge.danger::before { background: var(--danger); }
.status-badge.info { background: var(--info-dim); color: var(--info); }
.status-badge.info::before { background: var(--info); }
.status-badge.pending { background: var(--accent-dim); color: var(--accent); }
.status-badge.pending::before { background: var(--accent); animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Risk Levels */
.risk-low { color: var(--success); }
.risk-medium { color: var(--warning); }
.risk-high { color: var(--danger); }
.risk-critical { color: var(--danger); font-weight: 700; }

/* Grid */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 1000px) { .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

/* Stat Cards */
.stat-card { background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius-lg); padding: 20px; }
.stat-value { font-size: 32px; font-weight: 700; font-family: var(--font-mono); line-height: 1; }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-subtle); margin-top: 8px; }
.stat-trend { font-size: 12px; margin-top: 8px; display: flex; align-items: center; gap: 4px; }
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* Tables */
.table-container { overflow-x: auto; }
.neutron-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.neutron-table th { text-align: left; padding: 10px 12px; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-subtle); border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; }
.neutron-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.neutron-table tr:last-child td { border-bottom: none; }
.neutron-table tr:hover td { background: var(--bg-hover); }

/* Progress */
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 3px; transition: width 300ms ease; }
.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger { background: var(--danger); }
.progress-bar.info { background: var(--accent); }

/* Agent Status */
.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.agent-card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 16px; transition: var(--transition); }
.agent-card:hover { border-color: var(--line-strong); }
.agent-card.running { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-dim); }
.agent-card.completed { border-color: var(--success); }
.agent-card.failed { border-color: var(--danger); }
.agent-card.waiting { border-color: var(--warning); }
.agent-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.agent-name { font-weight: 600; font-size: 13px; }
.agent-status { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.agent-task { font-size: 12px; color: var(--fg-muted); margin-bottom: 12px; min-height: 20px; }
.agent-progress { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.agent-progress-bar { height: 100%; border-radius: 2px; transition: width 300ms ease; }

/* Impact Graph Container */
.impact-graph-container { height: 600px; background: var(--bg); border-radius: var(--radius-md); border: 1px solid var(--line); position: relative; }
.impact-graph-container canvas { width: 100%; height: 100%; }

/* File Tree */
.file-tree { font-family: var(--font-mono); font-size: 12px; }
.file-tree-item { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: var(--radius-sm); cursor: pointer; transition: var(--transition); }
.file-tree-item:hover { background: var(--bg-hover); }
.file-tree-item.selected { background: var(--accent-dim); color: var(--accent); }
.file-tree-indent { width: 16px; }
.file-tree-icon { width: 16px; height: 16px; flex-shrink: 0; }
.file-tree-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-tree-risk { font-size: 10px; padding: 1px 6px; border-radius: 999px; }

/* Diff View */
.diff-container { font-family: var(--font-mono); font-size: 12px; line-height: 1.6; max-height: 500px; overflow: auto; }
.diff-file { margin-bottom: 16px; }
.diff-header { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-md) var(--radius-md) 0 0; padding: 8px 12px; font-weight: 500; }
.diff-content { border: 1px solid var(--line); border-top: none; border-radius: 0 0 var(--radius-md) var(--radius-md); }
.diff-line { padding: 2px 12px; display: flex; }
.diff-line.added { background: var(--success-dim); }
.diff-line.removed { background: var(--danger-dim); }
.diff-line.context { color: var(--fg-muted); }
.diff-line-num { width: 50px; text-align: right; color: var(--fg-subtle); user-select: none; padding-right: 12px; flex-shrink: 0; }
.diff-line-content { flex: 1; white-space: pre; }

/* Timeline */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 0; bottom: 0; width: 2px; background: var(--line); }
.timeline-item { position: relative; padding-bottom: 20px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-marker { position: absolute; left: -20px; top: 2px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--bg); background: var(--panel); z-index: 1; }
.timeline-marker.completed { background: var(--success); border-color: var(--success); }
.timeline-marker.running { background: var(--accent); border-color: var(--accent); animation: pulse 1.5s infinite; }
.timeline-marker.failed { background: var(--danger); border-color: var(--danger); }
.timeline-marker.waiting { background: var(--warning); border-color: var(--warning); }
.timeline-time { font-size: 11px; color: var(--fg-subtle); margin-bottom: 2px; }
.timeline-event { font-size: 13px; color: var(--fg); }
.timeline-agent { font-size: 11px; color: var(--fg-muted); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 24px; opacity: 0; visibility: hidden; transition: var(--transition); }
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal { background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius-lg); width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; transform: scale(0.95); transition: var(--transition); }
.modal-overlay.open .modal { transform: scale(1); }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--panel-border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 14px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--fg-muted); cursor: pointer; padding: 4px; }
.modal-close:hover { color: var(--fg); }
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--panel-border); display: flex; justify-content: flex-end; gap: 8px; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tab { padding: 10px 16px; font-size: 13px; color: var(--fg-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: var(--transition); }
.tab:hover { color: var(--fg); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Empty State */
.empty-state { text-align: center; padding: 48px 24px; color: var(--fg-muted); }
.empty-state-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-state-title { font-size: 14px; font-weight: 500; color: var(--fg); margin-bottom: 8px; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--line-strong); }