* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    height: 100vh;
    overflow: hidden;
    background-color: #f0f2f5;
}

.app {
    display: flex;
    height: 100%;
}

/* 侧边栏 */
.sidebar {
    width: 220px;
    background-color: #1e2a3a;
    color: #e9ecef;
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
    box-shadow: 2px 0 8px rgba(0,0,0,0.1);
    height: 100vh;           /* 固定高度为视口高度 */
    overflow-y: auto;        /* 内容溢出时滚动 */
    position: sticky;
    top: 0;
}

.logo {
    padding: 1rem 1.5rem;
    font-size: 1.3rem;
    font-weight: 600;
    border-bottom: 1px solid #2c3e50;
    letter-spacing: 0.5px;
}

.menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 1rem 0.8rem;
}

.menu-item {
    background: none;
    border: none;
    color: #b0c4de;
    padding: 0.8rem 1rem;
    text-align: left;
    font-size: 1rem;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.menu-item:hover {
    background-color: #2c3e50;
    color: #fff;
}

.menu-item.active {
    background-color: #3498db;
    color: white;
    font-weight: 500;
}

.version {
    padding: 1rem 1.5rem;
    font-size: 0.8rem;
    color: #6c7a8d;
    border-top: 1px solid #2c3e50;
}

/* 内容区域 */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background-color: #f8fafc;
    position: relative;
}

.view {
    display: none;
    height: 100%;
}

.view.active-view {
    display: block;
}

.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #94a3b8;
    font-size: 1.2rem;
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

/* 加载遮罩 */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-overlay.hidden {
    display: none;
}

.loading-box {
    background: white;
    padding: 2rem 3rem;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.loading-box h3 {
    margin-bottom: 0.5rem;
    color: #1e2a3a;
}

.loading-box p {
    margin: 1rem 0 0.5rem;
    color: #475569;
}

.progress-bar {
    width: 300px;
    height: 20px;
    background-color: #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-fill {
    height: 100%;
    background-color: #3498db;
    transition: width 0.3s ease;
}

/* 物品浏览模块样式 */
.search-box {
    margin-bottom: 1.5rem;
}

#search-input {
    width: 100%;
    padding: 0.8rem 1.2rem;
    font-size: 1rem;
    border: 1px solid #d1d5db;
    border-radius: 40px;
    outline: none;
    transition: border 0.2s;
    background: white;
}

#search-input:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52,152,219,0.1);
}

.item-list {
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    overflow: hidden;
    min-height: 100px;
    max-height: calc(100vh - 170px);
    overflow-y: auto;
}

.item-row {
    display: flex;
    align-items: center;
    padding: 0.8rem 1.2rem;
    border-bottom: 1px solid #edf2f7;
    cursor: pointer;
    transition: background 0.1s;
}

.item-row:hover {
    background-color: #f1f5f9;
}

.item-name {
    flex: 2;
    font-weight: 500;
    color: #1e2a3a;
}

