:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #e3e9f0;
  --primary: #0f766e;
  --primary-dark: #0b5d57;
  --primary-soft: #e9f8f5;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --success: #067647;
  --success-soft: #ecfdf3;
  --warning: #b45309;
  --warning-soft: #fff7e6;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --grey-soft: #f2f4f7;
  --shadow: 0 16px 38px rgba(28, 45, 70, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 0 0, rgba(15, 118, 110, 0.08), transparent 30%),
    radial-gradient(circle at 100% 4%, rgba(37, 99, 235, 0.06), transparent 28%),
    var(--bg);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

.shell { width: min(1240px, calc(100% - 28px)); margin: 0 auto; padding: 22px 0 56px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  color: white; font-weight: 850; background: linear-gradient(145deg, #0f766e, #14b8a6);
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.22);
}
.brand h1 { margin: 0; font-size: 20px; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.tag {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px;
  border: 1px solid #cbe8e3; border-radius: 999px; background: var(--primary-soft);
  color: var(--primary-dark); font-size: 12px; font-weight: 750;
}
.tag::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #14b8a6; box-shadow: 0 0 0 4px rgba(20,184,166,.12); }

.hero {
  position: relative; overflow: hidden; margin-bottom: 22px; padding: 28px 30px;
  border-radius: 24px; color: white; background: linear-gradient(125deg, #0f766e, #155e75);
  box-shadow: var(--shadow);
}
.hero::after {
  content: ""; position: absolute; width: 320px; height: 320px; border: 54px solid rgba(255,255,255,.06);
  border-radius: 50%; right: -90px; top: -150px;
}
.hero > * { position: relative; z-index: 1; }
.hero h2 { margin: 0 0 9px; font-size: clamp(25px, 4vw, 36px); }
.hero p { margin: 0; max-width: 850px; color: rgba(255,255,255,.84); line-height: 1.75; font-size: 14px; }
.hero-flow { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.hero-flow span { padding: 7px 11px; border: 1px solid rgba(255,255,255,.17); background: rgba(255,255,255,.08); border-radius: 999px; font-size: 12px; }

.page-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(320px, .75fr); gap: 22px; align-items: start; }
.stack { display: grid; gap: 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card.locked { opacity: .62; }
.card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 20px 22px 16px; border-bottom: 1px solid var(--line); }
.card-title-wrap { display: flex; gap: 12px; align-items: flex-start; }
.index { width: 34px; height: 34px; flex: 0 0 auto; display: grid; place-items: center; color: var(--primary-dark); background: var(--primary-soft); border-radius: 11px; font-size: 13px; font-weight: 850; }
.card h3 { margin: 0; font-size: 17px; }
.desc { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.card-body { padding: 20px 22px 22px; }

.state-badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.state-waiting, .state-queued { background: var(--grey-soft); color: #667085; }
.state-ready, .state-running, .state-allocating_gpu, .state-starting_gpu, .state-waiting_worker, .state-claimed, .state-downloading, .state-uploading { background: var(--blue-soft); color: var(--blue); }
.state-completed, .state-success { background: var(--success-soft); color: var(--success); }
.state-failed { background: var(--danger-soft); color: var(--danger); }
.state-needs_confirmation, .state-production_finishing { background: var(--warning-soft); color: var(--warning); }
.state-cancelled, .state-skipped { background: var(--grey-soft); color: #667085; }

.upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.upload-box { border: 1.5px dashed #cbd5e1; border-radius: 15px; padding: 16px; background: #fbfdff; transition: .2s; }
.upload-box.valid { border-color: #70c5b8; background: #f8fffd; }
.upload-box.invalid { border-color: #fda29b; background: #fffafa; }
.upload-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 9px; }
.upload-title strong { font-size: 14px; }
.format-label { padding: 4px 7px; border-radius: 999px; background: #eef2f6; color: #475467; font-size: 10px; font-weight: 800; }
.file-picker { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: white; color: #344054; }
.file-meta { min-height: 38px; margin-top: 10px; color: var(--muted); font-size: 11px; line-height: 1.65; word-break: break-all; }
.file-meta.error { color: var(--danger); }

.notice { margin-top: 14px; padding: 12px 13px; border-radius: 12px; font-size: 12px; line-height: 1.65; }
.notice-info { border: 1px solid #bfdbfe; background: var(--blue-soft); color: #1d4ed8; }
.notice-warning { border: 1px solid #f5d08c; background: var(--warning-soft); color: #92400e; }
.notice-success { border: 1px solid #a6e4c5; background: var(--success-soft); color: var(--success); }
.notice-error { border: 1px solid #fda29b; background: var(--danger-soft); color: var(--danger); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.btn { min-height: 42px; padding: 0 16px; border: 0; border-radius: 11px; font-weight: 760; transition: .15s; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { color: white; background: var(--primary); box-shadow: 0 9px 22px rgba(15,118,110,.18); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { color: #344054; background: var(--grey-soft); }
.btn-outline { color: var(--primary-dark); background: white; border: 1px solid #b7ddd7; }
.btn-danger { color: var(--danger); background: var(--danger-soft); border: 1px solid #fda29b; }
.btn-small { min-height: 34px; padding: 0 11px; border-radius: 9px; font-size: 11px; }

.section-title { margin: 2px 0 11px; color: #344054; font-size: 13px; font-weight: 850; }
.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.table th, .table td { padding: 11px 10px; border-bottom: 1px solid var(--line); font-size: 12px; text-align: left; vertical-align: middle; }
.table th { background: #f8fafc; color: var(--muted); font-weight: 700; }
.table tr:last-child td { border-bottom: 0; }
.fixed { color: var(--muted); }

select, input[type="number"], input[type="text"], textarea {
  width: 100%; min-height: 40px; padding: 0 10px; border: 1px solid #d0d8e2; border-radius: 10px; background: white; outline: none;
}
textarea { min-height: 86px; padding-top: 10px; resize: vertical; }
select:focus, input:focus, textarea:focus { border-color: #2f9e95; box-shadow: 0 0 0 4px rgba(15,118,110,.1); }
.inline-radio { display: flex; flex-wrap: wrap; gap: 12px; }
.inline-radio label { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.manual-charge { display: none; margin-top: 9px; max-width: 180px; }
.manual-charge.show { display: block; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.field { padding: 14px; border: 1px solid var(--line); border-radius: 13px; }
.field.modified { border-color: #f1c26b; background: #fffdf8; }
.field.invalid { border-color: #fda29b; background: #fffafa; }
.field-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.field label { font-size: 12px; font-weight: 760; }
.default { color: var(--muted); font-size: 10px; }
.input-unit { position: relative; }
.input-unit input { padding-right: 58px; }
.unit { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 11px; }
.help { min-height: 16px; margin-top: 6px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.help.error { color: var(--danger); }

.summary-card { position: sticky; top: 18px; }
.summary-list { display: grid; }
.summary-row { display: flex; justify-content: space-between; gap: 15px; padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 12px; }
.summary-row:last-child { border-bottom: 0; }
.summary-row span:first-child { color: var(--muted); }
.summary-row span:last-child { max-width: 62%; text-align: right; font-weight: 760; word-break: break-word; }
.calc { margin-top: 15px; padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: #f8fafc; }
.calc h4 { margin: 0 0 8px; font-size: 12px; }
.calc-row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 11px; }
.calc-row span:first-child { color: var(--muted); }
.confirm-lock { margin-top: 10px; color: var(--muted); font-size: 11px; line-height: 1.6; }

.progress-shell { height: 10px; overflow: hidden; border-radius: 999px; background: #eef2f6; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg,#0f766e,#14b8a6); transition: width .35s; }
.progress-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; color: var(--muted); font-size: 11px; }

.resource-strip { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
.metric-card { padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #fbfdff; }
.metric-card .label { color: var(--muted); font-size: 10px; }
.metric-card .value { margin-top: 7px; font-size: 16px; font-weight: 850; line-height: 1.35; word-break: break-word; }
.metric-card .sub { margin-top: 5px; color: var(--muted); font-size: 10px; line-height: 1.45; }

.pipeline { display: grid; gap: 10px; margin-top: 18px; }
.pipe-step { display: grid; grid-template-columns: 36px minmax(0,1fr) auto; gap: 12px; align-items: start; padding: 13px 14px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.pipe-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--grey-soft); color: #98a2b3; font-weight: 900; }
.pipe-step.running { border-color: #93c5fd; background: #fbfdff; }
.pipe-step.running .pipe-icon { color: var(--blue); background: var(--blue-soft); animation: pulse 1.1s infinite; }
.pipe-step.completed, .pipe-step.success { border-color: #a6e4c5; background: #fbfffd; }
.pipe-step.completed .pipe-icon, .pipe-step.success .pipe-icon { color: var(--success); background: var(--success-soft); }
.pipe-step.failed { border-color: #fda29b; background: #fffafa; }
.pipe-step.failed .pipe-icon { color: var(--danger); background: var(--danger-soft); }
.pipe-step.needs_confirmation, .pipe-step.production_finishing { border-color: #f5d08c; background: #fffdf7; }
.pipe-step.needs_confirmation .pipe-icon, .pipe-step.production_finishing .pipe-icon { color: var(--warning); background: var(--warning-soft); }
.pipe-title { margin-bottom: 4px; font-size: 13px; font-weight: 820; }
.pipe-message { color: var(--muted); font-size: 11px; line-height: 1.55; }
.pipe-status { padding-top: 7px; color: #667085; font-size: 10px; font-weight: 800; }
.pipe-progress { height: 6px; margin-top: 9px; overflow: hidden; border-radius: 999px; background: #edf1f5; }
.pipe-progress > span { display: block; height: 100%; background: var(--primary); }
.pipe-error { margin-top: 9px; padding: 10px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 11px; line-height: 1.6; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(37,99,235,.2); } 50% { box-shadow: 0 0 0 7px rgba(37,99,235,0); } }

.timeline { display: grid; gap: 10px; }
.timeline-row { display: grid; grid-template-columns: 180px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 12px; }
.timeline-row:last-child { border-bottom: 0; }
.timeline-row .key { color: var(--muted); }
.timeline-row .val { font-weight: 700; word-break: break-word; }

.tabs { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 16px; }
.tab-btn { min-height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; background: white; color: #475467; font-size: 11px; font-weight: 760; }
.tab-btn.active { border-color: #94d4ca; background: var(--primary-soft); color: var(--primary-dark); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.artifact-list { display: grid; gap: 10px; }
.artifact-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 12px; align-items: center; padding: 12px 13px; border: 1px solid var(--line); border-radius: 12px; }
.artifact-name { font-size: 12px; font-weight: 780; word-break: break-all; }
.artifact-meta { margin-top: 4px; color: var(--muted); font-size: 10px; }

/* 下载进度条 */
.md-download-status { margin-top: 6px; min-height: 20px; }
.md-progress { margin-top: 4px; height: 6px; border-radius: 3px; background: #e2e8f0; overflow: hidden; }
.md-progress-bar { height: 100%; border-radius: 3px; background: linear-gradient(90deg, #3b82f6, #6366f1); transition: width .3s; }
.md-progress-text { margin-top: 3px; font-size: 11px; color: var(--muted); }

.empty { padding: 20px; border: 1px dashed #ccd5df; border-radius: 13px; color: var(--muted); text-align: center; font-size: 12px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgba(15,23,42,.46); }
.modal { width: min(640px,100%); max-height: 88vh; overflow: auto; border-radius: 18px; background: white; box-shadow: 0 24px 70px rgba(0,0,0,.25); }
.modal-header { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-header h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px 20px 20px; }

.toast { position: fixed; left: 50%; bottom: 25px; z-index: 200; opacity: 0; pointer-events: none; transform: translate(-50%,15px); padding: 10px 14px; border-radius: 10px; background: #172033; color: white; font-size: 12px; box-shadow: 0 14px 30px rgba(0,0,0,.18); transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%,0); }
.spinner { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.45); border-top-color: white; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.footer { margin-top: 22px; color: var(--muted); text-align: center; font-size: 11px; line-height: 1.7; }

@media (max-width: 960px) {
  .page-grid { grid-template-columns: 1fr; }
  .summary-card { position: static; }
  .resource-strip { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 680px) {
  .shell { width: min(100% - 18px,1240px); padding-top: 14px; }
  .tag { display: none; }
  .hero { padding: 22px 18px; }
  .upload-grid, .field-grid, .resource-strip { grid-template-columns: 1fr; }
  .card-header, .card-body { padding-left: 15px; padding-right: 15px; }
  .actions .btn { width: 100%; }
  .pipe-step { grid-template-columns: 32px minmax(0,1fr); }
  .pipe-status { grid-column: 2; }
  .timeline-row { grid-template-columns: 1fr; gap: 4px; }
  .artifact-row { grid-template-columns: 1fr; }
}
