* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0f1117;
  --fg: #e2e8f0;
  --card: #1a1d2e;
  --border: #2d3748;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --muted: #64748b;
}
body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', sans-serif;
  display: flex;
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; font-size: 14px; cursor: pointer; border: none; }

/* Sidebar */
#sidebar {
  width: 240px;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.logo {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-icon { font-size: 28px; }
.logo h1 { font-size: 16px; font-weight: 700; }
.logo p { font-size: 11px; color: var(--muted); }
nav { flex: 1; padding: 12px; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 4px;
  font-weight: 500;
  color: var(--muted);
  transition: all 0.15s;
}
.nav-item:hover { background: rgba(99,102,241,0.08); color: var(--fg); }
.nav-item.active { background: var(--accent); color: white; }
.nav-item span { font-size: 16px; }
.badge-count {
  margin-left: auto;
  background: var(--warning);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 700;
}
.badge-count:empty { display: none; }
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
}
.sidebar-footer p { margin-top: 8px; text-align: center; }
.btn-mini {
  width: 100%;
  padding: 6px 10px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
  margin-bottom: 4px;
  transition: all 0.15s;
}
.btn-mini:hover { border-color: var(--accent); color: var(--fg); }

/* Main */
#main { flex: 1; padding: 32px; max-width: 100%; overflow-x: hidden; }
.tab.hidden { display: none; }
header { margin-bottom: 28px; }
header h2 { font-size: 22px; font-weight: 700; }
header p { font-size: 13px; color: var(--muted); margin-top: 4px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; }

/* Card */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}
.card h3 { font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.card.clickable { cursor: pointer; transition: border 0.15s; }
.card.clickable:hover { border-color: var(--accent); }

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  transition: border 0.15s;
}
.stat-card:hover { border-color: var(--accent); }
.stat-card .label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.stat-card .value { font-size: 22px; font-weight: 700; }

/* Buttons */
.btn-primary {
  background: var(--accent);
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary {
  background: transparent;
  color: var(--fg);
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: border 0.15s;
}
.btn-secondary:hover { border-color: var(--accent); }
.btn-danger {
  background: transparent;
  color: var(--danger);
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  border: 1px solid var(--danger);
}
.btn-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* Form */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
.form-grid label.full { grid-column: 1 / -1; }
label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
input, select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 8px 10px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  margin-top: 4px;
}
textarea { resize: vertical; min-height: 80px; font-family: inherit; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.hint { font-size: 12px; color: var(--muted); margin-bottom: 8px; }

/* Two column */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}

