:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --bg: #f4f6fa;
  --card: #ffffff;
  --border: #e5e9f0;
  --text: #1f2937;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #f59e0b;
  --star: #f59e0b;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .14);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  padding: 20px;
}
.login-card {
  width: 380px; background: #fff; border-radius: 16px; padding: 36px 34px;
  box-shadow: var(--shadow-lg);
}
.login-logo { font-size: 22px; font-weight: 700; text-align: center; }
.login-sub { text-align: center; color: var(--text-3); font-size: 13px; margin: 6px 0 24px; }
.login-card label { display: block; font-size: 13px; color: var(--text-2); margin: 14px 0 6px; }
.login-card input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; outline: none; transition: border .15s;
}
.login-card input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.login-err { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 18px; text-align: center; }
.login-hint { text-align: center; color: var(--text-3); font-size: 12px; margin-top: 10px; }

/* ---------- 布局 ---------- */
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 220px; background: #fff; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.side-logo { padding: 20px 20px 16px; font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.side-nav { flex: 1; padding: 6px 10px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
  color: var(--text-2); cursor: pointer; margin-bottom: 2px; font-size: 14px; user-select: none;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-item .ico { width: 18px; text-align: center; }
.side-foot { padding: 14px; border-top: 1px solid var(--border); }
.side-user { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px;
}
.side-name { font-weight: 600; font-size: 14px; }
.side-role { font-size: 12px; color: var(--text-3); }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  height: 60px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px; flex-shrink: 0;
}
.page-title { font-size: 18px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-time { color: var(--text-2); font-size: 13px; }
.content { flex: 1; overflow-y: auto; padding: 24px; }

/* ---------- 通用组件 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid transparent; cursor: pointer;
  font-size: 14px; font-weight: 500; transition: all .15s; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: #fff; color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); border-color: #d1d5db; }
.btn-danger { background: #fff; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

/* 统计卡片 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.stat-label { font-size: 13px; color: var(--text-2); }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.stat-card .stat-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.stat-accent { color: var(--primary); }

/* 表格 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: #fafbfc; color: var(--text-2); font-weight: 600; font-size: 13px; white-space: nowrap; }
tbody tr:hover { background: #fafbff; }
tr.selected { background: var(--primary-soft); }
.td-actions { white-space: nowrap; }
.td-actions .btn { margin-right: 4px; }

/* 筛选栏 */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.filter-bar input, .filter-bar select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; outline: none; background: #fff;
}
.filter-bar input:focus, .filter-bar select:focus { border-color: var(--primary); }
.filter-bar .search { min-width: 200px; }
.spacer { flex: 1; }

