/* ==================== 全局样式 ==================== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif; background: #f5f6fa; color: #333; font-size: 14px; line-height: 1.5; }
a { text-decoration: none; color: #1a73e8; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 6px; background: #fff; }
textarea { resize: vertical; }
label { display: block; margin-bottom: 4px; font-weight: 500; color: #555; font-size: 13px; }

/* ==================== 按钮 ==================== */
.btn { display: inline-block; padding: 8px 16px; border: 1px solid #ddd; border-radius: 6px; background: #fff; color: #333; cursor: pointer; text-align: center; }
.btn:hover { background: #f0f0f0; }
.btn-primary { background: #1a73e8; color: #fff; border-color: #1a73e8; }
.btn-primary:hover { background: #1557b0; }
.btn-danger { background: #e74c3c; color: #fff; border-color: #e74c3c; }
.btn-danger:hover { background: #c0392b; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* 客资详情面板的"编辑"按钮 - 深蓝色 */
#panel-edit-btn {
    background: #1d4ed8 !important;
    color: #fff !important;
    border-color: #1d4ed8 !important;
}
#panel-edit-btn:hover {
    background: #1e40af !important;
    border-color: #1e40af !important;
}
.btn-block { display: block; width: 100%; }
.btn-delete { background: none; border: none; color: #e74c3c; cursor: pointer; font-size: 16px; padding: 0 4px; }

/* ==================== Flash消息 ==================== */
.flash-messages { margin-bottom: 16px; }
.flash { padding: 10px 16px; border-radius: 6px; margin-bottom: 8px; }
.flash-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.flash-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* ==================== 后台布局 ==================== */
.admin-body { display: flex; min-height: 100vh; background: #f5f6fa; }
.sidebar { width: 220px; background: #1a1f36; color: #fff; flex-shrink: 0; display: flex; flex-direction: column; }
.sidebar-brand { padding: 20px; text-align: center; border-bottom: 1px solid #2a2f4a; }
.brand-icon { font-size: 32px; margin-bottom: 8px; }
.brand-text { font-size: 16px; font-weight: bold; color: #fff; }
.sidebar-nav { flex: 1; padding: 12px 0; }
.sidebar-nav .nav-item { display: flex; align-items: center; padding: 12px 20px; color: #b0b7c3; transition: all 0.2s; }
.sidebar-nav .nav-item:hover { background: rgba(26,115,232,0.2); color: #fff; }
.sidebar-nav .nav-item.active { background: #1a73e8; color: #fff; }
.nav-icon { font-size: 18px; margin-right: 10px; width: 24px; text-align: center; }
.nav-text { font-size: 14px; }
.sidebar-footer { padding: 12px 0; border-top: 1px solid #2a2f4a; }

/* 后台头部 */
.admin-header { background: #fff; padding: 12px 24px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.admin-header h1 { font-size: 18px; color: #333; }
.user-info { display: flex; align-items: center; gap: 12px; color: #555; font-size: 13px; }
.user-name { color: #333; font-weight: 500; }
.logout { color: #e74c3c; font-size: 13px; }

/* 后台主内容 */
.main-content { flex: 1; padding: 24px; overflow-x: auto; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.page-title { font-size: 20px; font-weight: 600; color: #333; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* 卡片 */
.card { background: #fff; border-radius: 8px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); margin-bottom: 16px; }
.card-title { font-size: 16px; font-weight: 600; color: #333; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid #f0f0f0; }
.card-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #f5f5f5; font-size: 13px; }
.card-row:last-child { border-bottom: none; }
.card-row .label { color: #888; }
.card-row .value { color: #333; font-weight: 500; }

/* 表格 */
.table-wrap { background: #fff; border-radius: 8px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { background: #f8f9fa; padding: 10px 12px; text-align: left; color: #555; font-weight: 600; border-bottom: 2px solid #e8eaed; white-space: nowrap; }
.data-table td { padding: 10px 12px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
.data-table tr:hover td { background: #f8f9ff; }
.data-table .actions { display: flex; gap: 4px; }

/* 表单 */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; align-items: stretch; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; color: #2c3e50; }
.form-actions { margin-top: 16px; display: flex; gap: 8px; }
.form-group input[type="text"], .form-group input[type="date"], .form-group input[type="time"], .form-group input[type="datetime-local"], .form-group input[type="email"], .form-group input[type="number"], .form-group input:not([type]), .form-group select, .form-group textarea { width: 100%; box-sizing: border-box; padding: 0 10px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; }
.form-group input, .form-group select { height: 36px; }
.form-group textarea { min-height: 80px; padding: 8px 10px; line-height: 1.5; resize: vertical; }
.form-row { align-items: end; }


/* 统计 */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat-card { background: #fff; border-radius: 8px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.stat-number { font-size: 36px; font-weight: bold; color: #1a73e8; }
.stat-label { color: #888; margin-top: 4px; }

/* 筛选 */
.filter-bar { background: #fff; padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.filter-bar input, .filter-bar select { width: auto; min-width: 160px; padding: 6px 10px; font-size: 13px; }

/* 标签 */
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 12px; font-weight: 500; }
.badge-blue { background: #e7f3fe; color: #1a73e8; }
.badge-green { background: #e6f4ea; color: #137333; }
.badge-orange { background: #fef7e0; color: #b06000; }
.badge-red { background: #fce8e6; color: #c5221f; }
.badge-gray { background: #f1f3f4; color: #5f6368; }

/* 状态徽章 */
.status { display: inline-block; padding: 3px 10px; border-radius: 4px; font-size: 12px; font-weight: 500; }
.status-new { background: #e7f3fe; color: #1a73e8; }
.status-follow { background: #fef7e0; color: #b06000; }
.status-deal { background: #e6f4ea; color: #137333; }
.status-fail { background: #fce8e6; color: #c5221f; }
.status-invalid { background: #f1f3f4; color: #5f6368; }
.status-dup { background: #fce8e6; color: #c5221f; }

/* 分页 */
.pagination { display: flex; gap: 4px; justify-content: center; margin-top: 16px; }
.pagination a, .pagination span { padding: 6px 12px; border: 1px solid #ddd; border-radius: 4px; font-size: 13px; color: #333; background: #fff; }
.pagination a:hover { background: #f0f0f0; }
.pagination .current { background: #1a73e8; color: #fff; border-color: #1a73e8; }

/* 模态框 */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: none; align-items: center; justify-content: center; z-index: 1000; }
.modal-mask.show { display: flex; }
.modal { background: #fff; border-radius: 8px; width: 90%; max-width: 600px; max-height: 90vh; overflow-y: auto; }
.modal-header { padding: 14px 18px; border-bottom: 1px solid #f0f0f0; display: flex; justify-content: space-between; align-items: center; }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: #999; }
.modal-body { padding: 18px; }
.modal-footer { padding: 14px 18px; border-top: 1px solid #f0f0f0; display: flex; justify-content: flex-end; gap: 8px; }

/* 公告 */
.announcement-list { background: #fff; border-radius: 8px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.announcement-item { display: flex; justify-content: space-between; align-items: center; }
.ann-meta { display: flex; align-items: center; gap: 12px; color: #999; font-size: 12px; white-space: nowrap; }

/* ==================== 前端 ==================== */
.front-body { background: #f0f2f5; min-height: 100vh; }
.front-container { padding-bottom: 40px; }

/* 登录页 */
.login-page { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 40px 20px; }
.login-header { text-align: center; margin-bottom: 32px; }
.login-title { font-size: 28px; color: #1a73e8; font-weight: 700; }
.login-subtitle { color: #888; margin-top: 8px; font-size: 14px; }
.login-box { background: #fff; padding: 32px; border-radius: 12px; max-width: 400px; margin: 0 auto; box-shadow: 0 4px 12px rgba(0,0,0,0.08); }

/* 前台导航 */
.front-header { background: linear-gradient(135deg, #1a73e8, #1557b0); color: #fff; padding: 16px 20px; }
.front-brand { font-size: 18px; font-weight: 600; }
.front-nav { display: flex; gap: 16px; margin-top: 10px; }
.front-nav a { color: rgba(255,255,255,0.85); padding: 6px 12px; border-radius: 4px; font-size: 14px; }
.front-nav a:hover, .front-nav a.active { background: rgba(255,255,255,0.18); color: #fff; }

/* 前台主内容 */
.front-main { max-width: 1100px; margin: 0 auto; padding: 20px; }
.front-section { background: #fff; border-radius: 8px; padding: 18px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.section-title { font-size: 16px; font-weight: 600; color: #333; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid #f0f0f0; }

/* ==================== 手机端 ==================== */
.mobile-body { background: #f5f6fa; min-height: 100vh; padding-bottom: 70px; }
.mobile-header { background: #fff; padding: 14px 16px; font-size: 17px; font-weight: 600; color: #333; text-align: center; border-bottom: 1px solid #eee; position: sticky; top: 0; z-index: 10; }
.mobile-content { padding: 12px; }
.mobile-card { background: #fff; border-radius: 8px; padding: 14px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }

.btn-mobile { display: inline-block; padding: 10px 16px; background: #1a73e8; color: #fff; border: none; border-radius: 6px; font-size: 14px; cursor: pointer; text-align: center; text-decoration: none; }
.btn-mobile:hover { background: #1557b0; color: #fff; }
.btn-mobile-outline { background: #fff; color: #333; border: 1px solid #ddd; }
.btn-mobile-outline:hover { background: #f5f5f5; color: #333; }

/* 统计宫格 */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.stat-item { background: #fff; padding: 16px 10px; border-radius: 8px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.stat-num { font-size: 24px; font-weight: 700; color: #1a73e8; }
.stat-num.blue { color: #1a73e8; }
.stat-num.green { color: #137333; }
.stat-num.gray { color: #888; }

/* 底部Tab栏 */
.mobile-tabbar { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid #eee; display: flex; z-index: 100; }
.tabbar-item { flex: 1; text-align: center; padding: 8px 0; color: #888; text-decoration: none; font-size: 11px; }
.tabbar-item.active { color: #1a73e8; }
.tabbar-icon { display: block; font-size: 20px; margin-bottom: 2px; }

/* 客资列表 */
.tab-bar { display: flex; background: #fff; border-radius: 8px; margin-bottom: 10px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.tab-bar a { flex: 1; text-align: center; padding: 10px 0; color: #666; text-decoration: none; font-size: 13px; border-right: 1px solid #f0f0f0; }
.tab-bar a:last-child { border-right: none; }
.tab-bar a.active { background: #1a73e8; color: #fff; }

.search-bar { background: #fff; border-radius: 8px; padding: 10px; margin-bottom: 10px; display: flex; gap: 6px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.search-bar input, .search-bar select { flex: 1; padding: 8px; font-size: 13px; }
.search-bar button { flex: 0; padding: 8px 14px; }

.condition-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip { background: #e7f3fe; color: #1a73e8; padding: 4px 10px; border-radius: 12px; font-size: 12px; }

.tab-content { padding: 12px 16px; }
.lead-card { display: block; background: #fff; padding: 14px; margin-bottom: 10px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); color: #333; }
.lead-card:active { background: #f8f9ff; }
.lead-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.lead-name { font-weight: 500; font-size: 15px; }
.lead-phone { color: #1a73e8; font-size: 13px; }
.lead-card-body { display: flex; gap: 12px; font-size: 12px; color: #888; }
.lead-time { margin-left: auto; }

/* 详情页 */
.detail-card { background: #fff; margin: 12px 16px; padding: 16px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.detail-row { display: flex; padding: 8px 0; border-bottom: 1px solid #f5f5f5; }
.detail-label { color: #888; width: 80px; flex-shrink: 0; font-size: 13px; }
.detail-value { color: #333; font-size: 13px; word-break: break-all; }
.follow-form { margin-top: 8px; }
.follow-item { padding: 10px 0; border-bottom: 1px solid #f0f0f0; }
.follow-header { display: flex; justify-content: space-between; margin-bottom: 4px; }
.follow-time { font-size: 12px; color: #999; }
.follow-amounts { font-size: 12px; color: #888; margin-top: 4px; }

/* 空状态 */
.empty { text-align: center; padding: 40px; color: #aaa; }

/* 响应式 */
@media (max-width: 768px) {
    .form-row { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .sidebar { width: 60px; }
    .brand-text, .nav-text, .user-name { display: none; }
    .sidebar-brand { padding: 16px 0; }
    .sidebar-nav .nav-item, .user-info, .sidebar-footer .logout { padding: 12px 0; justify-content: center; }
    .nav-icon { margin-right: 0; }
    .main-content { padding: 12px; }
    .filter-bar { flex-direction: column; }
    .filter-bar input, .filter-bar select { width: 100%; }
}

/* 手机端 stat-item 作为链接时的样式（保留外观，去掉下划线） */
.stat-item { text-decoration: none; color: inherit; }

/* ==================== 手机端 stats.html 专用样式 ==================== */
.stats-hero { background: linear-gradient(135deg, #1a73e8, #1557b0); color: #fff; text-align: center; padding: 18px; }
.stats-hero-period { font-size: 13px; opacity: 0.9; }
.stats-hero-amount { font-size: 30px; font-weight: 700; margin-top: 6px; }
.stats-hero-meta { font-size: 12px; opacity: 0.9; margin-top: 4px; }

.stats-range-row { display: flex; gap: 6px; flex-wrap: wrap; }
.stats-range-btn {
    flex: 1;
    padding: 8px;
    font-size: 12px;
    text-decoration: none;
    text-align: center;
    background: #fff;
    color: #333;
    border: 1px solid #ddd;
    border-radius: 6px;
}
.stats-range-btn.active { background: #e7f3fe; color: #1a73e8; }

.stats-custom-row { display: flex; gap: 6px; align-items: center; }
.stats-date-input {
    flex: 1;
    padding: 6px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 12px;
}
.stats-date-sep { color: #999; }
.stats-query-btn { flex: 0; padding: 8px 12px; font-size: 12px; }

.stats-grid-3 { grid-template-columns: repeat(3, 1fr); }
.stats-num-blue { color: #1a73e8; }
.stats-num-green { color: #137333; }
.stats-num-follow { color: #1967d2; }
.stats-num-wait { color: #b06000; }
.stats-num-fail { color: #c5221f; }
.stats-num-gray { color: #888; }

.stats-chart-wrap {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 140px;
    padding: 8px 4px 0;
    border-bottom: 1px solid #eee;
}
.stats-chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; }
.stats-chart-amount { font-size: 10px; color: #137333; margin-bottom: 2px; min-height: 12px; }
.stats-chart-bar { width: 80%; height: 100px; display: flex; align-items: flex-end; }
.stats-chart-fill {
    width: 100%;
    background: linear-gradient(to top, #1a73e8, #6fa8dc);
    border-radius: 4px 4px 0 0;
    min-height: 2px;
}
.stats-chart-label { font-size: 10px; color: #666; margin-top: 4px; }

.stats-rank-meta { color: #999; font-size: 11px; margin-left: 6px; }


/* ============ 弹窗表单（字段设置、添加客资等） ============ */
.modal-form {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: none;
    align-items: flex-start;
    justify-content: center;
    z-index: 1100;
    padding: 60px 16px 40px;
    overflow-y: auto;
}
.modal-form[style*="display: block"],
.modal-form[style*="display:block"] {
    display: flex !important;
}
.modal-form .modal-content {
    background: #fff;
    border-radius: 8px;
    width: 100%;
    max-width: 700px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    padding: 24px 28px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
    position: relative;
}
.modal-form .modal-content .close {
    position: absolute;
    top: 10px;
    right: 14px;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    color: #888;
    background: none;
    border: none;
}
.modal-form .modal-content .close:hover { color: #e74c3c; }
.modal-form .modal-content h2 {
    margin: 0 0 16px;
    font-size: 18px;
    color: #2c3e50;
}


/* ============ 字段设置弹窗：开关列居中对齐 ============ */
#field-config-form table.data-table { table-layout: fixed; width: 100%; }
#field-config-form table.data-table th,
#field-config-form table.data-table td {
    text-align: center !important;
    vertical-align: middle !important;
    padding: 10px 6px !important;
}
/* 表头与字段名列单独处理 */
#field-config-form table.data-table th:nth-child(1),
#field-config-form table.data-table td:nth-child(1) { width: 36px; }
#field-config-form table.data-table th:nth-child(2),
#field-config-form table.data-table td:nth-child(2) {
    text-align: left !important;
    min-width: 110px;
}
#field-config-form table.data-table th:nth-child(8),
#field-config-form table.data-table td:nth-child(8) { width: 70px; }
#field-config-form table.data-table th:nth-child(9),
#field-config-form table.data-table td:nth-child(9) { width: 60px; }
/* 滚动时表头固定 */
#field-config-form table.data-table thead th {
    position: sticky;
    top: 0;
    background: #f5f7fa;
    z-index: 2;
    box-shadow: 0 1px 0 #e6e9ef;
}
/* 让 .switch 在 td 中水平居中 */
#field-config-form .switch {
    display: inline-flex;
    vertical-align: middle;
    margin: 0 auto;
}

/* 客资管理列表：灰色框格线 */
.table-wrapper { border: 1px solid #dfe3eb; border-radius: 8px; overflow: hidden; background: #fff; }
.table-wrapper table.data-table { border: none; }
.table-wrapper .data-table th { background: #f5f7fa; border-bottom: 1px solid #dfe3eb; }
.table-wrapper .data-table td { border-right: 1px solid #f0f2f5; border-bottom: 1px solid #f0f2f5; }
.table-wrapper .data-table td:last-child { border-right: none; }
.table-wrapper .data-table tr:last-child td { border-bottom: none; }
.table-wrapper .data-table tr:hover td { background: #f8f9ff; }
