/* 侧边栏样式 */
.sidebar {
    width: 250px;
    background: linear-gradient(180deg, #2c3e50 0%, #1a2530 100%);
    color: white;
    position: fixed;
    height: 100vh;
    overflow: hidden;              /* 滚动交给内部列表 */
    z-index: 100;
    box-shadow: 3px 0 10px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
}

.logo {
    padding: 25px 20px;
    font-size: 22px;
    font-weight: 600;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    text-align: center;
    flex-shrink: 0;
}

.sidebar ul {
    list-style: none;
    padding: 20px 0;
    flex: 1 1 auto;                /* 占满中间空间 */
    overflow-y: auto;             /* 活动多时只滚这里 */
    min-height: 0;                /* flex 内滚动必需 */
}

.sidebar li {
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar li a {
    display: block;
    padding: 15px 25px;
    color: #ecf0f1;
    text-decoration: none;
    transition: all 0.3s;
    font-size: 16px;
    text-align: center; /* 添加居中 */
    justify-content: center; /* 添加居中 */
}

.sidebar li a:hover, 
.sidebar li.active a {
    background: #3498db;
    padding-left: 25px; /* 移除悬停时左侧填充 */
}

/* 主内容区域调整 */
.main-content {
    margin-left: 250px;
    width: calc(100% - 250px);
    padding: 20px;
    box-sizing: border-box;
}

/* 基础样式 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
}

body {
    background: linear-gradient(135deg, #f5f7fa 0%, #e4edf5 100%);
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    position: relative;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: #fff;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: linear-gradient(90deg, #2c3e50 0%, #1a2530 100%);
    color: white;
    position: relative;
}

.header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #3498db, #2ecc71);
}

.header h1 {
    font-size: 28px;
    font-weight: 600;
    display: flex;
    align-items: center;
}

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

.btn {
    padding: 10px 20px;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn .icon {
    font-size: 16px;
}

.danger {
    background: #e74c3c;
}

.danger:hover {
    background: #c0392b;
}

.calculate-btn {
    background: #2ecc71;
}

.calculate-btn:hover {
    background: #27ae60;
}

.config-btn {
    background: #9b59b6;
}

.config-btn:hover {
    background: #8e44ad;
}

.back-btn {
    background: #3498db;
}

.back-btn:hover {
    background: #2980b9;
}

.export-btn {
    background: #f39c12;
}

.export-btn:hover {
    background: #d35400;
}

.save-btn {
    background: #3498db;
}

.save-btn:hover {
    background: #2980b9;
}

.add-rule-btn {
    background: #2ecc71;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    margin-right: 15px;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.add-rule-btn:hover {
    background: #27ae60;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.message {
    padding: 15px 25px;
    margin: 0 30px 20px;
    border-radius: 8px;
    text-align: center;
    font-weight: 500;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* 配置区域 */
.config-section {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 25px;
    margin: 0 30px 30px;
    border: 1px solid #eaeaea;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
}

.config-section h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 22px;
    padding-bottom: 10px;
    border-bottom: 2px solid #3498db;
}

.config-row {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.config-row label {
    font-weight: 500;
    min-width: 120px;
    color: #2c3e50;
}

.config-row input {
    padding: 10px 15px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    width: 150px;
    font-size: 16px;
    transition: border 0.3s;
}

.config-row input:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.config-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 25px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.config-table th, .config-table td {
    border: 1px solid #e0e6ed;
    padding: 14px;
    text-align: center;
}

.config-table th {
    background: linear-gradient(to bottom, #3498db, #2980b9);
    color: white;
    font-weight: 600;
}

.config-table tr:nth-child(even) {
    background-color: #f8fafc;
}

.config-table input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 5px;
    font-size: 14px;
    transition: all 0.3s;
}

.config-table input:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
    outline: none;
}

.config-table button {
    padding: 8px 15px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
}

.config-table button:hover {
    background: #c0392b;
    transform: scale(1.05);
}

/* 数据区域 */
.data-section {
    display: flex;
    gap: 30px;
    margin: 0 30px 30px;
    flex-wrap: wrap;
}

.data-column {
    flex: 1;
    min-width: 500px;
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid #eaeaea;
}

.data-column h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 18px;
    padding-bottom: 10px;
    border-bottom: 1px solid #3498db;
}

