/* ==================== 全局样式 - 现代SaaS风格 ==================== */
:root {
    --primary-color: #1890ff;
    --primary-hover: #40a9ff;
    --primary-light: #e6f7ff;
    --success-color: #52c41a;
    --warning-color: #faad14;
    --danger-color: #ff4d4f;
    --info-color: #1890ff;
    --text-primary: #262626;
    --text-secondary: #8c8c8c;
    --text-disabled: #bfbfbf;
    --bg-color: #f0f2f5;
    --bg-white: #ffffff;
    --border-color: #d9d9d9;
    --border-light: #f0f0f0;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.16);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-color);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}

/* ==================== 登录页面 ==================== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #001529 0%, #1890ff 100%);
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 420px;
}

.login-box {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header h1 {
    font-size: 28px;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.login-form input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    transition: var(--transition);
    background: var(--bg-white);
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.login-form button {
    width: 100%;
    padding: 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.login-form button:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.login-footer {
    margin-top: 24px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
}

/* ==================== 后台布局 ==================== */
.admin-container {
    display: flex;
    min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
    width: 240px;
    background: #001529;
    color: white;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.logo {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.logo h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
    letter-spacing: 1px;
}

.logo p {
    font-size: 12px;
    opacity: 0.65;
    letter-spacing: 0.5px;
}

.nav-menu {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    color: rgba(255,255,255,0.65);
    transition: var(--transition);
    border-left: 3px solid transparent;
    margin: 4px 0;
}

.nav-item:hover {
    background: rgba(255,255,255,0.05);
    color: white;
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
}

.nav-item .icon {
    margin-right: 12px;
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.user-info {
    padding: 16px 24px;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 13px;
}

.user-info p {
    opacity: 0.65;
    margin-bottom: 8px;
}

.logout-btn {
    color: rgba(255,255,255,0.45);
    font-size: 13px;
}

.logout-btn:hover {
    color: white;
}

/* 主内容区 */
.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 24px;
    min-height: 100vh;
}

/* 页面头部 */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.page-header .subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ==================== 按钮 ==================== */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    background: var(--bg-white);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
    margin-right: 4px;
    border-radius: var(--radius-sm);
}

.btn-info {
    background: var(--primary-light);
    color: var(--primary-color);
    border: none;
    cursor: pointer;
}

.btn-danger {
    background: #fff1f0;
    color: var(--danger-color);
    border: none;
    cursor: pointer;
}

.btn-danger:hover {
    background: #ffccc7;
}

/* ==================== 统计卡片 ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-card.highlight {
    background: linear-gradient(135deg, #722ed1 0%, #531dab 100%);
    color: white;
}

.stat-card.highlight .stat-label {
    color: rgba(255,255,255,0.85);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-right: 16px;
    flex-shrink: 0;
}

.stat-content {
    flex: 1;
    min-width: 0;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

/* ==================== 图表区域 ==================== */
.charts-section {
    margin-bottom: 24px;
}

.chart-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.chart-card h3 {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.chart-container {
    height: 280px;
}

/* ==================== 表格 ==================== */
.table-responsive {
    overflow-x: auto;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
}

.data-table th {
    background: #fafafa;
    font-weight: 500;
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.data-table tbody tr {
    transition: var(--transition);
}

.data-table tbody tr:hover {
    background: #f5f5f5;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table .empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 48px;
}

.data-table .money {
    font-weight: 500;
    color: #fa541c;
    white-space: nowrap;
}

.rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #f0f0f0;
    font-size: 12px;
    font-weight: 500;
}

.rank.top {
    background: #fff7e6;
    color: #fa8c16;
}

/* 状态徽章 */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 400;
    white-space: nowrap;
}

.badge.scan {
    background: #e6f7ff;
    color: #1890ff;
}

.badge.customer {
    background: #f9f0ff;
    color: #722ed1;
    cursor: pointer;
    transition: var(--transition);
}

.badge.customer:hover {
    background: #efdbff;
}

.badge.interesting {
    background: #fff7e6;
    color: #fa8c16;
}

.badge.loaned {
    background: #f6ffed;
    color: #52c41a;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 400;
}

.status-pending {
    background: #f5f5f5;
    color: #8c8c8c;
}

.status-contacted {
    background: #e6f7ff;
    color: #1890ff;
}

.status-interesting {
    background: #fff7e6;
    color: #fa8c16;
}

.status-qualified {
    background: #fff1b8;
    color: #d48806;
}

.status-loaned {
    background: #f6ffed;
    color: #52c41a;
}

.status-wechat_added {
    background: #e6f7ff;
    color: #1890ff;
}

.status-approved {
    background: #fff7e6;
    color: #fa8c16;
}

/* ==================== 筛选栏 ==================== */
.filter-bar {
    background: var(--bg-white);
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.filter-form {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.filter-group select {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    min-width: 140px;
    background: var(--bg-white);
}

/* ==================== 表单 ==================== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    transition: var(--transition);
    background: var(--bg-white);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.form-group small {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ==================== 弹窗 ==================== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.45);
    animation: fadeIn 0.2s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg-white);
    margin: 48px auto;
    padding: 0;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
    animation: slideDown 0.3s;
}

@keyframes slideDown {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-sm {
    max-width: 400px;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
}

.modal-header .close {
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}

.modal-header .close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* 二维码弹窗 */
.qr-modal {
    text-align: center;
}

.qr-display {
    padding: 24px;
}

.qr-display img {
    width: 200px;
    height: 200px;
    margin-bottom: 16px;
    border-radius: var(--radius-md);
}

.qr-title {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 8px;
}

.qr-url {
    font-size: 12px;
    color: var(--text-secondary);
    word-break: break-all;
    margin-bottom: 16px;
    padding: 8px 12px;
    background: #f5f5f5;
    border-radius: var(--radius-sm);
}

/* ==================== 消息提示 ==================== */
.flash-messages {
    margin-bottom: 16px;
}

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    font-size: 14px;
    display: flex;
    align-items: center;
}

.alert-success {
    background: #f6ffed;
    color: #52c41a;
    border: 1px solid #b7eb8f;
}

.alert-error {
    background: #fff2f0;
    color: #ff4d4f;
    border: 1px solid #ffccc7;
}

.alert-warning {
    background: #fffbe6;
    color: #faad14;
    border: 1px solid #ffe58f;
}

/* ==================== 响应式 ==================== */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 80px;
    }
    
    .logo h2,
    .logo p,
    .nav-item span:not(.icon),
    .user-info p,
    .user-info .logout-btn {
        display: none;
    }
    
    .nav-item {
        justify-content: center;
        padding: 14px;
    }
    
    .nav-item .icon {
        margin: 0;
    }
    
    .main-content {
        margin-left: 80px;
        padding: 16px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .page-header {
        flex-direction: column;
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}
