/* ── 基础重置 ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #f0f4f8;
    color: #1e293b;
    min-height: 100vh;
    padding-bottom: 2rem;
}
input, select, textarea, button { font-family: inherit; font-size: 1rem; }

/* ── 顶部 Header ── */
.header {
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    color: #fff;
    padding: 1rem 1.25rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.header-title {
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: .5rem;
}

/* ── 分类导航 ── */
.category-nav {
    display: flex;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 56px;
    z-index: 99;
}
.cat-btn {
    flex: 1;
    padding: .75rem;
    border: none;
    background: transparent;
    color: #64748b;
    font-weight: 600;
    font-size: .9rem;
    cursor: pointer;
    transition: all .2s;
    border-bottom: 3px solid transparent;
}
.cat-btn.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
    background: #eff6ff;
}

/* ── 子Tab导航 ── */
.sub-nav {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 108px;
    z-index: 98;
}
.sub-tabs {
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding: 0 .5rem;
    gap: .25rem;
}
.sub-tabs::-webkit-scrollbar { display: none; }
.sub-tabs.hidden { display: none; }
.sub-btn {
    flex-shrink: 0;
    padding: .5rem .75rem;
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: .85rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    transition: all .2s;
}
.sub-btn.active {
    color: #1e3a5f;
    border-bottom-color: #2563eb;
}

/* ── 内容区 ── */
.content { padding: 1rem; max-width: 640px; margin: 0 auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── 卡片 ── */
.card {
    background: #fff;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e3a5f;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.card-desc {
    color: #64748b;
    font-size: .875rem;
    margin-bottom: 1rem;
}

/* ── 表单 ── */
.form-group { margin-bottom: .875rem; }
.form-group label {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: .3rem;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: .65rem .75rem;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
    transition: border-color .2s;
    outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #2563eb;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

/* ── 按钮 ── */
.btn-primary {
    width: 100%;
    padding: .75rem;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: opacity .2s;
    margin-top: .5rem;
}
.btn-primary:active { opacity: .85; }
.btn-primary:disabled {
    background: #94a3b8;
    cursor: not-allowed;
}

/* ── 结果区 ── */
.result-box {
    margin-top: 1rem;
    padding: 1rem;
    background: #f0f9ff;
    border-radius: 10px;
    border: 1px solid #bae6fd;
}
.result-box.hidden { display: none; }
.result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .75rem;
}
.result-item {
    display: flex;
    flex-direction: column;
}
.result-item.highlight {
    grid-column: 1 / -1;
    background: #dbeafe;
    padding: .75rem;
    border-radius: 8px;
    text-align: center;
}
.result-label {
    font-size: .75rem;
    color: #64748b;
    margin-bottom: .15rem;
}
.result-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: #1e3a5f;
}
.result-item.highlight .result-value {
    font-size: 2rem;
    color: #1d4ed8;
}

/* ── CPA/CTR 判断结果 ── */
.cpa-verdict, .ctr-verdict, .roi-verdict { text-align: center; }
.verdict-badge {
    display: inline-block;
    padding: .5rem 1.5rem;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: .75rem;
}
.verdict-badge.green { background: #dcfce7; color: #166534; }
.verdict-badge.yellow { background: #fef9c3; color: #854d0e; }
.verdict-badge.red { background: #fee2e2; color: #991b1b; }
.verdict-badge.blue { background: #dbeafe; color: #1e40af; }
.verdict-badge.gray { background: #f1f5f9; color: #475569; }
.verdict-number {
    font-size: 2.5rem;
    font-weight: 800;
    margin: .5rem 0;
}
.verdict-number.green { color: #16a34a; }
.verdict-number.yellow { color: #ca8a04; }
.verdict-number.red { color: #dc2626; }
.verdict-number.blue { color: #2563eb; }
.verdict-suggestion {
    font-size: .9rem;
    color: #475569;
    margin-top: .5rem;
    line-height: 1.5;
}

/* ── 参考表 ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ref-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .8rem;
    min-width: 420px;
}
.ref-table th {
    background: #1e3a5f;
    color: #fff;
    padding: .5rem .4rem;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
}
.ref-table td {
    padding: .5rem .4rem;
    text-align: center;
    border-bottom: 1px solid #e2e8f0;
}
.ref-table tr:nth-child(even) { background: #f8fafc; }

/* 判断列颜色 */
.judge-green { color: #16a34a; font-weight: 700; }
.judge-orange { color: #ea580c; font-weight: 700; }
.judge-red { color: #dc2626; font-weight: 700; }

/* 品类参考表备注 */
.ref-note {
    margin-top: .75rem;
    padding: .75rem;
    background: #fefce8;
    border-left: 3px solid #ca8a04;
    border-radius: 0 8px 8px 0;
    font-size: .8rem;
    color: #854d0e;
    line-height: 1.6;
}

/* 结果占位符 */
.verdict-placeholder {
    color: #94a3b8;
    font-size: .875rem;
    text-align: center;
    padding: .5rem 0;
}

/* ── 提交状态 ── */
.submit-status {
    margin-top: .75rem;
    padding: .75rem;
    border-radius: 8px;
    font-size: .9rem;
    text-align: center;
}
.submit-status.hidden { display: none; }
.submit-status.success { background: #dcfce7; color: #166534; }
.submit-status.error { background: #fee2e2; color: #991b1b; }
.submit-status.loading { background: #f0f9ff; color: #1e40af; }

/* ── 隐藏工具类 ── */
.hidden { display: none !important; }

/* ── 桌面端适配 ── */
@media (min-width: 768px) {
    .content { padding: 1.5rem; }
    .result-grid { grid-template-columns: repeat(3, 1fr); }
    .ref-table { font-size: .875rem; }
}
