/* 模块主题色变量 + 响应式布局变量 */
:root {
    /* 模块主题色 */
    --dashboard-color: #607d8b;
    --dashboard-color-dark: #546e7a;
    --dashboard-hover-bg: #e8ecf0;
    --arrived-color: #e74c3c;
    --arrived-color-dark: #c0392b;
    --arrived-hover-bg: #fadbd8;
    --furnace-color: #3498db;
    --furnace-color-dark: #2980b9;
    --furnace-hover-bg: #d6eaf8;
    --inventory-color: #f39c12;
    --inventory-color-dark: #e67e22;
    --inventory-hover-bg: #fef5e7;
    --composition-color: #27ae60;
    --composition-color-dark: #219a52;
    --composition-hover-bg: #d4edda;
    --finance-color: #8e44ad;
    --finance-color-dark: #7d3c98;
    --finance-hover-bg: #ebdef0;

    /* 响应式布局变量（默认：桌面端） */
    --sidebar-width: 200px;
    --sidebar-collapsed-width: 60px;
    --topbar-height: 62px;            /* 顶部栏实际高度 */
    --topbar-title-size: 1.5em;
    --topbar-link-padding: 8px 15px;
    --topbar-link-font-size: 14px;
    --topbar-h1-margin: 30px;
    --stats-cols: 3;
    --table-font-size: 13px;
    --card-padding: 20px;
    --section-content-padding: 20px;
    --avatar-size: 36px;
    --avatar-inner-size: 30px;
}

/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* 主窗口容器 */
#main-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* 顶部菜单栏 */
#top-menu {
    background-color: #2c3e50;
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    z-index: 100;
    height: var(--topbar-height);
}

#top-menu-content {
    display: flex;
    align-items: center;
    width: 100%;
    justify-content: space-between;
}

#top-menu-left {
    display: flex;
    align-items: center;
}

#top-menu h1 {
    font-size: 1.5em;
    font-weight: bold;
    margin-right: 30px;
}

#top-menu nav ul {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 5px; /* 添加按钮间的间距 */
}

#top-menu nav ul li {
    margin: 0;
}

#top-menu nav ul li a {
    color: white;
    text-decoration: none;
    padding: 8px 15px;
    border-radius: 4px;
    display: block;
    border: 1px solid #3498db; /* 默认蓝色边框 */
    transition: background-color 0.3s, border-color 0.3s;
}

#top-menu nav ul li a:hover {
    background-color: #34495e;
}

/* ===== 用户头像 & 下拉菜单 ===== */

.user-menu {
    position: relative;
    display: flex;
    align-items: center;
    height: 100%;
}

/* 圆形头像按钮 */
.avatar-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.5);
    background: transparent;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s, box-shadow 0.2s;
    vertical-align: middle;
}

.avatar-btn:hover {
    border-color: #fff;
    box-shadow: 0 0 8px rgba(255,255,255,0.3);
}

.avatar-circle {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #607d8b;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.avatar-large {
    width: 42px;
    height: 42px;
    font-size: 18px;
    flex-shrink: 0;
}

/* 角色色彩 */
.avatar-admin { background: #e74c3c; }
.avatar-operator { background: #3498db; }
.avatar-viewer { background: #27ae60; }

/* 下拉菜单面板 */
.avatar-dropdown {
    display: none;
    position: absolute;
    top: 46px;
    right: 0;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    min-width: 220px;
    max-width: calc(100vw - 20px);
    z-index: 999;
    overflow: hidden;
    animation: dropdownIn 0.15s ease-out;
}

.avatar-dropdown.show {
    display: block;
}

@keyframes dropdownIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 下拉菜单头部 */
#avatar-dropdown .dropdown-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: #f8f9fa;
}

#avatar-dropdown .dropdown-user-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#avatar-dropdown .dropdown-name {
    font-size: 15px;
    font-weight: 600;
    color: #2c3e50;
}

#avatar-dropdown .dropdown-role-badge {
    display: inline-block;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
    width: fit-content;
}

#avatar-dropdown .dropdown-role-badge.role-admin {
    background: #fde8e8;
    color: #c0392b;
}

