/* ===== 进销存系统 - 全局样式 ===== */

:root {
    --primary: #1a73e8;
    --primary-dark: #1557b0;
    --primary-light: #e8f0fe;
    --success: #0d9488;
    --danger: #dc2626;
    --warning: #f59e0b;
    --bg: #f5f7fa;
    --card-bg: #ffffff;
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #ffffff;
    --sidebar-active-bg: #1a73e8;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --radius: 8px;
    --radius-sm: 5px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
}

/* ===== 布局 ===== */
.app-container { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.app-body { display: flex; flex: 1; min-height: 0; }

.app-container.frozen-active {
    height: 100vh;
    overflow: hidden;
}


/* ===== 侧边栏 ===== */
.sidebar {
    width: 230px;
    min-width: 230px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 40px;
    left: 0;
    bottom: 0;
    z-index: 99;
    transition: width 0.25s ease, min-width 0.25s ease;
}

.sidebar-header {
    padding: 20px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    position: relative;
}

.logo-icon {
    width: 40px; height: 40px;
    background: #fff;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    object-fit: contain;
    padding: 4px;
    box-sizing: border-box;
}

.logo-text h1 { font-size: 15px; color: #fff; font-weight: 600; }
.logo-text span { font-size: 11px; color: var(--sidebar-text); }

/* 侧边栏折叠/展开按钮 */
.sidebar-toggle {
    margin-left: auto;
    width: 28px; height: 28px;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    padding: 0;
}
.sidebar-toggle:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
    border-color: rgba(255,255,255,0.3);
}
.toggle-icon { font-size: 16px; line-height: 1; }
/* 默认展开态：显示 ◀(向左箭头，提示可折叠) */
.sidebar-toggle .toggle-icon-expand { display: none; }
.sidebar-toggle .toggle-icon-collapse { display: inline; }
/* 折叠态：显示 ▶(向右箭头，提示可展开) */
.sidebar.collapsed .sidebar-toggle .toggle-icon-collapse { display: none; }
.sidebar.collapsed .sidebar-toggle .toggle-icon-expand { display: inline; }

/* ===== 侧边栏折叠状态（仅图标列，参考极简侧栏风格） ===== */
.sidebar.collapsed {
    width: 56px;
    min-width: 56px;
}
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-arrow,
.sidebar.collapsed .footer-text {
    display: none !important;
}
/* 头部：logo 居中，无内边距 */
.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 14px 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
/* logo 缩小 */
.sidebar.collapsed .logo-icon {
    width: 32px; height: 32px;
    padding: 3px;
}
/* 导航区：垂直堆叠、图标居中 */
.sidebar.collapsed .sidebar-nav {
    padding: 8px 0;
    gap: 0;
    align-items: center;
}
/* 每个模块：垂直居中、单行 */
.sidebar.collapsed .nav-group {
    width: 100%;
    margin-bottom: 0;
}
.sidebar.collapsed .nav-group-header {
    justify-content: center;
    padding: 12px 0;
    border-radius: 0;
}
/* 图标本身加大、居中 */
.sidebar.collapsed .nav-icon {
    width: auto;
    font-size: 20px;
    line-height: 1;
}
/* 折叠按钮：外凸到右侧，半圆形 */
.sidebar.collapsed .sidebar-toggle {
    position: absolute;
    top: 50%;
    right: -12px;
    transform: translateY(-50%);
    background: var(--sidebar-bg);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 50%;
    width: 24px; height: 24px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    padding: 0;
}
.sidebar.collapsed .sidebar-toggle .toggle-icon {
    font-size: 11px;
    line-height: 1;
}
/* footer 也居中 */
.sidebar.collapsed .sidebar-footer {
    padding: 10px 0;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-nav {
    flex: 1; padding: 12px 8px;
    display: flex; flex-direction: column; gap: 2px;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

/* 侧边栏滚动条（暗色主题） */
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.18);
    border-radius: 3px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }
.sidebar-nav { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.18) transparent; }

.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-radius: var(--radius-sm);
    color: var(--sidebar-text); text-decoration: none;
    font-size: 14px; transition: all 0.2s; cursor: pointer;
}

