/* 打印机配件耗材仓库 - H5 样式 */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --bg: #f3f5fa;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --line: #e5e7eb;
    --radius: 14px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f172a;
        --card: #1e293b;
        --text: #e5e7eb;
        --muted: #94a3b8;
        --line: #334155;
    }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
}

a { color: var(--primary); text-decoration: none; }

/* 顶栏 */
.topbar {
    position: sticky; top: 0; z-index: 50;
    display: flex; align-items: center; gap: 8px;
    height: 50px; padding: 0 12px;
    background: var(--primary); color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
}
.topbar-back { width: 34px; height: 34px; font-size: 26px; line-height: 1; border: 0; border-radius: 50%; background: rgba(255,255,255,.16); color: #fff; }
.topbar-title { flex: 1; text-align: center; font-size: 17px; font-weight: 600; }
.topbar-user { min-width: 34px; text-align: right; font-size: 13px; opacity: .95; }

/* 容器 */
.wrap { padding: 12px 12px 8px; max-width: 900px; margin: 0 auto; }

/* 底部导航 */
.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    display: flex; background: var(--card); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
}
.tabbar-item { flex: 1; text-align: center; padding: 6px 0 8px; color: var(--muted); font-size: 12px; }
.tabbar-item.active { color: var(--primary); }
.tabbar-icon { display: block; font-size: 20px; line-height: 22px; }
.tabbar-text { display: block; }

/* 卡片 */
.card {
    background: var(--card); border-radius: var(--radius); padding: 14px;
    margin-bottom: 12px; box-shadow: 0 1px 3px rgba(16, 24, 40, .06);
}
.card-title { font-size: 15px; font-weight: 600; margin: 0 0 10px; display: flex; align-items: center; justify-content: space-between; }
.card-title .more { font-size: 13px; font-weight: 400; color: var(--muted); }

/* 统计 */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 12px; box-shadow: 0 1px 3px rgba(16, 24, 40, .06); }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 22px; font-weight: 700; margin-top: 2px; }
.stat.blue .stat-value { color: var(--primary); }
.stat.green .stat-value { color: var(--success); }
.stat.orange .stat-value { color: var(--warning); }
.stat.red .stat-value { color: var(--danger); }

/* 快捷入口 */
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.quick a { background: var(--card); border-radius: var(--radius); padding: 12px 4px; text-align: center; color: var(--text); font-size: 12px; box-shadow: 0 1px 3px rgba(16, 24, 40, .06); }
.quick-icon { display: block; font-size: 22px; line-height: 26px; margin-bottom: 2px; }

/* 列表 */
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.item-main { flex: 1; min-width: 0; }
.item-name { font-weight: 600; font-size: 15px; }
.item-sub { font-size: 12px; color: var(--muted); margin-top: 2px; word-break: break-all; }
.item-right { text-align: right; white-space: nowrap; }
.stock-num { font-size: 18px; font-weight: 700; }
.stock-num.low { color: var(--danger); }
.stock-num.ok { color: var(--success); }

