/* ============================================================ Login Page ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-page);
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(at 15% 25%, rgba(99,102,241,.18) 0, transparent 45%),
    radial-gradient(at 85% 75%, rgba(20,184,166,.12) 0, transparent 45%),
    radial-gradient(at 60% 0%, rgba(245,158,11,.10) 0, transparent 50%);
  pointer-events: none;
}
.login-card {
  position: relative;
  width: min(400px, 92vw);
  background: var(--bg-surface);
  padding: 40px 36px 32px;
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl), 0 0 0 1px var(--border-soft);
  z-index: 1;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand .logo {
  width: 44px; height: 44px;
  background: var(--grad-brand);
  border-radius: var(--r-md);
  color: white; font-weight: 800; font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-brand);
}
.login-brand h1 {
  font-size: 18px; font-weight: 700;
  letter-spacing: -0.02em; margin: 0;
}
.login-brand .sub { font-size: 11px; color: var(--text-tertiary); letter-spacing: 0.06em; }
.login-title { font-size: 24px; font-weight: 700; margin-bottom: 6px; }
.login-subtitle { font-size: 13px; color: var(--text-tertiary); margin-bottom: 24px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form .btn { margin-top: 8px; padding: 12px 16px; font-size: 14px; }
.hint {
  margin-top: 18px;
  padding: 12px 14px;
  background: var(--bg-subtle);
  border-radius: var(--r-sm);
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.7;
}
.hint code {
  background: var(--bg-surface);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-soft);
}

/* ============================================================ Dashboard ============================================================ */
.dash-hero {
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: 22px 24px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}
.dash-hero::after {
  content: ""; position: absolute; inset: 0;
  background: var(--grad-mesh);
  pointer-events: none;
}
.dash-hero h2 {
  font-size: 22px;
  letter-spacing: -0.02em;
  position: relative;
}
.dash-hero p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 6px;
  position: relative;
  max-width: 720px;
}

.dash-trend {
  height: 160px;
  display: flex; align-items: flex-end; gap: 4px;
  padding: 12px 0 24px;
  position: relative;
}
.dash-trend .bar {
  flex: 1;
  background: var(--grad-brand);
  border-radius: 4px 4px 0 0;
  position: relative;
  min-height: 4px;
  transition: opacity .2s;
}
.dash-trend .bar:hover { opacity: .8; }
.dash-trend .bar .tooltip {
  position: absolute;
  bottom: 100%; left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary);
  color: white;
  font-size: 10px;
  padding: 3px 6px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .15s;
  pointer-events: none;
}
.dash-trend .bar:hover .tooltip { opacity: 1; }
.dash-trend .label {
  position: absolute;
  bottom: 0;
  font-size: 10px;
  color: var(--text-tertiary);
  text-align: center;
}

/* Node load bar */
.load-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0;
}
.load-row .name { width: 130px; font-size: 12px; font-weight: 600; }
.load-row .progress { flex: 1; height: 8px; }
.load-row .val { width: 50px; text-align: right; font-size: 11px; font-variant-numeric: tabular-nums; color: var(--text-tertiary); }

/* ============================================================ Workflow editor ============================================================ */
.wf-editor {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
}
.wf-skill-palette {
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: 14px;
  max-height: 70vh;
  overflow-y: auto;
}
.wf-skill-palette .palette-title {
  font-size: 13px; font-weight: 700;
  margin-bottom: 10px;
  color: var(--text-secondary);
}
.palette-cat {
  font-size: 10px; font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 14px 0 4px;
}
.palette-skill {
  padding: 7px 10px;
  border-radius: var(--r-sm);
  font-size: 12px;
  cursor: grab;
  border: 1px dashed transparent;
  display: flex; align-items: center; gap: 8px;
  transition: all .15s;
}
.palette-skill:hover {
  background: var(--brand-50);
  border-color: var(--brand-200);
  color: var(--brand-700);
}
.palette-skill .icon { font-size: 14px; }