#avatar-dropdown .dropdown-role-badge.role-operator {
    background: #d6eaf8;
    color: #2980b9;
}

#avatar-dropdown .dropdown-role-badge.role-viewer {
    background: #d4edda;
    color: #1e7e34;
}

/* 下拉菜单分割线 */
#avatar-dropdown .dropdown-divider {
    height: 1px;
    background: #eee;
}

/* 下拉菜单项 */
#avatar-dropdown .dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.15s;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    background: transparent;
    border-radius: 0;
}

#avatar-dropdown .dropdown-item:hover {
    background: #f0f2f5;
}

#avatar-dropdown .dropdown-item-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

#avatar-dropdown .dropdown-item-danger {
    color: #e74c3c;
}

#avatar-dropdown .dropdown-item-danger:hover {
    background: #fde8e8;
}

/* 全局角色徽章（下拉菜单 & 弹窗表格共用）*/
.dropdown-role-badge.role-admin {
    display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 500;
    background: #fde8e8; color: #c0392b;
}
.dropdown-role-badge.role-operator {
    display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 500;
    background: #d6eaf8; color: #2980b9;
}
.dropdown-role-badge.role-viewer {
    display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 500;
    background: #d4edda; color: #1e7e34;
}

/* 顶部导航边框 — 模块主题色 */
#top-menu nav ul li a[data-module="dashboard"] { border-color: var(--dashboard-color); }
#top-menu nav ul li a[data-module="arrived"] { border-color: var(--arrived-color); }
#top-menu nav ul li a[data-module="furnace"] { border-color: var(--furnace-color); }
#top-menu nav ul li a[data-module="inventory"] { border-color: var(--inventory-color); }
#top-menu nav ul li a[data-module="composition"] { border-color: var(--composition-color); }
#top-menu nav ul li a[data-module="finance"] { border-color: var(--finance-color); }

/* 顶部导航 hover — 模块深色边框 */
#top-menu nav ul li a[data-module="dashboard"]:hover { border-color: var(--dashboard-color-dark); }
#top-menu nav ul li a[data-module="arrived"]:hover { border-color: var(--arrived-color-dark); }
#top-menu nav ul li a[data-module="furnace"]:hover { border-color: var(--furnace-color-dark); }
#top-menu nav ul li a[data-module="inventory"]:hover { border-color: var(--inventory-color-dark); }
#top-menu nav ul li a[data-module="composition"]:hover { border-color: var(--composition-color-dark); }
#top-menu nav ul li a[data-module="finance"]:hover { border-color: var(--finance-color-dark); }

/* 选中状态的边框 — 文字白色 */
#top-menu nav ul li a.active {
    color: white;
}

/* 顶部导航 active — 模块主题色背景+深色边框 */
body.module-dashboard #top-menu nav ul li a.active {
    background-color: var(--dashboard-color);
    border-color: var(--dashboard-color-dark);
}
body.module-arrived #top-menu nav ul li a.active {
    background-color: var(--arrived-color);
    border-color: var(--arrived-color-dark);
}
body.module-furnace #top-menu nav ul li a.active {
    background-color: var(--furnace-color);
    border-color: var(--furnace-color-dark);
}
body.module-inventory #top-menu nav ul li a.active {
    background-color: var(--inventory-color);
    border-color: var(--inventory-color-dark);
}
body.module-composition #top-menu nav ul li a.active {
    background-color: var(--composition-color);
    border-color: var(--composition-color-dark);
}
body.module-finance #top-menu nav ul li a.active {
    background-color: var(--finance-color);
    border-color: var(--finance-color-dark);
}

/* 侧边栏（功能子菜单） */
#sidebar {
    width: 200px;
    background-color: #ecf0f1;
    padding: 20px 0;
    box-shadow: 2px 0 5px rgba(0,0,0,0.05);
    position: fixed;
    top: var(--topbar-height, 62px);
    height: calc(100vh - var(--topbar-height, 62px));
    overflow-y: auto;
    z-index: 90;
}

.submenu {
    display: none;
}

.submenu.active {
    display: block;
}

.sidebar-section {
    padding: 15px 15px 0 15px;
    margin-bottom: 15px;
}

