/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #f1f5f9;
    --border-input: #e2e8f0;
    --text: #1a1a2e;
    --text-secondary: #475569;
    --text-dim: #94a3b8;
    --accent: #1a73e8;
    --accent-hover: #1557b0;
    --green: #2e7d32;
    --green-bg: #e8f5e9;
    --red: #c62828;
    --orange-bg: #fff3e0;
    --orange: #e65100;
    --indigo: #283593;
    --indigo-bg: #e8eaf6;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,0.04);
}

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    font-size: 16px;
}

/* ===== PC 导航 ===== */
.pc-nav {
    display: none;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    height: 56px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}
.nav-logo { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.logo-img { height: 40px; width: auto; vertical-align: middle; margin: -6px 0; }
.pc-nav-tabs { display: flex; gap: 4px; }
.nav-tab {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
}
.nav-tab:hover { background: #e8f0fe; color: var(--accent); }
.nav-tab.active { background: #e8f0fe; color: var(--accent); font-weight: 600; }

/* ===== 用户区域 ===== */
.user-area { display: flex; align-items: center; }
.user-menu-link {
    display: flex; align-items: center; gap: 6px; text-decoration: none;
    padding: 4px 10px; border-radius: 20px; transition: background 0.15s;
}
.user-menu-link:hover { background: #f0f0f0; }
.user-avatar-img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; vertical-align: middle; }
.user-name { font-size: 13px; color: var(--text-secondary); }
.hidden { display: none !important; }

/* ===== 主内容区 ===== */
.app-main {
    max-width: 720px;
    margin: 0 auto;
    padding: 20px 16px;
}

/* ===== 手机端底部 Tab ===== */
.mobile-tab-bar {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 0 14px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
}
.tab-item {
    text-decoration: none;
    text-align: center;
    color: var(--text-dim);
    transition: color 0.2s;
}
.tab-item.active { color: var(--accent); }
.tab-icon { width: 22px; height: 22px; display: block; margin: 0 auto; }
.tab-label { font-size: 10px; margin-top: 2px; display: block; }

/* ===== 输入区 ===== */
.input-section { padding: 16px; }
.input-row { display: flex; gap: 12px; align-items: center; }
.input-row input {
    flex: 1; padding: 12px 16px; font-size: 1rem; font-family: inherit;
    border: 1.5px solid var(--border-input); border-radius: 12px; outline: none;
    transition: border-color 0.2s; background: var(--surface);
}
.input-row input:focus { border-color: var(--accent); }

.rule-section { margin-top: 14px; }
.rule-group {
    display: grid;
    grid-template-columns: 72px 24px repeat(6, 52px);
    gap: 8px;
    align-items: center;
}
.rule-group + .rule-group { margin-top: 8px; }
.rule-title { font-weight: 700; font-size: 0.95rem; color: var(--text-secondary); white-space: nowrap; }
.rule-tip { font-size: 0.85rem; color: var(--text-dim); cursor: help; }
.rule-radio {
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.9rem; cursor: pointer; padding: 6px 0;
    border: 1.5px solid var(--border-input); border-radius: 8px;
    transition: all 0.15s; user-select: none;
}
.rule-radio:hover { background: #e8f0fe; border-color: var(--accent); }
.rule-radio input[type="radio"] { cursor: pointer; }

/* ===== 按钮 ===== */
.btn-primary {
    padding: 12px 28px; font-size: 1rem; font-family: inherit;
    background: var(--accent); color: #fff; border: none;
    border-radius: 12px; cursor: pointer; transition: background 0.2s; white-space: nowrap;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { background: #e0e0e0; color: #999; cursor: not-allowed; }
.btn-shot {
    padding: 12px 14px; font-size: 13px; font-family: inherit;
    background: var(--surface); border: 1.5px solid var(--border-input);
    border-radius: 12px; cursor: pointer; color: #1e8e3e;
    transition: all 0.2s; white-space: nowrap; flex-shrink: 0;
}
.btn-shot:hover { border-color: var(--accent); color: var(--accent); background: #e8f0fe; }

.result-rule {
    text-align: left; color: var(--accent); font-size: 13px; font-weight: 600;
    margin-bottom: 10px;
}

.banner { margin-bottom: 4px; text-align: center; }
.banner img { max-width: 100%; max-height: 90px; height: auto; display: inline-block; border-radius: 8px; padding: 4px; background: #fff; }

/* ===== 卡片 ===== */
.result-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
}

/* ===== 表格 ===== */
.summary-table, .detail-table {
    width: 100%; border-collapse: collapse; table-layout: fixed;
}
.summary-table { font-size: 1.1rem; }
.summary-table th, .detail-table th {
    text-align: center; padding: 8px 6px; color: var(--text-secondary);
    font-weight: 700; border-bottom: 2px solid var(--border);
}
.summary-table td, .detail-table td {
    text-align: center; padding: 8px 6px; border-bottom: 1px solid var(--border); font-weight: 500;
}
.summary-table .label, .detail-table .label {
    text-align: left; color: var(--text-dim); font-weight: 700; font-size: 0.9rem; width: 70px;
}
.summary-table tr:last-child td, .detail-table tr:last-child td { border-bottom: none; }
.detail-table { font-size: 0.9rem; }
.table-wrapper { overflow-x: auto; }

.about-page h2 { font-size: 1.3rem; margin-bottom: 4px; }
.about-subtitle { color: var(--text-dim); font-size: 13px; margin-bottom: 20px; }
.about-page h3 { font-size: 15px; margin: 20px 0 8px; }
.about-page p { font-size: 14px; color: var(--text-secondary); line-height: 1.8; margin-bottom: 8px; }
.about-footer { text-align: center; padding: 12px; font-size: 13px; color: var(--text-dim); margin-top: 20px; }

/* ===== 加载 & 错误 ===== */
.loading { text-align: center; padding: 40px; }
.spinner {
    width: 40px; height: 40px; margin: 0 auto 16px;
    border: 3px solid rgba(26,115,232,0.2); border-top-color: var(--accent);
    border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-msg {
    margin-top: 12px; padding: 10px 14px; border-radius: var(--radius-sm);
    background: #fef2f2; color: var(--red); font-size: 0.95rem;
}

/* ===== 认证页面 ===== */
.auth-page {
    display: flex; justify-content: center; padding-top: 40px;
}
.auth-card {
    background: var(--surface); border-radius: var(--radius); padding: 32px 24px;
    width: 100%; max-width: 380px; border: 1.5px solid var(--border); box-shadow: var(--shadow);
}
.auth-header { text-align: center; margin-bottom: 24px; }
.auth-header h2 { font-size: 1.6rem; margin-bottom: 4px; }
.auth-subtitle { color: var(--text-dim); font-size: 14px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 13px; color: var(--text-secondary); font-weight: 600; }
.form-group input {
    padding: 10px 14px; border: 1.5px solid var(--border-input); border-radius: var(--radius-sm);
    font-size: 15px; font-family: inherit; outline: none;
}
.form-group input:focus { border-color: var(--accent); }
.auth-btn { width: 100%; margin-top: 4px; }
.auth-error {
    padding: 8px 12px; background: #fef2f2; color: var(--red);
    border-radius: var(--radius-sm); font-size: 13px;
}
.auth-switch { text-align: center; font-size: 14px; color: var(--text-secondary); margin-top: 16px; }
.auth-link { color: var(--accent); text-decoration: none; font-weight: 600; }
.auth-cancel-btn {
    width: 100%; padding: 10px; margin-top: 8px; font-size: 14px; font-family: inherit;
    background: none; border: none; color: var(--text-dim); cursor: pointer;
}
.auth-cancel-btn:hover { color: var(--text-secondary); }
.auth-hint {
    margin-top: 16px; padding: 12px; background: #f8fafc; border-radius: var(--radius-sm);
    font-size: 12px; color: var(--text-dim); text-align: center; line-height: 1.6;
}

/* ===== 战绩列表 ===== */
.records-header { margin-bottom: 12px; }
.records-header h2 { font-size: 1.3rem; }
.records-filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-select {
    flex: 1; padding: 10px 14px; border: 1.5px solid var(--border-input);
    border-radius: var(--radius-sm); font-size: 13px; font-family: inherit;
    background: var(--surface); color: var(--text-secondary); outline: none;
    appearance: none; -webkit-appearance: none;
}

/* ===== 战绩表格 ===== */
.records-table {
    width: 100%; border-collapse: collapse; font-size: 14px; table-layout: fixed;
    background: var(--surface); border-radius: var(--radius);
    overflow: hidden; border: 1.5px solid var(--border);
}
.records-table th {
    padding: 12px 10px; text-align: left; font-size: 12px;
    color: var(--text-dim); font-weight: 600; background: #f8fafc;
    border-bottom: 1px solid var(--border);
}
.records-table th:nth-child(1) { width: 14%; }
.records-table th:nth-child(2) { width: 28%; }
.records-table th:nth-child(3) { width: 8%; text-align: center; }
.records-table th:nth-child(4) { width: 9%; text-align: center; }
.records-table th:nth-child(5) { width: 9%; text-align: center; }
.records-table th:nth-child(6) { width: 8%; text-align: center; }
.records-table th:nth-child(7) { width: 16%; text-align: right; }

.record-row {
    cursor: pointer; transition: background 0.15s;
    border-bottom: 1px solid var(--border);
}
.record-row:last-child { border-bottom: none; }
.record-row:hover { background: #f8fafc; }
.record-row td {
    padding: 12px 10px; color: var(--text-secondary);
}
.record-row td:nth-child(3) { text-align: center; }
.record-row td:nth-child(3),
.record-row td:nth-child(4) { text-align: center; }
.record-row td:nth-child(5),
.record-row td:nth-child(6) { text-align: center; }
.record-row td:last-child { text-align: right; font-weight: 700; }

.pos-badge {
    display: inline-block; padding: 2px 10px; border-radius: 20px;
    font-size: 12px; font-weight: 700;
}
.pos-1 { background: var(--green-bg); color: var(--green); }
.pos-2 { background: var(--indigo-bg); color: var(--indigo); }
.pos-3 { background: var(--orange-bg); color: var(--orange); }
.pos-4 { background: #fce4ec; color: var(--red); }
td.score-positive { color: var(--green) !important; }
td.score-negative { color: var(--red) !important; }

.records-total td {
    padding: 8px 10px; font-weight: 600; font-size: 13px;
    border-bottom: 2px solid var(--accent);
    background: linear-gradient(to bottom, #f0f6ff, #f8fafc);
}
.records-total td:first-child { font-size: 13px; color: var(--accent); }
.records-total td:first-child { color: var(--text-dim); }
.records-total td:nth-child(2),
.records-total td:nth-child(3) { /* empty */ }
.records-total td:nth-child(5),
.records-total td:nth-child(6) { text-align: center; }
.records-total td:last-child { text-align: right; }

/* ===== 战绩详情 ===== */
.detail-topbar {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px;
}
.back-link {
    display: inline-flex; align-items: center; gap: 4px;
    color: var(--accent); text-decoration: none; font-size: 15px; font-weight: 500;
    padding: 6px 0; transition: opacity 0.2s;
}
.back-link:hover { opacity: 0.7; }
.btn-delete {
    background: none; border: 1px solid var(--red); color: var(--red);
    border-radius: 8px; padding: 6px 14px; font-size: 13px; cursor: pointer;
    font-family: inherit;
}
.detail-meta { font-size: 14px; color: var(--text-secondary); margin-bottom: 16px; }

/* ===== 分析页 Tab ===== */
.analysis-tabs {
    display: flex; gap: 6px; margin-bottom: 16px;
    background: var(--surface); border-radius: var(--radius);
    padding: 4px; border: 1.5px solid var(--border);
}
.a-tab {
    flex: 1; padding: 8px 0; font-size: 13px; font-family: inherit;
    border: none; border-radius: 11px; background: transparent;
    color: var(--text-dim); cursor: pointer; transition: all 0.2s;
}
.a-tab.active {
    background: var(--accent); color: #fff; font-weight: 600;
    box-shadow: 0 1px 3px rgba(26,115,232,0.3);
}
.a-tab-content.hidden { display: none; }
.rival-sort { display: flex; justify-content: flex-end; gap: 6px; margin-bottom: 12px; }
.sort-btn {
    padding: 4px 12px; font-size: 12px; font-family: inherit;
    border: 1.5px solid var(--border-input); border-radius: 16px;
    background: var(--surface); color: var(--text-dim); cursor: pointer;
    transition: all 0.15s;
}
.sort-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.rival-list { display: flex; flex-direction: column; gap: 8px; }

.trend-limit-row {
    display: flex; align-items: center; justify-content: flex-end; gap: 2px;
    font-size: 13px; color: var(--text-dim);
}
.limit-btn {
    width: 26px; height: 26px; border: none;
    border-radius: 50%; background: var(--border);
    color: var(--text-secondary); font-size: 15px; line-height: 1;
    font-family: inherit; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.limit-btn:hover { background: var(--accent); color: #fff; }
#trendLimitVal {
    font-weight: 600; color: var(--text); min-width: 28px; text-align: center;
    font-size: 14px;
}

/* ===== 分析页 ===== */
.stats-cards {
    display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 10px; margin-bottom: 16px;
}
.stat-card {
    background: var(--surface); border: 1.5px solid var(--border);
    border-radius: var(--radius); padding: 16px 10px; text-align: center;
    box-shadow: var(--shadow);
}
.stat-main { grid-column: span 2; }
.stat-pos { border: none; }
.stat-value { font-size: 26px; font-weight: 800; }
.stat-value.positive { color: var(--green); }
.stat-label { font-size: 12px; margin-top: 4px; color: inherit; opacity: 0.8; }
.chart-card {
    background: var(--surface); border: 1.5px solid var(--border);
    border-radius: var(--radius); padding: 20px; margin-bottom: 12px;
    box-shadow: var(--shadow);
}
#trendChart { max-height: 180px; }
#posChart { max-height: 220px; }
.chart-card h3 { font-size: 1rem; margin-bottom: 12px; color: var(--text-secondary); }


/* ===== 我的页面 ===== */
.me-page { text-align: center; padding-top: 24px; }
.me-header { margin-bottom: 24px; }
.me-avatar .user-avatar-img { width: 64px; height: 64px; }
.me-header h2 { font-size: 1.4rem; }
.me-header p { color: var(--text-dim); font-size: 14px; margin-top: 4px; }
.me-links { display: flex; flex-direction: column; gap: 10px; max-width: 320px; margin: 0 auto; }
.me-btn {
    padding: 14px; font-size: 15px; font-family: inherit;
    background: var(--surface); border: 1.5px solid var(--border);
    border-radius: var(--radius); cursor: pointer; color: var(--text-secondary);
    transition: all 0.2s; text-decoration: none; text-align: center; display: block;
}
.me-btn:hover { border-color: var(--accent); color: var(--accent); }
.me-btn-danger { color: var(--red); border-color: #fce4ec; }
.me-btn-danger:hover { background: #fef2f2; }

/* ===== 保存提示 ===== */
.save-toast {
    padding: 10px 16px; border-radius: var(--radius-sm); font-size: 13px;
    margin-bottom: 12px; text-align: center;
}
.save-toast.success { background: var(--green-bg); color: var(--green); }
.save-toast.warning { background: #fff8e1; color: #f57f17; }

.action-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.15); z-index: 200;
}
.action-sheet {
    position: fixed; background: var(--surface);
    border-radius: 16px; padding: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    min-width: 140px;
}
.action-btn {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; font-size: 14px; font-family: inherit;
    border: none; border-radius: 12px; cursor: pointer;
    background: none; color: var(--text); width: 100%;
    transition: background 0.15s;
}
.action-btn:hover { background: #f0f4ff; }
.action-btn::before { font-size: 16px; }
#btnViewDetail::before { content: '📋'; }
#btnAiReview::before { content: '🤖'; }

.empty-state {
    text-align: center; padding: 40px 20px; color: var(--text-dim); font-size: 14px;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .pc-nav-tabs { display: none; }
    .mobile-tab-bar { display: flex; }
    body { padding-bottom: 72px; }
    .app-main { padding: 12px 10px 80px; }
    .input-row { flex-direction: column; gap: 8px; }
    .input-row input { width: 100%; }
    .btn-primary { width: 100%; }
    .btn-shot { display: none; }
    .rule-group { grid-template-columns: 56px 16px repeat(6, 42px); gap: 2px; }
    .rule-title { font-size: 0.7rem; }
    .rule-radio { font-size: 0.65rem; padding: 4px 0; }
    .result-card { padding: 12px 8px; }
    .summary-table { font-size: 0.65rem; }
    .summary-table th, .summary-table td { padding: 4px 2px; white-space: nowrap; }
    .summary-table .label { width: 28px; font-size: 0.6rem; }
    .detail-table { font-size: 0.6rem; }
    .detail-table th, .detail-table td { padding: 3px 1px; white-space: nowrap; }
    .detail-table .label { width: 40px; font-size: 0.55rem; }
    .stats-cards { grid-template-columns: 1fr 1fr 1fr 1fr; }
    .stat-main { grid-column: span 2; }
    .stat-value { font-size: 20px; }
    .records-table { font-size: 10px; table-layout: auto; }
    .records-table th, .records-table td { padding: 6px 3px; }
    .record-row td:first-child { font-size: 9px; }
    .pos-badge { padding: 1px 5px; font-size: 9px; }
    .records-total td { font-size: 10px !important; padding: 6px 2px !important; }
}

@media (min-width: 769px) {
    .pc-nav { display: flex; }
    .mobile-tab-bar { display: none; }
    .stats-cards { grid-template-columns: repeat(4, 1fr); }
    .btn-shot { display: inline-flex; align-items: center; }
}


