:root {
  --ink: #17212b;
  --muted: #66717e;
  --line: #dfe5e8;
  --surface: #ffffff;
  --surface-soft: #f4f7f7;
  --teal: #087f72;
  --teal-dark: #05655b;
  --amber: #b5680d;
  --red: #b83b3b;
  --blue: #2f648c;
  --shadow: 0 8px 24px rgba(31, 47, 58, 0.07);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--surface-soft);
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--surface-soft);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont,
    sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--teal);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(223, 229, 232, 0.92);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
}

.header-inner {
  width: min(1380px, calc(100% - 32px));
  min-height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand,
.header-actions,
.summary-item,
.panel-heading,
.button,
.status-pill,
.input-shell,
details summary {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: #fff;
  background: var(--teal);
  font-size: 18px;
  font-weight: 800;
}

.brand h1,
.panel h2,
.auth-card h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 18px;
  line-height: 1.25;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.header-actions {
  gap: 10px;
}

.inline-form {
  display: flex;
  margin: 0;
}

.page-shell {
  width: min(1380px, calc(100% - 32px));
  margin: 24px auto 48px;
}

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

.summary-item {
  min-width: 0;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 4px 16px rgba(31, 47, 58, 0.04);
}

.summary-icon {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: var(--teal);
  background: #e9f5f2;
}

.summary-icon svg,
.button svg,
.input-shell svg,
.icon-button svg,
.timeline svg,
.empty-state svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.9;
}

.summary-item div {
  min-width: 0;
}

.summary-label {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 12px;
}

.summary-item strong {
  display: block;
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.82fr) minmax(420px, 1.18fr);
  gap: 18px;
  align-items: start;
}

.settings-column,
.activity-column {
  display: grid;
  gap: 18px;
}

.panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-heading {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-heading h2 {
  margin-top: 2px;
  font-size: 18px;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.panel-note {
  margin: -4px 0 16px;
  padding: 11px 12px;
  border-left: 3px solid var(--amber);
  color: #73501f;
  background: #fff8e9;
  font-size: 13px;
}

.panel-note.compact {
  margin: 12px 0 16px;
}

.form-stack {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
  color: #3e4853;
  font-size: 13px;
  font-weight: 650;
}

.input-shell {
  min-width: 0;
  gap: 9px;
  padding: 0 12px;
  border: 1px solid #cfd7db;
  border-radius: var(--radius);
  background: #fff;
  color: #7b8791;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.input-shell:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8, 127, 114, 0.11);
}

.input-shell input {
  width: 100%;
  min-width: 0;
  height: 44px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

textarea {
  width: 100%;
  min-height: 84px;
  resize: vertical;
  padding: 11px 12px;
  border: 1px solid #cfd7db;
  border-radius: var(--radius);
  outline: 0;
  background: #fff;
  color: var(--ink);
}

textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8, 127, 114, 0.11);
}

.button {
  min-height: 42px;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 700;
  white-space: nowrap;
  transition:
    transform 140ms ease,
    background 140ms ease,
    border-color 140ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.button.primary {
  color: #fff;
  background: var(--teal);
}

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

.button.secondary {
  border-color: #bfc9ce;
  color: #33404a;
  background: #f9fbfb;
}

.button.secondary:hover {
  border-color: #96a3aa;
  background: #f1f5f5;
}

.button.danger-ghost {
  border-color: #e2c5c5;
  color: var(--red);
  background: #fffafa;
}

.button.wide {
  width: 100%;
}

.button-row {
  display: flex;
  gap: 10px;
}

.button-row .button {
  flex: 1;
}

.icon-button {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: #4f5b65;
  background: #fff;
}

.icon-button:hover {
  color: var(--teal);
  border-color: #a9c7c2;
}

.file-drop {
  min-height: 116px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 7px;
  padding: 18px;
  border: 1px dashed #9eb0b7;
  border-radius: var(--radius);
  color: #3b4a52;
  background: #f8fbfb;
  text-align: center;
}

.file-drop:hover {
  border-color: var(--teal);
  background: #f2faf8;
}

.file-drop svg {
  width: 28px;
  height: 28px;
  color: var(--teal);
}

.file-drop small {
  color: var(--muted);
  font-weight: 400;
}

#imageInput {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.schedule-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.schedule-hints button {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #4d5962;
  background: #fff;
  font-size: 12px;
}

.schedule-hints button:hover {
  color: var(--teal);
  border-color: #a9c7c2;
}

details {
  display: block;
}

details summary {
  justify-content: space-between;
  gap: 12px;
  list-style: none;
  cursor: pointer;
}

details summary::-webkit-details-marker {
  display: none;
}

details summary strong {
  display: block;
  margin-top: 2px;
  font-size: 17px;
}

details[open] summary > svg {
  transform: rotate(180deg);
}

.state-badge,
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid #cfd7db;
  border-radius: 999px;
  color: #59656e;
  background: #f8fafb;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.state-badge.success,
.status-pill.success {
  border-color: #b9d9d2;
  color: #06665b;
  background: #eaf7f4;
}

.state-badge.warning,
.status-pill.warning {
  border-color: #ead3aa;
  color: #8b570e;
  background: #fff7e8;
}

.state-badge.failed,
.status-pill.failed {
  border-color: #e7c2c2;
  color: #9a3030;
  background: #fff2f2;
}

.state-badge.running,
.status-pill.running {
  border-color: #bfd2e3;
  color: #285f89;
  background: #eef6fc;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.run-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  min-height: 22px;
  margin: -8px 0 18px;
  color: var(--muted);
  font-size: 12px;
}

.run-meta span {
  overflow-wrap: anywhere;
}

.timeline {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline li {
  position: relative;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 11px;
  padding-bottom: 18px;
}

.timeline li:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 26px;
  bottom: 2px;
  left: 13px;
  width: 1px;
  background: var(--line);
}

.step-icon {
  position: relative;
  z-index: 1;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: #68747d;
  background: #fff;
}

.step-icon svg {
  width: 15px;
  height: 15px;
}

.timeline li.success .step-icon {
  color: var(--teal);
  border-color: #a9d2ca;
  background: #eaf7f4;
}

.timeline li.warning .step-icon {
  color: var(--amber);
  border-color: #e9d1a9;
  background: #fff7e8;
}

.timeline li.failed .step-icon {
  color: var(--red);
  border-color: #e7c2c2;
  background: #fff2f2;
}

.timeline li.running .step-icon {
  color: var(--blue);
  border-color: #bfd2e3;
  background: #eef6fc;
}

.step-copy {
  min-width: 0;
  padding-top: 2px;
}

.step-copy strong {
  display: block;
  font-size: 14px;
}

.step-copy p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.step-copy time {
  display: block;
  margin-top: 4px;
  color: #929ca4;
  font-size: 11px;
}

.timeline-empty,
.empty-state {
  display: grid !important;
  place-items: center;
  gap: 8px;
  min-height: 132px;
  color: var(--muted);
  text-align: center;
}

.timeline-empty::after {
  display: none;
}

.timeline-empty svg,
.empty-state svg {
  width: 26px;
  height: 26px;
}

.history-list {
  display: grid;
  gap: 9px;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfc;
}

.history-item button {
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.history-main {
  min-width: 0;
}

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

.history-main p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.history-side {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.history-side time {
  color: #8b969e;
  font-size: 11px;
  white-space: nowrap;
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  width: min(380px, calc(100% - 36px));
  display: grid;
  gap: 8px;
}

.toast {
  padding: 12px 14px;
  border: 1px solid #c8d1d5;
  border-radius: var(--radius);
  color: #26323a;
  background: #fff;
  box-shadow: 0 12px 32px rgba(31, 47, 58, 0.16);
  animation: toast-in 180ms ease-out;
}

.toast.error {
  border-color: #e4bdbd;
  color: #8b2929;
  background: #fff7f7;
}

.toast.success {
  border-color: #b4d6cf;
  color: #075f55;
  background: #f0faf8;
}

.alert {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
}

.alert.error {
  border-color: #e4bdbd;
  color: #8b2929;
  background: #fff7f7;
}

.auth-page {
  min-height: 100vh;
  background:
    linear-gradient(rgba(244, 247, 247, 0.9), rgba(244, 247, 247, 0.9)),
    repeating-linear-gradient(90deg, #dfe8e5 0 1px, transparent 1px 40px),
    repeating-linear-gradient(0deg, #dfe8e5 0 1px, transparent 1px 40px);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(430px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 18px 50px rgba(31, 47, 58, 0.13);
}

.auth-brand {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.auth-heading {
  margin: 24px 0 20px;
}

.auth-heading h2 {
  margin-top: 4px;
  font-size: 24px;
}

.auth-heading > p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-card .alert {
  margin-bottom: 16px;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1040px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 640px) {
  .header-inner,
  .page-shell {
    width: min(100% - 20px, 1380px);
  }

  .header-inner {
    min-height: 64px;
    align-items: center;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .brand h1 {
    font-size: 16px;
  }

  .brand p,
  #globalStatus {
    display: none;
  }

  .page-shell {
    margin-top: 14px;
  }

  .summary-grid {
    gap: 8px;
    margin-bottom: 12px;
  }

  .summary-item {
    padding: 12px;
  }

  .summary-icon {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
  }

  .summary-item strong {
    font-size: 13px;
  }

  .workspace-grid,
  .settings-column,
  .activity-column {
    gap: 12px;
  }

  .panel {
    padding: 16px;
  }

  .button-row {
    flex-direction: column;
  }

  .toast-region {
    right: 10px;
    bottom: 10px;
    width: calc(100% - 20px);
  }

  .auth-shell {
    padding: 14px;
  }

  .auth-card {
    padding: 22px 18px;
  }
}
