:root {
  --brand: #1f4e78;
  --brand-2: #2b6cb0;
  --bg: #f4f6f9;
  --card: #fff;
  --line: #e3e8ef;
  --text: #1f2933;
  --muted: #6b7785;
  --good: #0f7b4d;
  --good-bg: #e3f6ec;
  --mid: #8a5a00;
  --mid-bg: #fdf1d8;
  --bad: #b42318;
  --bad-bg: #fde8e6;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.5 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(135deg, #16385a, #2b6cb0);
}
.login-card {
  width: 100%; max-width: 360px; background: var(--card); border-radius: 14px;
  padding: 32px 28px; box-shadow: 0 20px 50px rgba(0,0,0,.25);
  display: flex; flex-direction: column; gap: 8px;
}
.login-card h1 { margin: 10px 0 0; font-size: 22px; }
.login-card label { margin-top: 14px; font-weight: 600; }
.login-card input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.brand-mark {
  width: 46px; height: 46px; border-radius: 11px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: 24px; font-weight: 700;
}
.brand-mark.sm { width: 28px; height: 28px; font-size: 15px; border-radius: 7px; }
.muted { color: var(--muted); margin: 0; }
.err { color: var(--bad); min-height: 1.4em; margin: 4px 0 0; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10; background: var(--brand); color: #fff;
  display: flex; align-items: center; gap: 24px; padding: 0 20px; height: 56px;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand .brand-mark { background: #fff; color: var(--brand); }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab {
  background: none; border: 0; color: rgba(255,255,255,.75); padding: 8px 14px;
  border-radius: 8px; cursor: pointer; font-weight: 600;
}
.tab:hover { color: #fff; background: rgba(255,255,255,.1); }
.tab.active { color: var(--brand); background: #fff; }
.top-right { display: flex; align-items: center; gap: 10px; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: rgba(255,255,255,.18); }
.topbar .btn.ghost { color: #fff; border-color: rgba(255,255,255,.4); }

main { max-width: 1280px; margin: 0 auto; padding: 20px; }
.panel { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }

/* ---------- 工具栏 ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.toolbar input[type=search] { flex: 1 1 320px; }
.toolbar input, .toolbar select, .field input, .field select, .field textarea {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; min-width: 0;
}
.toolbar input:focus, .toolbar select:focus, .field :is(input,select,textarea):focus, .login-card input:focus {
  outline: 2px solid rgba(43,108,176,.35); border-color: var(--brand-2);
}
.check { display: flex; align-items: center; gap: 6px; color: var(--muted); cursor: pointer; user-select: none; }

.btn {
  border: 1px solid var(--line); background: #fff; padding: 8px 14px; border-radius: 8px;
  cursor: pointer; font-weight: 600; white-space: nowrap;
}
.btn:hover { filter: brightness(.97); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn.block { width: 100%; margin-top: 10px; padding: 10px; }
.btn.danger { color: var(--bad); border-color: #f3c3be; }
.link { background: none; border: 0; color: var(--brand-2); cursor: pointer; padding: 2px 4px; font-weight: 600; }
.link.danger { color: var(--bad); }

.summary { color: var(--muted); margin-bottom: 8px; font-size: 13px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table.grid { width: 100%; border-collapse: collapse; }
.grid th, .grid td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.grid th { background: #f7f9fc; font-weight: 600; color: #3d4852; position: sticky; top: 0; white-space: nowrap; }
.grid th[data-sort] { cursor: pointer; user-select: none; }
.grid th[data-sort]:hover { color: var(--brand-2); }
.grid th .arrow { font-size: 11px; margin-left: 3px; color: var(--brand-2); }
.grid tbody tr:hover { background: #f8fbff; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid .num { text-align: right; }
.grid td.model { font-family: ui-monospace, "Cascadia Mono", Consolas, "Microsoft YaHei", monospace; font-size: 13px; word-break: break-all; }
.grid td.op { white-space: nowrap; }
.grid mark { background: #fff1a8; padding: 0; border-radius: 2px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0 !important; }
.more { text-align: center; margin-top: 10px; }

.disc { display: inline-block; min-width: 46px; text-align: center; padding: 1px 8px; border-radius: 99px; font-weight: 700; font-variant-numeric: tabular-nums; }
.disc.lv1 { background: var(--good-bg); color: var(--good); }
.disc.lv2 { background: var(--mid-bg); color: var(--mid); }
.disc.lv3 { background: var(--bad-bg); color: var(--bad); }

.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 99px; background: #eef1f5; color: #4a5562; white-space: nowrap; }
.tag.ok { background: var(--good-bg); color: var(--good); }
.tag.ing { background: #e6f0fb; color: var(--brand-2); }
.tag.wait { background: var(--mid-bg); color: var(--mid); }
.tag.no { background: var(--bad-bg); color: var(--bad); }

/* ---------- 比价 ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { border: 1px solid var(--line); background: #f7f9fc; border-radius: 99px; padding: 4px 12px; cursor: pointer; font-size: 13px; }
.chip:hover { border-color: var(--brand-2); color: var(--brand-2); }
.cmp-group { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 14px; overflow: hidden; }
.cmp-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; background: #f7f9fc; border-bottom: 1px solid var(--line); }
.cmp-head h3 { margin: 0; font-size: 15px; }
.cmp-best { color: var(--good); font-weight: 600; font-size: 13px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 70px; gap: 12px; align-items: center; padding: 8px 14px; border-bottom: 1px solid #f0f2f5; }
.bar-row:last-child { border-bottom: 0; }
.bar-row .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .who small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 10px; background: #eef1f5; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--brand-2); }
.bar-row.best .bar > i { background: var(--good); }
.bar-row .val { text-align: right; }
.hint { color: var(--muted); padding: 30px 0; text-align: center; }

/* ---------- 供应商 ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; background: #fff; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card h3 { margin: 0; font-size: 17px; }
.card .meta { display: flex; flex-wrap: wrap; gap: 6px; }
.card .note { color: #3d4852; background: #f7f9fc; border-radius: 8px; padding: 8px 10px; min-height: 38px; white-space: pre-wrap; word-break: break-word; }
.card .note.empty-note { color: var(--muted); }
.card .stats { display: flex; gap: 18px; color: var(--muted); font-size: 13px; }
.card .stats b { color: var(--text); font-size: 16px; }
.card-actions { display: flex; gap: 8px; margin-top: auto; flex-wrap: wrap; }

/* ---------- 弹窗 ---------- */
dialog { border: 0; border-radius: 12px; padding: 0; width: min(480px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(15,25,40,.45); }
#dlg-form { padding: 22px; }
#dlg-form h2 { margin: 0 0 14px; font-size: 18px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-weight: 600; font-size: 13px; }
.field small { color: var(--muted); }
.field textarea { min-height: 80px; resize: vertical; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: #1f2933; color: #fff; padding: 10px 18px; border-radius: 8px; opacity: 0;
  transition: .2s; pointer-events: none; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%); }

.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 4px 20px 24px; }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 12px; gap: 8px; justify-content: space-between; }
  .tabs { order: 3; flex: 0 0 100%; overflow-x: auto; }
  .tab { white-space: nowrap; flex: 1; }
  .grid th, .grid td { padding: 8px; }
  main { padding: 10px; }
  .panel { padding: 12px; }
  .bar-row { grid-template-columns: 100px 1fr 56px; }
}
