:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-weak: #eff4ff;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --side: #111827;
  --radius: 8px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}
a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 18px; }
h3 { font-size: 15px; margin-bottom: 10px; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.side { width: 200px; background: var(--side); color: #cbd5e1; flex-shrink: 0; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 8px; padding: 11px 12px; font-size: 16px; font-weight: 600; color: #fff; border-bottom: 1px solid #1f2937; min-height: 56px; }
.brand-full { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-toggle { width: 34px; height: 34px; flex-shrink: 0; border: none; border-radius: 6px; background: transparent; color: #cbd5e1; font-size: 18px; cursor: pointer; }
.side-toggle:hover { background: #1f2937; color: #fff; }
.nav { padding: 10px 0; flex: 1; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: #cbd5e1; }
.nav a:hover { background: #1f2937; color: #fff; }
.nav a.active { background: var(--primary); color: #fff; }
.nav .badge { margin-left: auto; }
.nav .ico { width: 20px; text-align: center; flex-shrink: 0; }
.nav .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side { transition: width .18s ease; }
@media (min-width: 901px) { .side { position: sticky; top: 0; height: 100vh; overflow-y: auto; } }


.btn.icon { width: 34px; padding: 0; font-size: 16px; }
.btn.sm.icon { width: 28px; padding: 0; }
.btn svg { flex-shrink: 0; }
/* 颜色 */
.color-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.color-chip { min-width: 84px; height: 44px; font-size: 15px; }
.color-chip.on, .color-chip:focus-visible { border-color: var(--primary); background: var(--primary-weak); color: var(--primary); outline: none; }
.color-tag { display: inline-flex; align-items: center; margin-left: 6px; padding: 1px 8px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font: inherit; font-size: 12px; color: var(--text); cursor: pointer; white-space: nowrap; }
.color-tag:hover { border-color: var(--primary); color: var(--primary); }
.color-tag.bad { border-color: var(--danger); color: var(--danger); background: #fef2f2; }
.color-tag.static { cursor: default; }
/* 商品小图 */
.thumb { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; border-radius: 6px; background: #f3f4f6; color: #9ca3af; overflow: hidden; vertical-align: middle; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-edit { display: flex; align-items: center; gap: 14px; }
/* 商品编辑：编码 / Item / 条码 / 单位一行，名称 + 规格一行 */
.prod-row-details { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.product-colors { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 3px; }
.product-colors > span { display: inline-flex; align-items: center; gap: 4px; }
.product-prices { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.product-multiple { align-self: end; min-height: 38px; }
@media (max-width: 700px) { .prod-row-details { grid-template-columns: 1fr 1fr; } }
/* 颜色标签输入 */
.tag-input { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 40px; padding: 5px 6px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.tag-input:focus-within { border-color: var(--primary); }
.tag-input .chip { display: inline-flex; align-items: center; gap: 2px; height: 28px; padding: 0 4px 0 10px; border-radius: 999px; background: var(--primary-weak); color: var(--primary); font-size: 14px; }
.tag-input .chip button { border: none; background: none; color: inherit; font-size: 16px; line-height: 1; width: 22px; height: 22px; border-radius: 50%; cursor: pointer; }
.tag-input .chip .color-title { width: auto; padding: 0 4px; font-size: inherit; }
.tag-input .chip button:hover { background: rgba(37,99,235,.15); }
.product-image-row { flex-wrap: wrap; }
.product-sale-switch { display: inline-flex; align-items: center; gap: 8px; margin-inline-start: auto; position: relative; cursor: pointer; }
.product-sale-switch input { position: absolute; inset-inline-start: 0; width: 38px; height: 22px; margin: 0; opacity: 0; cursor: pointer; }
.product-sale-switch .switch-track { display: inline-flex; align-items: center; width: 38px; height: 22px; padding: 3px; border-radius: 999px; background: #64748b; }
.product-sale-switch .switch-track::before { content: ''; width: 16px; height: 16px; border-radius: 50%; background: #fff; }
.product-sale-switch input:checked + .switch-track { justify-content: flex-end; background: var(--primary); }
.product-sale-switch input:focus-visible + .switch-track { outline: 2px solid var(--primary); outline-offset: 3px; }
.img-edit .thumb svg { width: 32px; height: 32px; }
.cart th.act, .cart td.act { width: 1%; text-align: center; }

/* 语言切换 */
.mobile-only { display: none !important; }
/* 电脑上点 ☰ 整个隐藏侧边栏。侧边栏展开时 ☰ 在侧边栏顶部（店名左边，和顶部栏同一高度）；
   隐藏后 ☰ 出现在顶部栏，点它再展开。手机上顶部栏的 ☰ 一直显示，用来滑出菜单 */
@media (min-width: 901px) {
  .layout.side-off .side { display: none; }
  .layout:not(.side-off) .topbar-toggle { display: none; }
}
.side-mask { display: none; }

/* 下拉菜单（语言、账号） */
.dd { position: relative; flex-shrink: 0; }
.dd-menu { position: absolute; top: calc(100% + 6px); left: 0; min-width: 180px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.12); padding: 6px; z-index: 40; display: grid; gap: 2px; }
.dd-menu.dd-right { left: auto; right: 0; }
.dd-menu button { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; padding: 8px 10px; border: none; border-radius: 6px; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; white-space: nowrap; }
.dd-menu button:hover { background: #f3f4f6; }
.dd-menu button.on { color: var(--primary); font-weight: 500; }
.dd-menu button.danger { color: var(--danger); }
.dd-menu button.danger:hover { background: #fef2f2; }
.dd-head { display: grid; padding: 6px 10px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.dd-head small { color: var(--muted); font-size: 12px; }
.icon-btn { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 50%; background: #fff; color: var(--muted); cursor: pointer; }
.icon-btn:hover, .icon-btn[aria-expanded="true"] { color: var(--primary); border-color: var(--primary); }
.user-btn { display: flex; align-items: center; gap: 8px; padding: 3px 8px 3px 3px; border: 1px solid transparent; border-radius: 22px; background: none; font: inherit; color: inherit; cursor: pointer; }
.user-btn:hover, .user-btn[aria-expanded="true"] { background: #f3f4f6; border-color: var(--line); }
.avatar { width: 30px; height: 30px; flex-shrink: 0; border-radius: 50%; background: var(--primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; }
.user-btn .who { display: grid; text-align: left; line-height: 1.25; max-width: 200px; }
.user-btn .who b { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-btn .who small { color: var(--muted); font-size: 12px; }
.caret { color: var(--muted); font-size: 11px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; min-height: 56px; background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 0 20px; gap: 12px; }
.topbar-slot { flex: 1; min-width: 0; }
.topbar .title { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 开发票：顶栏里的客户信息 */
/* 客户信息：客户 / 电话 / 送货地址 一行 */
.tb-customer { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(120px, .8fr) minmax(0, 1.6fr); gap: 10px; align-items: end; }
/* 提交按钮里带应收合计 */
/* 金额在上（大字），「提交发票」在下（黄色字） */
.btn.pay-btn { height: auto; min-height: 56px; min-width: 240px; padding: 6px 26px; flex-direction: column; justify-content: center; align-items: center; gap: 2px; font-size: 15px; font-weight: 600; border-radius: 0; border: none; line-height: 1.15; }
.btn.pay-btn .pay-btn-lbl { color: #fde047; letter-spacing: 1px; }
/* 提交按钮占满结算栏的整个高度，没有圆角，贴着右边（抵消结算栏的内边距） */
.pay-bar:has(.pay-btn) .pay-actions { align-self: stretch; align-items: stretch; margin: -12px -20px -12px 0; }
@media (max-width: 900px) { .pay-bar:has(.pay-btn) .pay-actions { margin: -10px -12px -10px 0; } }
/* 比手机宽时结算栏永远一行：客户框可以缩窄，按钮不掉到第二行 */
@media (min-width: 641px) {
  .pay-bar:has(.pay-btn) { flex-wrap: nowrap; }
  .pay-bar:has(.pay-btn) .pay-customer { min-width: 0; }
  .pay-bar:has(.pay-btn) .pay-count { flex-shrink: 0; }
  .pay-bar:has(.pay-btn) .pay-actions { flex-shrink: 0; }
}
@media (min-width: 641px) and (max-width: 900px) { .btn.pay-btn { min-width: 190px; padding: 6px 18px; } }
/* 手机：按钮单独一行，贴着结算栏的底边和左右两边 */
@media (max-width: 640px) { .pay-bar:has(.pay-btn) .pay-actions { margin: 0 -12px -10px; } .btn.pay-btn { min-height: 60px; } }
.btn.pay-btn .pay-btn-amt { font-size: 26px; font-weight: 800; letter-spacing: .3px; }
.btn.pay-btn:disabled { opacity: .7; }
/* 输入框标题嵌在边框线上 */
.tb-field { position: relative; display: block; flex: 1; min-width: 0; }
.tb-field > span { position: absolute; top: -7px; left: 9px; z-index: 1; padding: 0 4px; background: #fff; font-size: 11px; line-height: 14px; color: var(--muted); pointer-events: none; white-space: nowrap; }
.tb-field input { width: 100%; height: 36px; }
/* 客户框右边的 + 新增客户按钮 */
.tb-name input, .cust-add-wrap input { padding-right: 40px; }
.cust-add-wrap { position: relative; }
.cust-add { position: absolute; right: 4px; bottom: 4px; width: 28px; height: 28px; padding: 0; border: none; border-radius: 6px; background: var(--primary, #2563eb); color: #fff; font-size: 20px; line-height: 28px; font-weight: 600; cursor: pointer; }
.cust-add-wrap .cust-add { top: 50%; bottom: auto; transform: translateY(-50%); }
.cust-add:hover { filter: brightness(1.1); }
.cust-suggest .cust-add-opt { color: var(--primary, #2563eb); gap: 8px; align-items: baseline; }
.tb-cust-btn { display: none; }
.pay-customer { flex: 1 1 0; min-width: 300px; max-width: 760px; margin-right: auto; }

/* 开发票：商品明细占满中间，结算栏固定在底部 */
.content.pos-page { display: flex; flex-direction: column; padding-bottom: 0; }
.cart-card { flex: 1; margin-bottom: 0; }
.pay-bar { position: sticky; bottom: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin: 16px -20px 0; padding: 12px 20px; background: var(--panel); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(0,0,0,.06); }
.pay-item { display: grid; gap: 2px; }
.pay-item input { height: 32px; width: 110px; text-align: right; }
.pay-remark { flex: 1; min-width: 180px; }
.pay-remark input { width: 100%; text-align: left; }
.pay-total, .pay-count { text-align: right; }
.pay-total .summary-total { line-height: 1.1; }
.pay-actions { display: flex; gap: 8px; align-items: center; }
.content { padding: 20px; flex: 1; }

/* ---------- 组件 ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.grid { display: grid; gap: 12px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.danger-text { color: var(--danger); }
.success-text { color: var(--success); }
.warn-text { color: var(--warning); }
.big { font-size: 24px; font-weight: 700; }
.nowrap { white-space: nowrap; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--text); cursor: pointer; font-size: 14px; white-space: nowrap; }
.btn:hover { border-color: #cbd5e1; background: #f9fafb; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: #1d4ed8; }
.btn.danger { background: #fff; border-color: #fecaca; color: var(--danger); }
.btn.danger:hover { background: #fef2f2; }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.lg { height: 44px; padding: 0 28px; font-size: 16px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.link { background: none; border: none; color: var(--primary); cursor: pointer; padding: 0; font-size: inherit; }
.link.danger { color: var(--danger); }

input, select, textarea { font: inherit; color: inherit; border: 1px solid #d1d5db; border-radius: 6px; padding: 0 10px; height: 34px; background: #fff; width: 100%; min-width: 0; }
textarea { padding: 8px 10px; height: auto; min-height: 60px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
input[type=checkbox] { width: auto; height: auto; }
input[readonly] { background: #f3f4f6; color: var(--muted); cursor: not-allowed; }
label.field { display: flex; flex-direction: column; gap: 4px; }
label.field > span { color: var(--muted); font-size: 13px; }
label.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.req::after { content: " *"; color: var(--danger); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: #f9fafb; color: var(--muted); font-weight: 500; font-size: 13px; white-space: nowrap; }
tbody tr:hover, tbody tr.hl { background: #eef4ff; } /* 浅蓝高亮；商品行和下面的样式行一起高亮 */
td.num, th.num { text-align: right; white-space: nowrap; }
td input { height: 30px; }
tr.clickable { cursor: pointer; }
th.commission-cell, td.commission-cell { text-align: center; }
.empty { text-align: center; color: var(--muted); padding: 30px; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #f3f4f6; color: #374151; white-space: nowrap; }
.tag.pending, .tag.due { background: #fef3c7; color: #92400e; }
.tag.approved { background: #dbeafe; color: #1e40af; }
.tag.shipped { background: #dcfce7; color: #166534; }
.tag.rejected { background: #fee2e2; color: #991b1b; }
.tag.cancelled { background: #e5e7eb; color: #6b7280; text-decoration: line-through; }
.tag.unpaid { background: #fee2e2; color: #991b1b; }
.tag.partial { background: #fef3c7; color: #92400e; }
.tag.paid { background: #dcfce7; color: #166534; }
.badge { min-width: 18px; height: 18px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--primary); border-color: var(--primary); font-weight: 500; }

.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 4px; }
a.stat:hover { border-color: var(--primary); }
/* 首页数字卡片：分三行，每行最多三张 */
.commission-stats { margin-block: 12px; }
.stat-rows { display: grid; gap: 12px; margin-bottom: 16px; }
.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

.notice { margin-top: 10px; white-space: pre-wrap; line-height: 1.7; word-break: break-word; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; }

/* ---------- 弹窗 / 提示 ---------- */
.mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px; z-index: 50; overflow-y: auto; }
.dialog { background: #fff; border-radius: 10px; width: 100%; max-width: 520px; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.dialog.wide { max-width: 760px; }
.dialog header { padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 600; display: flex; }
.dialog header .x { margin-left: auto; cursor: pointer; color: var(--muted); border: none; background: none; font-size: 18px; line-height: 1; }
.dialog .body { padding: 18px; display: grid; gap: 12px; }
.dialog footer { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
#toast { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; }
#toast div { background: #111827; color: #fff; padding: 10px 18px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); animation: fadein .2s; max-width: 90vw; }
#toast div.error { background: var(--danger); }
#toast div.ok { background: var(--success); }
@keyframes fadein { from { opacity: 0; transform: translateY(-6px); } }

/* ---------- 登录 ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e3a8a, #2563eb); padding: 16px; }
.login-box { background: #fff; border-radius: 12px; padding: 32px; width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-box h1 { font-size: 22px; margin-bottom: 4px; }
.login-box form { display: grid; gap: 14px; margin-top: 22px; }
.demo-accounts { margin-top: 22px; padding-top: 16px; border-top: 1px dashed var(--line); display: grid; gap: 6px; }
.demo { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; background: #f9fafb; cursor: pointer; font: inherit; color: inherit; text-align: left; }
.demo:hover { border-color: var(--primary); background: var(--primary-weak); }
.demo span { color: var(--muted); font-size: 13px; font-family: ui-monospace, Menlo, monospace; }

/* ---------- 开单 ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.search-row { display: flex; gap: 10px; align-items: center; }
.search-box { position: relative; flex: 1; min-width: 0; }
.cont-toggle { display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; white-space: nowrap; cursor: pointer; user-select: none; font-size: 14px; }
.cont-toggle input { width: auto; height: auto; margin: 0; }
.cont-toggle:has(input:checked) { border-color: var(--primary); background: var(--primary-weak); color: var(--primary); }
.search-box input { height: 44px; font-size: 16px; padding-left: 14px; }
.suggest { position: absolute; left: 0; right: 0; top: 48px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.12); z-index: 20; max-height: 360px; overflow-y: auto; }
.suggest .opt { padding: 8px 12px; display: flex; gap: 10px; align-items: center; cursor: pointer; border-bottom: 1px solid #f3f4f6; }
.suggest .opt.on, .suggest .opt:hover { background: var(--primary-weak); }
.suggest .order-suggestion { display: grid; column-gap: 5px; padding-inline-end: 6px; grid-template-columns: 32px clamp(50px, 11%, 90px) minmax(0, 1fr) 8ch 4ch 7ch 4ch; }
.order-suggestion .suggest-stock { align-self: stretch; display: grid; align-items: center; margin-block: -8px; padding-inline: 2px; background: #fff7d6; border-inline: 1px solid #e7c75c; }
.order-suggestion .suggest-added .tag { padding-inline: 4px; }
.order-suggestion .suggest-item, .order-suggestion .nm { overflow-wrap: anywhere; }
.order-suggestion .suggest-item, .order-suggestion .suggest-number, .order-suggestion .suggest-added { text-align: end; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
@media (max-width: 480px) {
  .suggest .order-suggestion { gap: 5px; padding-inline: 6px; }
}
.suggest-code { min-width: 0; overflow-wrap: anywhere; }
.suggest-code > span { display: block; }
.suggest .opt .nm { flex: 1; min-width: 0; }
/* 客户大下拉框 */
.has-suggest { position: relative; }
/* 出库页面：左边待出库列表，右边发票明细 + 确认出库 */
.ship-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; flex: 1; min-height: 0; align-items: start; }
.ship-list { position: sticky; top: 72px; max-height: calc(100vh - 96px); display: flex; flex-direction: column; margin-bottom: 0; }
.ship-items { overflow-y: auto; display: grid; gap: 8px; align-content: start; }
.ship-item { display: grid; gap: 4px; text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font: inherit; color: inherit; cursor: pointer; }
.ship-item:hover { border-color: #93c5fd; }
.ship-item.on { border-color: var(--primary); background: var(--primary-weak); box-shadow: 0 0 0 1px var(--primary) inset; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ship-detail { margin-bottom: 0; display: flex; flex-direction: column; gap: 14px; min-height: 60vh; }
.ship-cust { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 20px; padding: 12px 14px; background: #f9fafb; border-radius: 8px; }
.ship-cust > div { display: flex; gap: 10px; }
.ship-cust .wide { grid-column: 1 / -1; }
.ship-cust .muted { min-width: 64px; }
.ship-table { flex: 1; }
.ship-table tr.short td { background: #fef2f2; }
.ship-qty { font-size: 18px; }
.ship-bar { position: sticky; bottom: 0; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 0 2px; background: var(--panel); border-top: 1px solid var(--line); }
@media (max-width: 900px) {
  .ship-layout { grid-template-columns: minmax(0, 1fr); }
  .ship-detail { min-width: 0; }
  .ship-list { position: static; max-height: 45vh; }
  .ship-cust { grid-template-columns: 1fr; }
  .ship-bar .btn { flex: 1 1 100%; }
}
/* 开票成功窗口：大窗口 + 发票缩小预览 */
.dialog.xl { max-width: 1040px; }
.mask:has(.dialog.xl) { padding-top: 4vh; }
.done-head { display: flex; align-items: flex-end; gap: 28px; flex-wrap: wrap; }
.done-no { font-size: 26px; font-weight: 700; letter-spacing: .5px; line-height: 1.2; }
.done-total { font-size: 26px; font-weight: 700; line-height: 1.2; }
.done-acts { display: flex; gap: 12px; flex-wrap: wrap; }
.done-acts .btn { min-width: 150px; }
.done-preview { background: #eef0f3; border-radius: 8px; padding: 18px; max-height: 64vh; overflow: auto; }
/* 开票成功窗口：整张竖向 A4 缩小显示 */
.done-preview .print-sheet { zoom: .62; max-width: none; box-shadow: 0 2px 12px rgba(0,0,0,.15); }
@media (max-width: 700px) {
  .done-preview { padding: 10px; }
  .done-preview .print-sheet { zoom: .4; }
  .done-acts { width: 100%; }
  .done-acts .btn { flex: 1; min-width: 0; }
}
.suggest.up { top: auto; bottom: calc(100% + 4px); box-shadow: 0 -10px 30px rgba(0,0,0,.12); }
.cust-suggest { min-width: min(560px, 90vw); font-size: 15px; }
.cust-suggest .opt { padding: 10px 14px; gap: 14px; }
.cust-suggest .opt .nm { flex: 0 1 auto; min-width: 120px; }
.cust-suggest .ph { white-space: nowrap; color: var(--text); }
.cust-suggest .addr { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; }
.dialog .cust-suggest { min-width: 0; top: 100%; }
.dialog .cust-suggest .opt { flex-wrap: wrap; row-gap: 2px; }
.dialog .cust-suggest .addr { flex-basis: 100%; text-align: left; font-size: 13px; }
.cart td input.qty.bad { border-color: var(--danger); color: var(--danger); background: #fef2f2; }
.cart td input.qty { width: 96px; height: 30px; padding: 4px 6px; text-align: right; }
.order-cart th, .order-cart td { text-align: center; }
.cart.order-cart td input.qty { text-align: right; }
.summary-line { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; }
.summary-total { font-size: 28px; font-weight: 700; color: var(--danger); }
.kbd { display: inline-block; border: 1px solid #d1d5db; border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-size: 11px; color: var(--muted); background: #fff; }
.sticky { position: sticky; top: 16px; }
.dl { display: grid; grid-template-columns: 90px 1fr; gap: 6px 12px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 6px 0 6px 16px; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }

/* ---------- 打印 ---------- */
/* 发票 = 竖向 A4 纸（210 × 297 mm） */
.print-sheet { box-sizing: border-box; width: 210mm; max-width: 100%; min-height: 297mm; padding: 16mm 14mm; margin: 0 auto; background: #fff; color: #000; display: flex; flex-direction: column; font-size: 13px; }
.print-sheet.card { border: 1px solid var(--line); border-radius: 0; box-shadow: 0 2px 14px rgba(0,0,0,.10); }
.print-sheet table { width: 100%; border-collapse: collapse; font-size: 13px; }
/* 签名栏在纸的底部附近（屏幕预览和打印一样） */
.print-sheet .sign { margin-top: auto; padding-top: 48px; }
.print-sheet h1 { text-align: center; font-size: 22px; }
.print-sheet .sub { text-align: center; margin: 4px 0 8px; font-size: 13px; }
.print-sheet .doc-title { text-align: center; font-size: 16px; font-weight: 700; letter-spacing: 4px; margin: 0 0 14px; padding: 6px 0; border-top: 2px solid #000; border-bottom: 2px solid #000; }
.print-sheet table th, .print-sheet table td { border: 1px solid #333; padding: 6px 8px; background: none; color: #000; }
.print-sheet .meta { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 20px; margin-bottom: 10px; font-size: 13px; }
.print-sheet .sign { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; font-size: 13px; }

@page { size: A4 portrait; margin: 0; }
@media print {
  .side, .topbar, .no-print, #toast { display: none !important; }
  .content { padding: 0; }
  body, .print-sheet { background: #fff; }
  /* 打印时纸张本身就是 A4，发票高度跟着内容走，不再撑满一整页（否则签名会被挤到第二页） */
  html, body, .layout, .main, .content, #view { margin: 0 !important; padding: 0 !important; min-height: 0 !important; height: auto !important; background: #fff !important; }
  /* 发票高度略小于一张 A4（297mm），签名栏推到纸的底部附近，又保证在同一页 */
  .print-sheet, .print-sheet.card { width: 210mm; max-width: none; min-height: 285mm; margin: 0; border: none; box-shadow: none; }
  .print-sheet .sign { margin-top: auto; padding-top: 24px; }
  .print-sheet .sign, .print-sheet tr { break-inside: avoid; page-break-inside: avoid; }
}

/* ---------- 移动端 ---------- */
@media (max-width: 900px) {
  /* 手机：侧边栏平时完全隐藏，点顶栏 ☰ 从左边滑出 */
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 220px; z-index: 50; overflow-y: auto; transform: translateX(-100%); transition: transform .2s ease; }
  .layout.m-open .side { transform: none; box-shadow: 4px 0 24px rgba(0,0,0,.25); }
  .layout.m-open .side-mask { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(0,0,0,.35); }
  .mobile-only { display: inline-flex !important; }
  .topbar .title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .pos { grid-template-columns: 1fr; }
  .pay-bar { margin-left: -12px; margin-right: -12px; padding: 10px 12px; }
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content { padding: 12px; }
  .topbar { padding: 8px 12px; }
  .sticky { position: static; }
}
/* 真正的手机宽度才把结算栏改成竖排：客户只显示名字按钮（点开弹窗），按钮占满一行 */
@media (max-width: 640px) {
  .tb-customer { display: block; }
  .tb-customer .tb-field { display: none; }
  .tb-cust-btn { display: flex; align-items: center; gap: 6px; width: 100%; min-width: 0; height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 18px; background: #fff; font: inherit; color: inherit; cursor: pointer; }
  .tb-cust-btn .nm { flex: 1; min-width: 0; text-align: left; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tb-cust-btn.empty .nm { color: var(--muted); font-weight: 400; }
  .tb-cust-btn .caret { color: var(--muted); font-size: 11px; }
  .pay-customer { flex: 1 1 100%; max-width: none; }
  .pay-count { margin-left: auto; }
  .pay-actions { flex: 1 1 100%; }
  .pay-actions .btn { flex: 1; }
}
@media (max-width: 520px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .stat-row { grid-template-columns: 1fr; }
  .topbar .who { display: none; }
  .print-sheet .meta { grid-template-columns: 1fr; }
}
/* 生成 PDF 时用的隐藏发票（放在屏幕外，按 A4 尺寸渲染，高度略小于一页，避免多出空白第二页） */
.pdf-render { position: fixed; left: -10000px; top: 0; width: 210mm; background: #fff; }
.print-sheet.pdf { width: 210mm; max-width: none; min-height: 290mm; margin: 0; border: none; box-shadow: none; }
/* 数据清空页面 */
.clear-warn { border-left: 4px solid #dc2626; display: flex; flex-direction: column; gap: 4px; }
.clear-list { display: flex; flex-direction: column; gap: 8px; }
.clear-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.clear-item.on { border-color: #fca5a5; background: #fef2f2; }
.clear-item input { width: 18px; height: 18px; flex: none; }
.clear-item input:disabled { opacity: .7; }
.clear-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.clear-count { white-space: nowrap; font-weight: 600; }
.clear-count.zero { color: var(--muted); font-weight: 400; }
.clear-confirm { margin: 8px 0 14px; padding-left: 20px; line-height: 1.8; }
/* 数据库页面：备份 / 清空数据 两个区块 */
.db-section-title { font-size: 17px; margin: 18px 0 10px; }
.db-section-title:first-child { margin-top: 0; }
.tag.bk-daily { background: #e0f2fe; color: #075985; }
.tag.bk-manual { background: #dcfce7; color: #166534; }
.tag.bk-before_clear { background: #fef3c7; color: #92400e; }
.tag.bk-uploaded { background: #ede9fe; color: #5b21b6; }
.tag.bk-before_rollback, .tag.bk-before_restore { background: #fee2e2; color: #991b1b; }
.bk-note { min-width: 160px; }
.tag.bk-before_import { background: #f3e8ff; color: #6b21a8; }
.tag.bk-before_undo { background: #e5e7eb; color: #374151; }
/* 临时密码 */
.temp-pwd { margin-top: 4px; color: var(--muted); }
.temp-pwd code, .temp-pwd-box code { font-family: ui-monospace, Menlo, monospace; background: #f3f4f6; padding: 1px 6px; border-radius: 4px; color: #111827; letter-spacing: .5px; }
.temp-pwd-box { margin: 12px 0; padding: 12px 14px; border: 1px dashed var(--line); border-radius: 8px; display: flex; flex-direction: column; gap: 8px; font-size: 15px; }
.temp-pwd-box code { font-size: 17px; }
.pwd-code { font-family: ui-monospace, Menlo, monospace; background: #f3f4f6; padding: 1px 6px; border-radius: 4px; color: #111827; }
/* 按颜色的库存 */
.cs-item { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.cs-item b { color: var(--text); font-weight: 600; }
.cs-item.out b { color: var(--danger); }
.cs-item.none { color: #b45309; }
.cs-item.none b { color: #b45309; }
.color-chip { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; line-height: 1.2; }
.color-chip .chip-stock { font-size: 11px; color: var(--muted); font-weight: 400; }
.color-chip.on .chip-stock { color: inherit; opacity: .85; }
/* 商品详细（双击行） */
.dbl-row { cursor: pointer; user-select: none; }
.prod-detail { display: grid; grid-template-columns: 320px 1fr; gap: 20px; align-items: start; }
.prod-detail-img { width: 320px; height: 320px; border: 1px solid var(--line); border-radius: 8px; display: flex; align-items: center; justify-content: center; overflow: hidden; background: #f9fafb; }
.prod-detail-img img { width: 100%; height: 100%; object-fit: contain; }
.prod-detail .dl { margin: 0; }
@media (max-width: 640px) { .prod-detail { grid-template-columns: 1fr; } .prod-detail-img { width: 100%; height: 200px; } }
.prod-detail .dl { grid-template-columns: 110px 1fr; }
/* 编辑商品：颜色标签里的图片大一些 */
.tag-input .chip:has(.thumb) { height: auto; padding: 4px 4px 4px 4px; border-radius: 10px; gap: 4px; }
.tag-input .chip .thumb { border-radius: 6px; }
/* 颜色标签：删除 × 放在右上角 */
.tag-input .chip { position: relative; }
.tag-input .chip:has(.thumb) { padding-right: 12px; }
.tag-input .chip button.chip-x { position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; padding: 0; font-size: 14px; line-height: 18px; text-align: center;
  background: #fff; border: 1px solid var(--line); color: var(--muted); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.tag-input .chip button.chip-x:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.tag-input #color-tags { gap: 10px; }
/* 颜色标签：颜色自己的 Item / 条码 */
.tag-input .chip .color-title { display: inline-flex; flex-direction: column; align-items: flex-start; line-height: 1.25; text-align: left; }
.chip-codes { display: flex; flex-direction: column; font-size: 11px; color: var(--muted); font-weight: 400; }
/* 编辑商品：颜色（样式）表格 */
.color-box { border: 1px solid var(--line); border-radius: 6px; padding: 8px; background: #fff; }
.color-list { width: 100%; border-collapse: collapse; }
.color-list th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 4px 8px; border-bottom: 1px solid var(--line); }
.color-list td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.color-list tr:last-child td { border-bottom: none; }
.color-list .color-title { font-size: 14px; }
.thumb.empty { display: inline-block; border: 1px dashed var(--line); border-radius: 6px; background: #f9fafb; }
.prod-detail-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.prod-detail input[readonly], .dialog .product-prices input[readonly] { background: #f9fafb; cursor: default; }
@media (max-width: 640px) { .prod-detail-fields { grid-template-columns: 1fr; } }
.prod-detail-prices { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.prod-detail-prices input[readonly] { background: #f9fafb; }
@media (max-width: 640px) { .prod-detail-prices { grid-template-columns: 1fr; } }
.th-main { font-weight: 600; color: var(--text); font-size: 13px; margin-top: 2px; }
/* 商品详细：样式方格 */
.variant-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.variant-card { border: 1px solid var(--line); border-radius: 8px; padding: 8px; text-align: center; background: #fff; }
.variant-img { aspect-ratio: 1; border-radius: 6px; overflow: hidden; background: #f9fafb; display: flex; align-items: center; justify-content: center; margin-bottom: 6px; }
.variant-img img { width: 100%; height: 100%; object-fit: cover; }
.variant-name { font-weight: 600; margin-bottom: 2px; word-break: break-word; }
/* 主图高度跟右边输入框一样高 */
.prod-detail { align-items: stretch; }
.prod-detail-img { position: relative; height: auto; min-height: 200px; }
.prod-detail-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.variant-title { margin: 16px 0 2px; line-height: 1.2; color: var(--muted); font-size: 13px; }
@media (max-width: 640px) { .prod-detail-img { height: 260px; } }
/* 编辑商品：和详细窗口同一排版 */
.prod-edit-img #img-prev { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.prod-edit-img #img-prev img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.prod-edit-img .img-tools { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 8px; justify-content: center; padding: 8px; background: linear-gradient(transparent, rgba(0,0,0,.35)); }
.prod-detail-fields .product-multiple { align-self: end; min-height: 38px; }
.variant-edit { position: relative; padding: 0; }
.variant-open { display: block; width: 100%; padding: 8px; border: none; background: none; font: inherit; color: inherit; cursor: pointer; text-align: center; }
.variant-edit:hover { border-color: var(--primary); }
.variant-edit .chip-x { position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; padding: 0; border-radius: 50%; font-size: 14px; line-height: 20px;
  background: #fff; border: 1px solid var(--line); color: var(--muted); cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.variant-edit .chip-x:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.variant-add { cursor: pointer; font: inherit; color: var(--primary); border-style: dashed; }
.variant-add .variant-img { font-size: 36px; color: var(--primary); background: var(--primary-weak); }
.variant-add:hover { border-color: var(--primary); }
.variant-card .variant-img, .variant-card .variant-name { display: flex; }
.variant-card .variant-name { justify-content: center; }
/* 查看模式（双击商品）：同一个模板，只读 */
.viewing .img-tools, .viewing .variant-add, .viewing .chip-x { display: none !important; }
.viewing .variant-open { cursor: default; }
.viewing .variant-edit:hover { border-color: var(--line); }
.viewing .body input:not([type=checkbox]) { background: #f9fafb; }
.viewing .product-sale-switch, .viewing .product-multiple { pointer-events: none; }
.variant-open .small { display: block; margin-top: 2px; }
.viewing .req::after { display: none; }
/* 列表：样式图片放在商品行下面一行，名称保持垂直居中 */
tr.has-sub > td { border-bottom: none; }
tr.sub-row > td { padding-top: 0; padding-bottom: 10px; }
tr.sub-row .product-colors { margin-top: 0; gap: 6px 16px; }
.chip-added { font-size: 11px; font-weight: 700; color: var(--success); min-height: 14px; }
/* 连续选样式：每个样式下面一个数量框 */
.pick-col { display: inline-flex; flex-direction: column; gap: 6px; width: 110px; }
.pick-col .color-chip { width: 100%; }
.pick-qty { width: 100%; text-align: center; height: 34px; }
/* 选样式：带图片 */
.color-chip.has-img { height: auto; padding: 6px 8px 6px; min-width: 96px; }
.chip-img { width: 80px; height: 80px; border-radius: 6px; overflow: hidden; background: #f3f4f6; display: block; margin-bottom: 4px; }
.chip-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pick-col .color-chip.has-img { height: auto; }
.color-tag .tag-img { width: 26px; height: 26px; object-fit: cover; border-radius: 4px; margin: -1px 6px -1px -5px; }
.color-tag:has(.tag-img) { padding-top: 2px; padding-bottom: 2px; border-radius: 8px; }
.print-sheet .sub-th { font-weight: 400; font-size: 11px; }
.print-sheet .sub-td { font-size: 11px; color: #444; margin-top: 1px; }
/* 商品名称一律大写：编辑框里打字时就显示成大写 */
.dialog input[name="name"].upper { text-transform: uppercase; }
/* 小图放大 / 全屏查看 */
table .thumb img, .product-colors .thumb img, .color-tag img.tag-img { cursor: zoom-in; }
.img-pop { position: fixed; z-index: 1000; width: 260px; height: 260px; padding: 6px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.18); pointer-events: none; }
.img-pop[hidden] { display: none; }
.img-pop img { width: 100%; height: 100%; object-fit: contain; display: block; }
.lightbox { position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,.88); display: flex; align-items: center; justify-content: center; cursor: zoom-out; }
.lightbox img { max-width: 95vw; max-height: 95vh; object-fit: contain; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.lightbox-x { position: fixed; top: 16px; right: 20px; width: 40px; height: 40px; border-radius: 50%; border: none; background: rgba(255,255,255,.15); color: #fff; font-size: 26px; line-height: 40px; cursor: pointer; }
.lightbox-x:hover { background: rgba(255,255,255,.3); }
/* 样式库存小块：每个用白底 + 边线框起来 */
.product-colors .cs-item { padding: 2px 8px; border: 1px solid #b8bec8; border-radius: 6px; background: #fff; }
tr.sub-row .product-colors { gap: 6px 8px; }
