:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #eff6ff;
  --green: #16a34a;
  --green-soft: #f0fdf4;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --sidebar-w: 228px;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }

/* ---------- 侧边栏 ---------- */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: #111827;
  color: #d1d5db;
  display: flex;
  flex-direction: column;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-mark {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}
.brand-mark.large { width: 46px; height: 46px; font-size: 22px; }
.brand-name { color: #fff; font-weight: 600; font-size: 15px; }
.brand-sub { font-size: 11px; color: #9ca3af; margin-top: 2px; }

.nav { padding: 12px 10px; flex: 1; }
.nav-item {
  display: block;
  padding: 10px 14px;
  margin-bottom: 4px;
  border-radius: 8px;
  color: #cbd5e1;
  font-size: 14px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; font-weight: 600; }
.nav-divider { border-top: 1px solid rgba(255,255,255,.08); margin: 12px 8px; }

.sidebar-foot {
  padding: 14px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex-shrink: 0;
}
.user-name { color: #fff; font-size: 13px; }
.user-role { font-size: 11px; color: #9ca3af; }
.logout {
  display: block;
  text-align: center;
  padding: 8px;
  border-radius: 8px;
  background: rgba(255,255,255,.06);
  color: #cbd5e1;
  font-size: 13px;
}
.logout:hover { background: rgba(255,255,255,.12); color: #fff; }

/* ---------- 主区域 ---------- */
.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar h1 { margin: 0; font-size: 20px; font-weight: 600; }
.content { padding: 24px 28px 40px; max-width: 1200px; width: 100%; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-bottom: 18px;
}
.card h2 { margin: 0 0 14px; font-size: 16px; font-weight: 600; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.card-head h2 { margin: 0; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.records-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.records-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.card-stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 28px; font-weight: 700; margin: 6px 0 2px; letter-spacing: .5px; }
.stat-value.money { font-size: 22px; color: var(--accent-dark); }
.stat-hint { color: var(--muted); font-size: 12px; }

.notice {
  background: var(--accent-soft);
  border: 1px solid #bfdbfe;
  color: #1e40af;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 18px;
}
.notice a { font-weight: 600; }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: #f9fafb;
  white-space: nowrap;
}
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}
.table tbody tr:hover { background: #fafbfc; }
.td-name { max-width: 320px; }
.muted { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

/* ---------- 状态徽标 ---------- */
.pill {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.pill-pending { background: var(--amber-soft); color: var(--amber); }
.pill-running {
  background: var(--accent-soft);
  color: var(--accent-dark);
  position: relative;
}
.pill-running::before {
  content: "";
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .25; }
}
.pill-completed { background: var(--green-soft); color: var(--green); }
.pill-failed { background: var(--red-soft); color: var(--red); }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  background: #f3f4f6;
  color: #374151;
  font-size: 12px;
  white-space: nowrap;
}
.tag-blue { background: var(--accent-soft); color: var(--accent-dark); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-block;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  text-align: center;
  transition: background .15s, border-color .15s, color .15s;
  font-family: inherit;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); color: #fff; }
.btn-ghost { background: #fff; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-dark); }
.btn-danger { background: var(--red-soft); color: var(--red); border-color: #fecaca; }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.actions { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.actions .inline-form { margin: 0; }
.inline-form { display: inline; margin: 0; }
.actions-cell { white-space: nowrap; }

/* ---------- 表单 ---------- */
.form-card { max-width: 760px; }
.form-card.narrow { max-width: 520px; }
.form .field { display: block; margin-bottom: 14px; }
.field span {
  display: block;
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
  margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.field textarea.mono { font-family: Consolas, "Microsoft YaHei", monospace; line-height: 1.55; }
.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 600;
}
.checkbox-line input { width: 16px; height: 16px; accent-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.hint { color: var(--muted); font-size: 12px; margin: 4px 0 12px; }
.file-tip { color: var(--muted); font-size: 12px; margin-top: 4px; }
.optional { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 4px; }

/* 上传 */
.upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 8px; }
.upload-box {
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  padding: 16px;
  background: #fafbfc;
  transition: border-color .15s, background .15s;
}
.upload-box:hover { border-color: var(--accent); background: var(--accent-soft); }
.upload-label { font-weight: 600; font-size: 14px; display: block; margin-bottom: 8px; }
.file-input { width: 100%; font-size: 13px; }
.mode-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 16px 0 8px; }
.mode-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.mode-item:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.mode-item input { margin-top: 3px; accent-color: var(--accent); }
.mode-body { display: flex; flex-direction: column; gap: 2px; }
.mode-body small { color: var(--muted); font-size: 12px; }
.offpeak-hint {
  background: var(--green-soft);
  border: 1px solid #bbf7d0;
  color: #166534;
  border-radius: 10px;
  padding: 12px 16px;
  margin: 8px 0 14px;
}

/* 上传进度 */
.progress-box { margin: 8px 0 14px; }
.progress-label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.progress-track {
  height: 8px;
  border-radius: 999px;
  background: #eef1f6;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width .2s;
}

/* 在线预览 */
.doc-preview { line-height: 1.75; color: var(--text); }
.doc-preview h1, .doc-preview h2, .doc-preview h3 { color: var(--text); margin: 18px 0 8px; }
.doc-preview h1 { font-size: 22px; }
.doc-preview h2 { font-size: 17px; }
.doc-preview h3 { font-size: 15px; }
.doc-preview p { margin: 6px 0; }
.doc-preview ul, .doc-preview ol { padding-left: 24px; }
.doc-preview table { border-collapse: collapse; width: 100%; margin: 10px 0; }
.doc-preview table th, .doc-preview table td {
  border: 1px solid var(--border);
  padding: 7px 10px;
  font-size: 13px;
  vertical-align: top;
}
.doc-preview strong { font-weight: 600; }

/* 弹窗 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 640px;
  max-height: 92vh;
  overflow: auto;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, .22);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-close {
  border: none;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}
.modal-close:hover { color: var(--text); }

/* 详情 */
.detail-card { max-width: 900px; }
.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.detail-head h2 { margin: 0 0 4px; font-size: 18px; }
.kv { width: 100%; border-collapse: collapse; }
.kv td {
  padding: 8px 10px;
  border: 1px solid var(--border);
  font-size: 13px;
}
.kv td:nth-child(odd) { background: #f9fafb; color: var(--muted); width: 110px; font-weight: 600; }

/* ---------- 登录 ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #eef2ff 0%, var(--bg) 45%);
  padding: 20px;
}
.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .08);
  width: 100%;
  max-width: 400px;
  padding: 32px;
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-title { font-size: 19px; font-weight: 700; }
.auth-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.auth-tip { text-align: center; color: var(--muted); font-size: 12px; margin-top: 14px; }

/* ---------- 消息 ---------- */
.flash {
  border-radius: 10px;
  padding: 11px 15px;
  margin-bottom: 14px;
  font-size: 13px;
}
.flash-success { background: var(--green-soft); border: 1px solid #bbf7d0; color: #166534; }
.flash-error { background: var(--red-soft); border: 1px solid #fecaca; color: #991b1b; }
.flash-warning { background: var(--amber-soft); border: 1px solid #fde68a; color: #92400e; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .sidebar { position: static; width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .nav { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px; }
  .nav-item { margin: 0; }
  .sidebar-foot { display: none; }
  .main { margin-left: 0; }
  .grid2, .grid3, .upload-grid, .mode-row { grid-template-columns: 1fr; }
}
