:root {
    /* 旧变量名保留（大量历史规则引用），取值统一指向 theme.css 的 45 规范令牌 */
    --color-primary: var(--brand);
    --color-secondary: var(--accent);
    --color-success: #168269;
    --color-warning: #b45309;
    --color-danger: #dc3545;
    --color-muted: var(--text-secondary);
    --card-radius: var(--radius);
    --card-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

body {
    background: var(--bg);
    color: var(--text);
}

/* 注：导航栏的定位/配色（深色侧栏）统一在 theme.css 的「深色侧栏导航」段管理，
   这里只保留滚动过渡；避免两处各写一套背景/边框互相打架 */
.topbar {
    transition: box-shadow 0.2s ease;
}

.topbar.is-scrolled {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}

.nav-shell {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 0;
}

.brand,
.nav-links a {
    color: #f9fafb;
    text-decoration: none;
}

.brand {
    font-weight: 700;
    font-size: 1.05rem;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 0;
    padding: 0.4rem;
    border: 0;
    background: transparent;
}

.nav-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: #fff;
}

.nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

/* 注：.page-shell padding-top 统一在 theme.css 管理：
   .topbar + main/page-shell { padding-top: 12px !important }
   这里只保留底部留白，避免与顶栏让位冲突 */
.page-shell {
    padding-bottom: 2rem;
}

.hero-card,
.card {
    background: #ffffff;
    border: 1px solid #e6ebed;
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    padding: 1.25rem;
}

.hero-card {
    margin-bottom: 1rem;
    display: grid;
    grid-template-columns: 1.2fr 0.9fr;
    gap: 1rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1.4fr;
    gap: 1rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
    margin-bottom: 1rem;
}

.stat-tile {
    background: #f8fafc;
    border: 1px solid #e6ebed;
    border-radius: 14px;
    padding: 1rem;
}

.stat-label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.stat-value {
    display: block;
    margin-top: 0.25rem;
    font-size: 1.8rem;
}

.section-header {
    margin-bottom: 1rem;
}

.section-header h2,
.section-header h1,
.card-subsection h3 {
    margin-bottom: 0.35rem;
}

.section-desc {
    color: var(--text-secondary);
    margin-bottom: 0;
}

.chart-box {
    width: 100%;
    height: 260px;
    margin-bottom: 0.75rem;
}

.chart-box-tall {
    height: 320px;
}

.table-wrap {
    overflow-x: auto;
}

.match-table {
    width: 100%;
}

.match-table thead th,
.compact-table thead th {
    background: var(--color-primary);
    color: #fff;
}

.match-table tbody tr:hover,
.compact-table tbody tr:hover {
    background: #eff6ff;
}

.compact-table th,
.compact-table td,
.match-table th,
.match-table td {
    white-space: nowrap;
    border-color: #e6ebed;
}

.analyze-link {
    margin-bottom: 0;
}

.placeholder-card {
    background: #ffffff;
    border: 1px dashed #cbd5e1;
    border-radius: 16px;
    padding: 1.5rem;
}

.report-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.report-kpis {
    padding-left: 1rem;
}

.report-advice {
    font-weight: 600;
}

.path-card {
    background: #f8fafc;
    border: 1px solid #e6ebed;
    border-radius: 12px;
    padding: 0.9rem;
    margin-bottom: 0.75rem;
}

.path-meta {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.path-chain {
    font-weight: 600;
}

.derivation-box {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 12px;
    padding: 1rem;
    overflow-x: auto;
    white-space: pre-wrap;
}

.notice {
    border-radius: 12px;
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
}

.notice.warn {
    background: #fff7ed;
    color: #9a3412;
}

.notice.success {
    background: #ecfdf3;
    color: #166534;
    border: 1px solid #86efac;
}

.notice.error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
}

.site-footer {
    color: var(--text-secondary);
    font-size: 0.92rem;
    padding: 1rem 0 2rem;
}

