:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e5e7eb;
  --txt: #1f2937;
  --muted: #6b7280;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--txt); font-size: 14px;
}
#app { min-height: 100vh; }

/* ---------- 布局 ---------- */
.topbar {
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 0 20px; height: 56px; display: flex; align-items: center; gap: 18px;
  position: sticky; top: 0; z-index: 50;
}
.brand { font-weight: 600; font-size: 16px; color: var(--brand); cursor: pointer; white-space: nowrap; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a {
  padding: 8px 12px; border-radius: 8px; color: var(--muted);
  text-decoration: none; white-space: nowrap; font-size: 14px;
}
.nav a.active, .nav a:hover { background: #eef2ff; color: var(--brand); }
.userbox { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.balance-chip { background: #ecfdf5; color: var(--ok); border-radius: 999px; padding: 4px 12px; font-size: 13px; }
.container { max-width: 1200px; margin: 20px auto; padding: 0 16px; }

/* ---------- 卡片/表格 ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card h3 { font-size: 15px; margin-bottom: 14px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.tbl th { color: var(--muted); font-weight: 500; background: #fafafa; white-space: nowrap; }
.tbl tr:hover td { background: #f8fafc; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; white-space: nowrap; }
.tag.blue { background: #dbeafe; color: #1d4ed8; }
.tag.green { background: #dcfce7; color: #15803d; }
.tag.orange { background: #ffedd5; color: #c2410c; }
.tag.gray { background: #f3f4f6; color: #4b5563; }
.tag.red { background: #fee2e2; color: #b91c1c; }
.thumb { width: 46px; height: 46px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px; background: #fff; color: var(--txt); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); }
.btn {
  display: inline-block; padding: 8px 18px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--txt); font-size: 13px; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); color: #fff; }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input, .toolbar select { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }

/* ---------- 登录页 ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #eef2ff, #f5f6f8); }
.auth-card { width: 380px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 30px; }
.auth-card h2 { margin-bottom: 6px; }
.auth-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.auth-card .field { margin-bottom: 14px; }
.auth-card .btn.primary { width: 100%; padding: 10px; font-size: 14px; }

/* ---------- 分页 ---------- */
.pager { display: flex; gap: 6px; justify-content: flex-end; margin-top: 12px; align-items: center; color: var(--muted); font-size: 13px; }

/* ---------- AI 助手 ---------- */
.ai-fab {
  position: fixed; right: 22px; bottom: 22px; width: 54px; height: 54px; border-radius: 50%;
  background: var(--brand); color: #fff; border: none; font-size: 22px; cursor: pointer;
  box-shadow: 0 6px 20px rgba(37,99,235,.35); z-index: 90;
}
.ai-panel {
  position: fixed; right: 0; top: 0; bottom: 0; width: 400px; max-width: 95vw;
  background: #fff; border-left: 1px solid var(--line); z-index: 100;
  display: flex; flex-direction: column; box-shadow: -8px 0 30px rgba(0,0,0,.08);
}
.ai-head { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.ai-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 85%; padding: 9px 13px; border-radius: 12px; font-size: 13px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 3px; }
.msg.bot { align-self: flex-start; background: #f3f4f6; border-bottom-left-radius: 3px; }
.ai-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.ai-input input { flex: 1; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; outline: none; }

/* ---------- 状态点 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat .num { font-size: 22px; font-weight: 600; margin-top: 4px; }
.stat .lbl { color: var(--muted); font-size: 12px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.toast {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 20px; border-radius: 8px; z-index: 200; font-size: 13px;
}
.toast.err { background: var(--danger); }

/* ---------- AI 助手增强 ---------- */
.nav a.ai-nav { color: var(--brand); font-weight: 500; }
.ai-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; justify-content: center; }
.ai-chips span { background: #eef2ff; color: var(--brand); border-radius: 999px; padding: 5px 12px; font-size: 12px; cursor: pointer; }
.ai-chips span:hover { background: #dbeafe; }

/* ---------- 批量提交订单 ---------- */
.hint-box {
  background: #eff6ff; border: 1px solid #dbeafe; color: #1d4ed8;
  border-radius: 8px; padding: 10px 14px; font-size: 13px; line-height: 1.8; margin-bottom: 14px;
}
.rate-chip {
  display: flex; align-items: center; gap: 8px; background: #f0fdf4;
  border: 1px solid #dcfce7; color: #166534; border-radius: 999px; padding: 6px 14px; font-size: 13px;
}
.rate-chip b { color: #15803d; }
.tabs { display: flex; gap: 26px; border-bottom: 1px solid var(--line); }
.tabs .tab {
  padding: 10px 2px; cursor: pointer; color: var(--muted); font-size: 14px;
  border-bottom: 2px solid transparent; user-select: none;
}
.tabs .tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.fill-box { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.fill-box .fill-lbl { color: var(--muted); font-size: 13px; white-space: nowrap; }
.fill-box select, .fill-box input { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }

.batch-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
table.batch-tbl { border-collapse: separate; border-spacing: 0; font-size: 13px; width: max-content; min-width: 100%; }
.batch-tbl th, .batch-tbl td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 0; }
.batch-tbl th {
  background: #fafafa; color: var(--muted); font-weight: 500;
  padding: 9px 10px; white-space: nowrap; text-align: left; position: sticky; top: 0; z-index: 1;
}
.batch-tbl th .req { color: var(--danger); margin-left: 2px; }
.batch-tbl td { padding: 0; }
.batch-tbl td input {
  width: 100%; border: none; outline: none; background: transparent;
  padding: 9px 10px; font-size: 13px; color: var(--txt); font-family: inherit;
}
.batch-tbl td input:focus { background: #eff6ff; }
.batch-tbl tr:hover td { background: #f8fafc; }
.batch-tbl .sno { width: 54px; min-width: 54px; text-align: center; color: var(--muted); padding: 9px 6px; }
.batch-tbl .op { width: 72px; min-width: 72px; text-align: center; padding: 6px; }
.batch-tbl th:last-child, .batch-tbl td:last-child { border-right: none; }
.batch-tbl tbody tr:last-child td { border-bottom: none; }
.batch-tbl tr.row-err td { background: #fef2f2; }
.batch-tbl tr.row-err td input { color: var(--danger); }
.err-box {
  margin-top: 12px; background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c;
  border-radius: 8px; padding: 10px 14px; font-size: 13px; line-height: 1.9; max-height: 190px; overflow: auto;
}
.est { color: var(--brand); }
