/* ===== CSS 变量 ===== */
:root {
    /* 启源芯动力品牌色（官网 SPIC 体系）：深蓝 #13397A / 启源绿 #18D18E */
    --primary: #13397a;
    --primary-dark: #0c2a5e;
    --primary-deep: #0a2250;
    --primary-light: #dce7f7;
    --accent: #18d18e;
    --accent-dark: #0fb877;
    --accent-light: #d7f7ec;
    --secondary: #5b6b85;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #dc2626;
    --bg: #f0f5fb;
    --card-bg: #ffffff;
    --text: #1b2a44;
    --text-light: #5b6b85;
    --border: #dfe7f1;
    --sidebar-w: 232px;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(15,40,90,.08);
    --shadow-lg: 0 6px 18px rgba(15,40,90,.12);
    --topbar-h: 56px;
}

/* ===== 基础 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, "Microsoft YaHei", "PingFang SC", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
}
a { text-decoration: none; color: inherit; }

/* ===== 布局 ===== */
.app { display: flex; min-height: 100vh; }

/* ===== 侧边栏 ===== */
.sidebar {
    width: var(--sidebar-w);
    background: #1e293b;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
}
.sidebar-logo {
    padding: 18px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid #334155;
}
.logo-icon { font-size: 20px; }
.nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    color: #94a3b8;
    transition: all .15s;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
}
.nav-item:hover { background: #334155; color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-icon { font-size: 16px; }

/* ===== 统一树形菜单（一级 调度管理 / 仓储管理 → 二级 / 三级） ===== */
.nav.tree { padding: 6px 0; }
.nav-group { margin: 1px 0; }
.nav-group-title {
    display: flex; align-items: center; gap: 6px;
    padding: 11px 16px;
    font-size: 14px; font-weight: 700; color: #e2e8f0;
    cursor: pointer; user-select: none;
}
.nav-group-title.lvl2 {
    font-weight: 600; color: #cbd5e1; font-size: 13px;
    padding: 9px 16px 9px 30px;
    background: rgba(255,255,255,.04);
    margin-top: 3px;
}
.nav-group-title .caret {
    font-size: 10px; display: inline-block; transition: transform .15s;
}
.nav-group.collapsed > .nav-group-title .caret,
.nav-subgroup.collapsed > .nav-group-title .caret { transform: rotate(-90deg); }
.nav-group.collapsed > .nav-group-body,
.nav-subgroup.collapsed > .nav-group-body { display: none; }
.nav.tree .nav-item { padding: 9px 16px 9px 40px; }
.nav.tree .nav-item.lvl3 { padding-left: 54px; font-size: 13px; }

.sidebar-footer { padding: 16px; border-top: 1px solid #334155; }
.btn-logout {
    width: 100%;
    padding: 10px;
    border: 1px solid #334155;
    border-radius: 8px;
    background: #fee2e2;
    color: #dc2626;
    font-size: 13px;
    cursor: pointer;
}

/* ===== 主内容区 ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    padding: 24px 28px;
    min-height: 100vh;
}
.page-title { font-size: 22px; font-weight: 700; margin-bottom: 20px; }
.view { display: none; }
.view.active { display: block; }

/* ===== 统计卡片 ===== */
.stats-cards { display: flex; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px 24px;
    flex: 1;
    min-width: 140px;
    box-shadow: var(--shadow);
    text-align: center;
}
.stat-value { font-size: 32px; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--text-light); margin-top: 4px; }

/* ===== 图表 ===== */
.chart-row { display: flex; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.chart-box {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px 20px;
    flex: 1;
    min-width: 300px;
    box-shadow: var(--shadow);
}
.chart-box h3 { font-size: 15px; margin-bottom: 12px; font-weight: 600; }
.chart-box canvas { max-height: 240px; }

/* ===== 表单 ===== */
.order-form { max-width: 900px; }
.form-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.form-section h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.form-grid.two-col { grid-template-columns: 1fr 1fr; }
.col-left { display: flex; flex-direction: column; gap: 16px; }
.col-right { display: flex; flex-direction: column; }
.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-field label { font-size: 13px; font-weight: 600; color: var(--text); }
.form-field input, .form-field select, .form-field textarea {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color .15s;
    background: #fff;
    color: var(--text);
}
.form-field input:focus, .form-field select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.form-field input[style*="grid-column: span 2"] { grid-column: span 2; }
.required { color: var(--danger); }
.field-hint { font-size: 11px; color: var(--text-light); font-weight: 400; }
.auto-calc { background: #f8fafc; color: var(--text-light); }
.form-actions { display: flex; gap: 12px; padding: 8px 0; }

/* ===== 地图 ===== */
.map-box {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    height: 100%;
    min-height: 320px;
    display: flex;
    flex-direction: column;
}
.map-toolbar {
    display: flex;
    gap: 6px;
    padding: 8px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}
.map-search-input { flex: 1; padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.map-container { flex: 1; min-height: 260px; background: #e2e8f0; }
.map-hint { padding: 6px 10px; font-size: 12px; color: var(--text-light); background: #f8fafc; text-align: center; }

/* ===== 按钮 ===== */
.btn-primary, .btn-secondary, .btn-outline, .btn-export {
    padding: 9px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--success); color: #fff; }
.btn-secondary:hover { background: #15803d; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: #f8fafc; }
.btn-export { background: #475569; color: #fff; width: 100%; }
.btn-export:hover { background: #334155; }
.btn-small { padding: 6px 12px; font-size: 12px; border: 1px solid var(--border); border-radius: 6px; background: #fff; cursor: pointer; }
.btn-small:hover { background: var(--primary-light); }
.btn-link { background: none; border: none; color: var(--primary); font-size: 12px; cursor: pointer; }
.btn-link:hover { text-decoration: underline; }
.btn-icon { padding: 4px 8px; border: 1px solid var(--border); border-radius: 4px; cursor: pointer; background: #fff; font-size: 13px; }
.btn-icon:hover { background: var(--primary-light); }
.btn-icon.danger:hover { background: #fee2e2; border-color: var(--danger); }

/* ===== 工具栏 ===== */
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.search-input { flex: 1; min-width: 240px; padding: 9px 14px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; }
.filter-select { padding: 9px 14px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; background: #fff; }

/* ===== 表格 ===== */
.table-wrap { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { background: #f1f5f9; padding: 10px 12px; text-align: left; font-size: 12px; font-weight: 700; color: var(--text-light); white-space: nowrap; border-bottom: 2px solid var(--border); }
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.data-table tr:hover { background: #f8fafc; }
.status-badge { padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.status-draft { background: #e2e8f0; color: #475569; }
.status-pending { background: #fef3c7; color: #92400e; }
.status-completed { background: #d1fae5; color: #065f46; }
.status-cancel { background: #fee2e2; color: #b91c1c; }

/* ===== 分页 ===== */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 16px; }
.pagination button { padding: 6px 12px; border: 1px solid var(--border); border-radius: 4px; background: #fff; cursor: pointer; font-size: 13px; }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

/* ===== 预设 ===== */
.preset-layout { display: flex; gap: 20px; }
.preset-form { flex: 0 0 360px; background: var(--card-bg); border-radius: var(--radius); padding: 20px 24px; box-shadow: var(--shadow); }
.preset-form .form-field { margin-bottom: 12px; }
.preset-list { flex: 1; background: var(--card-bg); border-radius: var(--radius); padding: 20px 24px; box-shadow: var(--shadow); }
.preset-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.preset-tab { padding: 6px 16px; border: 1px solid var(--border); border-radius: 6px; background: #fff; cursor: pointer; font-size: 13px; }
.preset-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.preset-card { padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: start; }
.preset-card:hover { background: #f8fafc; }
.preset-card-info { flex: 1; }
.preset-card-name { font-weight: 600; margin-bottom: 4px; }
.preset-card-detail { font-size: 12px; color: var(--text-light); }

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 12px 24px;
    border-radius: 8px;
    background: #1e293b;
    color: #fff;
    font-size: 14px;
    z-index: 9999;
    opacity: 0;
    transform: translateY(20px);
    transition: all .3s;
    pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ===== 货物明细动态行 ===== */
.item-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.item-row select, .item-row input {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
}
.item-name { flex: 2; }
.item-name-custom { flex: 2; }
.item-qty { flex: 1; min-width: 70px; }
.item-unit { flex: 0 0 70px; }

/* ===== 预设面板 ===== */
.preset-panel { display: none; }
.preset-panel.active { display: block; }
.preset-main-tabs { margin-bottom: 20px; }
.preset-main-tabs .preset-tab { padding: 8px 20px; font-size: 14px; }
.template-info {
    padding: 12px 14px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
}
.template-info p { margin-bottom: 4px; }

/* ===== 弹窗 ===== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.45);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal {
    background: #fff;
    border-radius: 12px;
    padding: 24px 28px;
    width: 380px;
    max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal h3 { font-size: 17px; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ===== 仓库出库入库网格 ===== */
.warehouse-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.warehouse-grid .data-table td { font-size: 12px; padding: 7px 10px; }
@media (max-width: 900px) { .warehouse-grid { grid-template-columns: 1fr; } }

/* ===== 附件列表 ===== */
.attachment-list img { cursor: pointer; }

/* ===== 截图/照片拖拽上传区 ===== */
#attachmentDropZone {
    display: block;
    border: 1.5px dashed var(--border, #cbd5e1);
    border-radius: 10px;
    padding: 14px 16px;
    cursor: pointer;
    transition: border-color .15s, background-color .15s;
}
#attachmentDropZone:hover { border-color: var(--accent, #2563eb); }
#attachmentDropZone.dragover {
    border-color: var(--accent, #2563eb);
    background: rgba(37, 99, 235, .06);
}

/* ===== 新建调运单：左右布局 + 实时预览（填写:预览 = 3:2 填满宽度） ===== */
.form-layout { display: flex; gap: 22px; align-items: flex-start; }
.form-left { flex: 3; min-width: 0; }
.form-right { flex: 2; min-width: 0; position: sticky; top: calc(var(--topbar-h) + 16px); }
@media (max-width: 1200px) {
    .form-layout { flex-direction: column; }
    .form-right { flex: 1; width: 100%; position: static; }
}

/* ===== 多个卸车位置 ===== */
.unload-point-row { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }
.unload-point-row input[type="text"] { flex: 1; }
.unload-point-row .unload-del {
    flex: 0 0 26px; width: 26px; height: 26px;
    border: none; border-radius: 50%;
    background: #fee2e2; color: #dc2626;
    cursor: pointer; font-size: 12px;
}
.unload-point-row .unload-del:hover { background: #fecaca; }
.preview-panel {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.preview-title {
    font-size: 14px; font-weight: 700; color: #2563eb;
    margin-bottom: 12px; padding-bottom: 8px;
    border-bottom: 2px solid #dbeafe;
}
.preview-doc {
    background: #fff;
    border: 1px solid #cbd5e1;
    padding: 12px;
    font-size: 12px;
    color: #1e293b;
}
.pv-title {
    text-align: center; font-weight: 700; font-size: 14px;
    margin-bottom: 8px; line-height: 1.5;
}
.pv-table {
    width: 100%; border-collapse: collapse; margin-bottom: 6px;
    table-layout: auto;
}
.pv-table td {
    border: 1px solid #94a3b8;
    padding: 4px 6px;
    font-size: 11px;
    word-break: break-all;
    vertical-align: top;
}
.pv-table .pv-label { background: #f1f5f9; font-weight: 600; width: 90px; white-space: nowrap; }
.pv-table .pv-value { color: #334155; }
.pv-goods .pv-head td { background: #e2e8f0; font-weight: 600; text-align: center; }
.pv-goods td { text-align: center; }
.pv-sign td { height: 34px; text-align: center; font-size: 11px; }
.preview-hint {
    font-size: 11px; color: #94a3b8; text-align: center; margin-top: 10px;
}

/* ===== 分享弹窗：外网/局域网 切换 ===== */
.share-mode-switch { justify-content: center; }
.share-mode-btn {
    flex: 1;
    padding: 7px 10px;
    font-size: 13px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #475569;
    border-radius: 6px;
    cursor: pointer;
    transition: all .15s;
}
.share-mode-btn:hover { background: #eef2f7; }
.share-mode-btn.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
    font-weight: 600;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .sidebar { position: relative; width: 100%; }
    .main-content { margin-left: 0; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid.two-col { grid-template-columns: 1fr; }
    .preset-layout { flex-direction: column; }
    .topbar { left: 0; padding: 0 12px; }
    .topbar-slogan { display: none; }
    .topbar-title { font-size: 12.5px; }
    body .main-content { padding-top: calc(var(--topbar-h) + 12px); }
    #view-wms { margin: 0; }
    #view-wms iframe { height: calc(100vh - var(--topbar-h)) !important; }
}

/* ================================================================
 * 启源芯动力品牌主题（深蓝 #13397A + 启源绿 #18D18E）
 * ================================================================ */
body { background: var(--bg); }

/* ---- 侧边栏：深蓝品牌渐变 ---- */
.sidebar {
    background: linear-gradient(180deg, #123a7c 0%, #0b2a5e 45%, #081f47 100%);
    color: rgba(255,255,255,.82);
    width: var(--sidebar-w);
    box-shadow: 2px 0 14px rgba(8,31,71,.18);
}
.sidebar-logo {
    padding: 20px 14px 18px;
    border-bottom: 1px solid rgba(255,255,255,.1);
    gap: 10px;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.sidebar-logo .sidebar-logo-text {
    font-size: 16px; line-height: 1.4; font-weight: 700; color: #fff;
    letter-spacing: 1px;
}
.logo-icon { font-size: 20px; }
.nav { flex: 1; padding: 10px 0; overflow-y: auto; }
.nav-group-title { color: rgba(255,255,255,.9); font-size: 13.5px; letter-spacing: .5px; }
.nav-group-title .caret { color: rgba(255,255,255,.5); }
.nav-group-title.lvl2 { color: rgba(255,255,255,.65); background: rgba(255,255,255,.05); }
.nav.tree .nav-item { color: rgba(255,255,255,.72); }
.nav.tree .nav-item:hover { background: rgba(255,255,255,.09); color: #fff; }
.nav.tree .nav-item.active {
    background: linear-gradient(90deg, rgba(24,209,142,.28), rgba(24,209,142,.10));
    color: #fff;
    border-left: 3px solid var(--accent);
    font-weight: 600;
}
/* 一级账号管理（顶级导航项） */
.nav-item.nav-top {
    padding: 12px 20px; margin: 6px 10px; border-radius: 8px;
    color: rgba(255,255,255,.85); font-weight: 600; font-size: 14px;
    background: rgba(255,255,255,.07);
}
.nav-item.nav-top:hover { background: rgba(24,209,142,.22); color: #fff; }
.nav-item.nav-top.active { background: linear-gradient(90deg,#18d18e,#0fb877); color: #062b1c; }
.sidebar-footer { padding: 14px 14px; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-footer .btn-export, .sidebar-footer .btn-logout { border-radius: 8px; }
.btn-logout { background: rgba(220,38,38,.15); border-color: rgba(220,38,38,.4); color: #fecaca; }
.btn-logout:hover { background: rgba(220,38,38,.35); color:#fff; }
.btn-export { background: rgba(255,255,255,.12); color: #fff; border:1px solid rgba(255,255,255,.18); }
.btn-export:hover { background: rgba(255,255,255,.22); }

/* ---- 主内容区 ---- */
.main-content {
    margin-left: var(--sidebar-w);
    padding: 24px 28px;
    min-height: 100vh;
}
/* 固定顶栏占位 */
body .main-content { padding-top: calc(var(--topbar-h) + 22px); }
/* WMS iframe 高度适配顶栏 */
#view-wms { margin: -22px -28px 0; }
#view-wms iframe { height: calc(100vh - var(--topbar-h)) !important; display: block; }

/* ---- 顶部栏（固定，右上是账户信息，各视图常驻） ---- */
.topbar {
    position: fixed;
    top: 0; left: var(--sidebar-w); right: 0;
    height: var(--topbar-h);
    z-index: 800;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px;
    background: rgba(255,255,255,.88);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid #e2eaf5;
    box-shadow: 0 2px 10px rgba(15,40,90,.05);
}
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.topbar-brand .topbar-logo { height: 24px; width:auto; }
.topbar-brand .topbar-title {
    font-size: 14.5px; font-weight: 700; color: var(--primary);
    letter-spacing: .3px;
}
.topbar-brand .topbar-slogan { font-size: 11px; color: var(--text-light); margin-left: 8px; }
.user-chip {
    display: flex; align-items: center; gap: 10px;
    padding: 5px 14px 5px 6px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 32px;
    box-shadow: 0 2px 8px rgba(15,40,90,.08);
    cursor: default;
}
.user-chip .user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent);
    background: #eef5fd;
}
.user-chip .user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.user-chip .user-name { font-size: 13.5px; font-weight: 700; color: var(--text); }
.user-chip .user-role { font-size: 11px; color: var(--primary); font-weight: 500; }
/* 主内容已由顶部规则预留顶栏空间 */

/* 页面标题微调 */
.page-title {
    font-size: 20px; font-weight: 700; margin-bottom: 18px; color: var(--primary);
    display:flex; align-items:center; gap:8px;
}
.page-title::before { content:""; width:4px; height:18px; border-radius:2px; background:linear-gradient(180deg,var(--accent),#0fb877); display:inline-block; }

/* ---- 卡片：浅蓝调 + 顶边点缀 ---- */
.stat-card, .chart-box, .form-section, .table-wrap, .preset-form, .preset-list {
    box-shadow: 0 2px 10px rgba(15,40,90,.06);
    border: 1px solid #e7eef8;
    border-radius: 12px;
}
.stat-value { color: var(--primary); }
.stat-card { position: relative; overflow: hidden; }
.stat-card::before {
    content:""; position:absolute; left:0; top:0; bottom:0; width:4px;
    background: linear-gradient(180deg, var(--primary), var(--accent));
    border-radius: 4px 0 0 4px;
}
.form-section h3, .chart-box h3 { color: var(--primary); }

/* ---- 按钮主色微调（蓝→品牌绿，配合整体） ---- */
.btn-primary { background: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--accent); color: #052e1c; }
.btn-secondary:hover { background: var(--accent-dark); color:#fff; }

/* ---- 表格表头 ---- */
.data-table th { background: #f3f7fd; color: var(--primary); border-bottom: 2px solid var(--accent); }
/* 列宽拖拽调整 */
.data-table th { position: relative; }
.col-resizer {
    position: absolute; top: 0; right: -4px;
    width: 9px; height: 100%;
    cursor: col-resize; z-index: 5;
}
.col-resizer:hover, .col-resizer.active { background: rgba(24,209,142,.35); }

/* ---- 登录遮罩：品牌深蓝渐变 + 光效 + 白色 LOGO ---- */
#loginOverlay {
    background:
        radial-gradient(1100px 600px at 85% -10%, rgba(24,209,142,.22), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(24,209,142,.15), transparent 55%),
        linear-gradient(135deg, #0a2250 0%, #123a7c 55%, #0e5fa8 100%) !important;
}
#loginOverlay::before, #loginOverlay::after {
    content:""; position:absolute; border-radius: 50%;
    filter: blur(1px); opacity:.25; pointer-events:none;
}
#loginOverlay::before { width:340px; height:340px; right:-80px; top:-60px; border:2px dashed rgba(255,255,255,.5); }
#loginOverlay::after { width:220px; height:220px; left:-50px; bottom:-40px; border:2px dashed rgba(24,209,142,.6); }
.login-card {
    background: rgba(255,255,255,.97);
    border-radius: 18px;
    padding: 34px 36px 30px;
    width: 380px;
    box-shadow: 0 24px 70px rgba(0,0,0,.35);
    position: relative;
}
.login-card .login-brand { text-align:center; margin-bottom: 6px; }
.login-card .login-logo { height: 44px; width:auto; margin-bottom: 12px; }
.login-card h1 { font-size: 17px; font-weight: 800; color: var(--primary); margin: 6px 0 2px; }
.login-card .login-sub { font-size: 11px; color: var(--text-light); margin-bottom: 20px; }
.login-card .login-field { margin-bottom: 12px; }
.login-card .login-field input {
    width:100%; padding: 11px 14px; border:1px solid var(--border);
    border-radius: 10px; font-size:14px; box-sizing:border-box;
    background:#f8fafd; transition: all .15s;
}
.login-card .login-field input:focus {
    outline:none; border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(24,209,142,.18); background:#fff;
}
.login-btn {
    width:100%; padding: 12px; border:none; border-radius:10px;
    background: linear-gradient(90deg, #13397a, #0e5fa8);
    color:#fff; font-size:15px; font-weight:700; cursor:pointer;
    transition: all .15s;
}
.login-btn:hover { background: linear-gradient(90deg, #0c2a5e, #0c4d8f); box-shadow: 0 6px 16px rgba(18,58,124,.35); }
.login-foot { font-size: 11px; color:#8aa0bd; text-align:center; margin-top:16px; line-height:1.6; }

/* 手机端菜单按钮：桌面隐藏，窄屏媒体查询里打开 */
.mobile-menu-btn {
    display: none;
    align-items: center; justify-content: center;
    width: 34px; height: 34px; flex: 0 0 34px;
    border: 1px solid var(--border); border-radius: 8px;
    background: #fff; color: var(--primary);
    font-size: 18px; line-height: 1; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* ================================================================
 * 手机 / 窄屏适配（2026-11-11）
 * 必须放在文件最后：品牌主题样式块在中段，会把旧的 @media 规则反向覆盖，
 * 导致手机上侧栏仍是 232px、主内容仍留 232px 边距、顶栏从 232px 开始。
 * 桌面端（>768px）不受本块任何影响。
 * ================================================================ */
@media (max-width: 768px) {
    html, body {
        width: 100%; max-width: 100%;
        height: auto !important;
        overflow-x: hidden !important;
    }
    body { -webkit-text-size-adjust: 100%; -webkit-overflow-scrolling: touch; }

    /* 侧边栏 → 抽屉；主内容由外层文档统一纵向滚动 */
    .app { display: block !important; min-height: 100vh; }
    .sidebar {
        position: fixed !important; top: 0 !important; left: 0 !important; bottom: 0 !important;
        width: 84vw !important; max-width: 300px;
        transform: translateX(-103%); transition: transform .22s ease;
        z-index: 1200; overflow-y: auto !important;
        -webkit-overflow-scrolling: touch; box-shadow: none;
    }
    body.mobile-nav-open .sidebar {
        transform: translateX(0); box-shadow: 6px 0 24px rgba(0,0,0,.28);
    }
    body.mobile-nav-open::after {
        content: ""; position: fixed; inset: 0;
        background: rgba(15,23,42,.45); z-index: 1100;
    }
    .nav, .nav.tree { overflow-y: auto !important; }
    .nav.tree .nav-item.lvl3 { padding-top: 11px; padding-bottom: 11px; }

    /* 固定顶栏：全宽 + 汉堡按钮 */
    .topbar { left: 0 !important; right: 0 !important; padding: 0 10px !important; z-index: 1000; }
    .topbar-brand { gap: 6px; min-width: 0; }
    .topbar-slogan { display: none !important; }
    .topbar-title { font-size: 12px; white-space: nowrap; }
    .topbar-logo { height: 20px; }
    .user-chip { padding: 3px 8px 3px 4px; gap: 6px; flex-shrink: 0; }
    .user-chip .user-meta { display: none !important; }
    .mobile-menu-btn { display: inline-flex !important; }

    /* 主内容：全宽、可滚动 */
    .main-content, body .main-content {
        margin-left: 0 !important; width: 100% !important;
        padding: calc(var(--topbar-h) + 12px) 12px 32px !important;
        min-height: 100vh; overflow: visible !important;
    }
    .view { width: 100%; }
    .page-title { font-size: 18px; margin-bottom: 14px; }

    /* WMS iframe：高度按 iframe 实际内容撑开，让「外层页面」滚动。
       iOS Safari 对固定高度 iframe 会自动撑高/屏蔽内部滚动，是手机上滑不动的主因。
       高度由 index.html 底部脚本写入 --wms-frame-h；未写入时回退一屏。 */
    #view-wms { margin: 0 !important; }
    #view-wms iframe {
        height: calc(100vh - var(--topbar-h)) !important;
        height: var(--wms-frame-h, calc(100dvh - var(--topbar-h))) !important;
        min-height: 0 !important; display: block;
    }
    .wms-wrap, body.wms-embedded .wms-wrap { display: block !important; min-height: 0 !important; }
    .wms-main, body.wms-embedded .wms-main {
        padding: 12px !important; min-height: 0 !important;
        width: 100% !important; overflow: visible !important;
    }
    /* 直接打开 /wms/ 独立页：侧栏变顶部横向可滑菜单。
       必须用 .wms-wrap 限定：主框架 body 同样不带 wms-embedded，
       用 body:not(...) 会误伤主框架抽屉。 */
    .wms-wrap > .sidebar {
        position: relative !important; width: 100% !important; max-width: none;
        height: auto !important; transform: none !important;
        overflow: visible !important; box-shadow: none; z-index: 1;
    }
    .wms-wrap > .sidebar .sidebar-logo { padding: 10px 12px; justify-content: flex-start; }
    .wms-wrap > .sidebar .nav {
        display: flex !important; flex-direction: row !important; flex-wrap: nowrap !important;
        overflow-x: auto !important; overflow-y: hidden !important; white-space: nowrap;
        -webkit-overflow-scrolling: touch; padding: 4px 6px !important;
    }
    .wms-wrap > .sidebar .nav-item { flex: 0 0 auto; padding: 8px 12px !important; }
    .wms-wrap > .sidebar .sidebar-footer { display: none; }
    /* 表格只保留横向滑动，纵向交给页面统一滚动 */
    .scroll-x { max-height: none !important; overflow-y: visible !important; overflow-x: auto !important; }
    .table-wrap { overflow-x: auto !important; -webkit-overflow-scrolling: touch; max-width: 100%; }
    /* 主框架表格：给每列最小宽度，避免窄屏被压成单字竖排；表格在容器内横滑 */
    .table-wrap > .data-table { min-width: 780px; }
    .table-wrap > .data-table td {
        white-space: normal !important; word-break: break-word !important;
        min-width: 150px !important;
    }
    .table-wrap > .data-table td:first-child,
    .table-wrap > .data-table th:first-child { min-width: 48px !important; }
    table { font-size: 12px; }
    .wms-title { font-size: 17px; }

    /* 表单 / 栅格：单列 */
    .form-grid, .form-grid.two-col, .grid2, .grid4, .formgrid, .mkt-form,
    .preset-layout, .form-layout, .warehouse-grid {
        grid-template-columns: 1fr !important; flex-direction: column !important;
    }
    .form-left, .form-right, .col-left, .col-right { width: 100%; }
    .form-right { position: static !important; }
    .form-section, .card { padding: 14px !important; }
    .stats-cards { gap: 10px; }
    .stat-card { min-width: calc(50% - 6px) !important; padding: 14px 10px; }
    .stat-value { font-size: 24px; }
    .chart-box { min-width: 0 !important; width: 100%; }
    .chart-box canvas { max-height: 220px; }
    .item-row { flex-wrap: wrap; }
    .item-name, .item-name-custom, .item-qty { min-width: 0; flex: 1 1 45%; }

    /* 工具条 / 输入：不溢出屏幕 */
    .toolbar, .form-actions, .pager, .modal-actions { flex-wrap: wrap !important; gap: 6px !important; }
    .toolbar input, .toolbar select, .toolbar button,
    .search-input, .filter-select, .modal input, .modal select,
    .toolbar [style*="min-width"] {
        min-width: 0 !important; max-width: 100% !important;
    }
    .toolbar input, .toolbar select, .search-input, .filter-select { flex: 1 1 130px; }
    .toolbar button { flex: 0 0 auto; }

    /* 弹窗：宽度自适应、内部可滚 */
    .modal-overlay { padding: 12px !important; align-items: flex-start !important; overflow-y: auto !important; }
    .modal, .modal-overlay .modal, .modal-bg > .modal {
        min-width: 0 !important; width: 94vw !important; max-width: 94vw !important;
        max-height: 86dvh !important; overflow: auto !important;
        padding: 16px !important; margin: auto !important;
    }
    .modal-bg { align-items: flex-start !important; padding: 12px; overflow-y: auto; }
    #toast { max-width: 90vw; }

    /* 登录页：小屏可滚动，卡片自适应 */
    #loginOverlay { align-items: flex-start !important; overflow-y: auto !important; padding: 20px 12px !important; }
    .login-card {
        width: 100% !important; max-width: 380px;
        padding: 24px 20px !important; margin: auto !important;
    }
    .login-card h1 { font-size: 16px; }
    .login-apply, .login-forgot { font-size: 12px; }
}
