:root {
  --bg: #0b1220;
  --panel: #111a2e;
  --panel2: #17223a;
  --line: #24314d;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #6366f1;
  --ok: #10b981;
  --warn: #f59e0b;
  --err: #ef4444;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: #fca5a5; min-height: 1em; margin: 6px 0 0; font-size: 13px; }
code { background: #0b1220; padding: 1px 5px; border-radius: 5px; font-size: 12px; }

.topbar { height: 52px; display: flex; align-items: center; gap: 12px; padding: 0 14px; border-bottom: 1px solid var(--line); background: #0d1528; }
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; }
.badge { font-size: 12px; padding: 3px 9px; border-radius: 99px; background: #1e293b; border: 1px solid var(--line); white-space: nowrap; }
.badge.live { background: rgba(16,185,129,.15); border-color: rgba(16,185,129,.5); color: #6ee7b7; }
.badge.sim { background: rgba(245,158,11,.15); border-color: rgba(245,158,11,.5); color: #fcd34d; }
.badge.bad { background: rgba(239,68,68,.15); border-color: rgba(239,68,68,.5); color: #fca5a5; }
.stats { display: flex; gap: 12px; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.spacer { flex: 1; }

.layout { display: grid; grid-template-columns: 1fr 390px; height: calc(100% - 52px); }
.stage { position: relative; min-height: 0; }
#office { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.hint { position: absolute; left: 12px; bottom: 10px; font-size: 12px; color: var(--muted); background: rgba(11,18,32,.7); padding: 4px 10px; border-radius: 99px; pointer-events: none; }
.banner { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); max-width: 90%; background: rgba(239,68,68,.15); border: 1px solid rgba(239,68,68,.5); color: #fecaca; padding: 8px 14px; border-radius: var(--radius); font-size: 13px; }

.panel { border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab { flex: 1; background: none; border: 0; padding: 12px 6px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tabpane { padding: 14px; overflow: auto; flex: 1; display: flex; flex-direction: column; gap: 12px; }

.form { display: flex; flex-direction: column; gap: 10px; }
.form h3 { margin: 4px 0; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #cbd5e1; }
input, select, textarea { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[type="color"] { padding: 2px; height: 38px; }
textarea { resize: vertical; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.row.end { justify-content: flex-end; }
.row.end > * { flex: 0 0 auto; }

.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; cursor: pointer; }
.btn:hover { border-color: #3b4a6b; }
a.btn { color: inherit; text-decoration: none; display: inline-flex; align-items: center; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.danger { border-color: rgba(239,68,68,.6); color: #fca5a5; }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

.explain { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.explain h3 { margin: 4px 0 6px; font-size: 14px; }
.explain ol { margin: 0; padding-left: 18px; }
.explain li { margin: 4px 0; font-size: 13px; }

.list { display: flex; flex-direction: column; gap: 8px; }
.item { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; cursor: pointer; }
.item:hover { border-color: #3b4a6b; }
.item.sel { border-color: #facc15; }
.item-head { display: flex; align-items: center; gap: 8px; }
.item-title { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.item-sub { font-size: 12px; color: var(--muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-actions { display: flex; gap: 6px; margin-top: 8px; }
.empty { color: var(--muted); text-align: center; padding: 20px 0; }

.pill { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: #1e293b; white-space: nowrap; }
.pill.running { background: rgba(99,102,241,.2); color: #c7d2fe; }
.pill.queued { background: rgba(245,158,11,.15); color: #fcd34d; }
.pill.done { background: rgba(16,185,129,.15); color: #6ee7b7; }
.pill.error { background: rgba(239,68,68,.15); color: #fca5a5; }
.pill.cancelled { color: var(--muted); }

.steps { display: flex; gap: 4px; margin-top: 8px; }
.step { flex: 1; height: 5px; border-radius: 3px; background: #1e293b; }
.step.done { background: var(--ok); }
.step.running { background: var(--accent); animation: pulse 1.2s infinite; }
.step.error { background: var(--err); }
@keyframes pulse { 50% { opacity: .45; } }

.detail { display: flex; flex-direction: column; gap: 12px; }
.detail h3 { margin: 0; font-size: 16px; }
.timeline { display: flex; flex-direction: column; gap: 6px; }
.tl { display: flex; align-items: center; gap: 8px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 13px; }
.tl .name { flex: 1; }
.activity { background: #0b1220; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.log { background: #0b1220; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; max-height: 260px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.files { display: flex; flex-direction: column; gap: 6px; }
.file { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.file .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
video { width: 100%; max-height: 420px; background: #000; border-radius: 8px; }

.overlay { position: fixed; inset: 0; background: rgba(2,6,23,.75); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
.login { width: 340px; display: flex; flex-direction: column; gap: 10px; text-align: center; }
.login h1 { margin: 0; font-size: 22px; }
.login .logo { font-size: 42px; }
.viewer { width: min(820px, 100%); max-height: 90vh; display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.viewer-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.viewer pre { margin: 0; overflow: auto; white-space: pre-wrap; word-break: break-word; background: #0b1220; border-radius: 8px; padding: 12px; font: 13px/1.55 ui-monospace, Menlo, monospace; }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 55vh auto; height: auto; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  .stats { display: none; }
  .hint { display: none; }
  .topbar { gap: 8px; padding: 0 10px; }
  .brand span { display: none; }
  #fitBtn { white-space: nowrap; }
}

.ceo-section { display: flex; flex-direction: column; gap: 10px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.ceo-section:last-child { border-bottom: 0; }
.ceo-section h3 { margin: 2px 0 0; font-size: 15px; }
.rule { display: flex; align-items: flex-start; gap: 8px; background: var(--panel2); border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.rule.dont { border-left-color: var(--err); }
.rule.off { opacity: .5; }
.rule .rtext { flex: 1; white-space: pre-wrap; word-break: break-word; }
.rule .rscope { font-size: 11px; color: var(--muted); display: block; margin-top: 2px; }
.rule button { padding: 3px 8px; font-size: 12px; }

.staff-head { display: flex; align-items: center; gap: 12px; }
.staff-avatar { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 24px; flex: 0 0 auto; }
.staff-head h3 { margin: 0; font-size: 16px; }
.directive { display: flex; gap: 8px; align-items: flex-start; background: var(--panel2); border: 1px solid var(--line); border-left: 4px solid #38bdf8; border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.directive span { flex: 1; white-space: pre-wrap; word-break: break-word; }
.directive button { padding: 2px 8px; font-size: 12px; }