.item-id {
    flex: 1;
    color: #64748b;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

/* 关于页面 */
.about-container {
    max-width: 600px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.about-container h2 {
    margin-top: 0;
    color: #1e2a3a;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 0.5rem;
}

.about-container h3 {
    margin: 1.5rem 0 0.5rem;
    color: #1e2a3a;
}

.about-container p {
    line-height: 1.6;
    color: #334155;
    margin: 1rem 0;
}

.about-buttons {
    display: flex;
    gap: 1rem;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.about-button {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 40px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
    display: inline-block;
}

.about-button:hover {
    background-color: #2980b9;
}

.about-textarea {
    width: 100%;
    padding: 1rem;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
    background-color: #f9fafc;
    color: #1e2a3a;
}

/* 计算器页面 */
.calculator-layout {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
}
.calc-left, .calc-right {
    flex: 1;
}
.item-selector {
    background: white;
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    margin-bottom: 1rem;
}
.item-selector input {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    margin-bottom: 0.5rem;
}
.item-selector select {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 0.5rem;
    min-height: 160px;
}
.quantity-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.quantity-input input {
    width: 80px;
}
.selected-list {
    background: white;
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}
.selected-list ul {
    list-style: none;
    padding: 0;
    max-height: 200px;
    overflow-y: auto;
}
.selected-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    border-bottom: 1px solid #edf2f7;
}
.selected-list button {
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.2rem 0.6rem;
    cursor: pointer;
    font-size: 0.8rem;
}
.selected-list button:hover {
    background: #dc2626;
}
.calc-actions {
    display: flex;
    gap: 1rem;
    margin: 1.5rem 0;
}
.calc-actions button {
    padding: 0.8rem 2rem;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 40px;
    cursor: pointer;
    font-size: 1rem;
}
.calc-actions button:hover {
    background-color: #2980b9;
}
.calc-result {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.calc-result pre {
    background: #f8fafc;
    padding: 1rem;
    border-radius: 12px;
    font-family: 'Consolas', monospace;
    font-size: 0.9rem;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 400px;
    overflow-y: auto;
}

/* 基础材料管理页面 */
.base-materials-container {
    max-width: 900px;
    margin: 0 auto;
}
.base-controls {
    display: flex;
    gap: 1rem;
    margin: 1rem 0;
}
.base-lists {
    display: flex;
    gap: 2rem;
}
.base-available, .base-current {
    flex: 1;
}
.base-lists select {
    width: 100%;
    min-height: 300px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 0.5rem;
}
.base-lists input {
    width: 100%;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
}
.base-lists button {
    margin-top: 0.5rem;
    width: 100%;
    padding: 0.5rem;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}
.base-lists button:hover {
    background-color: #2980b9;
}
.base-actions {
    margin-top: 2rem;
    text-align: center;
}
.base-actions button {
    padding: 0.8rem 3rem;
    background-color: #2ecc71;
    color: white;
    border: none;
    border-radius: 40px;
    font-size: 1.1rem;
    cursor: pointer;
}
.base-actions button:hover {
    background-color: #27ae60;
}

/* 基础材料管理页面 - 导出/导入按钮样式 */
.base-controls button {
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}
.base-controls button:hover {
    background-color: #2980b9;
}
.base-controls button:active {
    transform: scale(0.98);
}

/* 计算器页面按钮样式 */
.quantity-input button {
    padding: 0.5rem 1rem;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}
.quantity-input button:hover {
    background-color: #2980b9;
}

/* 下载按钮样式 */
#download-result {
    margin-top: 0.5rem;
    padding: 0.5rem 1.5rem;
}

/* 设置页面 */
.settings-container {
    max-width: 600px;
    margin: 0 auto;
}
.stats-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}
.stats-card p {
    margin: 0.5rem 0;
    font-size: 1.1rem;
}
.danger-zone {
    background: #fff5f5;
    border: 1px solid #feb2b2;
    border-radius: 12px;
    padding: 1.5rem;
}
.danger-btn {
    background-color: #ef4444;
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    margin-right: 1rem;
}
.danger-btn:hover {
    background-color: #dc2626;
}
.note {
    font-size: 0.9rem;
    color: #6b7280;
    margin-top: 0.5rem;
}

/* 配方文件管理 */
.recipe-manager {
    max-width: 800px;
    margin: 0 auto;
    overflow-x: auto;  /* 添加横向滚动条 */
}
.recipe-table {
    width: max-content; /* 让表格根据内容自动撑开宽度 */
    min-width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}
.recipe-table th, .recipe-table td {
    padding: 0.8rem;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
    white-space: nowrap; /* 防止换行，保证单行显示 */
}
.recipe-table th {
    background: #f1f5f9;
    font-weight: 600;
}
.recipe-table input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}
.recipe-table input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.recipe-actions {
    margin-top: 1.5rem;
    text-align: center;
}
#save-recipe-btn {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 0.8rem 3rem;
    border-radius: 40px;
    font-size: 1.1rem;
    cursor: pointer;
}
#save-recipe-btn:hover {
    background-color: #2980b9;
}
.select-all-btn, .select-none-btn {
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 20px;
    padding: 0.4rem 1rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-right: 0.5rem;
}
.select-all-btn:hover, .select-none-btn:hover {
    background-color: #2980b9;
}

/* 统计条 */
.stats-bar {
    display: flex;
    justify-content: space-between;
    background-color: #e2e8f0;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: #1e2a3a;
}

