:root {
  --bg: #eef0f3; --panel: #ffffff; --line: #d5d9df; --line2: #e6e9ed;
  --text: #22262b; --muted: #6b737d; --accent: #2a6fdb; --accent-soft: #e3edfc;
  --sel: #cfe0fb; --done: #2e9b4f; --err: #d33a3a; --run: #2a6fdb; --warn: #d98a00;
  --font: "Segoe UI", "Malgun Gothic", -apple-system, "Apple SD Gothic Neo", sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 13px/1.4 var(--font); color: var(--text); background: var(--bg); overflow: hidden; }
button { font: inherit; cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

#app { display: flex; flex-direction: column; height: 100vh; }
.titlebar { display: flex; align-items: center; gap: 8px; padding: 5px 12px; background: #fff; border-bottom: 1px solid var(--line2); font-size: 13px; }
.titlebar .logo { color: var(--accent); font-size: 16px; }
.menubar { display: flex; background: #fff; border-bottom: 1px solid var(--line); padding: 0 6px; }
.mb-item { padding: 4px 10px; cursor: default; border-radius: 3px; }
.mb-item:hover, .mb-item.open { background: var(--accent-soft); }

/* ---------- module toolbar (OmicsBox style) ---------- */
.toolbar { display: flex; gap: 2px; padding: 6px 8px 4px; background: linear-gradient(#fafbfc, #eef0f3); border-bottom: 1px solid var(--line); overflow-x: auto; }
.mod { display: flex; align-items: flex-start; padding: 4px 6px 2px; border-radius: 4px; cursor: pointer; user-select: none; position: relative; }
.mod:hover, .mod.open { background: #e2e7ee; }
.mod .ic { display: flex; flex-direction: column; align-items: center; width: 74px; }
.mod .ring { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #7d858f; display: flex; align-items: center; justify-content: center; background: #fff; }
.mod .dot { width: 14px; height: 14px; border-radius: 50%; }
.mod .lbl { font-size: 11.5px; color: #555; text-align: center; line-height: 1.1; margin-top: 3px; }
.mod .caret { font-size: 9px; color: #666; margin-top: 12px; }
.mod .newb { position: absolute; top: 0; right: 4px; font-size: 9px; background: #2fa36b; color: #fff; border-radius: 6px; padding: 0 4px; }

/* ---------- cascading menus ---------- */
.menu { position: fixed; z-index: 50; background: #fff; border: 1px solid #b9c0c9; box-shadow: 2px 3px 10px rgba(0,0,0,.18); min-width: 240px; padding: 3px 0; }
.mi { display: flex; align-items: center; gap: 8px; padding: 5px 12px 5px 14px; white-space: nowrap; cursor: default; }
.mi:hover, .mi.open { background: var(--sel); }
.mi .t { flex: 1; }
.mi .arrow { color: #666; font-size: 10px; }
.mi.planned .t { color: #9aa1aa; }
.badge { font-size: 10px; padding: 0 5px; border-radius: 7px; line-height: 15px; }
.b-ready { background: #e2f3e7; color: #23753c; }
.b-server { background: #e6eefb; color: #2a5db0; }
.b-planned { background: #f0f1f3; color: #8a929c; }
.b-new { background: #2fa36b; color: #fff; }
.menu .sep { border-top: 1px solid var(--line2); margin: 3px 0; }

/* ---------- workbench tabs ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-height: 120px; background: #fff; margin: 4px 4px 0; border: 1px solid var(--line); }
.tabs { display: flex; background: #f3f5f7; border-bottom: 1px solid var(--line); overflow-x: auto; min-height: 29px; }
.tab { display: flex; align-items: center; gap: 6px; padding: 5px 10px; border-right: 1px solid var(--line); cursor: pointer; white-space: nowrap; color: #444; max-width: 280px; }
.tab .tt { overflow: hidden; text-overflow: ellipsis; }
.tab.active { background: #fff; color: var(--text); box-shadow: inset 0 2px 0 var(--accent); }
.tab .x { color: #999; padding: 0 2px; border-radius: 2px; }
.tab .x:hover { background: #ddd; color: #333; }
.tab .tdot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.tabcontent { flex: 1; overflow: auto; position: relative; }
.view { padding: 14px 18px; }

.splitter { height: 5px; cursor: row-resize; background: var(--bg); }
.bottom { height: 250px; display: flex; gap: 4px; padding: 0 4px 4px; }
.panel { background: #fff; border: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.panel.left { flex: 1.35; }
.panel.right { flex: 1; }
.ptabs { display: flex; background: #f3f5f7; border-bottom: 1px solid var(--line); }
.ptab { border: 0; background: none; padding: 5px 12px; color: #555; border-right: 1px solid var(--line2); }
.ptab.active { background: #fff; color: var(--text); box-shadow: inset 0 2px 0 var(--accent); }
.pbody { flex: 1; overflow: auto; padding: 6px 10px; }

/* progress */
.prog { padding: 6px 0; border-bottom: 1px solid var(--line2); }
.prog .row { display: flex; align-items: center; gap: 8px; }
.bar { flex: 1; height: 9px; background: #e9ecef; border-radius: 2px; overflow: hidden; }
.bar > div { height: 100%; background: #4caf50; transition: width .4s; }
.bar.err > div { background: var(--err); }

/* status chips */
.st { display: inline-block; font-size: 11px; font-weight: 600; color: #fff; padding: 1px 6px; border-radius: 2px; min-width: 56px; text-align: center; }
.st.DONE { background: var(--done); }
.st.ERROR { background: var(--err); }
.st.RUNNING { background: var(--run); }
.st.QUEUED { background: #8a929c; }

/* generic tables */
table.grid { border-collapse: collapse; width: 100%; font-size: 12px; }
table.grid th, table.grid td { border: 1px solid var(--line2); padding: 3px 7px; text-align: left; white-space: nowrap; }
table.grid th { background: #f3f5f7; position: sticky; top: 0; font-weight: 600; cursor: pointer; z-index: 1; }
table.grid th.sorted::after { content: " ▾"; color: var(--accent); }
table.grid th.sorted.asc::after { content: " ▴"; }
table.grid tr:hover td { background: #f6f9ff; }
table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
.hist td, .hist th { border-left: 0; border-right: 0; }
.iconbtn { border: 0; background: none; color: #556; padding: 1px 4px; border-radius: 3px; }
.iconbtn:hover { background: #e7ebf0; color: #111; }
a.link { color: var(--accent); cursor: pointer; text-decoration: none; }
a.link:hover { text-decoration: underline; }

/* files panel */
.ftools { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.btn { border: 1px solid #b9c0c9; background: #fff; padding: 4px 11px; border-radius: 3px; color: var(--text); }
.btn:hover { background: #f1f4f8; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1f5fc4; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.drop { border: 2px dashed #b9c0c9; border-radius: 6px; padding: 10px; text-align: center; color: var(--muted); margin-bottom: 6px; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.kind { font-size: 10px; padding: 0 5px; border-radius: 6px; background: #eef1f5; color: #667; }

/* messages */
.msg { font-family: Consolas, Menlo, monospace; font-size: 11.5px; padding: 1px 0; white-space: pre-wrap; }
.msg.err { color: var(--err); }
.msg.ok { color: var(--done); }

/* welcome */
.welcome { max-width: 980px; }
.welcome h1 { font-size: 22px; margin: 4px 0 2px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin: 14px 0; }
.card { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; background: #fafbfc; }
.card h3 { margin: 0 0 4px; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.card .n { font-size: 22px; font-weight: 700; }
.legend span { margin-right: 10px; }
.steps li { margin: 4px 0; }

/* results */
.rhead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.rhead h2 { margin: 0; font-size: 16px; }
.params { font-size: 11.5px; color: var(--muted); margin-bottom: 10px; }
.rcard { border: 1px solid var(--line); border-radius: 6px; margin: 12px 0; overflow: hidden; }
.rcard > .rh { display: flex; align-items: center; gap: 8px; background: #f6f7f9; padding: 6px 10px; border-bottom: 1px solid var(--line2); }
.rcard > .rh b { flex: 1; }
.rcard .rb { padding: 10px; overflow: auto; }
.rcard img { max-width: min(100%, 900px); max-height: 560px; display: block; margin: 0 auto; }
.rcard pre { margin: 0; font-family: Consolas, Menlo, monospace; font-size: 12px; white-space: pre-wrap; }
.tablewrap { max-height: 420px; overflow: auto; border: 1px solid var(--line2); }
.tbar { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.tbar input { border: 1px solid #c4cad2; border-radius: 3px; padding: 3px 7px; width: 200px; }
.note { font-size: 11.5px; color: var(--muted); }
.logbox { background: #1f2329; color: #d6dde6; font: 11.5px/1.45 Consolas, Menlo, monospace; padding: 10px; border-radius: 4px; max-height: 360px; overflow: auto; white-space: pre-wrap; }

/* modal dialog */
.modal { position: fixed; inset: 0; background: rgba(20,25,35,.35); z-index: 100; display: flex; align-items: center; justify-content: center; }
.dialog { background: #fff; width: 620px; max-width: calc(100vw - 32px); max-height: calc(100vh - 40px); display: flex; flex-direction: column; border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.dh { padding: 12px 16px; border-bottom: 1px solid var(--line2); }
.dh h2 { margin: 0; font-size: 15px; display: flex; gap: 8px; align-items: center; }
.dh .path { font-size: 11px; color: var(--muted); margin-top: 2px; }
.db { padding: 12px 16px; overflow: auto; flex: 1; }
.df { padding: 10px 16px; border-top: 1px solid var(--line2); display: flex; justify-content: flex-end; gap: 8px; align-items: center; }
.desc { background: #f6f8fb; border-left: 3px solid var(--accent); padding: 7px 10px; margin-bottom: 12px; font-size: 12.5px; }
.desc.warn { border-left-color: var(--warn); background: #fff8ea; }
fieldset { border: 1px solid var(--line2); border-radius: 5px; padding: 8px 12px 10px; margin: 0 0 12px; }
legend { font-weight: 600; padding: 0 4px; font-size: 12px; color: #444; }
.frow { display: grid; grid-template-columns: 190px 1fr; gap: 10px; align-items: center; margin: 6px 0; }
.frow label { color: #333; }
.frow .help { grid-column: 2; font-size: 11px; color: var(--muted); margin-top: -4px; }
.frow input[type=text], .frow input[type=number], .frow select { width: 100%; border: 1px solid #c4cad2; border-radius: 3px; padding: 4px 7px; font: inherit; }
.flist { border: 1px solid #c4cad2; border-radius: 3px; max-height: 150px; overflow: auto; padding: 3px 6px; }
.flist label { display: flex; gap: 6px; align-items: center; padding: 1px 0; white-space: nowrap; }
.flist .empty { color: var(--muted); font-size: 12px; padding: 4px 0; }
.groups { display: grid; grid-template-columns: 1fr 160px; gap: 4px 10px; align-items: center; max-height: 260px; overflow: auto; border: 1px solid var(--line2); border-radius: 4px; padding: 6px 8px; }
.groups input { border: 1px solid #c4cad2; border-radius: 3px; padding: 3px 6px; font: inherit; }
.groups .sname { font-family: Consolas, Menlo, monospace; font-size: 12px; }

#toast { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 6px; }
.toast { background: #23272e; color: #fff; padding: 8px 14px; border-radius: 5px; box-shadow: 0 4px 14px rgba(0,0,0,.25); font-size: 12.5px; max-width: 380px; }
.toast.err { background: #b52f2f; }

/* ---------- login ---------- */
.loginwrap { position: fixed; inset: 0; z-index: 300; background: linear-gradient(135deg, #e9eef6, #f7f9fc); display: flex; align-items: center; justify-content: center; }
.loginbox { background: #fff; width: 360px; padding: 30px 32px; border-radius: 10px; box-shadow: 0 10px 40px rgba(20,40,80,.15); display: flex; flex-direction: column; gap: 10px; text-align: center; }
.loginbox h1 { margin: 0; font-size: 22px; }
.loginbox input { border: 1px solid #c4cad2; border-radius: 5px; padding: 9px 11px; font: inherit; }
.loginbox .btn { padding: 9px; font-size: 14px; }
.logo-big { font-size: 34px; color: var(--accent); }
.lerr { color: var(--err); min-height: 18px; font-size: 12.5px; }
/* ---------- wizard ---------- */
.wizard { max-width: 1100px; }
.wizard fieldset { padding: 10px 14px 12px; }
.wizard legend { font-size: 13px; }
.choices { display: flex; flex-wrap: wrap; gap: 6px 8px; margin: 4px 0; }
.choice { border: 1px solid var(--line); border-radius: 16px; padding: 4px 12px; cursor: pointer; background: #fafbfc; }
.choice.on, .choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.wizard table.grid input, .wizard table.grid select { border: 1px solid #c4cad2; border-radius: 3px; padding: 2px 5px; font: inherit; max-width: 260px; }
.optgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 0 20px; margin-top: 6px; }
.optgrid .frow { grid-template-columns: 170px 1fr; }
