:root {
    --bg: #f6f8fb;
    --panel: #ffffff;
    --panel-2: #f8fafc;
    --border: #e6eaf0;
    --border-strong: #d3dae4;
    --text: #0f172a;
    --text-2: #475569;
    --text-3: #94a3b8;

    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #eff6ff;
    --primary-ring: rgba(37, 99, 235, .14);

    --ok: #059669;
    --ok-soft: #ecfdf5;
    --warn: #b45309;
    --warn-soft: #fffbeb;
    --danger: #dc2626;
    --danger-soft: #fef2f2;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 2px 6px rgba(15, 23, 42, .05);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, .14);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
          "PingFang SC", "Hiragino Sans GB", sans-serif;
    -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: #dbeafe; }

/* ---------------------------------------------------------- 登录 */
#login {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background:
        radial-gradient(1100px 500px at 50% -10%, #e8efff 0%, rgba(232,239,255,0) 62%),
        var(--bg);
}
.login-card {
    width: 372px; background: #fff; border: 1px solid var(--border);
    border-radius: 16px; padding: 34px 30px 28px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, .06), 0 16px 40px rgba(15, 23, 42, .07);
}
.login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 20px; }
.login-logo {
    width: 38px; height: 38px; border-radius: 10px; flex: none;
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 17px; font-weight: 600;
    box-shadow: 0 3px 8px rgba(37, 99, 235, .3);
}
.login-card h1 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.login-card p.sub { margin: 2px 0 0; color: var(--text-3); font-size: 12px; }
.login-card .field { margin-bottom: 13px; }
.login-card .field > label { font-size: 12px; color: var(--text-2); font-weight: 500; }
.login-card input { width: 100%; }
.login-btn {
    width: 100%; margin-top: 8px; padding: 9px; border: none; border-radius: var(--radius-sm);
    background: var(--primary); color: #fff; font-size: 14px; font-weight: 500; cursor: pointer;
    transition: background .15s, box-shadow .15s;
}
.login-btn:hover { background: var(--primary-dark); box-shadow: 0 3px 10px rgba(37, 99, 235, .25); }
.login-btn:active { transform: translateY(.5px); }
.captcha-row { display: flex; gap: 8px; align-items: stretch; }
.captcha-row input { flex: 1; min-width: 0; }
.login-tip {
    margin-top: 18px; padding: 11px 13px; background: var(--panel-2);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 12px; color: var(--text-2); line-height: 1.85;
}
.login-tip b { color: var(--text); font-weight: 500; }

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

.sidebar {
    width: 216px; flex: 0 0 216px; background: #fff; border-right: 1px solid var(--border);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand {
    padding: 16px 16px 14px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 10px;
}
.brand-logo {
    width: 32px; height: 32px; border-radius: 9px; flex: none;
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 15px; font-weight: 600;
    box-shadow: 0 2px 6px rgba(37, 99, 235, .28);
}
.brand b { font-size: 14px; font-weight: 600; display: block; letter-spacing: -.01em; }
.brand span { font-size: 11px; color: var(--text-3); }