.sidebar-section ul {
    list-style: none;
}

.sidebar-section ul li {
    margin-bottom: 10px;
}

.sidebar-section ul li a {
    color: #2c3e50;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 4px;
    display: block;
    border: 1px solid #3498db; /* 始终显示蓝色边框 */
    transition: all 0.3s;
}

.sidebar-section ul li a:hover {
    background-color: #bdc3c7;
    color: #2c3e50;
}

/* 选中状态的边框 */
.sidebar-section ul li a.active {
    background-color: #3498db;
    color: white;
    border: 1px solid #2980b9;
}

/* 主内容区 */
#main-content {
    flex: 1;
    margin-left: 200px;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* 页面切换区域 */
.section {
    display: none;
}

.section.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    animation: fadeIn 0.5s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 页面内容区 - 默认 flex 填充，支持 iframe 嵌入页 */
.section-content {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

/* 统计卡片 */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.stat-card {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    text-align: center;
}

.stat-card h3 {
    font-size: 1.1em;
    margin-bottom: 10px;
    color: #2c3e50;
}

.stat-card p {
    font-size: 1.5em;
    font-weight: bold;
    color: #3498db;
}

/* ===== 响应式设计 ===== */

/* 断点 1: ≤1199px 平板横屏 / 小笔记本 */
@media (max-width: 1199px) {
    :root {
        --topbar-height: 56px;
        --topbar-title-size: 1.2em;
        --topbar-link-padding: 6px 10px;
        --topbar-link-font-size: 13px;
        --topbar-h1-margin: 15px;
        --card-padding: 16px;
        --stats-cols: 3;
    }

    #top-menu h1 {
        font-size: var(--topbar-title-size);
        margin-right: var(--topbar-h1-margin);
    }

    #top-menu nav ul li a {
        padding: var(--topbar-link-padding);
        font-size: var(--topbar-link-font-size);
    }

    #top-menu nav ul {
        gap: 3px;
    }
}

/* 断点 2: ≤991px 平板竖屏 */
@media (max-width: 991px) {
    :root {
        --sidebar-width: var(--sidebar-collapsed-width);
        --topbar-height: 50px;
        --topbar-title-size: 1.05em;
        --topbar-link-padding: 5px 8px;
        --topbar-link-font-size: 12px;
        --topbar-h1-margin: 10px;
        --stats-cols: 2;
        --table-font-size: 12px;
        --card-padding: 12px;
        --section-content-padding: 12px;
        --avatar-size: 32px;
        --avatar-inner-size: 26px;
    }

    /* 顶部栏压缩 */
    #top-menu {
        padding: 10px 15px;
    }

    #top-menu h1 {
        font-size: var(--topbar-title-size);
        margin-right: var(--topbar-h1-margin);
    }

    #top-menu nav ul li a {
        padding: var(--topbar-link-padding);
        font-size: var(--topbar-link-font-size);
    }

    #top-menu nav ul {
        gap: 2px;
    }

    /* 头像缩小 */
    .avatar-btn {
        width: var(--avatar-size);
        height: var(--avatar-size);
    }
    .avatar-circle {
        width: var(--avatar-inner-size);
        height: var(--avatar-inner-size);
        font-size: 12px;
    }
    .avatar-dropdown {
        top: 40px;
        min-width: 200px;
        right: -4px;
    }

    /* 侧栏 → 仅图标模式 */
    #sidebar {
        width: var(--sidebar-collapsed-width);
        padding: 10px 0;
    }

    .sidebar-section {
        padding: 10px 5px 0 5px;
        margin-bottom: 8px;
    }

    .sidebar-section ul li {
        margin-bottom: 6px;
    }

    .sidebar-section ul li a {
        text-align: center;
        padding: 10px 4px;
        font-size: 0;
        position: relative;
    }

    /* 使用首字作为图标 */
    .sidebar-section ul li a::before {
        content: attr(data-tooltip);
        display: block;
        font-size: 12px;
        font-weight: 600;
        overflow: hidden;
        white-space: nowrap;
        max-width: 52px;
    }

    /* hover 时显示 tooltip */
    .sidebar-section ul li a:hover::after {
        content: attr(data-tooltip);
        position: absolute;
        left: 65px;
        top: 50%;
        transform: translateY(-50%);
        background: #2c3e50;
        color: #fff;
        padding: 4px 10px;
        border-radius: 4px;
        font-size: 12px;
        white-space: nowrap;
        z-index: 1000;
        pointer-events: none;
    }

    #main-content {
        margin-left: var(--sidebar-collapsed-width);
    }

    .section-content {
        padding: var(--section-content-padding);
    }

    /* excel 表格字体 */
    .excel-table th, .excel-table td {
        font-size: var(--table-font-size);
        padding: 4px 6px;
    }

    /* 冻结表头高度 */
    .frozen-part thead tr, .scrollable-part thead tr {
        height: auto !important;
        min-height: 28px !important;
    }
    .frozen-part thead th, .scrollable-part thead th {
        height: auto !important;
        min-height: 28px !important;
    }

    /* 隐藏桌面导航标签，显示汉堡按钮 */
    #top-menu-left > nav > ul {
        display: none;
    }
    .hamburger-btn {
        display: flex !important;
    }
}

