:root {
  --bg: #f3f5f9;
  --panel: #ffffff;
  --line: #e3e8f0;
  --text: #16202e;
  --muted: #6b7789;
  --accent: #1f6feb;
  --accent-soft: #e8f0fe;
  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 30, 54, .04), 0 8px 24px rgba(16, 30, 54, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

h1, h2, h3 { margin: 0; font-weight: 600; }

/* 顶栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #1f6feb, #4f9bff);
  color: #fff;
  font-weight: 700;
  font-size: 19px;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(31, 111, 235, .28);
}

.brand h1 { font-size: 17px; letter-spacing: .2px; }
.brand p { margin: 0; color: var(--muted); font-size: 12px; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  border: 1px solid transparent;
  white-space: nowrap;
}

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

.status-pill[data-state="loading"] { background: #eef1f6; color: var(--muted); }
.status-pill[data-state="ready"] { background: var(--ok-soft); color: var(--ok); border-color: #cfe9d8; }
.status-pill[data-state="eplan-off"] { background: var(--warn-soft); color: var(--warn); border-color: #f3e0c4; }
.status-pill[data-state="offline"] { background: var(--danger-soft); color: var(--danger); border-color: #f7d4d0; }

/* 布局 */
.layout {
  max-width: 1080px;
  margin: 0 auto;
  padding: 22px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

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

.panel-head h2 { font-size: 15px; }

.muted { color: var(--muted); font-size: 12.5px; }

/* 提示 */
.notice { border-color: #f3d9a4; background: #fffaf0; }
.notice-title { font-weight: 600; color: var(--warn); margin-bottom: 6px; }
.notice-body { color: #6b5a3e; font-size: 13px; margin-bottom: 10px; }
.notice-body ol { margin: 6px 0 0; padding-left: 20px; }
.notice-body code { background: #fff; border: 1px solid #eadfc8; border-radius: 5px; padding: 1px 5px; }

/* 搜索 */
.search-label { display: block; font-weight: 600; margin-bottom: 8px; }

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box svg {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  fill: #8a97a8;
  pointer-events: none;
}

#searchInput {
  width: 100%;
  padding: 12px 78px 12px 42px;
  font-size: 14.5px;
  font-family: inherit;
  color: var(--text);
  background: #f8fafc;
  border: 1.5px solid var(--line);
  border-radius: 11px;
  outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}

#searchInput:focus {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, .12);
}

.clear-btn {
  position: absolute;
  right: 10px;
  border: 0;
  background: #eef1f6;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 7px;
  cursor: pointer;
}

.clear-btn:hover { background: #e3e8f0; color: var(--text); }

.search-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12.5px;
}

.hint { color: #97a3b4; }

.meta-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-small {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 7px;
}

/* 项目列表 */
.list-panel { padding: 0; overflow: hidden; }

.list-head, .row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px 132px;
  gap: 12px;
  align-items: center;
  padding: 11px 18px;
}

.list-head {
  background: #f7f9fc;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .3px;
}

.list-body { max-height: 58vh; overflow-y: auto; }

.row { border-bottom: 1px solid #f0f3f8; }
.row:last-child { border-bottom: 0; }
.row:hover { background: #f8fbff; }

.col-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.col-date { color: var(--muted); font-size: 12.5px; }
.col-action { display: flex; justify-content: flex-end; }

.tag {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  vertical-align: 1px;
  background: var(--warn-soft);
  color: var(--warn);
}

/* 按钮 */
.btn {
  font-family: inherit;
  font-size: 13px;
  border-radius: 9px;
  padding: 7px 13px;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #1a5fd0; }

.btn-outline {
  background: #fff;
  border-color: #cfdaea;
  color: var(--accent);
}

.btn-outline:hover { background: var(--accent-soft); border-color: #b6cdf5; }

.btn-ghost {
  background: #f1f4f9;
  border-color: var(--line);
  color: #435065;
}

.btn-ghost:hover { background: #e8edf5; }

.btn:disabled { opacity: .55; cursor: not-allowed; }

/* 任务 */
.job-list { display: flex; flex-direction: column; gap: 9px; }

.job {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fbfcfe;
}

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

.job-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-meta {
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
}

.badge.queued { background: #eef1f6; color: #5a6779; }
.badge.running { background: var(--accent-soft); color: var(--accent); }
.badge.succeeded { background: var(--ok-soft); color: var(--ok); }
.badge.failed { background: var(--danger-soft); color: var(--danger); }

.spinner {
  width: 11px;
  height: 11px;
  border: 2px solid rgba(31, 111, 235, .25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.job-error { color: var(--danger); font-size: 12px; margin-top: 4px; word-break: break-all; }

.job-actions { display: flex; gap: 8px; }

/* 空状态 */
.empty {
  padding: 34px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.empty.small { padding: 18px 12px; }

.list-foot {
  padding: 12px;
  text-align: center;
  border-top: 1px solid var(--line);
  background: #fbfcfe;
}

/* PDF 预览层 */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #10161f;
  display: flex;
  flex-direction: column;
}

.viewer[hidden] { display: none; }

.viewer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: #1a2330;
  color: #e7edf6;
  font-size: 13px;
}

.viewer-bar > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-actions { display: flex; gap: 8px; flex-shrink: 0; }

#viewerFrame {
  flex: 1;
  width: 100%;
  border: 0;
  background: #fff;
}

.footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px 28px;
  color: #97a3b4;
  font-size: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 60;
  max-width: 80vw;
  padding: 10px 18px;
  border-radius: 10px;
  background: rgba(22, 32, 46, .94);
  color: #f2f6fc;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(16, 30, 54, .28);
}

.toast[hidden] { display: none; }

@media (max-width: 720px) {
  .topbar-inner { flex-direction: column; align-items: flex-start; gap: 10px; }
  .layout { padding: 16px 14px 32px; }
  .panel { padding: 14px; }
  .list-head, .row { grid-template-columns: minmax(0, 1fr) 108px; padding: 10px 14px; }
  .col-date { display: none; }
  .list-head .col-action { justify-self: end; }
  .job { grid-template-columns: minmax(0, 1fr); }
  .job-actions { justify-content: flex-start; }
}