.data-column textarea {
    width: 100%;
    height: 300px;
    padding: 15px;
    border: 1px solid #ced4da;
    border-radius: 8px;
    font-family: monospace;
    font-size: 14px;
    margin-bottom: 15px;
    resize: vertical;
    transition: border 0.3s;
}

.data-column textarea:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

/* 结果区域 */
.results-section {
    margin: 0 30px 30px;
    background: #fff;
    border-radius: 10px;
    padding: 25px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid #eaeaea;
}

.results-section h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 22px;
    padding-bottom: 10px;
    border-bottom: 2px solid #3498db;
}

.summary {
    display: flex;
    justify-content: space-between;
    background: linear-gradient(to right, #f8f9fa, #e9f7fe);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 25px;
    border: 1px solid #e0e6ed;
    flex-wrap: wrap;
    gap: 15px;
}

.summary-item {
    text-align: center;
    flex: 1;
    min-width: 180px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    border: 1 solid #e0e6ed;
}

.summary-item .label {
    display: block;
    font-weight: 500;
    color: #7f8c8d;
    margin-bottom: 8px;
    font-size: 14px;
}

.summary-item .value {
    display: block;
    font-size: 22px;
    font-weight: 700;
    color: #2c3e50;
}

.summary-item:nth-child(1) .value {
    color: #27ae60;
}

.table-container {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #e0e6ed;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    min-width: 1000px;
}

.results-table th, .results-table td {
    border: 1px solid #e0e6ed;
    padding: 14px;
    text-align: left;
}

.results-table th {
    background: linear-gradient(to bottom, #3498db, #2980b9);
    color: white;
    font-weight: 600;
    position: sticky;
    top: 0;
    text-align: center;
}

.results-table tr:nth-child(even) {
    background-color: #f8fafc;
}

.results-table tr:hover {
    background-color: #f1f8ff;
}

.results-table td {
    text-align: center;
}

.positive {
    color: #27ae60;
    font-weight: 600;
    font-size: 16px;
}

.negative {
    color: #e74c3c;
    font-weight: 500;
}

/* 加载指示器 */
#loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 1000;
}

.loading-spinner {
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    color: white;
    font-size: 18px;
    font-weight: 500;
}

/* 响应式调整 */
@media (max-width: 1200px) {
    .data-section {
        flex-direction: column;
    }
    
    .data-column {
        min-width: 100%;
    }
    
    .actions {
        flex-wrap: wrap;
    }
}

/* 分页样式 */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e6ed;
}

.pagination-controls {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 0;
}

.pagination-link {
    display: inline-block;
    padding: 8px 15px;
    background: #3498db;
    color: white;
    border-radius: 5px;
    text-decoration: none;
    transition: all 0.3s;
    font-weight: 500;
    min-width: 36px;
    text-align: center;
}

.pagination-link:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.pagination-link.active {
    background: #2c3e50;
    font-weight: bold;
}

.per-page-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    padding: 8px 15px;
    border-radius: 6px;
    border: 1px solid #e0e6ed;
    margin: 0 15px;
}

.per-page-selector select {
    padding: 6px 10px;
    border: 1px solid #ced4da;
    border-radius: 5px;
    background: white;
    cursor: pointer;
    font-size: 14px;
}

.per-page-selector select:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.pagination-info {
    color: #7f8c8d;
    font-size: 14px;
    font-weight: 500;
    min-width: 200px;
    text-align: center;
}

/* 响应式调整 */
@media (max-width: 1200px) {
    .pagination {
        flex-direction: column;
        gap: 15px;
    }
    
    .pagination-controls,
    .per-page-selector,
    .pagination-info {
        width: 100%;
        justify-content: center;
    }
}

/* 规则配置按钮布局 */
.config-buttons {
    display: flex;
    justify-content: flex-start;
    gap: 15px;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* 计算结果头部布局 */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

/* 搜索表单样式 */
.search-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.search-form input {
    padding: 10px 15px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    min-width: 250px;
    font-size: 14px;
    transition: all 0.3s;
}

.search-form input:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.search-btn {
    background: #2ecc71;
    padding: 10px 15px;
}

.search-btn:hover {
    background: #27ae60;
}

.clear-search-btn {
    background: #e74c3c;
    padding: 10px 15px;
}

.clear-search-btn:hover {
    background: #c0392b;
}

/* 修复表格中正负值样式 */
.positive-difference {
    color: #27ae60;
}

.negative-difference {
    color: #e74c3c;
}

/* 确保操作按钮可见 */
.actions {
    z-index: 10;
    position: relative;
}

/* 移动设备适配 */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
    }
    
    .data-column {
        min-width: 100%;
    }
}
/* 修改侧边栏所有文本居中 */
.sidebar ul li a,
.logout-btn {
    text-align: center;
    justify-content: center;
}


