/* HJS OS — neon Mission Control, theme-switchable (James, 2026-09-25).
   All colour lives in CSS custom properties on :root; a `data-theme`
   attribute on <html> selects one of three palettes (see the blocks below).
   Component rules below reference --accent (primary neon), --accent-2
   (secondary neon) and the fixed state colours (--state-*), never a raw
   colour, so a fourth theme is one new :root[data-theme="..."] block plus a
   line in README.md — nothing else changes. State colours (green=running/
   live, amber=waiting, red=failed/alert) are IDENTICAL across every theme.
   Every theme keeps white-on-black-ish text at WCAG AA (checked below). */

/* ---- Theme 1 (DEFAULT): "HJS Neon" — hjsapps24.store black+cyan base with
   the Mission Control purple as the secondary accent. ---- */
:root, :root[data-theme="hjs-neon"]{
  color-scheme: dark;
  --bg:#000000; --surface:rgba(16,16,20,.78); --surface-2:rgba(26,25,34,.9); --border:#2a2836;
  --text:#ffffff; --text-dim:#b9b9c2; --text-faint:#82818c;
  --accent:#2fabdc; --accent-bright:#5fd4ff; --accent-2:#c084fc; --accent-2-bright:#d9adff;
  --glow-accent: 0 0 12px rgba(47,171,220,.55);
  --glow-accent-2: 0 0 14px rgba(192,132,252,.5);
}

/* ---- Theme 2: "HJSAPPS" — the pure black + cyan shop palette (mono-cyan,
   no purple at all). ---- */
:root[data-theme="hjsapps"]{
  color-scheme: dark;
  --bg:#000000; --surface:rgba(15,15,15,.78); --surface-2:rgba(24,24,24,.9); --border:#262626;
  --text:#ffffff; --text-dim:#b7b7b7; --text-faint:#7d7d7d;
  --accent:#2fabdc; --accent-bright:#5fd4ff; --accent-2:#2fabdc; --accent-2-bright:#5fd4ff;
  --glow-accent: 0 0 12px rgba(47,171,220,.55);
  --glow-accent-2: 0 0 12px rgba(47,171,220,.4);
}

/* ---- Theme 3: "Agent OS" — the original purple control-room palette from
   the reference artifact (mission-control-artifact-v11.html). ---- */
:root[data-theme="agent-os"]{
  color-scheme: dark;
  --bg:#07040d; --surface:rgba(28,20,44,.75); --surface-2:rgba(38,28,58,.88); --border:#332a4a;
  --text:#f6f0ff; --text-dim:#c3b8dc; --text-faint:#8b7fa8;
  --accent:#c084fc; --accent-bright:#d9adff; --accent-2:#ff5ec4; --accent-2-bright:#ff8ad8;
  --glow-accent: 0 0 14px rgba(192,132,252,.55);
  --glow-accent-2: 0 0 14px rgba(255,94,196,.5);
}

/* ---- Fixed across every theme: state colours (never remapped) ---- */
:root{
  --state-green:#4bcf8f; --state-amber:#f0a03c; --state-red:#ff5757; --state-yellow:#e8cf5a;
  --shadow: 0 1px 2px rgba(0,0,0,.6), 0 20px 60px -20px rgba(0,0,0,.9);
  --font-display:'Inter', system-ui, sans-serif;
  --font-head:'Orbitron', var(--font-display);
  --font-mono:'IBM Plex Mono', ui-monospace, monospace;
}

*{box-sizing:border-box}
[hidden]{display:none !important}
html,body{height:100%}
body{
  margin:0; background:var(--bg); color:var(--text); font-family:var(--font-display);
  -webkit-font-smoothing:antialiased; overflow-x:hidden;
}
#bg-grid{position:fixed; inset:0; z-index:0; pointer-events:none}
a{color:var(--accent)}
.mono{font-family:var(--font-mono)}

.glass{
  background:var(--surface); border:1px solid var(--border); border-radius:14px;
  backdrop-filter:blur(14px); box-shadow:var(--shadow), 0 0 24px -14px var(--accent);
}