button,
[role="button"],
.button,
a[role="button"] {
    border-radius: 8px;
}

button:not(.secondary):not(.outline):not(.danger) {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

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

.danger {
    background: var(--color-danger);
    border-color: var(--color-danger);
    color: #fff;
}

.match-form {
    margin-top: 1rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.form-grid label {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    font-weight: 600;
}

.form-grid input,
.form-grid select {
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    box-shadow: none;
}

.form-grid input:focus,
.form-grid select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.field-error {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12) !important;
}

.form-error-text {
    color: #b91c1c;
    font-size: 0.92rem;
    margin-top: 0.85rem;
    min-height: 1.2rem;
}

.form-actions {
    margin-top: 1rem;
}

.input-with-action {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.75rem;
    align-items: center;
}

.small-button {
    white-space: nowrap;
    padding: 0.65rem 0.85rem;
    margin-bottom: 0;
}

.autocomplete-field {
    position: relative;
}

.autocomplete-list {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 10;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.12);
    padding: 0.25rem;
}

.autocomplete-list.visible {
    display: block;
}

.autocomplete-item {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    border: 0;
    border-radius: 8px;
    padding: 0.6rem 0.7rem;
    color: var(--text);
    margin: 0;
}

.autocomplete-item:hover {
    background: #eff6ff;
}

.inline-filter {
    margin-bottom: 1rem;
}

.league-group + .league-group {
    margin-top: 1.25rem;
}

.handicap-dialog article {
    min-width: min(560px, 92vw);
}

.dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.team-hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    border-radius: 20px;
    padding: 1.4rem;
    color: #fff;
    margin-bottom: 1rem;
    box-shadow: 0 14px 36px rgba(15, 23, 42, 0.12);
}

.league-theme-sweden {
    background: linear-gradient(135deg, #0f4aa8, #facc15);
}

.league-theme-norway {
    background: linear-gradient(135deg, #b91c1c, #1e3a8a);
}

.league-theme-default {
    background: linear-gradient(135deg, #334155, #64748b);
}

.team-hero h1 {
    color: #fff;
    margin-bottom: 0.25rem;
}

.team-hero-subtitle {
    margin: 0;
    color: rgba(255, 255, 255, 0.9);
}

.team-hero-meta {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.92);
    text-align: right;
}

.team-stats-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.9rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: #fff;
    border-radius: 16px;
    border: 1px solid #e6ebed;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
    padding: 1rem;
}

.team-detail-grid {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.team-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.match-detail-table tbody tr.expandable-row {
    cursor: pointer;
    transition: background 0.18s ease;
}

.match-detail-table tbody tr.expandable-row:hover {
    background: #f8fafc;
}

.match-detail-table tbody tr.expandable-row.is-open {
    background: #eff6ff;
}

.detail-row td {
    background: #f8fafc;
}

.detail-row-box {
    border-left: 4px solid #3b82f6;
    padding: 0.75rem 0.9rem;
    color: #475569;
}

.result-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 700;
}

.result-win {
    background: #dcfce7;
    color: #166534;
}

.result-draw {
    background: #fef3c7;
    color: #92400e;
}

.result-loss {
    background: #fee2e2;
    color: #b91c1c;
}

.graph-layout {
    display: grid;
    grid-template-columns: minmax(300px, 30%) minmax(0, 1fr);
    gap: 1rem;
}

.graph-sidebar {
    align-self: start;
    position: sticky;
    top: 1rem;
}

.graph-form {
    display: grid;
    gap: 0.9rem;
}

.graph-form label {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-weight: 600;
}

.graph-panel-section + .graph-panel-section {
    margin-top: 1.25rem;
}

.graph-chart {
    width: 100%;
    min-height: 760px;
    background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
    border-radius: 16px;
}

.graph-path-list {
    display: grid;
    gap: 0.75rem;
}

.graph-path-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.95rem;
    border: 1px solid #e6ebed;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
    margin: 0;
}