/* 标签 */
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: #eef2ff; color: var(--primary); }
.tag.in { background: #dcfce7; color: #15803d; }
.tag.out { background: #fee2e2; color: #b91c1c; }
.tag.check { background: #fef3c7; color: #b45309; }
.tag.gray { background: #f1f5f9; color: #64748b; }

/* 按钮 */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    border: 0; border-radius: 10px; padding: 10px 14px; font-size: 15px;
    background: var(--primary); color: #fff; cursor: pointer;
}
.btn:active { opacity: .85; }
.btn.block { display: flex; width: 100%; }
.btn.ghost { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn.gray { background: #e5e7eb; color: #374151; }
.btn.danger { background: var(--danger); }
.btn.success { background: var(--success); }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* 表单 */
.form-group { margin-bottom: 12px; }
.form-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.form-control {
    width: 100%; padding: 10px 12px; font-size: 15px;
    border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text);
}
textarea.form-control { min-height: 70px; resize: vertical; }
select.form-control { appearance: none; }
.form-row { display: flex; gap: 10px; }
.form-row > * { flex: 1; }

/* 搜索栏 */
.searchbar { display: flex; gap: 8px; margin-bottom: 12px; }
.searchbar .form-control { margin: 0; }
.filter-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; }
.chip { flex: 0 0 auto; padding: 6px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* 二维码 */
.qr-box { text-align: center; }
.qr-box img { width: 200px; height: 200px; image-rendering: pixelated; background: #fff; padding: 6px; border-radius: 10px; border: 1px solid var(--line); }
.qr-code-text { font-family: ui-monospace, Consolas, monospace; font-size: 16px; font-weight: 700; letter-spacing: 1px; margin-top: 8px; }

/* 扫码 */
.reader-box { position: relative; width: 100%; background: #000; border-radius: var(--radius); overflow: hidden; min-height: 240px; }
.reader-box video { width: 100% !important; height: auto !important; display: block; }
.reader-box img { display: none !important; }
.reader-tip { text-align: center; color: var(--muted); font-size: 13px; padding: 8px 0; }
.searchbar .btn.scan-btn { flex: 0 0 46px; padding: 0; font-size: 18px; }

/* 扫码弹层（库存查询等页面复用） */
.scan-modal { position: fixed; inset: 0; z-index: 1200; display: flex; align-items: center; justify-content: center; }
.scan-modal[hidden] { display: none; }
.scan-mask { position: absolute; inset: 0; background: rgba(15, 23, 42, .55); }
.scan-panel {
    position: relative; width: min(460px, 94vw); max-height: 90vh; overflow-y: auto;
    background: var(--bg); color: var(--text); border-radius: var(--radius); padding: 14px;
    box-shadow: 0 12px 34px rgba(15, 23, 42, .28);
}
.scan-head { display: flex; align-items: center; justify-content: space-between; font-size: 15px; font-weight: 700; margin-bottom: 10px; }
.scan-close { border: 0; background: transparent; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; }

/* 操作面板 */
.op-panel { position: sticky; bottom: 0; }
.qty-input { display: flex; align-items: center; gap: 8px; }
.qty-input input { text-align: center; font-size: 20px; font-weight: 700; }
.qty-input button { width: 44px; height: 44px; font-size: 20px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); }

/* 打印标签：网格列数由 --label-cols 精确控制，不再依赖容器宽度换行 */
.label-sheet {
    display: grid;
    grid-template-columns: repeat(var(--label-cols, 3), var(--label-w, 50mm));
    gap: var(--label-gap, 2mm);
    justify-content: start;
    align-content: start;
    overflow-x: auto;
}
.label {
    height: var(--label-h, 30mm);
    border: 1px dashed #999; border-radius: 2mm;
    padding: calc(1.5mm * var(--label-scale, 1));
    display: flex; align-items: center; gap: calc(1.5mm * var(--label-scale, 1));
    overflow: hidden; background: #fff; color: #000;
}
.label-qr { flex: 0 0 auto; }
.label-qr img {
    width: calc(var(--label-qr, 22mm) * var(--label-scale, 1));
    height: calc(var(--label-qr, 22mm) * var(--label-scale, 1));
    display: block; image-rendering: pixelated;
}
.label-info { flex: 1; min-width: 0; font-size: calc(8pt * var(--label-scale, 1)); line-height: 1.25; }
.label-code { font-weight: 700; font-size: calc(10pt * var(--label-scale, 1)); font-family: ui-monospace, Consolas, monospace; }
.label-name { font-weight: 600; }
.label-meta { color: #444; }
.label-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 表格（宽屏） */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.table th { color: var(--muted); font-weight: 500; font-size: 13px; }

/* 分页 */
.pager { display: flex; gap: 8px; justify-content: center; margin: 14px 0; }
.pager a, .pager span { padding: 6px 12px; border-radius: 8px; background: var(--card); border: 1px solid var(--line); font-size: 14px; }

/* 提示 */
.empty { text-align: center; color: var(--muted); padding: 30px 0; font-size: 14px; }
.flash { padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; font-size: 14px; background: #dcfce7; color: #15803d; }
.flash-error { background: #fee2e2; color: #b91c1c; }
.toast {
    position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
    max-width: 80%; padding: 10px 16px; border-radius: 999px; background: rgba(17, 24, 39, .92); color: #fff;
    font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 999;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.center { text-align: center; }
.mt0 { margin-top: 0; }
.mb0 { margin-bottom: 0; }

/* 登录页 */
.login-links { text-align: center; margin-top: 12px; font-size: 13px; }
body.route-login { padding-bottom: 0; }
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card { width: 100%; max-width: 360px; background: var(--card); border-radius: 18px; padding: 24px; box-shadow: 0 6px 24px rgba(16, 24, 40, .1); }
.login-logo { text-align: center; font-size: 40px; margin-bottom: 6px; }
.login-title { text-align: center; font-size: 19px; font-weight: 700; margin-bottom: 4px; }

/* 打印 */
@media print {
    body { background: #fff; padding: 0; color: #000; }
    .no-print, .topbar, .tabbar, .toast { display: none !important; }
    .wrap { padding: 0; max-width: none; }
    .card { box-shadow: none; border: 0; padding: 0; margin: 0; }
    .label-sheet { overflow: visible; }
    .label { border-color: #bbb; }
}
@page { size: A4; margin: 8mm; }
