:root {
  --ink: #172033;
  --muted: #6b7280;
  --line: #e5e7eb;
  --surface: #ffffff;
  --canvas: #f5f7fb;
  --sidebar: #111827;
  --sidebar-muted: #9ca3af;
  --accent: #5b5bd6;
  --accent-strong: #4646b8;
  --accent-soft: #eef0ff;
  --success: #16805b;
  --success-soft: #e8f7f0;
  --warning: #9a6700;
  --warning-soft: #fff6dc;
  --danger: #b42318;
  --danger-soft: #fff0ef;
  --info: #175cd3;
  --radius: 16px;
  --shadow: 0 10px 35px rgba(17, 24, 39, 0.06);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 85% -10%, rgba(91, 91, 214, 0.12), transparent 32rem),
    var(--canvas);
  font-family: "Inter", "SF Pro Display", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(1.55rem, 2vw, 2rem); letter-spacing: -0.035em; margin-bottom: 0; }
h2 { font-size: 1.08rem; letter-spacing: -0.02em; margin-bottom: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.78rem; }
.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--accent);
  font-size: 0.67rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
[hidden] { display: none !important; }

/* Login */
.login-overlay {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
  background:
    linear-gradient(135deg, rgba(17, 24, 39, 0.94), rgba(48, 48, 110, 0.92)),
    repeating-linear-gradient(45deg, transparent 0 28px, rgba(255,255,255,.025) 28px 29px);
}
.login-card {
  width: min(430px, 100%);
  padding: 2.2rem;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 24px;
  background: rgba(255,255,255,.97);
  box-shadow: 0 30px 80px rgba(0,0,0,.28);
}
.login-card h1 { margin: 1.1rem 0 .5rem; font-size: 1.7rem; }
.login-card form { display: grid; gap: .7rem; margin-top: 1.5rem; }
.login-card label { font-size: .8rem; font-weight: 700; }
.login-card input {
  width: 100%;
  padding: .8rem .9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcff;
}
.login-hint { margin: 1.1rem 0 0; color: var(--muted); font-size: .73rem; }
.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: white;
  background: linear-gradient(135deg, #818cf8, #4f46e5);
  font-weight: 900;
  font-size: 1.3rem;
  box-shadow: 0 10px 24px rgba(79, 70, 229, .28);
}

