/* 移除了原来的 @import 语句，改为在 HTML 中更高效地加载 */

:root {
    --background: #ffffff;
    --foreground: #0f172a;
    --secondary: #f1f5f9;
    --secondary-foreground: #0f172a;
    --muted: #f1f5f9;
    --muted-foreground: #64748b;
    --accent: #f1f5f9;
    --accent-foreground: #0f172a;
    --destructive: #ef4444;
    --border: #e2e8f0;
    --input: #e2e8f0;
    --ring: #0f172a;
    --primary: #0f172a;
    --primary-foreground: #ffffff;
    --radius: 0.5rem;
}

.dark {
    --background: #020617;
    --foreground: #f8fafc;
    --secondary: #1e293b;
    --secondary-foreground: #f8fafc;
    --muted: #1e293b;
    --muted-foreground: #94a3b8;
    --accent: #1e293b;
    --accent-foreground: #f8fafc;
    --destructive: #7f1d1d;
    --border: #1e293b;
    --input: #1e293b;
    --ring: #cbd5e1;
    --primary: #f8fafc;
    --primary-foreground: #020617;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--muted-foreground);
}

/* Table Sticky Styles */
/* Header Sticky */
th.sticky-header {
    position: sticky;
    top: 0;
    z-index: 10;
    /* 使用纯色背景，确保完全不透明 */
    background-color: var(--background);
    /* 移除可能导致透明的rgba设置 */
    box-shadow: 0 1px 0 var(--border);
}

/* Column Sticky */
td.sticky-col,
th.sticky-col {
    position: sticky;
    left: 0;
    z-index: 5;
    /* Lower than header */
    background-color: var(--background);
    border-right: 1px solid var(--border) !important;
    /* 只保留右边框，避免边框叠加 */
    /* 添加内部阴影确保边框显示 */
    text-align: center;
    vertical-align: middle;
}

/* Corner Sticky (Intersection of Header and First Col) */
th.sticky-col.sticky-header {
    z-index: 20;
    /* Highest */
    border-right: 1px solid var(--border) !important;
    /* 只保留右边框，避免边框叠加 */
    /* 添加内部阴影确保边框显示 */
    text-align: center;
    vertical-align: middle;
}

/* Sticky Offset Logic - Handled via JS usually, but basic first col is simple */
.sticky-col-1 {
    left: 0;
}

/* Toast Animation */
@keyframes slideIn {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

.toast {
    animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.exiting {
    animation: fadeOut 0.3s forwards;
}

/* Interactive Elements */
.sheet-item {
    transition: all 0.2s ease;
}

.sheet-item.active {
    background-color: var(--secondary);
    color: var(--foreground);
    font-weight: 500;
    border-left: 3px solid var(--primary);
}

/* Drag over effect */
body.drag-over::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(2px);
    z-index: 9999;
    pointer-events: none;
    border: 4px dashed var(--primary);
}

/* 参数值样式 */
.param-value {
    margin-right: 2px;
    white-space: nowrap;
    display: inline-block;
}

#compare-dialog-content .param-value {
    white-space: nowrap;
    display: inline-block;
}

/* 平均值特殊颜色标注 */
.average-value {
    color: #e91e63;
    font-weight: bold;
}

/* 选中行样式 */
.row-selected {
    font-weight: 500;
}

/* 对比弹窗表格样式 */
#compare-dialog-content table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    border: 1px solid var(--border);
    /* 添加边框以明确表格范围 */
    table-layout: auto;
    /* 允许表格根据内容自适应列宽 */
    font-size: 0.8rem;
    /* 设置较小的字体大小 */
    min-width: max-content;
    /* 确保表格至少适应其内容，允许水平滚动 */
}

/* 对比弹窗表格容器 */
.compare-table-container {
    /* 启用垂直滚动以显示全部内容 */
    overflow-y: auto;
    overflow-x: auto;
    height: auto;
    /* 限制容器最大高度，确保分页效果 */
    max-height: calc(70vh - 150px);
    /* 调整容器高度以适应小屏幕 */
    /* 确保最小高度以适应内容 */
    min-height: 300px;
    /* 调整最小高度以适应小屏幕 */
    /* 添加过渡效果以减少切换时的闪烁 */
    transition: opacity 0.2s ease-in-out;
    /* 确保内容完整显示 */
    display: flex;
    flex-direction: column;
    /* 添加滚动条样式 */
    scrollbar-width: thin;
    scrollbar-color: var(--border) var(--background);
}

