:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2333;
  --border: #2a3140;
  --text: #e6edf3;
  --muted: #8b97a7;
  --accent: #6e8bff;
  --accent-2: #2ea043;
  --danger: #f85149;
  --tag: #233044;
}

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

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #182033, var(--bg));
  color: var(--text);
  min-height: 100vh;
}

/* Topbar */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  background: rgba(22, 27, 34, 0.8);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  flex-wrap: wrap;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  font-size: 28px;
  color: var(--accent);
  background: var(--panel-2);
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.topbar h1 { font-size: 18px; }
.topbar p { font-size: 12.5px; color: var(--muted); }
.topbar-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.userbox { display: flex; align-items: center; gap: 8px; }
.userbox label { font-size: 11px; color: var(--muted); }
.userbox select {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; font-size: 12.5px; cursor: pointer;
}
.role-badge {
  font-size: 11px; color: var(--accent);
  background: rgba(110,139,255,.15);
  padding: 3px 10px; border-radius: 10px;
  border: 1px solid var(--border);
}
.pipeline {
  font-size: 12px;
  color: var(--muted);
  background: var(--panel);
  padding: 8px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
}
.pipeline b { color: var(--accent); }
.local-path-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.local-path-box label { font-size: 11px; color: var(--muted); white-space: nowrap; }
.local-path-box input {
  min-width: 220px;
  max-width: 320px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
}
.save-path-btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}
.save-path-btn:hover { border-color: var(--accent); }
.path-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 20px;
}
.path-modal.hidden { display: none; }
.path-modal-card {
  width: min(520px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
}
.path-modal-card h3 { margin-bottom: 10px; }
.path-modal-card p { color: var(--muted); font-size: 13.5px; line-height: 1.5; margin-bottom: 12px; }
.path-modal-card input {
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
}
.path-modal-hint { font-size: 12px !important; margin-top: 8px !important; }
.path-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

/* "Open in Cursor" options (deep link / git clone / zip download) */
.open-options { margin: 12px 0; display: flex; flex-direction: column; gap: 12px; }
.open-opt {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.open-opt .ttl { font-size: 12.5px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.open-opt .ttl span { color: var(--muted); font-weight: 400; }
.open-opt a.btn-link {
  display: inline-block;
  background: var(--accent);
  color: #0b0f17;
  font-weight: 700;
  font-size: 13.5px;
  text-decoration: none;
  padding: 10px 18px;
  border-radius: 9px;
  transition: 0.15s;
}
.open-opt a.btn-link:hover { filter: brightness(1.08); transform: translateY(-1px); }
.open-opt.note-box { border-color: rgba(245, 158, 11, 0.35); background: rgba(245, 158, 11, 0.08); }
.open-opt .cmd-row { display: flex; gap: 8px; align-items: stretch; }
.open-opt code.cmd {
  flex: 1;
  background: #0a0e14;
  color: #7ee787;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 12px;
  overflow-x: auto;
  white-space: nowrap;
}
.open-opt .copy-btn, .open-opt .dl-btn {
  background: var(--tag);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 14px;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
}
.open-opt .dl-btn { background: var(--accent-2); color: #04140a; font-weight: 700; border: none; padding: 10px 18px; }
.open-opt .copy-btn:hover, .open-opt .dl-btn:hover { filter: brightness(1.1); }
.open-opt small { display: block; color: var(--muted); margin-top: 8px; font-size: 11.5px; }

/* Git hook info */
.githook {
  font-size: 12.5px; color: #d2a8ff;
  background: #0a0e14; border-radius: 8px;
  padding: 8px 11px; margin: 8px 0;
}
.githook b { color: #d2a8ff; }

/* required role hint in stage panel */
.req-role { font-size: 11px; color: var(--accent); margin-top: 6px; }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 22px;
  padding: 24px 28px;
  max-width: 1200px;
  margin: 0 auto;
}
@media (max-width: 820px) { .layout { grid-template-columns: 1fr; } }

.sidebar h2, .detail h2 { font-size: 16px; margin-bottom: 14px; }

/* Task list */
.task-list { display: flex; flex-direction: column; gap: 12px; }
.task-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  transition: 0.15s;
}
.task-item:hover { border-color: var(--accent); transform: translateY(-1px); }
.task-item.active { border-color: var(--accent); background: var(--panel-2); }
.task-item .id { font-size: 11px; color: var(--muted); }
.task-item .t { font-size: 14px; font-weight: 600; margin: 4px 0 8px; }
.progress {
  height: 6px; background: var(--tag); border-radius: 4px; overflow: hidden;
}
.progress > i { display: block; height: 100%; background: var(--accent-2); transition: 0.3s; }
.task-item .pct { font-size: 11px; color: var(--muted); margin-top: 5px; }

/* Detail */
.empty {
  color: var(--muted);
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 60px 20px;
  text-align: center;
}
.detail-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
}
.hidden { display: none; }

.tag {
  display: inline-block;
  font-size: 11px;
  background: var(--tag);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 20px;
  margin-right: 6px;
}
.tag-alt { color: #ffb86b; }
.detail-card h2 { margin: 10px 0 6px; font-size: 20px; }
.muted { color: var(--muted); font-size: 13px; }

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 20px 0;
}
.info {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.info span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.info b { font-size: 13px; font-weight: 600; }

.detail-card h3 { font-size: 14px; margin: 8px 0 12px; }
.hint { color: var(--muted); font-weight: 400; font-size: 12px; }

/* Checklist */
.checklist { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.checklist li {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 13.5px;
  transition: 0.15s;
}
.checklist li:hover { border-color: var(--accent); }
.checklist .box {
  width: 20px; height: 20px; border-radius: 6px;
  border: 1.5px solid var(--muted);
  display: grid; place-items: center;
  font-size: 13px; flex-shrink: 0;
}
.checklist li.done .box { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.checklist li.done { color: var(--text); }

/* Lifecycle pipeline */
.lifecycle {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 14px;
}
.stage {
  flex: 1 0 110px;
  min-width: 110px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 10px 12px;
  cursor: pointer;
  position: relative;
  transition: 0.15s;
}
.stage:hover { border-color: var(--accent); }
.stage.selected { outline: 2px solid var(--accent); }
.stage .st-num {
  font-size: 10px; color: var(--muted);
  display: flex; justify-content: space-between; align-items: center;
}
.stage .st-name { font-size: 12px; font-weight: 600; margin-top: 6px; line-height: 1.3; }
.stage .st-status {
  font-size: 10.5px; margin-top: 8px; display: inline-block;
  padding: 2px 8px; border-radius: 10px;
}
.stage.approved { border-color: var(--accent-2); }
.stage.approved .st-status { background: rgba(46,160,67,.15); color: var(--accent-2); }
.stage.active { border-color: var(--accent); background: #1a2336; }
.stage.active .st-status { background: rgba(110,139,255,.18); color: var(--accent); }
.stage.locked { opacity: .55; }
.stage.locked .st-status { background: var(--tag); color: var(--muted); }
.stage .dot { font-size: 13px; }

/* Stage panel (artifact + approve) */
.stage-panel {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 18px;
}
.stage-panel h4 { font-size: 13px; margin-bottom: 6px; }
.stage-panel p { font-size: 13px; color: var(--muted); line-height: 1.5; }
.stage-panel .approve-btn {
  margin-top: 12px;
  background: var(--accent-2); color: #07140b; border: none;
  font-weight: 700; font-size: 13px; padding: 9px 16px;
  border-radius: 9px; cursor: pointer;
}
.stage-panel .approve-btn:disabled { background: var(--tag); color: var(--muted); cursor: not-allowed; }
.stage-panel .meta { font-size: 11px; color: var(--accent-2); margin-top: 8px; }

/* Launch */
.launch-row { display: flex; align-items: center; gap: 14px; margin-top: 22px; flex-wrap: wrap; }
.launch-btn, .validate-btn {
  border: none;
  font-weight: 700;
  font-size: 14px;
  padding: 12px 22px;
  border-radius: 10px;
  cursor: pointer;
  transition: 0.15s;
}
.launch-btn { background: var(--accent); color: #0b0f17; }
.validate-btn { background: #ffb86b; color: #1a1206; }
.deploy-btn { background: #2ea043; color: #04140a; }
.launch-btn:hover:not(:disabled), .validate-btn:hover:not(:disabled), .deploy-btn:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
.launch-btn:disabled, .validate-btn:disabled, .deploy-btn:disabled { background: var(--tag); color: var(--muted); cursor: not-allowed; }

/* Validation engine badge */
.engine {
  font-size: 11.5px; color: #7ee787; margin: 6px 0;
}
.engine b { color: #7ee787; }

/* Deploy log */
.deploy-log {
  background: #0a0e14; color: #9bd1ff;
  padding: 12px; border-radius: 8px; margin-top: 10px;
  font-size: 12px; white-space: pre-wrap; overflow-x: auto;
  max-height: 280px; overflow-y: auto;
}

/* Validation checks */
.checks { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.checks .chk {
  font-size: 12.5px; display: flex; align-items: center; gap: 8px;
  background: #0a0e14; border-radius: 8px; padding: 7px 10px;
}
.checks .chk.pass { color: #7ee787; }
.checks .chk.fail { color: var(--danger); }

/* Audit trail */
.audit { list-style: none; margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.audit li {
  font-size: 12px; color: var(--muted);
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 11px;
  display: flex; gap: 10px;
}
.audit li .who { color: var(--accent); font-weight: 600; }
.audit li .when { margin-left: auto; opacity: .7; }

/* Result */
.result {
  margin-top: 20px;
  background: var(--panel-2);
  border: 1px solid var(--accent-2);
  border-radius: 12px;
  padding: 16px;
}
.result h4 { margin-bottom: 8px; }
.result code {
  display: block;
  background: #0a0e14;
  padding: 8px 12px;
  border-radius: 8px;
  margin: 8px 0;
  font-size: 12.5px;
  color: #7ee787;
}
.result details { margin-top: 8px; }
.result summary { cursor: pointer; color: var(--accent); font-size: 13px; }
.result pre {
  background: #0a0e14;
  padding: 12px;
  border-radius: 8px;
  margin-top: 8px;
  font-size: 12px;
  overflow-x: auto;
  white-space: pre-wrap;
  color: var(--muted);
}
