:root {
  --bg: #0b0f1a;
  --bg-elev: #111827;
  --bg-elev-2: #1a2234;
  --border: #243049;
  --text: #e5e9f0;
  --muted: #8b98ad;
  --accent: #38bdf8;
  --accent-dim: #0ea5e9;
  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;
  --orange: #fb923c;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
body {
  margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; min-height: 100vh;
}
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---- login ---- */
.login-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { width: 400px; max-width: 92vw; }
.login-brand { justify-content: center; margin-bottom: 8px; }
.login-brand .brand-name { font-size: 22px; }
.login-card form { display: flex; flex-direction: column; }
.login-card label { margin: 14px 0 5px; font-size: 13px; color: var(--muted); }
.login-card input[type=text], .login-card input[type=password] {
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 10px 12px; font-size: 14px;
}
.login-card input:focus { outline: none; border-color: var(--accent-dim); }
.btn-block { width: 100%; margin-top: 18px; padding: 12px; }

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 12px 20px; background: var(--bg-elev); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; }
.logo { color: var(--accent); font-size: 20px; }
.brand-name { font-weight: 700; font-size: 16px; }

.stage-nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.stage-nav-btn {
  background: none; border: none; color: var(--muted); padding: 8px 14px;
  cursor: pointer; font-size: 13px; border-radius: 6px; white-space: nowrap;
}
.stage-nav-btn:hover { color: var(--text); background: var(--bg-elev-2); }
.stage-nav-btn.active { color: var(--accent); background: var(--bg-elev-2); }
.topbar-right { display: flex; align-items: center; gap: 12px; }

/* ---- main ---- */
.stage-main { max-width: 1080px; margin: 0 auto; padding: 24px 28px 60px; }
.stage-head h1 { margin: 0 0 4px; font-size: 24px; }
.stage-head p { margin: 0 0 18px; }