/* 响应式设计：针对小屏幕的样式调整 */
@media (max-width: 768px) {
    body {
        font-size: 0.875rem;
        /* 减小基础字体大小 */
    }

    /* 调整主表字体大小 */
    #data-table {
        font-size: 0.75rem;
    }

    #data-table th,
    #data-table td {
        padding: 0.5rem;
        max-width: 150px;
        /* 限制单元格最大宽度，便于移动设备显示 */
    }

    /* 调整工具栏字体大小 */
    header {
        padding: 0.5rem;
    }

    /* 调整搜索输入框字体大小 */
    #search-input {
        font-size: 0.875rem;
        padding: 0.5rem 1rem 0.5rem 2rem;
    }

    /* 调整按钮字体大小 */
    button {
        font-size: 0.75rem;
        padding: 0.5rem;
    }

    /* 调整侧边栏字体大小 */
    #sidebar {
        width: 200px;
    }

    .sheet-item {
        font-size: 0.8rem;
        padding: 0.5rem;
    }

    /* 调整对比弹窗的字体大小 */
    #compare-dialog .bg-background {
        width: 95vw;
        min-width: 300px;
        /* 调整最小宽度以适应小屏幕 */
        max-width: 95vw;
        margin: auto;
        /* 保持居中 */
    }

    #compare-dialog-content {
        padding: 1rem;
        overflow-x: auto;
        /* 确保在小屏幕上表格可以横向滚动 */
    }

    #compare-dialog-content table {
        font-size: 0.75rem;
        min-width: 100%;
        /* 确保表格至少占据容器宽度 */
    }

    #compare-dialog-content th,
    #compare-dialog-content td {
        padding: 0.5rem 0.5rem;
        min-width: 60px;
        /* 调整最小宽度以适应小屏幕 */
        max-width: 100px;
        /* 限制最大宽度 */
        overflow: hidden;
        /* 隐藏超出的内容 */
        text-overflow: ellipsis;
        /* 超出时显示省略号 */
    }

    /* 确保表头（参数名称）不换行 */
    #compare-dialog-content th {
        white-space: nowrap;
    }

    /* 允许数据单元格换行 */
    #compare-dialog-content td {
        white-space: normal;
        word-break: break-word;
        /* 允许长文本换行 */
    }

    /* 调整对比弹窗的表头 */
    #compare-dialog-content th {
        font-size: 0.75rem;
        padding: 0.5rem;
        min-width: 70px;
        /* 调整表头最小宽度 */
        max-width: 120px;
        /* 限制表头最大宽度 */
    }

    /* 调整对比弹窗的分页控件 */
    .pagination-controls {
        margin-top: 0.5rem;
        gap: 0.5rem;
        flex-wrap: wrap;
        /* 在小屏幕上允许分页控件换行 */
    }

    /* 调整页脚分页控件 */
    footer {
        padding: 0.5rem 1rem;
        height: auto;
        min-height: 40px;
        flex-direction: column;
        /* 在小屏幕上垂直排列元素 */
    }

    #pagination-info {
        font-size: 0.75rem;
        margin-bottom: 0.5rem;
    }

    #page-indicator {
        font-size: 0.875rem;
    }

    /* 调整移动端菜单 */
    #actions-menu {
        width: 200px;
        font-size: 0.8rem;
    }

    /* 确保对比弹窗表格容器在小屏幕上表现良好 */
    .compare-table-container {
        max-height: calc(70vh - 150px);
        /* 在小屏幕上为弹窗头部和分页控件留出更多空间 */
        min-height: 250px;
        /* 确保最小高度以显示内容 */
    }
}

/* 针对更小屏幕（如手机）的额外优化 */
@media (max-width: 480px) {
    body {
        font-size: 0.8rem;
    }

    #data-table {
        font-size: 0.7rem;
    }

    #data-table th,
    #data-table td {
        padding: 0.25rem;
        max-width: 120px;
    }

    /* 进一步减小侧边栏 */
    #sidebar {
        width: 180px;
    }

    .sheet-item {
        font-size: 0.75rem;
        padding: 0.25rem;
    }

    /* 针对非常小的屏幕优化对比弹窗 */
    #compare-dialog .bg-background {
        width: 98vw;
        min-width: 300px;
        /* 调整最小宽度以适应小屏幕 */
        max-width: 98vw;
        margin: auto;
        /* 保持居中 */
    }

    #compare-dialog-content {
        padding: 0.5rem;
    }

    #compare-dialog-content table {
        font-size: 0.65rem;
        min-width: 100%;
        table-layout: auto;
        /* 确保表格可以自适应列宽 */
    }

    #compare-dialog-content th,
    #compare-dialog-content td {
        padding: 0.25rem;
        min-width: 35px;
        /* 进一步减小最小宽度以适应小屏幕 */
        max-width: 70px;
        /* 限制最大宽度 */
        overflow: hidden;
        /* 隐藏超出的内容 */
        text-overflow: ellipsis;
        /* 超出时显示省略号 */
    }

    /* 确保表头（参数名称）不换行 */
    #compare-dialog-content th {
        white-space: nowrap;
    }

    /* 允许数据单元格换行 */
    #compare-dialog-content td {
        white-space: normal;
        word-break: break-word;
        /* 允许长单词换行 */
    }

    #compare-dialog-content th {
        font-size: 0.7rem;
        min-width: 45px;
        /* 调整表头最小宽度 */
        max-width: 90px;
        /* 限制表头最大宽度 */
    }

    /* 对比弹窗表格容器进一步优化 */
    .compare-table-container {
        max-height: calc(65vh - 120px);
        min-height: 200px;
        /* 在小屏幕上也需要最小高度 */
    }

    /* 工具栏更紧凑 */
    header {
        padding: 0.25rem;
    }

    /* 按钮更小 */
    button {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }

    /* 搜索输入框更紧凑 */
    #search-input {
        font-size: 0.8rem;
        padding: 0.25rem 0.5rem 0.25rem 1.5rem;
    }

    /* 页脚更紧凑 */
    footer {
        padding: 0.25rem 0.5rem;
        min-height: 35px;
    }

    #pagination-info {
        font-size: 0.7rem;
        margin-bottom: 0.25rem;
    }

    #page-indicator {
        font-size: 0.8rem;
    }

    /* 移动端菜单更紧凑 */
    #actions-menu {
        width: 180px;
        font-size: 0.75rem;
    }

    /* 优化对比弹窗中的滚动条显示 */
    #compare-dialog-content {
        overflow-x: auto;
    }

    /* 优化参数值显示 */
    .param-value {
        font-size: 0.6rem;
    }

    /* 优化对比弹窗中的参数值显示 */
    #compare-dialog-content .param-value {
        font-size: 0.55rem;
        display: inline-block;
        max-width: 50px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* 针对超小屏幕的进一步优化 */
    #compare-dialog .bg-background {
        margin-top: 10px;
    }
}

