:root {
  --bg: #0b1016;
  --surface: #121923;
  --surface-2: #192230;
  --border: #253244;
  --text: #e6edf5;
  --muted: #8ea0b5;
  --accent: #2dd4bf;
  --accent-strong: #14b8a6;
  --blue: #38bdf8;
  --amber: #f59e0b;
  --red: #f87171;
  --green: #34d399;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 14px;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; line-height: 1.5; }
.text-emerald { color: var(--accent); }
.err-text { color: var(--red); font-size: 12px; margin-top: 6px; }
.hint-text { color: var(--accent); font-size: 12px; margin-top: 6px; }

/* LAYOUT */
.app-shell {
  display: grid;
  grid-template-columns: 276px 1fr;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 16px;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2dd4bf, #0284c7);
  color: #061318;
  font-weight: 800;
  display: grid;
  place-items: center;
  font-size: 16px;
  letter-spacing: -0.5px;
}

.brand-title { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.project-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 40vh;
  overflow-y: auto;
}

.project-item {
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 11px;
  cursor: pointer;
  transition: 0.15s ease;
}
.project-item:hover { border-color: #364962; }
.project-item.active {
  border-color: var(--accent);
  background: rgba(45, 212, 191, 0.08);
}
.project-item-name { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.project-item-meta { font-size: 11px; color: var(--muted); display: flex; gap: 8px; }

.btn-import {
  background: rgba(45, 212, 191, 0.1);
  color: var(--accent);
  border: 1px dashed rgba(45, 212, 191, 0.45);
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s;
}
.btn-import:hover { background: rgba(45, 212, 191, 0.18); }

.telemetry-card {
  margin-top: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}
.stat-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* MAIN AREA */
.main-area {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  padding: 16px 24px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title { margin: 0; font-size: 19px; font-weight: 700; }
.page-desc { font-size: 12px; color: var(--muted); margin-top: 3px; }

.nav-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab-btn {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 13px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab-btn:hover { color: var(--text); border-color: #3a4c63; }
.tab-btn.active {
  background: rgba(45, 212, 191, 0.14);
  color: var(--accent);
  border-color: var(--accent);
}

.badge {
  background: var(--amber);
  color: #111;
  border-radius: 99px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 700;
}

.tab-panel {
  display: none;
  padding: 18px 24px 24px;
  overflow-y: auto;
  flex: 1;
}
.tab-panel.active { display: block; }

/* BUTTONS & INPUTS */
.btn-primary, .btn-secondary, .btn-mini, .btn-danger {
  border-radius: 9px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #04201c;
  padding: 8px 15px;
  font-size: 13px;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary.btn-lg { padding: 10px 22px; font-size: 14px; }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
  padding: 8px 13px;
  font-size: 13px;
}
.btn-secondary:hover { border-color: #465b75; }

.btn-danger {
  background: rgba(248, 113, 113, 0.14);
  color: var(--red);
  border-color: rgba(248, 113, 113, 0.4);
  padding: 6px 11px;
  font-size: 12px;
}
.btn-danger:hover { background: rgba(248, 113, 113, 0.25); }

.btn-mini {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
  padding: 4px 9px;
  font-size: 12px;
}
.btn-mini:hover { border-color: var(--accent); color: var(--accent); }

.input, .select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 13px;
  width: 100%;
  outline: none;
}
.input:focus, .select:focus { border-color: var(--accent); }

.pill {
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}
.pill-muted { background: var(--surface-2); color: var(--muted); }
.pill-ok { background: rgba(52, 211, 153, 0.16); color: var(--green); }
.pill-warn { background: rgba(245, 158, 11, 0.18); color: var(--amber); }
.pill-err { background: rgba(248, 113, 113, 0.16); color: var(--red); }
.pill-blue { background: rgba(56, 189, 248, 0.16); color: var(--blue); }

/* ASSETS TAB */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.cat-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.cat-pill {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}
.cat-pill.active {
  background: var(--accent);
  color: #05201c;
  border-color: var(--accent);
  font-weight: 700;
}
.toolbar-actions { display: flex; gap: 8px; }

.drop-zone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 13px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 16px;
  transition: 0.15s;
}
.drop-zone.dragover {
  border-color: var(--accent);
  background: rgba(45, 212, 191, 0.08);
  color: var(--accent);
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.asset-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: 0.15s;
}
.asset-card:hover { border-color: #3a4f68; transform: translateY(-1px); }

.asset-thumb {
  height: 155px;
  background: #090d12;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}
.asset-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.asset-icon-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}
.asset-icon-big { font-size: 42px; }
.asset-cat-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(11, 16, 22, 0.82);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 11px;
  color: var(--text);
}

.asset-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.asset-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.asset-meta { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; }
.asset-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

/* PIPELINE TAB */
.pipeline-header-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.stage-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: 0.15s;
}
.stage-card:hover { border-color: #3f556e; }
.stage-card.active {
  border-color: var(--accent);
  background: rgba(45, 212, 191, 0.06);
}
.stage-num { font-size: 11px; color: var(--accent); font-weight: 700; margin-bottom: 4px; }
.stage-name { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.stage-tip { font-size: 12px; color: var(--muted); line-height: 1.45; }

.studio-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.studio-card h3 { margin: 0 0 10px; font-size: 15px; }

.form-grid { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field-label { font-size: 12px; font-weight: 600; color: #c7d5e5; }
.field-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-3col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.input-group { display: flex; gap: 8px; }

.engine-bar { display: flex; flex-direction: column; gap: 8px; }
.engine-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.engine-opt {
  background: var(--bg);
  color: var(--muted);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.engine-opt.active {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(45, 212, 191, 0.09);
}
.engine-opt:disabled { opacity: 0.4; cursor: not-allowed; }
.sub-tag { font-size: 11px; font-weight: 500; color: var(--accent); }

.stage-fields { display: flex; flex-direction: column; gap: 14px; }
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 8px;
}
.check-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12px;
}
.check-item img { width: 32px; height: 32px; border-radius: 5px; object-fit: cover; }

.form-footer {
  display: flex;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.form-footer .input { flex: 1; }

/* JOBS TAB */
.jobs-split {
  display: grid;
  grid-template-columns: 370px 1fr;
  gap: 14px;
  height: calc(100vh - 125px);
}
.jobs-list-col, .jobs-console-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.col-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 13px;
}
.jobs-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.job-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px;
  cursor: pointer;
  transition: 0.15s;
}
.job-card.active { border-color: var(--accent); background: rgba(45, 212, 191, 0.06); }
.job-card-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-bottom: 6px; }
.job-title { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-track {
  height: 6px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
  margin: 6px 0;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--blue));
  transition: width 0.3s ease;
}
.job-meta-row { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }

.console-actions { display: flex; gap: 6px; }
.console-meta {
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.console-outputs {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  background: rgba(45, 212, 191, 0.05);
}
.console-log {
  margin: 0;
  padding: 14px;
  flex: 1;
  overflow: auto;
  background: #070b10;
  color: #c8d6e5;
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-all;
}

/* COLAB TAB */
.colab-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 16px; }
.kv-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-top: 12px;
}
.kv-label { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.kv-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.code-inline {
  background: var(--surface-2);
  padding: 5px 9px;
  border-radius: 6px;
  font-family: Consolas, monospace;
  font-size: 12px;
  color: var(--blue);
  word-break: break-all;
}
.workers-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.worker-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-form { max-width: 720px; display: flex; flex-direction: column; gap: 14px; }

/* MODALS */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 7, 11, 0.78);
  backdrop-filter: blur(4px);
}
.modal-dialog {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 92vh;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}
.modal-sm { width: 420px; }
.modal-xl { width: min(1060px, 94vw); }
.modal-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.modal-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.modal-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { padding: 8px 16px; border-top: 1px solid var(--border); background: var(--bg); }

.glb-canvas-host {
  width: 100%;
  height: 68vh;
  background: #141c26;
  position: relative;
}
.img-viewer-host {
  padding: 14px;
  background: #070b10;
  display: grid;
  place-items: center;
  overflow: auto;
  max-height: 78vh;
}
.img-viewer-host img {
  max-width: 100%;
  max-height: 74vh;
  border-radius: 8px;
}

/* BEFORE / AFTER COMPARE */
.compare-controls {
  padding: 10px 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}
.compare-stage {
  position: relative;
  width: 100%;
  height: 66vh;
  background: #070b10;
  overflow: hidden;
  user-select: none;
}
.cmp-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.cmp-clip {
  position: absolute;
  inset: 0;
  clip-path: inset(0 50% 0 0);
}
.cmp-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(45, 212, 191, 0.9);
  pointer-events: none;
}
.cmp-slider {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: ew-resize;
  margin: 0;
}

.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: var(--surface-2);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  z-index: 200;
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
}

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .pipeline-header-cards, .colab-grid, .jobs-split { grid-template-columns: 1fr; }
}

/* LOGIN OVERLAY & DUAL-NODE ADDITIONS */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: radial-gradient(circle at top, #132131, #070b10 70%);
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65);
}

.auth-user-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
}

.node-group-head {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  margin-top: 6px;
}

.win-cmd-box {
  max-height: 110px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font-size: 11.5px;
}