/* 断点 3: ≤767px 手机 */
@media (max-width: 767px) {
    :root {
        --sidebar-width: 0px;
        --topbar-height: 48px;
        --stats-cols: 1;
        --table-font-size: 11px;
        --card-padding: 10px;
        --section-content-padding: 8px;
    }

    /* 侧栏完全隐藏 */
    #sidebar {
        width: 0;
        overflow: hidden;
        padding: 0;
    }

    #main-content {
        margin-left: 0;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .section-content {
        padding: var(--section-content-padding);
        overflow-y: auto;
        overflow-x: hidden;
    }

    .section.active {
        flex: 1 0 auto;
    }

    /* 手机端：解除 overflow hidden 链，允许竖向滚动，禁止横向溢出 */
    html, body {
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }

    /* 顶部栏 */
    #top-menu {
        padding: 8px 12px;
        flex-wrap: nowrap;
    }

    #top-menu h1 {
        font-size: 1em;
        margin-right: 8px;
        white-space: nowrap;
    }

    /* 隐藏桌面导航标签 */
    #top-menu-left > nav > ul {
        display: none;
    }

    /* 汉堡按钮 */
    .hamburger-btn {
        display: flex !important;
    }

    /* 头像 */
    .avatar-btn {
        width: 32px;
        height: 32px;
    }
    .avatar-circle {
        width: 26px;
        height: 26px;
        font-size: 12px;
    }
    .avatar-dropdown {
        top: 38px;
        right: -4px;
        min-width: 180px;
    }

    /* excel 表格进一步缩小 */
    .excel-table th, .excel-table td {
        font-size: 11px;
        padding: 3px 4px;
    }
    .frozen-part thead tr, .scrollable-part thead tr {
        height: auto !important;
        min-height: 28px !important;
    }
    .frozen-part thead th, .scrollable-part thead th {
        height: auto !important;
        min-height: 28px !important;
        white-space: normal !important;
        word-break: break-all;
        overflow: visible !important;
    }

    /* 冻结表格手机端滚动保护 */
    .frozen-table-wrapper {
        overflow-x: auto !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        touch-action: pan-x pan-y !important;
        position: relative;
        z-index: 1;
    }

    /* sticky 在手机端降级 */
    .frozen-part {
        position: relative !important;
        left: 0 !important;
    }
    .frozen-part thead th {
        position: relative !important;
        top: 0 !important;
        left: auto !important;
    }

    /* 卡片 */
    .stat-card { padding: var(--card-padding); }
    .card { padding: var(--card-padding); margin-bottom: 12px; }
    .card-title { font-size: 15px; }

    /* 移动端触摸优化 - 最小触摸目标 44px */
    .btn {
        min-height: 44px;
        padding: 12px 20px;
    }
    .delete-row-btn {
        padding: 6px 10px;
        font-size: 14px;
        min-height: 32px;
    }
    .add-row-btn {
        padding: 6px 12px;
        font-size: 16px;
        min-height: 32px;
    }

    /* 弹窗窄屏自适应 */
    .validation-panel {
        max-width: calc(100vw - 40px) !important;
        min-width: auto !important;
    }

    /* 汉堡面板导航链接模块主题色边框 */
    .hm-nav-list li a[data-module="dashboard"]   { border-color: var(--dashboard-color); }
    .hm-nav-list li a[data-module="arrived"]     { border-color: var(--arrived-color); }
    .hm-nav-list li a[data-module="furnace"]     { border-color: var(--furnace-color); }
    .hm-nav-list li a[data-module="inventory"]   { border-color: var(--inventory-color); }
    .hm-nav-list li a[data-module="composition"] { border-color: var(--composition-color); }
    .hm-nav-list li a[data-module="finance"]     { border-color: var(--finance-color); }
    .hm-nav-list li a[data-module="settings"]    { border-color: #95a5a6; }
}