/* ==================== 手机端响应式适配增强 ==================== */

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {

    /* 增大触摸目标 */
    .sheet-item {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    button,
    [role="button"],
    input[type="checkbox"],
    input[type="radio"] {
        min-height: 44px;
        min-width: 44px;
    }

    /* 移除悬停效果，使用激活效果 */
    .sheet-item:hover {
        background-color: transparent;
    }

    .sheet-item:active {
        background-color: var(--secondary);
    }

    /* 表格行触摸反馈 */
    #data-table tbody tr:active {
        background-color: var(--accent);
    }
}

/* 小屏幕布局优化 */
@media (max-width: 640px) {

    /* 侧边栏全屏显示 */
    #sidebar {
        width: 85vw;
        max-width: 320px;
    }

    /* 主内容区域调整 */
    main {
        width: 100vw;
    }

    /* 工具栏紧凑布局 */
    header .relative.mt-3 {
        margin-top: 0.5rem;
    }

    /* 搜索框和按钮布局 */
    header .relative.mt-3.flex {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    #search-input {
        flex: 1;
        min-width: 0;
    }

    #search-mode-btn {
        flex-shrink: 0;
    }

    /* 表格横向滚动优化 */
    #table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    #data-table {
        min-width: 100%;
        font-size: 0.75rem;
    }

    #data-table th,
    #data-table td {
        padding: 0.5rem 0.375rem;
        white-space: nowrap;
    }

    /* 分页控件优化 */
    footer {
        padding: 0.5rem;
        height: auto;
        min-height: 48px;
    }

    footer .flex.items-center.gap-2 {
        gap: 1rem;
    }

    /* 空状态文字大小 */
    #empty-state h3 {
        font-size: 1rem;
    }

    #empty-state p {
        font-size: 0.75rem;
    }

    /* Toast 通知位置调整 */
    #toast-container {
        left: 1rem;
        right: 1rem;
        bottom: 4rem;
    }

    .toast {
        width: 100%;
    }
}

/* 超小屏幕优化 */
@media (max-width: 380px) {

    /* 进一步压缩字体 */
    body {
        font-size: 0.75rem;
    }

    #data-table {
        font-size: 0.7rem;
    }

    #data-table th,
    #data-table td {
        padding: 0.375rem 0.25rem;
    }

    /* 侧边栏更窄 */
    #sidebar {
        width: 80vw;
    }

    /* 按钮文字更小 */
    button {
        font-size: 0.7rem;
    }

    /* 搜索框更紧凑 */
    #search-input {
        font-size: 0.75rem;
    }
}

/* 横屏模式优化 */
@media (max-width: 896px) and (orientation: landscape) {

    /* 侧边栏在横屏时更窄 */
    #sidebar {
        width: 200px;
    }

    /* 工具栏更紧凑 */
    header {
        padding: 0.25rem 0.5rem;
    }

    /* 表格高度调整 */
    #table-container {
        max-height: calc(100vh - 100px);
    }

    /* 分页控件更紧凑 */
    footer {
        padding: 0.25rem 0.5rem;
        min-height: 36px;
    }
}

/* iPhone 安全区域适配 */
@supports (padding-top: env(safe-area-inset-top)) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    #sidebar {
        padding-top: env(safe-area-inset-top);
    }

    footer {
        padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
    }

    #toast-container {
        bottom: calc(1rem + env(safe-area-inset-bottom));
    }
}

/* 防止表单元素缩放 */
input,
textarea,
select {
    font-size: 16px;
}

@media (min-width: 641px) {

    input,
    textarea,
    select {
        font-size: inherit;
    }
}

/* 移动端菜单动画 */
#actions-menu {
    transition: opacity 0.2s ease, transform 0.2s ease;
    transform-origin: top right;
}

#actions-menu:not(.hidden) {
    animation: menuSlideIn 0.2s ease;
}

@keyframes menuSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* 侧边栏滑入动画优化 */
#sidebar {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#sidebar-backdrop {
    transition: opacity 0.3s ease;
}

/* 对比弹窗移动端优化 */
@media (max-width: 640px) {
    #compare-dialog {
        padding: 0.5rem;
    }

    #compare-dialog .bg-background {
        width: 100%;
        max-width: 100%;
        max-height: calc(100vh - 1rem);
        border-radius: 0.5rem;
    }

    #compare-dialog header {
        padding: 0.75rem 1rem;
    }

    #compare-dialog header h2 {
        font-size: 1rem;
    }

    #compare-dialog-content {
        padding: 0.75rem;
    }

    .compare-table-container {
        max-height: calc(100vh - 200px);
    }
}

/* 滚动条在移动端的优化 */
@media (max-width: 640px) {
    ::-webkit-scrollbar {
        width: 4px;
        height: 4px;
    }

    ::-webkit-scrollbar-thumb {
        border-radius: 2px;
    }
}