.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }

.nav-item.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active);
    font-weight: 500;
}

.nav-icon { font-size: 16px; width: 22px; text-align: center; }

/* ===== 侧边栏分组折叠 ===== */
.nav-group {
    margin-bottom: 2px;
}

.nav-group-header {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-radius: var(--radius-sm);
    color: var(--sidebar-text); font-size: 14px;
    cursor: pointer; transition: all 0.2s;
    user-select: none;
}

.nav-group-header:hover {
    background: rgba(255,255,255,0.08); color: #fff;
}

.nav-group-header .nav-arrow {
    font-size: 10px; margin-left: auto;
    transition: transform 0.25s ease;
    opacity: 0.6;
    transform: rotate(-90deg);  /* 默认指向右，提示"点击右侧展开" */
}

.nav-group.flyout-open .nav-arrow {
    transform: rotate(0deg);  /* 展开后指向下 */
    opacity: 1;
}

/* 预警红点指示器 */
.nav-badge-dot {
    display: inline-block;
    width: 8px; height: 8px;
    background: #ff4444;
    border-radius: 50%;
    margin-left: 6px;
    animation: pulse-dot 1.5s infinite;
    flex-shrink: 0;
}

.nav-sub-dot {
    display: inline-block;
    width: 6px; height: 6px;
    background: #ff4444;
    border-radius: 50%;
    margin-left: auto;
    flex-shrink: 0;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.3); }
}

/* ===== 子菜单飞出面板（右侧弹出） ===== */
.nav-group-body {
    display: none;
    position: fixed;
    z-index: 200;
    min-width: 180px;
    background: var(--sidebar-bg);
    border: 1px solid rgba(255,255,255,0.12);
    border-left: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    box-shadow: 4px 2px 16px rgba(0,0,0,0.35);
    padding: 6px;
}

.nav-group.flyout-open .nav-group-body {
    display: block;
    animation: flyoutIn 0.18s ease;
}

@keyframes flyoutIn {
    from { opacity: 0; transform: translateX(-12px); }
    to { opacity: 1; transform: translateX(0); }
}

/* 高亮当前飞出的模块标题 */
.nav-group.flyout-open .nav-group-header {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

.nav-sub-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px 8px 36px; border-radius: var(--radius-sm);
    color: var(--sidebar-text); text-decoration: none;
    font-size: 13px; transition: all 0.2s; cursor: pointer;
}

.nav-sub-item:hover { background: rgba(255,255,255,0.08); color: #fff; }

.nav-sub-item.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active);
    font-weight: 500;
}

/* 飞出面板中的子菜单项：减少缩进 */
.nav-group-body .nav-sub-item {
    padding: 8px 14px;
    white-space: nowrap;
}

.sidebar-footer {
    padding: 12px 16px; font-size: 11px;
    border-top: 1px solid rgba(255,255,255,0.1);
    color: var(--text-muted); text-align: center;
}

/* ===== 主内容区 ===== */
.content-area {
    margin-left: 230px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left 0.25s ease;
}

/* 侧边栏折叠时内容区左缩进同步 */
.app-container.sidebar-collapsed .content-area {
    margin-left: 56px;
}

.main-content {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

/* 侧边栏折叠时主内容区左缩进同步（兼容旧引用） */
.app-container.sidebar-collapsed .main-content {
    margin-left: 0;
}

/* ===== 固定顶部 + 滚动 body 的列表页布局 ===== */
.tab-panel.active.frozen-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    padding: 24px;
    box-sizing: border-box;
}

.frozen-page-top {
    flex-shrink: 0;
}

.frozen-page-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-top: 12px;
}

.frozen-page-body .card {
    border: none;
    box-shadow: none;
    background: transparent;
    overflow: visible !important;
}

.frozen-page-body .card-body {
    padding: 0;
}

/* 冻结表头：直接相对于 frozen-page-body 的滚动容器 */
.frozen-page-body thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #f8fafc;
}

/* 多行表头：第二行粘在第一行下方 */
.frozen-page-body thead tr:nth-child(2) th {
    top: 40px;
}

