/* ============================================
   EVE制造信息查询计算器 - 样式（门户浅色统一风格）
   变量名沿用历史命名，取值与门户 lunar/typing 页一致
   ============================================ */

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

:root {
    --primary: #2f6fe0;
    --primary-dark: #2559b8;
    --danger: #e74c3c;
    --success: #1e8e3e;
    --warning: #f39c12;
    --bg: #f4f7fc;
    --bg-card: #ffffff;
    --bg-input: #fbfcfe;
    --bg-hover: #f0f4fa;
    --border: #e5eaf2;
    --text: #1f2937;
    --text-secondary: #5b6675;
    --text-muted: #8a94a6;
    --accent: #d97706;
    --brand-2: #3aa6d8;
    --brand-soft: #eaf1fe;
    --radius: 14px;
    --shadow: 0 2px 10px rgba(31,41,55,.05);
}

body {
    font-family: 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ========== 顶部导航栏（门户统一） ========== */
.site-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255,255,255,.92);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--border);
}

.nav-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 17px;
    color: var(--text);
}

.brand img { width: 26px; height: 26px; display: block; }
.brand:hover { text-decoration: none; }

.nav-links {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 22px;
    font-size: 14px;
}

.nav-links a { color: var(--text-secondary); }
.nav-links a:hover { color: var(--primary); text-decoration: none; }

.nav-login {
    padding: 6px 16px;
    border: 1px solid var(--primary);
    border-radius: 999px;
    color: var(--primary) !important;
    font-size: 13px;
}

.nav-login:hover { background: var(--brand-soft); text-decoration: none; }

/* 免费工具下拉菜单（悬停展开） */
.nav-dropdown { position: relative; }
.nav-dropdown-toggle { display: inline-flex; align-items: center; gap: 4px; }
.nav-dropdown-toggle svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.nav-dropdown:hover .nav-dropdown-toggle svg { transform: rotate(180deg); }
.nav-dropdown-menu {
    position: absolute; top: 100%; right: 0; min-width: 190px; padding: 8px;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
    box-shadow: 0 12px 32px rgba(35,64,112,.16);
    display: none; flex-direction: column; z-index: 130;
}
.nav-dropdown-menu::before { content: ""; position: absolute; top: -10px; left: 0; right: 0; height: 10px; }
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu { display: flex; }
.nav-dropdown-menu a { padding: 8px 12px; border-radius: 8px; color: var(--text-secondary) !important; font-size: 13.5px; white-space: nowrap; }
.nav-dropdown-menu a:hover { background: var(--brand-soft); color: var(--primary) !important; text-decoration: none; }


/* ========== 页面标题（门户统一渐变标题） ========== */
.page-head {
    padding: 34px 20px 6px;
    text-align: center;
    max-width: 1400px;
    margin: 0 auto;
}

