:root {
  color-scheme: light;
  font-family: Geist, Inter, system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #17241d;
  background: #f2f5f3;
  --surface: #fff;
  --muted: #53615b;
  --line: #dbe4dc;
  --accent: #1d5e47;
  --accent-dark: #164835;
  --mint: #98e5be;
  --gutter: clamp(1.5rem, 3vw, 2.5rem);
  --panel-padding: clamp(1.15rem, 1.7vw, 1.75rem);
  --panel-radius: 1rem;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body { margin: 0; min-height: 100vh; }
h1, h2, p, dl, dd, form { margin: 0; }

h1 {
  font-size: clamp(1.65rem, 2.5vw, 2.35rem);
  font-weight: 720;
  letter-spacing: -.035em;
  line-height: 1.2;
}

h2 { font-size: 1.1rem; font-weight: 700; }

a { color: inherit; }

:focus-visible {
  outline: 3px solid #378369;
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  overflow: hidden;
  width: 1px;
  height: 1px;
  clip-path: inset(50%);
  white-space: nowrap;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 64px;
  padding: .65rem var(--gutter);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand, .session-controls, .connection {
  display: inline-flex;
  align-items: center;
}

.brand {
  gap: .66rem;
  font-size: 1.02rem;
  font-weight: 780;
  letter-spacing: .025em;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 9px;
  background: #153a2d;
}

.brand-mark::before {
  position: absolute;
  top: 6px;
  left: 11px;
  width: 8px;
  height: 11px;
  background: var(--mint);
  clip-path: polygon(37% 0, 63% 0, 63% 56%, 100% 56%, 50% 100%, 0 56%, 37% 56%);
  content: "";
}

.brand-mark::after {
  position: absolute;
  bottom: 7px;
  left: 8px;
  width: 14px;
  height: 5px;
  border: solid var(--mint);
  border-width: 0 2px 2px;
  border-radius: 0 0 3px 3px;
  content: "";
}

.session-controls { gap: 1rem; }

.connection {
  gap: .42rem;
  color: var(--muted);
  font-size: .79rem;
  white-space: nowrap;
}

.connection::before {
  width: .46rem;
  height: .46rem;
  flex: none;
  border-radius: 50%;
  background: #328161;
  box-shadow: 0 0 0 .2rem #dfede4;
  content: "";
}

.connection[data-state="offline"]::before, .connection.is-offline::before {
  background: #b45138;
  box-shadow: 0 0 0 .2rem #f4e5de;
}

.connection[data-state="connecting"]::before {
  background: #a8752a;
  box-shadow: 0 0 0 .2rem #f0e7d8;
}

.workspace { width: 100%; padding: clamp(1.65rem, 3.2vw, 3.5rem) var(--gutter) 2rem; }

.page-heading, .tasks-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.page-heading { margin-bottom: 1.35rem; }

.updated-at, .storage {
  color: var(--muted);
  font-size: .81rem;
  line-height: 1.55;
}

.updated-at time { margin-left: .25rem; font-variant-numeric: tabular-nums; }

.queue-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 9.5rem), 1fr));
  gap: .8rem;
  margin-bottom: 1rem;
}

.summary-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  min-width: 0;
  gap: .6rem;
  padding: .95rem 1.05rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: .74rem;
}

.summary-label {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  color: var(--muted);
  font-size: .84rem;
}