/* 详情弹窗 */
.detail-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.detail-content {
    background: white;
    border-radius: 12px;
    padding: 1.2rem;
    max-width: 550px;
    width: 85%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

/* 详情头部 */
.detail-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.8rem;
}
.detail-header .close-btn {
    margin-left: auto;
    font-size: 1.3rem;
    cursor: pointer;
    color: #666;
}
.detail-header .back-btn {
    cursor: pointer;
    color: #3498db;
    font-size: 0.9rem;
    font-weight: 500;
}
.item-title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    flex: 1;
}
.item-id {
    font-size: 0.8rem;
    color: #666;
    font-weight: normal;
}

/* 物品信息 */
.item-info {
    font-size: 0.9rem;
    margin-bottom: 1rem;
}
.item-info p {
    margin: 0.3rem 0;
}

/* 数量控制 */
.quantity-control {
    margin: 0.8rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.quantity-control label {
    font-weight: 500;
    font-size: 0.9rem;
}
.quantity-control input {
    width: 70px;
    padding: 0.3rem 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
}
.quantity-control input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52,152,219,0.2);
}

/* 配方网格 */
.recipe-grid {
    display: grid;
    gap: 3px;
    margin: 0.8rem 0;
}
.recipe-cell {
    aspect-ratio: 1;
    border: 1px solid #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 1rem;
    background: #f8fafc;
    white-space: pre-line;
    padding: 2px;
    border-radius: 4px;
}
.recipe-cell.clickable {
    background-color: #c5deff;
}
.recipe-cell.clickable:hover {
    background-color: #a6ccff;
}
.recipe-cell.non-clickable {
    background-color: #dff4ff;
}
.recipe-cell.empty {
    background-color: #f0f0f0;
}

/* 详情操作按钮 */
.detail-actions {
    display: flex;
    gap: 0.8rem;
    margin: 1rem 0 0.8rem;
}
.detail-actions button {
    flex: 1;
    padding: 0.6rem 0.8rem;
    border: none;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.detail-actions .calc-materials-btn {
    background-color: #3498db;
    color: white;
}
.detail-actions .calc-materials-btn:hover {
    background-color: #2980b9;
}
.detail-actions .calc-steps-btn {
    background-color: #2ecc71;
    color: white;
}
.detail-actions .calc-steps-btn:hover {
    background-color: #27ae60;
}

/* 结果头部 */
.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0.8rem 0 0.3rem;
    font-size: 0.9rem;
}
.result-tools {
    display: flex;
    gap: 0.3rem;
}
.result-tools button {
    background: #f1f5f9;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    padding: 0.2rem 0.6rem;
    font-size: 0.7rem;
    cursor: pointer;
}
.result-tools button:hover {
    background: #e2e8f0;
}

/* 结果区域 */
.detail-result {
    background: #f1f5f9;
    padding: 0.8rem;
    border-radius: 8px;
    white-space: pre-wrap;
    font-family: 'Consolas', monospace;
    font-size: 0.8rem;
    max-height: 200px;
    overflow-y: auto;
    margin-top: 1rem;
}

/* ========== 手机端侧边栏折叠 ========== */
.menu-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1100;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.5rem;
    padding: 0.2rem 0.8rem;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

@media (max-width: 768px) {
    .menu-toggle {
        display: block !important;
    }
    .sidebar {
        position: fixed !important;
        top: 0 !important;
        left: -240px !important;
        width: 240px !important;
        height: 100% !important;
        z-index: 1000 !important;
        background-color: #1e2a3a !important;
        transition: left 0.3s ease !important;
        box-shadow: 2px 0 5px rgba(0,0,0,0.1) !important;
        overflow-y: auto !important;  /* 新增：允许垂直滚动 */
    }
    .sidebar.open {
        left: 0 !important;
    }
    .content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 1rem !important;
        padding-top: 3rem !important;
    }
}

/* 鸣谢区域 */
.acknowledgement {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
}
.acknowledgement h3 {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    color: #1e2a3a;
}
.acknowledgement ul {
    margin: 0;
    padding-left: 1.2rem;
}
.acknowledgement li {
    margin: 0.3rem 0;
}
.acknowledgement a {
    color: #3498db;
    text-decoration: none;
}
.acknowledgement a:hover {
    text-decoration: underline;
}

/* 视图内加载动画 */
.view-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
    color: #6c7a8d;
}
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top-color: #3498db;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 1rem;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}
.sidebar::-webkit-scrollbar-track {
    background: #2c3e50;
}
.sidebar::-webkit-scrollbar-thumb {
    background: #3498db;
    border-radius: 3px;
}