/* 参考设计稿的细体中文字体：从本机 Noto Sans SC 抽出的项目用字子集，离线可用 */
@font-face {
    font-family: "WB Sans SC";
    src: url("../fonts/noto-sans-sc.woff2") format("woff2");
    font-style: normal;
    font-weight: 400;
    font-display: swap;
}

:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --border: #e8edf5;
    --text: #1c2430;
    --muted: #6b7688;
    --primary: #3b6cf6;
    --primary-soft: #eaf1ff;
    --success: #16a34a;
    --success-soft: #e8f7ee;
    --warning: #e08a19;
    --warning-soft: #fff4e5;
    --danger: #e04444;
    --danger-soft: #fdeeee;
    --sidebar-w: 180px;
    --radius: 14px;
    --shadow: 0 2px 14px rgba(30, 55, 100, .07), 0 1px 3px rgba(30, 55, 100, .04);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    /* 优先用系统原生字体（带完整 hinting，小字最清晰）；子集字体只作无系统字体时的兜底 */
    font-family: "Noto Sans SC", "HarmonyOS Sans SC", "MiSans", "PingFang SC",
                 "Microsoft YaHei UI", "Microsoft YaHei", "Segoe UI", system-ui,
                 "WB Sans SC", sans-serif;
    font-size: 14px;
    line-height: 1.55;
    letter-spacing: 0;
    -webkit-font-smoothing: auto;
}

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

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

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 18px 16px;
    border-bottom: 1px solid var(--border);
}

.brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    flex-shrink: 0;
    display: block;
    object-fit: contain;
    box-shadow: 0 2px 8px rgba(20, 102, 232, .35);
}

.brand-title { font-size: 14.5px; font-weight: 600; line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--muted); }

.nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }

.nav-label {
    font-size: 11px;
    color: #9aa3b2;
    padding: 12px 10px 6px;
    letter-spacing: .06em;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    color: #3d4757;
    font-size: 13.5px;
    text-decoration: none;
    transition: background .15s, color .15s;
}

.nav-item:hover { background: #f2f5fa; text-decoration: none; color: var(--text); }

.nav-item.active {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
}

.nav-item .ico { width: 16px; text-align: center; opacity: .85; font-size: 13px; }

.nav-badge {
    margin-left: auto;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #dc2626;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.nav-item.active .nav-badge { background: #dc2626; }

.sidebar-foot {
    margin-top: auto;
    padding: 12px 14px 16px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--muted);
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    height: 58px;
    background: rgba(255, 255, 255, .86);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 26px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.page-title { font-size: 15px; font-weight: 600; margin: 0; }
.page-sub { font-size: 12px; color: var(--muted); }

.topbar-right { display: flex; align-items: center; gap: 14px; font-size: 13px; }

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px 5px 5px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
}

.avatar {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: #e8eefb;
    color: var(--primary);
    font-size: 11px;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}

.content { padding: 22px 26px 44px; max-width: 1400px; width: 100%; }

/* ---------- 卡片 ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

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

.card-title { font-size: 14px; font-weight: 600; margin: 0; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

.section-gap { margin-bottom: 18px; }

/* ---------- 统计卡 ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.stat-label { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.stat-value { font-size: 25px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.stat-foot { font-size: 12px; color: var(--muted); margin-top: 6px; }
.stat-value.warn { color: var(--warning); }
.stat-value.danger { color: var(--danger); }

.stat::after {
    content: "";
    position: absolute;
    right: -18px; top: -18px;
    width: 68px; height: 68px;
    border-radius: 50%;
    background: var(--primary-soft);
    opacity: .55;
}

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

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

table.data thead th {
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 11px 14px;
    background: #fafbfd;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

/* 可排序表头：明显的胶囊按钮 */
th.sortable { padding: 8px 10px; }

th.sortable a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 7px;
    border: 1px solid #dde3ec;
    background: #fff;
    color: #46505f;
    font-weight: 600;
    font-size: 12px;
    line-height: 1.5;
    text-decoration: none;
    transition: all .15s;
}

th.sortable a:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #f5f9ff;
    text-decoration: none;
}

