:root {
  --bg: #f6f7f9;
  --panel: #fff;
  --line: #e6e8eb;
  --text: #1f2328;
  --muted: #6b7280;
  --blue: #1a73e8;
  --blue-2: #1765cc;
  --green: #137333;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, "Segoe UI", "Microsoft YaHei", Roboto, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, #1a73e8, #3fa9f5);
  color: #fff; font-size: 19px;
  display: flex; align-items: center; justify-content: center;
}
.brand h1 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: .2px; }
.sub { margin: 1px 0 0; font-size: 12px; color: var(--muted); }

.actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 7px 13px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; color: var(--text); font: inherit; font-size: 13px;
  cursor: pointer; text-decoration: none; transition: .15s; white-space: nowrap;
}
.btn:hover { background: #f1f3f5; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--blue-2); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: #f1f3f5; }
.btn:disabled { opacity: .55; cursor: default; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  padding: 16px 22px 0;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.stat .n { font-size: 22px; font-weight: 680; line-height: 1.2; }
.stat .l { font-size: 12px; color: var(--muted); margin-top: 2px; }

.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 22px;
}
.toolbar input[type="search"] {
  flex: 1 1 260px; min-width: 200px;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px;
  font: inherit; font-size: 13px; outline: none; background: #fff;
}
.toolbar input[type="search"]:focus { border-color: var(--blue); }
.toolbar select {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px;
  font: inherit; font-size: 13px; background: #fff; outline: none;
}
.chk { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); cursor: pointer; }
.grow { flex: 1; }
.count { font-size: 12.5px; color: var(--muted); }

main { padding: 0 22px 40px; }

table {
  width: 100%; table-layout: fixed;
  border-collapse: separate; border-spacing: 0;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
thead th {
  position: sticky; top: 0; z-index: 5;
  background: #fafbfc; text-align: left;
  font-size: 12px; font-weight: 600; color: var(--muted);
  padding: 10px 8px; border-bottom: 1px solid var(--line);
  cursor: pointer; user-select: none; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
thead th:hover { color: var(--text); }
thead th.num { text-align: right; }
thead th.op { cursor: default; }

tbody td {
  padding: 9px 10px; border-bottom: 1px solid #f0f1f3;
  font-size: 13px; vertical-align: top;
  overflow-wrap: anywhere; word-break: break-word;
}

.web-link {
  display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.addr {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}
.timecell { font-size: 11.5px; color: var(--muted); }
.timecell .d, .timecell .t {
  display: inline-block; white-space: nowrap;
}
.timecell .t { margin-left: 4px; }
td select.status { width: 100%; max-width: 108px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfc; }

.name { font-weight: 600; }
.cat { color: var(--muted); font-size: 12px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
a.link { color: var(--blue); text-decoration: none; }
a.link:hover { text-decoration: underline; }
.dim { color: #b0b4ba; }
.num-cell { text-align: right; white-space: nowrap; }
.star { color: #e37400; font-weight: 600; }

td input.note {
  width: 100%; min-width: 110px; padding: 5px 8px;
  border: 1px solid transparent; border-radius: 7px;
  font: inherit; font-size: 12.5px; background: transparent; outline: none;
}
td input.note:hover { border-color: var(--line); background: #fff; }
td input.note:focus { border-color: var(--blue); background: #fff; }

select.status {
  padding: 4px 6px; border-radius: 7px; border: 1px solid var(--line);
  font: inherit; font-size: 12px; background: #fff; outline: none; cursor: pointer;
}
select.status[data-s="contacted"] { border-color: #c6dafc; background: #e8f0fe; color: #174ea6; }
select.status[data-s="replied"]   { border-color: #ceead6; background: #e6f4ea; color: var(--green); }
select.status[data-s="quoted"]    { border-color: #fde293; background: #fef7e0; color: #9a6b00; }
select.status[data-s="won"]       { border-color: #b7e1c1; background: #ceead6; color: var(--green); font-weight: 600; }
select.status[data-s="dead"]      { border-color: #e8eaed; background: #f1f3f4; color: var(--muted); }

.icon-btn {
  border: 0; background: transparent; color: #9aa0a6; cursor: pointer;
  padding: 4px 6px; border-radius: 6px; font-size: 13px;
}
.icon-btn:hover { background: #fdeaea; color: #d93025; }

.empty {
  padding: 60px 20px; text-align: center; color: var(--muted); font-size: 13px;
}

.modal {
  position: fixed; inset: 0; background: rgba(15,18,22,.42);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal[hidden] { display: none; }
.modal-box {
  width: min(440px, calc(100vw - 32px));
  background: #fff; border-radius: 14px; padding: 20px;
  box-shadow: 0 18px 50px rgba(0,0,0,.22);
}
.modal-box h2 { margin: 0 0 6px; font-size: 15px; }
.hint { margin: 0 0 14px; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.modal-box label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
.modal-box input {
  width: 100%; margin-top: 5px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 13px; outline: none;
}
.modal-box input:focus { border-color: var(--blue); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(8px);
  background: #202124; color: #fff; padding: 9px 16px; border-radius: 9px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: .2s; z-index: 60;
}
.toast.on { opacity: .96; transform: translateX(-50%) translateY(0); }

.badge {
  display: inline-block; padding: 1px 7px; border-radius: 20px;
  background: #eef1f5; color: var(--muted); font-size: 11px; margin-left: 6px;
}

/* ---- 体检 + AI ---- */

.btn.small { padding: 6px 10px; font-size: 12px; }

.sitechk {
  margin-top: 3px; font-size: 11px; line-height: 1.3;
  color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sitechk.ok { color: #137333; }
.sitechk.warn { color: #9a6b00; }
.sitechk.bad { color: #c5221f; }

.ops { display: flex; gap: 0; align-items: center; flex-wrap: nowrap; }
.ops .icon-btn { padding: 3px 3px; font-size: 12px; line-height: 1; }
.ops .icon-btn.spin { opacity: .45; pointer-events: none; }
tbody td:last-child { padding-left: 4px; padding-right: 6px; }

.modal-box.wide { width: min(600px, calc(100vw - 32px)); }

.ai-body { font-size: 13px; line-height: 1.65; max-height: 56vh; overflow: auto; }
.ai-score {
  display: inline-flex; align-items: baseline; gap: 4px;
  font-size: 26px; font-weight: 700; color: var(--blue); margin-right: 10px;
}
.ai-score small { font-size: 12px; font-weight: 500; color: var(--muted); }
.ai-kv { margin: 8px 0; }
.ai-kv div { margin: 3px 0; }
.ai-kv b { color: var(--muted); font-weight: 600; margin-right: 6px; }
.ai-summary {
  background: #f6f8fb; border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 12px; margin: 10px 0; white-space: pre-wrap;
}
.ai-pitch {
  background: #e8f0fe; border-radius: 9px; padding: 9px 12px;
  color: #174ea6; margin-top: 10px;
}
.ai-raw {
  margin-top: 10px; padding: 9px 11px; background: #fafbfc; border: 1px dashed var(--line);
  border-radius: 8px; font-size: 12px; color: var(--muted); white-space: pre-wrap; word-break: break-word;
}
.ai-tag {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11.5px; background: #eef1f5; color: var(--muted); margin-right: 6px;
}
.ai-tag.strong { background: #e6f4ea; color: var(--green); }
.ai-tag.weak { background: #fef7e0; color: #9a6b00; }