.graph-path-item:hover,
.graph-path-item.active {
    border-color: #3b82f6;
    box-shadow: 0 12px 28px rgba(59, 130, 246, 0.12);
}

.graph-path-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}

.graph-path-chain {
    font-weight: 700;
    color: #111827;
    margin-bottom: 0.35rem;
}

.graph-path-text {
    color: #475569;
    font-size: 0.92rem;
    line-height: 1.45;
}

.graph-result-box {
    background: #f8fafc;
    border: 1px solid #e6ebed;
    border-radius: 14px;
    padding: 1rem;
}

.result-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.65rem;
}

.signal-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 700;
}

.signal-badge.recommend {
    background: #dcfce7;
    color: #166534;
}

.signal-badge.neutral {
    background: #e6ebed;
    color: #374151;
}

.signal-badge.conflict {
    background: #ffedd5;
    color: #c2410c;
}

.result-advice {
    margin: 0.85rem 0;
    font-weight: 600;
}

.graph-derivation {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 12px;
    padding: 0.9rem;
    white-space: pre-wrap;
    min-height: 180px;
}

.hero-actions,
.quick-analyze-form {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.quick-analyze-card {
    background: #f8fafc;
    border: 1px solid #e6ebed;
    border-radius: var(--card-radius);
    padding: 1rem;
}

.quick-analyze-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.quick-analyze-form label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.reports-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.8fr);
    gap: 1rem;
}

.reports-toolbar {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
    align-items: end;
}

.reports-toolbar label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.report-summary-grid {
    grid-template-columns: 1fr;
}

.report-table tbody tr.clickable-row {
    cursor: pointer;
}

.expand-row-detail td {
    background: #f8fafc;
}

.inline-arrow-up {
    color: var(--color-success);
    font-weight: 700;
}

.inline-arrow-down {
    color: var(--color-danger);
    font-weight: 700;
}

.empty-state {
    display: grid;
    place-items: center;
    gap: 0.5rem;
    min-height: 180px;
    color: var(--color-muted);
    text-align: center;
}

.empty-state-icon {
    font-size: 2rem;
}

.global-loading {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: grid;
    place-items: center;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(2px);
}