/* ===== 汉堡菜单按钮（默认隐藏，≤767px 显示） ===== */

.hamburger-btn {
    display: none;
    width: 34px;
    height: 34px;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 6px;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    margin-right: 8px;
    flex-shrink: 0;
    line-height: 1;
    transition: background 0.2s;
}

.hamburger-btn:hover {
    background: rgba(255,255,255,0.1);
}

/* ===== 汉堡菜单全屏面板 ===== */

.hamburger-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 9998;
    display: flex;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

.hamburger-panel.show {
    opacity: 1;
    pointer-events: auto;
}

.hamburger-panel-inner {
    background: #2c3e50;
    width: 220px;
    max-width: 75vw;
    height: 100%;
    overflow-y: auto;
    padding: 24px 16px;
    box-shadow: 4px 0 20px rgba(0,0,0,0.3);
    transform: translateX(-100%);
    transition: transform 0.25s;
}

.hamburger-panel.show .hamburger-panel-inner {
    transform: translateX(0);
}

.hm-nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.hm-nav-list li {
    margin-bottom: 8px;
}

/* 与 PC 端顶部栏按钮风格一致：白色文字 + 模块色边框 */
.hm-nav-list li a {
    display: block;
    padding: 10px 14px;
    color: #fff;
    text-decoration: none;
    border: 1px solid #3498db;
    border-radius: 4px;
    font-size: 14px;
    text-align: center;
    transition: background-color 0.2s, border-color 0.2s;
}

.hm-nav-list li a:hover,
.hm-nav-list li a:active {
    background-color: #34495e;
}

.hm-nav-list li a[data-module="dashboard"]   { border-color: var(--dashboard-color); }
.hm-nav-list li a[data-module="arrived"]     { border-color: var(--arrived-color); }
.hm-nav-list li a[data-module="furnace"]     { border-color: var(--furnace-color); }
.hm-nav-list li a[data-module="inventory"]   { border-color: var(--inventory-color); }
.hm-nav-list li a[data-module="composition"] { border-color: var(--composition-color); }
.hm-nav-list li a[data-module="finance"]     { border-color: var(--finance-color); }
.hm-nav-list li a[data-module="settings"]    { border-color: #95a5a6; }

/* ===== 侧栏滑出抽屉（≤767px 时使用，替代汉堡面板中的独立菜单） ===== */

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 95;
    opacity: 0;
    transition: opacity 0.25s;
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* 小屏下侧栏变为滑出抽屉（从顶部栏下方开始） */
@media (max-width: 767px) {
    #sidebar {
        position: fixed;
        left: 0;
        top: var(--topbar-height, 48px);
        height: calc(100% - var(--topbar-height, 48px));
        width: 250px;
        z-index: 96;
        transform: translateX(-100%);
        transition: transform 0.25s;
        padding: 10px 0;
        overflow-y: auto;
        box-shadow: 4px 0 20px rgba(0,0,0,0.2);
    }

    #sidebar.drawer-open {
        transform: translateX(0);
    }

    .sidebar-section {
        padding: 15px 12px 0 12px;
    }

    .sidebar-section ul li a {
        text-align: left;
        padding: 10px 14px;
        font-size: 14px;
    }

    /* 抽屉中不显示 ::before 图标 */
    .sidebar-section ul li a::before {
        display: none;
    }

    .sidebar-section ul li a:hover::after {
        display: none;
    }

    .sidebar-overlay {
        /* 由 JS 切换 .show */
    }
}

