/* ============================================================
   进销存管理系统 · 样式表
   浅色主题,面向门店日常高频操作
   ============================================================ */

:root {
  --bg:            #f4f6fa;
  --surface:       #ffffff;
  --surface-2:     #fafbfd;
  --border:        #e4e8ef;
  --border-strong: #d3d9e4;

  --text:          #1c2434;
  --text-2:        #5a6478;
  --text-3:        #8b95a8;

  --primary:       #2f6fed;
  --primary-dark:  #2559c4;
  --primary-soft:  #eaf1fe;

  --success:       #16a34a;
  --success-soft:  #e7f6ec;
  --danger:        #dc2626;
  --danger-soft:   #fdeaea;
  --warning:       #d97706;
  --warning-soft:  #fdf3e3;
  --info:          #0891b2;
  --info-soft:     #e4f5f9;

  --radius:        10px;
  --radius-sm:     6px;
  --shadow:        0 1px 3px rgba(20,32,56,.07), 0 6px 20px rgba(20,32,56,.05);
  --shadow-lg:     0 8px 40px rgba(20,32,56,.16);

  --sidebar-w:     214px;
  --topbar-h:      58px;

  --fs:            13px;
  --fs-sm:         12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* HTML 的 hidden 属性靠浏览器默认样式 [hidden]{display:none} 实现,
   但任何作者写的 display 都会覆盖它(如 .modal-mask{display:grid})。
   这里显式兜底,确保 hidden 永远生效 —— 否则弹窗遮罩会常驻显示。 */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC",
               "Hiragino Sans GB", "Segoe UI", system-ui, sans-serif;
  font-size: var(--fs);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* ---------- 侧边栏 ---------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: #1b2334;
  display: flex;
  flex-direction: column;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.brand-logo {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #4d86f7, #2f6fed);
  color: #fff;
  display: grid; place-items: center;
  font-size: 16px; font-weight: 700;
  flex: none;
}
.brand-title { color: #fff; font-size: 14px; font-weight: 600; letter-spacing: .3px; }
.brand-sub   { color: #7d889e; font-size: 11px; margin-top: 1px; }

.nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 16px;
}
.nav::-webkit-scrollbar { width: 5px; }
.nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 3px; }

.nav-group {
  color: #626d82;
  font-size: 10.5px;
  letter-spacing: 1.2px;
  padding: 12px 16px 5px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 16px;
  color: #b3bccd;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background .13s, color .13s;
  position: relative;
}
.nav-item .ico { font-size: 14px; width: 17px; text-align: center; flex: none; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #e8ecf3; }
.nav-item.active {
  background: rgba(47,111,237,.18);
  color: #fff;
  border-left-color: #4d86f7;
}
.nav-item .badge {
  margin-left: auto;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 9px;
  font-weight: 700;
}

/* ---------- 登录页 ---------- */
.login-page {
  position: fixed;
  inset: 0;
  z-index: 500;
  /* ★ 门店货架实景背景;图片缺失时自动回退到渐变
     遮罩分三层:整体压暗 + 四周径向压暗 + 底部加深,
     避免原图中央的白色光源太亮抢走登录框的注意力 */
  background:
    radial-gradient(ellipse 70% 60% at 50% 45%, rgba(8,14,26,.18) 0%,
                    rgba(8,14,26,.42) 70%, rgba(8,14,26,.62) 100%),
    linear-gradient(180deg, rgba(10,16,30,.50) 0%, rgba(10,16,30,.34) 45%,
                    rgba(10,16,30,.66) 100%),
    url('/static/img/login-bg.jpg') center center / cover no-repeat,
    linear-gradient(135deg, #1b2334 0%, #2d3a55 55%, #3a4a6b 100%);
  background-color: #1b2334;
  display: grid;
  place-items: center;
}
.login-card {
  width: 380px;
  max-width: 92vw;
  /* ★ 半透明卡片 + 毛玻璃,让背景图透出来但文字依然清晰 */
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.55);
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
  overflow: hidden;
}
.login-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 22px 24px;
  background: linear-gradient(135deg, #2f6fed, #24509f);
  color: #fff;
}
.login-logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: rgba(255,255,255,.2);
  display: grid; place-items: center;
  font-size: 20px; font-weight: 700;
  flex: none;
}
.login-title { font-size: 16px; font-weight: 600; }
.login-sub { font-size: 12px; opacity: .82; margin-top: 2px; }
.login-body { padding: 22px 24px 24px; }
.login-body label.field { margin-bottom: 13px; }
.login-body input { height: 36px; }
.login-err {
  display: none;
  background: var(--danger-soft);
  color: #b91c1c;
  padding: 7px 11px;
  border-radius: 6px;
  font-size: var(--fs-sm);
  margin-bottom: 12px;
}
.login-err.show { display: block; }
.login-btn {
  width: 100%;
  justify-content: center;
  margin-top: 4px;
}
.login-foot {
  margin-top: 14px;
  text-align: center;
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.6;
}
/* 登录页的局域网排查说明 */
.login-help {
  margin-top: 10px;
  text-align: left;
  font-size: 11.5px;
  color: var(--text-2);
}
.login-help summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 500;
  text-align: center;
  padding: 4px 0;
  list-style: none;
}
.login-help summary::-webkit-details-marker { display: none; }
.login-help summary::before { content: "💡 "; }
.login-help ol {
  margin: 8px 0 0;
  padding-left: 20px;
  line-height: 1.9;
  background: #f7f9fc;
  border-radius: 6px;
  padding: 10px 10px 10px 28px;
}
.login-help b { color: var(--text-1); }
/* 登录模式下隐藏主界面 */
body.login-mode .sidebar,
body.login-mode .main { display: none !important; }