/* Quick actions */
.quick-action {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  transition: background 0.15s;
}
.quick-action:hover { background: rgba(99,102,241,0.08); }
.quick-action > span { font-size: 22px; width: 32px; text-align: center; }
.quick-action div { flex: 1; }
.quick-action strong { display: block; font-size: 13px; font-weight: 600; }
.quick-action small { font-size: 11px; color: var(--muted); }
.quick-action em { color: var(--muted); font-style: normal; }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
}
.badge-draft { background: #64748b22; color: #94a3b8; }
.badge-published, .badge-approved, .badge-active { background: #10b98122; color: #6ee7b7; }
.badge-pending_review, .badge-awaiting { background: #f59e0b22; color: #fcd34d; }
.badge-rejected { background: #ef444422; color: #fca5a5; }
.badge-paused { background: #f59e0b22; color: #fcd34d; }
.badge-ai { background: #7c3aed22; color: #a78bfa; }

/* List items */
.item-row {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.item-row .icon { font-size: 22px; }
.item-row .body { flex: 1; min-width: 0; }
.item-row .title { font-weight: 600; font-size: 14px; }
.item-row .meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.item-row .right { text-align: right; }
.item-row .amount { font-weight: 700; font-size: 16px; color: var(--success); }

/* Filters */
.filters { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.filters button {
  padding: 5px 12px;
  border-radius: 99px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.filters button.active { background: var(--accent); border-color: var(--accent); color: white; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal.hidden { display: none; }
.modal-content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  padding: 4px 8px;
}

/* Toast */
#toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--success);
  color: white;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: all 0.25s;
  z-index: 200;
}
#toast.show { opacity: 1; transform: translateY(0); }

/* Bar chart */
.bar-row { margin-bottom: 10px; }
.bar-label { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 3px; }
.bar-track { height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--success); border-radius: 99px; transition: width 0.4s; }

/* Stepper */
.stepper {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
  overflow-x: auto;
  padding: 4px 2px;
}
.stepper .step {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.stepper .step span {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--border);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  transition: all 0.2s;
}
.stepper .step.active span { background: var(--accent); color: white; }
.stepper .step.done span { background: var(--success); color: white; }
.stepper .step div { font-size: 12px; font-weight: 600; }
.stepper .step small { display: block; color: var(--muted); font-weight: 400; font-size: 10px; margin-top: 1px; }
.stepper .step-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 10px;
  min-width: 20px;
}
.stepper .step.done + .step-line { background: var(--success); }

/* ASP guide */
.asp-guide {
  background: var(--bg);
  border-radius: 8px;
  padding: 14px;
  margin: 12px 0;
  font-size: 13px;
}
.asp-guide ol { margin: 10px 0 0 0; padding-left: 20px; }
.asp-guide ul { margin: 4px 0; }

.asp-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.asp-link {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s;
  text-align: center;
}
.asp-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Candidate niche cards */
.cand-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.cand-card .cand-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.cand-card .cand-name {
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.cand-card .cand-name input {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 13px;
  width: 220px;
  margin: 0;
}
.cand-card .asp-btns {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.asp-btn {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
  transition: all 0.15s;
  cursor: pointer;
}
.asp-btn:hover { border-color: var(--accent); color: var(--accent); }
.asp-btn.open-all {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  font-weight: 600;
}
.asp-btn.open-all:hover { background: var(--accent-hover); }

/* Mode switch */
.mode-switch {
  display: flex;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 20px;
  gap: 4px;
}
.mode-btn {
  flex: 1;
  background: transparent;
  color: var(--muted);
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  transition: all 0.15s;
}
.mode-btn.active {
  background: var(--accent);
  color: white;
}

/* Option cards (pipeline selection) */
.opt-card {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}
.opt-card:hover { border-color: var(--accent); }
.opt-card.selected {
  border-color: var(--accent);
  background: rgba(99,102,241,0.08);
}
.opt-card.selected::before {
  content: '✓';
  position: absolute;
  top: 10px;
  right: 12px;
  background: var(--accent);
  color: white;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}
.opt-card .opt-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
}
.opt-card .opt-meta {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.opt-card .opt-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}
.opt-count {
  text-align: center;
  font-size: 13px;
  margin: 12px 0;
  color: var(--muted);
}
.opt-count strong { color: var(--fg); }

/* AI response display */
.ai-response {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  max-height: 500px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.7;
}
.ai-response pre {
  white-space: pre-wrap;
  font-family: inherit;
  margin: 0;
}

/* Loading overlay */
#loading {
  position: fixed;
  inset: 0;
  background: rgba(15,17,23,0.85);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}
#loading.hidden { display: none; }
.loader {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 40px;
  text-align: center;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-text {
  font-size: 13px;
  color: var(--muted);
}

.method-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.method-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 14px;
}

kbd {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
  font-family: ui-monospace, monospace;
}

/* Empty state */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty .icon { font-size: 40px; margin-bottom: 12px; }

/* Utilities */
.hidden { display: none !important; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--muted); }
code { background: var(--bg); padding: 2px 6px; border-radius: 4px; font-size: 12px; }
ol, ul { padding-left: 20px; margin: 8px 0; }
li { margin: 4px 0; font-size: 13px; }
