/* 配色沿用 PH 总控舱：深蓝 #1e3a5f 作主色，橙 #e07b2e 作强调 */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --border: #e2e6ec;
  --text: #16202c;
  --muted: #6b7789;
  --accent: #1e3a5f;
  --accent-soft: #e6ecf4;
  --accent-2: #e07b2e;
  --accent-2-soft: #fbeedf;
  --side-bg: #1e3a5f;
  --side-text: #c9d6e6;
  --side-hover: #2a4d78;
  --side-active: #e07b2e;
  --danger: #d93b3b;
  --ok: #1c7c3c;
  --warn: #b05c0e;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(30, 58, 95, .06), 0 4px 12px rgba(30, 58, 95, .05);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1319;
    --surface: #171c24;
    --surface-2: #1e2530;
    --border: #2b333f;
    --text: #e6eaf0;
    --muted: #94a1b3;
    --accent: #7ba6e0;
    --accent-soft: #1b2a3f;
    --accent-2: #e8a35c;
    --accent-2-soft: #35291a;
    --side-bg: #141b25;
    --side-text: #a8b6c8;
    --side-hover: #212c3a;
    --side-active: #e8a35c;
    --danger: #f06a6a;
    --ok: #4bc17f;
    --warn: #e0a233;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- 骨架：左栏 + 内容区 ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 216px; flex: 0 0 216px;
  background: var(--side-bg); color: var(--side-text);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand {
  padding: 18px 18px 14px; font-size: 17px; font-weight: 700;
  letter-spacing: .06em; display: flex; gap: 6px; align-items: baseline;
}
.brand .logo { color: #fff; }
.brand .logo-accent { color: var(--side-active); }

.side-nav { flex: 1; padding: 4px 10px 16px; }
.side-nav .sec {
  font-size: 11px; letter-spacing: .12em; color: #7c8ea5;
  padding: 16px 8px 6px; text-transform: uppercase;
}
.side-nav a, .side-nav button {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; margin-bottom: 1px; border: 0; border-radius: 8px;
  background: none; color: var(--side-text); font: inherit; text-align: left;
  cursor: pointer; text-decoration: none; line-height: 1.35;
}
.side-nav a:hover, .side-nav button:hover { background: var(--side-hover); color: #fff; text-decoration: none; }
.side-nav button.active { background: var(--side-hover); color: #fff; font-weight: 600; }
.side-nav button.active .ico { color: var(--side-active); }
.side-nav .ico { width: 15px; text-align: center; opacity: .85; flex: 0 0 15px; }
.side-nav .lbl { flex: 1; }
.side-nav .pill {
  font-size: 10.5px; padding: 1px 6px; border-radius: 999px;
  background: rgba(255, 255, 255, .13); color: #dfe8f3; white-space: nowrap;
}
.side-nav .pill.live { background: var(--side-active); color: #2a1a08; font-weight: 600; }
.side-nav .pill.soon { background: rgba(255, 255, 255, .07); color: #8fa0b5; }
.side-nav a .ico.out { font-size: 10px; opacity: .5; }
.side-foot { padding: 12px; border-top: 1px solid rgba(255, 255, 255, .08); }
.side-foot .btn {
  width: 100%; background: transparent; color: var(--side-text);
  border-color: rgba(255, 255, 255, .16);
}
.side-foot .btn:hover { background: var(--side-hover); color: #fff; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.crumb { font-weight: 600; white-space: nowrap; }
.icon-btn {
  display: none; background: none; border: 0; font-size: 19px;
  cursor: pointer; padding: 2px 6px; border-radius: 6px; color: var(--text);
}
.icon-btn:hover { background: var(--surface-2); }

.topbar .spacer { flex: 1; }
.search {
  width: 220px; padding: 7px 11px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg);
}
.search:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.backdrop { position: fixed; inset: 0; background: rgba(9, 12, 16, .4); z-index: 35; }

main { padding: 20px; max-width: 1500px; margin: 0 auto; width: 100%; }
.page-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.page-head h1 { font-size: 19px; margin: 0; }
.page-head .spacer { flex: 1; }

/* ---------- 按钮 ---------- */
.btn {
  padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: var(--border); }
.btn.sm { padding: 4px 9px; font-size: 13px; }

/* ---------- 卡片 / 统计 ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.stat .k { color: var(--muted); font-size: 12.5px; }
.stat .v { font-size: 26px; font-weight: 650; margin-top: 4px; letter-spacing: -.02em; }
.stat.alert .v { color: var(--danger); }
.stat.good .v { color: var(--ok); }

.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-top: 16px;
}
.panel h2 { font-size: 14px; margin: 0 0 12px; color: var(--muted); font-weight: 600; }

.bar-row { display: grid; grid-template-columns: 110px 1fr 46px; align-items: center; gap: 10px; margin-bottom: 7px; }
.bar-row .label { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--surface-2); border-radius: 5px; height: 9px; overflow: hidden; }
.bar-fill { background: var(--accent); height: 100%; border-radius: 5px; }
.bar-row .num { text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }

/* ---------- 看板 ---------- */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.col {
  flex: 0 0 258px; background: var(--surface-2); border-radius: var(--radius);
  padding: 10px; min-height: 140px; border: 1px solid transparent;
}
.col.drop { border-color: var(--accent); background: var(--accent-soft); }
.col h3 { font-size: 13px; margin: 2px 4px 10px; display: flex; justify-content: space-between; }
.col h3 .count { color: var(--muted); font-weight: 500; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 11px; margin-bottom: 8px; cursor: grab; box-shadow: var(--shadow);
}
.card:hover { border-color: var(--accent); }
.card.dragging { opacity: .45; }
.card .name { font-weight: 600; margin-bottom: 3px; }
.card .meta { color: var(--muted); font-size: 12.5px; display: flex; gap: 8px; flex-wrap: wrap; }
.card .due { font-size: 12.5px; margin-top: 6px; color: var(--warn); }
.card .due.late { color: var(--danger); font-weight: 600; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; min-width: 860px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; background: var(--surface-2); position: sticky; top: 0; }
tbody tr:hover { background: var(--surface-2); cursor: pointer; }
tbody tr:last-child td { border-bottom: 0; }
td.name { font-weight: 600; }

/* ---------- 标签 ---------- */
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.tag.s-线索 { background: #e9ecf1; color: #5b6472; }
.tag.s-已触达 { background: #e2ecfd; color: #2c5fc0; }
.tag.s-有回复 { background: #d9f2ee; color: #14776b; }
.tag.s-报价中 { background: #fdf0d9; color: #96690b; }
.tag.s-样品中 { background: #ece2fb; color: #6a42b8; }
.tag.s-成交 { background: #dcf3e4; color: #1a7a45; }
.tag.s-沉睡 { background: #ecedee; color: #8a8f96; }
.tag.r-A { background: #dcf3e4; color: #1a7a45; font-weight: 600; }
.tag.r-B { background: #fdf0d9; color: #96690b; }
.tag.r-C { background: #ecedee; color: #8a8f96; }

@media (prefers-color-scheme: dark) {
  .tag.s-线索 { background: #262c34; color: #a2acba; }
  .tag.s-已触达 { background: #1d2c47; color: #7aa5f5; }
  .tag.s-有回复 { background: #13332f; color: #52c2b1; }
  .tag.s-报价中 { background: #3a2d12; color: #e0a233; }
  .tag.s-样品中 { background: #2a2140; color: #ab8ceb; }
  .tag.s-成交 { background: #14331f; color: #4bc17f; }
  .tag.s-沉睡 { background: #23262a; color: #868d97; }
  .tag.r-A { background: #14331f; color: #4bc17f; }
  .tag.r-B { background: #3a2d12; color: #e0a233; }
  .tag.r-C { background: #23262a; color: #868d97; }
}

/* ---------- 抽屉 ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(9, 12, 16, .42); z-index: 50;
  display: flex; justify-content: flex-end;
}
.drawer {
  width: min(660px, 100%); background: var(--surface); height: 100%;
  overflow-y: auto; padding: 20px 22px; border-left: 1px solid var(--border);
}
.drawer h2 { margin: 0 0 4px; font-size: 18px; }
.drawer .sub { color: var(--muted); margin-bottom: 14px; }
.drawer section { margin-top: 22px; }
.drawer section > h3 {
  font-size: 13px; color: var(--muted); margin: 0 0 10px; text-transform: none;
  display: flex; align-items: center; gap: 8px;
}
.drawer section > h3 .spacer { flex: 1; }

.kv { display: grid; grid-template-columns: 92px 1fr; gap: 6px 12px; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; word-break: break-word; }

.timeline { border-left: 2px solid var(--border); padding-left: 14px; margin-left: 4px; }
.tl-item { margin-bottom: 14px; position: relative; }
.tl-item::before {
  content: ""; position: absolute; left: -20px; top: 6px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
}
.tl-item.in::before { background: var(--ok); }
.tl-head { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.tl-body { white-space: pre-wrap; margin-top: 2px; }

.contact-row {
  display: flex; gap: 10px; align-items: baseline; padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.contact-row:last-child { border-bottom: 0; }
.contact-row .who { font-weight: 600; }
.contact-row .detail { color: var(--muted); font-size: 13px; }

/* ---------- 表单 ---------- */
.form { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.form .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12.5px; color: var(--muted); }
.field input, .field select, .field textarea {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--accent-soft); border-color: var(--accent);
}
.field textarea { resize: vertical; min-height: 66px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters select, .filters input {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
}

.empty { color: var(--muted); padding: 28px; text-align: center; }
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 9px 18px; border-radius: 999px;
  z-index: 60; box-shadow: var(--shadow); font-size: 13px;
}
.toast.err { background: var(--danger); color: #fff; }

/* ---------- 指挥台 ---------- */
.hero { margin-bottom: 18px; }
.hero h1 { font-size: 21px; margin: 0 0 4px; color: var(--accent); }
.hero .sub { color: var(--muted); font-size: 13px; }

.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 14px; }
.chip {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--shadow);
}
.chip .cn { font-size: 23px; font-weight: 700; letter-spacing: -.02em; }
.chip .ct { font-size: 12px; color: var(--muted); margin-top: 2px; }
.chip.warn .cn { color: var(--accent-2); }
.chip.bad .cn { color: var(--danger); }
.chip.ok .cn { color: var(--ok); }

details.grp {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; margin: 10px 0; box-shadow: var(--shadow);
}
details.grp > summary {
  cursor: pointer; padding: 13px 16px; font-size: 15px; font-weight: 700;
  color: var(--accent); list-style: none; display: flex; align-items: baseline;
  gap: 8px; flex-wrap: wrap;
}
details.grp > summary::-webkit-details-marker { display: none; }
details.grp > summary::before { content: "▸"; font-size: 12px; color: var(--muted); }
details.grp[open] > summary::before { content: "▾"; }
details.grp > summary .n { color: var(--accent-2); }
details.grp > summary .hint { font-weight: 400; font-size: 12px; color: var(--muted); }
.grp-body { padding: 0 14px 14px; display: grid; gap: 10px; }
/* grid 项默认 min-width:auto，决策卡里的长邮箱和 URL 会把卡片撑破视口 */
.grp-body > *, .cockpit-grid > * { min-width: 0; }

.dcard {
  background: var(--bg); border: 1px solid var(--border);
  border-left: 3px solid var(--accent-2); border-radius: 9px; padding: 11px 13px;
  overflow-wrap: anywhere;
}
.dcard .who { font-weight: 700; font-size: 13px; }
.dcard .src { font-size: 10.5px; color: var(--muted); margin-left: 6px; }
.dcard .what { font-size: 13px; margin-top: 5px; }
.dcard .todo { font-size: 12.5px; margin-top: 7px; }
.dcard .todo b { color: var(--warn); }
.dcard .unlock { font-size: 11.5px; margin-top: 4px; color: var(--ok); }

.cockpit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.cockpit {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 13px 15px; box-shadow: var(--shadow); display: block; color: inherit;
}
.cockpit:hover { border-color: var(--accent-2); text-decoration: none; }
.cockpit .cn { font-weight: 650; display: flex; align-items: center; gap: 7px; }
.cockpit .cd { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.cockpit .cnote { font-size: 11.5px; color: var(--muted); margin-top: 6px; opacity: .85; }
.cockpit .cd, .cockpit .cnote { overflow-wrap: anywhere; }
.cockpit.off { opacity: .6; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 32px; width: min(360px, 100%); box-shadow: var(--shadow); text-align: center;
}
.login-card h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: .04em; }
.login-card p { color: var(--muted); margin: 0 0 20px; font-size: 13px; }
.login-card input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 9px; background: var(--bg); margin-bottom: 12px; text-align: center;
}
.login-card .btn { width: 100%; }
.login-err { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 10px; }

@media (max-width: 860px) {
  .form { grid-template-columns: 1fr; }
  main { padding: 14px; }

  /* 窄屏左栏收成抽屉，由顶栏的 ☰ 拉出 */
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 40;
    transform: translateX(-100%); transition: transform .18s ease;
    box-shadow: 0 0 24px rgba(0, 0, 0, .3);
  }
  .sidebar.open { transform: none; }
  .icon-btn { display: block; }

  .topbar { padding: 10px 14px; flex-wrap: wrap; gap: 8px; }
  .topbar .spacer { display: none; }
  .search { flex: 1 1 110px; width: auto; min-width: 0; order: 10; }
  .btn { padding: 7px 10px; }

  .drawer { padding: 16px; }
  .kv { grid-template-columns: 74px 1fr; }
  .contact-row { flex-wrap: wrap; }
}
