:root {
  --ink: #17202a;
  --muted: #687483;
  --line: #dfe5eb;
  --soft: #f4f7f9;
  --paper: #ffffff;
  --brand: #155a52;
  --brand-deep: #0d443e;
  --brand-soft: #e5f2ef;
  --accent: #d89931;
  --danger: #b53b32;
  --danger-soft: #faeae8;
  --warning: #8a5b00;
  --warning-soft: #fff4d8;
  --success: #28764d;
  --success-soft: #e8f5ed;
  --shadow: 0 14px 40px rgba(32, 50, 59, 0.09);
  --radius: 18px;
  font-family: "Segoe UI", "Microsoft YaHei UI", "PingFang SC", sans-serif;
  color: var(--ink);
  background: #eef3f4;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: linear-gradient(150deg, #f7f9f8 0%, #eaf1f2 100%); }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled, input:disabled, select:disabled { cursor: not-allowed; opacity: 0.55; }
a { color: inherit; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(1.9rem, 4vw, 2.65rem); letter-spacing: -0.04em; }
h2 { margin-bottom: 6px; font-size: 1.2rem; letter-spacing: -0.02em; }
h3 { margin-bottom: 14px; font-size: 1rem; }
.hidden { display: none !important; }
.muted, .helper { color: var(--muted); }
.helper { margin: 7px 0 0; font-size: 0.82rem; line-height: 1.5; }
.eyebrow { margin-bottom: 5px; color: var(--brand); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.skip-link { position: fixed; z-index: 100; top: 8px; left: 8px; padding: 10px 14px; transform: translateY(-150%); border-radius: 8px; background: var(--ink); color: white; }
.skip-link:focus { transform: translateY(0); }

.topbar { position: sticky; z-index: 20; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 72px; padding: 10px max(22px, calc((100vw - 1500px) / 2)); border-bottom: 1px solid rgba(23, 32, 42, 0.1); background: rgba(249, 251, 250, 0.93); backdrop-filter: blur(16px); }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 1rem; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 0.74rem; }
.brand-mark { display: grid; width: 42px; height: 42px; flex: 0 0 42px; place-items: center; border-radius: 13px; background: var(--brand); color: #fff; font-family: Georgia, serif; font-size: 1.35rem; font-weight: 700; box-shadow: 0 8px 20px rgba(21, 90, 82, 0.22); }
.top-actions { display: flex; align-items: center; gap: 8px; }
.current-user { margin-right: 6px; color: var(--muted); font-size: 0.88rem; }

.page-shell { width: min(1500px, calc(100% - 40px)); margin: 24px auto 60px; }
.notice { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; padding: 15px 18px; border: 1px solid #ebcd83; border-radius: 14px; background: var(--warning-soft); color: #624713; }
.notice strong, .notice span { display: block; }
.notice span { margin-top: 3px; font-size: 0.85rem; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.metric-card, .panel { border: 1px solid rgba(31, 54, 61, 0.1); background: rgba(255, 255, 255, 0.96); box-shadow: var(--shadow); }
.metric-card { min-height: 132px; padding: 20px; border-radius: 16px; }
.metric-label, .metric-note { display: block; color: var(--muted); }
.metric-label { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; }
.metric-value { display: block; margin: 8px 0 4px; font-size: clamp(1.8rem, 4vw, 2.55rem); line-height: 1; }
.metric-note { overflow: hidden; font-size: 0.78rem; line-height: 1.45; text-overflow: ellipsis; }

.panel { overflow: hidden; border-radius: var(--radius); }
.panel + .panel { margin-top: 16px; }
.panel-heading { padding: 20px 22px 16px; border-bottom: 1px solid var(--line); }
.panel-heading p:last-child { margin-bottom: 0; color: var(--muted); font-size: 0.84rem; line-height: 1.5; }
.split-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.panel-body { padding: 20px 22px 24px; }
.workspace-grid { display: grid; grid-template-columns: minmax(360px, 0.8fr) minmax(620px, 1.7fr); align-items: start; gap: 16px; margin-top: 16px; }
.workspace-grid > .panel { margin-top: 0; }
.jobs-panel { min-width: 0; }
.stack > * + * { margin-top: 15px; }

.button { min-height: 40px; padding: 9px 15px; border: 1px solid transparent; border-radius: 10px; font-weight: 750; transition: border-color 0.15s, background 0.15s, transform 0.15s; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, .upload-zone:focus-within { outline: 3px solid rgba(21, 90, 82, 0.23); outline-offset: 2px; }
.button.primary { background: var(--brand); color: white; }
.button.primary:hover:not(:disabled) { background: var(--brand-deep); }
.button.secondary { border-color: var(--line); background: var(--paper); color: var(--ink); }
.button.quiet { min-height: 36px; padding: 7px 10px; background: transparent; color: var(--muted); }
.button.danger { background: var(--danger); color: #fff; }
.button.warning-button { background: #6d4c08; color: #fff; }
.button.full { width: 100%; }
.icon-button { width: 38px; height: 38px; border: 0; border-radius: 50%; background: var(--soft); color: var(--muted); font-size: 1.4rem; }

.field { display: block; color: var(--ink); font-size: 0.88rem; font-weight: 700; }
.field > span, .field > small { display: block; }
.field small { margin-top: 5px; color: var(--muted); font-size: 0.74rem; font-weight: 500; }
.field input, .field select, .field textarea { width: 100%; margin-top: 7px; border: 1px solid #cfd8de; border-radius: 10px; background: #fff; color: var(--ink); }
.field input, .field select { min-height: 43px; padding: 9px 11px; }
.field textarea { min-height: 150px; padding: 12px; resize: vertical; line-height: 1.6; }
.field.compact { font-size: 0.8rem; }
.field.compact input, .field.compact select { min-height: 39px; }
.label-row { display: flex !important; align-items: baseline; justify-content: space-between; gap: 10px; }
.label-row small { color: var(--muted); font-size: 0.74rem; font-weight: 500; }
.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error { min-height: 1.2em; margin: 0; color: var(--danger); font-size: 0.82rem; font-weight: 650; }

.upload-zone { position: relative; display: grid; min-height: 140px; margin-top: 8px; padding: 18px; place-items: center; align-content: center; gap: 5px; border: 1.5px dashed #9cb7b2; border-radius: 14px; background: var(--brand-soft); color: var(--brand-deep); text-align: center; transition: 0.15s; }
.upload-zone:hover, .upload-zone.dragging { border-color: var(--brand); background: #dceeea; }
.upload-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-zone span:last-child { color: var(--muted); font-size: 0.77rem; font-weight: 500; }
.upload-icon { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; background: #fff; font-size: 1.25rem; }
.preview-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin-top: 10px; }
.preview-card { position: relative; overflow: hidden; aspect-ratio: 1; border-radius: 10px; background: var(--soft); }
.preview-card img { width: 100%; height: 100%; object-fit: cover; }
.preview-card span { position: absolute; right: 6px; bottom: 6px; padding: 3px 6px; border-radius: 6px; background: rgba(10, 22, 24, 0.76); color: #fff; font-size: 0.68rem; }

.parameter-box { margin: 0; padding: 16px; border: 1px solid var(--line); border-radius: 13px; background: var(--soft); }
.parameter-box legend { padding: 0 5px; font-size: 0.85rem; font-weight: 800; }
.parameter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.parameter-summary { margin: 13px 0 0; padding: 9px 11px; border-radius: 9px; background: var(--paper); color: var(--brand-deep); font-size: 0.79rem; font-weight: 700; }
.warning-text { color: var(--warning); }

.table-scroll { overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.data-table th { position: sticky; z-index: 1; top: 0; padding: 11px 12px; background: #f5f7f7; color: var(--muted); font-size: 0.71rem; letter-spacing: 0.03em; text-align: left; white-space: nowrap; }
.data-table td { padding: 13px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
.data-table tr:hover td { background: #fafcfb; }
.jobs-table tbody tr:first-child td { border-top: 0; }
.job-main { min-width: 270px; max-width: 500px; }
.job-id { margin-bottom: 4px; font-weight: 750; }
.job-prompt { overflow: hidden; max-width: 460px; color: var(--muted); line-height: 1.45; text-overflow: ellipsis; white-space: nowrap; }
.empty-state { padding: 30px !important; color: var(--muted); text-align: center !important; }
.download-link { display: inline-flex; padding: 6px 10px; border-radius: 8px; background: var(--brand-soft); color: var(--brand-deep); font-weight: 750; text-decoration: none; white-space: nowrap; }
.download-link:hover { text-decoration: underline; }
.artifact-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.archive-state { font-size: 0.68rem; font-weight: 750; white-space: nowrap; color: var(--muted); }
.archive-state.archived { color: var(--success); }
.archive-state.failed { color: var(--danger); }
.archive-state.leased { color: var(--warning); }

.status-pill { display: inline-flex; align-items: center; min-height: 25px; padding: 4px 8px; border-radius: 999px; font-size: 0.7rem; font-weight: 800; white-space: nowrap; }
.status-pill.success, .status-pill.completed { background: var(--success-soft); color: var(--success); }
.status-pill.warning, .status-pill.leased, .status-pill.running { background: var(--warning-soft); color: var(--warning); }
.status-pill.danger, .status-pill.failed { background: var(--danger-soft); color: var(--danger); }
.status-pill.neutral, .status-pill.queued { background: #edf0f2; color: #596673; }

.dispatch-panel { border-color: rgba(181, 59, 50, 0.28); }
.dispatch-panel .panel-heading { border-bottom: 0; background: linear-gradient(100deg, #fff 0%, #fff6f4 100%); }
.dispatch-control { display: flex; align-items: center; gap: 10px; }
.admin-area { margin-top: 16px; }
.worker-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 12px; padding: 18px 22px 22px; }
.worker-card { padding: 16px; border: 1px solid var(--line); border-radius: 13px; background: var(--soft); }
.worker-card-head { display: flex; align-items: start; justify-content: space-between; gap: 10px; }
.worker-card h3 { margin-bottom: 3px; }
.worker-id { color: var(--muted); font-size: 0.72rem; }
.worker-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
.worker-fact { padding: 9px; border-radius: 9px; background: white; }
.worker-fact span, .worker-fact strong { display: block; }
.worker-fact span { margin-bottom: 4px; color: var(--muted); font-size: 0.68rem; }
.worker-fact strong { overflow: hidden; font-size: 0.8rem; text-overflow: ellipsis; white-space: nowrap; }
.worker-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.worker-actions .button { min-height: 34px; padding: 6px 9px; font-size: 0.74rem; }
.worker-error { margin: 8px 0 0; color: var(--danger); font-size: 0.72rem; }
.admin-split { display: grid; grid-template-columns: minmax(250px, 0.52fr) minmax(620px, 1.48fr); align-items: start; gap: 18px; }
.subpanel { padding: 16px; border: 1px solid var(--line); border-radius: 13px; background: var(--soft); }
.account-table-wrap { border: 1px solid var(--line); border-radius: 13px; }
.account-table input, .account-table select { min-width: 90px; min-height: 34px; padding: 5px 7px; border: 1px solid #cfd8de; border-radius: 8px; background: white; }
.account-table .password-reset { min-width: 150px; }
.account-name strong, .account-name small { display: block; }
.account-name small { margin-top: 3px; color: var(--muted); }
.account-actions { display: flex; gap: 6px; }
.account-actions .button { min-height: 34px; padding: 6px 9px; font-size: 0.72rem; }

.dialog { width: min(460px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 18px; background: transparent; box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(12, 23, 27, 0.54); backdrop-filter: blur(3px); }
.dialog-card { margin: 0; padding: 24px; border-radius: 18px; background: white; }
.dialog-heading { display: flex; align-items: start; justify-content: space-between; gap: 15px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; }
.danger-symbol { display: grid; width: 48px; height: 48px; place-items: center; border-radius: 50%; background: var(--danger-soft); color: var(--danger); font-size: 1.4rem; font-weight: 900; }

.toast { position: fixed; z-index: 80; right: 22px; bottom: 22px; max-width: min(420px, calc(100% - 44px)); padding: 12px 16px; transform: translateY(20px); border-radius: 11px; background: #132a2a; color: white; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: 0.2s; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--danger); }

.login-page { display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 15% 15%, #d7ebe6 0, transparent 36%), radial-gradient(circle at 88% 82%, #f1ddbc 0, transparent 30%), #edf2f1; }
.login-shell { width: min(430px, 100%); }
.login-card { padding: 34px; border: 1px solid rgba(31, 54, 61, 0.1); border-radius: 24px; background: rgba(255, 255, 255, 0.95); box-shadow: 0 24px 70px rgba(29, 55, 57, 0.14); }
.login-card .brand-mark { margin-bottom: 22px; }
.login-card .muted { margin-bottom: 24px; line-height: 1.6; }

@media (max-width: 1100px) {
  .metrics { grid-template-columns: 1fr 1fr; }
  .workspace-grid, .admin-split { grid-template-columns: 1fr; }
  .jobs-panel { margin-top: 0; }
}

@media (max-width: 680px) {
  .topbar { position: static; align-items: flex-start; padding: 12px 15px; }
  .brand small, .current-user { display: none; }
  .brand-mark { width: 38px; height: 38px; flex-basis: 38px; }
  .top-actions { gap: 2px; }
  .button.quiet { padding-inline: 7px; font-size: 0.78rem; }
  .page-shell { width: min(100% - 22px, 1500px); margin-top: 12px; }
  .metrics { gap: 9px; }
  .metric-card { min-height: 112px; padding: 15px; }
  .metric-value { font-size: 1.8rem; }
  .split-heading, .notice { align-items: stretch; flex-direction: column; }
  .dispatch-control { justify-content: space-between; }
  .parameter-grid, .two-columns { grid-template-columns: 1fr; }
  .panel-heading, .panel-body { padding-right: 16px; padding-left: 16px; }
  .data-table.jobs-table, .jobs-table tbody, .jobs-table tr, .jobs-table td { display: block; width: 100%; }
  .jobs-table thead { position: absolute; overflow: hidden; width: 1px; height: 1px; clip: rect(0 0 0 0); }
  .jobs-table tr { padding: 14px 15px; border-top: 1px solid var(--line); }
  .jobs-table td { display: flex; justify-content: space-between; gap: 16px; padding: 5px 0; border: 0; text-align: right; }
  .jobs-table td::before { flex: 0 0 68px; color: var(--muted); font-size: 0.7rem; font-weight: 700; text-align: left; }
  .jobs-table td:nth-child(1)::before { content: "状态"; }
  .jobs-table td:nth-child(2)::before { content: "任务"; }
  .jobs-table td:nth-child(3)::before { content: "提交人"; }
  .jobs-table td:nth-child(4)::before { content: "服务器"; }
  .jobs-table td:nth-child(5)::before { content: "时间"; }
  .jobs-table td:nth-child(6)::before { content: "耗时"; }
  .jobs-table td:nth-child(7)::before { content: "成片"; }
  .job-main { min-width: 0; max-width: calc(100% - 82px); text-align: right; }
  .job-prompt { max-width: 100%; }
  .empty-state::before { display: none; }
  .account-table-wrap { max-width: calc(100vw - 54px); }
  .dialog-actions .button { flex: 1; }
  .login-page { padding: 14px; }
  .login-card { padding: 26px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