/* 手机端隐藏右上角设置（已在汉堡菜单中） */
@media (max-width: 767px) {
    #top-menu-right > li:last-child {
        display: none;
    }
}

.excel-table-container {
    margin-top: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 100%;
    max-width: 100%;
    display: block;
}

.excel-table {
    width: auto; /* 允许表格根据内容自动扩展宽度 */
    min-width: 100%; /* 至少占满容器宽度 */
    border-collapse: collapse;
    table-layout: auto; /* 使用自动布局以支持自适应列宽 */
}

.excel-table th,
.excel-table td {
    border: 1px solid #ccc;
    padding: 5px 7px;
    text-align: center; /* 设置居中对齐 */
    min-width: 48px;
    min-height: 28px; /* 最小高度，防止空单元格导致行高不一致 */
    font-size: 13px;
    position: relative;
    white-space: nowrap; /* 禁止自动换行 */
    overflow: hidden; /* 超出内容隐藏 */
    text-overflow: ellipsis; /* 超出部分显示省略号 */
}

/* 冻结列表头和单元格固定列宽（针对编辑页：第1列=操作/+） */
/* 注意：这些规则会被各子页面的 inline <style> 中的 !important 覆盖 */
/* 保留作为编辑页的默认参考 */
#frozen-table th:nth-child(1), #frozen-table td:nth-child(1) { min-width: 50px !important; max-width: 50px !important; width: 50px !important; }
#frozen-table th:nth-child(2), #frozen-table td:nth-child(2) { min-width: 48px !important; max-width: 48px !important; width: 48px !important; }
#frozen-table th:nth-child(3), #frozen-table td:nth-child(3) { min-width: 80px !important; max-width: 80px !important; width: 80px !important; }
#frozen-table th:nth-child(4), #frozen-table td:nth-child(4) { min-width: 90px !important; max-width: 90px !important; width: 90px !important; }
#frozen-table th:nth-child(5), #frozen-table td:nth-child(5) { min-width: 65px !important; max-width: 65px !important; width: 65px !important; }
#frozen-table th:nth-child(6), #frozen-table td:nth-child(6) { min-width: 100px !important; }
#frozen-table th:nth-child(7), #frozen-table td:nth-child(7) { min-width: 65px !important; max-width: 65px !important; width: 65px !important; }
#frozen-table th:nth-child(8), #frozen-table td:nth-child(8) { min-width: 65px !important; max-width: 65px !important; width: 65px !important; }
#frozen-table th:nth-child(9), #frozen-table td:nth-child(9) { min-width: 80px !important; max-width: 80px !important; width: 80px !important; }

.excel-table th {
    background-color: #4a5568; /* 深灰色背景，类似Excel */
    color: white; /* 白色文字 */
    position: sticky;
    top: 0;
    z-index: 20;
    white-space: nowrap; /* 禁止自动换行 */
    overflow: hidden; /* 超出内容隐藏 */
    text-overflow: ellipsis; /* 超出部分显示省略号 */
}

/* 表格行交替背景色，类似Excel样式 */
.excel-table tbody tr:nth-child(odd) {
    background-color: #ffffff; /* 白色背景 */
}

.excel-table tbody tr:nth-child(even) {
    background-color: #f8f9fa; /* 淡灰色背景 */
}

/* 选中的单元格样式 */
.excel-table td.selected {
    background-color: #d6eaf8 !important;
    box-shadow: inset 0 0 0 2px #3498db;
}

/* 多单元格选择高亮（与条件格式共存，使用outline避免冲突） */
.excel-table td.cell-selected {
    outline: 2px solid #3498db !important;
    outline-offset: -2px;
    background-color: #d6eaf8 !important;
}

/* 选择区域的锚点单元格（起点） */
.excel-table td.cell-selected.anchor-cell {
    outline: 2px solid #1a5276 !important;
}