/* 登录页面样式 */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(135deg, #3498db 0%, #8e44ad 100%);
}

.login-box {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    padding: 40px;
    width: 100%;
    max-width: 450px;
    text-align: left; /* 整体左对齐 */
}

.login-box h1 {
    color: #2c3e50;
    margin-bottom: 30px;
    font-size: 28px;
    text-align: center; /* 标题居中 */
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #2c3e50;
    /* 标签左对齐 */
    text-align: left;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 16px;
    transition: border 0.3s;
    /* 输入框左对齐 */
    text-align: left;
}

.form-group input:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

/* 登录按钮居中 */
.login-btn-container {
    display: flex;
    justify-content: center; /* 按钮居中 */
    margin-top: 20px;
}

.login-btn {
    width: 50%; /* 适当宽度 */
    padding: 12px;
    background: #3498db;
    font-size: 16px;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s;
}

.login-btn:hover {
    background: #2980b9;
}

/* 侧边栏底部退出按钮 */
.logout-container {
    flex-shrink: 0;                /* 始终固定在底部，不被列表覆盖 */
    padding: 12px 20px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    background: rgba(0,0,0,0.15);
}

.logout-btn {
    display: block;
    padding: 13px 25px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    text-decoration: none;
    transition: all 0.3s;
    font-size: 16px;
    border-radius: 6px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.logout-btn:hover {
    background: rgba(231, 76, 60, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.logout-btn .icon {
    margin-right: 8px;
}



/* 页面顶部说明文字（复用于 rules/activity 页） */
.page-desc {
    padding: 15px 30px;
    margin: 0;
    color: #555;
    background: #f8f9fa;
    border-bottom: 1px solid #eaeaea;
    font-size: 14px;
    line-height: 1.6;
}
.page-desc strong { color: #2c3e50; }

/* ============================================================
   活动管理页
   ============================================================ */

/* ---- 添加新活动面板 ---- */
.add-panel {
    margin: 25px 30px;
    background: #fff;
    border: 1px solid #eaeaea;
    border-radius: 12px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}
.add-panel .panel-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 24px;
    background: linear-gradient(90deg, #3498db, #2ecc71);
    color: #fff;
    font-size: 18px;
    font-weight: 600;
}
.add-panel .panel-body { padding: 24px; }

.add-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px 24px;
}
@media (max-width: 768px) {
    .add-fields { grid-template-columns: 1fr; }
}
.field label {
    display: block;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 14px;
}
.field input,
.field select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ced4da;
    border-radius: 8px;
    font-size: 15px;
    background: #fff;
    transition: border 0.25s, box-shadow 0.25s;
}
.field input:focus,
.field select:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.18);
}

.calc-desc {
    margin: 18px 0 0;
    color: #5a6b7b;
    font-size: 14px;
    line-height: 1.7;
    padding: 14px 18px;
    background: #f1f8ff;
    border-left: 4px solid #3498db;
    border-radius: 6px;
}

.add-panel .panel-foot {
    margin-top: 22px;
    display: flex;
    justify-content: flex-end;
}

/* ---- 活动卡片网格 ---- */
.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 30px 30px 4px;
    font-size: 20px;
    font-weight: 600;
    color: #2c3e50;
}
.section-title .count {
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    background: #3498db;
    border-radius: 20px;
    padding: 2px 12px;
}

.activity-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
    padding: 18px 30px 40px;
}

.activity-card {
    position: relative;
    background: #fff;
    border: 1px solid #eaeaea;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    padding: 22px 22px 18px;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s;
    border-top: 4px solid #3498db;
}
.activity-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.1);
}

.activity-card .card-name {
    font-size: 19px;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 12px;
    padding-right: 30px; /* 给右上角删除按钮留位 */
}

.activity-card .card-badge {
    display: inline-block;
    align-self: flex-start;
    background: #eaf4fc;
    color: #2980b9;
    font-size: 13px;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 20px;
    margin-bottom: 14px;
}