/* 选中行样式 */
.row-selected td {
    background-color: rgba(37, 99, 235, 0.12);
    box-shadow: inset 0 1px 0 rgba(37, 99, 235, 0.18), inset 0 -1px 0 rgba(37, 99, 235, 0.18);
}

.dark .row-selected td {
    background-color: rgba(59, 130, 246, 0.22);
    box-shadow: inset 0 1px 0 rgba(96, 165, 250, 0.26), inset 0 -1px 0 rgba(96, 165, 250, 0.26);
}

.row-selected td:first-child {
    background-image: linear-gradient(to right, var(--primary) 0, var(--primary) 4px, transparent 4px);
    background-repeat: no-repeat;
}

.row-selected td,
.row-selected td .text-pink-600 {
    color: var(--foreground);
}

@media (max-width: 640px) {
    .row-selected td:first-child {
        background-image: linear-gradient(to right, var(--primary) 0, var(--primary) 5px, transparent 5px);
    }
}

/* 拖拽上传区域在移动端的提示 */
@media (max-width: 640px) {
    body.drag-over::after {
        border-width: 3px;
        font-size: 0.875rem;
    }
}

/* 高亮搜索词在移动端的样式 */
@media (max-width: 640px) {
    .bg-yellow-200 {
        padding: 0 2px;
        border-radius: 2px;
    }
}

/* 触摸操作优化 */
.touch-manipulation {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* 禁用文本选择（提升触摸体验） */
.no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* 允许文本选择 */
.allow-select {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* 数据对比弹窗居中调整 */
#compare-dialog:not(.hidden) {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 数据对比弹窗宽度调整 */
#compare-dialog .bg-background {
    width: auto;
    max-width: 95vw;
    /* 增加最大宽度至视口的95% */
    min-width: 300px;
    /* 调整最小宽度以适应小屏幕 */
    max-height: 85vh;
    /* 限制最大高度，允许内部滚动 */
    display: flex;
    flex-direction: column;
    margin: auto;
    /* 确保在容器中居中 */
}



#compare-dialog-content th,
#compare-dialog-content td {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    text-align: center;
    overflow: hidden;
    max-width: 120px;
    /* 限制单元格最大宽度 */
}

/* 确保表头（参数名称）不换行 */
#compare-dialog-content th {
    white-space: nowrap;
}

/* 允许数据单元格换行 */
#compare-dialog-content td {
    white-space: normal;
}

#compare-dialog-content td {
    max-width: 120px;
    /* 调整单元格最大宽度以适应小屏幕 */
}

#compare-dialog-content th {
    background-color: var(--secondary);
    font-weight: 600;
}

#compare-dialog-content tbody tr:nth-child(even) {
    background-color: var(--secondary);
}

/* 确保表头完全不透明 */
thead th {
    background-color: var(--background);
    color: var(--foreground);
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    /* 确保参数行不换行 */
}

/* 允许数据行换行 */
tbody td {
    white-space: normal;
}

/* 固定参数列在最左侧 */
th.sticky-first-col,
td.sticky-first-col {
    position: sticky;
    left: 0;
    z-index: 30;
    /* 确保参数列在最顶层 */
    background-color: var(--background);
    border-right: 1px solid var(--border) !important;
    /* 保留右边框 */
    border-top: 0 !important;
    /* 移除上边框，避免边框叠加 */
    border-bottom: 0 !important;
    /* 移除下边框，避免边框叠加 */
    min-width: max-content;
    /* 确保内容完全显示 */
    white-space: nowrap;
    /* 确保内容不换行 */
    overflow: hidden;
    /* 隐藏溢出内容 */
    text-overflow: ellipsis;
    /* 溢出时显示省略号 */
    text-align: center;
    /* 文本水平居中 */
    vertical-align: middle;
    /* 文本垂直居中 */
}

/* 特别针对对比弹窗中的固定列 */
#compare-dialog-content th.sticky-first-col,
#compare-dialog-content td.sticky-first-col {
    position: sticky;
    left: 0;
    z-index: 35;
    /* 比一般固定列更高的层级 */
    background-color: var(--background);
    box-shadow: inset 0 0 0 1px var(--border);
    /* 添加内部阴影确保边框显示 */
    vertical-align: middle;
    /* 垂直居中对齐 */
    text-align: center;
    /* 文本居中对齐 */
    padding-left: 1rem;
    padding-right: 1rem;
    white-space: nowrap;
    /* 确保内容不换行 */
    overflow: hidden;
    /* 隐藏溢出内容 */
    text-overflow: ellipsis;
    /* 溢出时显示省略号 */
    transform: translateX(-1px);
    /* 向左平移一个像素 */
}

#data-table td {
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    max-width: 300px;
    /* 限制单元格最大宽度，防止表格过宽 */
}

/* 首页表格第一列添加右侧边框 */
#data-table td:first-child {
    border-right: 1px solid var(--border);
}

/* ==================== 2026-03 responsive UI refresh ==================== */

:root {
    --app-shell-padding: clamp(0.75rem, 1.4vw, 1.25rem);
    --panel-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
    --panel-shadow-strong: 0 22px 60px rgba(15, 23, 42, 0.16);
    --hero-gradient:
        radial-gradient(circle at top left, rgba(14, 165, 233, 0.18), transparent 34%),
        radial-gradient(circle at top right, rgba(99, 102, 241, 0.14), transparent 28%),
        linear-gradient(180deg, rgba(248, 250, 252, 0.95), rgba(255, 255, 255, 1));
}