/* ---------- 侧边栏用户信息 ---------- */
.user-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 2px 9px;
}
.user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4d86f7, #2f6fed);
  color: #fff;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
  flex: none;
}
.user-info { flex: 1; min-width: 0; }
.user-name {
  color: #e8ecf3;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-role {
  color: #7d889e;
  font-size: 10.5px;
  margin-top: 1px;
}
.user-logout {
  background: transparent;
  border: none;
  color: #7d889e;
  cursor: pointer;
  font-size: 14px;
  padding: 4px 6px;
  border-radius: 4px;
  flex: none;
}
.user-logout:hover { background: rgba(255,255,255,.1); color: #e8ecf3; }

.sidebar-foot {
  padding: 9px 14px;
  border-top: 1px solid rgba(255,255,255,.07);
}
.db-path {
  color: #5d6879;
  font-size: 10px;
  word-break: break-all;
  line-height: 1.5;
}

/* ---------- 主区 ---------- */
.main {
  margin-left: var(--sidebar-w);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  flex: none;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}
.topbar-left { display: flex; align-items: baseline; gap: 10px; }
.topbar-left h1 { font-size: 16px; font-weight: 600; }
.page-sub { font-size: var(--fs-sm); color: var(--text-3); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.today { color: var(--text-3); font-size: var(--fs-sm); }

.quick-sale {
  background: var(--primary);
  color: #fff;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  transition: background .13s;
}
.quick-sale:hover { background: var(--primary-dark); }

.content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 28px;
}
.content::-webkit-scrollbar { width: 9px; height: 9px; }
.content::-webkit-scrollbar-thumb { background: #cfd6e2; border-radius: 5px; }
.content::-webkit-scrollbar-thumb:hover { background: #b6c0d1; }
.content::-webkit-scrollbar-track { background: transparent; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 15px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.card-title { font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 7px; }
.card-body { padding: 15px; }
.card-body.flush { padding: 0; }

/* ---------- KPI ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 15px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--primary);
}
.kpi.green::before  { background: var(--success); }
.kpi.red::before    { background: var(--danger); }
.kpi.orange::before { background: var(--warning); }
.kpi.cyan::before   { background: var(--info); }

.kpi-label { color: var(--text-3); font-size: var(--fs-sm); margin-bottom: 6px; }
.kpi-value {
  font-size: 22px; font-weight: 700; line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.kpi-value .unit { font-size: 12px; font-weight: 500; color: var(--text-3); margin-left: 3px; }
.kpi-foot { margin-top: 5px; font-size: 11px; color: var(--text-3); }
.kpi-foot .up   { color: var(--success); font-weight: 600; }
.kpi-foot .down { color: var(--danger);  font-weight: 600; }

/* ---------- 工具条 ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 11px 15px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.toolbar .spacer { flex: 1; }

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}
.search-box input { padding-left: 28px; width: 210px; }
.search-box::before {
  content: "🔍";
  position: absolute; left: 9px;
  font-size: 11px; opacity: .55; pointer-events: none;
}

/* ---------- 表单控件 ---------- */
input[type=text], input[type=number], input[type=date], input[type=search],
select, textarea {
  font-family: inherit;
  font-size: var(--fs);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 9px;
  height: 30px;
  outline: none;
  transition: border-color .13s, box-shadow .13s;
  user-select: text;
}
textarea { height: auto; padding: 7px 9px; resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2.5px var(--primary-soft);
}
input:disabled, input[readonly] { background: var(--surface-2); color: var(--text-2); }
input::placeholder { color: #aab2c1; }

select {
  padding-right: 24px;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M1 1l4 4 4-4' stroke='%235a6478' stroke-width='1.4' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 9px center;
  cursor: pointer;
}
input[type=number] { text-align: right; font-variant-numeric: tabular-nums; }

label.field { display: flex; flex-direction: column; gap: 4px; }
label.field > span { font-size: var(--fs-sm); color: var(--text-2); }
.field-req::after { content: " *"; color: var(--danger); }

/* ---------- 按钮 ---------- */
.btn {
  font-family: inherit;
  font-size: var(--fs);
  height: 30px;
  padding: 0 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all .13s;
  white-space: nowrap;
  font-weight: 500;
}
.btn:hover  { background: var(--surface-2); border-color: var(--text-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

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

.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.08); }

.btn-danger  { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover  { filter: brightness(1.08); }

.btn-ghost   { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: #eceff5; }

.btn-sm { height: 25px; padding: 0 9px; font-size: var(--fs-sm); }
.btn-lg { height: 38px; padding: 0 22px; font-size: 14px; font-weight: 600; }

.link {
  color: var(--primary);
  cursor: pointer;
  margin-right: 10px;
  font-size: var(--fs-sm);
  white-space: nowrap;
}
.link:hover { text-decoration: underline; }
.link.danger { color: var(--danger); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs);
  min-width: 640px;
}
table.tbl th {
  background: var(--surface-2);
  color: var(--text-2);
  font-weight: 600;
  text-align: left;
  padding: 8px 11px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: var(--fs-sm);
}
table.tbl td {
  padding: 7px 11px;
  border-bottom: 1px solid #f0f2f6;
  white-space: nowrap;
}
table.tbl tbody tr:hover { background: #f7f9fc; }
table.tbl tbody tr.sel { background: var(--primary-soft); }
table.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl .mid { text-align: center; }
table.tbl .muted { color: var(--text-3); }
table.tbl tfoot td {
  background: var(--surface-2);
  font-weight: 600;
  border-top: 2px solid var(--border-strong);
  border-bottom: none;
}
.table-empty { padding: 40px; text-align: center; color: var(--text-3); font-size: var(--fs); }

/* ---------- 标签 ---------- */
.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  line-height: 17px;
  white-space: nowrap;
}
.tag-green  { background: var(--success-soft); color: #14833c; }
.tag-orange { background: var(--warning-soft); color: #a35c05; }
.tag-red    { background: var(--danger-soft);  color: #b91c1c; }
.tag-blue   { background: var(--primary-soft); color: var(--primary-dark); }
.tag-gray   { background: #eef0f4; color: var(--text-2); }
.tag-cyan   { background: var(--info-soft);    color: #0e7490; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(18,26,42,.42);
  display: grid; place-items: center;
  z-index: 100;
  animation: fade .15s;
}
@keyframes fade { from { opacity: 0 } }
.modal {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 560px;
  max-width: 92vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  animation: pop .17s cubic-bezier(.2,.9,.3,1.2);
}
.modal.wide { width: 860px; }
.modal.xwide { width: 1060px; }
@keyframes pop { from { transform: scale(.94) translateY(-8px); opacity: 0 } }

.modal-head {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  display: flex; align-items: center; justify-content: space-between;
  flex: none;
}
.modal-x {
  border: none; background: transparent;
  font-size: 15px; color: var(--text-3); cursor: pointer;
  width: 24px; height: 24px; border-radius: 4px;
}
.modal-x:hover { background: #eef0f4; color: var(--text); }
.modal-body { padding: 18px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 11px 18px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
  background: var(--surface-2);
  flex: none;
}

/* 表单网格 */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 13px;
}
.form-grid .full { grid-column: 1 / -1; }
.form-grid .three { grid-column: span 1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.hint { font-size: 11px; color: var(--text-3); margin-top: 3px; line-height: 1.5; }

/* ---------- 确认框 ---------- */
.confirm-mask {
  position: fixed; inset: 0;
  background: rgba(18,26,42,.45);
  display: grid; place-items: center;
  z-index: 200;
}
.confirm-box {
  background: var(--surface);
  border-radius: 12px;
  padding: 22px;
  width: 380px;
  max-width: 90vw;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: pop .17s;
}
.confirm-icon { font-size: 34px; margin-bottom: 9px; }
.confirm-title { font-size: 15px; font-weight: 600; margin-bottom: 7px; }
.confirm-text { color: var(--text-2); font-size: var(--fs); line-height: 1.6; margin-bottom: 18px; }
.confirm-btns { display: flex; gap: 9px; justify-content: center; }

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed;
  top: 16px; left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: #1f2937;
  color: #fff;
  padding: 9px 17px;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  font-size: var(--fs);
  animation: toastIn .22s;
  max-width: 480px;
  display: flex; align-items: center; gap: 8px;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px) } }
.toast.success { background: #15803d; }
.toast.error   { background: #b91c1c; }
.toast.warn    { background: #b45309; }

/* ---------- 收银台 ---------- */
.pos {
  display: grid;
  grid-template-columns: 1fr 372px;
  gap: 14px;
  height: 100%;
  align-items: start;
}
@media (max-width: 1180px) { .pos { grid-template-columns: 1fr; } }

.pos-left  { display: flex; flex-direction: column; gap: 12px; }
.pos-right { position: sticky; top: 0; }

.prod-picker {
  position: relative;
}
.prod-picker .results {
  position: absolute;
  top: 34px; left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  max-height: 320px;
  overflow-y: auto;
  z-index: 30;
  display: none;
}
.prod-picker .results.show { display: block; }
.prod-picker .results div {
  padding: 8px 12px;
  cursor: pointer;
  display: flex; justify-content: space-between; gap: 10px;
  border-bottom: 1px solid #f2f4f8;
}
.prod-picker .results div:last-child { border-bottom: none; }
.prod-picker .results div:hover,
.prod-picker .results div.active { background: var(--primary-soft); }
.prod-picker .results .rname { font-weight: 500; }
.prod-picker .results .rsub  { color: var(--text-3); font-size: 11px; }
.prod-picker .results .rprice { color: var(--danger); font-weight: 600; }

.cart { max-height: 250px; overflow-y: auto; }
.cart-empty { padding: 32px; text-align: center; color: var(--text-3); }

.sum-row {
  display: flex; justify-content: space-between;
  padding: 5px 0;
  font-size: var(--fs);
}
.sum-row.total {
  border-top: 1px dashed var(--border-strong);
  margin-top: 7px; padding-top: 10px;
  font-size: 16px; font-weight: 700;
  color: var(--danger);
  font-variant-numeric: tabular-nums;
}
.sum-row .lbl { color: var(--text-2); }
.sum-row .val { font-variant-numeric: tabular-nums; font-weight: 500; }

.pay-label {
  font-size: var(--fs-sm);
  color: var(--text-2);
  margin-bottom: 6px;
}
.pay-methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pay-methods button {
  padding: 9px 0;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  transition: all .13s;
}
.pay-methods button:hover { border-color: var(--primary); }
.pay-methods button.on {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-dark);
  font-weight: 600;
}
/* 挂账需要客户:未选客户时按钮置灰并提示 */
.pay-methods button[data-pay="credit"].need-customer {
  border-style: dashed;
  color: var(--text-3);
}
.pay-hint {
  font-size: 11px;
  margin-top: 6px;
  min-height: 15px;
  line-height: 1.5;
}
.pay-hint.warn { color: var(--warning); }
.pay-hint.info { color: var(--info); }

/* 快速品类 */
.quick-cats { display: flex; gap: 7px; flex-wrap: wrap; }
.quick-cats button {
  padding: 5px 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 15px;
  cursor: pointer;
  font-family: inherit; font-size: var(--fs-sm);
  transition: all .13s;
}
.quick-cats button:hover,
.quick-cats button.on { background: var(--primary); border-color: var(--primary); color: #fff; }

/* 商品宫格 */
.prod-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 9px;
  max-height: 400px;
  overflow-y: auto;
  padding: 2px;
}
.prod-cell {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  cursor: pointer;
  background: var(--surface);
  transition: all .13s;
  position: relative;
}
.prod-cell:hover { border-color: var(--primary); box-shadow: 0 2px 10px rgba(47,111,237,.16); }
.prod-cell .pname {
  font-size: var(--fs); font-weight: 500; margin-bottom: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.prod-cell .pprice { color: var(--danger); font-weight: 700; font-size: 14px; }
.prod-cell .pstock { font-size: 10.5px; color: var(--text-3); margin-top: 2px; }
.prod-cell .pstock.low { color: var(--warning); font-weight: 600; }

/* ---------- 单据条目编辑 ---------- */
.items-table { width: 100%; border-collapse: collapse; }
.items-table th {
  background: var(--surface-2);
  padding: 7px 9px;
  font-size: var(--fs-sm);
  color: var(--text-2);
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.items-table td { padding: 5px 7px; border-bottom: 1px solid #f2f4f8; }
.items-table input, .items-table select { height: 28px; font-size: var(--fs-sm); }
.items-table .w-qty   { width: 74px; }
.items-table .w-price { width: 92px; }
.items-table .w-amt   { width: 96px; }
.items-table .w-del   { width: 34px; }
.items-table .line-total {
  font-weight: 600; text-align: right; font-variant-numeric: tabular-nums;
}
.items-table tr.invalid td { background: var(--danger-soft); }
.items-table .stock-tip { font-size: 10.5px; color: var(--text-3); margin-top: 1px; }
.items-table .stock-tip.warn { color: var(--warning); font-weight: 600; }
.items-table .stock-tip.bad  { color: var(--danger); font-weight: 600; }

/* ---------- 图表 ---------- */
.bar-chart {
  /* ★ align-items 必须是 stretch:
     若用 flex-end,子项 .bar-item 高度会塌成 auto,
     导致 .bar-wrap 没有确定高度,内部 .bar 的 height:X% 百分比失效,
     全部柱子回退到 min-height:2px —— 图表看起来完全空白。 */
  display: flex; align-items: stretch; gap: 4px;
  height: 168px; padding: 12px 4px 0;
}
.bar-item { flex: 1; display: flex; flex-direction: column; align-items: center;
            justify-content: flex-end; gap: 4px; min-width: 0; min-height: 0; }
/* ★ flex:1 1 auto + min-height:0 —— 让 .bar-wrap 拿到「除标签外」的确定高度,
   .bar 的百分比高度才有参照物 */
.bar-wrap { flex: 1 1 auto; width: 100%; display: flex; align-items: flex-end;
            min-height: 0; }
.bar {
  width: 100%;
  background: linear-gradient(180deg, #5b95f8, #2f6fed);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  transition: opacity .13s;
  position: relative;
}
.bar:hover { opacity: .78; }
.bar-tip {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  background: #1f2937; color: #fff;
  padding: 3px 7px; border-radius: 4px;
  font-size: 10.5px; white-space: nowrap;
  margin-bottom: 4px;
  display: none;
}
.bar:hover .bar-tip { display: block; }
.bar-label { font-size: 10px; color: var(--text-3); white-space: nowrap; }

.rank-list { display: flex; flex-direction: column; }
.rank-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid #f2f4f8;
}
.rank-row:last-child { border-bottom: none; }
.rank-no {
  width: 20px; height: 20px; border-radius: 5px;
  background: #eef0f4; color: var(--text-2);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; flex: none;
}
.rank-row:nth-child(1) .rank-no { background: #fef3c7; color: #b45309; }
.rank-row:nth-child(2) .rank-no { background: #e5e7eb; color: #4b5563; }
.rank-row:nth-child(3) .rank-no { background: #fde8d0; color: #9a5b13; }
.rank-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis;
             white-space: nowrap; }
.rank-val { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- 杂项 ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 1080px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.month-pick {
  display: flex; gap: 6px; align-items: center;
}
.chip {
  padding: 4px 11px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 15px;
  cursor: pointer;
  font-family: inherit; font-size: var(--fs-sm);
}
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }

.empty-box {
  padding: 56px 20px;
  text-align: center;
  color: var(--text-3);
}
.empty-box .e-ico { font-size: 40px; margin-bottom: 10px; opacity: .35; }
.empty-box .e-title { font-size: 14px; color: var(--text-2); margin-bottom: 5px; font-weight: 500; }

.divider { height: 1px; background: var(--border); margin: 14px 0; }

.kv-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px 20px; }
.kv { display: flex; justify-content: space-between; gap: 10px;
      padding: 5px 0; border-bottom: 1px dashed var(--border); }
.kv .k { color: var(--text-3); }
.kv .v { font-weight: 500; text-align: right; }

.mono { font-family: "Consolas", "Courier New", monospace; }

.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }
.text-muted   { color: var(--text-3); }
.text-right   { text-align: right; }
.mt { margin-top: 12px; }
.mb0 { margin-bottom: 0; }

.loading {
  padding: 40px; text-align: center; color: var(--text-3); font-size: var(--fs);
}
.loading::after {
  content: "";
  display: inline-block; width: 13px; height: 13px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: -2px; margin-left: 8px;
}
@keyframes spin { to { transform: rotate(360deg) } }

.scroll-x { overflow-x: auto; }
.nowrap { white-space: nowrap; }