:root {
  --bg: #F6F7F9;
  --surface: #FFFFFF;
  --surface-2: #FBFCFD;
  --border: #E4E7EC;
  --border-2: #D0D5DD;
  --text: #16191F;
  --text-2: #5A6270;
  --text-3: #8B929D;
  --accent: #185FA5;
  --accent-soft: #E6F1FB;
  --up: #C0392B;
  --up-soft: #FCEBEB;
  --down: #0F6E56;
  --down-soft: #E1F5EE;
  --warn: #BA7517;
  --warn-soft: #FAEEDA;
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1440px; margin: 0 auto; padding: 0 24px 64px; }

/* ---------- header ---------- */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}
.hd {
  max-width: 1440px; margin: 0 auto; padding: 14px 24px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-mark {
  width: 30px; height: 30px; border-radius: 7px;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 500;
}
.logo h1 { font-size: 16px; font-weight: 500; letter-spacing: .2px; }
.logo span { font-size: 12px; color: var(--text-3); display: block; }
.hd-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.live {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 5px 11px; border-radius: 20px;
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: #2FA36B; }

/* 本机采集器：连上才亮，没连上就是灰的，别让人误以为在自动跑 */
#bridge .dot { background: var(--text-3); }
#bridge.on .dot { background: #2FA36B; box-shadow: 0 0 0 3px rgba(47, 163, 107, .16); }
#bridge.on { color: var(--text); border-color: rgba(47, 163, 107, .4); }

/* 没开采集器的机器（同事的电脑）：数据照样来自云端，用蓝色区分，别显示成"故障" */
#bridge.sync .dot { background: #185FA5; box-shadow: 0 0 0 3px rgba(24, 95, 165, .16); }
#bridge.sync { color: var(--text); border-color: rgba(24, 95, 165, .35); }

button { font-family: inherit; cursor: pointer; border: none; }
.btn {
  padding: 7px 14px; border-radius: 8px; font-size: 13px;
  border: 1px solid var(--border-2); background: var(--surface); color: var(--text);
  transition: background .12s;
}
.btn:hover { background: var(--surface-2); }
.btn-primary {
  background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 500;
}
.btn-primary:hover { background: #14508E; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ---------- kpi ---------- */
.kpis {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 22px 0 18px;
}
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 15px 17px;
}
.kpi .lab { font-size: 12px; color: var(--text-3); }
.kpi .val { font-size: 25px; font-weight: 500; margin-top: 5px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--text-2); margin-top: 3px; }

/* ---------- filters ---------- */
.filters {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px;
}
.lane-tabs { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 13px; }
.tab {
  padding: 5px 13px; border-radius: 20px; font-size: 13px;
  border: 1px solid var(--border-2); background: var(--surface); color: var(--text-2);
}
.tab.on { background: var(--accent-soft); border-color: #85B7EB; color: var(--accent); font-weight: 500; }
.frow { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.fld { display: flex; flex-direction: column; gap: 4px; }
.fld label { font-size: 11px; color: var(--text-3); }
select, input[type=text] {
  font-family: inherit; font-size: 13px; color: var(--text);
  border: 1px solid var(--border-2); border-radius: 7px;
  padding: 6px 9px; background: var(--surface); outline: none;
  min-width: 108px;
}
select:focus, input:focus { border-color: var(--accent); }
.fspacer { flex: 1; }
.chk { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); cursor: pointer; }

/* ---------- table ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.tbl-head {
  padding: 11px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  font-size: 13px; color: var(--text-2);
}
.tbl-head .cnt { font-weight: 500; color: var(--text); }
table { width: 100%; border-collapse: collapse; }
th {
  font-size: 12px; font-weight: 500; color: var(--text-3);
  text-align: left; padding: 9px 12px; background: var(--surface-2);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 11px 12px; border-bottom: 1px solid #F0F2F5; font-size: 13px; vertical-align: middle; }
tbody tr:hover { background: #FAFBFC; }
tbody tr.expired { opacity: .55; }
.num { font-variant-numeric: tabular-nums; }

.lane-tag {
  display: inline-block; padding: 2px 8px; border-radius: 5px;
  font-size: 12px; background: var(--accent-soft); color: var(--accent);
}
.route { font-weight: 500; white-space: nowrap; }
.route .arrow { color: var(--text-3); margin: 0 5px; font-weight: 400; }
.price-cell { display: flex; align-items: baseline; gap: 7px; }
.price { font-size: 16px; font-weight: 500; font-variant-numeric: tabular-nums; }
.cur { font-size: 11px; color: var(--text-3); }
.chg { font-size: 12px; font-variant-numeric: tabular-nums; }
.chg.up { color: var(--up); }
.chg.down { color: var(--down); }
.chg.flat { color: var(--text-3); }
.best {
  display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 4px;
  font-size: 11px; background: var(--down-soft); color: var(--down);
}
.src {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2);
  white-space: nowrap;
}
.src i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.space {
  display: inline-block; padding: 2px 8px; border-radius: 5px; font-size: 12px;
}
.space.ok { background: var(--down-soft); color: var(--down); }
.space.tight { background: var(--warn-soft); color: var(--warn); }
.space.full { background: var(--up-soft); color: var(--up); }
.space.tbd { background: #F1EFE8; color: #5F5E5A; }
.valid { font-size: 12px; white-space: nowrap; }
.valid.soon { color: var(--up); font-weight: 500; }
.valid.gone { color: var(--text-3); text-decoration: line-through; }
.valid .d { color: var(--text-3); }
.term { font-size: 11px; color: var(--text-3); }
.rmk { font-size: 12px; color: var(--text-2); max-width: 210px; }
.empty { padding: 56px 20px; text-align: center; color: var(--text-3); font-size: 13px; }

.conf {
  display: inline-block; width: 34px; height: 4px; border-radius: 2px; background: #E4E7EC;
  position: relative; overflow: hidden; vertical-align: middle;
}
.conf b { position: absolute; left: 0; top: 0; bottom: 0; background: #2FA36B; display: block; }

/* ---------- modal ---------- */
.mask {
  position: absolute; inset: 0; background: rgba(20,24,30,.42);
  display: none; z-index: 90; overflow-y: auto; padding: 40px 20px;
}
.mask.on { display: block; }
.modal {
  max-width: 760px; margin: 0 auto; background: var(--surface);
  border-radius: 14px; overflow: hidden;
}
.modal-hd {
  padding: 15px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
}
.modal-hd h3 { font-size: 15px; font-weight: 500; }
.modal-hd .x { margin-left: auto; font-size: 19px; color: var(--text-3); background: none; line-height: 1; }
.modal-bd { padding: 18px 20px; }
.modal-ft {
  padding: 13px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end; background: var(--surface-2);
}
.hint { font-size: 12px; color: var(--text-3); margin-bottom: 9px; }
textarea {
  width: 100%; min-height: 96px; font-family: inherit; font-size: 13px; line-height: 1.6;
  border: 1px solid var(--border-2); border-radius: 8px; padding: 11px; resize: vertical;
  outline: none; color: var(--text);
}
textarea:focus { border-color: var(--accent); }
.samples { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 9px; }
.samples button {
  font-size: 12px; padding: 4px 10px; border-radius: 6px;
  border: 1px dashed var(--border-2); background: var(--surface-2); color: var(--text-2);
}
.parsed { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 15px; }
.parsed h4 { font-size: 13px; font-weight: 500; margin-bottom: 4px; }
.grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 12px; margin-top: 12px;
}
.gf { display: flex; flex-direction: column; gap: 4px; }
.gf label { font-size: 11px; color: var(--text-3); }
.gf input, .gf select { width: 100%; min-width: 0; }
.warnbox {
  margin-top: 12px; padding: 9px 12px; border-radius: 8px;
  background: var(--warn-soft); color: #854F0B; font-size: 12px;
}
.rawbox {
  margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2);
  border: 1px solid var(--border); font-size: 12px; color: var(--text-2); line-height: 1.6;
}

