:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #e4e9f0;
  --line-strong: #d7dee8;
  --text: #172033;
  --muted: #65748b;
  --muted-soft: #8a9ab0;
  --navy: #060b1f;
  --navy-hover: #111a34;
  --blue: #2563eb;
  --green: #059669;
  --orange: #d97706;
  --red: #dc2626;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  font-family: Arial, "Microsoft YaHei", "PingFang SC", sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.brand {
  height: 58px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: var(--navy);
  border-radius: 7px;
  font-size: 14px;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 15px;
  line-height: 1.2;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.side-nav {
  display: grid;
  gap: 4px;
  padding: 14px 10px;
}

.nav-item {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  color: #475569;
  border-radius: 7px;
  font-size: 14px;
}

.nav-item:hover {
  background: var(--panel-soft);
  color: var(--text);
}

.nav-item.active {
  color: #ffffff;
  background: var(--navy);
}

.nav-item b {
  color: currentColor;
  font-size: 18px;
  font-weight: 400;
  opacity: 0.6;
}

.sidebar-foot {
  margin: auto 14px 14px;
  padding: 13px;
  color: #475569;
  background: var(--panel-soft);
  border-radius: 8px;
  font-size: 12px;
}

.sidebar-foot strong,
.sidebar-foot span {
  display: block;
}

.sidebar-foot span {
  margin-top: 4px;
  color: var(--muted);
}

.workspace {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 22px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.search-box {
  flex: 1;
  min-width: 0;
  margin: 0;
}

.search-box input,
input {
  width: 100%;
  min-height: 36px;
  padding: 8px 11px;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  outline: none;
}

.search-box input {
  background: #f9fbfd;
}

input:focus {
  border-color: #93b4f8;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input[type="file"] {
  padding: 7px 10px;
}

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

.avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: #2f3440;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
}

.page {
  width: min(1340px, 100%);
  margin: 0 auto;
  padding: 26px 28px 56px;
}

.notice {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  padding: 10px 12px;
  color: #875216;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow);
  font-size: 13px;
}

.notice.error {
  color: #991b1b;
  border-color: #fecaca;
  background: #fff7f7;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  color: var(--blue);
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.pill.danger {
  color: var(--red);
  background: #fef2f2;
  border-color: #fecaca;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.page-head h1 {
  margin: 4px 0 6px;
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: 0;
}

.page-head p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.eyebrow {
  color: var(--muted-soft);
  font-size: 12px;
  font-weight: 700;
}

.btn {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
}

.btn.primary {
  color: #ffffff;
  background: var(--navy);
  border-color: var(--navy);
}

.btn.primary:hover {
  background: var(--navy-hover);
}

.btn.secondary {
  color: var(--text);
  background: #ffffff;
  border-color: var(--line-strong);
}

.btn.secondary:hover {
  background: var(--panel-soft);
}

.btn.small {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 13px;
}

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

.metric-card {
  min-height: 86px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-card span,
.metric-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric-card strong {
  display: block;
  margin: 7px 0 5px;
  font-size: 22px;
  line-height: 1.2;
}

.metric-card strong.compact {
  font-size: 14px;
  word-break: break-word;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

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

.panel.wide {
  grid-column: 1 / -1;
}

.panel-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-title h2 {
  margin: 0 0 4px;
  font-size: 16px;
  line-height: 1.3;
}

.panel-title p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.form-stack,
.form-inline,
.upload-row {
  display: grid;
  gap: 10px;
  margin: 0;
}

.form-inline {
  grid-template-columns: 120px minmax(220px, 1fr) minmax(180px, 0.8fr) auto;
}

.upload-row {
  grid-template-columns: minmax(220px, 1fr) auto;
  margin-bottom: 14px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 700px;
  border-collapse: collapse;
  background: #ffffff;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  color: #516078;
  background: #f7f9fc;
  font-weight: 700;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #fbfcfe;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  color: #475569;
  background: #eef2f7;
  border: 1px solid #dbe3ee;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-succeeded,
.status-info {
  color: var(--green);
  background: #ecfdf5;
  border-color: #a7f3d0;
}

.status-running,
.status-pending {
  color: var(--blue);
  background: #eff6ff;
  border-color: #bfdbfe;
}

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

.status-needs_human,
.status-warning,
.status-paused {
  color: var(--orange);
  background: #fff7ed;
  border-color: #fed7aa;
}

.status-cancelled {
  color: #64748b;
  background: #f1f5f9;
  border-color: #cbd5e1;
}

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

.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  word-break: break-all;
}

.empty {
  padding: 24px 14px;
  color: var(--muted);
  text-align: center;
}

.detail-metrics .metric-card {
  min-height: 92px;
}

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

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    height: auto;
  }

  .side-nav {
    display: flex;
    overflow-x: auto;
    padding: 10px;
  }

  .nav-item {
    flex: 0 0 auto;
  }

  .nav-item b,
  .sidebar-foot {
    display: none;
  }

  .topbar {
    position: static;
  }

  .page {
    padding: 20px 16px 40px;
  }

  .metrics,
  .panel-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-inline {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: stretch;
    height: auto;
    flex-direction: column;
  }

  .topbar-actions,
  .page-head,
  .head-actions,
  .upload-row {
    align-items: stretch;
    flex-direction: column;
  }

  .page-head {
    display: grid;
  }

  .head-actions {
    display: grid;
  }

  .metrics,
  .panel-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 14px;
  }

  .notice {
    align-items: flex-start;
    flex-direction: column;
  }

  table {
    min-width: 620px;
  }
}