.summary-label::before {
  width: .46rem;
  height: .46rem;
  flex: none;
  border-radius: 50%;
  background: var(--summary-dot, #72847a);
  content: "";
}

.summary-item--running { --summary-dot: #308a65; }
.summary-item--queued { --summary-dot: #ac771c; }
.summary-item--done { --summary-dot: #3386ae; }
.summary-item--failed { --summary-dot: #b2584d; }

.summary-value {
  font-size: clamp(1.35rem, 1.3vw + .65rem, 1.8rem);
  font-weight: 720;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.06em;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(21rem, 1fr);
  gap: 1rem;
  margin-bottom: 1.1rem;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--panel-radius);
  background: var(--surface);
}

.activity-panel {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  min-width: 0;
  padding: var(--panel-padding);
  overflow: hidden;
  border: 1px solid #213d30;
  border-radius: var(--panel-radius);
  color: #edf6f0;
  background: radial-gradient(ellipse at right top, #224c3b, transparent 68%), #15291f;
}

.activity-panel h2 { color: #bfd5c9; font-size: .9rem; }

#download-activity { display: grid; align-content: center; flex: 1; }

.activity-content { display: grid; gap: .95rem; }

.activity-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem .85rem;
}

.activity-id {
  font-size: clamp(1.45rem, 2.5vw, 2.3rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -.035em;
  overflow-wrap: anywhere;
}

.activity-stage {
  color: #cbe9d8;
  padding: .28rem .5rem;
  border: 1px solid #ffffff28;
  border-radius: .35rem;
  font-size: .75rem;
  line-height: 1.25;
}

.activity-progress, .activity-track {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-width: 0;
}

.activity-track { flex: 1; }

.activity-percent {
  color: var(--mint);
  font-size: .85rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.activity-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(8.5rem, 100%), 1fr));
  gap: .7rem 1rem;
  padding-top: .8rem;
  border-top: 1px solid #ffffff27;
}

.activity-metrics dt { color: #b5cbbf; font-size: .76rem; }

.activity-metrics dd {
  margin-top: .3rem;
  font-size: .98rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.activity-empty {
  padding: .85rem 0 1.45rem;
  color: #b5cbbf;
  font-size: .9rem;
  line-height: 1.6;
}

.submit-panel { padding: var(--panel-padding); }
.submit-panel h2 { margin-bottom: 1rem; }

label { display: block; margin-bottom: .4rem; font-size: .82rem; font-weight: 650; }

input, button { font: inherit; }

input {
  width: 100%;
  min-width: 0;
  min-height: 43px;
  padding: .62rem .75rem;
  border: 1px solid #aab8ae;
  border-radius: .55rem;
  color: inherit;
  background: var(--surface);
}

input::placeholder { color: #6a796f; }

button, .secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: .53rem .8rem;
  border: 1px solid transparent;
  border-radius: .53rem;
  cursor: pointer;
  text-decoration: none;
  font-size: .82rem;
  font-weight: 670;
  white-space: nowrap;
}

.primary { min-height: 43px; padding-inline: 1rem; color: #fff; background: var(--accent); }
.primary:hover { background: var(--accent-dark); }
.secondary { color: #264437; background: var(--surface); border-color: var(--line); }
.secondary:hover { background: #eff4f0; }
.logout { min-height: 36px; }
button:disabled { cursor: default; opacity: .55; }

.submit-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .55rem; }

.hint, .disk-details { color: var(--muted); font-size: .78rem; line-height: 1.5; }
.hint { margin-top: .65rem; }

.disk-status:not(:empty) {
  display: grid;
  gap: .48rem;
  margin-top: 1rem;
  padding-top: .82rem;
  border-top: 1px solid var(--line);
}

.disk-copy {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .2rem .65rem;
  font-size: .8rem;
}

.disk-value { font-variant-numeric: tabular-nums; font-weight: 660; }

.tasks-heading { padding: var(--panel-padding) var(--panel-padding) .8rem; }

.task-count {
  display: inline-flex;
  align-items: center;
  gap: .2rem;
  min-height: 1.45rem;
  margin-left: .25rem;
  padding: 0 .43rem;
  border-radius: .33rem;
  color: #455c50;
  background: #edf2ee;
  font-size: .76rem;
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
}

.tasks-tools { display: flex; align-items: center; gap: .55rem; }

.search { position: relative; margin: 0; }

.search input {
  width: clamp(9rem, 17vw, 18rem);
  min-height: 40px;
  padding-left: 2.05rem;
  border-color: var(--line);
  font-size: .82rem;
  font-weight: 470;
}

.search-icon {
  position: absolute;
  top: .77rem;
  left: .76rem;
  width: .65rem;
  height: .65rem;
  border: 1.5px solid #6a796f;
  border-radius: 50%;
  pointer-events: none;
}

.search-icon::after {
  position: absolute;
  right: -.30rem;
  bottom: -.15rem;
  width: .34rem;
  height: 1.5px;
  transform: rotate(45deg);
  border-radius: 2px;
  background: #6a796f;
  content: "";
}

.task-filters {
  display: flex;
  flex-wrap: wrap;
  gap: .28rem;
  padding: 0 var(--panel-padding) .85rem;
}

.task-filters button {
  min-height: 35px;
  padding-inline: .7rem;
  color: var(--muted);
  background: transparent;
}

.task-filters button:hover { color: #204634; background: #f2f6f3; }

.task-filters [aria-pressed="true"], .task-filters .is-active {
  border-color: #d6e7dd;
  color: #1c5b42;
  background: #e9f3ec;
}

.table-scroll { overflow-x: auto; }

.tasks {
  width: 100%;
  min-width: 710px;
  border-collapse: collapse;
  text-align: left;
  font-size: .84rem;
}

.tasks th, .tasks td {
  padding: .88rem clamp(.65rem, 1.45vw, 1.45rem);
  border-top: 1px solid #e4ebe5;
}

.tasks th { color: #4b5d53; background: #f6f8f6; font-weight: 650; white-space: nowrap; }
.tasks td { vertical-align: middle; }
.tasks tbody tr:hover { background: #fafcfb; }

.tasks th:first-child, .tasks td:first-child { padding-left: var(--panel-padding); }
.tasks th:last-child, .tasks td:last-child { padding-right: var(--panel-padding); }

.tasks th:last-child, .task-actions { text-align: right; }
.tasks th:last-child { width: 5.75rem; }

.danger-action {
  min-height: 34px;
  padding: .35rem .58rem;
  border-color: #edd7d4;
  color: #8a3d36;
  background: #fff;
}

.danger-action:hover:not(:disabled) { background: #faeeec; border-color: #e4bcb7; }

.task-id {
  display: inline-block;
  max-width: 18ch;
  font-weight: 680;
  overflow-wrap: anywhere;
}

.metric-number, .tasks td:nth-child(n + 4) { font-variant-numeric: tabular-nums; }
.tasks td:nth-child(n + 4) { white-space: nowrap; }
.tasks .muted { color: var(--muted); }

.tasks .empty {
  padding: 2.35rem 1rem;
  color: var(--muted);
  text-align: center;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .75rem;
  padding: .75rem var(--panel-padding);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .82rem;
  font-variant-numeric: tabular-nums;
}

.pagination button { min-height: 35px; }

.status {
  display: inline-block;
  padding: .28rem .52rem;
  border-radius: .32rem;
  font-size: .75rem;
  font-weight: 670;
  line-height: 1.1;
  white-space: nowrap;
}

.status--queued { color: #6a4e1a; background: #f8f1e1; }
.status--running { color: #205743; background: #e7f3ec; }
.status--done { color: #285874; background: #edf4f9; }
.status--failed { color: #8a3d36; background: #faeeec; }

.tasks .failure-row td[colspan] {
  padding: 0 var(--panel-padding) .65rem;
  border-top: 0;
  background: var(--surface);
}

.failure-detail {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: baseline;
  gap: .3rem .55rem;
  padding: .55rem .7rem;
  border: 1px solid #f0dcd8;
  border-radius: .45rem;
  color: #683e39;
  background: #fcf2f0;
  font-size: .78rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.failure-label { color: #8a3d36; }

.failure-attempts { grid-column: 2; min-width: 0; }

.failure-attempts summary { width: fit-content; cursor: pointer; }

.failure-attempts ul { margin: .3rem 0 0; padding: 0; list-style: none; }

.failure-attempts li {
  display: grid;
  grid-template-columns: minmax(0, 7rem) minmax(0, 1fr);
  gap: .5rem;
  padding: .15rem 0;
}

.task-progress { display: grid; gap: .3rem; min-width: 4rem; max-width: 10rem; }

.progress-bar {
  display: block;
  width: 100%;
  height: .42rem;
  accent-color: var(--fill, #378266);
}

.progress-bar[value] {
  appearance: none;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--track, #e5eee7);
}

.progress-bar[value]::-webkit-progress-bar { background: var(--track, #e5eee7); }
.progress-bar[value]::-webkit-progress-value { background: var(--fill, #378266); }
.progress-bar[value]::-moz-progress-bar { background: var(--fill, #378266); }

.activity-panel .progress-bar {
  --track: #ffffff30;
  --fill: var(--mint);
  height: .55rem;
}

.storage { margin-top: 1rem; }
.storage code { overflow-wrap: anywhere; }

.notice {
  margin-bottom: .8rem;
  padding: .6rem .75rem;
  border: 1px solid var(--line);
  border-radius: .55rem;
  font-size: .85rem;
  overflow-wrap: anywhere;
}

.notice--success { color: #1e5c43; background: #edf6ef; }
.notice--error { color: #912f32; background: #fff0ef; border-color: #f0c8c8; }
.task-action-notice { margin: 0 var(--panel-padding) .85rem; }

.login-page {
  display: grid;
  place-items: center;
  padding: 1rem;
  background: radial-gradient(ellipse at 50% 18%, #e0eee4, transparent 65%), #f2f5f3;
}

.login-panel {
  width: min(100%, 26rem);
  padding: clamp(1.4rem, 5vw, 2.25rem);
  box-shadow: 0 1rem 2.3rem #254b3610;
}

.login-panel h1 { margin: 1.25rem 0 1.55rem; font-size: 1.58rem; }
.login-panel .primary { width: 100%; margin-top: .95rem; }

@media (max-width: 56rem) {
  .dashboard-grid { grid-template-columns: minmax(0, 1.1fr) minmax(17rem, 1fr); }
}

@media (max-width: 44rem) {
  :root { --gutter: 1rem; }
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
  .queue-summary { grid-template-columns: repeat(auto-fit, minmax(min(100%, 7.5rem), 1fr)); }
  .summary-item { padding: .75rem .65rem; }
}

@media (max-width: 30rem) {
  .page-heading { align-items: start; flex-direction: column; gap: .35rem; }
  .queue-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-item--all { grid-column: 1 / -1; }
  .tasks-heading { align-items: stretch; flex-direction: column; gap: .75rem; }
  .search { flex: 1; }
  .search input { width: 100%; }
  .session-controls { gap: .6rem; }
  .tasks { min-width: 0; table-layout: fixed; font-size: .76rem; }
  .tasks th, .tasks td,
  .tasks th:first-child, .tasks td:first-child,
  .tasks th:last-child, .tasks td:last-child { padding: .65rem .5rem; }
  .tasks th:first-child { width: 24%; }
  .tasks th:nth-child(2) { width: 19%; }
  .tasks th:nth-child(3) { width: 15%; }
  .tasks :is(th, td):is(:nth-child(4), :nth-child(5)):not([colspan]) { display: none; }
  .tasks th:nth-child(6) { width: 25%; }
  .tasks td:nth-child(6) { white-space: normal; font-size: .70rem; }
  .tasks th:last-child { width: 17%; }
  .task-actions .danger-action { padding-inline: .3rem; font-size: .72rem; }
  .task-actions .muted { font-size: .68rem; }
  .tasks .status { padding-inline: .35rem; font-size: .68rem; }
  .tasks .failure-row td[colspan] { padding-inline: .5rem; }
  .failure-detail { padding: .5rem; }
  .failure-attempts li { grid-template-columns: minmax(0, 4.75rem) minmax(0, 1fr); }
  .task-progress { min-width: 0; }
}

@media (max-width: 22rem) {
  .submit-controls { grid-template-columns: minmax(0, 1fr); }
}
