:root {
  --bg: #f4efe6;
  --bg-deep: #eadfce;
  --panel: rgba(255, 251, 245, 0.92);
  --panel-strong: #fffdf9;
  --panel-soft: rgba(255, 255, 255, 0.72);
  --ink: #1e2533;
  --muted: #697382;
  --line: rgba(73, 58, 34, 0.14);
  --brand: #0f766e;
  --brand-deep: #115e59;
  --accent: #c97a17;
  --danger: #c2372b;
  --warning: #c9791a;
  --success: #15803d;
  --shadow-lg: 0 24px 60px rgba(67, 49, 24, 0.14);
  --shadow-md: 0 14px 32px rgba(67, 49, 24, 0.1);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.12), transparent 34%),
    radial-gradient(circle at bottom right, rgba(201, 122, 23, 0.1), transparent 28%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  -webkit-font-smoothing: antialiased;
}

.public-body,
.admin-body {
  min-height: 100vh;
}

/* ====== 前端页面布局 ====== */

.public-layout {
  width: min(1220px, calc(100% - 40px));
  margin: 0 auto;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  gap: 24px;
  align-items: center;
  padding: 32px 0;
}

.public-layout.compact {
  width: min(760px, calc(100% - 32px));
  grid-template-columns: 1fr;
  align-items: start;
  padding: 42px 0 28px;
}

/* ====== 通用卡片 ====== */

.hero-panel,
.surface-card,
.login-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(14px);
}

.hero-panel {
  padding: 34px 30px;
  position: relative;
  overflow: hidden;
}

.hero-panel::before {
  content: "";
  position: absolute;
  inset: auto -60px -70px auto;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(15, 118, 110, 0.16), transparent 72%);
  pointer-events: none;
}

.surface-card {
  padding: 28px;
}

.action-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78) 0%, rgba(255, 251, 245, 0.96) 100%);
}

/* ====== 字体层级 ====== */

.hero-kicker,
.section-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brand);
}

.hero-title,
.section-title,
.admin-title {
  margin: 0;
  letter-spacing: -0.02em;
}

.hero-title {
  font-size: 42px;
  line-height: 1.04;
}

.hero-title.small {
  font-size: 34px;
}

.hero-copy {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.85;
  font-size: 15px;
}

.hero-points {
  display: grid;
  gap: 14px;
  margin-top: 26px;
}

.hero-point {
  border: 1px solid rgba(15, 118, 110, 0.08);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.54);
  padding: 16px 16px 14px;
}

.hero-point-title {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
}

.hero-point-copy {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.public-main {
  display: grid;
  gap: 22px;
}

.public-main.single-column {
  max-width: 760px;
  margin: 0 auto;
}

/* ====== 区块头部 ====== */

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.section-badge,
.detail-status,
.status-chip,
.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.section-badge {
  color: var(--brand);
  background: rgba(15, 118, 110, 0.08);
}

.section-badge.muted {
  color: var(--accent);
  background: rgba(201, 122, 23, 0.1);
}

/* ====== 表单 ====== */

.field-stack {
  display: grid;
  gap: 16px;
}

.form-spacing {
  margin-bottom: 22px;
}

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

.field-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.inline-field,
.toolbar,
.admin-topbar,
.pagination,
.table-actions,
.status-head {
  display: flex;
  gap: 12px;
  align-items: center;
}

.inline-field input {
  flex: 1;
}

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

input,
textarea,
select {
  width: 100%;
  border: 1px solid rgba(86, 72, 44, 0.18);
  border-radius: 16px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 15px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

input::placeholder,
textarea::placeholder {
  color: #98a2b3;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(15, 118, 110, 0.44);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.08);
  transform: translateY(-1px);
}

button {
  border: 0;
  border-radius: 16px;
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.14s ease, opacity 0.14s ease, box-shadow 0.14s ease;
  white-space: nowrap;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
}

.btn-secondary {
  color: var(--brand);
  background: rgba(15, 118, 110, 0.08);
  border: 1px solid rgba(15, 118, 110, 0.16);
}

.btn-ghost {
  color: var(--accent);
  background: rgba(201, 122, 23, 0.08);
  border: 1px solid rgba(201, 122, 23, 0.16);
}

.btn-danger {
  color: var(--danger);
  background: rgba(194, 55, 43, 0.08);
  border: 1px solid rgba(194, 55, 43, 0.14);
}

.btn-warning {
  margin-top: 14px;
  color: #fff;
  background: linear-gradient(135deg, #e79a20, #c9791a);
}

/* ====== 状态面板 ====== */

.status-panel {
  display: none;
  margin-top: 12px;
  border: 1px solid rgba(15, 118, 110, 0.1);
  border-radius: var(--radius-lg);
  background: rgba(15, 118, 110, 0.04);
  padding: 18px;
}

.status-panel.show {
  display: block;
}

.status-head {
  justify-content: space-between;
  margin-bottom: 14px;
}

.status-title {
  font-weight: 800;
}

.status-badge {
  color: #92400e;
  background: #fef3c7;
}

.badge-running {
  color: #92400e;
  background: #fef3c7;
}

.badge-done {
  color: #065f46;
  background: #d1fae5;
}

.badge-failed {
  color: #c2410c;
  background: #ffedd5;
}

.badge-stopped {
  color: #991b1b;
  background: #fee2e2;
}

.badge-pending {
  color: #1d4ed8;
  background: #dbeafe;
}

/* ====== 进度条 ====== */

.progress-wrap {
  margin: 16px 0 12px;
}

.progress-bar {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.06);
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), #31b6ac);
  transition: width 0.4s ease;
}

.progress-fill.has-fail {
  background: linear-gradient(90deg, #f59e0b, #f97316);
}

.progress-pct {
  margin-top: 6px;
  text-align: right;
  color: var(--brand);
  font-size: 13px;
  font-weight: 800;
}

/* ====== 状态信息网格 ====== */

.status-grid,
.summary-grid,
.meta-grid {
  display: grid;
  gap: 12px;
}

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

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

.status-item,
.summary-item {
  border-radius: 16px;
  padding: 14px 14px 12px;
  background: rgba(255, 255, 255, 0.82);
}

.status-item span,
.summary-item span,
.meta-grid span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.status-item strong,
.summary-item strong,
.meta-grid strong {
  display: block;
  word-break: break-word;
}

.status-note {
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.9;
}

.status-error {
  color: var(--danger);
}

.status-empty,
.empty-row {
  padding: 16px;
  text-align: center;
  color: var(--muted);
}

/* ====== 弹窗 ====== */

.modal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(18, 18, 18, 0.38);
  backdrop-filter: blur(6px);
  z-index: 1000;
}

.modal-overlay.show {
  display: flex;
}

.modal-card {
  width: min(420px, 100%);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.48);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow-lg);
  padding: 28px 26px 24px;
  text-align: center;
}