.dark {
    --panel-shadow: 0 22px 48px rgba(2, 6, 23, 0.35);
    --panel-shadow-strong: 0 28px 72px rgba(2, 6, 23, 0.5);
    --hero-gradient:
        radial-gradient(circle at top left, rgba(56, 189, 248, 0.16), transparent 34%),
        radial-gradient(circle at top right, rgba(129, 140, 248, 0.14), transparent 30%),
        linear-gradient(180deg, rgba(2, 6, 23, 0.98), rgba(2, 6, 23, 1));
}

html,
body {
    height: 100%;
}

body.app-body {
    background: var(--hero-gradient);
    font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

.app-shell {
    position: relative;
    min-height: 100dvh;
    padding: var(--app-shell-padding);
    gap: var(--app-shell-padding);
}

#sidebar {
    border-radius: 1.25rem;
    box-shadow: var(--panel-shadow);
    overflow: hidden;
}

.app-main {
    min-width: 0;
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 1.5rem;
    background: rgba(255, 255, 255, 0.82);
    box-shadow: var(--panel-shadow);
}

.dark .app-main {
    background: rgba(2, 6, 23, 0.84);
}

.top-toolbar {
    border-top-left-radius: 1.5rem;
    border-top-right-radius: 1.5rem;
}

.search-shell {
    isolation: isolate;
}

.search-shell::after {
    content: '';
    position: absolute;
    inset: -0.2rem;
    border-radius: 0;
    background: transparent;
    opacity: 0;
    transition: none;
    z-index: -1;
}

.search-shell:focus-within::after {
    opacity: 0;
}

.data-viewport {
    min-height: 0;
    background: var(--background);
}

.dark .data-viewport {
    background: var(--background);
}

#empty-state {
    padding: 2rem;
    text-align: center;
}

#data-table {
    min-width: max(100%, 56rem);
}

#data-table thead th {
    backdrop-filter: blur(12px);
}

#data-table th,
#data-table td {
    border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}

#data-table tbody tr {
    transition: background-color 0.18s ease, transform 0.18s ease;
}

#data-table tbody tr:hover {
    background-color: rgba(148, 163, 184, 0.09);
}

.app-footer {
    gap: 0.75rem;
    border-bottom-left-radius: 1.5rem;
    border-bottom-right-radius: 1.5rem;
    background: rgba(255, 255, 255, 0.9);
}

.dark .app-footer {
    background: rgba(2, 6, 23, 0.92);
}

#actions-menu,
.compare-panel,
.toast {
    box-shadow: var(--panel-shadow-strong);
}

#compare-dialog {
    padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}

.compare-panel {
    border: 1px solid rgba(148, 163, 184, 0.14);
    overflow: hidden;
}

#compare-dialog-content {
    min-height: 0;
}

@media (min-width: 1024px) {
    .app-shell {
        padding: 1rem;
    }

    #sidebar {
        width: min(18rem, 24vw);
    }

    .top-toolbar {
        padding-top: 1rem;
        padding-bottom: 1rem;
    }
}

@media (max-width: 1023px) {
    body.app-body {
        overflow: hidden;
    }

    .app-shell {
        padding: 0;
        gap: 0;
    }

    .app-main {
        border-radius: 0;
        border-left: 0;
        border-right: 0;
        box-shadow: none;
    }

    #sidebar {
        border-radius: 0 1.25rem 1.25rem 0;
        height: 100dvh;
        max-height: 100dvh;
    }

    .top-toolbar,
    .app-footer {
        border-radius: 0;
    }
}

@media (max-width: 768px) {
    .top-toolbar {
        padding: 0.85rem 0.9rem 0.75rem;
        background: rgba(255, 255, 255, 0.88);
    }

    .dark .top-toolbar {
        background: rgba(2, 6, 23, 0.88);
    }

    .search-shell {
        gap: 0.55rem;
    }

    #search-input,
    #search-mode-btn,
    #actions-menu-toggle,
    #menu-toggle {
        min-height: 2.75rem;
    }

    #search-input {
        border-radius: 0.9rem;
        background: rgba(255, 255, 255, 0.72);
    }

    .dark #search-input {
        background: rgba(15, 23, 42, 0.78);
    }

    #search-mode-btn {
        border-radius: 0.9rem;
        white-space: nowrap;
        padding-inline: 0.9rem;
    }

    .data-viewport {
        padding-bottom: 0.5rem;
    }

    #empty-state {
        justify-content: center;
        padding: 1.5rem 1rem 5rem;
    }

    #data-table {
        min-width: max(100%, 42rem);
    }

    #data-table th,
    #data-table td {
        padding: 0.7rem 0.6rem;
    }

    .app-footer {
        padding: 0.7rem 0.9rem;
        min-height: 4.5rem;
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: center;
    }

    #pagination-info {
        display: block !important;
        line-height: 1.4;
    }

    #actions-menu {
        width: min(18rem, calc(100vw - 1.25rem));
        border-radius: 1rem;
    }

    .compare-panel {
        max-height: calc(100dvh - 1.25rem);
        border-radius: 1rem;
    }

    #compare-dialog-content {
        padding: 1rem;
    }
}