/* ---- coach panel (handholding) ---- */
.coach {
  background: linear-gradient(180deg, #12203a, #111827);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 16px;
}
.coach-title {
  text-transform: uppercase; font-size: 11px; letter-spacing: .08em;
  color: var(--accent); font-weight: 700; margin-bottom: 4px;
}
.coach-body { margin: 0 0 12px; font-size: 13.5px; line-height: 1.55; color: var(--text); }
.coach-body:last-child { margin-bottom: 0; }

.target-bar {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 16px; margin-bottom: 18px;
}
.target-label { text-transform: uppercase; font-size: 11px; letter-spacing: .06em; color: var(--muted); }
.cmd-input {
  flex: 1; background: var(--bg-elev-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 6px; padding: 10px 12px; font-size: 13px; font-family: var(--mono);
}
.cmd-input:focus { outline: none; border-color: var(--accent-dim); }
#target-carry { font-size: 12px; }

/* ---- buttons ---- */
.button-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; margin-bottom: 18px; }
.hack-btn {
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 14px; cursor: pointer; text-align: left; transition: border-color .12s;
}
.hack-btn:hover { border-color: var(--accent-dim); }
.hack-btn .bt-label { font-weight: 600; margin-bottom: 3px; }
.hack-btn .bt-tool { font-size: 11px; color: var(--muted); font-family: var(--mono); }
.hack-btn.confirm { border-color: var(--amber); }
.hack-btn.confirm .bt-flag { color: var(--amber); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }

/* ---- console ---- */
.console-toolbar { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 8px; }
.console {
  background: #060913; border: 1px solid var(--border); border-radius: 8px;
  padding: 14px; min-height: 200px; max-height: 400px; overflow-y: auto;
  font-size: 12.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
}

.promote-row { margin-top: 14px; text-align: right; }

/* ---- history ---- */
.history { margin-top: 28px; }
.history-title { text-transform: uppercase; font-size: 11px; letter-spacing: .08em; color: var(--muted); margin-bottom: 10px; }
.history-row {
  display: grid; grid-template-columns: 150px 110px 80px 1fr;
  gap: 10px; font-family: var(--mono); font-size: 12px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 6px;
  padding: 7px 12px; margin-bottom: 4px;
}
.history-row .h-ts { color: var(--muted); }
.history-row .h-stage { color: var(--accent); }
.history-row .h-cmd { word-break: break-all; }
.history-row.expandable { cursor: pointer; }
.history-row.expandable:hover { border-color: var(--accent-dim); }
.history-detail {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 10px 14px;
  margin: -6px 0 8px 0;
}
.detail-command { font-size: 12px; color: var(--accent); margin-bottom: 4px; }
.detail-meta-line { font-size: 11px; margin-bottom: 8px; }
.detail-output {
  font-size: 12px; line-height: 1.5; color: var(--text);
  background: #060913; border: 1px solid var(--border); border-radius: 6px;
  padding: 10px; white-space: pre-wrap; word-break: break-word;
  max-height: 320px; overflow-y: auto; margin: 0;
}

/* ---- exploit suggestions ---- */
.suggest { padding: 12px 14px; margin-bottom: 10px; }
.suggest-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.suggest-exploits { display: flex; flex-direction: column; gap: 8px; }
.suggest-exploit {
  background: var(--bg-elev-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px;
  display: grid; grid-template-columns: 1fr; gap: 4px;
}
.suggest-exploit-name { font-weight: 600; font-size: 13px; }
.suggest-cmd { font-size: 12px; word-break: break-all; margin-bottom: 6px; }
.suggest-exploit .btn-exploit { justify-self: start; }

/* ---- guided engagement wizard ---- */
.wizard {
  background: linear-gradient(180deg, #14233c, #111827);
  border: 1px solid var(--accent-dim);
  border-radius: 12px;
  margin-bottom: 16px;
  overflow: hidden;
}
.wizard-head {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: rgba(14, 165, 233, .08);
  border-bottom: 1px solid var(--border);
}
.wizard-title { font-weight: 700; color: var(--accent); }
.wizard-head .muted { margin-left: auto; font-size: 12px; }
.btn-sm { padding: 3px 9px; font-size: 12px; border-radius: 6px; }
.wizard-body { padding: 14px 18px 16px; }
.wizard-step-title { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.wizard-why { margin: 0 0 8px; line-height: 1.55; }
.wizard-expect { margin: 0 0 10px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.wizard-cmd { margin-bottom: 10px; font-size: 12px; color: var(--muted); }
.wizard-cmd code { display: block; margin-top: 6px; background: #060913; border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; word-break: break-all; }
.wizard-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.wizard-choices { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.wizard-choice {
  background: var(--bg-elev-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 5px;
}
.wizard-choice.recommended {
  border-color: var(--green);
  box-shadow: 0 0 0 1px var(--green), 0 0 18px rgba(52, 211, 153, .15);
}
.wizard-rec {
  color: var(--green); font-size: 12px; font-weight: 600;
  background: rgba(52, 211, 153, .08);
  border-radius: 6px; padding: 5px 8px; line-height: 1.45;
}
.wizard-choice-name { font-weight: 600; font-size: 13.5px; }
.wizard-choice .btn { align-self: flex-start; margin-top: 4px; }
.wizard input.cmd-input { width: 100%; margin-bottom: 8px; }
.wizard-warn {
  color: var(--amber); font-size: 12px; line-height: 1.5;
  background: rgba(251, 191, 36, .07);
  border: 1px solid rgba(251, 191, 36, .35);
  border-radius: 6px; padding: 6px 9px;
}
.wizard-warn.banner { margin-bottom: 10px; font-weight: 600; }

/* ---- live shell ---- */
.shell-box {
  background: #060913;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.shell-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 14px;
  background: rgba(14, 165, 233, .07);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.shell-scroll {
  height: 340px;
  overflow-y: auto;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
}
.shell-out {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text);
  flex: 1;
}
.shell-line { display: flex; align-items: center; gap: 2px; margin-top: 6px; }
.shell-prompt { color: var(--green); font-size: 12.5px; white-space: pre; }
.shell-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 12.5px;
  font-family: inherit;
  caret-color: var(--green);
}

/* ---- stage progress badges ---- */
.stage-nav-btn.ran::after {
  content: "●";
  color: var(--green);
  font-size: 8px;
  margin-left: 5px;
  vertical-align: 2px;
}

/* ---- overview dashboard ---- */
.dash-card {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dash-big { font-size: 30px; font-weight: 800; color: var(--accent); line-height: 1.1; }
.dash-wide {
  grid-column: 1 / -1;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}
.dash-title { font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.dash-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* ---- misc ---- */
.btn {
  background: var(--bg-elev-2); color: var(--text); border: 1px solid var(--border);
  padding: 8px 14px; border-radius: 7px; cursor: pointer; font-size: 13px; font-weight: 500;
}
.btn:hover { border-color: var(--accent-dim); }
.btn-primary { background: var(--accent); color: #06121f; border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { background: var(--accent-dim); }
.btn-success { background: var(--green); color: #052016; border-color: var(--green); font-weight: 600; }

.ack-check {
  display: flex !important; gap: 10px; align-items: flex-start;
  background: #2a1c0a; border: 1px solid var(--amber); border-radius: 8px;
  padding: 12px; color: var(--amber) !important; margin-top: 16px !important;
}
.ack-check input { margin-top: 2px; }
.ack-check span { line-height: 1.45; color: var(--amber) !important; }

.error { color: var(--red); margin-top: 12px; font-size: 13px; }

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px; padding: 24px; width: 500px; max-width: 92vw; }
.modal-card h2 { margin: 0 0 8px; }
.confirm-cmd { background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: 6px; padding: 12px; font-size: 12px; margin: 12px 0; word-break: break-all; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 100;
  background: var(--bg-elev-2); border: 1px solid var(--border);
  padding: 12px 18px; border-radius: 8px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.toast.error { border-color: var(--red); color: var(--red); }
.toast.ok { border-color: var(--green); }

.spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--muted); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; margin-right: 6px; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }
