:root {
  color-scheme: light;
  --page: #f3f5f8;
  --surface: #fff;
  --border: #d8dee8;
  --text: #172033;
  --muted: #667085;
  --primary: #2356d8;
  --primary-hover: #1947bd;
  --success: #137a4b;
  --danger: #b42318;
  --warning: #a15c00;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--page);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}
button, input, select, textarea { font: inherit; letter-spacing: 0; }
[hidden] { display: none !important; }

.app-header {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand, .user-bar { display: flex; align-items: center; gap: 10px; }
.brand > span {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

.login-view { min-height: calc(100vh - 58px); display: grid; place-items: center; padding: 20px; }
.login-form { width: min(380px, 100%); padding: 26px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.client-download { text-decoration: none; }
h1, h2 { margin: 0; }
h1 { margin-bottom: 20px; font-size: 20px; }
h2 { font-size: 15px; }
label { display: grid; gap: 6px; color: #475467; font-size: 12px; font-weight: 600; }
.login-form label { margin-bottom: 14px; }
input, select, textarea {
  width: 100%;
  border: 1px solid #c5ceda;
  border-radius: 6px;
  outline: 0;
  background: #fff;
  color: var(--text);
}
input, select { height: 36px; padding: 0 10px; }
textarea { min-height: 104px; resize: vertical; padding: 9px 10px; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(35,86,216,.12); }

.button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 12px;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.button.primary { background: var(--primary); color: #fff; }
.button.primary:hover { background: var(--primary-hover); }
.button.quiet { border-color: var(--border); background: #fff; color: #475467; }
.button.danger { border-color: #edc2bd; background: #fff; color: var(--danger); }
.form-error { min-height: 21px; margin: 10px 0 0; color: var(--danger); font-size: 12px; }

main { width: min(1440px, 100%); margin: 0 auto; padding: 0 20px 30px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.tab { min-height: 48px; border: 0; border-bottom: 2px solid transparent; padding: 0 14px; background: transparent; color: var(--muted); cursor: pointer; font-weight: 600; }
.tab.active { border-bottom-color: var(--primary); color: var(--primary); }
.notice { margin: 14px 0 0; padding: 9px 12px; border: 1px solid #b8ccfb; border-radius: 6px; background: #edf3ff; color: #23438e; }
.notice.error { border-color: #efbdb8; background: #fff0ee; color: var(--danger); }
.notice.success { border-color: #a9ddc0; background: #ebf8f1; color: var(--success); }
.page-section { padding: 20px 0; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.table-heading { margin-top: 24px; }
.task-form, .config-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.span-2 { grid-column: span 2; }
.form-actions { display: flex; align-items: end; justify-content: flex-end; }
.inline-form { display: flex; align-items: end; gap: 10px; max-width: 520px; }
.inline-form label { flex: 1; }
.pairing-result { margin-top: 14px; padding: 12px; border-left: 3px solid var(--primary); background: #edf3ff; }
.pairing-code { display: block; margin-top: 4px; color: var(--primary); font: 700 18px Consolas, monospace; overflow-wrap: anywhere; }

.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 7px; background: #fff; }
.task-detail { margin-top: 18px; padding-top: 2px; border-top: 1px solid var(--border); }
.password-dialog { width: min(420px, calc(100vw - 32px)); border: 1px solid var(--border); border-radius: 8px; padding: 0; box-shadow: 0 18px 60px rgba(15, 23, 42, .18); }
.password-dialog::backdrop { background: rgba(15, 23, 42, .36); }
.dialog-form { display: grid; gap: 16px; padding: 24px; }
.dialog-form h2 { margin: 0; font-size: 18px; }
.task-detail .section-heading p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.detail-table { min-width: 1040px; }
.wrap-cell { max-width: 320px; white-space: normal; overflow-wrap: anywhere; }
.row-actions { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
table { width: 100%; min-width: 860px; border-collapse: collapse; font-size: 12px; }
th, td { padding: 9px 10px; border-bottom: 1px solid #e8edf3; text-align: left; vertical-align: top; }
th { background: #f8fafc; color: #475467; font-size: 11px; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
.empty { height: 58px; color: var(--muted); text-align: center; vertical-align: middle; }
.main-text { display: block; color: var(--text); font-weight: 600; }
.sub-text { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.status { display: inline-flex; min-height: 22px; align-items: center; border-radius: 999px; padding: 2px 8px; background: #eef1f5; color: #475467; font-size: 11px; font-weight: 600; }
.status.success, .status.active { background: #e8f7ef; color: var(--success); }
.status.failed { background: #feebe9; color: var(--danger); }
.status.queued { background: #edf3ff; color: var(--primary); }
.status.claimed, .status.running { background: #fff3df; color: var(--warning); }
.download-list { display: flex; flex-wrap: wrap; gap: 8px; }
.download-list a { color: var(--primary); text-decoration: none; font-weight: 600; }

@media (max-width: 840px) {
  .task-form, .config-form { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .app-header { padding: 0 14px; }
  main { padding-left: 12px; padding-right: 12px; }
  .tabs { overflow-x: auto; }
  .tab { flex: 0 0 auto; }
  .inline-form { align-items: stretch; flex-direction: column; }
}
