/* OSA — fleet control console.
   Deep-space ops surface: cool layered darks, periwinkle for interaction,
   aqua reserved for live link state. Space Grotesk (UI) + JetBrains Mono (data). */

:root {
  --void:   #070a12;
  --panel:  #0d1322;
  --raised: #151d31;
  --raised-2:#1b2539;
  --line:   #243049;
  --line-bright: #33426a;

  --astral: #8b8cff;   /* interactive / primary */
  --astral-soft: #5c5fd6;
  --signal: #4fe3c1;   /* live / online ONLY */
  --amber:  #f3c969;   /* running / warn */
  --rose:   #ff6b86;   /* error / nonzero exit */

  --ink:    #e9edf8;
  --muted:  #97a3c0;
  --faint:  #58647e;

  --sans: "Space Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --r-sm: 8px;
  --r-md: 11px;
  --r-lg: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--void);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: rgba(139,140,255,.3); }

/* faint deep-space field: two drifting glows + a hairline dot grid */
.spacefield {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 500px at 78% -8%, rgba(139,140,255,.10), transparent 60%),
    radial-gradient(700px 500px at 8% 108%, rgba(79,227,193,.07), transparent 60%),
    var(--void);
}
.spacefield::after {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.045) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(120% 120% at 50% 0%, #000 40%, transparent 85%);
}

/* ---------- shared type ---------- */
.wordmark {
  font-weight: 700; letter-spacing: -0.02em; font-size: 19px; color: var(--ink);
}
.wordmark .x { color: var(--astral); }
.kicker { color: var(--faint); font-size: 12.5px; font-weight: 400; }

/* ---------- signal (the one live motif) ---------- */
.signal { position: relative; width: 16px; height: 16px; flex: none; display: inline-grid; place-items: center; }
.signal-core { width: 8px; height: 8px; border-radius: 50%; background: var(--signal); box-shadow: 0 0 10px rgba(79,227,193,.7); }
.signal::before, .signal::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 1.5px solid var(--signal); opacity: 0; animation: ping 2.8s ease-out infinite;
}
.signal::after { animation-delay: 1.4s; }
@keyframes ping { 0% { transform: scale(.4); opacity: .55; } 80%,100% { transform: scale(1.9); opacity: 0; } }

/* ================= LOGIN ================= */
.login {
  min-height: 100vh; display: grid; place-items: center; grid-auto-rows: min-content;
  gap: 16px; padding: 32px 16px;
}
.login-card {
  width: min(380px, 100%);
  background: linear-gradient(180deg, rgba(27,37,57,.55), rgba(13,19,34,.85));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 30px 28px 24px;
  box-shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 30px 70px -20px rgba(0,0,0,.7);
  backdrop-filter: blur(6px);
}
.login-head { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.login-head .wordmark { font-size: 26px; }
.login-title { display: flex; flex-direction: column; line-height: 1.2; }
.login-head .signal { width: 20px; height: 20px; }
.login-head .signal-core { width: 10px; height: 10px; }

.field { display: block; margin-bottom: 15px; }
.field-label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 7px; }