.page-head h1 {
    margin: 0 0 8px;
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(120deg, var(--primary), var(--brand-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.page-head p {
    margin: 0 auto;
    max-width: 640px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* ========== 功能页签条 ========== */
.tool-tabnav {
    position: sticky;
    top: 51px;
    z-index: 90;
    background: rgba(244,247,252,.94);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--border);
}

.tool-tabnav-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.tool-tabnav-inner::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 12px 20px;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--primary);
}

.tab-btn.active {
    color: var(--primary);
    font-weight: 600;
    border-bottom-color: var(--primary);
}

/* ========== 主内容区 ========== */
.app-main {
    flex: 1;
    padding: 16px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* 主卡片统一阴影（与门户工具页一致） */
.global-params,
.calc-target,
.material-list,
.stats-panel,
.data-table,
.rev-panel,
.card-item,
.modal-content {
    box-shadow: var(--shadow);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.panel-header h2 {
    font-size: 18px;
    font-weight: 600;
}

/* ========== 按钮 ========== */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: linear-gradient(120deg, var(--primary), var(--brand-2));
    color: white;
    font-weight: 600;
}

.btn-primary:hover {
    opacity: 0.94;
}

.btn-default {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-default:hover {
    background: var(--border);
}

.btn-warning {
    background: var(--warning);
    color: #fff;
    font-weight: 600;
}

.btn-warning:hover {
    background: #d9820b;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
    min-height: 28px;
}

/* ========== 全局参数区 ========== */
.global-params {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

.param-group {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.param-group label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.multiplier-input {
    display: flex;
    align-items: center;
    gap: 6px;
}

.multiplier-input input {
    width: 80px;
    padding: 8px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--accent);
    font-size: 16px;
    font-weight: 600;
    text-align: center;
}

.multiplier-input .unit {
    color: var(--text-secondary);
    font-size: 14px;
}

.param-tip {
    font-size: 12px;
    color: var(--text-muted);
    width: 100%;
    margin-top: 4px;
}

/* ========== 计算目标区 ========== */
.calc-target {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

.target-row {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.target-field {
    flex: 1;
    min-width: 150px;
}

.target-field label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.target-field select,
.target-field input {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 14px;
}

/* 面包屑 */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.breadcrumb-item {
    padding: 4px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.breadcrumb-item:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.breadcrumb-item.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    cursor: default;
}

.breadcrumb-sep {
    color: var(--text-muted);
    font-size: 12px;
}

/* ========== 物料列表 ========== */
.material-list {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    overflow: hidden;
}

.material-list-header {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-input);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.material-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    align-items: center;
    font-size: 14px;
}

.material-row:last-child {
    border-bottom: none;
}

.material-row .mat-name {
    font-weight: 500;
}

.material-row .mat-base {
    color: var(--text-muted);
    text-decoration: line-through;
}

.material-row .mat-actual {
    color: var(--accent);
    font-weight: 600;
}

.material-row .mat-price {
    color: var(--text-secondary);
}

.material-row .mat-subtotal {
    color: var(--success);
    font-weight: 600;
}

.view-recipe-btn {
    padding: 4px 10px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
}

.view-recipe-btn:hover {
    background: var(--primary-dark);
}

/* ========== 物料折叠树 ========== */
.material-row .mat-name {
    display: flex;
    align-items: center;
    min-width: 0;
}

.mat-name-text {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

/* 展开/折叠箭头 */
.tree-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    font-size: 9px;
    line-height: 1;
    color: var(--primary);
    border-radius: 3px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s, transform 0.15s;
}

.tree-toggle:hover {
    background: rgba(47, 111, 224, 0.12);
}

.tree-toggle.expanded {
    /* 展开态箭头朝下，字符已为 ▼ */
}

/* 无子配方的占位箭头，保持名称对齐 */
.tree-dot {
    visibility: hidden;
    cursor: default;
}

/* 可展开的组件行 */
.material-row.row-component {
    background: rgba(47, 111, 224, 0.05);
}

.component-name {
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
}

.component-name:hover {
    text-decoration: underline;
}

.component-badge {
    font-size: 10px;
    line-height: 1.5;
    padding: 0 6px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    white-space: nowrap;
}

/* 组件“按制造/按成品外购”切换按钮 */
.buy-toggle {
    margin-left: 6px;
    font-size: 10px;
    line-height: 1.5;
    padding: 0 7px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
}
.buy-toggle:hover { border-color: var(--primary); color: var(--primary); }
.buy-toggle.is-buy {
    background: rgba(245, 166, 35, 0.15);
    border-color: #f5a623;
    color: #f5a623;
}
.buy-badge {
    font-size: 10px;
    line-height: 1.5;
    padding: 0 6px;
    border-radius: 8px;
    background: #f5a623;
    color: #fff;
    white-space: nowrap;
    margin-left: 4px;
}
.row-buy .mat-name-text { color: #f5a623; }

/* 可逆推标记：可以-绿色 / 不可以-红色 */
.rev-tag {
    font-size: 12px;
    font-weight: 600;
    padding: 1px 8px;
    border-radius: var(--radius);
    white-space: nowrap;
}
.rev-tag.rev-yes { color: #16a34a; background: rgba(22, 163, 74, 0.12); }
.rev-tag.rev-no { color: #dc2626; background: rgba(220, 38, 38, 0.12); }

/* 制造配方 / 逆推配方 切换页签 */
.recipe-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}
.recipe-tab {
    padding: 4px 14px;
    font-size: 13px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
}
.recipe-tab:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.recipe-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.recipe-tab:disabled { opacity: 0.5; cursor: not-allowed; }

/* 是否可逆推复选行 */
.checkbox-line {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: normal;
    color: var(--text-muted);
    cursor: pointer;
}
.checkbox-line input { width: 16px; height: 16px; cursor: pointer; margin: 0; }

/* 成品关联蓝图的蓝图单价提示 */
.bp-price-hint {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0 6px;
    line-height: 1.6;
    white-space: nowrap;
}

/* ========== 多计算目标 ========== */
.target-add-field {
    white-space: nowrap;
}

.calc-targets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.calc-targets-empty {
    font-size: 12px;
    color: var(--text-muted);
}

.calc-target-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-input);
    border: 1px solid var(--primary);
    border-radius: 20px;
    padding: 4px 8px 4px 12px;
    font-size: 13px;
}

.calc-target-chip .chip-name {
    font-weight: 500;
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calc-target-chip .chip-mult {
    color: var(--text-muted);
}

.calc-target-chip .chip-count {
    width: 68px;
    padding: 3px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-card);
    font-size: 13px;
    color: var(--text);
}

.calc-target-chip .chip-remove {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

.calc-target-chip .chip-remove:hover {
    color: #e11d48;
}

/* 物料树中每个目标蓝图的分组标题 */
.target-group-title {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: rgba(47, 111, 224, 0.08);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}

.target-group-title.group-toggle:hover {
    background: rgba(47, 111, 224, 0.16);
}

.target-group-title .tg-toggle {
    width: 16px;
    color: var(--primary);
    font-size: 11px;
    color: var(--primary);
}

.target-group-title .tg-count {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 12px;
}

.empty-state {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
}

/* ========== 底部统计面板 ========== */
.stats-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    /* 2026-10-10：取消整面板吸底（原为 sticky bottom:0，滚动时悬浮遮挡上方物料清单），
       改为与上方物料清单一致的正常文档流布局 */
}

.stats-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.stats-toolbar-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

/* 汇总面板折叠开关（2026-10-10）：标题可点击，默认折叠 */
.stats-toolbar-title.stats-toggle {
    cursor: pointer;
    user-select: none;
}

.stats-toolbar-title.stats-toggle:hover {
    color: var(--primary);
}

/* 总计金额常显条：明细折叠时仍显示（从表尾提取） */
.stats-grand {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: rgba(245, 147, 34, 0.06);
}

.stats-grand-label {
    font-weight: 600;
    color: var(--text);
    font-size: 13px;
}

.stats-grand .grand-total {
    font-size: 17px;
    font-weight: 800;
    color: var(--accent, #f59322);
}

.stats-toolbar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.stats-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.stats-tab {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.stats-tab.active {
    color: var(--primary);
    background: var(--bg-input);
    border-bottom: 2px solid var(--primary);
}

.stats-content {
    /* 横向 + 纵向滚动统一交给 .stats-table-wrapper，
       否则 wrapper 的 overflow-x 会成为表头 sticky 的滚动祖先，导致吸顶失效 */
}

.stats-table-wrapper {
    /* 2026-10-10：取消纵向限高（原 max-height:420px 会产生竖滚动条），
       纵向随页面滚动；仅保留横向滚动，供宽度不足时查看完整列 */
    overflow-x: auto;
    overflow-y: visible;
}

.stats-table-wrapper.hidden {
    display: none;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.stats-table th {
    padding: 10px 12px;
    text-align: left;
    background: var(--bg-input);
    color: var(--text-secondary);
    font-weight: 600;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 6;
    box-shadow: inset 0 -1px 0 var(--border);
}

.stats-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.stats-table .num-accent {
    color: var(--accent);
    font-weight: 600;
}

.stats-table .num-success {
    color: var(--success);
    font-weight: 600;
}

/* 整合成本表：蓝图行 / 制造费占位 / 总计行 */
.stats-table tr.blueprint-line td {
    background: rgba(47, 111, 224, 0.06);
}

.stats-table tr.blueprint-line td:first-child {
    color: var(--primary);
    font-weight: 500;
}

.stats-table td.cell-dash {
    color: var(--text-muted);
    text-align: right;
}

.stats-table tr.total-row td {
    border-top: 2px solid var(--primary);
    padding-top: 12px;
    font-weight: 700;
    text-align: left;
    color: #f5a623;
}

.stats-table tr.total-row td.grand-total {
    color: #f5a623;
    font-size: 16px;
    font-weight: 700;
    text-align: right;
}

/* 保存按钮提交中（防重复点击） */
.btn:disabled,
.btn[disabled],
.btn.btn-loading {
    opacity: 0.65;
    cursor: not-allowed;
    pointer-events: none;
}

.empty-cell {
    text-align: center;
    color: var(--text-muted);
    padding: 20px !important;
}

/* 费用统计 */
.fee-summary {
    padding: 16px;
}

.fee-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.fee-item:last-child {
    border-bottom: none;
}

.fee-item .fee-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.fee-item .fee-label small {
    color: var(--text-muted);
    font-size: 11px;
}

.fee-item .fee-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.fee-item.total {
    padding-top: 16px;
    margin-top: 4px;
    border-top: 2px solid var(--primary);
    border-bottom: none;
}

.fee-item.total .fee-label {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.fee-item.total .fee-value {
    font-size: 20px;
    color: var(--accent);
}

/* ========== 数据表格（材料库/蓝图库） ========== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table .action-btns {
    display: flex;
    gap: 8px;
}

/* 卡片列表（移动端） */
.card-list {
    display: none;
}

.card-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 10px;
}

.card-item .card-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.card-item .card-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 13px;
}

.card-item .card-row .label {
    color: var(--text-secondary);
}

.card-item .card-row .value {
    color: var(--text);
}

.card-item .card-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.card-item .card-actions .btn {
    flex: 1;
}

/* ========== 弹窗 ========== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-large {
    max-width: 640px;
}

.modal-small {
    max-width: 360px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

/* 表单 */
.form-group {
    margin-bottom: 16px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group .required {
    color: var(--danger);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

/* 物料行（蓝图编辑） */
.material-rows {
    margin-bottom: 10px;
}

.material-row-item {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}

.material-row-item select {
    flex: 2;
    padding: 8px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
}

.material-row-item input {
    flex: 1;
    padding: 8px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
}

.material-row-item .remove-row {
    width: 32px;
    height: 32px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    flex-shrink: 0;
}

/* ========== 底部（门户统一页脚） ========== */
.site-footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    margin-top: 30px;
    padding: 12px 20px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
}

/* ========== 响应式：平板 ========== */
@media (max-width: 900px) {
    .material-list-header,
    .material-row {
        grid-template-columns: 1.5fr 1fr 1fr 1fr auto;
    }

    .material-list-header .col-price,
    .material-row .mat-price {
        display: none;
    }
}

/* ========== 响应式：手机 ========== */
@media (max-width: 600px) {
    .nav-inner {
        padding: 12px;
    }

    .nav-links a:not(.nav-login) {
        display: none;
    }
    .nav-dropdown {
        display: none;
    }

    .page-head h1 {
        font-size: 22px;
    }

    .tool-tabnav {
        top: 50px;
    }

    .app-main {
        padding: 10px;
    }

    .tab-btn {
        padding: 10px 14px;
        font-size: 13px;
    }

    /* 表格转卡片 */
    .data-table {
        display: none;
    }

    .card-list {
        display: block;
    }

    /* 物料列表适配 */
    .material-list-header {
        display: none;
    }

    .material-row {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding: 12px;
    }

    .material-row .mat-name {
        grid-column: 1 / -1;
        font-size: 15px;
        padding-bottom: 4px;
        border-bottom: 1px solid var(--border);
    }

    .material-row .mat-base,
    .material-row .mat-actual,
    .material-row .mat-subtotal {
        font-size: 13px;
    }

    .material-row .mat-base::before {
        content: "基础: ";
        color: var(--text-muted);
    }

    .material-row .mat-actual::before {
        content: "实际: ";
        color: var(--text-muted);
    }

    .material-row .mat-subtotal::before {
        content: "小计: ";
        color: var(--text-muted);
    }

    .material-row .view-recipe-btn {
        grid-column: 1 / -1;
        width: 100%;
        padding: 8px;
    }

    /* 全局参数 */
    .param-group {
        flex-direction: column;
        align-items: flex-start;
    }

    .multiplier-input {
        width: 100%;
    }

    .multiplier-input input {
        flex: 1;
    }

    /* 弹窗 */
    .modal {
        padding: 0;
        align-items: flex-end;
    }

    .modal-content {
        max-width: 100%;
        max-height: 92vh;
        border-radius: 12px 12px 0 0;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    /* 统计面板 */
    .stats-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: var(--radius) var(--radius) 0 0;
        z-index: 50;
    }

    .stats-table-wrapper {
        max-height: 45vh;
    }

    .app-main {
        padding-bottom: 60px;
    }

    /* 按钮最小点击区域 */
    .btn,
    .tab-btn,
    .breadcrumb-item,
    .view-recipe-btn {
        min-height: 44px;
    }

    .btn-sm {
        min-height: 36px;
    }
}

/* ========== 搜索框 ========== */
.panel-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 6px;
}

.search-box input {
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    width: 180px;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
}

/* ========== 分页控件 ========== */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 10px 10px;
    margin-top: -1px;
}

.pagination-info {
    font-size: 13px;
    color: var(--text-secondary);
}

.pagination-buttons {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pagination-pages {
    display: flex;
    gap: 4px;
}

.page-btn {
    padding: 6px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    min-width: 32px;
    text-align: center;
    transition: all 0.2s;
}

.page-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.page-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* 分页按钮禁用状态 */
.pagination-buttons .btn:disabled {
    cursor: not-allowed;
}

/* ========== 响应式：手机端搜索和分页 ========== */
@media (max-width: 600px) {
    .panel-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .panel-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        width: 100%;
    }

    .search-box input {
        flex: 1;
        width: auto;
    }

    .pagination {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }

    .pagination-info {
        text-align: center;
        font-size: 12px;
    }

    .pagination-buttons {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* ========== 类型筛选 ========== */
.filter-box {
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-box select {
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    min-width: 120px;
}

.filter-box select:focus {
    outline: none;
    border-color: var(--primary);
}

/* ========== 类型标签 ========== */
.type-tag {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(59, 130, 246, 0.15);
    color: var(--primary);
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
}

/* 移动端类型筛选 */
@media (max-width: 768px) {
    .filter-box {
        width: 100%;
    }

    .filter-box select {
        flex: 1;
        width: 100%;
    }
}

/* ========== 大弹窗 ========== */
.modal-large {
    max-width: 720px;
    width: 90%;
}

/* ========== 选择材料弹窗 ========== */
.picker-source-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--border);
}

.source-tab {
    padding: 10px 24px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.source-tab:hover {
    color: var(--text);
}

.source-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.picker-filters {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-group label {
    font-size: 12px;
    color: var(--text-secondary);
}

.filter-group select,
.filter-group input {
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
}

.filter-group select:focus,
.filter-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.filter-search {
    flex: 1;
    min-width: 180px;
}

.picker-list {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
}

.picker-item {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
    gap: 12px;
}

.picker-item:last-child {
    border-bottom: none;
}

.picker-item:hover {
    background: var(--bg-hover);
}

.picker-item.selected {
    background: rgba(59, 130, 246, 0.1);
}

.picker-item-name {
    flex: 1;
    font-size: 14px;
    color: var(--text);
}

.picker-item-type {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-input);
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

.picker-item-check {
    width: 20px;
    text-align: center;
    color: var(--primary);
    font-weight: bold;
    font-size: 16px;
}

.picker-empty {
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

.picker-selected {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.picker-selected-title {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.picker-selected-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.selected-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(59, 130, 246, 0.15);
    color: var(--primary);
    border-radius: 16px;
    font-size: 13px;
}

.selected-remove {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
    opacity: 0.7;
}

.selected-remove:hover {
    opacity: 1;
}

/* ========== 蓝图物料行（新样式） ========== */
.material-row-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.mat-name {
    flex: 1;
    min-width: 0;
}

.mat-name-text {
    font-size: 14px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.mat-count {
    width: 100px;
    padding: 6px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-size: 13px;
    text-align: center;
}

.mat-count:focus {
    outline: none;
    border-color: var(--primary);
}

.remove-row {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.15s;
}

.remove-row:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* 物料来源标签 */
.source-tag {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    margin-left: 6px;
    vertical-align: middle;
}

.source-mat {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.source-bp {
    background: rgba(168, 85, 247, 0.15);
    color: #a855f7;
}

/* 移动端选择弹窗适配 */
@media (max-width: 768px) {
    .modal-large {
        width: 95%;
        max-height: 90vh;
    }

    .picker-filters {
        flex-direction: column;
    }

    .filter-search {
        min-width: 100%;
    }

    .picker-list {
        max-height: 240px;
    }

    .material-row-item {
        flex-wrap: wrap;
    }

    .mat-name {
        width: 100%;
        flex: none;
    }

    .mat-count {
        flex: 1;
        width: auto;
    }
}


/* ===== 逆推计算标签 ===== */
.rev-panel{background:var(--bg-card);border:1px solid var(--border);border-radius:10px;padding:14px 16px;margin:14px 0;}
.rev-panel-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:10px;}
.rev-panel-title{font-size:15px;font-weight:600;}
.rev-panel-title small{color:var(--text-secondary);font-weight:400;margin-left:6px;}
.rev-rate-area{background:var(--bg-input);border:1px solid var(--border);border-radius:8px;padding:10px 12px;margin-bottom:12px;}
.rev-rate-line{display:flex;flex-wrap:wrap;align-items:center;gap:16px;margin:4px 0;font-size:13px;}
.rev-base-rate b{color:var(--text);}
.rev-bonus-list{display:flex;flex-wrap:wrap;gap:16px;}
/* 解码器单选组（2026-10-10）：独占一行，与上方复选加成区分 */
.rev-decryptor-list{margin-top:6px;padding-top:6px;border-top:1px dashed var(--border);}
.rev-bonus-item{display:inline-flex;align-items:center;gap:6px;cursor:pointer;user-select:none;color:var(--text-secondary);}
.rev-bonus-item input{margin:0;}
.rev-rate-final{color:var(--text);}
.rev-final-num{color:var(--accent);font-size:16px;}
.rev-grand{display:flex;justify-content:flex-end;align-items:baseline;gap:12px;margin:10px 2px 24px;font-size:15px;}
.rev-grand .grand-total{font-size:18px;color:var(--accent);}


/* ===== 制造计算：单价就地修改 ===== */
.price-num{margin-right:6px;}
.price-edit-btn{margin-left:2px;padding:0 6px;height:20px;line-height:18px;font-size:11px;border:1px solid var(--border);background:var(--bg-input);color:var(--text-secondary);border-radius:4px;cursor:pointer;}
.price-edit-btn:hover{border-color:var(--primary);color:var(--primary);}
.price-modal-name{font-size:15px;font-weight:600;margin-top:4px;}
.price-modal-current{color:var(--accent);font-size:14px;margin-top:4px;}
#priceModal .modal-content{max-width:420px;}