.wf-canvas {
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: 18px;
  min-height: 70vh;
}
.wf-step {
  background: var(--bg-page);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: 14px 16px;
  margin-bottom: 14px;
  position: relative;
  display: flex; gap: 14px; align-items: flex-start;
  transition: border-color .15s, box-shadow .15s;
}
.wf-step:hover { border-color: var(--brand-200); box-shadow: var(--shadow-sm); }
.wf-step::after {
  content: ""; position: absolute;
  left: 32px; top: 100%;
  width: 2px; height: 14px;
  background: var(--border-default);
}
.wf-step:last-of-type::after { display: none; }
.wf-step .step-num {
  width: 28px; height: 28px;
  background: var(--grad-brand);
  color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
  flex-shrink: 0;
}
.wf-step .step-body { flex: 1; min-width: 0; }
.wf-step .step-name { font-weight: 700; margin-bottom: 4px; font-size: 13px; }
.wf-step .step-meta {
  font-size: 11px; color: var(--text-tertiary);
  display: flex; gap: 10px; align-items: center;
}
.wf-step .step-actions {
  display: flex; gap: 4px;
  align-items: center;
}

/* ============================================================ Experiment detail ============================================================ */
.exp-step-list { display: flex; flex-direction: column; gap: 0; }
.exp-step-item {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
  margin-bottom: 8px;
  background: var(--bg-surface);
  transition: all .15s;
}
.exp-step-item:hover { border-color: var(--brand-200); }
.exp-step-item .step-no {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg-subtle);
  color: var(--text-tertiary);
  font-weight: 700;
  font-size: 11px;
  display: flex; align-items: center; justify-content: center;
}
.exp-step-item.running .step-no { background: var(--brand-500); color: white; animation: pulse 1.5s infinite; }
.exp-step-item.succeeded .step-no { background: var(--success); color: white; }
.exp-step-item.failed .step-no { background: var(--danger); color: white; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(79,70,229,.45); }
  50% { box-shadow: 0 0 0 8px rgba(79,70,229,0); }
}

.exp-log {
  background: #0b1020;
  color: #d1d5db;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.65;
  padding: 14px;
  border-radius: var(--r-sm);
  max-height: 360px;
  overflow-y: auto;
}
.exp-log .log-line { padding: 2px 0; white-space: pre-wrap; word-break: break-all; }
.exp-log .log-time { color: #6b7280; margin-right: 8px; }
.exp-log .log-level { font-weight: 700; margin-right: 8px; }
.exp-log .log-level.info { color: #60a5fa; }
.exp-log .log-level.warn { color: #fbbf24; }
.exp-log .log-level.error { color: #f87171; }

/* ============================================================ AI Chat ============================================================ */
.chat-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 16px;
  height: calc(100vh - 130px);
}
.chat-sessions {
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: 12px;
  overflow-y: auto;
}
.chat-session-item {
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: 12px;
  margin-bottom: 4px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all .12s;
}
.chat-session-item:hover { background: var(--bg-hover); }
.chat-session-item.active { background: var(--brand-50); color: var(--brand-700); font-weight: 600; }

.chat-main {
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px 18px; }
.chat-msg {
  margin-bottom: 14px;
  display: flex;
  gap: 8px;
}
.chat-msg .bubble {
  max-width: 70%;
  padding: 9px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-msg.user { justify-content: flex-end; }
.chat-msg.user .bubble {
  background: var(--brand-500); color: white;
  border-bottom-right-radius: 4px;
}
.chat-msg.assistant .bubble {
  background: var(--bg-subtle);
  border-bottom-left-radius: 4px;
}
.chat-input-bar {
  padding: 12px;
  border-top: 1px solid var(--border-soft);
  display: flex; gap: 8px;
}
.chat-input-bar textarea {
  flex: 1;
  resize: none;
  height: 44px;
  min-height: 44px;
  max-height: 100px;
}

@media (max-width: 900px) {
  .wf-editor { grid-template-columns: 1fr; }
  .chat-layout { grid-template-columns: 1fr; height: auto; }
}