@media (max-width: 640px) {
    .top-toolbar > div {
        gap: 0.35rem;
    }

    #sidebar-backdrop {
        backdrop-filter: blur(4px);
    }

    .data-viewport::after {
        content: '左右滑动可查看更多列';
        position: sticky;
        left: 0.75rem;
        bottom: 0.75rem;
        display: inline-flex;
        margin-left: 0.75rem;
        padding: 0.3rem 0.6rem;
        border-radius: 999px;
        font-size: 0.7rem;
        letter-spacing: 0.02em;
        color: var(--muted-foreground);
        background: rgba(255, 255, 255, 0.88);
        border: 1px solid rgba(148, 163, 184, 0.24);
        box-shadow: var(--panel-shadow);
        pointer-events: none;
        z-index: 3;
    }

    .dark .data-viewport::after {
        background: rgba(15, 23, 42, 0.9);
    }

    #data-table th,
    #data-table td {
        max-width: 12rem;
    }

    .app-footer {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
        padding-bottom: calc(0.9rem + env(safe-area-inset-bottom));
    }

    #pagination-info {
        max-width: 100%;
    }

    #toast-container {
        left: 0.75rem;
        right: 0.75rem;
        bottom: calc(1rem + env(safe-area-inset-bottom));
    }

    .toast {
        width: 100%;
    }
}

@media (max-width: 480px) {
    #sidebar {
        width: min(88vw, 20rem);
    }

    .top-toolbar {
        padding-inline: 0.7rem;
    }

    #search-input {
        padding-right: 0.75rem;
    }

    #search-mode-btn {
        padding-inline: 0.75rem;
        font-size: 0.75rem;
    }

    #data-table {
        min-width: max(100%, 36rem);
    }

    #data-table th,
    #data-table td {
        padding: 0.6rem 0.5rem;
        max-width: 9rem;
    }

    .compare-panel {
        border-radius: 0.85rem;
    }

    #compare-dialog-content {
        padding: 0.75rem;
    }
}

@supports not (height: 100dvh) {
    .app-shell {
        height: 100vh;
        min-height: 100vh;
    }

    .app-main {
        height: 100vh;
        min-height: 100vh;
    }

    #sidebar {
        height: 100vh;
        max-height: 100vh;
    }
}

/* Mobile actions drawer */
#actions-drawer-backdrop {
    opacity: 0;
    transition: opacity 0.3s ease;
}

#actions-drawer-backdrop.is-open {
    opacity: 1;
}

#actions-menu {
    display: block;
    width: min(88vw, 20rem);
    max-width: 20rem;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    box-shadow: -14px 0 32px rgba(15, 23, 42, 0.18);
}

#actions-menu.hidden {
    display: none;
}

#actions-menu.is-open {
    transform: translateX(0);
}

@media (max-width: 640px) {
    #actions-menu {
        width: min(88vw, 20rem);
        max-width: 20rem;
    }
}

/* Straight-edge override */
:root {
    --radius: 0;
}

body.app-body [class*="rounded"],
body.app-body button,
body.app-body input,
body.app-body select,
body.app-body textarea,
body.app-body label,
body.app-body #sidebar,
body.app-body .app-main,
body.app-body .top-toolbar,
body.app-body .app-footer,
body.app-body .compare-panel,
body.app-body #actions-menu {
    border-radius: 0 !important;
}

body.app-body .search-shell::after,
body.app-body .data-viewport::after,
body.app-body #actions-drawer-backdrop,
body.app-body #sidebar-backdrop {
    border-radius: 0 !important;
}

/* Unified workspace layout */
body.app-body {
    background: var(--background);
}

.app-shell {
    padding: 0;
    gap: 0;
    height: 100dvh;
    min-height: 100vh;
}

#sidebar {
    box-shadow: none;
    border-right: 1px solid rgba(148, 163, 184, 0.16);
}

.app-main {
    border: 0;
    box-shadow: none;
    background: var(--background);
}

.top-toolbar,
.app-footer,
.data-viewport {
    background: var(--background);
}

@media (min-width: 1024px) {
    .app-shell {
        padding: 0;
        gap: 0;
    }

    #sidebar {
        width: 17rem;
        border-right: 1px solid rgba(148, 163, 184, 0.16);
    }

    .app-main {
        border-left: 0;
    }
}