/* 标签 */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.badge-pending { background: #f3f4f6; color: #6b7280; }
.badge-calling { background: #eff6ff; color: #2563eb; }
.badge-connected { background: #ecfdf5; color: #16a34a; }
.badge-no_answer { background: #fff7ed; color: #ea580c; }
.badge-invalid { background: #fef2f2; color: #dc2626; }
.badge-done { background: #eef2ff; color: #4f46e5; }

/* 星级 */
.stars { color: var(--star); letter-spacing: 1px; }
.star-input { display: flex; gap: 6px; font-size: 30px; margin: 8px 0 4px; }
.star-input .st { cursor: pointer; color: #d1d5db; transition: color .1s; }
.star-input .st.on { color: var(--star); }
.star-input .star-label { font-size: 14px; color: var(--text-2); align-self: center; margin-left: 8px; }

/* 模态框 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(17, 24, 39, .45); display: flex;
  align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal { width: 480px; max-width: 100%; background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); max-height: 90vh; display: flex; flex-direction: column; }
.modal-lg { width: 640px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; font-weight: 600; font-size: 16px; }
.modal-close { border: none; background: none; font-size: 24px; cursor: pointer; color: var(--text-3); line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-body label { display: block; font-size: 13px; color: var(--text-2); margin: 14px 0 6px; }
.modal-body textarea, .modal-body select, .modal-body input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; outline: none; resize: vertical;
}
.modal-body textarea:focus, .modal-body select:focus, .modal-body input:focus { border-color: var(--primary); }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.lead-brief { background: var(--primary-soft); padding: 12px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 4px; }
.assign-count { background: var(--primary-soft); padding: 12px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 4px; }

/* 详情 */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; }
.detail-item { font-size: 14px; }
.detail-item .k { color: var(--text-3); font-size: 12px; }
.detail-item .v { font-weight: 500; }
.detail-section { margin-top: 20px; }
.detail-section h4 { font-size: 14px; margin-bottom: 10px; color: var(--text-2); }
.timeline { border-left: 2px solid var(--border); padding-left: 16px; }
.timeline-item { margin-bottom: 12px; position: relative; }
.timeline-item::before {
  content: ''; position: absolute; left: -21px; top: 6px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--primary);
}
.timeline-meta { font-size: 12px; color: var(--text-3); }
.timeline-content { font-size: 14px; }
.audio-link { color: var(--primary); text-decoration: none; }
.audio-link:hover { text-decoration: underline; }

/* 空状态 / 加载 */
.empty { text-align: center; color: var(--text-3); padding: 40px 0; font-size: 14px; }
.loading { text-align: center; color: var(--text-3); padding: 30px 0; }

/* 分页 */
.pagination { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.pagination .btn { padding: 6px 12px; font-size: 13px; }
.page-info { color: var(--text-2); font-size: 13px; margin: 0 6px; }

/* 上传区 */
.upload-zone {
  border: 2px dashed var(--border); border-radius: 12px; padding: 40px 20px; text-align: center;
  color: var(--text-2); cursor: pointer; transition: all .15s; background: #fafbfc;
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--primary); background: var(--primary-soft); }
.upload-zone .up-ico { font-size: 40px; }
.upload-zone .up-tip { margin-top: 8px; font-size: 13px; color: var(--text-3); }
.upload-zone .file-name { margin-top: 8px; color: var(--primary); font-weight: 500; }

/* toast */
.toast {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
  background: #1f2937; color: #fff; padding: 10px 20px; border-radius: 8px; font-size: 14px;
  z-index: 200; opacity: 0; pointer-events: none; transition: opacity .25s;
}
.toast.show { opacity: 1; }
.toast.error { background: var(--danger); }

/* ---------- 公告栏（滚动） ---------- */
.announce-bar {
  display: flex; align-items: center; gap: 10px;
  background: #fffbeb; border-bottom: 1px solid #fde68a;
  padding: 7px 24px; flex-shrink: 0; overflow: hidden;
}
.announce-label { font-size: 13px; font-weight: 600; color: #b45309; white-space: nowrap; flex-shrink: 0; }
.announce-scroll { flex: 1; overflow: hidden; position: relative; }
.announce-text {
  display: inline-block; white-space: nowrap; padding-left: 100%;
  animation: announceScroll 22s linear infinite;
  font-size: 13px; color: #92400e;
}
.announce-text.no-scroll { padding-left: 0; animation: none; }
@keyframes announceScroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}

/* ---------- 个人中心下拉 ---------- */
.user-menu { position: relative; cursor: pointer; }
.user-menu .avatar { width: 36px; height: 36px; }
.user-menu-drop {
  position: absolute; right: 0; top: 46px; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-lg); min-width: 150px; z-index: 50; overflow: hidden;
}
.um-item { padding: 11px 16px; font-size: 14px; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.um-item:hover { background: var(--bg); }
.um-item.danger { color: var(--danger); }

/* 休息/求助按钮激活态 */
.btn-resting { background: #fef3c7; color: #b45309; border-color: #fcd34d; }
.btn-helping { background: #fee2e2; color: var(--danger); border-color: #fca5a5; }

/* ---------- 标签 ---------- */
.tag-badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500;
  color: #fff; line-height: 1.6;
}
.tag-select {
  padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; background: #fff; cursor: pointer; max-width: 120px;
}
.tag-select:focus { border-color: var(--primary); outline: none; }

/* 呼叫按钮 */
.btn-call { background: #ecfdf5; color: #059669; border-color: #a7f3d0; }
.btn-call:hover { background: #d1fae5; }

/* 公海规则提示 */
.pool-rule {
  background: var(--primary-soft); border: 1px solid #c7d2fe; border-radius: 10px;
  padding: 12px 16px; font-size: 13px; color: #4338ca; margin-bottom: 16px;
}
.pool-rule b { font-weight: 600; }

/* ---------- 数据看板 ---------- */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.chart-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.chart-card .card-title { padding: 14px 20px; font-size: 14px; font-weight: 600; border-bottom: 1px solid var(--border); }
.chart-box { width: 100%; height: 300px; padding: 8px; }
@media (max-width: 900px) { .chart-grid { grid-template-columns: 1fr; } }

/* 休息/求助状态徽章 */
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.status-dot.resting { background: #f59e0b; }
.status-dot.helping { background: #ef4444; }

/* 响应式 */
@media (max-width: 768px) {
  .sidebar { width: 64px; }
  .side-logo span, .side-user-info, .nav-item span.txt { display: none; }
  .side-logo { justify-content: center; }
  .nav-item { justify-content: center; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
