/* ====== 基础 ====== */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    --c-bg: #f5f7fa;
    --c-card: #ffffff;
    --c-text: #2c3e50;
    --c-muted: #90a4ae;
    --c-primary: #2c7be5;
    --c-primary-d: #1a68d4;
    --c-danger: #e74c3c;
    --c-success: #27ae60;
    --c-warn: #f39c12;
    --c-border: #e3e8ef;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.06);
}
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--c-bg);
    color: var(--c-text);
    font-size: 14px;
    line-height: 1.6;
}
a { color: var(--c-primary); text-decoration: none; }
a:hover { color: var(--c-primary-d); text-decoration: underline; }

/* ====== 顶栏 ====== */
.topbar {
    background: linear-gradient(90deg, #1a68d4 0%, #2c7be5 100%);
    color: #fff;
    box-shadow: var(--shadow);
}
.topbar-inner {
    max-width: 1280px; margin: 0 auto;
    padding: 0 20px; height: 56px;
    display: flex; align-items: center; gap: 24px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 16px; }
.brand-mark {
    width: 28px; height: 28px;
    background: #fff; color: var(--c-primary);
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700;
}
.menu { display: flex; gap: 4px; flex: 1; }
.menu a {
    color: rgba(255,255,255,0.85);
    padding: 6px 12px; border-radius: 6px;
    font-size: 14px; transition: all .15s;
}
.menu a:hover { background: rgba(255,255,255,0.15); color: #fff; text-decoration: none; }
.menu a.active { background: rgba(255,255,255,0.22); color: #fff; font-weight: 500; }
.user-box { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.user-name { color: #fff; }
.user-role { font-size: 12px; padding: 2px 6px; border-radius: 4px; }
.role-admin { background: #fff3cd; color: #856404; }
.role-user  { background: #d4edda; color: #155724; }
.btn-logout {
    color: #fff; padding: 4px 10px;
    border: 1px solid rgba(255,255,255,0.5);
    border-radius: 4px; font-size: 12px;
}
.btn-logout:hover { background: rgba(255,255,255,0.15); text-decoration: none; }
.nav-toggle {
    display: none;
    background: rgba(255,255,255,0.2); border: none; color: #fff;
    font-size: 20px; line-height: 1; cursor: pointer;
    padding: 6px 12px; border-radius: 6px;
}
.nav-toggle:hover { background: rgba(255,255,255,0.3); }

/* ====== 容器 ====== */
.container { max-width: 1280px; margin: 20px auto; padding: 0 20px; }
.footer {
    max-width: 1280px; margin: 30px auto; padding: 16px 20px;
    border-top: 1px solid var(--c-border);
    color: var(--c-muted); font-size: 12px;
    display: flex; justify-content: space-between;
}

/* ====== 卡片 ====== */
.card {
    background: var(--c-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
}
.card-title {
    font-size: 16px; font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--c-border);
    display: flex; justify-content: space-between; align-items: center;
}

/* ====== 表格 ====== */
.table {
    width: 100%; border-collapse: collapse;
}
.table th, .table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--c-border);
    font-size: 14px;
}
.table th { background: #f8fafc; font-weight: 600; color: #5a6877; }
.table tr:hover td { background: #fafbfc; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.muted { color: var(--c-muted); }
.amount { font-variant-numeric: tabular-nums; font-weight: 600; color: #d9534f; }

/* ====== 按钮 ====== */
.btn {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid var(--c-border);
    background: #fff;
    color: var(--c-text);
    font-size: 13px;
    cursor: pointer;
    line-height: 1.5;
    transition: all .15s;
}
.btn:hover { text-decoration: none; border-color: var(--c-primary); color: var(--c-primary); }
.btn-primary { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.btn-primary:hover { background: var(--c-primary-d); color: #fff; }
.btn-danger { background: var(--c-danger); color: #fff; border-color: var(--c-danger); }
.btn-danger:hover { background: #c0392b; color: #fff; }
.btn-sm { padding: 3px 8px; font-size: 12px; }
.btn-ghost { background: transparent; }
.btn-in  { background: #2e9e5b; color: #fff; border-color: #2e9e5b; }
.btn-in:hover  { background: #248a4c; color: #fff; }
.btn-out { background: #d9534f; color: #fff; border-color: #d9534f; }
.btn-out:hover { background: #c0392b; color: #fff; }

/* ====== 表单 ====== */
.form-row { margin-bottom: 14px; }
.form-row label { display: block; margin-bottom: 6px; font-weight: 500; color: #5a6877; }
.form-row .required { color: var(--c-danger); }
.input, .select, .textarea {
    width: 100%; padding: 8px 10px;
    border: 1px solid var(--c-border);
    border-radius: 6px; font-size: 14px;
    background: #fff; color: var(--c-text);
    transition: border-color .15s;
}
.input:focus, .select:focus, .textarea:focus {
    outline: none; border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(44,123,229,0.1);
}
.textarea { resize: vertical; min-height: 80px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { margin-top: 18px; display: flex; gap: 8px; }

/* ====== 提示 ====== */
.alert {
    padding: 10px 14px; border-radius: 6px;
    margin-bottom: 16px; font-size: 13px;
}
.alert-info { background: #d9ecff; color: #1a68d4; border: 1px solid #b3d7ff; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-danger { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-warn { background: #fff3cd; color: #856404; border: 1px solid #ffeaa7; }

/* ====== 统计卡 ====== */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card {
    background: var(--c-card);
    border-radius: var(--radius);
    padding: 16px; box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; color: var(--c-muted); margin-bottom: 6px; }
.stat-value { font-size: 22px; font-weight: 600; color: var(--c-text); }
.stat-value.danger { color: var(--c-danger); }

/* ====== 标签 ====== */
.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; }
.tag-active { background: #d4edda; color: #155724; }
.tag-void   { background: #f8d7da; color: #721c24; }
.tag-admin  { background: #fff3cd; color: #856404; }
.tag-user   { background: #d1ecf1; color: #0c5460; }
.tag-on     { background: #d4edda; color: #155724; }
.tag-off    { background: #f8d7da; color: #721c24; }

/* ====== 工具栏 ====== */
.toolbar {
    display: flex; gap: 10px; align-items: center;
    margin-bottom: 16px; flex-wrap: wrap;
}
.toolbar .input, .toolbar .select { width: auto; min-width: 140px; }

/* ====== 分页 ====== */
.pagination { display: flex; gap: 4px; justify-content: center; margin-top: 16px; }
.pagination a, .pagination span {
    padding: 5px 10px; border: 1px solid var(--c-border);
    border-radius: 4px; font-size: 13px; background: #fff;
}
.pagination a:hover { background: #f0f4f8; text-decoration: none; }
.pagination .current { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }

/* ====== 我的单据筛选栏 ====== */
.filter-bar {
    display: flex; gap: 10px; align-items: center;
    margin-bottom: 16px; flex-wrap: wrap;
}
.filter-bar .select, .filter-bar .input { width: auto; min-width: 120px; }
.filter-bar .select-sm, .filter-bar .input-sm { width: auto; padding: 6px 8px; font-size: 13px; }
.filter-bar .input-sm[type="date"]   { min-width: 150px; }
.filter-bar .input-sm[type="number"] { min-width: 110px; }
.filter-bar .input-sm[type="text"]   { min-width: 130px; }
.filter-bar .range { display: inline-flex; align-items: center; gap: 6px; }
.filter-bar .range-sep { color: var(--c-muted); }
.filter-bar .range input { width: auto; }

/* ====== 收据预览/打印 ====== */
.receipt-preview-wrap { background: #ececec; padding: 24px 0; }
.receipt {
    width: 210mm; min-height: 130mm;
    background: #fff; margin: 0 auto;
    padding: 18mm 16mm;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    font-family: "SimSun", "宋体", serif;
    color: #000;
    position: relative;
}
.receipt .r-title {
    text-align: center; font-size: 28px; font-weight: 700;
    letter-spacing: 6px; margin-bottom: 6px;
    font-family: "SimHei", "黑体", sans-serif;
}
.receipt .r-subtitle {
    text-align: center; font-size: 16px; color: #333;
    font-weight: 500; margin-bottom: 16px;
}
.receipt .r-no {
    text-align: right; font-size: 13px; margin-bottom: 8px;
}
.receipt .r-line {
    height: 1px; background: #000; margin: 4px 0 12px;
}
.receipt table.r-table {
    width: 100%; border-collapse: collapse;
    font-size: 14px;
}
.receipt table.r-table th, .receipt table.r-table td {
    border: 1px solid #000;
    padding: 6px 8px;
    vertical-align: middle;
}
.receipt table.r-table th {
    background: #f5f5f5; font-weight: 700; text-align: center;
    font-family: "SimHei", "黑体", sans-serif;
}
/* ====== 收据：额外信息与金额框（屏幕/预览统一，打印由 print.css 覆盖） ====== */
.receipt .r-extra-info {
    margin: 6px 0;
    padding: 12px 16px;
    font-size: 15px; font-weight: 600;
    color: #1a2a3c;
    background: linear-gradient(to right, #eef4ff, #f8faff);
    border-left: 5px solid #2c7be5;
    border-radius: 4px;
    line-height: 1.8;
    box-shadow: 0 1px 4px rgba(44,123,229,0.1);
}
.receipt .r-amount-box {
    margin: 10px 0;
    border: 2px solid #000;
    border-radius: 2px;
    overflow: hidden;
}
.receipt .r-amount-box .r-amount-cn-line,
.receipt .r-amount-box .r-amount-num-line {
    display: flex; align-items: center;
    border-bottom: 1px solid #000;
}
.receipt .r-amount-box .r-amount-num-line { border-bottom: none; }
.receipt .r-amount-box .r-amt-label {
    flex: 0 0 170px; padding: 8px 12px;
    font-weight: 700; font-size: 14px;
    background: #f0f0f0; border-right: 1px solid #000;
    font-family: "SimHei", "黑体", sans-serif;
}
.receipt .r-amount-box .r-amount-cn {
    flex: 1; padding: 8px 14px;
    font-size: 18px; font-weight: 900; letter-spacing: 1px;
    font-family: "SimSun", "宋体", serif;
}
.receipt .r-amount-box .r-amount-num {
    flex: 1; padding: 8px 14px;
    font-size: 24px; font-weight: 900; color: #c0392b;
    font-variant-numeric: tabular-nums;
}
.receipt .r-foot {
    margin-top: 10px;
    display: flex; justify-content: space-between;
    font-size: 14px;
}
.receipt .r-foot div { line-height: 1.6; }
.receipt .r-seal {
    position: absolute; right: 24mm; bottom: 24mm;
    width: 150px; height: 150px;
    border: 3px solid #c0392b; border-radius: 50%;
    color: #c0392b; font-size: 22px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: space-evenly;
    text-align: center; opacity: 0.85;
    transform: rotate(-12deg);
    font-family: "SimHei", "黑体", sans-serif;
    line-height: 1.3;
    padding: 8px 0;
}
.receipt .r-note {
    margin-top: 6px; font-size: 15px; color: #222;
    border-top: 1px solid #999; padding-top: 6px;
}
/* 1/2、1/3 纸不显示印章（仅 A4 显示），预览与打印一致 */
body.paper-half .receipt .r-seal,
body.paper-third .receipt .r-seal {
    display: none;
}
.btn-print-bar {
    text-align: center; margin: 20px 0;
}

/* ====== 登录页 ====== */
.login-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #1a68d4 0%, #4a90e2 50%, #6fb1e8 100%);
}
.login-card {
    width: 360px; background: #fff;
    border-radius: 10px; padding: 32px 28px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.login-title { text-align: center; font-size: 20px; font-weight: 600; margin-bottom: 6px; }
.login-sub { text-align: center; color: var(--c-muted); font-size: 13px; margin-bottom: 24px; }
.login-card .btn-primary { width: 100%; padding: 10px; font-size: 15px; }
.login-tip { text-align: center; margin-top: 16px; font-size: 12px; color: var(--c-muted); }

@media (max-width: 768px) {
    .container { margin: 12px auto; padding: 0 12px; }
    .stats { grid-template-columns: 1fr 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .card { padding: 12px; }

    /* 顶栏：折叠为汉堡菜单 */
    .nav-toggle { display: block; }
    .topbar-inner { flex-wrap: wrap; height: auto; padding: 8px 14px; gap: 8px; }
    .brand { flex: 1; }
    .user-box { order: 2; }
    .menu {
        order: 3; width: 100%;
        display: none; flex-wrap: wrap; gap: 4px;
    }
    .menu.open { display: flex; }
    .menu a { flex: 1 1 auto; text-align: center; }

    /* 工具栏/筛选：纵向铺满 */
    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar .input,
    .toolbar .select,
    .toolbar input,
    .toolbar select,
    .toolbar button { width: 100% !important; }
    .toolbar .muted { display: none; }

    /* 我的单据筛选栏：窄屏纵向铺满 */
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-bar .select, .filter-bar .input,
    .filter-bar input, .filter-bar select, .filter-bar button { width: 100% !important; }
    .filter-bar .range { width: 100%; }
    .filter-bar .range input { flex: 1; min-width: 0; }

    /* 列表表格：横向滚动避免挤压（明细录入表除外，改为竖向卡片） */
    .table:not(.items-table) { min-width: 680px; }
    .table:not(.items-table) th, .table:not(.items-table) td { white-space: nowrap; }

    /* 开具明细：窄屏竖向堆叠卡片，输入框全宽、触控友好 */
    .table.items-table,
    .table.items-table thead,
    .table.items-table tbody,
    .table.items-table tr,
    .table.items-table td,
    .table.items-table tfoot { display: block; }
    .table.items-table { border: none; }
    .table.items-table thead { display: none; }
    .table.items-table .item-row {
        border: 1px solid var(--c-border);
        border-radius: 10px;
        padding: 12px 12px 10px;
        margin-bottom: 12px;
        background: #fff;
        position: relative;
        box-shadow: var(--shadow);
    }
    .table.items-table .item-row td {
        display: flex; align-items: center; gap: 8px;
        padding: 5px 0; border: none !important; white-space: normal !important;
    }
    .table.items-table .item-row td::before {
        content: attr(data-label);
        flex: 0 0 56px; font-weight: 600; color: #5a6877; font-size: 13px;
    }
    .table.items-table .item-row td .input { flex: 1; width: 100%; font-size: 16px; padding: 9px 10px; }
    .table.items-table .item-row td.amount { justify-content: space-between; font-size: 16px; }
    .table.items-table .item-row td.cell-del { display: block; position: absolute; top: 8px; right: 8px; padding: 0; }
    .table.items-table .item-row td.cell-del::before { content: none; }
    .table.items-table .item-row td.cell-del .btn { padding: 6px 10px; font-size: 14px; }
    .table.items-table tfoot tr td { border: none !important; display: flex; justify-content: space-between; align-items: center; padding: 4px 0; }
    .table.items-table tfoot .amount { font-size: 18px; }

    /* 打印条按钮换行 */
    .btn-print-bar {
        display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
    }
    .btn-print-bar .btn,
    .btn-print-bar .select { flex: 1 1 auto; }

    /* 收据预览在手机上可横向滚动，文本缩小 */
    .print-area { overflow-x: auto; }
    .receipt { width: 100%; min-width: 360px; }
    .receipt .r-title { font-size: 22px; letter-spacing: 3px; }
    .receipt .r-subtitle { font-size: 13px; }
    .receipt .r-no { font-size: 11px; }
    .receipt table.r-table { font-size: 12px; }
    .receipt .r-amount-box .r-amt-label { flex: 0 0 110px; }
}

@media (max-width: 480px) {
    .login-card { width: 92%; padding: 24px 18px; }
    .receipt .r-amount-box .r-amt-label { flex: 0 0 92px; font-size: 12px; }
}

/* ====== 收据明细：手机端竖向卡片（仅屏幕，打印不受影响） ====== */
@media (max-width: 600px) {
    .receipt table.r-items,
    .receipt table.r-items thead,
    .receipt table.r-items tbody,
    .receipt table.r-items tr,
    .receipt table.r-items td { display: block; width: 100% !important; }
    .receipt table.r-items { margin: 6px 0; }
    .receipt table.r-items thead { display: none; }
    .receipt table.r-items tr {
        border: 1px solid #000; border-radius: 6px;
        padding: 6px 8px; margin-bottom: 8px; background: #fff;
    }
    .receipt table.r-items td {
        border: none !important; padding: 3px 0 !important;
        display: flex; justify-content: space-between; align-items: baseline;
        gap: 10px; text-align: right !important; font-size: 13px;
        white-space: normal !important; word-break: break-word;
    }
    .receipt table.r-items td::before {
        content: attr(data-label);
        flex: 0 0 auto; font-weight: 700; color: #333; text-align: left;
        font-family: "SimHei", "黑体", sans-serif;
    }
    .receipt table.r-items td.text-center,
    .receipt table.r-items td.text-right { text-align: right !important; }
    .receipt table.r-items td.amount { color: #d9534f; font-weight: 700; }
}

/* ====== 导出 PDF 时强制桌面版式（仅 JS 给 <html> 加 .force-desktop 时生效） ======
   html2pdf 用 html2canvas 截图当前屏幕 DOM，手机窄屏下会沿用 @media 卡片堆叠。
   加此类后强制按电脑 Web 端完整收据表格渲染，保证导出 PDF 与桌面一致。
   收据宽度由 JS 按所选纸张（A4/1/2/1/3）内联设置，这里只清掉 min-width 限制。 */
html.force-desktop .receipt { min-width: 0 !important; }
/* 恢复桌面级字号与间距，使导出 PDF 与电脑 Web 端完全一致（覆盖手机 @media 缩放） */
html.force-desktop .receipt .r-title { font-size: 28px !important; letter-spacing: 6px !important; margin-bottom: 6px !important; }
html.force-desktop .receipt .r-subtitle { font-size: 16px !important; font-weight: 500 !important; margin-bottom: 16px !important; }
html.force-desktop .receipt .r-no { font-size: 13px !important; margin-bottom: 8px !important; }
html.force-desktop .receipt .r-line { margin: 4px 0 12px !important; }
html.force-desktop .receipt table.r-table th,
html.force-desktop .receipt table.r-table td { font-size: 14px !important; padding: 6px 8px !important; }
html.force-desktop .receipt .r-amount-box .r-amt-label { flex: 0 0 170px !important; font-size: 14px !important; padding: 8px 12px !important; }
html.force-desktop .receipt .r-amount-cn { font-size: 18px !important; font-weight: 900 !important; }
html.force-desktop .receipt .r-amount-num { font-size: 24px !important; font-weight: 900 !important; }
html.force-desktop .receipt .r-extra-info { font-size: 15px !important; padding: 12px 16px !important; }
html.force-desktop .receipt .r-foot { margin-top: 10px !important; font-size: 14px !important; }
html.force-desktop .receipt .r-note { margin-top: 6px !important; font-size: 15px !important; padding-top: 6px !important; }
html.force-desktop .receipt table.r-items { display: table !important; width: 100% !important; border-collapse: collapse !important; }
html.force-desktop .receipt table.r-items thead { display: table-header-group !important; }
html.force-desktop .receipt table.r-items tbody { display: table-row-group !important; }
html.force-desktop .receipt table.r-items tr { display: table-row !important; border: none !important; padding: 0 !important; margin: 0 !important; background: transparent !important; box-shadow: none !important; border-radius: 0 !important; }
html.force-desktop .receipt table.r-items td {
    display: table-cell !important;
    width: auto !important;
    text-align: left !important;
    border: 1px solid #000 !important;
    padding: 6px 8px !important;
    font-size: 14px !important;
    white-space: normal !important;
    justify-content: normal !important;
    color: #000 !important;
    vertical-align: middle !important;
}
html.force-desktop .receipt table.r-items td::before { display: none !important; content: none !important; }
html.force-desktop .receipt table.r-items th { display: table-cell !important; width: auto !important; }
html.force-desktop .receipt table.r-items td.text-right { text-align: right !important; }
html.force-desktop .receipt table.r-items td.text-center { text-align: center !important; }
html.force-desktop .receipt table.r-items td.amount { color: #d9534f !important; font-weight: 600 !important; }

/* 开具明细录入表（编辑页）同样恢复桌面表格，保持一致 */
html.force-desktop .table.items-table { display: table !important; }
html.force-desktop .table.items-table thead { display: table-header-group !important; }
html.force-desktop .table.items-table tbody { display: table-row-group !important; }
html.force-desktop .table.items-table tr { display: table-row !important; }
html.force-desktop .table.items-table td { display: table-cell !important; }
html.force-desktop .table.items-table .item-row { border: none !important; box-shadow: none !important; padding: 0 !important; margin: 0 !important; }
html.force-desktop .table.items-table td::before { display: none !important; content: none !important; }

/* ====== 徽章 / 结算状态 ====== */
.badge { display: inline-block; padding: 2px 9px; border-radius: 4px; font-size: 12px; font-weight: 500; line-height: 1.6; }
.badge-ok   { background: #d4edda; color: #155724; }
.badge-void { background: #f8d7da; color: #721c24; }
.badge-in   { background: #eafaf0; color: #2e9e5b; }
.badge-out  { background: #fdeeee; color: #d9534f; }
.badge-warn { background: #fff3cd; color: #856404; }
.badge-svc  { background: #e7e3ff; color: #5b3fd6; font-weight: 600; }
.chk-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--c-text); cursor: pointer; white-space: nowrap; }
.chk-inline input { width: auto; }
.settle-row { display: flex; gap: 28px; flex-wrap: wrap; margin-top: 12px; }
.settle-row > div { display: flex; flex-direction: column; gap: 2px; }
.settle-row .muted { font-size: 12px; }
.settle-row strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.ok   { color: var(--c-success); }
.warn { color: var(--c-danger); }

/* ====== 统计卡（首页 / 统计 / 账款） ====== */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-box {
    display: block; background: var(--c-card); border-radius: var(--radius);
    padding: 16px; box-shadow: var(--shadow); color: var(--c-text);
    transition: all .15s; border: 1px solid var(--c-border);
}
.stat-box:hover { text-decoration: none; box-shadow: 0 4px 14px rgba(0,0,0,.1); transform: translateY(-1px); }
.stat-box.in  { border-top: 3px solid #2e9e5b; }
.stat-box.out { border-top: 3px solid #d9534f; }
.stat-box .stat-num { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-box .stat-label { font-size: 13px; color: var(--c-muted); margin-top: 4px; }
.stat-box .stat-sub { font-size: 12px; color: var(--c-muted); margin-top: 2px; }
@media (max-width: 768px) { .stat-row { grid-template-columns: 1fr 1fr; } }

/* ====== 基础资料 CRUD 列表（单位/分类） ====== */
.crud-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--c-border); border-radius: 8px; margin-bottom: 8px; background: #fff; }
.crud-row .crud-main { flex: 1; }
.crud-row .crud-main b { font-size: 14px; }
.crud-row .crud-main span { color: var(--c-muted); font-size: 12px; margin-left: 8px; }
.crud-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.crud-form .form-row { margin-bottom: 0; min-width: 180px; }

/* 分类行：可点击选中 */
.crud-row .crud-pick { flex: 1; cursor: pointer; text-decoration: none; color: var(--c-text); }
.crud-row .crud-pick:hover b { color: var(--c-primary); }
.crud-row.sel { border-color: var(--c-primary); box-shadow: 0 0 0 2px rgba(44,123,229,.15); background: #f5f9ff; }

/* ====== 弹窗（新增/编辑货品） ====== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.modal { background: #fff; border-radius: 10px; width: 420px; max-width: 100%; max-height: 90vh; overflow: auto; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal-title { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--c-border); font-weight: 600; font-size: 15px; }
.modal-close { border: none; background: transparent; font-size: 22px; line-height: 1; cursor: pointer; color: var(--c-muted); }
.modal-close:hover { color: var(--c-danger); }
.modal-body { padding: 18px; }
.modal-body .form-row { margin-bottom: 14px; }
.modal-body .form-actions { display: flex; gap: 10px; margin-top: 8px; }

/* ====== 归入分类：多选货品面板 ====== */
.pick-panel { margin-top: 18px; border: 1px solid var(--c-border); border-radius: 10px; padding: 16px; background: #fafbfd; }
.pick-panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.pick-panel-head b { font-size: 14px; }
.pick-list { max-height: 320px; overflow: auto; border: 1px solid var(--c-border); border-radius: 8px; background: #fff; }
.pick-item { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-bottom: 1px solid #f0f2f5; cursor: pointer; }
.pick-item:last-child { border-bottom: none; }
.pick-item:hover { background: #f5f9ff; }
.pick-item.checked { background: #eef5ff; }
.pick-item input[type=checkbox] { width: 16px; height: 16px; flex: none; }
.pick-name { font-size: 14px; flex: 1; }
.pick-meta { color: var(--c-muted); font-size: 12px; }
.pick-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; }

/* 选中分类后的「添加产品」工具条 */
.pick-toolbar { display: flex; align-items: center; gap: 10px; margin-top: 16px; padding: 10px 12px; border: 1px dashed var(--c-primary); border-radius: 8px; background: #f5f9ff; }
.pick-toolbar b { font-size: 14px; }
.pick-toolbar .btn { margin-left: auto; }

/* 产品列表过滤（未分类 / 全部） */
.pick-filter { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.pick-filter .pfilter { border: 1px solid var(--c-border); background: #fff; color: var(--c-text); padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.pick-filter .pfilter.active { border-color: var(--c-primary); background: var(--c-primary); color: #fff; }
.pick-filter #pickSearch { margin-left: auto; width: 200px; }
.pick-item.is-uncat .pick-name::after { content: '未分类'; color: #c0392b; font-size: 11px; border: 1px solid #f0c0b8; border-radius: 4px; padding: 1px 5px; margin-left: 8px; }
.pick-empty { font-size: 13px; }