/* Mobile-first refinement */
@media (max-width: 768px) {
    body.app-body {
        overflow: hidden;
    }

    .app-shell,
    .app-main {
        height: 100dvh;
        min-height: 100dvh;
    }

    #sidebar {
        width: min(88vw, 20rem);
        max-width: 20rem;
        border-right-width: 0;
        box-shadow: 14px 0 32px rgba(15, 23, 42, 0.18);
    }

    .top-toolbar {
        position: sticky;
        top: 0;
        padding: 0.75rem;
        border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    }

    .top-toolbar > div {
        gap: 0.5rem;
    }

    .search-shell {
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: center;
        gap: 0.5rem;
        margin-top: 0.6rem;
    }

    #search-input {
        height: 2.8rem;
        padding-left: 2.15rem;
        padding-right: 0.85rem;
        font-size: 0.95rem;
        background: rgba(148, 163, 184, 0.08);
    }

    #search-mode-btn,
    #menu-toggle,
    #actions-menu-toggle {
        min-width: 2.8rem;
        min-height: 2.8rem;
    }

    .data-viewport {
        padding-bottom: calc(3.9rem + env(safe-area-inset-bottom));
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    #empty-state {
        padding: 1.25rem 1rem 6rem;
    }

    #empty-state .w-24 {
        width: 4.25rem;
        height: 4.25rem;
        margin-bottom: 0.9rem;
    }

    #empty-state h3 {
        font-size: 1rem;
    }

    #empty-state p {
        max-width: 18rem;
        font-size: 0.8rem;
        line-height: 1.5;
    }

    #data-table {
        min-width: max(100%, 40rem);
    }

    #data-table th,
    #data-table td {
        padding: 0.75rem 0.55rem;
        font-size: 0.78rem;
    }

    .app-footer {
        position: relative;
        z-index: 40;
        flex-shrink: 0;
        min-height: auto;
        padding: 0.55rem 0.75rem calc(0.7rem + env(safe-area-inset-bottom));
        border-top: 1px solid rgba(148, 163, 184, 0.18);
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(14px);
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 0.75rem;
    }

    .dark .app-footer {
        background: rgba(2, 6, 23, 0.96);
    }

    #pagination-info {
        display: none !important;
    }

    .app-footer > .flex.items-center.gap-2 {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;
        gap: 0.4rem;
        min-height: 2.4rem;
    }

    #prev-page,
    #next-page {
        min-width: 2.1rem;
        min-height: 2.1rem;
        border: 0;
    }

    #prev-page {
        justify-self: end;
    }

    #next-page {
        justify-self: start;
    }

    #page-indicator {
        min-width: 0;
        font-size: 0.78rem;
        white-space: nowrap;
        justify-self: center;
        text-align: center;
    }

    #actions-menu {
        width: min(23rem, 92vw);
    }

    .compare-panel {
        width: calc(100vw - 1rem);
        max-width: calc(100vw - 1rem);
        max-height: calc(100dvh - 1rem);
    }

    #compare-dialog > .compare-panel > header {
        padding: 0.8rem 0.9rem;
    }

    #compare-dialog-content {
        padding: 0.8rem;
    }

    .compare-table-container {
        max-height: calc(100dvh - 15rem);
        min-height: 12rem;
    }
}

@media (max-width: 480px) {
    .top-toolbar {
        padding: 0.65rem;
    }

    .search-shell {
        grid-template-columns: 1fr;
    }

    #search-mode-btn {
        width: 100%;
        justify-content: center;
    }

    #data-table {
        min-width: max(100%, 34rem);
    }

    #data-table th,
    #data-table td {
        padding: 0.7rem 0.45rem;
        max-width: 8rem;
    }

    .app-footer {
        padding-left: 0.65rem;
        padding-right: 0.65rem;
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
    }

    #actions-menu {
        width: 94vw;
    }

    .compare-panel {
        width: calc(100vw - 0.5rem);
        max-width: calc(100vw - 0.5rem);
        max-height: calc(100dvh - 0.5rem);
    }
}

@media (max-width: 768px) {
    th.sticky-header,
    td.sticky-col,
    th.sticky-col,
    .top-toolbar,
    .app-footer,
    #sidebar,
    #actions-menu,
    .compare-panel,
    .data-viewport {
        background-image: none !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
    }

    .data-viewport {
        padding-bottom: 0 !important;
    }

    .data-viewport::after {
        content: none !important;
        display: none !important;
    }
}

/* Final compare table overflow fix */
#compare-dialog-content .compare-table-container {
    overflow-x: auto !important;
    overflow-y: auto !important;
    padding-right: 0 !important;
}

#compare-dialog-content table {
    width: max-content !important;
    min-width: 100% !important;
}

#compare-dialog-content th,
#compare-dialog-content td {
    max-width: none !important;
    overflow: visible !important;
    text-overflow: clip !important;
}

#compare-dialog-content th {
    white-space: nowrap !important;
}

#compare-dialog-content td {
    white-space: nowrap !important;
}

#compare-dialog-content th:last-child,
#compare-dialog-content td:last-child {
    padding-right: 0.9rem !important;
}

@media (max-width: 768px) {
    #compare-dialog {
        padding: 0 !important;
    }

    .compare-panel {
        width: 100vw !important;
        max-width: 100vw !important;
        max-height: 100dvh !important;
    }

    #compare-dialog-content {
        overflow: hidden !important;
    }

    #compare-dialog-content .compare-table-container {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: auto !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    #compare-dialog-content table {
        width: max-content !important;
        min-width: max-content !important;
    }

    #compare-dialog-content th,
    #compare-dialog-content td {
        min-width: max-content !important;
    }
}

/* Final mobile search + sticky column fixes */
@media (max-width: 768px) {
    .search-shell {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto !important;
        align-items: center;
        gap: 0.5rem;
        margin-top: 0.6rem;
    }

    #search-mode-btn {
        width: auto !important;
        min-width: 6.5rem;
        justify-self: end;
        justify-content: center;
        white-space: nowrap;
    }
}

@media (max-width: 480px) {
    .search-shell {
        grid-template-columns: minmax(0, 1fr) auto !important;
    }

    #search-input {
        min-width: 0;
    }

    #search-mode-btn {
        width: auto !important;
        min-width: 6rem;
        padding-inline: 0.7rem;
    }
}

#data-table td.sticky-col,
#data-table th.sticky-col {
    background-color: var(--background) !important;
    background-image: none !important;
    background-clip: padding-box;
}