.activity-card .card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
    color: #7f8c8d;
}
.activity-card .card-meta .meta-label { color: #95a5a6; }
.activity-card .tag {
    background: #f0f2f5;
    color: #556;
    border-radius: 5px;
    padding: 3px 9px;
    font-size: 12px;
    font-weight: 500;
}

.activity-card .card-date {
    font-size: 12px;
    color: #b0b8c0;
    margin-bottom: 16px;
}

.activity-card .card-actions {
    display: flex;
    gap: 10px;
    margin-top: auto;
}
.activity-card .card-actions .btn {
    flex: 1;
    justify-content: center;
    padding: 9px 0;
    font-size: 14px;
}

/* 右上角删除图标按钮 */
.card-delete {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: #f7f0f0;
    color: #c0392b;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
}
.card-delete:hover {
    background: #e74c3c;
    color: #fff;
    transform: scale(1.1);
}

/* 空状态 */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 50px 20px;
    color: #95a5a6;
    background: #fff;
    border: 1px dashed #d5dce2;
    border-radius: 12px;
}
.empty-state .big { font-size: 40px; margin-bottom: 10px; }

/* 去重开关 */
.dedup-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0 12px;
    font-size: 13px;
    color: #5a6b7b;
    cursor: pointer;
    user-select: none;
}
.dedup-check input {
    width: 16px;
    height: 16px;
    accent-color: #3498db;
    cursor: pointer;
}

/* 汇总栏中的和值项高亮 */
.summary-item.highlight-sum {
    background: linear-gradient(135deg, #eef6ff, #e3f0ff);
    border: 1px solid #cfe4fb;
}
.summary-item.highlight-sum .value { color: #2471c9; }

/* 统计类：无需规则提示 */
.norule-note {
    text-align: center;
    padding: 40px 20px;
    color: #5a6b7b;
}
.norule-note .big { font-size: 44px; margin-bottom: 12px; }
.norule-note p { margin: 6px 0; font-size: 15px; line-height: 1.7; }
.norule-note .btn { margin-top: 18px; display: inline-flex; }

/* ============================================================
   主题化自定义下拉组件 cn-select
   ============================================================ */
.cn-select { position: relative; width: 100%; }

.cn-select__trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 15px;
    border: 1px solid #ced4da;
    border-radius: 8px;
    background: #fff;
    font-size: 15px;
    color: #2c3e50;
    cursor: pointer;
    text-align: left;
    transition: border-color .2s, box-shadow .2s;
    font-family: inherit;
}
.cn-select__trigger:hover { border-color: #aebac6; }
.cn-select.is-open .cn-select__trigger,
.cn-select__trigger:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, .18);
}
.cn-select__value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cn-select__arrow {
    color: #7f8c8d;
    font-size: 12px;
    transition: transform .2s, color .2s;
    flex-shrink: 0;
}
.cn-select.is-open .cn-select__arrow { transform: rotate(180deg); color: #3498db; }

.cn-select__menu {
    position: absolute;
    z-index: 60;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e0e6ed;
    border-radius: 10px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .14);
    padding: 6px;
    max-height: 320px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity .18s ease, transform .18s ease, visibility .18s;
}
.cn-select.is-open .cn-select__menu { opacity: 1; visibility: visible; transform: translateY(0); }

