:root {
  color-scheme: light;
  --ink: #18212c;
  --muted: #68727e;
  --line: #dbe0e5;
  --soft-line: #e9edf0;
  --paper: #ffffff;
  --canvas: #f3f5f6;
  --cyan: #00aeb8;
  --cyan-dark: #007b84;
  --coral: #ee4b5a;
  --green: #2e8b68;
  --amber: #b06d11;
  --red: #c43e49;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  font-size: 14px;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app-header {
  height: 72px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.brand-block { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand-block h1 { margin: 0; font-size: 17px; line-height: 1.3; letter-spacing: 0; }
.brand-block p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.brand-mark { position: relative; width: 34px; height: 34px; background: var(--ink); border-radius: 6px; }
.brand-mark::before, .brand-mark::after, .brand-mark span {
  content: ""; position: absolute; width: 4px; height: 19px; left: 16px; top: 7px; border-radius: 2px; background: white;
}
.brand-mark::before { transform: translate(-3px, 2px); background: var(--cyan); }
.brand-mark::after { transform: translate(3px, -2px); background: var(--coral); }
.brand-mark span { z-index: 1; }
.service-status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #9aa3ad; }
.service-status.online .status-dot { background: var(--green); box-shadow: 0 0 0 3px #dcefe7; }
.service-status.offline .status-dot { background: var(--red); }

.workspace { min-height: calc(100vh - 72px); display: grid; grid-template-columns: minmax(320px, 390px) minmax(0, 1fr); }
.task-panel { padding: 26px 28px 32px; background: var(--paper); border-right: 1px solid var(--line); }
.content-panel { padding: 26px 32px 40px; min-width: 0; }
.panel-heading, .toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
h2 { margin: 4px 0 0; font-size: 22px; line-height: 1.25; letter-spacing: 0; }
.eyebrow { color: var(--cyan-dark); font-weight: 700; font-size: 10px; letter-spacing: .12em; }

form { margin-top: 24px; }
.form-section { padding: 18px 0; border-top: 1px solid var(--soft-line); }
.form-section:first-child { border-top-color: var(--line); }
label { display: block; margin-bottom: 9px; font-weight: 650; font-size: 13px; }
textarea, input[type="text"], input[type="date"], input[type="number"] {
  width: 100%; min-width: 0; border: 1px solid #cbd2d9; border-radius: 5px; color: var(--ink); background: var(--paper); outline: 0;
}
textarea { padding: 11px 12px; line-height: 1.6; resize: vertical; min-height: 130px; }
input[type="text"], input[type="date"], input[type="number"] { height: 40px; padding: 0 11px; }
textarea:focus, input:focus { border-color: var(--cyan-dark); box-shadow: 0 0 0 3px rgb(0 174 184 / 12%); }
.field-meta, .range-labels { margin-top: 7px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; }
.field-meta strong { color: var(--ink); font-weight: 650; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-title label { margin-bottom: 9px; }
.section-title output { margin-bottom: 9px; color: var(--cyan-dark); font-size: 12px; font-weight: 700; }
.text-button { padding: 0; border: 0; color: var(--cyan-dark); background: transparent; font-size: 12px; }
.account-section-title { align-items: center; margin-bottom: 10px; }
.account-section-title label { margin: 0; }
.add-group-button { min-height: 32px; padding: 0 10px; display: inline-flex; align-items: center; gap: 5px; color: var(--cyan-dark); background: var(--paper); border: 1px solid #b9c8cb; border-radius: 4px; font-size: 12px; font-weight: 650; }
.add-group-button svg { width: 15px; height: 15px; }
.account-group-editors { display: grid; gap: 14px; }
.account-group-editor { padding: 13px 0 15px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.group-editor-header { min-height: 28px; margin-bottom: 9px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.group-editor-label { color: var(--cyan-dark); font-size: 11px; }
.remove-group-button { width: 28px; height: 28px; padding: 0; display: inline-grid; place-items: center; color: var(--muted); background: transparent; border: 0; border-radius: 3px; }
.remove-group-button:hover:not(:disabled) { color: var(--red); background: #fff0f1; }
.remove-group-button:disabled { opacity: .3; cursor: not-allowed; }
.remove-group-button svg { width: 16px; height: 16px; }
.account-group-editor label { margin: 10px 0 6px; color: var(--muted); font-size: 11px; font-weight: 600; }
.account-group-editor textarea { min-height: 100px; }
.date-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.input-label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin-top: 11px; border: 1px solid #cbd2d9; border-radius: 5px; overflow: hidden; }
.segmented label { margin: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { min-height: 35px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; font-weight: 500; }
.segmented label + label { border-left: 1px solid #cbd2d9; }
.segmented input:checked + span { color: var(--paper); background: var(--ink); }
input[type="range"] { width: 100%; accent-color: var(--cyan-dark); }
.primary-button { width: 100%; height: 44px; display: flex; align-items: center; justify-content: center; gap: 9px; border: 0; border-radius: 5px; color: white; background: var(--ink); font-weight: 700; }
.primary-button:hover { background: #2c3947; }
.primary-button:disabled { opacity: .55; cursor: wait; }

.toolbar-actions { display: flex; gap: 8px; }
.icon-button { width: 38px; height: 38px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 5px; color: #58636f; background: var(--paper); }
.icon-button:hover { color: var(--ink); border-color: #b9c1c9; }
.stats-strip { margin: 22px 0; display: grid; grid-template-columns: repeat(3, minmax(100px, 1fr)); border: 1px solid var(--line); background: var(--paper); }
.stats-strip div { min-height: 66px; padding: 12px 18px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-left: 1px solid var(--soft-line); }
.stats-strip div:first-child { border-left: 0; }
.stats-strip span { color: var(--muted); font-size: 12px; }
.stats-strip strong { font-size: 21px; }

.empty-state { min-height: 380px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--muted); border: 1px dashed #cbd2d9; }
.empty-state.hidden { display: none; }
.empty-icon { width: 50px; height: 50px; margin-bottom: 13px; display: grid; place-items: center; color: var(--cyan-dark); background: #e7f6f6; border-radius: 6px; }
.empty-state h3 { margin: 0; color: var(--ink); font-size: 15px; }
.empty-state p { max-width: 430px; margin: 8px 20px 0; font-size: 12px; line-height: 1.7; }
.job-list { display: grid; gap: 12px; }
.job-group { min-width: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: transparent; }
.job-group-summary { min-height: 58px; padding: 10px 14px; display: grid; grid-template-columns: 14px minmax(120px, 1fr) auto; align-items: center; gap: 10px; list-style: none; color: var(--ink); background: var(--paper); cursor: pointer; user-select: none; }
.job-group-summary::-webkit-details-marker { display: none; }
.job-group-summary:hover { background: #f9fafb; }
.group-chevron { width: 0; height: 0; border-top: 5px solid transparent; border-bottom: 5px solid transparent; border-left: 7px solid #65717c; transition: transform .16s ease; }
.job-group[open] .group-chevron { transform: rotate(90deg); }
.job-group-name { min-width: 0; overflow-wrap: anywhere; font-size: 15px; font-weight: 750; }
.job-group-summary-counts { color: var(--muted); font-size: 11px; white-space: nowrap; }
.job-group-content { padding: 10px 0 2px; display: grid; gap: 8px; }
.job-card { display: grid; grid-template-columns: minmax(210px, 1.35fr) minmax(180px, 1fr) minmax(170px, .8fr) auto; align-items: center; gap: 20px; padding: 16px 18px; background: var(--paper); border: 1px solid var(--line); border-left: 3px solid #aab2bb; border-radius: 4px; }
.job-card.running, .job-card.queued { border-left-color: var(--cyan); }
.job-card.completed { border-left-color: var(--green); }
.job-card.failed, .job-card.partial { border-left-color: var(--red); }
.job-name { width: 100%; min-width: 0; overflow: hidden; display: flex; gap: 11px; }
.job-name > div { min-width: 0; flex: 1 1 auto; overflow: hidden; }
.job-name svg { flex: 0 0 auto; margin-top: 1px; color: var(--muted); }
.job-name h3 { margin: 0; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-name p, .job-filter p { margin: 5px 0 0; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-filter { min-width: 0; }
.job-filter strong { font-size: 12px; }
.status-badge { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 700; }
.status-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-badge.running, .status-badge.queued { color: var(--cyan-dark); }
.status-badge.completed { color: var(--green); }
.status-badge.failed, .status-badge.partial { color: var(--red); }
.status-badge.cancelled { color: #7d8791; }
.progress-line { height: 4px; margin-top: 8px; overflow: hidden; background: #e7ebee; }
.progress-line span { display: block; height: 100%; background: var(--cyan); transition: width .25s ease; }
.job-metrics { display: flex; gap: 16px; }
.job-metrics div { min-width: 52px; }
.job-metrics span { display: block; color: var(--muted); font-size: 10px; }
.job-metrics strong { display: block; margin-top: 3px; font-size: 16px; }
.job-actions { display: flex; align-items: center; gap: 6px; }

dialog { width: min(980px, calc(100vw - 40px)); max-height: calc(100vh - 50px); padding: 0; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 24px 60px rgb(26 34 43 / 20%); }
dialog::backdrop { background: rgb(23 30 38 / 50%); }
.dialog-header { position: sticky; top: 0; z-index: 1; padding: 18px 20px; display: flex; align-items: flex-start; justify-content: space-between; background: var(--paper); border-bottom: 1px solid var(--line); }
.dialog-header h2 { font-size: 18px; }
.dialog-content { padding: 20px; }
.detail-summary { display: grid; grid-template-columns: repeat(4, 1fr); margin-bottom: 18px; border: 1px solid var(--line); }
.detail-summary div { padding: 12px; border-left: 1px solid var(--line); }
.detail-summary div:first-child { border-left: 0; }
.detail-summary span { display: block; color: var(--muted); font-size: 10px; }
.detail-summary strong { display: block; margin-top: 5px; }
.error-box { margin-bottom: 16px; padding: 12px; color: #8c2c35; background: #fff0f1; border-left: 3px solid var(--red); font-size: 12px; line-height: 1.6; }
.result-toolbar { margin: 0 0 10px; display: flex; align-items: center; justify-content: space-between; }
.result-toolbar h3 { margin: 0; font-size: 14px; }
.result-actions, .video-actions { display: flex; align-items: center; gap: 6px; }
.secondary-button { min-height: 34px; padding: 0 12px; display: inline-flex; align-items: center; gap: 7px; color: var(--ink); text-decoration: none; background: var(--paper); border: 1px solid var(--line); border-radius: 4px; font-size: 12px; }
.result-group { margin-top: 16px; }
.group-toolbar { min-height: 48px; padding: 8px 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--canvas); border: 1px solid var(--line); border-bottom: 0; }
.group-name { min-width: 0; display: flex; align-items: baseline; gap: 8px; }
.group-name strong { overflow-wrap: anywhere; font-size: 14px; }
.group-name span { flex: 0 0 auto; color: var(--muted); font-size: 11px; }
.empty-group { padding: 24px 12px; color: var(--muted); text-align: center; border: 1px solid var(--line); }
.video-list { display: grid; border-top: 1px solid var(--line); }
.video-row { padding: 13px 4px; display: grid; grid-template-columns: 100px 130px minmax(180px, 1fr) auto; align-items: center; gap: 12px; border-bottom: 1px solid var(--soft-line); }
.video-row span, .video-row a { font-size: 12px; }
.video-row .account { font-weight: 700; }
.video-title { min-width: 0; }
.video-title strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.video-title small { display: block; margin-top: 3px; color: var(--cyan-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.video-url { width: 100%; min-width: 0; height: 27px; margin-top: 7px; padding: 0 8px; color: #4f5b67; background: var(--canvas); border: 1px solid var(--soft-line); border-radius: 3px; font-size: 10px; }
.video-url:focus { border-color: var(--cyan-dark); box-shadow: none; }
.empty-results { padding: 40px; color: var(--muted); text-align: center; border: 1px dashed var(--line); }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: 360px; padding: 11px 14px; color: white; background: var(--ink); border-radius: 4px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 340px minmax(0, 1fr); }
  .task-panel { padding-left: 20px; padding-right: 20px; }
  .content-panel { padding-left: 22px; padding-right: 22px; }
  .job-card { grid-template-columns: 1fr auto; gap: 14px; }
  .job-filter { grid-column: 1; }
  .job-metrics { grid-row: 1 / span 2; grid-column: 2; }
  .job-actions { grid-column: 2; }
}

@media (max-width: 720px) {
  .app-header { height: auto; min-height: 70px; padding: 13px 16px; gap: 12px; }
  .brand-block p { display: none; }
  .service-status span:last-child { display: none; }
  .workspace { display: block; }
  .task-panel { border-right: 0; border-bottom: 1px solid var(--line); padding: 22px 18px; }
  .add-group-button { min-height: 36px; }
  .content-panel { padding: 22px 18px 32px; }
  .stats-strip div { padding: 10px; display: block; }
  .stats-strip strong { display: block; margin-top: 4px; }
  .job-card { grid-template-columns: 1fr; }
  .job-group-summary { grid-template-columns: 14px minmax(0, 1fr); }
  .job-group-summary-counts { grid-column: 2; white-space: normal; }
  .job-filter, .job-metrics, .job-actions { grid-column: 1; grid-row: auto; }
  .job-actions { justify-content: flex-end; }
  .detail-summary { grid-template-columns: 1fr 1fr; }
  .detail-summary div:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .detail-summary div:nth-child(4) { border-top: 1px solid var(--line); }
  .video-row { grid-template-columns: 1fr auto; }
  .video-row .account, .video-row .date { display: none; }
  .result-toolbar { align-items: flex-start; gap: 10px; }
  .result-toolbar, .group-toolbar { align-items: stretch; flex-direction: column; }
  .result-actions { flex-wrap: wrap; }
}