/* Shell */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  padding: 1.6rem 1.1rem 1.2rem;
  color: white;
  background: var(--sidebar);
}
.brand { display: flex; align-items: center; gap: .8rem; padding: 0 .4rem; }
.brand strong { display: block; letter-spacing: .08em; font-size: .9rem; }
.brand span { display: block; color: var(--sidebar-muted); font-size: .72rem; }
.nav { display: grid; gap: .28rem; }
.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  width: 100%;
  padding: .72rem .7rem;
  border: 0;
  border-radius: 10px;
  color: #c7cbd5;
  background: transparent;
  text-align: left;
  transition: background .16s ease, color .16s ease;
}
.nav-item:hover { color: white; background: rgba(255,255,255,.07); }
.nav-item.active { color: white; background: rgba(129, 140, 248, .18); }
.nav-index { color: #6f7789; font-size: .63rem; font-weight: 800; letter-spacing: .08em; }
.nav-item.active .nav-index { color: #a5b4fc; }
.sidebar-footer { margin-top: auto; display: grid; gap: 1rem; padding: 0 .4rem; }
.connection { display: flex; align-items: center; gap: .5rem; color: var(--sidebar-muted); font-size: .72rem; }
.dot { width: 7px; height: 7px; border-radius: 999px; background: #6b7280; }
.dot.ok { background: #34d399; box-shadow: 0 0 0 4px rgba(52, 211, 153, .12); }
.dot.bad { background: #f87171; box-shadow: 0 0 0 4px rgba(248, 113, 113, .12); }

.main { min-width: 0; padding: 1.8rem clamp(1rem, 3.5vw, 3rem) 4rem; }
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.top-actions { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; justify-content: flex-end; }
.view { display: none; animation: rise .22s ease both; }
.view.active { display: grid; gap: 1.1rem; }
@keyframes rise { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* Buttons and pills */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 36px;
  padding: .55rem .82rem;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: .8rem;
  font-weight: 700;
  transition: transform .12s ease, background .16s ease, border-color .16s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { color: white; background: var(--accent); }
.btn-primary:hover { background: var(--accent-strong); }
.btn-secondary { color: var(--ink); background: white; border-color: var(--line); }
.btn-secondary:hover { border-color: #b9bfcc; }
.btn-danger { color: var(--danger); background: var(--danger-soft); border-color: #ffd5d2; }
.btn-ghost { color: #c7cbd5; background: transparent; border-color: rgba(255,255,255,.12); }
.btn-small { min-height: 30px; padding: .35rem .6rem; font-size: .72rem; }
.btn-block { width: 100%; }
.button-row { display: flex; gap: .45rem; flex-wrap: wrap; justify-content: flex-end; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  min-height: 28px;
  padding: .25rem .6rem;
  border-radius: 999px;
  color: var(--muted);
  background: #eef1f6;
  font-size: .7rem;
  font-weight: 800;
  white-space: nowrap;
}
.pill.ok { color: var(--success); background: var(--success-soft); }
.pill.warn { color: var(--warning); background: var(--warning-soft); }
.pill.bad { color: var(--danger); background: var(--danger-soft); }
.pill-idle { color: #4b5563; background: #eef1f6; }
.pill-running { color: var(--info); background: #eaf2ff; }

/* Cards and panels */
.card-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .8rem; }
.status-card {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.status-card .label { color: var(--muted); font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.status-card .value { margin-top: .45rem; font-size: 1.55rem; font-weight: 800; letter-spacing: -.04em; }
.status-card .hint { margin-top: .25rem; color: var(--muted); font-size: .72rem; }
.panel {
  padding: 1.15rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.panel-subheading { display: flex; align-items: baseline; justify-content: space-between; gap: .7rem; margin-bottom: .6rem; }
.split-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 1.1rem; }
.runs-top { grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); }
.stack { display: grid; gap: .5rem; }
.blocker {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  padding: .68rem .75rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fbfcff;
  font-size: .8rem;
}
.blocker.error { border-color: #ffd5d2; background: var(--danger-soft); }
.blocker.warning { border-color: #ffe7ae; background: var(--warning-soft); }
.blocker-mark { width: 8px; height: 8px; border-radius: 999px; margin-top: .42rem; flex: 0 0 auto; background: var(--info); }
.blocker.error .blocker-mark { background: var(--danger); }
.blocker.warning .blocker-mark { background: var(--warning); }
.empty-state { padding: 1.1rem; color: var(--muted); border: 1px dashed var(--line); border-radius: 10px; text-align: center; font-size: .8rem; }

.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.action-card {
  display: grid;
  gap: .18rem;
  padding: .8rem;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fbfcff;
  text-align: left;
}
.action-card:hover { border-color: #a5b4fc; background: var(--accent-soft); }
.action-card strong { font-size: .8rem; }
.action-card span { color: var(--muted); font-size: .7rem; }

/* Tables */
.table-scroll, .matrix-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.data-table { width: 100%; border-collapse: collapse; min-width: 720px; }
.data-table th, .data-table td { padding: .6rem .65rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.data-table th { position: sticky; top: 0; z-index: 1; color: var(--muted); background: #f8faff; font-size: .68rem; letter-spacing: .04em; text-transform: uppercase; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fafbff; }
.data-table td { font-size: .78rem; }
.matrix-table { min-width: 620px; }
.matrix-table td, .matrix-table th { text-align: center; }
.matrix-table td:first-child, .matrix-table th:first-child { text-align: left; }
.matrix-cell { display: inline-flex; min-width: 2rem; justify-content: center; padding: .18rem .4rem; border-radius: 7px; font-size: .7rem; font-weight: 800; }
.matrix-cell.ready { color: var(--success); background: var(--success-soft); }
.matrix-cell.missing { color: var(--danger); background: var(--danger-soft); }
.matrix-cell.optional { color: var(--muted); background: #f0f2f6; }
.matrix-cell.excluded { color: #8b5e00; background: var(--warning-soft); }
.row-actions { display: flex; gap: .3rem; }
.icon-button { border: 0; background: transparent; color: var(--muted); font-size: .72rem; padding: .2rem .3rem; }
.icon-button:hover { color: var(--accent); }
.icon-button.danger:hover { color: var(--danger); }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.form-grid label, .modal-form label { display: grid; gap: .3rem; color: var(--muted); font-size: .72rem; font-weight: 700; }
input, select {
  width: 100%;
  min-height: 35px;
  padding: .45rem .55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fbfcff;
  outline: none;
}
input:focus, select:focus { border-color: #a5b4fc; box-shadow: 0 0 0 3px rgba(99, 102, 241, .12); }
.form-actions { display: flex; align-items: end; gap: .5rem; }
.pilot-picker { margin-top: 1rem; }
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .35rem; max-height: 220px; overflow: auto; padding-right: .2rem; }
.check-row { display: flex; align-items: flex-start; gap: .45rem; padding: .4rem .45rem; border: 1px solid var(--line); border-radius: 8px; font-size: .72rem; }
.check-row input { width: auto; min-height: auto; margin-top: .15rem; }
.check-row span { display: grid; gap: .08rem; }
.check-row small { color: var(--muted); font-size: .68rem; }
.notice { padding: .7rem .8rem; border-radius: 9px; color: #475467; background: #f4f7ff; font-size: .76rem; }
.error-text { min-height: 1.2rem; margin: .7rem 0 0; color: var(--danger); font-size: .78rem; }
.error-box { padding: .7rem .8rem; border: 1px solid #ffd5d2; border-radius: 9px; color: var(--danger); background: var(--danger-soft); font-size: .78rem; white-space: pre-wrap; }
.success { color: var(--success); }

/* Logs and results */
.log-console {
  min-height: 310px;
  max-height: 440px;
  overflow: auto;
  margin: 0;
  padding: .8rem;
  border-radius: 10px;
  color: #d1d5db;
  background: #0b1020;
  font: 0.72rem/1.55 "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
  word-break: break-word;
}
.log-console:empty::before { content: "等待任务输出..."; color: #6b7280; }
.dag-thumb {
  display: block;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcff;
}
.dag-thumb img { display: block; width: 100%; height: auto; }
.dag-caption { margin: .7rem 0 0; }
.figure-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.figure-card { border: 1px solid var(--line); border-radius: 11px; overflow: hidden; background: #fbfcff; }
.figure-card a { display: block; }
.figure-card img { display: block; width: 100%; height: 190px; object-fit: contain; background: white; }
.figure-card div { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .55rem .65rem; font-size: .72rem; }
.link-list { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: 1rem; }
.link-list a { padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: #fbfcff; font-size: .75rem; }
.detail-list { display: grid; gap: .5rem; }
.detail-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding-bottom: .45rem; border-bottom: 1px dashed var(--line); font-size: .77rem; }
.detail-row:last-child { border-bottom: 0; padding-bottom: 0; }
.detail-row span:first-child { color: var(--muted); }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .45rem; }
.tool { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .55rem .6rem; border: 1px solid var(--line); border-radius: 8px; font-size: .74rem; }
.tool.ok { color: var(--success); background: var(--success-soft); }
.tool.bad { color: var(--danger); background: var(--danger-soft); }

/* Modal and toast */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(17, 24, 39, .56);
  backdrop-filter: blur(4px);
}
.modal {
  width: min(820px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 1.3rem;
  border-radius: 18px;
  background: white;
  box-shadow: 0 30px 80px rgba(0,0,0,.28);
}
.modal h2 { margin-bottom: .2rem; }
.modal-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; margin-top: 1rem; }
.modal-form .full { grid-column: 1 / -1; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
.toast {
  position: fixed;
  right: 1.3rem;
  bottom: 1.3rem;
  z-index: 60;
  max-width: min(450px, calc(100vw - 2rem));
  padding: .75rem 1rem;
  border: 1px solid #c7d7fe;
  border-radius: 10px;
  color: #1e3a8a;
  background: #eff6ff;
  box-shadow: 0 14px 35px rgba(17,24,39,.16);
  font-size: .8rem;
}
.toast.error { color: var(--danger); border-color: #ffd5d2; background: var(--danger-soft); }

@media (max-width: 1050px) {
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split-grid, .runs-top { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 1rem; gap: 1rem; }
  .nav { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .nav-item { justify-content: center; font-size: .7rem; padding: .5rem .25rem; }
  .nav-index { display: none; }
  .sidebar-footer { display: flex; justify-content: space-between; align-items: center; }
  .main { padding: 1.2rem 1rem 3rem; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .top-actions { justify-content: flex-start; }
  .card-grid, .quick-actions, .figure-grid, .form-grid, .modal-form { grid-template-columns: 1fr; }
  .modal-form .full { grid-column: auto; }
  .check-grid { grid-template-columns: 1fr; }
  .button-row { justify-content: flex-start; }
}