.nav { padding: 10px 10px; overflow-y: auto; flex: 1; }
.nav-group {
    font-size: 11px; color: var(--text-3); padding: 13px 10px 5px;
    letter-spacing: .04em; font-weight: 500;
}
.nav a {
    display: flex; align-items: center; gap: 9px;
    padding: 7px 10px; border-radius: var(--radius-sm); color: var(--text-2);
    text-decoration: none; font-size: 13px; cursor: pointer;
    margin-bottom: 1px; transition: background .13s, color .13s;
    border-left: 3px solid transparent;
}
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.active {
    background: var(--primary-soft); color: var(--primary-dark);
    font-weight: 500; border-left-color: var(--primary);
}
.nav a .ic {
    width: 16px; height: 16px; flex: none;
    color: #94a3b8; transition: color .13s;
}
.nav a:hover .ic { color: var(--text-2); }
.nav a.active .ic { color: var(--primary); }
.sidebar-foot {
    padding: 12px 14px; border-top: 1px solid var(--border);
    font-size: 12px; color: var(--text-2); background: var(--panel-2);
}
.sidebar-foot a { color: var(--text-3); text-decoration: none; font-size: 12px; }
.sidebar-foot a:hover { color: var(--danger); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    height: 56px; background: #fff; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; padding: 0 22px; gap: 12px;
    position: sticky; top: 0; z-index: 20;
}
.topbar h2 {
    margin: 0; font-size: 15px; font-weight: 600; flex: 1; letter-spacing: -.01em;
    display: flex; align-items: center; gap: 9px;
}
.topbar h2 .ic { width: 18px; height: 18px; flex: none; color: var(--primary); }
.topbar .who { font-size: 12px; color: var(--text-3); }
.content { padding: 20px 22px 44px; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------- 卡片 */
.card {
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); margin-bottom: 16px; overflow: hidden;
}
.card-head {
    padding: 13px 16px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    background: linear-gradient(180deg, #fff, #fcfdff);
}
.card-head h3 {
    margin: 0; font-size: 14px; font-weight: 600; flex: 1; letter-spacing: -.01em;
    display: flex; align-items: center; gap: 8px;
}
.card-head h3::before {
    content: ''; width: 3px; height: 13px; border-radius: 2px;
    background: var(--primary); opacity: .85;
}
.card-body { padding: 15px 16px; }
.card-body.tight { padding: 0; }

/* ---------------------------------------------------------- 按钮 */
.btn {
    border: 1px solid var(--border-strong); background: #fff; border-radius: var(--radius-sm);
    padding: 6px 13px; cursor: pointer; font-size: 13px; line-height: 1.5;
    color: var(--text-2); transition: background .13s, border-color .13s, color .13s, box-shadow .13s;
    white-space: nowrap;
}
.btn:hover { background: var(--panel-2); border-color: #c3ccd9; color: var(--text); }
.btn:active { transform: translateY(.5px); }
.btn.primary {
    background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 500;
    box-shadow: 0 1px 2px rgba(37, 99, 235, .25);
}
.btn.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn.danger { color: var(--danger); border-color: #f5c9c9; background: #fff; }
.btn.danger:hover { background: var(--danger-soft); border-color: #eeb4b4; color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.sm { padding: 3px 9px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------- 表单 */
input[type=text], input[type=number], input[type=date], input[type=password], select, textarea {
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 6px 10px;
    background: #fff; outline: none; min-width: 0;
    transition: border-color .13s, box-shadow .13s;
}
input:hover, select:hover, textarea:hover { border-color: #c3ccd9; }
input:focus, select:focus, textarea:focus {
    border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring);
}
input[type=number] { font-variant-numeric: tabular-nums; }
select { cursor: pointer; }

.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: 12px; color: var(--text-2); font-weight: 500; }

/* ---------------------------------------------------------- 表格 */
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
th, td { padding: 9px 12px; border-bottom: 1px solid #f1f5f9; text-align: left; vertical-align: middle; }
th {
    background: var(--panel-2); font-weight: 500; color: var(--text-2);
    white-space: nowrap; position: sticky; top: 0; z-index: 1; font-size: 12px;
    border-bottom: 1px solid var(--border);
}
tbody tr { transition: background .1s; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow: auto; max-height: calc(100vh - 230px); }
.empty {
    padding: 46px 20px; text-align: center; color: var(--text-3); font-size: 13px;
}
.empty::before {
    content: ''; display: block; width: 40px; height: 40px; margin: 0 auto 12px;
    border-radius: 10px; background: var(--panel-2); border: 1px dashed var(--border-strong);
}

/* ---------------------------------------------------------- 标签 */
.tag {
    display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 12px;
    border: 1px solid transparent; font-weight: 500; white-space: nowrap;
}
.tag.blue { background: var(--primary-soft); color: var(--primary-dark); border-color: #dbeafe; }
.tag.green { background: var(--ok-soft); color: var(--ok); border-color: #d1fae5; }
.tag.amber { background: var(--warn-soft); color: var(--warn); border-color: #fde68a; }
.tag.red { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.tag.gray { background: #f1f5f9; color: #64748b; border-color: #e2e8f0; }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 12px; letter-spacing: -.02em; }

/* ---------------------------------------------------------- 统计卡 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 14px; }
.stat {
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 15px 17px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
    transition: box-shadow .15s, transform .15s;
}
.stat:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.stat::after {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
    background: var(--primary); opacity: .8;
}
.stat.warn::after { background: var(--warn); }
.stat.ok::after { background: var(--ok); }
.stat .v { font-size: 25px; font-weight: 600; line-height: 1.2; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.stat.alert .v { color: var(--danger); }
.stat.alert::after { background: var(--danger); }

/* ---------------------------------------------------------- 弹层 */
.mask {
    position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
    display: flex; align-items: flex-start; justify-content: center;
    padding: 36px 16px; overflow: auto; z-index: 100;
    backdrop-filter: blur(2px);
    animation: fade .15s ease-out;
}
.modal {
    background: #fff; border-radius: 14px; width: 1000px; max-width: 100%;
    box-shadow: var(--shadow-lg); overflow: hidden;
}
.modal.narrow { width: 560px; }
.modal-head {
    padding: 15px 20px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 10px; background: linear-gradient(180deg, #fff, #fcfdff);
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; flex: 1; letter-spacing: -.01em; }
.modal-body { padding: 18px 20px; max-height: 66vh; overflow: auto; }
.modal-foot {
    padding: 13px 20px; border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 9px; background: var(--panel-2);
}
.close-x {
    border: none; background: none; font-size: 22px; cursor: pointer;
    color: var(--text-3); line-height: 1; padding: 0 2px; border-radius: 6px;
}
.close-x:hover { color: var(--text); background: var(--panel-2); }

/* ---------------------------------------------------------- 提示 */
#toast {
    position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
    z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast {
    background: #0f172a; color: #fff; padding: 9px 16px; border-radius: var(--radius-sm);
    font-size: 13px; box-shadow: var(--shadow-lg);
    animation: drop .2s ease-out;
}
@keyframes drop { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }
.toast.warn { background: var(--warn); }

/* ---------------------------------------------------------- 单据明细编辑 */
.doc-item {
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 13px 14px; margin-bottom: 12px; background: #fff;
    position: relative; transition: border-color .15s, box-shadow .15s;
}
.doc-item:hover { border-color: #cdd7e5; box-shadow: var(--shadow-sm); }
.doc-item.focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.doc-item-head { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; }
.doc-item-no {
    width: 21px; height: 21px; border-radius: 6px; flex: none;
    background: var(--panel-2); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 600; color: var(--text-2);
}
.doc-item-title { font-size: 13px; font-weight: 500; flex: 1; min-width: 0; }
.doc-item-title .none { color: var(--text-3); font-weight: 400; }

.item-grid {
    display: grid; gap: 10px; align-items: end;
    grid-template-columns: minmax(190px, 2fr) 88px 96px 100px minmax(120px, 1fr) 96px minmax(120px, 1fr) 32px;
}
.item-grid.one-line-no-ident {
    grid-template-columns: minmax(190px, 2fr) 88px 96px 100px minmax(120px, 1fr) 96px minmax(120px, 1fr) 32px;
}

/* 物料信息条 */
.mat-info {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    margin-top: 10px; padding: 7px 11px; border-radius: var(--radius-sm);
    background: var(--panel-2); border: 1px solid var(--border);
    font-size: 12px; color: var(--text-2);
}
.mat-info .sep { width: 1px; height: 12px; background: var(--border-strong); }
.mat-info b { color: var(--text); font-weight: 600; }
.mat-info .stock-n { font-variant-numeric: tabular-nums; }

/* 标识录入区 */
.ident-panel {
    margin-top: 10px; border: 1px dashed #bfdbfe; border-radius: var(--radius);
    background: linear-gradient(180deg, #f8fbff, #fff); overflow: hidden;
}
.ident-head {
    display: flex; align-items: center; gap: 8px; padding: 8px 12px;
    border-bottom: 1px dashed #dbeafe; font-size: 12px; color: var(--text-2);
}
.ident-head b { color: var(--primary-dark); font-weight: 600; }
.ident-head .sp { flex: 1; }
.ident-body { padding: 11px 12px; }
.ident-body textarea {
    width: 100%; resize: vertical; min-height: 66px; font-family: ui-monospace, Consolas, monospace;
    font-size: 12.5px; line-height: 1.7;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.chips:empty { display: none; }
.chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 6px 2px 9px; border-radius: 6px; font-size: 12px;
    background: #fff; border: 1px solid #bfdbfe; color: var(--primary-dark);
    font-family: ui-monospace, Consolas, monospace;
}
.chip button {
    border: none; background: none; cursor: pointer; color: #94a3b8;
    font-size: 14px; line-height: 1; padding: 0 1px; border-radius: 3px;
}
.chip button:hover { color: var(--danger); }
.chip.dup { border-color: #fecaca; background: var(--danger-soft); color: var(--danger); }
.ident-note {
    margin-top: 9px; font-size: 12px; display: flex; align-items: center; gap: 6px;
    padding: 6px 10px; border-radius: 6px; background: #fff; border: 1px solid var(--border);
    color: var(--text-2);
}
.ident-note.warn { background: var(--warn-soft); border-color: #fde68a; color: var(--warn); }
.ident-note.ok { background: var(--ok-soft); border-color: #d1fae5; color: var(--ok); }
.ident-note b { font-weight: 600; }

/* 数量类提示 */
.ident-none {
    margin-top: 10px; padding: 8px 12px; border-radius: var(--radius-sm);
    background: var(--panel-2); border: 1px solid var(--border);
    font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 7px;
}

/* 单据底部汇总 */
.doc-summary {
    display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
    margin-top: 14px; padding: 11px 15px; border-radius: var(--radius);
    background: linear-gradient(180deg, #f8fafc, #f4f7fb); border: 1px solid var(--border);
    font-size: 13px; color: var(--text-2);
}
.doc-summary .sp { flex: 1; }
.doc-summary .big {
    font-size: 16px; font-weight: 600; color: var(--text);
    font-variant-numeric: tabular-nums;
}

.row-sep { border-top: 1px solid var(--border); margin: 12px 0; }
.hint { font-size: 12px; color: var(--text-3); line-height: 1.7; }
.pill {
    background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px;
    padding: 1px 10px; font-size: 12px; color: var(--text-2);
}
.right { text-align: right; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.nowrap { white-space: nowrap; }
.checkline { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }
.scan-box { border-radius: var(--radius-sm); padding: 8px 10px; }

/* ---------------------------------------------------------- 标签打印 */
@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    body { background: #fff; }
    .label-sheet { display: grid !important; grid-template-columns: repeat(3, 1fr); gap: 6px; }
    .label {
        border: 1px solid #999; padding: 4px 6px; height: 30mm;
        display: flex; gap: 6px; align-items: center; page-break-inside: avoid;
    }
}
.label-sheet { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.label {
    border: 1px solid var(--border-strong); border-radius: 5px; padding: 4px 6px; height: 30mm;
    display: flex; gap: 6px; align-items: center; background: #fff;
}
.label .qr { width: 26mm; height: 26mm; flex: 0 0 26mm; }
.label .txt { font-size: 9px; line-height: 1.35; min-width: 0; word-break: break-all; }
.label .txt b { font-size: 11px; display: block; }

/* ============================================================ 扫码界面 */
.scan-layer {
    position: fixed; inset: 0; z-index: 500;
    background: #0b0f16; color: #fff;
    display: flex; flex-direction: column;
    height: 100dvh; padding-bottom: env(safe-area-inset-bottom);
}
.scan-head {
    height: 56px; flex: none; display: flex; align-items: center; gap: 10px;
    padding: env(safe-area-inset-top) 12px 0;
    padding-top: max(env(safe-area-inset-top), 0px);
}
.scan-title { flex: 1; font-size: 15px; font-weight: 500; }
.scan-icon-btn {
    width: 40px; height: 40px; border-radius: 10px; border: none; cursor: pointer;
    background: rgba(255, 255, 255, .12); color: #fff; font-size: 17px;
    display: flex; align-items: center; justify-content: center;
}
.scan-icon-btn:active { background: rgba(255, 255, 255, .25); }
.scan-icon-btn.on { background: #facc15; color: #1f2937; }

.scan-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #000; }
.scan-video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-mask {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    pointer-events: none;
}
.scan-frame {
    width: 82%; max-width: 560px; height: 26%; min-height: 90px; max-height: 180px;
    border: 2px solid rgba(255, 255, 255, .92); border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, .55);
    position: relative; overflow: hidden;
}
.scan-frame::after {
    content: ''; position: absolute; left: 0; right: 0; height: 2px;
    background: linear-gradient(90deg, transparent, #34d399, transparent);
    animation: scanline 1.8s ease-in-out infinite;
}
@keyframes scanline {
    0%, 100% { top: 6%; opacity: .2; }
    50% { top: 92%; opacity: 1; }
}
.scan-tip {
    position: absolute; left: 0; right: 0; bottom: 14px; text-align: center;
    font-size: 13px; color: rgba(255, 255, 255, .88); padding: 0 24px; line-height: 1.6;
}
.scan-tip.warn { color: #fbbf24; }

.scan-foot {
    flex: none; padding: 12px 14px; background: #111827;
    border-top: 1px solid rgba(255, 255, 255, .08);
}
.scan-count { font-size: 13px; color: #34d399; margin-bottom: 8px; font-weight: 500; }
.scan-chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 88px; overflow: auto; margin-bottom: 10px; }
.scan-chips:empty { display: none; }
.scan-chip {
    display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px;
    background: rgba(52, 211, 153, .16); border: 1px solid rgba(52, 211, 153, .35);
    border-radius: 6px; font-size: 12px; font-family: ui-monospace, Consolas, monospace;
}
.scan-chip em { font-style: normal; font-size: 10px; opacity: .75; }
.scan-actions { display: flex; gap: 8px; }
.scan-btn {
    flex: 1; height: 44px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .18);
    background: rgba(255, 255, 255, .08); color: #fff; font-size: 14px; cursor: pointer;
}
.scan-btn:active { background: rgba(255, 255, 255, .2); }
.scan-btn.primary { background: var(--primary); border-color: var(--primary); font-weight: 500; }

/* 标识录入区里的扫码按钮 */
.ident-actions { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.btn.scan-trigger {
    background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 500;
    display: inline-flex; align-items: center; gap: 6px;
}
.btn.scan-trigger:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn.scan-trigger .ico { width: 15px; height: 15px; }

/* ============================================================ 移动端适配 */
@media (max-width: 860px) {
    body { font-size: 15px; }
    /* 输入框 ≥16px，否则 iOS 会强制放大页面 */
    input[type=text], input[type=number], input[type=date], input[type=password], select, textarea {
        font-size: 16px; padding: 9px 11px; border-radius: 10px;
    }
    .btn { min-height: 40px; padding: 8px 14px; border-radius: 10px; }
    .btn.sm { min-height: 32px; padding: 4px 10px; }

    /* 侧边栏 → 底部 Tab 栏 */
    #app.on { display: block; }
    .sidebar {
        position: fixed; left: 0; right: 0; bottom: 0; top: auto;
        width: 100%; height: auto; flex: none; z-index: 60;
        border-right: none; border-top: 1px solid var(--border);
        padding-bottom: env(safe-area-inset-bottom);
        box-shadow: 0 -2px 12px rgba(15, 23, 42, .06);
    }
    .brand, .sidebar-foot { display: none; }
    .nav { display: flex; padding: 4px 6px; overflow-x: auto; gap: 2px; }
    .nav::-webkit-scrollbar { display: none; }
    .nav-group { display: none; }
    .nav a {
        flex: 0 0 auto; min-width: 62px; flex-direction: column; gap: 3px;
        padding: 7px 8px 6px; font-size: 11px; border-left: none;
        border-top: 2px solid transparent; border-radius: 8px; margin: 0;
        white-space: nowrap;
    }
    .nav a .ic { width: 20px; height: 20px; }
    .nav a.active { border-left: none; border-top-color: var(--primary); background: transparent; }
    .nav a.active .ic { color: var(--primary); }

    .main { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
    .topbar { height: 50px; padding: 0 14px; }
    .topbar h2 { font-size: 16px; }
    .content { padding: 12px 12px 24px; }

    /* 卡片、间距收紧 */
    .card { border-radius: 12px; margin-bottom: 12px; }
    .card-head { padding: 11px 12px; }
    .card-body { padding: 12px; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat { padding: 12px 13px; }
    .stat .v { font-size: 21px; }
    .filters { gap: 8px; }
    .filters .field { flex: 1 1 46%; }
    .filters input, .filters select { width: 100%; }

    /* 表格 → 卡片 */
    .table-wrap { max-height: none; overflow: visible; }
    .table-wrap table { display: block; }
    .table-wrap thead { display: none; }
    .table-wrap tbody { display: block; }
    .table-wrap tr {
        display: block; background: #fff; border: 1px solid var(--border);
        border-radius: 12px; margin: 0 0 10px; padding: 4px 2px; box-shadow: var(--shadow-sm);
    }
    .table-wrap td {
        display: flex; align-items: center; gap: 12px; justify-content: space-between;
        border: none; padding: 7px 12px; text-align: right; font-size: 14px;
        min-height: 36px;
    }
    .table-wrap td::before {
        content: attr(data-label); color: var(--text-3); font-size: 12.5px;
        flex: none; text-align: left; font-weight: 400;
    }
    .table-wrap td:empty { display: none; }
    .table-wrap td.num { text-align: right; }
    .table-wrap tr:hover { background: #fff; }

    /* 弹窗全屏 */
    .mask { padding: 0; align-items: stretch; }
    .modal, .modal.narrow {
        width: 100% !important; max-width: 100%; border-radius: 0;
        min-height: 100dvh; display: flex; flex-direction: column;
    }
    .modal-body { max-height: none; flex: 1; padding: 14px; }
    .modal-head { padding: 12px 14px; position: sticky; top: 0; background: #fff; z-index: 2; }
    .modal-foot {
        padding: 10px 14px; position: sticky; bottom: 0;
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }
    .modal-foot .btn { flex: 1; }
    .close-x { width: 36px; height: 36px; }

    /* 明细编辑器 */
    .item-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
    .item-grid .field:first-child { grid-column: 1 / -1; }
    .item-grid > button { grid-column: 1 / -1; justify-self: end; }
    .doc-item { padding: 12px; }
    .doc-item-head { flex-wrap: wrap; }
    .doc-summary { gap: 10px; font-size: 13px; }
    .doc-summary .big { font-size: 15px; }

    /* 登录 */
    .login-card { width: auto; margin: 0 16px; padding: 26px 20px; }
}

/* 桌面端表格的标签不显示（只在移动端卡片里用） */
@media (min-width: 861px) {
    .table-wrap td::before { content: none; }
}

/* ============ 批量导入对话框 ============ */
.import-drop {
    border: 2px dashed #c3ccd9;
    border-radius: 12px;
    padding: 28px 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    background: var(--panel-2);
}
.import-drop:hover, .import-drop.drag {
    border-color: var(--primary);
    background: var(--primary-soft);
}
.im-drop-inner { pointer-events: none; }
.im-ico {
    font-size: 28px; line-height: 1; color: var(--primary);
    margin-bottom: 8px; font-weight: 500;
}
.im-summary { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.im-stat {
    padding: 4px 12px; border-radius: 20px; font-size: 13px; font-weight: 500;
}
.im-stat.green { background: var(--ok-soft); color: var(--ok); }
.im-stat.amber { background: var(--warn-soft); color: var(--warn); }
.im-stat.red { background: var(--danger-soft); color: var(--danger); }
.im-block { margin-bottom: 12px; }
.im-block-title { font-weight: 500; font-size: 13px; margin-bottom: 6px; color: var(--text); }
.im-row {
    padding: 6px 10px; border-radius: 8px; font-size: 13px; margin-bottom: 4px;
    line-height: 1.5; word-break: break-all;
}
.im-row.err { background: var(--danger-soft); color: var(--danger); }
.im-row.warn { background: var(--warn-soft); color: var(--warn); }
.im-row.ok { background: var(--ok-soft); color: var(--ok); }
