:root {
  --bg: #f4f6fa; --card: #fff; --line: #e5e9f0; --txt: #1f2937; --sub: #6b7280;
  --brand: #2563eb; --brand-d: #1d4ed8;
  --new: #94a3b8; --contacted: #38bdf8; --unreachable: #a78bfa; --quoted: #f59e0b;
  --negotiating: #fb923c; --won: #10b981; --lost: #ef4444; --invalid: #6b7280;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif; background: var(--bg); color: var(--txt); font-size: 14px; }
a { color: var(--brand); text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--txt); }
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--brand); }

/* 登录 */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: linear-gradient(135deg, #1e3a8a, #2563eb 60%, #38bdf8); }
.login-card { background: #fff; border-radius: 16px; padding: 40px 36px; width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-logo { font-size: 28px; font-weight: 800; letter-spacing: 1px; }
.login-logo span, .logo span { color: var(--brand); margin-left: 4px; }
.login-sub { color: var(--sub); margin: 6px 0 24px; }
.login-card label { display: block; margin: 14px 0 6px; font-weight: 600; }
.login-card input { width: 100%; }
.btn-block { width: 100%; margin-top: 22px; }
.err { color: var(--lost); margin-top: 10px; min-height: 18px; }

/* 布局 */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 210px; background: #0f172a; color: #cbd5e1; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.logo { font-size: 20px; font-weight: 800; color: #fff; padding: 20px 18px; }
.sidebar nav { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 6px 10px; }
.sidebar nav a { color: #cbd5e1; padding: 10px 12px; border-radius: 8px; }
.sidebar nav a:hover { background: #1e293b; }
.sidebar nav a.active { background: var(--brand); color: #fff; }
.sidebar-foot { padding: 14px 16px; border-top: 1px solid #1e293b; font-size: 13px; }
.sidebar-foot .who { margin-bottom: 8px; color: #fff; font-weight: 600; }
.sidebar-foot em { font-style: normal; font-size: 11px; background: #1e293b; padding: 2px 6px; border-radius: 6px; margin-left: 4px; }
.sidebar-foot a { color: #93c5fd; }
main { flex: 1; padding: 22px 26px; min-width: 0; }
body:not(.is-admin) .admin-only { display: none; }

h1.page-title { font-size: 20px; margin-bottom: 16px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar input[type=search] { width: 240px; }
.btn-primary { background: var(--brand); color: #fff; border: none; border-radius: 8px; padding: 9px 16px; font-weight: 600; }
.btn-primary:hover { background: var(--brand-d); }
.btn-ghost { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-sm { padding: 5px 10px; font-size: 13px; }

/* 卡片 & 仪表盘 */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.kpi .num { font-size: 26px; font-weight: 800; margin-top: 4px; }
.kpi .lbl { color: var(--sub); font-size: 13px; }
.kpi.clickable { cursor: pointer; }
.kpi.clickable:hover { border-color: var(--brand); }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 18px; }
.panel h3 { font-size: 15px; margin-bottom: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }

.stage-bar { display: flex; height: 26px; border-radius: 8px; overflow: hidden; margin-bottom: 10px; }
.stage-bar div { display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; min-width: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; color: var(--sub); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 3px; min-width: 0; }
.bars .b .col { width: 100%; display: flex; flex-direction: column-reverse; border-radius: 4px 4px 0 0; overflow: hidden; }
.bars .b .seg-won { background: var(--won); }
.bars .b .seg-lost { background: #fca5a5; }
.bars .b .seg-other { background: #dbeafe; }
.bars .b .x { font-size: 10px; color: var(--sub); white-space: nowrap; transform: rotate(-45deg); margin-top: 8px; }
.bars .b:hover .col { outline: 2px solid var(--brand); }

table.list { width: 100%; border-collapse: collapse; background: var(--card); }
table.list th { text-align: left; font-size: 12px; color: var(--sub); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr:hover td { background: #f8fafc; }
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: auto; }
.num-cell { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 12px; color: #fff; white-space: nowrap; }
.badge.new { background: var(--new); } .badge.contacted { background: var(--contacted); }
.badge.unreachable { background: var(--unreachable); } .badge.quoted { background: var(--quoted); }
.badge.negotiating { background: var(--negotiating); } .badge.won { background: var(--won); }
.badge.lost { background: var(--lost); } .badge.invalid { background: var(--invalid); }
.tag { display: inline-block; background: #eef2ff; color: #4338ca; border-radius: 6px; padding: 2px 7px; font-size: 12px; }
.muted { color: var(--sub); }
.small { font-size: 12px; }
.danger-text { color: var(--lost); font-weight: 600; }
.ok-text { color: var(--won); font-weight: 600; }

.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 14px; }

/* 看板 */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.kcol { background: #eef1f6; border-radius: 12px; width: 250px; flex-shrink: 0; max-height: calc(100vh - 190px); display: flex; flex-direction: column; }
.kcol-head { padding: 10px 12px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; border-top: 3px solid transparent; border-radius: 12px 12px 0 0; }
.kcol-head .cnt { background: #fff; border-radius: 12px; padding: 1px 9px; font-size: 12px; }
.kcol-body { overflow-y: auto; padding: 0 8px 8px; display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.kcard { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: grab; }
.kcard:hover { border-color: var(--brand); box-shadow: 0 2px 8px rgba(37,99,235,.12); }
.kcard .nm { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.kcard .meta { font-size: 12px; color: var(--sub); display: flex; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.kcol.dragover { outline: 2px dashed var(--brand); }
.kmore { text-align: center; padding: 6px; font-size: 12px; color: var(--brand); cursor: pointer; }

/* 抽屉 */
.drawer-mask { position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 520px; max-width: 95vw; background: #fff; z-index: 50; box-shadow: -8px 0 30px rgba(0,0,0,.15); overflow-y: auto; padding: 22px 24px; }
.drawer h2 { font-size: 18px; margin-bottom: 2px; }
.drawer .close-x { float: right; border: none; background: none; font-size: 20px; color: var(--sub); }
.dl { display: grid; grid-template-columns: 96px 1fr; row-gap: 7px; margin: 14px 0; font-size: 13px; }
.dl dt { color: var(--sub); }
.section-title { font-size: 14px; font-weight: 700; margin: 18px 0 10px; border-top: 1px solid var(--line); padding-top: 14px; }
.timeline { display: flex; flex-direction: column; gap: 10px; }
.titem { border-left: 3px solid var(--line); padding: 2px 0 2px 12px; }
.titem.call { border-color: var(--contacted); } .titem.whatsapp { border-color: var(--won); }
.titem.note { border-color: var(--quoted); } .titem.stage { border-color: var(--unreachable); }
.titem .thead { font-size: 12px; color: var(--sub); display: flex; gap: 8px; flex-wrap: wrap; }
.titem .tbody { margin-top: 3px; white-space: pre-wrap; word-break: break-word; }
.fu-form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.fu-form textarea { grid-column: 1 / -1; min-height: 60px; }
.fu-form .full { grid-column: 1 / -1; }
.edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.edit-grid label { font-size: 12px; color: var(--sub); display: block; margin-bottom: 3px; }
.edit-grid input, .edit-grid select { width: 100%; }

/* 弹窗 */
[hidden] { display: none !important; }
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 60; display: flex; align-items: center; justify-content: center; }
.modal { background: #fff; border-radius: 14px; padding: 24px; width: 440px; max-width: 94vw; max-height: 90vh; overflow-y: auto; }
.modal h3 { margin-bottom: 14px; }
.modal label { display: block; font-size: 13px; color: var(--sub); margin: 10px 0 4px; }
.modal input, .modal select { width: 100%; }
.modal .mrow { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.toast { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 10px 20px; border-radius: 10px; z-index: 99; font-size: 13px; }
.empty { text-align: center; color: var(--sub); padding: 40px 0; }

/* 顶部控件：语言切换 + 提醒铃铛 */
.topctl { position: fixed; top: 14px; right: 20px; z-index: 55; display: flex; gap: 8px; align-items: center; }
.ctl-btn { position: relative; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px; font-size: 14px; font-weight: 700; box-shadow: 0 2px 8px rgba(15,23,42,.08); }
.ctl-btn:hover { border-color: var(--brand); color: var(--brand); }
.bell-badge { position: absolute; top: -7px; right: -7px; background: var(--lost); color: #fff; font-size: 11px; font-weight: 700; border-radius: 12px; padding: 1px 6px; min-width: 18px; }
.bell-panel { position: absolute; top: 44px; right: 0; width: 340px; max-height: 70vh; overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 40px rgba(15,23,42,.18); padding: 12px 14px; }
.r-title { font-weight: 800; font-size: 14px; margin-bottom: 8px; }
.r-sec { margin-bottom: 10px; }
.r-head { font-size: 13px; font-weight: 700; color: var(--sub); display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 4px; margin-bottom: 4px; }
.r-cnt { background: #eef2ff; color: #4338ca; border-radius: 10px; padding: 0 8px; font-size: 12px; }
.r-item { padding: 6px 4px; border-radius: 8px; cursor: pointer; }
.r-item:hover { background: #f1f5f9; }
.r-notif { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--sub); border-top: 1px solid var(--line); padding-top: 10px; cursor: pointer; }

/* WhatsApp 按钮 */
.wa-btn { display: inline-block; background: #25d366; color: #fff !important; border-radius: 8px; padding: 7px 14px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.wa-btn:hover { background: #1ebe5b; }
.wa-btn.wa-sm { padding: 2px 8px; font-size: 11px; border-radius: 6px; }
.wa-btn.disabled { background: #e5e9f0; color: var(--sub) !important; }
main { padding-right: 120px; }
@media (max-width: 900px) { main { padding-right: 26px; padding-top: 56px; } }