.cn-select__option {
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: #34495e;
    line-height: 1.4;
    transition: background .15s, color .15s;
}
.cn-select__option.is-highlight { background: #eef6ff; color: #2471c9; }
.cn-select__option.is-selected {
    background: linear-gradient(to bottom, #3498db, #2980b9);
    color: #fff;
    font-weight: 600;
}
.cn-select__option.is-selected.is-highlight { background: #2980b9; }

.cn-select__menu::-webkit-scrollbar { width: 8px; }
.cn-select__menu::-webkit-scrollbar-track { background: transparent; }
.cn-select__menu::-webkit-scrollbar-thumb { background: #cdd8e2; border-radius: 4px; }
.cn-select__menu::-webkit-scrollbar-thumb:hover { background: #b4c2ce; }

/* 紧凑变体（分页每页显示） */
.cn-select--compact { width: auto; min-width: 92px; }
.cn-select--compact .cn-select__trigger { padding: 8px 12px; font-size: 14px; }
.cn-select--compact .cn-select__menu { min-width: 92px; }

/* ---- 主题化复选框（去重开关）---- */
.dedup-check input {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid #c3ccd5;
    border-radius: 5px;
    background: #fff;
    position: relative;
    cursor: pointer;
    transition: background .2s, border-color .2s;
    flex-shrink: 0;
}
.dedup-check input:hover { border-color: #3498db; }
.dedup-check input:checked { background: #3498db; border-color: #3498db; }
.dedup-check input:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 1px;
    width: 4px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.dedup-check input:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, .22);
}

/* ============================================================
   弹窗 modal
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 30, 40, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: opacity .22s ease, visibility .22s ease;
}
.modal-overlay.is-open { opacity: 1; visibility: visible; }

.modal {
    width: 100%;
    max-width: 520px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
    transform: translateY(24px) scale(.97);
    transition: transform .26s cubic-bezier(.2, .8, .3, 1);
}
.modal-overlay.is-open .modal { transform: translateY(0) scale(1); }

.modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    background: linear-gradient(90deg, #3498db, #2ecc71);
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    border-radius: 14px 14px 0 0;
}
.modal__head .icon { margin-right: 6px; }
.modal__close {
    background: rgba(255, 255, 255, .22);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s, transform .2s;
    flex-shrink: 0;
}
.modal__close:hover { background: rgba(255, 255, 255, .38); transform: rotate(90deg); }

.modal__body { padding: 24px; }
.modal__body .field + .field { margin-top: 18px; }
.modal__body .calc-desc { margin-bottom: 0; }

.modal__foot {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid #eef0f2;
}
.cancel-btn { background: #95a5a6; }
.cancel-btn:hover { background: #7f8c8d; }

@media (max-width: 560px) {
    .modal { max-width: 100%; }
}

/* 计算方式优缺点提示（规则配置页） */
.calc-tip {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 30px 4px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.6;
}
.calc-tip__icon { flex-shrink: 0; font-size: 16px; line-height: 1.4; }
.calc-tip--warn { background: #fff4e5; border: 1px solid #ffd9a8; color: #8a5300; }
.calc-tip--good { background: #e9f9ef; border: 1px solid #b6e6c7; color: #1c6b3c; }
.calc-tip--info { background: #eaf4fc; border: 1px solid #c3e0f7; color: #1f5f96; }

/* 活动卡片拖动手柄 */
.card-drag {
    position: absolute;
    top: 12px;
    left: 14px;
    cursor: grab;
    color: #c0c8d0;
    font-size: 17px;
    line-height: 1;
    padding: 3px 5px;
    border-radius: 5px;
    user-select: none;
    transition: color .15s, background .15s;
    letter-spacing: -1px;
}
.card-drag:hover { color: #3498db; background: #eef6ff; }
.card-drag:active { cursor: grabbing; }
.activity-card .card-name { padding-left: 26px; }   /* 给手柄让位 */
.activity-card.dragging {
    opacity: .55;
    box-shadow: 0 12px 28px rgba(0, 0, 0, .18);
    transform: scale(1.02);
}

/* ============================================================
   滚动条主题化（页面 / 文本框 / 表格 / 侧边栏）
   ============================================================ */
* {
    scrollbar-width: thin;
    scrollbar-color: #c6d0da transparent;   /* Firefox */
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: #c6d0da;
    border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover { background: #a9b6c4; }
::-webkit-scrollbar-corner { background: transparent; }

/* 文本框滚动条留点内边距更精致 */
.data-column textarea::-webkit-scrollbar-thumb,
.table-container::-webkit-scrollbar-thumb {
    background: #cbd5df;
    border: 2px solid transparent;
    background-clip: padding-box;
}
.data-column textarea::-webkit-scrollbar-thumb:hover,
.table-container::-webkit-scrollbar-thumb:hover {
    background: #aab8c6;
    border: 2px solid transparent;
    background-clip: padding-box;
}

/* 侧边栏深色滚动条 */
.sidebar ul { scrollbar-color: rgba(255,255,255,.22) transparent; }
.sidebar ul::-webkit-scrollbar { width: 8px; }
.sidebar ul::-webkit-scrollbar-track { background: transparent; }
.sidebar ul::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.18);
    border-radius: 4px;
}
.sidebar ul::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.36); }

/* 确认弹窗小尺寸 + 危险红色标题 */
.modal--sm { max-width: 420px; }
.modal__head--danger { background: linear-gradient(90deg, #e74c3c, #c0392b); }
