/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

/* 布局 */
.app {
    display: flex;
    min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
    width: 220px;
    background: #1a1a2e;
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h1 {
    font-size: 18px;
    font-weight: 600;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
}

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

.nav-item.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border-left: 3px solid #4a9eff;
}

.nav-item .icon {
    margin-right: 10px;
    font-size: 16px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* 主内容区 */
.main-content {
    flex: 1;
    margin-left: 220px;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: #fff;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e8e8e8;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar h2 {
    font-size: 20px;
    font-weight: 600;
}

.current-date {
    color: #888;
    font-size: 14px;
}

.page-content {
    flex: 1;
    padding: 24px;
}

/* 页面 */
.page {
    display: none;
}

.page.active {
    display: block;
}

/* 统计卡片 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-right: 16px;
}

.stat-info h3 {
    font-size: 24px;
    font-weight: 700;
    color: #1a1a2e;
}

.stat-info p {
    color: #888;
    font-size: 14px;
    margin-top: 2px;
}

/* 仪表盘分区 */
.dashboard-sections {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.section-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.section-card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: #1a1a2e;
}

/* 图表 */
.chart-placeholder {
    height: 200px;
    display: flex;
    align-items: flex-end;
    padding: 0 10px;
}

.chart-bars {
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    width: 100%;
    height: 100%;
    gap: 8px;
}

.chart-bar {
    flex: 1;
    background: #4a9eff;
    border-radius: 4px 4px 0 0;
    min-height: 4px;
    position: relative;
    transition: all 0.3s;
}

.chart-bar:hover {
    background: #1976d2;
}

.chart-bar-label {
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    color: #888;
    white-space: nowrap;
}

.chart-bar-value {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    color: #666;
    white-space: nowrap;
}

/* 工具栏 */
.page-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.search-box {
    display: flex;
    gap: 8px;
}

.search-box input {
    width: 280px;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}

.search-box input:focus {
    outline: none;
    border-color: #4a9eff;
}

/* 按钮 */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: #4a9eff;
    color: #fff;
}

.btn-primary:hover {
    background: #1976d2;
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-danger {
    background: #ff5252;
    color: #fff;
}

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

.btn-success {
    background: #4caf50;
    color: #fff;
}

.btn-success:hover {
    background: #388e3c;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-xs {
    padding: 4px 10px;
    font-size: 12px;
}

/* 表格 */
.table-container {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    overflow: hidden;
}

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

.data-table th {
    background: #f8f9fa;
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: #555;
    border-bottom: 1px solid #e8e8e8;
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
}

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

/* 状态标签 */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-active {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-public {
    background: #fff3e0;
    color: #ef6c00;
}

.status-risk {
    background: #ffebee;
    color: #c62828;
}

/* 信息横幅 */
.info-banner {
    background: #e3f2fd;
    border: 1px solid #bbdefb;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #1565c0;
}

/* 弹窗 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #fff;
    border-radius: 16px;
    width: 90%;
    max-width: 520px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-lg {
    max-width: 640px;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e8e8e8;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #888;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #e8e8e8;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

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

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #4a9eff;
}

.form-group textarea {
    resize: vertical;
}

.required {
    color: #ff5252;
}

/* 导入预览 */
.import-preview {
    margin-top: 16px;
    max-height: 200px;
    overflow-y: auto;
}

.import-preview table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.import-preview th,
.import-preview td {
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    text-align: left;
}

.import-preview th {
    background: #f5f5f5;
}

.import-preview .match-ok {
    color: #2e7d32;
}

.import-preview .match-fail {
    color: #c62828;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #888;
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
}

/* 响应式 */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
    .main-content {
        margin-left: 0;
        margin-bottom: 70px;
    }
    .dashboard-sections {
        grid-template-columns: 1fr;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .stat-card {
        padding: 14px;
    }
    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    .stat-info h3 {
        font-size: 20px;
    }
    .page-toolbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .search-box {
        width: 100%;
    }
    .search-box input {
        width: 100%;
        flex: 1;
    }
    .data-table {
        font-size: 12px;
    }
    .data-table th,
    .data-table td {
        padding: 10px 8px;
        white-space: nowrap;
    }
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .modal-content {
        width: 95%;
        max-height: 85vh;
    }
    .modal-lg {
        max-width: 95%;
    }
    .topbar {
        padding: 12px 16px;
    }
    .topbar h2 {
        font-size: 16px;
    }
    .page-content {
        padding: 16px;
    }
    .login-card {
        padding: 32px 24px;
    }
    .login-options {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    .stat-info h3 {
        font-size: 18px;
    }
}

/* ==================== 移动端底部导航 ==================== */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1a1a2e;
    padding: 6px 0 8px;
    z-index: 100;
    justify-content: space-around;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 10px;
    gap: 2px;
    padding: 4px 8px;
    border-radius: 8px;
    transition: all 0.2s;
}

.mobile-nav-item .icon {
    font-size: 20px;
}

.mobile-nav-item.active {
    color: #4a9eff;
}

/* ==================== PWA 安装提示 ==================== */
.pwa-install-banner {
    position: fixed;
    bottom: 70px;
    left: 10px;
    right: 10px;
    background: #1a1a2e;
    color: #fff;
    padding: 12px 16px;
    border-radius: 12px;
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    z-index: 150;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    font-size: 14px;
}

/* ==================== 登录页面 ==================== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 48px 40px;
    width: 90%;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-card h1 {
    font-size: 24px;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 8px;
}

.login-subtitle {
    color: #888;
    font-size: 14px;
    margin-bottom: 32px;
}

.login-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.login-option {
    padding: 24px 16px;
    border: 2px solid #e8e8e8;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.login-option:hover {
    border-color: #4a9eff;
    background: #f5f9ff;
}

.login-option.selected {
    border-color: #4a9eff;
    background: #e3f2fd;
}

.login-icon {
    font-size: 36px;
    margin-bottom: 8px;
}

.login-label {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.login-desc {
    font-size: 12px;
    color: #888;
}

.login-salesperson-select {
    margin-bottom: 16px;
    text-align: left;
}

.login-form {
    margin-bottom: 16px;
    text-align: left;
}

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

.login-form .form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.login-form .form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.login-form .form-group input:focus {
    outline: none;
    border-color: #4a9eff;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

/* ==================== 用户信息 ==================== */
.user-info {
    padding-top: 8px;
}

.user-role {
    font-size: 12px;
    color: rgba(255,255,255,0.6);
    margin-bottom: 8px;
    text-align: center;
}

.current-user {
    font-size: 14px;
    color: #555;
    margin-right: 16px;
    font-weight: 500;
}

/* 隐藏管理员功能 */
.salesperson-only .admin-only,
.nav-item.admin-only.hidden {
    display: none !important;
}

/* 公共库只读样式 */
.salesperson-only #public-pool-page .page-toolbar .btn-primary {
    display: none;
}

/* 认领审核页面 */
#claim-review-page .page-toolbar h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a2e;
}