.modal-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--danger);
  background: rgba(194, 55, 43, 0.12);
  font-size: 24px;
  font-weight: 800;
}

.modal-message {
  margin-bottom: 18px;
  line-height: 1.75;
  font-size: 15px;
  font-weight: 600;
}

/* ====== 后台登录 ====== */

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

.login-card {
  width: min(440px, 100%);
  padding: 34px 30px;
}

.login-card .hero-copy.compact {
  margin-bottom: 22px;
}

.admin-shell.hidden,
.hidden {
  display: none !important;
}

/* ====== 后台布局 ====== */

.admin-topbar {
  width: min(1380px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 16px;
  justify-content: space-between;
  flex-wrap: wrap;
}

.admin-layout {
  width: min(1380px, calc(100% - 40px));
  margin: 0 auto 40px;
  display: grid;
  gap: 22px;
}

.admin-title {
  font-size: 30px;
}

.toolbar {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toolbar select,
.toolbar input {
  width: auto;
  min-width: 112px;
}

/* ====== 表格 ====== */

.table-card {
  border: 1px solid rgba(84, 70, 41, 0.1);
  border-radius: 18px;
  background: var(--panel-soft);
  overflow: hidden;
}

.table-wrap {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid rgba(84, 70, 41, 0.08);
  text-align: left;
  font-size: 13px;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.72);
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.5);
}

.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

/* ====== 分页 ====== */

.pagination {
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 18px;
}

.page-btn {
  min-width: 42px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(84, 70, 41, 0.1);
}

.page-btn.active {
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
}

/* ====== 详情区 ====== */

.generated-cards,
.detail-meta,
.detail-logs {
  margin: 0;
  border-radius: 18px;
  padding: 16px;
}

.generated-cards,
.detail-meta {
  background: rgba(255, 255, 255, 0.7);
}

.detail-meta.empty {
  color: var(--muted);
  text-align: center;
}

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

.detail-card {
  padding-bottom: 24px;
}

.detail-status {
  color: var(--brand);
  background: rgba(15, 118, 110, 0.08);
}

.detail-logs {
  min-height: 360px;
  max-height: 760px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.68;
  font-size: 13px;
  color: #dce8f7;
  background:
    linear-gradient(180deg, rgba(19, 29, 45, 0.98), rgba(14, 22, 35, 0.98));
}

/* ====== 响应式 - 平板 ====== */

@media (max-width: 1180px) {
  .public-layout {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .hero-panel {
    order: 2;
  }

  .public-main {
    order: 1;
  }

  .public-layout.compact {
    width: min(760px, calc(100% - 24px));
  }

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

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

/* ====== 响应式 - 手机 ====== */

@media (max-width: 760px) {
  .public-layout,
  .admin-topbar,
  .admin-layout {
    width: min(100%, calc(100% - 24px));
  }

  .public-layout {
    padding: 16px 0 24px;
    gap: 16px;
  }

  .public-layout.compact {
    padding: 20px 0 24px;
  }

  .surface-card,
  .hero-panel,
  .login-card {
    padding: 20px 16px;
    border-radius: 22px;
  }

  .hero-title {
    font-size: 32px;
  }

  .hero-title.small,
  .admin-title {
    font-size: 24px;
  }

  .section-head {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 16px;
  }

  .inline-field {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }

  .toolbar select,
  .toolbar input {
    flex: 1;
    min-width: 80px;
  }

  .toolbar .btn {
    flex: 0 0 auto;
  }

  .admin-topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 16px 0 8px;
  }

  .table-actions {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }

  .table-actions .btn {
    font-size: 12px;
    padding: 10px 12px;
  }

  .status-head {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .summary-grid,
  .status-grid,
  .meta-grid {
    grid-template-columns: 1fr;
  }

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

  button,
  .btn {
    padding: 14px 16px;
  }

  input,
  textarea,
  select {
    padding: 14px;
    font-size: 16px;
  }

  th,
  td {
    padding: 10px 8px;
    font-size: 12px;
  }

  .detail-logs {
    min-height: 240px;
    max-height: 480px;
    font-size: 12px;
  }
}

/* ====== 小屏手机 ====== */

@media (max-width: 420px) {
  .public-layout,
  .admin-topbar,
  .admin-layout {
    width: calc(100% - 16px);
  }

  .surface-card,
  .hero-panel,
  .login-card {
    padding: 16px 12px;
    border-radius: 18px;
  }

  .hero-title {
    font-size: 26px;
  }

  .hero-title.small,
  .admin-title {
    font-size: 20px;
  }

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

  .toolbar {
    flex-direction: column;
  }

  .toolbar select,
  .toolbar input {
    width: 100%;
  }
}
