:root {
  color-scheme: light;
  --bg: #eef2f4;
  --surface: #ffffff;
  --surface-soft: #f7f9fa;
  --rail: #16211f;
  --rail-soft: #20302d;
  --ink: #17201d;
  --muted: #63716d;
  --muted-strong: #3c4a46;
  --line: #dce3e1;
  --line-strong: #c7d1ce;
  --field: #f8fafb;
  --accent: #0c8f78;
  --accent-dark: #08725f;
  --accent-soft: #e2f5f1;
  --warn: #b76e00;
  --danger: #c8452d;
  --danger-soft: #fff0ec;
  --success: #16724f;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  --font: "Segoe UI", "Microsoft YaHei UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
}

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

button {
  border: 0;
}

button:not(:disabled) {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.app-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 300px minmax(0, 1fr);
}

.rail {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  background: var(--rail);
  color: #edf7f4;
}

.brand-block,
.rail-tools,
.topbar,
.topbar-actions,
.panel-header,
.metric-row,
.run-state,
.modal-header,
.modal-actions {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 12px;
  padding-bottom: 6px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 10px;
  background: #d7f36a;
  color: #152015;
  font-weight: 900;
}

.label {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.rail .label {
  color: #a9bab5;
}

h1,
h2,
h3 {
  margin: 0;
  text-wrap: balance;
}

h1 {
  font-size: 20px;
  line-height: 1.2;
}

h2 {
  font-size: 26px;
  line-height: 1.16;
}

h3 {
  font-size: 17px;
  line-height: 1.25;
}

.rail-tools {
  gap: 8px;
}

.button {
  min-height: 38px;
  border-radius: 7px;
  padding: 0 13px;
  font-weight: 700;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.button:not(:disabled):active {
  transform: translateY(1px);
}

.button-primary {
  background: var(--accent);
  color: #ffffff;
}

.button-primary:hover {
  background: var(--accent-dark);
}

.button-secondary {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
}

.rail .button-secondary {
  border-color: rgba(255, 255, 255, 0.14);
  background: var(--rail-soft);
  color: #edf7f4;
}

.button-danger {
  background: var(--danger);
  color: #ffffff;
}

.button-danger-light {
  background: var(--danger-soft);
  color: #9f2f1d;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #d8e7e2;
  font-size: 13px;
  font-weight: 800;
}

.section-title strong {
  display: grid;
  min-width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 12px;
}

.site-list {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
}

.site-row {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: #edf7f4;
  padding: 12px;
  text-align: left;
}

.site-row:hover {
  border-color: rgba(215, 243, 106, 0.44);
  background: rgba(255, 255, 255, 0.075);
}

.site-row.active {
  border-color: #d7f36a;
  background: rgba(215, 243, 106, 0.12);
}

.site-row.warning {
  border-color: rgba(245, 174, 66, 0.58);
  background: rgba(245, 174, 66, 0.1);
}

.site-row-top,
.site-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.site-row strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-meta {
  margin-top: 8px;
  color: #b7c7c2;
  font-size: 12px;
}

.site-cookie {
  max-width: 100%;
  margin-top: 8px;
  overflow: hidden;
  color: #8fa09b;
  font-family: var(--mono);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-warning {
  margin-top: 7px;
  color: #ffd18a;
  font-size: 11px;
  line-height: 1.35;
}

.badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #d7e4df;
  font-size: 11px;
  font-weight: 800;
}

.badge.ok {
  background: #d7f36a;
  color: #152015;
}

.badge.warn {
  background: #f5ae42;
  color: #201600;
}

.main-stage {
  min-width: 0;
  padding: 22px;
}

.topbar {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.topbar-actions {
  gap: 10px;
}

.status-chip {
  max-width: 220px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted-strong);
  padding: 8px 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  gap: 14px;
}

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

.panel-header {
  justify-content: space-between;
  gap: 12px;
  min-height: 70px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.run-panel,
.monitor-panel {
  min-height: 560px;
}

.field,
.run-panel {
  display: flex;
  flex-direction: column;
}

.run-panel {
  gap: 14px;
}

.field {
  gap: 7px;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 700;
}

.run-panel > .field,
.field-grid {
  margin: 0 16px;
}

.run-panel > .field {
  flex: 1;
  min-height: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: 2fr repeat(3, minmax(96px, 1fr));
  gap: 10px;
  padding-bottom: 16px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--field);
  color: var(--ink);
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

input,
select {
  height: 39px;
  padding: 0 11px;
}

textarea {
  min-height: 310px;
  resize: vertical;
  padding: 12px;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(12, 143, 120, 0.14);
}

.metric-row {
  gap: 10px;
  padding: 14px 16px 0;
}

.metric {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
}

.metric span,
.metric strong {
  display: block;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  margin-top: 4px;
  font-size: 24px;
  line-height: 1;
}

.run-state {
  justify-content: space-between;
  gap: 10px;
  margin: 14px 16px 0;
}

.job-status {
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted-strong);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
}

.job-status.running {
  background: #fff2d8;
  color: var(--warn);
}

.job-status.completed {
  background: #e0f5ea;
  color: var(--success);
}

.job-status.failed,
.job-status.cancelled {
  background: var(--danger-soft);
  color: #9f2f1d;
}

#serviceVersion {
  overflow: hidden;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-box {
  min-height: 342px;
  max-height: 430px;
  margin: 14px 16px 16px;
  overflow: auto;
  border: 1px solid #23322f;
  border-radius: 8px;
  background: #111917;
  color: #def2ed;
  font: 12px/1.55 var(--mono);
  padding: 13px;
  white-space: pre-wrap;
}

.results-panel {
  margin-top: 14px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

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

td {
  font-size: 13px;
}

.download-links {
  display: flex;
  gap: 10px;
}

.download-links a {
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: none;
}

.download-links a:hover {
  text-decoration: underline;
}

.empty-row {
  color: var(--muted);
}

dialog {
  width: min(920px, calc(100vw - 28px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

dialog::backdrop {
  background: rgba(14, 22, 20, 0.56);
}

.modal {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 16px;
}

.modal-header {
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.icon-button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 22px;
}

.modal > .field,
.advanced-box,
.modal-actions,
.modal-grid {
  margin-inline: 16px;
}

.modal-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.cookie-area {
  min-height: 150px;
  font-family: var(--mono);
  font-size: 12px;
}

.advanced-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
}

.advanced-box summary {
  cursor: pointer;
  color: var(--muted-strong);
  font-weight: 800;
}

.advanced-box .field-grid {
  margin: 12px 0;
}

#proxyApiInput {
  min-height: 84px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--muted-strong);
  font-weight: 700;
}

.check-row input {
  width: 17px;
  height: 17px;
}

.modal-actions {
  justify-content: flex-end;
  gap: 10px;
}

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

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 260px minmax(0, 1fr);
  }

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

  .run-panel,
  .monitor-panel {
    min-height: auto;
  }

  .log-box {
    min-height: 240px;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .rail {
    min-height: auto;
  }

  .site-list {
    max-height: 310px;
  }

  .main-stage {
    padding: 16px;
  }

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

  .field-grid,
  .modal-grid {
    grid-template-columns: 1fr;
  }

  textarea {
    min-height: 220px;
  }
}