.loading-spinner {
    width: 42px;
    height: 42px;
    border: 4px solid #dbeafe;
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.toast-container {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 400;
    display: grid;
    gap: 0.6rem;
}

.toast {
    min-width: 220px;
    max-width: 380px;
    background: #fff;
    border-left: 4px solid var(--color-primary);
    border-radius: 8px;
    box-shadow: var(--card-shadow);
    padding: 0.85rem 1rem;
}

.toast.error {
    border-left-color: var(--color-danger);
}

.toast.success {
    border-left-color: var(--color-success);
}

.toast.out { opacity: 0; transform: translateY(6px); }
.toast { transition: opacity .3s ease, transform .3s ease; }

.match-detail-modal article.modal-shell {
    min-width: min(1000px, 95vw);
}

/* === 竞彩模块专用样式 === */
.jingcai-grid {
    display: grid;
    /* 用 fr 而非百分比：百分比 + gap 会超过 100% 导致整页横溢 */
    grid-template-columns: 2fr 3fr;
    gap: 1.25rem;
}
@media (max-width: 980px) {
    .jingcai-grid { grid-template-columns: 1fr; }
}
.jingcai-input,
.jingcai-list { background: #fff; border-radius: 8px; padding: 1.1rem; box-shadow: var(--card-shadow); }

.subtle { color: var(--color-muted); font-weight: 400; font-size: 0.9em; }
/* 旧 section-header 样式保留用于卡片内部子头（与外部 page-header 不冲突）；
   页头（顶栏级）一律使用 .page-header，不套 .section-header */
.section-header {
    display: flex; justify-content: space-between; align-items: center;
    gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.section-desc { color: var(--color-muted); font-size: 0.9rem; margin-top: 2px; }

.stack { display: grid; gap: 0.85rem; }
.row { display: flex; align-items: center; }
.flex-wrap { flex-wrap: wrap; }

.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px; background: #eef2f7; color: var(--text);
    border-radius: 999px; font-size: 0.88rem;
}
.chip.primary { background: var(--color-primary); color: #fff; }
.chip.neutral { background: #fde68a; color: #78350f; }
.chip.info { background: #dbeafe; color: #1e3a8a; }
.chip.danger { background: #fee2e2; color: #7f1d1d; }

.open-modal { cursor: pointer; }
.jingcai-modal article.modal-shell {
    min-width: min(1080px, 96vw);
    max-width: 96vw;
}
.jingcai-modal article.modal-shell.wide { min-width: min(1100px, 96vw); }
.jingcai-modal article.modal-shell.deep { max-height: 90vh; display: flex; flex-direction: column; }
.jingcai-modal .modal-body { overflow-y: auto; }

.wide td, .dense th, .dense td { padding: 8px 10px !important; font-size: 0.92rem; }

/* 拖拽上传 */
.dropzone {
    border: 2px dashed #cbd5e1; border-radius: 10px;
    padding: 18px; text-align: center; cursor: pointer;
    background: #fafbfc;
}
.dropzone:hover { border-color: var(--color-primary); background: #f1f5fb; }
.file-list { list-style: none; padding: 0; margin-top: 10px; text-align: left; }
.file-list li {
    font-size: 0.85rem; padding: 4px 8px;
    background: #fff; border-radius: 6px; margin-top: 4px;
}

.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th { background: #f0f3f7; font-weight: 600; text-align: left; }
.data-table th, .data-table td { border-bottom: 1px solid #eef0f3; padding: 10px 12px; vertical-align: middle; }
.data-table input, .data-table select {
    padding: 4px 6px; font-size: 0.9rem; margin: 0;
}

.small-button {
    padding: 3px 10px; font-size: 0.82rem; border-radius: 6px;
}
.small-button.outline.danger {
    color: #b91c1c; border-color: #fca5a5;
}
.small-button.outline.danger:hover { background: #fef2f2; }

.data-table td > input,
.data-table td > .row > input {
    width: 100%;
}
.data-table td .row { gap: 4px; }

.placeholder-card {
    padding: 16px; border-radius: 8px; background: #f8fafc;
    color: #475569; border: 1px dashed #cbd5e1; text-align: center;
}

.nav-links a.active {
    color: var(--color-secondary);
    border-bottom: 2px solid var(--color-secondary);
    padding-bottom: 2px;
}


.modal-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.modal-body {
    display: grid;
    gap: 1rem;
}

.modal-compare-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.signal-badge.recommend {
    background: var(--color-success);
    color: #fff;
}

.signal-badge.neutral {
    background: #d1d5db;
    color: #374151;
}

.signal-badge.conflict {
    background: #f59e0b;
    color: #fff;
}

.clickable-row {
    cursor: pointer;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 900px) {
    .dashboard-grid,
    .report-grid,
    .team-detail-grid,
    .graph-layout,
    .reports-layout,
    .hero-card {
        grid-template-columns: 1fr;
    }

    .nav-shell {
        align-items: center;
        flex-wrap: wrap;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .input-with-action {
        grid-template-columns: 1fr;
    }

    .team-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .team-hero {
        flex-direction: column;
        align-items: flex-start;
    }

    .team-hero-meta {
        text-align: left;
    }

    .graph-sidebar {
        position: static;
    }

    .graph-chart {
        min-height: 520px;
    }

    .reports-toolbar,
    .quick-analyze-form,
    .modal-compare-grid {
        grid-template-columns: 1fr;
    }

    .nav-toggle {
        display: flex;
    }

    .nav-links {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        background: var(--color-primary);
        padding-top: 0.5rem;
    }

    .nav-links.open {
        display: flex;
    }
}