/* 左侧列冻结（4列：日期/姓名/电话/当天合计） */
.frozen-page-body .pw-freeze {
    position: sticky;
    z-index: 5;
    background: #fff;
}
.frozen-page-body thead th.pw-freeze {
    z-index: 12;
    background: #f8fafc;
}
.frozen-page-body tfoot td.pw-freeze {
    z-index: 6;
    background: #f8fafc;
}
.frozen-page-body .pw-freeze-1 { left: 0; min-width: 115px; }
.frozen-page-body .pw-freeze-2 { left: 115px; min-width: 90px; }
.frozen-page-body .pw-freeze-3 { left: 205px; min-width: 100px; }
.frozen-page-body .pw-freeze-4 { left: 305px; min-width: 80px; }
/* 冻结列右侧加一道阴影，提示可滚动 */
.frozen-page-body .pw-freeze-4 {
    box-shadow: 2px 0 4px rgba(0,0,0,0.08);
}

/* ===== 通用：冻结左侧前 4 列（物品名称 / 规格 / 类别 / 单位） =====
   用于「出入库汇总表」「原材料差异表」这类横向很宽的报表：
   固定宽度 + 内层裁剪，保证横向滚动时左侧 4 列不动、且不会因长名称撑宽导致错位。 */
.frozen-page-body .fx-col {
    position: sticky;
    z-index: 5;
    background: #fff;
}
.frozen-page-body thead th.fx-col {
    z-index: 12;
    background: #f8fafc;
}
.frozen-page-body tfoot td.fx-col {
    z-index: 6;
    background: #f8fafc;
}
.frozen-page-body .fx-col-1 { left: 0;     width: 170px; min-width: 170px; max-width: 170px; }
.frozen-page-body .fx-col-2 { left: 170px; width: 100px; min-width: 100px; max-width: 100px; }
.frozen-page-body .fx-col-3 { left: 270px; width: 100px; min-width: 100px; max-width: 100px; }
.frozen-page-body .fx-col-4 {
    left: 370px; width: 60px; min-width: 60px; max-width: 60px;
    box-shadow: 2px 0 4px rgba(0,0,0,0.08);
}
/* 合计行的合并单元格（colspan=4）：只吸顶左侧，不设宽度 */
.frozen-page-body .fx-span { left: 0; }
/* 冻结列内层裁剪：长文本省略号显示，鼠标悬停看完整内容（用 title） */
.fx-clip { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 多行表头：合并列（如期初/进货）跨多列时居中显示 */
.frozen-page-body thead th[colspan] {
    text-align: center;
}

/* ===== 多标签页栏 ===== */
.tab-bar {
    display: flex;
    align-items: center;
    background: #f1f5f9;
    border-bottom: 1px solid var(--border);
    padding: 0 8px;
    height: 38px;
    flex-shrink: 0;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 2px;
    scrollbar-width: thin;
}
.tab-bar::-webkit-scrollbar { height: 3px; }
.tab-bar::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }

.tab-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 8px 0 14px;
    background: #e2e8f0;
    border-radius: 6px 6px 0 0;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
    border: 1px solid transparent;
    border-bottom: none;
    user-select: none;
    position: relative;
}
.tab-item:hover {
    background: #f8fafc;
    color: var(--text);
}
.tab-item.active {
    background: #fff;
    color: var(--primary);
    font-weight: 500;
    border-color: var(--border);
}
.tab-item .tab-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    font-size: 14px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1;
}
.tab-item .tab-close:hover {
    background: var(--danger);
    color: #fff;
}
.tab-item.active .tab-close {
    color: var(--text-secondary);
}

/* ===== 标签页内容面板 ===== */
.tab-panel {
    display: none;
    height: 100%;
    box-sizing: border-box;
}
.tab-panel.active {
    display: block;
    overflow: auto;
    padding: 24px;
}
/* 非冻结时也用 flex 确保高度填满 */
.tab-panel.active:not(.frozen-layout) {
    display: block;
}

/* 空状态（无标签页时） */
.tab-empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 15px;
}