input, select, textarea {
  width: 100%;
  background: var(--void);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 11px 12px;
  font-family: inherit; font-size: 14px; outline: none;
  transition: border-color .14s, box-shadow .14s, background .14s;
}
input::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus {
  border-color: var(--astral); background: #0a1120;
  box-shadow: 0 0 0 3px rgba(139,140,255,.16);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line-bright);
  background: var(--raised);
  color: var(--ink);
  border-radius: var(--r-sm);
  padding: 10px 14px; font-size: 14px; font-family: inherit; font-weight: 500;
  cursor: pointer; user-select: none;
  transition: background .13s, border-color .13s, transform .05s, opacity .13s;
}
.btn:hover { background: var(--raised-2); border-color: var(--line-bright); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary {
  width: 100%; margin-top: 8px;
  background: linear-gradient(180deg, #9a9bff, var(--astral));
  border-color: var(--astral); color: #0a0c1a; font-weight: 600;
  box-shadow: 0 8px 22px -10px rgba(139,140,255,.8);
}
.btn-primary:hover { background: linear-gradient(180deg, #a7a8ff, #8f90ff); }
.btn-sm { padding: 7px 11px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn-danger { color: var(--rose); border-color: #46283a; background: transparent; }
.btn-danger:hover { background: #241521; border-color: #5e3147; }

.form-error { color: var(--rose); font-size: 13px; margin: 13px 0 0; }
.login-foot {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  color: var(--faint); font-size: 12px; margin: 22px 0 0;
}
.lock-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--astral-soft); }
.login-host { font-family: var(--mono); font-size: 12px; color: var(--faint); letter-spacing: .02em; }

/* ================= APP SHELL ================= */
.app { display: grid; grid-template-rows: auto 1fr; height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 18px;
  background: linear-gradient(180deg, var(--panel), rgba(13,19,34,.7));
  border-bottom: 1px solid var(--line);
}
.topbar .signal { width: 14px; height: 14px; }
.topbar .signal-core { width: 7px; height: 7px; }
.topbar .spacer, .spacer { flex: 1; }

.status {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px;
}
.status.live { color: var(--signal); border-color: #1d4a40; background: rgba(79,227,193,.06); }
.status.preview { color: var(--amber); border-color: #4a3f1e; background: rgba(243,201,105,.06); }

.layout { display: grid; grid-template-columns: 296px 1fr; min-height: 0; }
@media (max-width: 880px) { .layout { grid-template-columns: 1fr; } }

/* ---------- node rail ---------- */
.sidebar { border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.sidebar-head { display: flex; align-items: center; gap: 8px; padding: 13px 15px; border-bottom: 1px solid var(--line); }
.sidebar-head h2 { font-size: 13px; font-weight: 500; color: var(--ink); margin: 0; flex: 1; letter-spacing: -0.01em; }
.count-badge { font-size: 11.5px; color: var(--muted); font-family: var(--mono); }
.node-list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 3px; }

.node-row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 11px;
  padding: 10px 11px; border-radius: var(--r-md); cursor: pointer;
  border: 1px solid transparent; transition: background .12s, border-color .12s;
}
.node-row:hover { background: var(--raised); }
.node-row.selected { background: linear-gradient(90deg, rgba(139,140,255,.14), rgba(139,140,255,.04)); border-color: var(--astral-soft); }
.node-row.excluded { opacity: .45; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.online { background: var(--signal); box-shadow: 0 0 9px rgba(79,227,193,.55); }
.dot.offline { background: var(--faint); }
.node-name { font-weight: 500; letter-spacing: -0.01em; }
.node-meta { font-size: 11.5px; color: var(--faint); font-family: var(--mono); margin-top: 1px; }
.node-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 5px; }
.tag { font-size: 10.5px; color: var(--muted); background: var(--void); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; }
.exclude-x { font-size: 11px; color: var(--faint); padding: 2px 7px; border-radius: 6px; border: 1px solid transparent; }
.node-row:hover .exclude-x { border-color: var(--line); }
.node-row.excluded .exclude-x { color: var(--rose); border-color: #46283a; }

/* ---------- console ---------- */
.console { display: flex; flex-direction: column; min-height: 0; }

/* targeting — the hero component */
.targeting { padding: 15px 18px 16px; border-bottom: 1px solid var(--line); background: radial-gradient(600px 160px at 20% 0%, rgba(139,140,255,.06), transparent 70%); }
.target-modes {
  display: inline-flex; gap: 3px; margin-bottom: 13px;
  background: var(--void); border: 1px solid var(--line); border-radius: 10px; padding: 3px;
}
.mode-btn {
  font-size: 12.5px; padding: 7px 14px; border-radius: 7px;
  border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer;
  font-family: inherit; transition: color .12s, background .12s;
}
.mode-btn:hover { color: var(--ink); }
.mode-btn.active { background: var(--astral); color: #0a0c1a; font-weight: 600; box-shadow: 0 6px 16px -8px rgba(139,140,255,.9); }

.target-summary { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.ts-figure { font-family: var(--mono); font-size: 26px; font-weight: 500; color: var(--ink); line-height: 1; letter-spacing: -0.02em; }
.ts-figure.none { color: var(--faint); }
.ts-label { color: var(--muted); }
.ts-live { color: var(--signal); font-size: 12.5px; }
.ts-scope { color: var(--faint); }
.chip { font-size: 11.5px; background: var(--raised); border: 1px solid var(--line-bright); border-radius: 6px; padding: 2px 8px; color: var(--ink); font-family: var(--mono); }
.chip.excl { border-color: #46283a; color: var(--rose); background: rgba(255,107,134,.05); }

.cmd-bar { display: flex; gap: 9px; padding: 13px 18px; border-bottom: 1px solid var(--line); align-items: center; background: var(--panel); }
.cmd-prompt { color: var(--signal); font-family: var(--mono); font-weight: 700; font-size: 15px; }
#cmd-input { font-family: var(--mono); font-size: 13.5px; }
.cmd-bar .btn { white-space: nowrap; }

.panes { display: grid; gap: 13px; padding: 16px 18px; overflow-y: auto; min-height: 0; grid-template-columns: repeat(auto-fill, minmax(372px, 1fr)); align-content: start; }
.empty-state { grid-column: 1 / -1; color: var(--faint); text-align: center; padding: 72px 20px; font-size: 13.5px; }

.pane { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; display: flex; flex-direction: column; }
.pane-head { display: flex; align-items: center; gap: 9px; padding: 10px 13px; border-bottom: 1px solid var(--line); background: var(--raised); }
.pane-head .node-name { font-size: 13px; }
.exit-badge { font-family: var(--mono); font-size: 11px; padding: 2px 9px; border-radius: 6px; border: 1px solid var(--line); color: var(--muted); }
.exit-badge.ok { color: var(--signal); border-color: #1d4a40; background: rgba(79,227,193,.07); }
.exit-badge.err { color: var(--rose); border-color: #46283a; background: rgba(255,107,134,.07); }
.exit-badge.running { color: var(--amber); border-color: #4a3f1e; background: rgba(243,201,105,.07); }
.pane-body {
  font-family: var(--mono); font-size: 12.5px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
  padding: 12px 13px; margin: 0; overflow-y: auto; max-height: 340px; min-height: 92px; color: var(--ink);
}
.pane-body .stderr { color: var(--rose); }
.pane-body .meta { color: var(--faint); }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(6px);
  background: var(--raised-2); border: 1px solid var(--line-bright);
  color: var(--ink); padding: 10px 16px; border-radius: var(--r-sm); font-size: 13px;
  box-shadow: 0 14px 34px rgba(0,0,0,.5); opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(4,6,13,.72); display: none; place-items: center; z-index: 50; padding: 16px; backdrop-filter: blur(2px); }
.modal-backdrop.open { display: grid; }
.modal { width: min(560px, 100%); background: var(--panel); border: 1px solid var(--line-bright); border-radius: var(--r-lg); overflow: hidden; box-shadow: 0 40px 90px -30px rgba(0,0,0,.8); }
.modal-head { display: flex; align-items: center; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; flex: 1; letter-spacing: -0.01em; }
.modal-body { padding: 18px; }
.modal-body p { color: var(--muted); margin-top: 0; }
.code-block { position: relative; background: var(--void); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 13px 44px 13px 13px; font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; word-break: break-all; color: var(--ink); cursor: copy; }
.code-block:hover { border-color: var(--line-bright); }
.copy-btn { position: absolute; top: 8px; right: 8px; }
.warn-note { font-size: 12px; color: var(--amber); border: 1px solid #4a3f1e; background: rgba(243,201,105,.06); border-radius: var(--r-sm); padding: 10px 12px; margin-top: 14px; }
.icon-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 20px; line-height: 1; padding: 2px 8px; border-radius: 6px; }
.icon-btn:hover { color: var(--ink); background: var(--raised); }

/* ---------- a11y / motion / responsive ---------- */
:focus-visible { outline: 2px solid var(--astral); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .signal::before, .signal::after { animation: none; display: none; }
  * { transition: none !important; }
}
@media (max-width: 880px) {
  .sidebar { max-height: 38vh; }
  .target-modes { width: 100%; }
  .mode-btn { flex: 1; }
}