/* ---------- 批量解析卡片 ---------- */
.pcard {
  border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; overflow: hidden;
}
.pcard.low { border-color: #EF9F27; }
.pc-sum {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 9px 11px; background: var(--surface-2); font-size: 13px;
}
.pcard.low .pc-sum { background: var(--warn-soft); }
.pc-sum .idx {
  width: 20px; height: 20px; border-radius: 4px; background: #E4E7EC;
  color: var(--text-2); font-size: 11px;
  display: flex; align-items: center; justify-content: center; flex: none;
}
.pc-sum .arrow { color: var(--text-3); font-weight: 400; }
.pc-sum .pprice { font-weight: 500; font-variant-numeric: tabular-nums; }
.pc-edit { padding: 11px; border-top: 1px solid var(--border); }
.confb {
  font-size: 11px; padding: 1px 6px; border-radius: 4px;
  background: #E4E7EC; color: var(--text-2);
}
.confb.low { background: #FAEEDA; color: #854F0B; }
.mini {
  font-size: 12px; padding: 2px 9px; border-radius: 5px;
  border: 1px solid var(--border-2); background: var(--surface); color: var(--text-2);
}
.mini:hover { background: var(--surface-2); }
.mini.del { color: var(--up); border-color: #F09595; }

/* ---------- toast ---------- */
.toast {
  position: absolute; left: 50%; bottom: 34px; transform: translateX(-50%);
  background: #16191F; color: #fff; font-size: 13px; padding: 9px 18px; border-radius: 8px;
  z-index: 200; display: none;
}
.toast.on { display: block; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .hide-md { display: none; }
}
@media (max-width: 720px) {
  .wrap { padding: 0 12px 40px; }
  .hd { padding: 12px; }
  .hide-sm { display: none; }
  .grid { grid-template-columns: repeat(2, 1fr); }
}