/* ===== 页面头部 ===== */
.page-header {
    display: flex; justify-content: space-between;
    align-items: flex-start; margin-bottom: 20px;
    flex-wrap: wrap; gap: 12px;
}

.page-header-left h2 {
    font-size: 22px; font-weight: 600; color: var(--text);
}

.page-header-left p {
    font-size: 13px; color: var(--text-secondary); margin-top: 4px;
}

.page-header-right {
    display: flex; gap: 8px; flex-wrap: wrap;
}

/* ===== 按钮 ===== */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border: none; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 500; cursor: pointer;
    transition: all 0.2s; text-decoration: none;
    white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #0f766e; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; }

.btn-outline {
    background: #fff; color: var(--text); border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 2px 8px; font-size: 11px; }

/* ===== 卡片 ===== */
.card {
    background: var(--card-bg); border-radius: var(--radius);
    box-shadow: var(--shadow); overflow: hidden;
}

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

.card-body { padding: 16px 20px; }

/* ===== 表格 ===== */
.table-wrapper { overflow-x: auto; }

table {
    width: 100%; border-collapse: collapse;
}

thead th {
    background: #f8fafc; padding: 10px 14px;
    text-align: left; font-size: 12px; font-weight: 600;
    color: var(--text-secondary); border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 10px 14px; border-bottom: 1px solid var(--border-light);
    font-size: 13px;
}

tbody tr:hover { background: #f8fafc; }

/* 冻结布局下 tfoot 合计行固定在底部 */
.frozen-page-body tfoot tr {
    position: sticky;
    bottom: 0;
    z-index: 10;
}

/* 冻结布局下的表格：用 border-collapse:separate 让多行表头粘性正常堆叠 */
.frozen-page-body table {
    border-collapse: separate;
    border-spacing: 0;
}

/* 冻结布局下：用单元格边框替代 collapse 重叠边框 */
.frozen-page-body thead th {
    border-right: 1px solid var(--border-light);
}
.frozen-page-body thead th:last-child {
    border-right: none;
}
.frozen-page-body tbody td {
    border-right: 1px solid var(--border-light);
}
.frozen-page-body tbody td:last-child {
    border-right: none;
}

.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-center { text-align: center; }

/* ===== 状态标签 ===== */
.status-badge {
    display: inline-block; padding: 2px 10px;
    border-radius: 12px; font-size: 11px; font-weight: 500;
}

.status-active { background: #dcfce7; color: #166534; }
.status-disabled { background: #fee2e2; color: #991b1b; }

/* 加工单客户选择器锁定状态 */
.proc-customer-locked {
    opacity: 0.5;
    background: #f0f0f0 !important;
    cursor: not-allowed;
}

/* ===== 操作按钮组 ===== */
.action-btns {
    display: flex; gap: 4px; flex-wrap: wrap;
}

/* ===== 模态框 ===== */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 1000;
    display: flex; align-items: center; justify-content: center;
}

.sub-modal-overlay {
    z-index: 2000;
}

.modal-container {
    background: #fff; border-radius: var(--radius);
    box-shadow: var(--shadow-md); width: 90%; max-width: 600px;
    max-height: 85vh; display: flex; flex-direction: column;
}

.modal-container.wide { max-width: 1000px; }
.modal-container.xwide { max-width: 1400px; }
.modal-container.xxwide { max-width: 92vw; width: 1500px; }

.modal-container .items-table {
    width: 100%; border-collapse: collapse; margin-top: 12px;
}

.modal-container .items-table th {
    background: #f8fafc; padding: 6px 8px; font-size: 11px;
    text-align: left; border: 1px solid var(--border);
}

.modal-container .items-table td {
    padding: 4px 6px; border: 1px solid var(--border-light);
    vertical-align: middle;
}

.modal-container .items-table input,
.modal-container .items-table select {
    width: 100%; padding: 5px 6px; border: 1px solid var(--border);
    border-radius: 3px; font-size: 12px; outline: none;
}

.modal-container .items-table input:focus,
.modal-container .items-table select:focus {
    border-color: var(--primary);
}

.cost-card-items-table {
    width: 100%; border-collapse: collapse;
    counter-reset: cc-item-row;
}
.cost-card-items-table thead th {
    background: #f8fafc; padding: 8px 6px; font-size: 12px;
    text-align: left; border: 1px solid var(--border); font-weight: 600;
}
.cost-card-items-table tbody td {
    padding: 4px 6px; border: 1px solid var(--border-light);
    vertical-align: middle;
}
.cost-card-items-table tbody tr {
    counter-increment: cc-item-row;
}
.cost-card-items-table tbody tr .cci-seq::before {
    content: counter(cc-item-row);
}
.cost-card-items-table input,
.cost-card-items-table select {
    width: 100%; padding: 5px 6px; border: 1px solid var(--border);
    border-radius: 3px; font-size: 12px; outline: none;
}
.cost-card-items-table input:focus,
.cost-card-items-table select:focus {
    border-color: var(--primary);
}

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

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

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

.modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; }

.modal-footer {
    padding: 14px 24px; border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 8px;
}

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

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

.form-group label .required { color: var(--danger); margin-left: 2px; }

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%; padding: 8px 12px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 13px;
    color: var(--text); background: #fff; transition: border-color 0.2s;
    outline: none;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

.form-row-3 { display: flex; gap: 12px; }
.form-row-3 .form-label { flex: 0 0 auto; }
.form-row-3 .form-input { flex: 1; }
.form-row-3 .form-hint {
    flex: 0 0 auto; display: flex; align-items: center;
    font-size: 12px; color: var(--text-secondary); white-space: nowrap;
}

/* ===== 空状态 ===== */
.empty-state {
    text-align: center; padding: 48px 20px; color: var(--text-muted);
}
.empty-state-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ===== Toast 提示 ===== */
.toast-container {
    position: fixed; top: 20px; right: 20px; z-index: 9999;
    display: flex; flex-direction: column; gap: 8px;
}

.toast {
    padding: 12px 20px; border-radius: var(--radius-sm);
    color: #fff; font-size: 13px; box-shadow: var(--shadow-md);
    animation: slideIn 0.3s ease; max-width: 380px;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--primary); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ===== 上传区域 ===== */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius); padding: 40px 20px;
    text-align: center; cursor: pointer; transition: all 0.2s;
    background: #fafbfc; margin-bottom: 16px;
}