.row-selected td.sticky-col {
    background-color: #dbe7ff !important;
    background-image: none !important;
    z-index: 12;
}

.dark .row-selected td.sticky-col {
    background-color: #1e3a5f !important;
}

.row-selected td.sticky-col:first-child {
    background-image: linear-gradient(to right, var(--primary) 0, var(--primary) 4px, transparent 4px) !important;
    background-repeat: no-repeat !important;
}

@media (max-width: 640px) {
    .row-selected td.sticky-col:first-child {
        background-image: linear-gradient(to right, var(--primary) 0, var(--primary) 5px, transparent 5px) !important;
    }
}

.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.quick-action-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    min-height: 5rem;
    padding: 1rem 0.9rem;
    background: transparent;
    border-right: 1px solid rgba(148, 163, 184, 0.2);
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    transition: background-color 0.18s ease, color 0.18s ease;
}

.quick-action-tile:nth-child(2n) {
    border-right: 0;
}

.quick-action-tile:nth-last-child(-n+2) {
    border-bottom: 0;
}

.quick-action-tile:hover,
.quick-action-tile:active {
    background: rgba(148, 163, 184, 0.08);
}

.quick-action-tile i {
    width: 1.05rem;
    height: 1.05rem;
}

.quick-action-tile span {
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.2;
    text-align: center;
}

@media (min-width: 1024px) {
    .top-toolbar > div > div:first-child {
        display: none;
    }
}

@media (min-width: 1024px) and (max-width: 1480px) {
    .top-toolbar {
        padding-inline: 1rem;
    }

    .top-toolbar > div {
        display: grid;
        grid-template-columns: minmax(19rem, 1.15fr) minmax(0, 1fr);
        align-items: start;
        gap: 0.8rem 1rem;
    }

    .top-toolbar > div > div:first-child {
        display: none;
    }

    .search-shell {
        grid-column: 1;
        margin-top: 0;
        min-width: 0;
        width: 100%;
    }

    .toolbar-actions {
        grid-column: 2;
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
        align-items: center;
        align-content: flex-start;
        gap: 0.6rem 0.7rem;
        min-width: 0;
    }

    .toolbar-actions > .h-6.w-px {
        display: none;
    }

    .toolbar-actions button {
        white-space: nowrap;
        padding-inline: 0.8rem;
    }

    .toolbar-display-mode,
    .toolbar-freeze-controls {
        gap: 0.45rem;
        flex-wrap: wrap;
    }

    #freeze-row,
    #freeze-col {
        width: 2.75rem;
    }
}

@media (min-width: 1024px) and (max-width: 1220px) {
    .top-toolbar > div {
        grid-template-columns: 1fr;
    }

    .search-shell,
    .toolbar-actions {
        grid-column: 1;
    }

    .toolbar-actions {
        justify-content: flex-start;
    }

    .toolbar-display-mode {
        margin-left: 0;
    }
}

/* Compare dialog refresh */
.compare-panel {
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: var(--background);
}

#compare-dialog > .compare-panel > header {
    gap: 1rem;
    padding: 1rem 1.25rem;
    align-items: flex-start;
}

#compare-mode-toggle {
    min-height: 2rem;
    padding-inline: 0.85rem;
    font-weight: 600;
}

#compare-dialog-content {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    background: var(--background);
    padding: 0 !important;
    margin: 0 !important;
}

.compare-table-container {
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: var(--background);
    box-sizing: border-box;
}

#compare-dialog-content table {
    margin-top: 0;
    border: 0;
    width: max-content;
    min-width: 100%;
}

#compare-dialog-content thead th {
    position: sticky;
    top: 0;
    z-index: 8;
    background: var(--background);
}

#compare-dialog-content th,
#compare-dialog-content td {
    padding: 0.8rem 0.9rem;
    border-color: rgba(148, 163, 184, 0.16);
}

#compare-dialog-content th:last-child,
#compare-dialog-content td:last-child {
    padding-right: 0.9rem;
}

.compare-pagination {
    border-top: 1px solid rgba(148, 163, 184, 0.16);
    padding-top: 0.9rem;
}

.compare-pagination-info {
    min-width: 5rem;
}

.compare-empty-state {
    border: 1px solid rgba(148, 163, 184, 0.18);
    padding: 1.4rem 1.1rem;
    text-align: center;
    background: rgba(148, 163, 184, 0.04);
}

.compare-empty-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.compare-empty-text {
    font-size: 0.85rem;
    line-height: 1.55;
    color: var(--muted-foreground);
}

@media (max-width: 768px) {
    #compare-dialog > .compare-panel > header {
        flex-direction: column;
        align-items: stretch;
        padding: 0.85rem 0.9rem;
    }

    #compare-dialog > .compare-panel > header > div {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.6rem;
    }

    #compare-dialog > .compare-panel > header > div > div:last-child {
        width: 100%;
        justify-content: space-between;
    }

    #close-compare-dialog {
        position: absolute;
        top: 0.7rem;
        right: 0.7rem;
    }

    #compare-dialog-content {
        gap: 0.75rem;
    }

    #compare-dialog-content th,
    #compare-dialog-content td {
        padding: 0.7rem 0.65rem;
        font-size: 0.76rem;
    }

    .compare-pagination {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;
        gap: 0.5rem;
    }

    .compare-pagination #prev-page-compare {
        justify-self: end;
    }

    .compare-pagination #next-page-compare {
        justify-self: start;
    }
}