/* login */
.login-wrap{position:relative; z-index:1; min-height:100vh; display:flex; align-items:center; justify-content:center; padding:16px}
.login-card{width:100%; max-width:380px; padding:28px; display:flex; flex-direction:column; gap:16px}
.login-card .brand{display:flex; align-items:baseline; gap:10px; margin-bottom:6px}
.login-card label{display:flex; flex-direction:column; gap:6px; font-size:12.5px; color:var(--text-dim)}
.login-card input{
  background:var(--surface-2); border:1px solid var(--border); border-radius:8px; color:var(--text);
  padding:10px 12px; font-size:14px; font-family:var(--font-display);
}
.login-card input:focus{outline:none; border-color:var(--accent); box-shadow:var(--glow-accent)}
#login-form, #totp-form{display:flex; flex-direction:column; gap:14px}
.form-error{color:var(--state-red); font-size:12.5px}
#totp-qr{width:180px; height:180px; align-self:center; border-radius:10px; background:#fff; padding:8px}
.hint{font-size:12.5px; color:var(--text-faint); line-height:1.5}

.btn-neon, .btn-neon-sm{
  font-family:var(--font-display); font-weight:600; color:#04141a; cursor:pointer;
  background:linear-gradient(120deg, var(--accent), var(--accent-2));
  border:none; border-radius:9px; padding:11px 18px; font-size:14px;
  box-shadow:var(--glow-accent-2);
  transition:filter .15s ease, transform .1s ease;
}
.btn-neon-sm{padding:6px 14px; font-size:12.5px; border-radius:7px}
.btn-neon:hover, .btn-neon-sm:hover{filter:brightness(1.15)}
.btn-neon:active, .btn-neon-sm:active{transform:scale(.98)}
.btn-neon-sm.danger{background:linear-gradient(120deg, var(--state-red), #ff8a5c)}

/* app shell */
#app-view{position:relative; z-index:1}
header.bar{
  position:sticky; top:0; z-index:5; margin:12px; padding:12px 16px;
  display:flex; flex-wrap:wrap; align-items:center; gap:10px 14px;
}
.brand{display:flex; align-items:baseline; gap:10px; margin-right:auto}
.brand .mark{
  font-family:var(--font-head); font-weight:700; font-size:12px; letter-spacing:.08em;
  color:var(--accent); border:1px solid var(--accent); border-radius:6px; padding:3px 8px;
  box-shadow:var(--glow-accent);
}
.brand h1{font-size:16px; font-weight:600; margin:0}
.chip{
  font-family:var(--font-mono); font-size:11.5px; color:var(--text-dim);
  background:var(--surface-2); border:1px solid var(--border); border-radius:20px;
  padding:5px 12px; white-space:nowrap; display:inline-flex; align-items:center; gap:6px;
}
.chip-btn{cursor:pointer; color:var(--text)}
.chip-btn:hover{border-color:var(--accent)}
.dot{width:7px; height:7px; border-radius:50%; background:var(--state-green); box-shadow:0 0 6px var(--state-green); flex:none}
.dot.stale{background:var(--text-faint); box-shadow:none}
.dot.err{background:var(--state-red); box-shadow:0 0 6px var(--state-red)}

select#theme-select, select#unit-select{
  font-family:var(--font-mono); font-size:11.5px; color:var(--text);
  background:var(--surface-2); border:1px solid var(--border); border-radius:20px;
  padding:5px 10px; cursor:pointer;
}
select#theme-select:focus, select#unit-select:focus{outline:none; border-color:var(--accent)}

.view-tabs{display:flex; gap:8px; margin:0 12px 12px}
.view-tab{
  font-family:var(--font-display); font-size:12.5px; font-weight:600; color:var(--text-dim);
  background:var(--surface); border:1px solid var(--border); border-radius:20px; padding:7px 16px; cursor:pointer;
}
.view-tab.active{color:#04141a; background:linear-gradient(120deg, var(--accent), var(--accent-2)); border-color:transparent; box-shadow:var(--glow-accent-2)}

main{max-width:1180px; margin:0 auto; padding:0 12px 40px; display:flex; flex-direction:column; gap:26px}
section{display:flex; flex-direction:column; gap:12px}
.section-head{display:flex; align-items:baseline; gap:10px; justify-content:space-between; flex-wrap:wrap}
.section-head h2{font-size:13px; text-transform:uppercase; letter-spacing:.08em; color:var(--text-dim); font-weight:700; margin:0}
.count{font-family:var(--font-mono); font-size:12px; color:var(--text-faint); margin-right:auto}

/* hero status strip */
.stat-strip{display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:12px}
.stat-tile{
  padding:16px 18px; border-radius:14px; background:var(--surface); border:1px solid var(--border);
  backdrop-filter:blur(14px); position:relative; overflow:hidden;
  box-shadow:0 0 0 1px rgba(255,255,255,.02) inset, 0 0 18px -6px var(--accent);
  transition:box-shadow .2s ease, transform .15s ease;
}
.stat-tile:hover{transform:translateY(-2px); box-shadow:0 0 0 1px rgba(255,255,255,.03) inset, 0 0 26px -4px var(--accent)}
.stat-tile .stat-value{font-family:var(--font-head); font-size:30px; font-weight:800; color:var(--text); line-height:1; text-shadow:0 0 18px currentColor}
.stat-tile .stat-label{margin-top:6px; font-size:11px; letter-spacing:.06em; text-transform:uppercase; color:var(--text-faint)}
.stat-tile.accent-running .stat-value{color:var(--state-green)}
.stat-tile.accent-waiting .stat-value{color:var(--state-amber)}
.stat-tile.accent-snags .stat-value{color:var(--state-red)}
.stat-tile.accent-now .stat-value{color:var(--accent-bright)}

.list{display:flex; flex-direction:column; gap:8px}
.list-item{
  padding:12px 14px; border-radius:10px; background:var(--surface);
  border:1px solid color-mix(in srgb, var(--accent) 20%, var(--border));
  box-shadow:0 0 14px -10px var(--accent);
  font-size:13px; line-height:1.5; cursor:pointer;
  transition:border-color .15s ease, box-shadow .15s ease, transform .1s ease;
}
.list-item:hover{border-color:var(--accent); box-shadow:0 0 16px -4px var(--accent); transform:translateX(2px)}
.list-item .tag{font-family:var(--font-mono); font-size:10.5px; color:var(--accent); margin-right:8px}
.list-item.unparsed{border-style:dashed; color:var(--text-faint); box-shadow:none}
.list-item.sev-red{border-left:3px solid var(--state-red)}
.list-item.sev-orange{border-left:3px solid var(--state-amber)}
.list-item.sev-yellow{border-left:3px solid var(--state-yellow)}
.list-item.sev-green{border-left:3px solid var(--state-green)}
.list-item.is-done{opacity:.55}
.list-item .lead-text{display:block}
.list-item .full-text{display:none; margin-top:6px; color:var(--text-dim); white-space:pre-wrap}
.list-item.expanded .full-text{display:block}
.list-item.expanded .lead-text{display:none}
.list-item .expand-hint{font-size:10.5px; color:var(--text-faint); margin-left:6px}

.card-grid{display:grid; grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); gap:12px}
.dept-card{
  padding:14px; border-radius:12px; background:var(--surface);
  border:1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  box-shadow:0 0 16px -10px var(--accent);
  display:flex; flex-direction:column; gap:8px; cursor:pointer;
  transition:border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.dept-card:hover{border-color:var(--accent-2); box-shadow:var(--glow-accent-2); transform:translateY(-2px)}
.dept-card.running{border-color:var(--state-green); box-shadow:0 0 16px rgba(75,207,143,.35)}
.dept-card.empty{align-items:center; justify-content:center; color:var(--text-faint); font-size:12.5px; cursor:default}
.dept-card.empty:hover{border-color:var(--border); box-shadow:none}
.dept-card .dept-head{display:flex; align-items:center; justify-content:space-between}
.dept-card .dept-name{font-weight:700; font-size:14px}
.dept-card .dept-role{font-size:11px; color:var(--text-faint)}
.dept-card .dept-status{font-family:var(--font-mono); font-size:11px; color:var(--text-dim)}
.dept-card .dept-log{font-family:var(--font-mono); font-size:10.5px; color:var(--text-faint); max-height:60px; overflow:hidden}

.outbox-textarea{
  width:100%; resize:vertical; min-height:60px; background:var(--surface-2); border:1px solid var(--border);
  border-radius:8px; color:var(--text); font-family:var(--font-display); font-size:13px; padding:10px 12px;
}
.outbox-textarea:focus{outline:none; border-color:var(--accent); box-shadow:var(--glow-accent)}
.outbox-actions{display:flex; align-items:center; justify-content:flex-end; gap:10px}
.outbox-status{font-size:11.5px; color:var(--text-faint); margin-right:auto}

.modal-overlay{position:fixed; inset:0; background:rgba(0,0,0,.75); display:flex; align-items:center; justify-content:center; padding:16px; z-index:50}
.modal-overlay[hidden]{display:none}
.modal-box{width:100%; max-width:480px; padding:18px; display:flex; flex-direction:column; gap:14px}
.modal-box h3{font-size:13px; text-transform:uppercase; letter-spacing:.06em; color:var(--text-dim); margin:0}
.modal-box label{display:flex; flex-direction:column; gap:6px; font-size:12px; color:var(--text-dim)}
.modal-box select{background:var(--surface-2); border:1px solid var(--border); border-radius:8px; color:var(--text); padding:8px}
.modal-actions{display:flex; align-items:center; justify-content:flex-end; gap:10px}
.modal-cancel-btn{font-size:12.5px; font-weight:600; color:var(--text-dim); background:transparent; border:1px solid var(--border); border-radius:7px; padding:7px 16px; cursor:pointer}
.modal-status{font-size:11.5px; color:var(--text-faint); margin-right:auto}

#job-panel{padding:14px; display:flex; flex-direction:column; gap:10px}
.job-panel-head{display:flex; align-items:center; justify-content:space-between; font-size:12.5px; color:var(--text-dim)}
.job-log{
  font-family:var(--font-mono); font-size:11.5px; color:var(--state-green); background:#020204;
  border-radius:8px; padding:12px; max-height:280px; overflow:auto; white-space:pre-wrap; margin:0;
}

/* radial map */
#radial-map{width:100%; height:auto; max-height:460px}
.mc-radial-line{stroke:var(--border); stroke-width:1.6; fill:none}
.mc-radial-line.flow{stroke:var(--accent); stroke-dasharray:6 6; animation:mc-flow 1.4s linear infinite}
@keyframes mc-flow{to{stroke-dashoffset:-24}}
.mc-radial-label{font:600 10px var(--font-mono); fill:var(--text-faint); text-anchor:middle}
.mc-radial-hub circle.body{fill:var(--surface-2); stroke:var(--accent-2); stroke-width:2; filter:drop-shadow(var(--glow-accent-2))}
.mc-radial-hub .pulse{fill:none; stroke:var(--state-green); stroke-width:1.4; animation:mc-ping 2.2s ease-out infinite}
@keyframes mc-ping{0%{opacity:.9; transform:scale(.6)} 100%{opacity:0; transform:scale(1.7)}}
.mc-radial-hub text{fill:var(--text); text-anchor:middle}
.mc-radial-hub .title{font:800 16px var(--font-head)}
.mc-radial-hub .sub{font:600 9px var(--font-mono); fill:var(--text-faint); letter-spacing:.06em}
.mc-radial-node rect{fill:var(--surface); stroke:var(--border); stroke-width:1.4; rx:10}
.mc-radial-node.running rect{stroke:var(--state-green); filter:drop-shadow(0 0 8px rgba(75,207,143,.6))}
.mc-radial-node text{fill:var(--text); text-anchor:middle}
.mc-radial-node .name{font:700 12px var(--font-display)}
.mc-radial-node .tag{font:600 9px var(--font-mono); fill:var(--text-faint)}
.mc-radial-node.clickable{cursor:pointer}
.mc-radial-node.clickable:hover rect{stroke:var(--accent); filter:drop-shadow(var(--glow-accent))}

#toast-root{position:fixed; bottom:16px; right:16px; z-index:60; display:flex; flex-direction:column; gap:8px}
.toast{padding:10px 16px; border-radius:10px; font-size:12.5px; background:var(--surface); border:1px solid var(--accent); box-shadow:var(--glow-accent); color:var(--text); max-width:320px; animation:toast-in .2s ease}
@keyframes toast-in{from{opacity:0; transform:translateY(8px)} to{opacity:1; transform:translateY(0)}}

/* ---------- Team view: the "space" home screen (v1.2) ---------- */
.team-space{
  position:relative; min-height:72vh; border-radius:18px; overflow:hidden;
  transition:margin-right .25s ease;
  background:
    radial-gradient(ellipse 60% 50% at 25% 20%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 60%),
    radial-gradient(ellipse 55% 45% at 80% 78%, color-mix(in srgb, var(--accent-2) 18%, transparent), transparent 55%),
    #000;
  border:1px solid var(--border);
}
#space-bg{position:absolute; inset:0; width:100%; height:100%}
#team-orbits{position:absolute; inset:0}

.orbit-hub{
  position:absolute; left:50%; top:50%; transform:translate(-50%,-50%);
  text-align:center; cursor:pointer; z-index:2;
}
.orbit-hub img{
  width:104px; height:104px; border-radius:50%; object-fit:cover;
  border:3px solid var(--accent-2); box-shadow:0 0 34px -4px var(--accent-2), 0 0 60px -20px var(--accent);
  transition:transform .2s ease;
}
.orbit-hub:hover img{transform:scale(1.06)}
.orbit-hub .orbit-name{font-family:var(--font-head); font-weight:800; font-size:13px; margin-top:6px; color:var(--text)}
.orbit-hub .orbit-role{font-size:10px; color:var(--text-faint); letter-spacing:.05em; text-transform:uppercase}

.orbit-node{
  position:absolute; width:88px; text-align:center; cursor:pointer;
  transform:translate(-50%,-50%); transition:transform .2s ease, filter .2s ease;
}
.orbit-node:hover{transform:translate(-50%,-50%) scale(1.12); z-index:3}
.orbit-node img{
  width:60px; height:60px; border-radius:50%; object-fit:cover;
  border:2px solid var(--border); box-shadow:0 0 14px -6px var(--accent);
  transition:border-color .2s ease, box-shadow .2s ease;
}
.orbit-node .orbit-name{font-size:11px; font-weight:700; margin-top:5px; color:var(--text)}
.orbit-node .orbit-role{font-size:9px; color:var(--text-faint)}
.orbit-node.status-running img{border-color:var(--state-green); box-shadow:0 0 18px var(--state-green); animation:orbit-pulse 1.4s ease-in-out infinite}
.orbit-node.status-waiting img{border-color:var(--state-amber); box-shadow:0 0 14px var(--state-amber)}
.orbit-node.status-failed img{border-color:var(--state-red); box-shadow:0 0 14px var(--state-red)}
@keyframes orbit-pulse{0%,100%{filter:brightness(1)} 50%{filter:brightness(1.35)}}

/* ---------- Chat side panel ---------- */
.chat-panel{
  position:fixed; top:0; right:0; height:100vh; width:380px; max-width:94vw; z-index:45;
  display:flex; flex-direction:column; border-radius:0; border-left:1px solid var(--border);
  padding:14px; gap:10px; box-shadow:-20px 0 60px -20px rgba(0,0,0,.8), 0 0 40px -10px var(--accent);
}
.chat-head{display:flex; align-items:center; gap:10px}
.chat-portrait{width:44px; height:44px; border-radius:50%; object-fit:cover; border:2px solid var(--accent); flex:none}
.chat-head-text{flex:1; min-width:0}
.chat-name{font-weight:700; font-size:14px}
.chat-role{font-size:11px; color:var(--text-faint)}
.chat-messages{flex:1; overflow-y:auto; display:flex; flex-direction:column; gap:8px; padding-right:4px}
.chat-msg{padding:9px 11px; border-radius:11px; font-size:12.5px; line-height:1.45; max-width:88%; white-space:pre-wrap}
.chat-msg.user{align-self:flex-end; background:linear-gradient(120deg, var(--accent), var(--accent-2)); color:#04141a}
.chat-msg.assistant{align-self:flex-start; background:var(--surface-2); border:1px solid var(--border); color:var(--text)}
.chat-job-offer{
  display:flex; align-items:center; justify-content:space-between; gap:8px; padding:8px 10px;
  border-radius:8px; background:var(--surface-2); border:1px solid var(--state-amber); font-size:12px; color:var(--text-dim);
}
.chat-form{display:flex; gap:6px; align-items:center}
.chat-form input{
  flex:1; background:var(--surface-2); border:1px solid var(--border); border-radius:8px;
  padding:9px 11px; color:var(--text); font-size:13px;
}
.chat-form input:focus{outline:none; border-color:var(--accent)}
#chat-mic-btn.recording{background:var(--state-red); color:#fff; border-color:var(--state-red)}

@media (min-width: 900px){
  /* The chat panel is a fixed overlay, so on desktop it covers the orbit
     unless the space shrinks to make room (Boss, 2026-09-25). */
  #view-team.chat-open .team-space{margin-right:380px}
}
@media (max-width: 640px){
  .chat-panel{width:100vw}
  .team-space{min-height:60vh}
}

@media (prefers-reduced-motion: reduce){
  .orbit-node.status-running img{animation:none}
  .mc-radial-hub .pulse, .mc-radial-line.flow{animation:none}
  .toast{animation:none}
}
@media (max-width: 640px){
  main{padding:0 8px 32px}
  header.bar{margin:8px}
  .card-grid{grid-template-columns:1fr 1fr}
}

/* v1.5: header gauge chips (usage meter + Max's context gauge) */
.gauge-chip{cursor:default}
.gauge-chip[data-level="amber"] .dot{background:var(--state-amber); box-shadow:0 0 6px var(--state-amber)}
.gauge-chip[data-level="red"] .dot{background:var(--state-red); box-shadow:0 0 6px var(--state-red)}

.bookoff-banner{
  position:fixed; top:14px; left:50%; transform:translateX(-50%); z-index:60;
  display:flex; align-items:center; gap:10px; padding:10px 14px; border-radius:12px;
  background:var(--surface); border:1px solid var(--state-red); box-shadow:0 0 20px rgba(255,87,87,.35);
  font-size:12.5px; color:var(--text);
}
.bookoff-banner[hidden]{display:none}

/* v3: engines popover */
.engines-list{display:flex; flex-direction:column; gap:12px; max-height:50vh; overflow-y:auto}
.engine-row{border:1px solid var(--border); border-radius:10px; padding:10px; font-size:12.5px}
.engine-badge{padding:2px 8px; border-radius:999px; font-size:11px; text-transform:uppercase; letter-spacing:.04em}
.engine-badge.engine-ok{background:rgba(75,207,143,.18); color:var(--state-green)}
.engine-badge.engine-off{background:rgba(240,160,60,.18); color:var(--state-amber)}
.engine-steps{margin:8px 0 0; padding-left:18px; color:var(--text-dim); font-size:11.5px; line-height:1.5}

.chat-msg.system{align-self:center; background:transparent; border:1px dashed var(--border); color:var(--text-faint); font-size:11.5px; text-align:center}
