* { box-sizing: border-box; }
:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e4e6eb;
  --text: #1e2330;
  --muted: #7b8194;
  --brand: #2f6bff;
  --brand-dark: #1f52d0;
  --ok: #12a150;
  --warn: #d98324;
  --danger: #e5484d;
  --radius: 12px;
}
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: 0 10px 30px rgba(20, 30, 60, .06);
  text-align: center;
}
.login-card .logo { font-size: 22px; font-weight: 700; letter-spacing: 2px; }
.login-card .sub { color: var(--muted); margin: 6px 0 18px; }
.login-card input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-align: center;
  letter-spacing: 2px;
  font-size: 16px;
  outline: none;
  background: #fbfbfd;
}
.login-card input:focus { border-color: var(--brand); background: #fff; }
.login-card .tip { color: var(--muted); font-size: 12px; margin: 16px 0 0; }
.err { color: var(--danger); min-height: 20px; margin-top: 10px; font-size: 13px; }

.primary {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 11px 20px;
  font-weight: 600;
  transition: background .15s;
}
.primary:hover { background: var(--brand-dark); }
.primary:disabled { opacity: .55; cursor: not-allowed; }
.login-card .primary { width: 100%; margin-top: 14px; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 20px;
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: 1px; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tabs button {
  border: none;
  background: transparent;
  padding: 8px 14px;
  border-radius: 8px;
  color: var(--muted);
  white-space: nowrap;
}
.tabs button.active { background: #eef3ff; color: var(--brand); font-weight: 600; }
.who { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.stock-pill {
  display: flex;
  gap: 6px;
  align-items: center;
  border: 1px solid var(--line);
  background: #f7f9ff;
  border-radius: 999px;
  padding: 4px 6px;
  white-space: nowrap;
}
.stock-pill .sp { font-size: 12px; color: var(--muted); padding: 2px 9px; border-radius: 999px; }
.stock-pill .sp + .sp { border-left: 1px solid var(--line); border-radius: 0 999px 999px 0; padding-left: 12px; }
.stock-pill b { font-size: 14px; color: var(--brand); font-variant-numeric: tabular-nums; }
.stock-pill .sp.empty b { color: var(--danger); }
.stock-pill .sp.low b { color: var(--warn); }
.stock-pill .sp b.bump { animation: bump .6s ease; }
@keyframes bump { 0% { transform: scale(1); } 35% { transform: scale(1.45); color: var(--ok); } 100% { transform: scale(1); } }
.ghost {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 13px;
  color: var(--text);
}
.ghost:hover { border-color: #c9cdd8; background: #fafbff; }
.ghost.danger { color: var(--danger); border-color: #f6d3d4; }
.ghost.danger:hover { background: #fff5f5; }

/* ---------- 布局 ---------- */
.main { max-width: 1080px; margin: 0 auto; padding: 20px; display: grid; gap: 16px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.card h2 { font-size: 16px; margin: 0 0 6px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--muted); margin: 0 0 14px; font-size: 13px; }

.form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12px; color: var(--muted); }
.field select, .field input, .field textarea {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfbfd;
  outline: none;
  min-width: 190px;
}
.field select:focus, .field input:focus { border-color: var(--brand); background: #fff; }
#claimCount { min-width: 110px; width: 110px; }

.stockbar { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0 16px; }
.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  background: #fafbfe;
}
.chip b { color: var(--brand); font-size: 15px; }
.chip.warn b { color: var(--warn); }
.hint { margin-top: 12px; font-size: 13px; color: var(--muted); min-height: 20px; }

textarea#resultBox {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #fbfbfd;
  font-family: ui-monospace, Menlo, Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.75;
  white-space: pre;
  overflow: auto;
}

/* ---------- 上传 ---------- */
.drop {
  border: 2px dashed #cfd4e0;
  border-radius: var(--radius);
  padding: 30px;
  text-align: center;
  color: var(--muted);
  background: #fafbff;
  cursor: pointer;
  transition: .15s;
}
.drop:hover, .drop.over { border-color: var(--brand); background: #f2f6ff; color: var(--brand); }
.parse-list { display: grid; gap: 12px; margin-top: 16px; }
.parse-item { border: 1px solid var(--line); border-radius: 10px; padding: 14px; background: #fff; }
.parse-item .row1 { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; }
.parse-item .name { font-weight: 600; word-break: break-all; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; margin-left: 6px; }
.tag.acc { background: #eaf0ff; color: var(--brand); }
.tag.pho { background: #e8f8ef; color: var(--ok); }
.tag.mix { background: #fff4e5; color: var(--warn); }
pre.preview {
  margin: 10px 0 0;
  background: #fbfbfd;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
  max-height: 170px;
  overflow: auto;
  white-space: pre;
}
.skipped { color: var(--warn); font-size: 12px; margin-top: 8px; }
.ok-msg { color: var(--ok); font-size: 13px; }

/* ---------- 列表 / 表格 ---------- */
.list { display: grid; gap: 10px; }
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  flex-wrap: wrap;
}
.list-item .meta { color: var(--muted); font-size: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; background: #fafbfd; position: sticky; top: 0; }
td.code { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .5px; }
tr.off td { color: #b6bac6; text-decoration: line-through; }
tr.hl td { background: #f2f6ff; }
.empty { color: var(--muted); padding: 14px 0; font-size: 13px; }
.mini-select {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfbfd;
  outline: none;
}
.tag-act { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: #eef1f6; color: #555c6e; }
.tag-act.good { background: #e8f8ef; color: var(--ok); }
.tag-act.warn { background: #fff4e5; color: var(--warn); }
.tag-act.bad { background: #fdecec; color: var(--danger); }
td.when { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; }
td.num { font-variant-numeric: tabular-nums; }
.table-wrap.scroll { max-height: 420px; overflow-y: auto; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  background: #1e2330;
  color: #fff;
  padding: 11px 20px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 99;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
  max-width: 80vw;
}
.toast.error { background: var(--danger); }

@media (max-width: 640px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 14px; gap: 8px; }
  .tabs { order: 4; width: 100%; }
  .stock-pill { order: 3; width: 100%; justify-content: center; background: transparent; border: none; padding: 0; }
  .stock-pill .sp { background: #f7f9ff; border: 1px solid var(--line); border-radius: 999px; flex: 1; text-align: center; }
  .stock-pill .sp + .sp { border-left: 1px solid var(--line); padding-left: 9px; }
  .main { padding: 14px; }
  .field select, .field input { min-width: 0; width: 100%; }
  .form-row { flex-direction: column; align-items: stretch; }
  .form-row .primary { width: 100%; }
}
