html,
body {
    max-width: 100%;
    overflow-x: hidden;
}
        
/* 表格基础样式 */
table {
    width: 100%;
}

@media (min-width: 768px) {
    /* 桌面端表格修复 */
    table {
        display: table;
        white-space: normal;
        table-layout: fixed;
    }

    /* 移除桌面端不必要的水平滚动 */
    .overflow-x-auto {
        overflow-x: visible;
    }

    /* comparison表格列宽 */
    #comparison table th:nth-child(1),
    #comparison table td:nth-child(1) {
        width: 20%;
    }
    #comparison table th:nth-child(2),
    #comparison table td:nth-child(2) {
        width: 15%;
    }
    #comparison table th:nth-child(3),
    #comparison table td:nth-child(3) {
        width: 20%;
    }
    #comparison table th:nth-child(4),
    #comparison table td:nth-child(4) {
        width: 10%;
    }
    #comparison table th:nth-child(5),
    #comparison table td:nth-child(5) {
        width: 35%;
    }

    /* breakdown表格列宽 */
    details table th:nth-child(1),
    details table td:nth-child(1) {
        width: 8%;
    }
    details table th:nth-child(2),
    details table td:nth-child(2) {
        width: 18%;
    }
    details table th:nth-child(3),
    details table td:nth-child(3) {
        width: 20%;
    }
    details table th:nth-child(4),
    details table td:nth-child(4) {
        width: 18%;
    }
    details table th:nth-child(5),
    details table td:nth-child(5) {
        width: 36%;
    }
}

/* 移动端优化 */
@media (max-width: 768px) {
    /* 主容器 */
    main.max-w-7xl {
        max-width: 100%;
        padding: 1.5rem 0.75rem;
    }

    /* 标题 */
    .text-3xl.sm\:text-5xl {
        font-size: 1.75rem !important;
        line-height: 2.25rem;
    }

    /* 卡片 */
    .glass-card {
        padding: 1rem !important;
    }

    /* 输入框 */
    input,
    select {
        font-size: 16px !important;
    }

    /* 图表 */
    .h-\[350px\] {
        height: 250px !important;
    }

    /* AI顾问区域 */
    .rounded-\[2\.5rem\] {
        border-radius: 1.5rem !important;
        padding: 1.5rem !important;
    }

    /* 移动端表格换行处理 */
    table {
        display: table;
        white-space: normal !important; /* 允许换行 */
        font-size: 0.75rem;
    }

    th,
    td {
        word-wrap: break-word;
        word-break: break-word;
        overflow-wrap: break-word;
        white-space: normal !important;
        padding: 0.4rem 0.3rem !important;
    }

    /* 比较表格特定优化 */
    #comparison table {
        font-size: 0.7rem;
    }

    #comparison table th {
        font-size: 0.65rem;
        text-transform: uppercase;
        background-color: #f8fafc;
        font-weight: 600;
    }

    .plan-badge {
        display: inline-block;
        padding: 0.2rem 0.5rem;
        font-size: 0.65rem;
        border-radius: 0.2rem;
        font-weight: 600;
        margin-bottom: 0.2rem;
    }

    /* 处理Term列的长文本 */
    #comparison table td:nth-child(5) {
        min-width: 120px; /* 给Term列最小宽度保证可读性 */
    }
}

/* 小屏幕手机 */
@media (max-width: 640px) {
    main {
        padding: 1rem 0.5rem !important;
    }
    .text-3xl.sm\:text-5xl {
        font-size: 1.5rem !important;
    }
    .px-5.py-3 {
        padding: 0.5rem 0.75rem !important;
    }
    .prose.prose-slate {
        font-size: 0.875rem;
    }

    /* 进一步优化表格 */
    table {
        font-size: 0.65rem;
    }

    th,
    td {
        padding: 0.35rem 0.25rem !important;
    }

    #comparison table th {
        font-size: 0.6rem;
    }

    .plan-badge {
        font-size: 0.6rem;
        padding: 0.15rem 0.4rem;
    }

    #comparison table td:nth-child(5) {
        min-width: 100px;
    }
}