:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #172033;
  --muted: #64748b;
  --line: #d8dee8;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --cyan: #0e7490;
  --green: #15803d;
  --amber: #b45309;
  --red: #dc2626;
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
}

h1,
h2,
p {
  margin: 0;
}

.shell {
  width: min(1500px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 32px;
}

.topbar {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--blue-dark);
  font-size: 13px;
  font-weight: 800;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 17px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.access-field {
  width: 230px;
  display: grid;
  gap: 5px;
}

.access-field[hidden] {
  display: none;
}

.access-field span,
.field span,
.upload-box strong,
.accounts-head span,
.current-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.status-pill {
  min-width: 88px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  padding: 8px 12px;
  text-align: center;
  font-size: 13px;
  font-weight: 900;
}

.status-pill.running {
  border-color: #93c5fd;
  background: #eff6ff;
  color: var(--blue-dark);
}

.status-pill.finished {
  border-color: #86efac;
  background: #f0fdf4;
  color: var(--green);
}

.status-pill.failed,
.status-pill.stopped {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--red);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(520px, 1fr) 360px;
  grid-template-areas:
    "task control"
    "result result"
    "log log";
  gap: 14px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
}

.task-panel {
  grid-area: task;
}

.control-panel {
  grid-area: control;
}

.result-panel {
  grid-area: result;
}

.log-panel {
  grid-area: log;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 13px;
}

.upload-box {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.upload-box > div:first-child {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

#runId {
  min-width: 0;
  max-width: 100%;
  justify-self: end;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
}

.upload-actions,
.actions,
.stop-row,
.accounts-head,
.account-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.upload-button {
  position: relative;
  overflow: hidden;
  flex: 0 0 auto;
  min-width: 150px;
  max-width: 220px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  padding: 9px 14px;
  font-weight: 900;
  cursor: pointer;
}

.upload-button span {
  position: relative;
  z-index: 2;
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

.upload-button.secondary {
  border: 1px solid #a5f3fc;
  background: #ecfeff;
  color: var(--cyan);
}

.upload-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-width: 0;
  min-height: 0;
  max-width: 1px;
  max-height: 1px;
  margin: 0;
  border: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.upload-actions .ghost-button {
  flex: 0 0 auto;
  min-width: 112px;
  white-space: nowrap;
}

#selectedInfo {
  color: var(--muted);
  font-size: 13px;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.preset-button {
  min-height: 114px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.preset-button strong {
  display: block;
  margin-bottom: 8px;
  font-size: 16px;
}

.preset-button span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.preset-button.selected {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.notice-row {
  border: 1px solid #bae6fd;
  border-radius: 8px;
  background: #f0f9ff;
  color: #075985;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.field-wide {
  margin-bottom: 12px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.field-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.advanced-box {
  border-top: 1px dashed var(--line);
  padding-top: 12px;
}

.advanced-box summary {
  color: var(--text);
  font-weight: 900;
  cursor: pointer;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.accounts-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 11px;
  margin-bottom: 12px;
}

.accounts-head {
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.account-cards {
  display: grid;
  gap: 8px;
}

.account-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  display: grid;
  gap: 7px;
}

.account-card.ready {
  border-color: #bbf7d0;
}

.account-card.quota,
.account-card.cooldown {
  border-color: #fde68a;
}

.account-main {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.account-sub {
  color: var(--muted);
  font-size: 12px;
}

.account-badge,
.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.account-badge.ready,
.tag.done {
  background: #dcfce7;
  color: var(--green);
}

.account-badge.off,
.tag.pending {
  background: #f1f5f9;
  color: var(--muted);
}

.account-badge.expired,
.account-badge.quota,
.account-badge.cooldown,
.tag.processing {
  background: #fef3c7;
  color: var(--amber);
}

.tag.failed {
  background: #fee2e2;
  color: var(--red);
}

.quota-wait {
  margin-top: 8px;
  border-radius: 8px;
  background: #fffbeb;
  color: var(--amber);
  padding: 9px;
  font-size: 13px;
  font-weight: 800;
}

.primary-button,
.secondary-button,
.ghost-button,
.stop-button,
.link-button {
  min-height: 38px;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 900;
  cursor: pointer;
}

.primary-button {
  width: 100%;
  background: var(--blue);
  color: #fff;
}

.primary-button.strong {
  background: var(--blue-dark);
}

.secondary-button {
  width: 100%;
  border: 1px solid #a5f3fc;
  background: #ecfeff;
  color: var(--cyan);
}

.ghost-button,
.link-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.ghost-button.danger {
  color: var(--red);
}

.stop-button {
  flex: 1;
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fed7aa;
}

.stop-button.force {
  background: #fef2f2;
  color: var(--red);
  border-color: #fecaca;
}

button:disabled,
input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.actions {
  display: grid;
  gap: 9px;
}

.meters {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 13px 0;
}

.meters div,
.current-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.meters dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.meters dd {
  margin: 4px 0 0;
  font-size: 24px;
  font-weight: 950;
}

.current-box {
  display: grid;
  gap: 6px;
}

.current-box strong {
  min-height: 20px;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.table-wrap {
  max-height: 430px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #f1f5f9;
  color: var(--muted);
  font-weight: 900;
}

td {
  overflow-wrap: anywhere;
}

.log-box {
  height: 290px;
  overflow: auto;
  margin: 0;
  border: 1px solid #1f2937;
  border-radius: 8px;
  background: #111827;
  color: #d1fae5;
  padding: 13px;
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.login-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.52);
  padding: 18px;
}

.login-modal[hidden],
.compare-modal[hidden] {
  display: none;
}

.login-dialog {
  width: min(960px, 100%);
  max-height: min(92dvh, 900px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.22);
  padding: 16px;
}

.login-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.login-shot-box {
  position: relative;
  min-height: 360px;
  display: grid;
  place-items: center;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

#loginShot {
  display: block;
  max-width: 100%;
  height: auto;
}

#loginShot[src=""],
#loginShot:not([src]) {
  display: none;
}

#loginShotEmpty {
  color: var(--muted);
  font-weight: 800;
}

.login-log {
  min-height: 88px;
  max-height: 150px;
  overflow: auto;
  margin: 10px 0 0;
  border: 1px solid #1f2937;
  border-radius: 8px;
  background: #111827;
  color: #d1fae5;
  padding: 10px;
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.compare-modal {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.52);
  padding: 18px;
}

.compare-dialog {
  width: min(1280px, 100%);
  max-height: min(92dvh, 920px);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.22);
  padding: 16px;
}

.compare-head-actions,
.result-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.compare-meta {
  margin-bottom: 12px;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  background: #f0f9ff;
  color: #075985;
  padding: 9px 11px;
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.compare-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.compare-pane {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.compare-pane h3 {
  margin: 0;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  padding: 10px 12px;
  font-size: 14px;
}

.compare-pane pre {
  margin: 0;
  overflow: auto;
  padding: 12px;
  color: var(--text);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-areas:
      "control"
      "task"
      "result"
      "log";
  }

  .preset-grid,
  .field-grid.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 18px, 1500px);
  }

  .topbar,
  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .access-field {
    width: 100%;
  }

  .preset-grid,
  .field-grid,
  .field-grid.compact,
  .meters {
    grid-template-columns: 1fr;
  }

  .upload-box > div:first-child {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  #runId {
    justify-self: start;
  }

  .upload-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .upload-button,
  .upload-actions .ghost-button {
    width: 100%;
    max-width: none;
  }

  .compare-grid {
    grid-template-columns: 1fr;
  }

  .compare-dialog {
    overflow: auto;
  }
}
