/* 若海AI · 轻量CRM — 样式（浅色主题） */
:root {
  --primary: #c0392b;          /* 若海红 */
  --primary-hover: #a93226;
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e5e8ec;
  --text: #26303a;
  --text-sub: #7a8694;
  --sidebar: #22292f;
  --sidebar-text: #cfd6de;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(30,40,50,.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
.hidden { display: none !important; }
a { color: var(--primary); text-decoration: none; }

/* ---------- 登录 ---------- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #2b3440 0%, #4a3f3a 60%, #6e3b32 100%);
}
.login-card {
  width: 380px; background: var(--card); border-radius: 14px; padding: 36px 34px;
  box-shadow: 0 18px 50px rgba(0,0,0,.28);
}
.login-logo { display: flex; align-items: center; gap: 14px; margin-bottom: 30px; }
.logo-mark {
  width: 52px; height: 52px; border-radius: 12px; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700;
  letter-spacing: 2px; flex: none;
}
.logo-mark.small { width: 34px; height: 34px; font-size: 13px; border-radius: 8px; }
.logo-title { font-size: 17px; font-weight: 700; }
.logo-sub { font-size: 12px; color: var(--text-sub); margin-top: 2px; letter-spacing: .5px; }
.login-card label { display: block; font-size: 13px; color: var(--text-sub); margin: 14px 0 6px; }
.login-card input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; outline: none; background: #fafbfc;
}
.login-card input:focus { border-color: var(--primary); background: #fff; }
.login-error { color: #d93025; font-size: 13px; min-height: 18px; margin-top: 10px; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 200px; background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; flex: none; position: sticky; top: 0; height: 100vh;
}
.side-brand {
  display: flex; align-items: center; gap: 10px; padding: 18px 16px; color: #fff;
  font-weight: 600; font-size: 15px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar nav { flex: 1; padding: 12px 10px; }
.nav-item {
  display: block; padding: 11px 14px; border-radius: 8px; color: var(--sidebar-text);
  margin-bottom: 4px; font-size: 14px; transition: background .15s;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.side-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; line-height: 1.8; }
.main { flex: 1; padding: 24px 28px; min-width: 0; }

/* ---------- 通用组件 ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 20px; font-weight: 700; }
.page-sub { font-size: 13px; color: var(--text-sub); margin-top: 4px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border: none;
  border-radius: 8px; font-size: 14px; cursor: pointer; background: #eef0f3; color: var(--text);
  transition: background .15s;
}
.btn:hover { background: #e2e6ea; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: #fff; color: #d93025; border: 1px solid #f2c4c0; }
.btn-danger:hover { background: #fdf0ef; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; border-radius: 6px; }
.btn-block { width: 100%; justify-content: center; }

input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13.5px;
  outline: none; background: #fff; color: var(--text); font-family: inherit;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { resize: vertical; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12.5px; color: var(--text-sub); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid #f0f2f4; font-size: 13.5px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; cursor: pointer; }
td.actions, th.actions { text-align: right; white-space: nowrap; }
td.actions .btn { margin-left: 6px; }

.tag { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag-a { background: #fdecea; color: #c0392b; }
.tag-b { background: #fff4e0; color: #b9770e; }
.tag-c { background: #eef2f7; color: #64748b; }
.tag-won { background: #e8f6ee; color: #1e7e44; }
.tag-lost { background: #f4f4f5; color: #8a8f98; }
.tag-status { background: #eaf1fd; color: #2a60c9; }
.tag-intent { background: #f3ecfb; color: #7d3ba8; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.toolbar input, .toolbar select { min-width: 130px; }
.toolbar input[type=text] { flex: 1; min-width: 200px; }

.empty { text-align: center; color: var(--text-sub); padding: 40px 0; font-size: 13px; }

/* ---------- 工作台 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.stat-label { font-size: 12.5px; color: var(--text-sub); }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.stat-value.money { color: var(--primary); }
.stat-extra { font-size: 12px; color: var(--text-sub); margin-top: 4px; }
.stat-card.clickable { cursor: pointer; transition: transform .12s, box-shadow .12s; }
.stat-card.clickable:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(30,40,50,.14); }
.dist-row.clickable { cursor: pointer; border-radius: 6px; padding: 3px 4px; margin-left: -4px; margin-right: -4px; }
.dist-row.clickable:hover { background: #f4f6f8; }
.dist-tip { font-weight: 400; font-size: 12px; color: var(--text-sub); }
.source-link { color: var(--primary); cursor: pointer; margin-right: 2px; }
.source-link:hover { text-decoration: underline; }

.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .dash-grid { grid-template-columns: 1fr; } }

.dist-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.dist-label { width: 72px; font-size: 13px; flex: none; color: var(--text); }
.dist-bar-wrap { flex: 1; background: #f0f2f4; border-radius: 6px; height: 18px; overflow: hidden; }
.dist-bar { height: 100%; border-radius: 6px; background: var(--primary); min-width: 2px; }
.dist-bar.green { background: #1e7e44; }
.dist-bar.blue { background: #2a60c9; }
.dist-bar.purple { background: #7d3ba8; }
.dist-bar.orange { background: #d97b29; }
.dist-bar.gray { background: #98a2ad; }
.dist-num { width: 90px; font-size: 12px; color: var(--text-sub); text-align: right; flex: none; }

.todo-item { display: flex; gap: 10px; padding: 10px 4px; border-bottom: 1px solid #f0f2f4; font-size: 13px; align-items: flex-start; }
.todo-item:last-child { border-bottom: none; }
.todo-date { flex: none; width: 88px; font-weight: 600; }
.todo-date.overdue { color: #d93025; }
.todo-body { flex: 1; min-width: 0; }
.todo-meta { color: var(--text-sub); font-size: 12px; margin-top: 3px; }

.followup-item { padding: 10px 4px; border-bottom: 1px solid #f0f2f4; font-size: 13px; }
.followup-item:last-child { border-bottom: none; }
.followup-meta { color: var(--text-sub); font-size: 12px; margin-top: 3px; }

/* ---------- 客户详情 ---------- */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 12px; }
.detail-name { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.detail-info { display: flex; flex-wrap: wrap; gap: 6px 28px; margin-top: 12px; font-size: 13px; }
.info-item { min-width: 160px; }
.info-label { color: var(--text-sub); font-size: 12px; }
.info-value { margin-top: 2px; }

.timeline { position: relative; padding-left: 18px; }
.timeline::before { content: ''; position: absolute; left: 4px; top: 6px; bottom: 6px; width: 2px; background: #e8ebee; }
.tl-item { position: relative; padding: 0 0 18px 12px; }
.tl-dot { position: absolute; left: -18px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--primary); }
.tl-head { display: flex; gap: 8px; align-items: center; font-size: 13px; flex-wrap: wrap; }
.tl-type { background: #eef2f7; color: #52606f; border-radius: 4px; padding: 1px 7px; font-size: 12px; }
.tl-time { color: var(--text-sub); font-size: 12px; }
.tl-content { margin-top: 5px; font-size: 13.5px; line-height: 1.6; }
.tl-next { margin-top: 4px; font-size: 12px; color: #b9770e; }
.tl-del { color: #c5cad1; cursor: pointer; font-size: 12px; margin-left: auto; }
.tl-del:hover { color: #d93025; }

/* ---------- 商机看板 ---------- */
.view-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.view-toggle button { border: none; background: #fff; padding: 7px 16px; font-size: 13px; cursor: pointer; }
.view-toggle button.active { background: var(--primary); color: #fff; }

.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.kanban-col { min-width: 235px; width: 235px; flex: none; background: #eef0f3; border-radius: 10px; padding: 10px; }
.kanban-col.drag-over { outline: 2px dashed var(--primary); outline-offset: -2px; }
.kanban-col-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 10px; font-weight: 600; font-size: 13.5px; }
.kanban-col-count { background: #fff; border-radius: 10px; padding: 1px 8px; font-size: 12px; color: var(--text-sub); }
.kanban-card { background: #fff; border-radius: 8px; padding: 12px; margin-bottom: 8px; box-shadow: var(--shadow); cursor: grab; border-left: 3px solid var(--primary); }
.kanban-card.dragging { opacity: .4; }
.kanban-card h4 { font-size: 13.5px; font-weight: 600; line-height: 1.4; }
.kanban-cust { font-size: 12px; color: var(--text-sub); margin-top: 4px; }
.kanban-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.kanban-amount { font-weight: 700; color: var(--primary); font-size: 14px; }
.kanban-date { font-size: 11.5px; color: var(--text-sub); }
.kanban-foot { font-size: 11.5px; color: var(--text-sub); margin-top: 6px; }
.col-won .kanban-card { border-left-color: #1e7e44; }
.col-lost .kanban-card { border-left-color: #98a2ad; }

/* ---------- 系统配置 / 权限 ---------- */
.dict-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 4px 24px; }
.dict-input { width: 100%; min-height: 92px; font-size: 13px; line-height: 1.7; }
.dict-tip { font-size: 11.5px; color: var(--text-sub); margin-top: 4px; line-height: 1.5; }
.perm-tip { font-size: 12px; color: var(--text-sub); background: #f6f7f9; border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; line-height: 1.6; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20,26,32,.45); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal { background: #fff; border-radius: 12px; width: 520px; max-width: 100%; max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 15px; position: sticky; top: 0; background: #fff; }
.modal-close { border: none; background: none; font-size: 15px; cursor: pointer; color: var(--text-sub); }
.modal-body { padding: 20px; }
.form-row { display: flex; gap: 14px; }
.form-row .form-group { flex: 1; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12.5px; color: var(--text-sub); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; }
.form-group textarea { min-height: 70px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.form-err { color: #d93025; font-size: 13px; min-height: 18px; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 200;
  background: #22292f; color: #fff; padding: 10px 22px; border-radius: 8px; font-size: 13.5px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.toast.err { background: #c0392b; }

@media (max-width: 760px) {
  .sidebar { width: 64px; }
  .side-brand span, .nav-item { font-size: 0; }
  .side-brand { justify-content: center; }
  .nav-item { text-align: center; font-size: 18px; padding: 12px 0; }
  .side-footer { display: none; }
  .main { padding: 16px 12px; }
}