/* 冻结表格系统样式 */
.frozen-table-wrapper {
    display: flex;
    width: 100%;
    max-height: 70vh;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.frozen-part {
    flex-shrink: 0;
    border-right: 2px solid #ccc;
    background-color: #f8f9fa;
    position: sticky;
    left: 0;
    z-index: 20;
}

.frozen-part thead tr {
    height: 28px !important;
}

.frozen-part thead th {
    position: sticky !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 30 !important;
    height: 28px !important;
    line-height: 1 !important;
    vertical-align: middle !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

.scrollable-part {
    min-width: 0;
    overflow: visible;
}

.scrollable-part thead tr {
    height: 28px !important;
}

.scrollable-part thead th {
    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
    height: 28px !important;
    line-height: 1 !important;
    vertical-align: middle !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

/* 约束表头中的角标元素，防止撑高表头 */
#scrollable-table thead th sub,
#scrollable-table thead th sup,
#frozen-table thead th sub,
#frozen-table thead th sup {
    font-size: 0.7em !important;
    line-height: 0 !important;
}

/* 删除行按钮样式 */
.delete-row-btn {
    background-color: #e74c3c;
    color: white;
    border: none;
    padding: 1px 4px;
    cursor: pointer;
    border-radius: 2px;
    font-size: 12px;
}

.delete-row-btn:hover {
    background-color: #c0392b;
}

/* 添加行按钮样式 */
.add-row-btn {
    background-color: #2ecc71;
    color: white;
    border: none;
    padding: 1px 6px;
    cursor: pointer;
    border-radius: 2px;
    font-size: 14px;
    font-weight: bold;
}

.add-row-btn:hover {
    background-color: #27ae60;
}

/* 行号样式 */
.row-number {
    text-align: center;
    background-color: #ecf0f1;
    font-weight: bold;
}

/* 居中对齐样式 */
.text-center {
    text-align: center;
}

/* 基础按钮样式（实心按钮） */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.btn:hover {
    opacity: 0.9;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: #3498db;
    color: #fff;
}

.btn-success {
    background: #27ae60;
    color: #fff;
}

.btn-warning {
    background: #f39c12;
    color: #fff;
}

.btn-secondary {
    background: #95a5a6;
    color: #fff;
}

.btn-danger {
    background: #e74c3c;
    color: #fff;
}

/* 淡绿色按钮样式 */
.btn-light-green {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

.btn-light-green:hover {
    background-color: #c3e6cb;
}

/* 淡红色按钮样式 */
.btn-light-red {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

.btn-light-red:hover {
    background-color: #f5c6cb;
}

/* 更淡的红色按钮样式（用于清空表格按钮） */
.btn-danger-light {
    background-color: #fce4e6;
    color: #a94442;
    border: 1px solid #f5c6cb;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

.btn-danger-light:hover {
    background-color: #f8d7da;
}

/* 淡蓝色按钮样式 */
.btn-light-blue {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

.btn-light-blue:hover {
    background-color: #bee5eb;
}

/* Cu、Fe、S、Pb、As、Zn 列的黄色背景样式 - 可滚动表格部分 */
/* 不使用!important，让JS条件格式可通过setProperty覆盖 */
/* 滚动列序: 1=水份 2=Cu 3=Au 4=Ag 5=Fe 6=S 7=SiO2 8=CaO 9=Pb 10=As 11=Zn 12=Al2O3 ... */
#scrollable-table td:nth-child(2),  /* Cu列 */
#scrollable-table td:nth-child(5),  /* Fe列 */
#scrollable-table td:nth-child(6),  /* S列 */
#scrollable-table td:nth-child(9),  /* Pb列 */
#scrollable-table td:nth-child(10), /* As列 */
#scrollable-table td:nth-child(11)  /* Zn列 */
{
    background-color: #fff3cd;
}

/* 对应表头的黄色字体样式 - 可滚动表格部分 */
#scrollable-table th:nth-child(2),   /* Cu表头 */
#scrollable-table th:nth-child(5),   /* Fe表头 */
#scrollable-table th:nth-child(6),   /* S表头 */
#scrollable-table th:nth-child(9),   /* Pb表头 */
#scrollable-table th:nth-child(10),  /* As表头 */
#scrollable-table th:nth-child(11)   /* Zn表头 */
{
    color: #fff3cd !important;
}

/* Hg、F、Cl、SO42- 列的绿色背景样式 - 可滚动表格部分 */
/* 滚动列序: ...14=Sb 15=Cd 16=Ni 17=Bi 18=Hg 19=F 20=Cl 21=SO4 22=Se ... */
#scrollable-table td:nth-child(18),  /* Hg列 */
#scrollable-table td:nth-child(19),  /* F列 */
#scrollable-table td:nth-child(20),  /* Cl列 */
#scrollable-table td:nth-child(21)   /* SO42-列 */
{
    background-color: #d4edda;
}

/* 对应表头的绿色字体样式 - 可滚动表格部分 */
#scrollable-table th:nth-child(18),  /* Hg表头 */
#scrollable-table th:nth-child(19),  /* F表头 */
#scrollable-table th:nth-child(20),  /* Cl表头 */
#scrollable-table th:nth-child(21)   /* SO42-表头 */
{
    color: #d4edda !important;
}

/* 种类列条件格式样式 - 动态CSS规则将在JavaScript中应用 */
/* 由于CSS无法直接基于单元格内容进行条件格式化，
    因此动态样式将通过JavaScript在运行时应用 */

/* 卡片容器样式（成分管理页面使用） */
.card {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 20px;
    margin-bottom: 20px;
}

.card-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 15px;
    color: #34495e;
    padding-left: 10px;
    border-left: 4px solid #3498db;
}

.card-content {
    padding: 10px 0;
}

.form-group {
    margin-bottom: 15px;
}

/* ===== 模块主题色 ===== */

/* 侧边栏链接边框 */
body.module-dashboard .sidebar-section ul li a { border-color: var(--dashboard-color); }
body.module-arrived .sidebar-section ul li a { border-color: var(--arrived-color); }
body.module-furnace .sidebar-section ul li a { border-color: var(--furnace-color); }
body.module-inventory .sidebar-section ul li a { border-color: var(--inventory-color); }
body.module-composition .sidebar-section ul li a { border-color: var(--composition-color); }
body.module-finance .sidebar-section ul li a { border-color: var(--finance-color); }

/* 侧边栏链接 hover */
body.module-dashboard .sidebar-section ul li a:hover { background-color: var(--dashboard-hover-bg); }
body.module-arrived .sidebar-section ul li a:hover { background-color: var(--arrived-hover-bg); }
body.module-furnace .sidebar-section ul li a:hover { background-color: var(--furnace-hover-bg); }
body.module-inventory .sidebar-section ul li a:hover { background-color: var(--inventory-hover-bg); }
body.module-composition .sidebar-section ul li a:hover { background-color: var(--composition-hover-bg); }
body.module-finance .sidebar-section ul li a:hover { background-color: var(--finance-hover-bg); }

/* 侧边栏链接 active */
body.module-dashboard .sidebar-section ul li a.active {
    background-color: var(--dashboard-color);
    border-color: var(--dashboard-color-dark);
    color: white;
}
body.module-arrived .sidebar-section ul li a.active {
    background-color: var(--arrived-color);
    border-color: var(--arrived-color-dark);
    color: white;
}
body.module-furnace .sidebar-section ul li a.active {
    background-color: var(--furnace-color);
    border-color: var(--furnace-color-dark);
    color: white;
}
body.module-inventory .sidebar-section ul li a.active {
    background-color: var(--inventory-color);
    border-color: var(--inventory-color-dark);
    color: white;
}
body.module-composition .sidebar-section ul li a.active {
    background-color: var(--composition-color);
    border-color: var(--composition-color-dark);
    color: white;
}
body.module-finance .sidebar-section ul li a.active {
    background-color: var(--finance-color);
    border-color: var(--finance-color-dark);
    color: white;
}

/* 卡片标题竖杠 */
body.module-dashboard .card-title { border-left-color: var(--dashboard-color); }
body.module-arrived .card-title { border-left-color: var(--arrived-color); }
body.module-furnace .card-title { border-left-color: var(--furnace-color); }
body.module-inventory .card-title { border-left-color: var(--inventory-color); }
body.module-composition .card-title { border-left-color: var(--composition-color); }
body.module-finance .card-title { border-left-color: var(--finance-color); }