/* 基础样式 */
* {
    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;
    }
}

@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 env(safe-area-inset-bottom, 8px);
    z-index: 110;
    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;
    min-width: 48px;
    min-height: 44px;
    justify-content: center;
}

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

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

/* ==================== FAB 浮动按钮 ==================== */
.fab {
    display: none;
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #4a9eff;
    color: #fff;
    font-size: 28px;
    border: none;
    box-shadow: 0 4px 12px rgba(74,158,255,0.4);
    z-index: 105;
    cursor: pointer;
    transition: all 0.2s;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.fab:active {
    transform: scale(0.92);
    background: #1976d2;
}

.fab-menu {
    display: none;
    position: fixed;
    bottom: 144px;
    right: 20px;
    z-index: 105;
    flex-direction: column;
    gap: 10px;
}

.fab-menu.open {
    display: flex;
}

.fab-menu-item {
    padding: 12px 20px;
    background: #1a1a2e;
    color: #fff;
    border: none;
    border-radius: 24px;
    font-size: 14px;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    text-align: right;
}

.fab-menu-item:active {
    background: #333;
    transform: scale(0.95);
}

/* 移动端统计卡片紧凑模式 */
@media (max-width: 768px) {
    .fab {
        display: flex;
    }
}

/* ==================== 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, #0d2818 0%, #14532d 45%, #0b2414 100%);
    position: relative;
    overflow: hidden;
    padding: 20px;
}

/* 背景装饰光斑 */
.login-page::before,
.login-page::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.45;
}

.login-page::before {
    width: 420px;
    height: 420px;
    background: #22c55e;
    top: -120px;
    right: -80px;
}

.login-page::after {
    width: 360px;
    height: 360px;
    background: #14b8a6;
    bottom: -140px;
    left: -60px;
    opacity: 0.3;
}

/* 整体外壳 */
.login-shell {
    display: flex;
    width: 100%;
    max-width: 900px;
    min-height: 540px;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0,0,0,0.45);
    position: relative;
    z-index: 1;
    background: #fff;
}

/* ===== 品牌区 ===== */
.login-brand {
    flex: 1.15;
    background: linear-gradient(160deg, #15803d 0%, #16a34a 60%, #22c55e 100%);
    color: #fff;
    padding: 56px 48px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.login-brand h1 {
    font-size: 36px;
    font-weight: 700;
    letter-spacing: 3px;
    margin-bottom: 8px;
}

.brand-tagline {
    font-size: 20px;
    color: rgba(255,255,255,0.88);
    letter-spacing: 3px;
    margin-bottom: 36px;
    font-weight: 500;
}

.brand-features {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.brand-features span {
    font-size: 14px;
    color: rgba(255,255,255,0.85);
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-deco {
    position: absolute;
    border-radius: 50%;
    border: 1.5px solid rgba(255,255,255,0.12);
}

.deco-1 {
    width: 220px;
    height: 220px;
    right: -70px;
    bottom: -60px;
}

.deco-2 {
    width: 130px;
    height: 130px;
    right: 40px;
    bottom: 50px;
}

/* ===== 表单区 ===== */
.login-form-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    background: #fff;
}

.login-form-inner {
    width: 100%;
    max-width: 320px;
}

.login-form-inner h2 {
    font-size: 26px;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 8px;
}

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

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

.login-form-inner .form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #444;
}

.input-wrap {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 15px;
    opacity: 0.55;
    pointer-events: none;
}

.input-wrap select,
.input-wrap input {
    width: 100%;
    padding: 13px 14px 13px 42px;
    border: 1.5px solid #e3e6ee;
    border-radius: 10px;
    font-size: 14px;
    background: #fafbfd;
    transition: all 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.input-wrap select {
    cursor: pointer;
}

.input-wrap select:focus,
.input-wrap input:focus {
    outline: none;
    border-color: #4a9eff;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(74,158,255,0.12);
}

.login-btn {
    padding: 14px;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 8px;
    border-radius: 10px;
    background: linear-gradient(90deg, #16a34a, #22c55e);
    margin-top: 8px;
    box-shadow: 0 8px 20px rgba(34,197,94,0.35);
    justify-content: center;
}

.login-btn:hover {
    background: linear-gradient(90deg, #15803d, #16a34a);
    box-shadow: 0 10px 26px rgba(34,197,94,0.45);
    transform: translateY(-1px);
}

.login-tip {
    margin-top: 20px;
    text-align: center;
    color: #bbb;
    font-size: 12px;
}

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

/* 移动端：隐藏品牌区，只留表单 */
@media (max-width: 768px) {
    .login-shell {
        max-width: 420px;
        min-height: auto;
    }
    .login-brand {
        display: none;
    }
    .login-form-panel {
        padding: 40px 28px;
    }
}

/* ==================== 用户信息 ==================== */
.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;
}
