* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  font-size: 14px;
  color: #222;
  background: #f5f6f8;
}

header {
  background: #37474f;
  color: #fff;
  padding: 10px 20px;
}

header h1 {
  margin: 0 0 8px;
  font-size: 20px;
}

nav button {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #dfe6ee;
  padding: 6px 16px;
  margin-right: 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

nav button.active {
  background: #fff;
  color: #37474f;
  font-weight: bold;
}

main {
  padding: 16px 20px 40px;
  max-width: 1200px;
  margin: 0 auto;
}

.view { display: none; }
.view.active { display: block; }

.panel {
  background: #fff;
  border: 1px solid #e1e4e8;
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 16px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.toolbar .spacer { flex: 1; }

button.btn {
  background: #2c6fbb;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 14px;
}

button.btn:hover { background: #245e9e; }
button.btn.secondary { background: #6b7a8d; }
button.btn.secondary:hover { background: #59687a; }
button.btn.danger { background: #c0392b; }
button.btn.danger:hover { background: #a93226; }
button.btn:disabled { background: #b9c0c7; cursor: not-allowed; }

button.link {
  background: none;
  border: none;
  color: #2c6fbb;
  cursor: pointer;
  padding: 2px 6px;
  font-size: 13px;
}
button.link.danger { color: #c0392b; }

input[type="text"], input[type="number"], input[type="date"], input[type="password"], select {
  border: 1px solid #c9d0d8;
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 14px;
  background: #fff;
}

input[type="number"] { width: 90px; text-align: right; }

table {
  border-collapse: collapse;
  width: 100%;
  background: #fff;
}

th, td {
  border: 1px solid #e1e4e8;
  padding: 6px 8px;
  text-align: center;
}

th { background: #eef1f5; font-weight: bold; }
td.left { text-align: left; }
th.left { text-align: left; }

tr.warn td { background: #fdecea; color: #b3261e; font-weight: bold; }

tr.best td { background: #e8f5e9; }
td.best, th.best { background: #e8f5e9; font-weight: bold; color: #1b5e20; }

tr.detail td { background: #f8fafc; text-align: left; }
tr.flash td { animation: rowflash 0.9s ease-in-out 2; }
@keyframes rowflash {
  0%, 100% { background: #fff; }
  50% { background: #fff3bf; }
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  background: #e8f0e9;
  color: #2e7d32;
}
.badge.matched { background: #e3f2fd; color: #1565c0; }
.badge.new { background: #fff4e0; color: #e65100; }
.badge.skipped { background: #fdecea; color: #b3261e; }
.badge.inactive { background: #eee; color: #777; }
.badge.low { background: #e8f5e9; color: #1b5e20; font-weight: bold; }

.muted { color: #888; font-size: 13px; }
.right { text-align: right; }

.empty-state {
  text-align: center;
  padding: 40px 0;
  color: #666;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.form-grid label {
  display: block;
  font-size: 13px;
  color: #555;
  margin-bottom: 4px;
}

.form-grid input, .form-grid select { width: 100%; }

.msg-ok { color: #2e7d32; }
.msg-err { color: #b3261e; }

footer {
  text-align: center;
  padding: 12px;
}

h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 16px 0 8px; }

/* 服务器版：登录与用户 */
.login-overlay {
  position: fixed;
  inset: 0;
  background: #f5f6f8;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-box { width: 320px; }
.login-label { display: block; font-size: 13px; color: #555; margin: 10px 0 4px; }
.login-box input { width: 100%; }

header { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
header h1 { margin: 0; }
header nav { width: 100%; }
#user-box { color: #dfe6ee; font-size: 13px; margin-left: auto; }
#user-box .link { color: #ffd699; }

/* buyer 角色隐藏管理入口（服务端仍强制拦截） */
body[data-role="buyer"] .admin-only { display: none !important; }
