/* ============================================
   全局样式
   ============================================ */
:root {
    --primary: #1a237e;
    --primary-light: #283593;
    --success: #2e7d32;
    --warning: #e65100;
    --danger: #c62828;
    --gray: #9E9E9E;
    --gray-light: #f5f7fa;
    --border: #e0e0e0;
    --radius: 10px;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --font: -apple-system, "Microsoft YaHei", Arial, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font);
    background: var(--gray-light);
    padding: 12px;
    color: #333;
}

.container { max-width: 1400px; margin: 0 auto; }

/* ============================================
   登录页
   ============================================ */
.login-box {
    max-width: 360px;
    margin: 80px auto;
    background: white;
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.login-box h1 { text-align: center; font-size: 24px; margin-bottom: 24px; }
.login-box input {
    width: 100%;
    padding: 12px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
}
.login-box button {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
}
.login-box .error { color: var(--danger); text-align: center; margin-bottom: 12px; }
.login-box .hint { text-align: center; margin-top: 12px; font-size: 12px; color: var(--gray); }

/* ============================================
   后台头部
   ============================================ */
.header {
    background: var(--primary);
    color: white;
    padding: 16px 24px;
    border-radius: var(--radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}
.header h1 { font-size: 20px; }
.header .user { font-size: 14px; opacity: 0.8; }
.header .user a { color: white; margin-left: 12px; opacity: 0.7; text-decoration: none; }
.header .user a:hover { opacity: 1; }

/* ============================================
   按钮
   ============================================ */
.btn {
    padding: 8px 18px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}
.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #1b5e20; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #bf360c; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b71c1c; }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline:hover { background: var(--gray-light); }
.btn-blue { background: #2196F3; color: white; }
.btn-blue:hover { background: #1976D2; }
.btn-orange { background: #ff9800; color: white; }
.btn-orange:hover { background: #f57c00; }
.btn-sm { padding: 4px 12px; font-size: 12px; }

.actions-bar {
    background: white;
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    box-shadow: var(--shadow);
}

/* ============================================
   消息
   ============================================ */
.message {
    padding: 10px 16px;
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 14px;
}
.message.success { background: #e8f5e9; color: var(--success); border: 1px solid #a5d6a7; }
.message.error { background: #ffebee; color: var(--danger); border: 1px solid #ef9a9a; }

/* ============================================
   统计卡片
   ============================================ */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}
.stat-card {
    background: white;
    padding: 12px 16px;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow);
}
.stat-card .num { font-size: 24px; font-weight: bold; color: var(--primary); }
.stat-card .label { font-size: 12px; color: var(--gray); margin-top: 2px; }

/* ============================================
   布局
   ============================================ */
.layout { display: grid; grid-template-columns: 280px 1fr; gap: 16px; }
@media (max-width: 768px) { .layout { grid-template-columns: 1fr; } }

/* ============================================
   侧边栏
   ============================================ */
.sidebar {
    background: white;
    border-radius: var(--radius);
    padding: 12px;
    max-height: 70vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}
.sidebar h3 { font-size: 14px; color: var(--gray); margin-bottom: 8px; }
.sidebar .match-item {
    padding: 6px 10px;
    margin: 2px 0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 3px solid transparent;
}
.sidebar .match-item:hover { background: #f0f2f5; }
.sidebar .match-item.active {
    background: #e8eaf6;
    border-left-color: var(--primary);
    font-weight: 600;
}
.sidebar .match-item .badge {
    font-size: 10px;
    padding: 1px 8px;
    border-radius: 10px;
}
.badge-draft { background: #fff3e0; color: #e65100; }
.badge-published { background: #e8f5e9; color: #2e7d32; }
.badge-compared { background: #e3f2fd; color: #0d47a1; }

/* ============================================
   主内容区
   ============================================ */
.main {
    background: white;
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}
.main .match-info {
    background: #f0f4f8;
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.match-info .home { color: #d32f2f; font-weight: bold; }
.match-info .away { color: #1976d2; font-weight: bold; }
.match-info .vs { color: #999; }

/* ============================================
   表单
   ============================================ */
.form-group { margin-bottom: 12px; }
.form-group label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 4px;
    color: #555;
}
.form-group textarea,
.form-group input,
.form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: var(--font);
}
.form-group textarea:focus,
.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary);
    outline: none;
}
.form-group textarea { min-height: 120px; resize: vertical; }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
}
.form-row .form-group { margin-bottom: 0; }

.prediction-box {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
    margin: 12px 0;
}
.prediction-box h4 { font-size: 14px; color: #333; margin-bottom: 10px; }

.btn-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.status-info {
    font-size: 13px;
    color: var(--gray);
    padding: 8px 12px;
    background: #f5f5f5;
    border-radius: 6px;
    margin-top: 10px;
}

/* ============================================
   批量发布
   ============================================ */
.draft-list {
    margin-top: 12px;
    padding: 12px;
    background: #fafafa;
    border-radius: 6px;
}
.draft-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
    font-size: 13px;
}
.draft-item input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }

/* ============================================
   赛果录入
   ============================================ */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
    background: white;
    border-radius: var(--radius);
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    align-items: center;
}
.filters label { font-size: 13px; color: #666; }
.filters select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    background: white;
}

.match-list { display: flex; flex-direction: column; gap: 10px; }

.match-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: var(--shadow);
}
.match-card.finished { border-left: 4px solid var(--success); }
.match-card.pending { border-left: 4px solid var(--warning); }

.match-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f0f0f0;
}
.match-code { font-weight: bold; font-size: 15px; color: #333; }
.match-code small { font-weight: normal; font-size: 12px; color: var(--gray); }
.match-league { font-size: 12px; color: var(--gray); background: #f0f0f0; padding: 1px 8px; border-radius: 10px; }

.match-teams {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    flex-wrap: wrap;
}
.team-home { color: #d32f2f; font-weight: bold; }
.team-away { color: #1976d2; font-weight: bold; }
.team-rank { font-size: 11px; color: var(--gray); }
.team-vs { color: var(--gray); font-size: 12px; }
.match-time { font-size: 12px; color: var(--gray); }

.status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
}
.status-pending { background: #FFF3E0; color: #E65100; }
.status-finished { background: #E8F5E9; color: #2E7D32; }

.result-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 8px;
    margin-top: 8px;
}
.result-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.result-field label {
    font-size: 11px;
    color: var(--gray);
    font-weight: 600;
    text-transform: uppercase;
}
.result-field select,
.result-field input {
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    width: 100%;
    background: white;
}

.field-crs .crs-input-group {
    display: flex;
    gap: 4px;
    align-items: center;
}
.field-crs .crs-input-group input {
    flex: 1;
    padding: 8px 10px;
    font-size: 16px;
    text-align: center;
    border: 2px solid var(--border);
    border-radius: 6px;
}
.field-crs .crs-input-group input:focus {
    border-color: var(--primary);
    outline: none;
}
.field-crs .crs-input-group input.error {
    border-color: var(--danger);
    background: #fff5f5;
}
.field-crs .crs-input-group .btn-save {
    padding: 8px 14px;
    background: var(--success);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 18px;
    cursor: pointer;
    min-width: 48px;
    min-height: 42px;
}
.field-crs .crs-hint {
    font-size: 11px;
    color: var(--gray);
    margin-top: 2px;
}
.field-crs .crs-hint .example {
    color: var(--primary);
    font-weight: bold;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 3px;
}
.field-crs .crs-hint .example:hover { background: #e8eaf6; }

.batch-actions {
    margin: 16px 0;
    padding: 12px;
    background: #e3f2fd;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.batch-actions .label { font-weight: bold; font-size: 13px; }

/* ============================================
   分页
   ============================================ */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 16px;
    flex-wrap: wrap;
}
.pagination .btn { min-width: 36px; text-align: center; }
.pagination .btn.active { background: var(--primary); color: white; }
.pagination .info { font-size: 13px; color: var(--gray); padding: 0 8px; }

/* ============================================
   前端样式
   ============================================ */
.front-container {
    max-width: 900px;
    margin: 0 auto;
}
.front-header {
    background: linear-gradient(135deg, var(--primary), #0d47a1);
    color: white;
    padding: 24px 30px;
    border-radius: var(--radius);
    margin-bottom: 20px;
}
.front-header h1 { font-size: 24px; }
.front-header p { opacity: 0.8; font-size: 14px; margin-top: 4px; }

/* ===== Header Logo 区域 ===== */
.logo-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.logo-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.site-logo {
    width: 30px;
    height: 30px;
    object-fit: contain;
    border-radius: 6px;
    flex-shrink: 0;
}
.site-title {
    font-family: 'Noto Sans SC', -apple-system, sans-serif;
    font-size: 17px;
    font-weight: 600;
    margin: 0;
    letter-spacing: 1px;
    color: #ffffff;
    white-space: nowrap;
}
.site-subtitle {
    font-family: 'Noto Sans SC', -apple-system, sans-serif;
    font-size: 10px;
    font-weight: 400;
    margin: 0;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
    transform: scale(0.85);
    transform-origin: center top;
}

/* ===== Toolbar 工具栏 ===== */
.front-toolbar {
    background: #ffffff;
    padding: 8px 12px;
    border-radius: 16px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.toolbar-left {
    display: flex;
    gap: 8px;
}
.toolbar-right {
    display: flex;
    gap: 8px;
}
.toolbar-left a,
.toolbar-right a {
    display: flex;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
}
.toolbar-left .calc-btn {
    background: linear-gradient(145deg, #1a237e, #0d47a1);
    color: #ffffff;
}
.toolbar-left .calc-btn:hover {
    transform: scale(1.02);
}
.toolbar-right .user-link {
    background: rgba(26, 35, 126, 0.08);
    color: #1a237e;
}
.toolbar-right .login-btn {
    background: rgba(198, 40, 40, 0.08);
    color: #c62828;
}
.toolbar-right .register-btn {
    background: linear-gradient(145deg, #c62828, #8b0000);
    color: #ffffff;
}

.front-list { display: flex; flex-direction: column; gap: 8px; }

.list-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    text-decoration: none;
    color: #333;
    transition: all 0.2s;
}
.list-item:hover {
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.list-item .code { font-weight: bold; color: #555; font-size: 14px; min-width: 70px; }
.list-item .teams { font-size: 15px; }
.list-item .teams .home { color: #d32f2f; }
.list-item .teams .away { color: #1976d2; }
.list-item .status { font-size: 13px; }

.badge-hit {
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    background: #e8f5e9;
    color: #2e7d32;
}
.badge-pending {
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    background: #fff3e0;
    color: #e65100;
}

.analysis-card {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}
.analysis-card .match-title { font-size: 18px; font-weight: bold; }
.analysis-card .match-meta { color: #666; font-size: 14px; margin-bottom: 8px; }
.analysis-card .match-teams {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 12px;
}
.analysis-card .match-teams .team-home { font-size: 18px; }
.analysis-card .match-teams .team-away { font-size: 18px; }

.prediction-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 8px;
    background: #f8f9fa;
    padding: 14px;
    border-radius: 8px;
    margin: 10px 0;
}
.prediction-item { text-align: center; }
.prediction-item .label { font-size: 11px; color: #999; }
.prediction-item .value { font-size: 17px; font-weight: bold; color: var(--primary); }
.prediction-item .value.hit { color: var(--success); }
.prediction-item .value.miss { color: var(--danger); }
.prediction-item .value.pending { color: var(--warning); }

.hit-summary {
    text-align: center;
    padding: 8px 0;
    font-weight: bold;
    font-size: 16px;
}
.waiting { text-align: center; padding: 8px 0; color: var(--gray); }

.analysis-content {
    font-size: 15px;
    line-height: 1.8;
    color: #444;
    white-space: pre-wrap;
    padding: 12px 0;
}
.analysis-author {
    font-size: 13px;
    color: #999;
    text-align: right;
    margin-top: 8px;
}

.back-link {
    display: inline-block;
    margin-top: 12px;
    color: #1976d2;
    text-decoration: none;
}
.back-link:hover { text-decoration: underline; }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray);
    font-size: 16px;
}
.empty-state .icon { font-size: 48px; margin-bottom: 8px; }

/* ============================================
   Toast 提示
   ============================================ */
.toast {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: var(--radius);
    color: white;
    z-index: 999;
    display: none;
    font-size: 14px;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ============================================
   复选框多选样式（移动端友好）
   ============================================ */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 0;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border: 1.5px solid #ddd;
    border-radius: 20px;
    background: white;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    touch-action: manipulation;
}

.checkbox-label:active {
    transform: scale(0.95);
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkbox-label span {
    padding: 2px 4px;
    color: #555;
}

/* 选中状态 */
.checkbox-label.active,
.checkbox-label:has(input:checked) {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(26, 35, 126, 0.3);
}

.checkbox-label.active span,
.checkbox-label:has(input:checked) span {
    color: white;
}

/* 比分特殊网格布局 */
.crs-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
}

.crs-grid .crs-item {
    justify-content: center;
    padding: 3px 6px;
    font-size: 12px;
    border-radius: 4px;
}

/* ============================================
   响应式
   ============================================ */
@media (max-width: 768px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar { max-height: 40vh; }
    .crs-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (max-width: 600px) {
    body { padding: 8px; }
    .header { padding: 12px 16px; flex-direction: column; text-align: center; }
    .header h1 { font-size: 16px; }
    .form-row { grid-template-columns: 1fr 1fr; }
    .result-fields { grid-template-columns: 1fr 1fr; }
    .field-crs { grid-column: span 2; }
    .list-item { grid-template-columns: 1fr; gap: 4px; text-align: center; }
    .prediction-grid { grid-template-columns: repeat(3, 1fr); }
    .stats { grid-template-columns: repeat(3, 1fr); }
    .front-header h1 { font-size: 18px; }
    .analysis-card { padding: 16px; }
    .filters { flex-direction: column; align-items: stretch; }
    .filters select { width: 100%; }
    .crs-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    .checkbox-label {
        padding: 6px 10px;
        font-size: 13px;
        border-radius: 18px;
    }
}

@media (max-width: 400px) {
    .result-fields { grid-template-columns: 1fr; }
    .field-crs { grid-column: span 1; }
    .stats { grid-template-columns: 1fr 1fr; }
    .crs-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .checkbox-label {
        padding: 4px 8px;
        font-size: 12px;
        border-radius: 14px;
    }
}