th.sortable a.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 2px 6px rgba(37, 99, 235, .28);
}

th.sortable .arrow {
    font-size: 10px;
    line-height: 1;
    color: #9aa3b2;
}

th.sortable a.active .arrow { color: #fff; }
th.sortable a:hover .arrow { color: var(--primary); }

table.data tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid #f0f2f6;
    vertical-align: middle;
}

table.data tbody tr:hover { background: #fafcff; }
table.data tbody tr:last-child td { border-bottom: none; }

/* 表格内的操作按钮保持一行，不换行堆叠 */
table.data td .btn-row { flex-wrap: nowrap; gap: 6px; }
table.data td .btn-row .btn-sm { padding: 5px 9px; }

/* 数字与状态列统一居中，表头与数据保持同一对齐 */
.num,
.center,
table.data th.num,
table.data td.num,
table.data th.center,
table.data td.center {
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }

.empty {
    padding: 42px 20px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

/* 卡片内空状态占满剩余高度并居中 */
.empty.fill {
    height: 100%;
    min-height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---------- 徽章 ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.7;
    white-space: nowrap;
}

.badge-in { background: var(--success-soft); color: var(--success); }
.badge-out { background: var(--primary-soft); color: var(--primary); }
.badge-adj { background: var(--warning-soft); color: var(--warning); }
.badge-low { background: var(--danger-soft); color: var(--danger); }
.badge-off { background: #eef0f4; color: var(--muted); }
.badge-plain { background: #f2f4f8; color: #46505f; }
.badge-pending { background: var(--warning-soft); color: var(--warning); }
.badge-done { background: var(--success-soft); color: var(--success); }

.delta-up { color: var(--success); font-weight: 600; }
.delta-down { color: var(--danger); font-weight: 600; }

/* ---------- 表单 ---------- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 16px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }

label.lbl { font-size: 12.5px; font-weight: 600; color: #3d4757; }
label.lbl .req { color: var(--danger); }

input[type=text], input[type=password], input[type=number], input[type=date],
select, textarea {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid #d5dbe5;
    border-radius: 8px;
    background: #fff;
    font-size: 13.5px;
    color: var(--text);
    font-family: inherit;
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

input[readonly] { background: #f7f8fa; color: var(--muted); }
textarea { resize: vertical; min-height: 74px; }

.hint { font-size: 11.5px; color: var(--muted); }

/* 一行内的表单：日期窄、备注占满剩余 */
.form-inline {
    display: flex;
    gap: 14px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-inline .field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-inline .date-field { flex: 0 0 168px; width: 168px; }
.form-inline .grow { flex: 1; min-width: 220px; max-width: 520px; }

.card-body.compact { padding: 16px 18px; }

/* 提交结果条 */
.result-bar {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    border-radius: 10px;
    background: var(--success-soft);
    border: 1px solid #bfe8cf;
    color: #157347;
    font-size: 13.5px;
    margin-bottom: 16px;
}

.result-bar.show { display: flex; }

.result-bar.error {
    background: var(--danger-soft);
    border-color: #f5c7c7;
    color: #b91c1c;
}

.result-bar .rlink {
    margin-left: auto;
    font-weight: 600;
    color: inherit;
    text-decoration: underline;
    white-space: nowrap;
}

/* 角色说明卡片 */
.role-list {
    display: grid;
    gap: 10px;
}

.role-item {
    display: flex;
    gap: 14px;
    align-items: baseline;
    padding: 10px 14px;
    background: #fafbfd;
    border: 1px solid var(--border);
    border-radius: 9px;
}

.role-name {
    flex: 0 0 84px;
    font-weight: 600;
    font-size: 13px;
}

.role-desc {
    font-size: 12.5px;
    color: var(--muted);
    line-height: 1.6;
}

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    background: #fff;
    color: var(--text);
    text-decoration: none;
    transition: background .15s, border-color .15s, transform .05s;
    white-space: nowrap;
    font-family: inherit;
    line-height: 1.4;
}

.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }

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

.btn-outline { border-color: #d5dbe5; color: #3d4757; background: #fff; }
.btn-outline:hover { background: #f4f7fc; color: var(--text); }

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

.btn-ghost { color: var(--muted); background: transparent; }
.btn-ghost:hover { background: #f2f5fa; color: var(--text); }

.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; }

.btn-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- 工具栏 ---------- */
.toolbar {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: #fcfdfe;
}

.toolbar .field { min-width: 150px; }
.toolbar .field.wide { min-width: 220px; flex: 1; }
.toolbar .spacer { flex: 1; }

/* ---------- 提示 ---------- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 11px 14px;
    border-radius: 9px;
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.alert-success { background: var(--success-soft); border-color: #bfe8cf; color: #157347; }
.alert-error { background: var(--danger-soft); border-color: #f5c7c7; color: #b91c1c; }
.alert-info { background: var(--primary-soft); border-color: #cfdcff; color: #1d4ed8; }

/* ---------- 分页 ---------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--muted);
    flex-wrap: wrap;
}

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

.page-btn {
    min-width: 30px;
    height: 30px;
    padding: 0 9px;
    border: 1px solid #d5dbe5;
    border-radius: 7px;
    background: #fff;
    color: #3d4757;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12.5px;
    text-decoration: none;
}

.page-btn:hover { background: #f2f5fa; text-decoration: none; }
.page-btn.current { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.page-btn.disabled { opacity: .45; pointer-events: none; }

/* ---------- 登录页 ---------- */
.login-wrap {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    background: #fff;
}

.login-hero {
    background: linear-gradient(150deg, #1e3a8a 0%, #2563eb 55%, #4f7ffb 100%);
    color: #fff;
    padding: 56px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.hero-brand {
    display: flex;
    align-items: center;
    gap: 13px;
    margin-bottom: 26px;
    position: relative;
    z-index: 1;
}

.hero-brand img {
    width: 56px;
    height: 56px;
    border-radius: 15px;
    box-shadow: 0 10px 26px rgba(0, 0, 0, .3);
}

.hero-brand span {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: .3px;
}

.login-hero::before {
    content: "";
    position: absolute;
    width: 460px; height: 460px;
    border-radius: 50%;    background: rgba(255, 255, 255, .07);
    right: -140px; top: -120px;
}

.login-hero::after {
    content: "";
    position: absolute;
    width: 300px; height: 300px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .06);
    left: -90px; bottom: -110px;
}

.login-hero h1 { font-size: 32px; line-height: 1.3; margin: 0 0 16px; font-weight: 700; letter-spacing: -.02em; }
.login-hero p { font-size: 14.5px; color: rgba(255, 255, 255, .82); max-width: 380px; margin: 0 0 32px; }

.hero-points { display: flex; flex-direction: column; gap: 12px; z-index: 1; }
.hero-point { display: flex; gap: 10px; align-items: center; font-size: 13.5px; color: rgba(255,255,255,.92); }
.hero-dot {
    width: 20px; height: 20px; border-radius: 50%;
    background: rgba(255,255,255,.18);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px;
}

.login-form-side { display: flex; align-items: center; justify-content: center; padding: 40px; }
.login-box { width: 100%; max-width: 360px; }
.login-box h2 { font-size: 22px; margin: 0 0 6px; font-weight: 700; }
.login-box .sub { color: var(--muted); font-size: 13px; margin-bottom: 26px; }
.login-box .field { margin-bottom: 15px; }
.login-box .btn { margin-top: 8px; padding: 10px; }

.demo-tip {
    margin-top: 22px;
    padding: 12px 14px;
    background: #f7f9fc;
    border: 1px dashed #d7dee9;
    border-radius: 9px;
    font-size: 12.5px;
    color: var(--muted);
    line-height: 1.7;
}

/* ---------- 图表 ---------- */
.chart {
    display: flex;
    align-items: flex-end;
    gap: 18px;
    height: 190px;
    padding: 8px 4px 0;
}

.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; }

.chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 5px;
    height: 100%;
    width: 100%;
    justify-content: center;
}

.bar {
    width: 20px;
    border-radius: 4px 4px 0 0;
    min-height: 2px;
    transition: height .3s;
}

.bar-in { background: #34a853; }
.bar-out { background: #4f7ffb; }
.chart-label { font-size: 11.5px; color: var(--muted); white-space: nowrap; }

.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); align-items: center; }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 5px; }

/* ---------- 明细行编辑 ---------- */
.items-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.items-table th {
    text-align: left; font-size: 11.5px; color: var(--muted);
    padding: 8px 10px; border-bottom: 1px solid var(--border);
    background: #fafbfd; font-weight: 600;
}
.items-table td { padding: 7px 10px; border-bottom: 1px solid #f1f3f7; vertical-align: middle; }
.items-table th.center,
.items-table td.center { text-align: center; }
.items-table input, .items-table select { padding: 6px 9px; font-size: 13px; }
.items-table .col-qty { width: 100px; text-align: center; }
.items-table .col-price { width: 140px; }
.items-table .col-remark { width: 150px; }
.items-table .col-amount { width: 120px; text-align: center; }
.items-table .col-op { width: 50px; text-align: center; }
.items-table .col-qty input,
.items-table .col-remark input { width: 100%; }

.row-remove {
    border: none; background: transparent; color: #c02626; cursor: pointer;
    font-size: 15px; line-height: 1; padding: 4px 6px; border-radius: 6px;
}
.row-remove:hover { background: var(--danger-soft); }

/* ---------- 商品模糊搜索选择器 ---------- */
/* 明细表容器保持 overflow: visible，否则下拉会被 table-wrap 的滚动容器裁掉 */
.table-wrap.items-wrap { overflow: visible; }

.combo { position: relative; min-width: 260px; }

.combo-input {
    width: 100%;
    padding: 6px 9px;
    font-size: 13px;
    border: 1px solid #d5dbe5;
    border-radius: 7px;
    background: #fff;
    font-family: inherit;
    outline: none;
}

.combo-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}

.combo-input.picked { background: #f6f9ff; border-color: #bcd0f7; font-weight: 500; }

.combo-drop {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 9px;
    box-shadow: 0 10px 28px rgba(16, 24, 40, .14);
    max-height: 264px;
    overflow-y: auto;
    z-index: 60;
    display: none;
}

.combo-drop.open { display: block; }

.combo-item {
    padding: 8px 11px;
    cursor: pointer;
    border-bottom: 1px solid #f4f6fa;
}

.combo-item:last-child { border-bottom: none; }
.combo-item:hover, .combo-item.hover { background: #f2f7ff; }

.combo-item .ci-name { font-size: 13px; font-weight: 500; color: var(--text); }
.combo-item .ci-meta { font-size: 11.5px; color: var(--muted); margin-top: 1px; }

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

.stock-cell {
    font-variant-numeric: tabular-nums;
    font-size: 13px;
    white-space: nowrap;
    text-align: center;
}

.stock-cell.none { color: var(--muted); }
.stock-cell.enough { color: var(--success); font-weight: 600; }
.stock-cell.short { color: var(--danger); font-weight: 600; }

/* ---------- 明细表底部常驻的快速录入条 ---------- */
.quick-add {
    padding: 12px 14px 16px;
    background: #fbfcfe;
    border-top: 1px solid var(--border);
}

/* 没有任何明细时，录入条直接贴着表头，不再画分隔线 */
.quick-add.flush {
    border-top: none;
    padding-top: 14px;
}

.quick-add .combo { max-width: 520px; min-width: 0; }

.quick-add .combo-input {
    padding: 9px 12px;
    font-size: 13.5px;
    border-style: dashed;
    background: #fff;
}

.quick-add .combo-input:focus {
    border-style: solid;
}

.quick-hint {
    margin-top: 6px;
    font-size: 11.5px;
    color: var(--muted);
}

/* 明细行内的商品展示（纯文本，不可编辑） */
.p-name { font-size: 13.5px; font-weight: 500; color: var(--text); }
.p-meta { font-size: 11.5px; color: var(--muted); margin-top: 1px; }

.summary-bar {
    display: flex; justify-content: flex-end; gap: 28px;
    padding: 12px 10px 4px; font-size: 13px;
}
.summary-bar b { font-size: 15px; }

/* ---------- 详情 ---------- */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px 24px;
}
.detail-item .k { font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.detail-item .v { font-size: 13.5px; font-weight: 500; }

@media (max-width: 900px) {
    .login-wrap { grid-template-columns: 1fr; }
    .login-hero { display: none; }
    .sidebar { display: none; }
    .content { padding: 16px; }
    .topbar { padding: 0 16px; }
}

/* ---------- 多标签外壳 ---------- */
body.shell { overflow: hidden; }
body.shell .app-shell { height: 100vh; }
body.shell .main { height: 100vh; }

.tabbar {
    flex: 0 0 48px;
    height: 48px;
    background: #e9edf4;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: flex-end;
    padding: 0 10px;
}

.tab-items {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    flex: 1;
    min-width: 0;
    height: 100%;
    padding-top: 10px;
    overflow-x: auto;
    overflow-y: hidden;
}

.tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    max-width: 190px;
    padding: 0 8px 0 12px;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    font-size: 13px;
    color: var(--muted);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    background: transparent;
    position: relative;
}

.tab .tab-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

.tab:hover { background: #f4f6fa; color: var(--text); }

.tab.active {
    background: var(--bg);
    border-color: var(--border);
    color: var(--text);
    font-weight: 600;
    box-shadow: inset 0 2px 0 var(--primary);
}

.tab.active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 1px;
    background: var(--bg);
}

.tab .close {
    width: 16px;
    height: 16px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #9aa3b2;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tab .close:hover { background: #e3e8f0; color: var(--text); }

.tabbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    padding: 0 6px 7px 12px;
}

.tab-user {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--muted);
}

.tab-user .avatar { width: 22px; height: 22px; font-size: 10px; }

.tab-frames {
    flex: 1;
    position: relative;
    min-height: 0;
    background: var(--bg);
}

.tab-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    display: none;
    background: var(--bg);
}

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

/* 被标签页嵌入时，隐藏重复的侧边栏和顶栏 */
html.embedded .sidebar,
html.embedded .topbar { display: none; }

html.embedded .app-shell { display: block; }
html.embedded .main { display: block; min-height: 100vh; }
html.embedded .content { padding: 18px 22px 32px; }

/* ============================================================
   参考设计稿风格层：只改视觉与布局，不动任何业务字段与数据
   ============================================================ */

/* ---------- 全局细体排版 ---------- */
body { font-weight: 400; }
h1, h2, h3, .page-title, .card-title, .brand-title { font-weight: 500; }
.strong, .badge, label.lbl, th.sortable a, .page-btn.current { font-weight: 500; }
a { color: var(--primary); }
a:hover { text-decoration: none; }

/* ---------- 侧边栏 ---------- */
.sidebar {
    background: #fff;
    border-right: 1px solid #f0f3f8;
    width: var(--sidebar-w);
    flex-basis: var(--sidebar-w);
}

.brand {
    gap: 11px;
    padding: 22px 20px 18px;
    border-bottom: none;
}

.brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    box-shadow: none;
}

.brand-title { font-size: 17px; letter-spacing: .04em; color: #1b2a44; }
.brand-sub { display: none; }

.nav { padding: 6px 12px; gap: 3px; }

.nav-label {
    font-size: 10.5px;
    color: #aab4c4;
    padding: 16px 12px 7px;
    letter-spacing: .1em;
}

.nav-item {
    gap: 11px;
    padding: 9px 12px;
    border-radius: 10px;
    color: #5b6678;
    font-size: 13px;
    font-weight: 400;
}

.nav-item .ico { opacity: .72; width: 16px; }
.nav-item:hover { background: #f5f8fd; color: var(--text); }

.nav-item.active {
    background: #eef4ff;
    color: var(--primary);
    font-weight: 500;
}

.nav-badge {
    min-width: 17px;
    height: 17px;
    font-size: 10.5px;
    font-weight: 500;
    background: #f2724b;
}

.sidebar-foot {
    border-top: 1px solid #f2f5fa;
    padding: 14px 18px 18px;
    font-size: 11.5px;
    line-height: 1.8;
    color: #9aa4b4;
}

/* ---------- 顶栏（直接访问页面时） ---------- */
.topbar {
    height: 60px;
    background: #fff;
    border-bottom: 1px solid #f0f3f8;
    backdrop-filter: none;
    padding: 0 28px;
}

.page-title { font-size: 15px; color: #1e293b; }
.page-sub { font-size: 12px; color: #9aa4b4; }

.user-chip {
    border: none;
    background: transparent;
    padding: 4px 6px 4px 4px;
    font-size: 12.5px;
    color: #5b6678;
}

.avatar {
    width: 26px;
    height: 26px;
    background: linear-gradient(135deg, #dbe8ff, #eef3ff);
    font-weight: 500;
    font-size: 11px;
}

.content { padding: 24px 28px 48px; }
html.embedded .content { padding: 22px 26px 40px; }

/* ---------- 多标签外壳顶栏与标签 ---------- */
.shell-topbar {
    flex: 0 0 58px;
    height: 58px;
    background: #fff;
    border-bottom: 1px solid #f0f3f8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 26px;
}

.crumb { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #9aa4b4; }
.crumb .sep { color: #cdd5e2; }
.crumb b { color: #1e293b; font-weight: 500; }

.crumb-back {
    width: 28px;
    height: 28px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: #fff;
    color: #6b7688;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    padding: 0;
}

.crumb-back:hover { background: #f5f8fd; color: var(--primary); }

.top-actions { display: flex; align-items: center; gap: 18px; }

.notif {
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #7b879a;
    position: relative;
}

.notif::after {
    content: "";
    position: absolute;
    top: 2px;
    right: 3px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #f2635a;
    border: 1.5px solid #fff;
}

.user-menu { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: #4a5568; }
.user-menu .avatar { width: 28px; height: 28px; }
.chev { color: #aab4c4; font-size: 10px; }

.tabbar {
    flex: 0 0 44px;
    height: 44px;
    background: #fff;
    border-bottom: 1px solid #f0f3f8;
    align-items: center;
    padding: 0 18px;
}

.tab-items { padding-top: 0; align-items: center; }

.tab {
    height: 30px;
    border: none;
    border-radius: 9px;
    background: transparent;
    font-size: 12.5px;
    padding: 0 8px 0 12px;
}

.tab:hover { background: #f5f8fd; }

.tab.active {
    background: var(--primary-soft);
    border: none;
    color: var(--primary);
    font-weight: 500;
    box-shadow: none;
}

.tab.active::after { display: none; }
.tabbar-right { padding: 0 4px 0 12px; }
.tab-frames, .tab-frame { background: var(--bg); }

/* ---------- 卡片 ---------- */
.card {
    border: 1px solid #f1f4f9;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-head {
    padding: 17px 20px 13px;
    border-bottom: none;
}

.card-title { font-size: 14px; color: #26324a; }
.card-body { padding: 18px 20px 20px; }
.card-body.tight { padding: 0 8px 8px; }
.card-body.tight .table-wrap { border-radius: 10px; }
.card-body .table-wrap { border-radius: 10px; }
/* 明细表的商品下拉需要溢出可见，不能被圆角容器重新裁掉 */
.card-body .table-wrap.items-wrap { overflow: visible; }

/* ---------- 统计卡（工作台） ---------- */
.stat-grid { gap: 16px; margin-bottom: 16px; }

.kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.mini-grid { grid-template-columns: 1fr 1fr 2.1fr; }

.stat {
    border: 1px solid #f1f4f9;
    border-radius: var(--radius);
    padding: 17px 20px 18px;
    box-shadow: var(--shadow);
    overflow: visible;
}

.stat::after { display: none; }

.stat-head { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }

.stat-icon {
    width: 28px;
    height: 28px;
    border-radius: 9px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.stat-icon.blue { background: linear-gradient(135deg, #5b8bff, #3b6cf6); }
.stat-icon.cyan { background: linear-gradient(135deg, #58b8f5, #2f8ee8); }
.stat-icon.orange { background: linear-gradient(135deg, #ffb354, #f08a1c); }
.stat-icon.violet { background: linear-gradient(135deg, #8f9bff, #6172ee); }
.stat-icon.green { background: linear-gradient(135deg, #57d29a, #21a86d); }

.stat-icon svg { width: 15px; height: 15px; }

.stat-label { font-size: 12.5px; color: #7b879a; margin: 0; font-weight: 400; }

.stat-more {
    margin-left: auto;
    color: #b8c1d0;
    font-size: 17px;
    line-height: 1;
    letter-spacing: 0;
    user-select: none;
}

.stat-value {
    font-size: 27px;
    font-weight: 400;
    letter-spacing: -.02em;
    line-height: 1.25;
    color: #1e293b;
    font-variant-numeric: tabular-nums;
}

.stat-value.warn { color: #ec8b1c; }
.stat-value.danger { color: var(--danger); }

.stat-foot { font-size: 11.5px; color: #9ba6b7; margin-top: 7px; }

/* 快捷操作卡：标题与按钮保持原有内容，仅重排 */
.quick-card .stat-head { margin-bottom: 8px; }
.quick-card .btn-row { gap: 7px; margin-top: 8px; }
.quick-card .btn-sm { padding: 5px 10px; font-size: 12px; }
.quick-card .stat-foot { margin-top: 6px; }

/* ---------- 表格 ---------- */
table.data { font-size: 13px; }

table.data thead th {
    font-size: 11.5px;
    font-weight: 400;
    color: #9aa4b4;
    text-transform: none;
    letter-spacing: .03em;
    padding: 12px 16px;
    background: #fafbfd;
    border-bottom: 1px solid #f0f3f8;
}

table.data tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid #f3f5f9;
}

table.data tbody tr:hover { background: #fafcff; }

.mono { font-size: 12px; letter-spacing: .01em; }
.muted { color: #9aa4b4; }

.badge {
    border-radius: 6px;
    padding: 2px 9px;
    font-size: 11px;
    font-weight: 400;
    line-height: 1.75;
}

.badge-in { background: #e9f8ef; color: #199a55; }
.badge-out { background: #eaf1ff; color: var(--primary); }

.toolbar { padding: 16px 20px; background: #fff; border-bottom: 1px solid #f1f4f9; }
.card-body.compact { padding: 17px 20px; }

/* ---------- 按钮 / 表单 / 徽章 ---------- */
.btn {
    border-radius: 9px;
    font-size: 13px;
    font-weight: 400;
    padding: 8px 14px;
}

.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: #2f5ce0; }
.btn-outline { border-color: #e3e9f2; color: #5b6678; }
.btn-sm { border-radius: 8px; font-size: 12px; }
.btn-ghost { color: #8a95a8; }

input[type=text], input[type=password], input[type=number], input[type=date],
select, textarea {
    border-radius: 9px;
    border-color: #e3e9f2;
    font-size: 13px;
}

label.lbl { font-size: 12.5px; font-weight: 400; color: #6b7688; }

.alert { border-radius: 11px; font-size: 12.5px; border: none; }
.alert-info { background: #eef4ff; color: #3b62c4; }
.alert-success { background: var(--success-soft); color: #157347; }
.alert-error { background: var(--danger-soft); color: #b91c1c; }

.pagination { padding: 14px 20px; border-top: 1px solid #f1f4f9; font-size: 12.5px; }
.page-btn { border-radius: 8px; border-color: #e3e9f2; }

/* 右上角文字链接（保留原有按钮文案） */
.link-more {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 12px;
    color: var(--primary);
    background: transparent;
    border: none;
    padding: 4px 2px;
}

.link-more::after { content: "›"; font-size: 15px; line-height: 1; }

/* ---------- 图表：网格线 + 渐变柱 ---------- */
.chart-wrap { position: relative; padding-left: 4px; }

.chart-axis {
    position: absolute;
    left: 0;
    top: 4px;
    bottom: 24px;
    width: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
    font-size: 10.5px;
    color: #b0bac9;
    font-variant-numeric: tabular-nums;
}

.chart {
    height: 190px;
    gap: 12px;
    padding: 4px 4px 0;
    background: repeating-linear-gradient(to bottom,
                transparent 0, transparent 46px, #f0f3f9 46px, #f0f3f9 47px);
}

.chart-bars { gap: 6px; }

.bar {
    width: 16px;
    border-radius: 5px 5px 0 0;
}

.bar-in { background: linear-gradient(180deg, #2fbf78 0%, #8ee0ae 100%); }
.bar-out { background: linear-gradient(180deg, #4b7cf8 0%, #9dbbff 100%); }
.chart-label { font-size: 11px; color: #9ba6b7; }
.legend { font-size: 11.5px; }
.legend i { border-radius: 50%; width: 8px; height: 8px; }

/* ---------- 空状态插画 ---------- */
.empty-state { flex-direction: column; gap: 0; }

.empty-art {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 55%, #e6efff 0%, #f4f8ff 62%, #fff 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}

.empty-art svg { width: 38px; height: 38px; }
.empty-art-title { font-size: 13px; color: #6b7688; font-weight: 500; }
.empty-art-sub { font-size: 11.5px; color: #aab4c4; margin-top: 4px; }

/* ---------- 登录页同步细体 ---------- */
.login-hero { background: linear-gradient(150deg, #2046a8 0%, #3b6cf6 58%, #6f9bff 100%); }
.hero-brand span { font-weight: 500; letter-spacing: .04em; }
.login-hero h1 { font-weight: 500; font-size: 31px; }
.login-box h2 { font-weight: 500; }
.login-box .btn { border-radius: 10px; }

/* ---------- 窄屏兜底 ---------- */
@media (max-width: 1100px) {
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .mini-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .quick-card { grid-column: 1 / -1; }
}

@media (max-width: 900px) {
    .content { padding: 18px; }
    html.embedded .content { padding: 16px; }
    .shell-topbar { padding: 0 16px; }
}

/* ============================================================
   可读性修正层：参考稿的「轻」在小字号下发虚，这里把字重与对比度做实。
   只调排版参数，布局结构与业务内容不变。
   ============================================================ */
.card-title, .page-title, .brand-title, .strong, .badge,
label.lbl, th.sortable a, .page-btn.current, .empty-art-title,
.stat-value { font-weight: 600; }

.stat-label, .btn, .link-more, table.data thead th,
.nav-item.active, .tab.active, .combo-item .ci-name,
.p-name, .detail-item .v { font-weight: 500; }

.card, .stat { border-color: #e5eaf3; }

.muted, .page-sub, .pagination, .legend, .crumb,
.sidebar-foot, .chart-axis { color: var(--muted); }

.stat-label { font-size: 13px; color: #4a5568; }
.stat-value { font-size: 28px; color: #17202e; }
.stat-foot { font-size: 12px; color: #6b7688; }
.stat-more { color: #98a3b3; }
.card-title { font-size: 14px; color: #1c2430; }
.nav-item { font-size: 13.5px; color: #3d4757; }
.nav-label { color: #8a95a8; }
.user-menu, .topbar-right, .crumb b { color: #3d4757; }

table.data { font-size: 13.5px; }
table.data thead th { font-size: 12px; color: #5b6678; }
.mono { font-size: 12.5px; }
.badge { font-size: 11.5px; }

.btn { font-size: 13.5px; }
.btn-sm { font-size: 12.5px; }
label.lbl { font-size: 13px; color: #3d4757; }

input[type=text], input[type=password], input[type=number], input[type=date],
select, textarea, .combo-input { font-size: 13.5px; }

.chart-label { font-size: 11.5px; color: #7b879a; }
.empty-art-title { font-size: 13.5px; color: #3d4757; }
.empty-art-sub { font-size: 12px; color: #8a95a8; }
.link-more { font-size: 12.5px; }
.pagination { font-size: 13px; }
.alert { font-size: 13px; }
.page-btn { font-size: 13px; }
.hint, .quick-hint, .p-meta, .ci-meta { color: #6b7688; }
