/**
 * Copyright (c) 2014 The xterm.js authors. All rights reserved.
 * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
 * https://github.com/chjj/term.js
 * @license MIT
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * Originally forked from (with the author's permission):
 *   Fabrice Bellard's javascript vt100 for jslinux:
 *   http://bellard.org/jslinux/
 *   Copyright (c) 2011 Fabrice Bellard
 *   The original design remains. The terminal itself
 *   has been extended to include xterm CSI codes, among
 *   other features.
 */.xterm{cursor:text;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{position:absolute;top:0;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#fff;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;right:0;left:0;top:0;bottom:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm .xterm-scroll-area{visibility:hidden}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility,.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:10;color:transparent;pointer-events:none}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1!important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}:root{--bg: #0f1115;--panel: #161a22;--panel-2: #1c212c;--border: #262b36;--text: #e6e8ee;--muted: #8a93a4;--accent: #4f8cff;--accent-2: #2f64c4;--good: #3ec28a;--warn: #e8b440;--bad: #e8625a;--sidebar-w: 220px}[data-theme=light]{--bg: #f5f7fa;--panel: #ffffff;--panel-2: #eef1f6;--border: #d6dae3;--text: #1a1d24;--muted: #6b7280;--accent: #3b6fd6;--accent-2: #284fa2;--good: #128a5b;--warn: #b87900;--bad: #c0382a}html{color-scheme:dark}html[data-theme=light]{color-scheme:light}*{box-sizing:border-box}html,body,#root{height:100%;margin:0}body{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;background:var(--bg);color:var(--text);font-size:14px;line-height:1.4}button{font:inherit;background:var(--panel-2);color:var(--text);border:1px solid var(--border);padding:6px 12px;border-radius:6px;cursor:pointer}button:hover{background:var(--border)}button.primary{background:var(--accent);border-color:var(--accent);color:#fff}button.primary:hover{background:var(--accent-2)}button.danger{background:transparent;border-color:var(--bad);color:var(--bad)}button:disabled{opacity:.5;cursor:not-allowed}input,select,textarea{font:inherit;background:var(--panel);color:var(--text);border:1px solid var(--border);padding:6px 10px;border-radius:6px;width:100%}input:focus,select:focus,textarea:focus{outline:none;border-color:var(--accent)}a{color:var(--accent);text-decoration:none}a:hover{text-decoration:underline}.layout{display:grid;grid-template-columns:var(--sidebar-w) 1fr;height:100vh;transition:grid-template-columns .16s ease}.layout.collapsed{--sidebar-w: 64px}.sidebar{background:var(--panel);border-right:1px solid var(--border);padding:12px 8px;display:flex;flex-direction:column;gap:4px;overflow:hidden}.sidebar-header{display:flex;align-items:center;gap:6px;padding:4px;margin-bottom:12px;min-height:32px}.sidebar-header .title-text{flex:1;font-size:16px;font-weight:700;color:var(--text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-decoration:none}.sidebar-header .title-text:hover{text-decoration:none;color:var(--text)}.sidebar.collapsed .sidebar-header{justify-content:center}.sidebar-nav,.sidebar-footer{display:flex;flex-direction:column;gap:2px}.sidebar-nav a,.sidebar-footer .icon-button{display:flex;align-items:center;gap:10px;padding:8px 10px;border-radius:6px;color:var(--text);background:transparent;border:none;font:inherit;text-align:left;cursor:pointer;white-space:nowrap;overflow:hidden;width:100%}.sidebar-nav a:hover,.sidebar-footer .icon-button:hover{background:var(--panel-2);text-decoration:none}.sidebar-nav a.active,.sidebar-nav a.active:hover{background:var(--accent);color:#fff}.sidebar-nav a.active:hover{background:var(--accent-2)}.icon-button.collapse-toggle{width:32px;height:32px;padding:0;border:1px solid var(--border);border-radius:6px;flex:0 0 auto;justify-content:center}.nav-icon{display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;flex:0 0 auto}.nav-icon svg{width:100%;height:100%;display:block}.sidebar.collapsed .sidebar-nav a,.sidebar.collapsed .sidebar-footer .icon-button{justify-content:center;padding:10px 6px}.sidebar.collapsed .nav-label,.sidebar.collapsed .who{display:none}.sidebar .spacer{flex:1}.sidebar .who{color:var(--muted);font-size:12px;padding:6px 10px;overflow:hidden;text-overflow:ellipsis}.main{overflow:auto}.page-wrap{display:flex;justify-content:flex-start;padding:16px 24px}.page{display:flex;flex-direction:column;gap:12px}.toolbar{display:flex;align-items:center;gap:8px;background:var(--panel);border:1px solid var(--border);border-radius:8px;padding:8px 12px}.toolbar h2{margin:0;font-size:16px}.toolbar .spacer{flex:1}.table-wrap{background:var(--panel);border:1px solid var(--border);border-radius:8px;overflow:hidden}table.dt{border-collapse:collapse;table-layout:fixed}table.dt th,table.dt td{padding:8px 10px;text-align:left;border-bottom:1px solid var(--border);overflow:hidden;white-space:nowrap;text-overflow:ellipsis}table.dt th{background:var(--panel-2);font-weight:600;-webkit-user-select:none;user-select:none;position:sticky;top:0;z-index:1}table.dt tr:hover td{background:var(--panel-2)}.footer{display:flex;align-items:center;gap:8px;background:var(--panel);border:1px solid var(--border);border-radius:8px;padding:8px 12px;color:var(--muted)}.status{display:inline-block;padding:2px 8px;border-radius:999px;font-size:11px}.status.draft{background:var(--panel-2);color:var(--muted)}.status.active{background:#4f8cff33;color:var(--accent)}.status.paused{background:#e8b44033;color:var(--warn)}.status.completed{background:#3ec28a33;color:var(--good)}.status.pending{background:var(--panel-2);color:var(--muted)}.status.in_progress{background:#4f8cff33;color:var(--accent)}.status.done{background:#3ec28a33;color:var(--good)}.status.failed{background:#e8625a33;color:var(--bad)}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;background:#00000080;display:flex;align-items:center;justify-content:center;z-index:100}.modal{background:var(--panel);border:1px solid var(--border);border-radius:8px;padding:16px;width:min(560px,calc(100vw - 32px));max-height:calc(100vh - 32px);overflow:auto;display:flex;flex-direction:column;gap:12px}.modal.wide{width:min(820px,calc(100vw - 32px))}.modal h3{margin:0}.modal .row{display:grid;grid-template-columns:140px 1fr;gap:8px;align-items:center}.modal textarea{min-height:140px;resize:vertical}.modal .actions{display:flex;gap:8px;justify-content:flex-end}.muted{color:var(--muted)}.code{font-family:ui-monospace,Menlo,monospace;background:var(--bg);padding:6px 8px;border-radius:4px;word-break:break-all}.error{color:var(--bad)}.login-shell{height:100vh;display:flex;align-items:center;justify-content:center}.login-card{background:var(--panel);border:1px solid var(--border);padding:24px;border-radius:8px;width:min(360px,calc(100vw - 32px));display:flex;flex-direction:column;gap:12px}.drawer-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;background:#0006;z-index:90}.drawer{position:fixed;top:0;right:0;bottom:0;width:min(50vw,720px);background:var(--panel);border-left:1px solid var(--border);padding:16px;overflow:auto;z-index:91;display:flex;flex-direction:column;gap:12px}.drawer.terminal-drawer{width:min(72vw,1152px);overflow:hidden}.terminal-drawer-header{display:flex;align-items:center;gap:10px;flex:0 0 auto}.drawer-close-btn{display:inline-flex;align-items:center;gap:6px;padding:4px 10px;border-radius:6px;border:1px solid var(--border);background:var(--panel-2);color:var(--text);cursor:pointer;font:inherit}.drawer-close-btn:hover{background:var(--border)}.drawer-close-chev{font-size:16px;line-height:1;letter-spacing:-1px;font-weight:700;color:var(--muted)}.terminal-wrap{flex:1 1 auto;display:flex;flex-direction:column;gap:6px;min-height:0;background:#0b0d12;border:1px solid var(--border);border-radius:6px;padding:8px}.terminal-status{display:flex;align-items:center;gap:6px;flex:0 0 auto;font-size:12px}.status-dot{width:8px;height:8px;border-radius:50%;display:inline-block;background:var(--muted)}.status-dot.status-open{background:var(--good)}.status-dot.status-connecting{background:var(--warn)}.status-dot.status-closed{background:var(--muted)}.status-dot.status-error{background:var(--bad)}.terminal-host{flex:1 1 auto;min-height:0}.terminal-host .xterm,.terminal-host .xterm-viewport,.terminal-host .xterm-screen{width:100%!important;height:100%!important}.card{background:var(--panel);border:1px solid var(--border);border-radius:8px;padding:16px;display:flex;flex-direction:column;gap:4px}.instructions-block{background:var(--panel-2);border:1px solid var(--border);border-radius:8px;padding:10px 14px;font-size:13px;line-height:1.55}.instructions-block code{background:var(--bg);padding:1px 5px;border-radius:3px;font-family:ui-monospace,Menlo,monospace;font-size:12px}.agent-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:16px}.agent-card{background:var(--panel);border:1px solid var(--border);border-radius:10px;overflow:hidden;cursor:pointer;transition:border-color .12s ease,transform .12s ease;position:relative;display:flex;flex-direction:column}.agent-card:hover{border-color:var(--accent)}.agent-card:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.agent-card-status{position:absolute;top:10px;left:10px;z-index:2}.agent-card-busy{position:absolute;top:10px;right:10px;z-index:2;display:flex;align-items:center;justify-content:center;width:18px;height:18px;border-radius:50%;background:#00000073;border:1px solid var(--border)}.agent-busy-dot{display:inline-block;width:10px;height:10px;border-radius:50%;background:var(--muted)}.agent-busy-dot.is-busy{background:var(--warn);animation:busy-pulse 1.6s ease-in-out infinite}.agent-busy-dot.is-idle{background:var(--good)}.agent-busy-dot.is-rate-limited{background:var(--bad)}@keyframes busy-pulse{0%,to{box-shadow:0 0 #e8b4408c}50%{box-shadow:0 0 0 4px #e8b44000}}.agent-card-rl-banner{position:absolute;top:36px;left:8px;right:8px;z-index:2;padding:4px 10px;border-radius:6px;background:#e8625a24;border:1px solid var(--bad);color:var(--bad);font-size:11px;text-align:center;pointer-events:none}.mode-pill{display:inline-flex;align-items:center;gap:6px;padding:4px 10px;border-radius:999px;font-size:12px;border:1px solid var(--border);background:var(--panel-2);white-space:nowrap}.mode-pill.mode-busy{color:var(--warn)}.mode-pill.mode-idle{color:var(--good)}.mode-pill.mode-rate-limited{color:var(--bad);border-color:var(--bad)}.icon-row-btn{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border-radius:6px;border:1px solid var(--border);background:var(--panel-2);color:var(--text);cursor:pointer}.icon-row-btn:hover{background:var(--border)}.icon-row-btn.primary{background:var(--accent);border-color:var(--accent);color:#fff}.icon-row-btn.primary:hover{background:var(--accent-2)}.icon-row-btn.danger{background:transparent;border-color:var(--bad);color:var(--bad)}.icon-row-btn.danger:hover{background:#e8625a1f}.icon-row-btn-glyph{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px}.icon-row-btn-glyph svg{width:100%;height:100%;display:block}.progress-cell{display:inline-flex;align-items:center;gap:12px;cursor:default;font-variant-numeric:tabular-nums}.progress-cell-stat{display:inline-flex;align-items:center;gap:4px;white-space:nowrap}.progress-cell-icon{display:inline-flex;width:14px;height:14px;align-items:center;justify-content:center;flex:0 0 auto}.progress-cell-icon svg{width:100%;height:100%;display:block}.agent-card-body{aspect-ratio:100 / 38;background:#0b0d12;border-bottom:1px solid var(--border);overflow:hidden;position:relative}.agent-card-term-scaler{position:absolute;top:0;right:0;bottom:0;left:0;overflow:hidden;--preview-scale: .4}.agent-card-term{position:absolute;top:0;left:0;margin:0;padding:6px 8px;width:calc(100% / var(--preview-scale));height:calc(100% / var(--preview-scale));font-family:ui-monospace,Menlo,Consolas,monospace;font-size:11px;line-height:1.35;color:#c8cdd6;white-space:pre;overflow:hidden;transform:scale(var(--preview-scale));transform-origin:top left}.agent-card-term-empty{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;justify-content:center;color:var(--muted)}.agent-card-footer{padding:12px 14px;display:flex;flex-direction:column;gap:2px}.agent-card-name{font-weight:700}.agent-card-sub{font-size:12px;color:var(--text)}.agent-card-meta{font-size:11px}.agent-card-actions{position:absolute;bottom:10px;right:10px;display:flex;gap:6px;opacity:0;transition:opacity .12s ease}.agent-card:hover .agent-card-actions{opacity:1}.agent-card-actions button{padding:4px 8px;font-size:12px}.tabs{display:flex;gap:2px;border-bottom:1px solid var(--border);margin:0 0 8px}.tab{background:transparent;border:0;border-bottom:2px solid transparent;color:var(--muted);padding:8px 14px;cursor:pointer;font:inherit;font-weight:500;border-radius:0}.tab:hover{color:var(--text)}.tab.active{color:var(--text);border-bottom-color:var(--accent)}.status.disconnected{background:var(--panel-2);color:var(--muted)}.status.connecting{background:#e8b44033;color:var(--warn)}.status.connected{background:#3ec28a33;color:var(--good)}.status.error{background:#e8625a33;color:var(--bad)}