.upload-area:hover, .upload-area.drag-over {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-area-icon { font-size: 40px; margin-bottom: 8px; }
.upload-area p { font-size: 13px; color: var(--text-secondary); }
.upload-area .hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ===== 导入结果 ===== */
.import-result {
    margin-top: 16px; padding: 12px 16px;
    border-radius: var(--radius-sm); font-size: 13px;
}

.import-result.success { background: #dcfce7; color: #166534; }
.import-result.error { background: #fee2e2; color: #991b1b; }

.import-result ul { margin-top: 8px; padding-left: 20px; }

/* ===== 搜索/筛选栏 ===== */
.toolbar {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}

/* ===== 进货单搜索栏 ===== */
.search-bar {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
    padding: 14px 16px; background: #f8fafc;
    border: 1px solid var(--border); border-radius: var(--radius);
    margin-bottom: 16px;
}

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

.search-bar .search-group label {
    font-size: 11px; color: var(--text-secondary); font-weight: 500;
}

.search-bar .search-group input,
.search-bar .search-group select {
    padding: 6px 10px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 12px;
    outline: none; min-width: 120px;
}

.search-bar .search-group input:focus,
.search-bar .search-group select:focus {
    border-color: var(--primary);
}

.search-bar .btn { align-self: flex-end; }

/* ===== 自动补全下拉 ===== */
.autocomplete-wrapper {
    position: relative;
}

.autocomplete-wrapper input {
    width: 100%; padding: 5px 6px; border: 1px solid var(--border);
    border-radius: 3px; font-size: 12px; outline: none;
}

.autocomplete-wrapper input:focus {
    border-color: var(--primary);
}

.autocomplete-dropdown {
    position: absolute; top: 100%; left: 0; right: 0;
    max-height: 200px; overflow-y: auto;
    background: #fff; border: 1px solid var(--border);
    border-top: none; border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    z-index: 2000; display: none; box-shadow: var(--shadow-md);
}

.autocomplete-dropdown.show { display: block; }

.autocomplete-dropdown .ac-item {
    padding: 6px 10px; font-size: 12px; cursor: pointer;
    border-bottom: 1px solid var(--border-light);
}

.autocomplete-dropdown .ac-item:hover {
    background: var(--primary-light);
}

.autocomplete-dropdown .ac-item .ac-name { font-weight: 500; }
.autocomplete-dropdown .ac-item .ac-spec {
    font-size: 11px; color: var(--text-muted); margin-left: 6px;
}

.autocomplete-dropdown .ac-empty {
    padding: 8px 10px; font-size: 12px; color: var(--text-muted);
    text-align: center;
}

.autocomplete-dropdown .ac-no-results {
    padding: 10px 12px;
    font-size: 12px;
    color: #e74c3c;
    line-height: 1.6;
    cursor: default;
    border-bottom: 1px solid var(--border-light);
}

/* 商品定价模糊搜索下拉 */
.dropdown-suggestions {
    position: absolute;
    top: 100%; left: 0; right: 0;
    max-height: 200px; overflow-y: auto;
    background: #fff;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    z-index: 2050;
    box-shadow: var(--shadow-md);
}
.dropdown-suggestions .dropdown-item {
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
}
.dropdown-suggestions .dropdown-item:hover {
    background: var(--primary-light);
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .sidebar { width: 60px; min-width: 60px; }
    .sidebar .logo-text,
    .sidebar .nav-label,
    .sidebar .nav-arrow,
    .sidebar-footer { display: none; }
    .sidebar-header { justify-content: center; padding: 16px 8px; }
    .nav-group-header { justify-content: center; padding: 10px; }
    .content-area { margin-left: 60px; }
    .main-content { padding: 0; }
    .tab-panel.active { padding: 16px; }
    .form-row { flex-direction: column; }
    .form-row-3 { flex-direction: column; }
    .modal-container { width: 95%; }
    .modal-container.wide, .modal-container.xwide, .modal-container.xxwide { max-width: 95%; }
}

/* ==================== 登录页面 ==================== */
.login-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, #1a237e 0%, #283593 50%, #3949ab 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.login-box {
    background: #fff;
    border-radius: 12px;
    padding: 40px 36px;
    width: 360px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.login-logo {
    text-align: center;
    margin-bottom: 28px;
}
.login-logo-icon {
    width: 96px;
    height: 96px;
    display: block;
    margin: 0 auto 12px;
    object-fit: contain;
}
.login-logo h2 {
    font-size: 22px;
    color: #333;
    margin: 0;
}
.login-field {
    margin-bottom: 18px;
}
.login-field label {
    display: block;
    font-size: 13px;
    color: #666;
    margin-bottom: 6px;
}
.login-field input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 15px;
    box-sizing: border-box;
    transition: border-color 0.2s;
}
.login-field input:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 3px rgba(26,115,232,0.1);
}
.login-error {
    color: #d32f2f;
    font-size: 13px;
    text-align: center;
    margin-bottom: 12px;
    padding: 8px;
    background: #ffebee;
    border-radius: 4px;
}
.login-btn {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border-radius: 6px;
    cursor: pointer;
    border: none;
}

.login-footer {
    text-align: center;
    margin-top: 12px;
    font-size: 13px;
}
.login-footer a {
    color: #1a73e8;
    text-decoration: none;
}
.login-footer a:hover {
    text-decoration: underline;
}

/* ==================== 顶部用户信息栏 ==================== */
.topbar {
    height: 40px;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.topbar-user {
    font-size: 14px;
    color: #333;
    font-weight: 500;
}
.topbar-badge {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}
.topbar-badge.badge-admin { background: #fce4ec; color: #c62828; }
.topbar-badge.badge-l1 { background: #e8f5e9; color: #2e7d32; }
.topbar-badge.badge-l2f { background: #f3e5f5; color: #6a1b9a; }
.topbar-badge.badge-l2 { background: #fff3e0; color: #e65100; }
.topbar-badge.badge-l3 { background: #e3f2fd; color: #1565c0; }
.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ==================== 权限标签 ==================== */
.perm-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
}
.perm-tag.perm-admin { background: #fce4ec; color: #c62828; }
.perm-tag.perm-l1 { background: #e8f5e9; color: #2e7d32; }
.perm-tag.perm-l2f { background: #f3e5f5; color: #6a1b9a; }
.perm-tag.perm-l2 { background: #fff3e0; color: #e65100; }
.perm-tag.perm-l3 { background: #e3f2fd; color: #1565c0; }

/* ==================== 数字输入框：去除上下调整按钮 ==================== */
.modal-container input[type=number]::-webkit-outer-spin-button,
.modal-container input[type=number]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.modal-container input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}
/* .num-input: 文本模式数字输入框（支持 selectionStart/End 用于方向键导航） */
.num-input {
    text-align: right;
}

/* ==================== 键盘方向键导航 ==================== */
.items-table tr.focused-row td {
    background: #fff8e1 !important;
}
.items-table input.cell-focused {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 2px rgba(26,115,232,0.15);
}

/* ==================== 主页仪表盘 ==================== */

/* 侧边栏主页入口 */
.nav-home-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    margin: 4px 8px;
    transition: all 0.2s;
    cursor: pointer;
}
.nav-home-item:hover {
    background: rgba(255,255,255,0.08);
    color: var(--sidebar-active);
}
.nav-home-item .nav-icon {
    font-size: 16px;
    flex-shrink: 0;
}

/* 折叠态 */
.sidebar.collapsed .nav-home-item {
    justify-content: center;
    padding: 10px 0;
}
.sidebar.collapsed .nav-home-item .nav-label {
    display: none;
}

/* 仪表盘容器 */
.dashboard {
    padding: 4px 0;
}

/* 欢迎区 */
.dashboard-hero {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: var(--radius);
    padding: 24px 28px;
    margin-bottom: 20px;
    color: #fff;
}
.dashboard-hero h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6px;
}
.dashboard-hero p {
    font-size: 14px;
    opacity: 0.92;
}
.dashboard-hero p strong {
    font-size: 16px;
    margin: 0 2px;
}

/* 数据区块 */
.dash-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    overflow: hidden;
}
.dash-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg);
}
.dash-section-icon {
    font-size: 18px;
}
.dash-section-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    flex: 1;
}
.dash-section-link {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 13px;
    cursor: pointer;
    padding: 2px 4px;
    transition: opacity 0.2s;
}
.dash-section-link:hover {
    opacity: 0.7;
    text-decoration: underline;
}

/* 数据卡片 */
.dash-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 1px;
    background: var(--border-light);
}
.dash-card {
    flex: 1;
    min-width: 120px;
    padding: 18px 16px;
    text-align: center;
    background: var(--card-bg);
    transition: transform 0.15s;
}
.dash-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    z-index: 1;
}
.dash-card-value {
    font-size: 26px;
    font-weight: 800;
    color: var(--text);
    line-height: 1.2;
    margin-bottom: 4px;
}
.dash-card-label {
    font-size: 12px;
    color: var(--text-muted);
}
.dash-card-highlight {
    background: linear-gradient(135deg, #fff8e1 0%, #fff3cd 100%);
}
.dash-card-highlight .dash-card-value {
    color: var(--danger);
}
.dash-card-highlight .dash-card-label {
    color: #856404;
    font-weight: 600;
}

/* 快捷入口 */
.dash-shortcuts {
    margin-top: 20px;
}
.dash-shortcuts-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
    padding-left: 4px;
}
.dash-shortcuts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
}
.dash-shortcut-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 18px 12px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    color: var(--text-secondary);
}
.dash-shortcut-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.dash-shortcut-icon {
    font-size: 24px;
}

/* 响应式 */
@media (max-width: 768px) {
    .dash-cards {
        flex-direction: column;
    }
    .dash-card {
        min-width: 100%;
    }
    .dash-shortcuts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
