/* ==========================================================================
   知本堂进销存 · 视觉系统
   设计取向：企业级后台（B 端）。中性冷灰底、藏青主色、1px 描边、
   小圆角、无渐变光晕、高信息密度。所有数值对齐 tabular-nums。
   ========================================================================== */

:root {
  /* 主色：藏青蓝。传统、克制，比亮蓝更像内部业务系统 */
  --primary: #1b4b7d;
  --primary-hover: #163e67;
  --primary-soft: #eaf1f8;
  --primary-line: #c6d7e7;

  /* 语义色：降低饱和度，避免「糖果感」 */
  --success: #0f7b4f;
  --success-soft: #e9f5ef;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #b25e09;
  --warn-soft: #fdf3e4;
  --info: #3f5b78;
  --info-soft: #eef2f7;

  /* 中性色 */
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-soft: #f7f8fa;
  --text: #16191d;
  --text-soft: #3d4650;
  --muted: #6b7480;
  --border: #e2e6eb;
  --border-strong: #ccd3db;

  /* 圆角：后台系统用小圆角，圆角越大越像消费级 App */
  --radius: 8px;
  --radius-sm: 6px;
  --radius-xs: 4px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 6px 16px -6px rgba(16, 24, 40, 0.16);
  --shadow-lg: 0 18px 44px -14px rgba(16, 24, 40, 0.24);

  --sidebar: #101b2a;

  /* 兼容：页面内联样式与图表仍在用这些名字 */
  --brand: var(--primary);
  --brand-strong: var(--primary-hover);
  --brand-bright: #2f6fa8;
  --brand-soft: var(--primary-soft);
  --accent: #b98b4a;
  --primary-dark: var(--primary-hover);
  --primary-light: var(--primary-soft);
  --card: var(--surface);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { height: 100%; }
body {
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
svg { display: block; }
::selection { background: #d5e4f2; color: var(--primary-hover); }
.hidden { display: none !important; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #c8cfd7; border: 3px solid transparent; background-clip: content-box; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #aeb7c2; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes barGrow { from { transform: scaleY(0.4); opacity: 0.5; } to { transform: scaleY(1); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -40% 0; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes toastProgress { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes scanline { 0%, 100% { transform: translateY(-40px); opacity: 0.45; } 50% { transform: translateY(40px); opacity: 1; } }

/* ============================ 登录 ============================ */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}
.login-panel {
  width: min(940px, 100%);
  min-height: 420px;
  display: grid;
  grid-template-columns: 1.02fr 0.98fr;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: rise 0.3s ease both;
}
.login-brand {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 40px 38px 30px;
  background: linear-gradient(170deg, #16283c 0%, #0e1a29 100%);
  color: #dbe6f1;
}
.login-brand::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(circle at 20% 10%, #000, transparent 72%);
  pointer-events: none;
}
.login-brand > * { position: relative; z-index: 1; }
.login-brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  color: #cfdfef;
}
.login-brand-mark svg { width: 22px; height: 22px; }
.login-brand h1 { margin: 22px 0 6px; font-size: 22px; font-weight: 600; letter-spacing: 0.02em; color: #f4f8fc; }
.login-brand p { margin: 0; font-size: 12.5px; color: #8fa3b8; letter-spacing: 0.04em; }
.login-points { margin: 30px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.login-points li {
  padding: 5px 0 5px 12px;
  border-left: 2px solid rgba(78, 147, 201, 0.32);
  font-size: 12.5px;
  line-height: 1.6;
  color: #b6c6d6;
}
.login-brand-foot { margin-top: auto; padding-top: 28px; font-size: 11px; color: #63798f; letter-spacing: 0.06em; }

.login-form-side { display: flex; align-items: center; padding: 40px 44px; }
.login-form-box { width: 100%; }
.login-form-box h2 { margin: 0 0 4px; font-size: 18px; font-weight: 600; }
.login-form-sub { margin: 0 0 26px; color: var(--muted); font-size: 12px; }
.login-card .field, .login-form-box .field { margin-bottom: 14px; }
.login-form-box .btn-block { height: 38px; margin-top: 6px; }
.login-tip { margin: 16px 0 0; color: var(--muted); font-size: 11.5px; line-height: 1.6; }
.login-tip code { font-family: var(--font-mono); font-size: 11px; color: var(--text-soft); }

/* [hidden] 必须压过 .btn 的 display:inline-flex，否则「只在 APP 显示」的按钮会漏到浏览器里 */
[hidden] { display: none !important; }

/* ============================ 基础控件 ============================ */

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; margin-bottom: 6px; color: var(--text-soft); font-size: 12px; font-weight: 500; }
.field input, .field select, .field textarea, .input {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field textarea, textarea.input { height: auto; padding: 7px 10px; line-height: 1.55; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus,
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27, 75, 125, 0.12);
}
input::placeholder, textarea::placeholder { color: #9aa4b0; }
input:disabled, textarea:disabled, select:disabled { background: var(--surface-soft); color: var(--muted); }
select { cursor: pointer; }
select.input, .field select, .form-grid select, .toolbar select {
  appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7480' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
}
.btn-block { width: 100%; justify-content: center; }

/* ============================ 布局与侧栏 ============================ */

.layout { display: flex; min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  z-index: 30;
  width: 232px;
  flex: 0 0 232px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--sidebar);
  color: #9fb0c2;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.06);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 15px 16px; border-bottom: 1px solid rgba(255, 255, 255, 0.07); }
.brand-icon {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.06);
  color: #cddced;
}
.brand-icon svg { width: 18px; height: 18px; }
.brand-name { color: #eef3f8; font-size: 13.5px; font-weight: 600; letter-spacing: 0.01em; }
.brand-sub { margin-top: 2px; color: #64798f; font-size: 9.5px; font-weight: 500; letter-spacing: 0.14em; }
.nav { position: relative; flex: 1; overflow-y: auto; padding: 10px 8px 12px; }
.nav::-webkit-scrollbar { width: 4px; }
.nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border: 0; }
.nav-group { margin-bottom: 14px; }
.nav-group-title {
  padding: 6px 10px 5px;
  color: #5f7488;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
}
.nav-item {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 1px;
  padding: 7px 10px;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: #a3b2c3;
  font-size: 13px;
  font-weight: 400;
  text-align: left;
  transition: background 0.14s, color 0.14s;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #e9f0f7; }
.nav-item.active {
  background: rgba(47, 111, 168, 0.22);
  color: #ffffff;
  font-weight: 500;
  box-shadow: inset 2px 0 0 #4e93c9;
}
.nav-item .ico { width: 18px; height: 18px; flex: none; display: grid; place-items: center; opacity: 0.85; }
.nav-item .ico svg { width: 16px; height: 16px; }
.nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 12px 12px;
  padding: 8px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  color: #7b8ea1;
  font-size: 11px;
}
.dot { width: 6px; height: 6px; flex: none; border-radius: 50%; background: #4c9a6a; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar .menu-btn { display: none; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.today {
  padding-right: 14px;
  border-right: 1px solid var(--border);
  color: var(--muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.user-menu { position: relative; }
.user-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 6px 3px 3px;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  background: transparent;
  transition: background 0.14s, border-color 0.14s;
}
.user-btn:hover { background: var(--surface-soft); border-color: var(--border); }
.avatar {
  width: 26px;
  height: 26px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  color: #fff;
  background: var(--primary);
  font-size: 11.5px;
  font-weight: 600;
}
#user-name { color: var(--text-soft); font-size: 12.5px; font-weight: 500; }
.caret { display: grid; place-items: center; color: var(--muted); }
.caret svg { width: 11px; height: 11px; }
.dropdown {
  position: absolute;
  right: 0;
  top: 42px;
  z-index: 50;
  min-width: 132px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  animation: rise 0.14s ease both;
}
.dropdown button {
  display: block;
  width: 100%;
  padding: 7px 9px;
  border: 0;
  border-radius: var(--radius-xs);
  background: none;
  color: var(--text-soft);
  font-size: 12.5px;
  text-align: left;
  transition: background 0.14s, color 0.14s;
}
.dropdown button:hover { background: var(--surface-soft); color: var(--primary); }
.view { width: 100%; max-width: 1560px; margin: 0 auto; padding: 18px 22px 36px; flex: 1; }
.view > * { animation: rise 0.28s ease both; }

/* ============================ 卡片 / 按钮 ============================ */

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
}
.card-head h3 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13.5px; font-weight: 600; letter-spacing: 0; }
.card-head h3::before { display: none; }
.card-body { padding: 14px; }
.card-body.p0 { padding: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.14s, border-color 0.14s, color 0.14s;
}
.btn:hover { background: var(--surface-soft); border-color: #b6c0cb; color: var(--text); }
.btn:active { background: #eef1f5; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; flex: none; }
.btn-primary { border-color: var(--primary); background: var(--primary); color: #fff; }
.btn-primary:hover { border-color: var(--primary-hover); background: var(--primary-hover); color: #fff; }
.btn-primary:active { background: #12324f; }
.btn-danger { border-color: #f0c9c5; background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { border-color: #e3aca6; background: #fbe3e1; color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-soft); border-color: transparent; }
.btn-sm { height: 27px; padding: 0 9px; font-size: 12px; border-radius: var(--radius-xs); }
.btn-lg { height: 38px; padding: 0 18px; font-size: 13.5px; }
.icon-btn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--muted);
  transition: background 0.14s, color 0.14s, border-color 0.14s;
}
.icon-btn:hover { background: var(--surface-soft); border-color: var(--border); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar .spacer { flex: 1; }
.toolbar .input, .toolbar select { width: auto; min-width: 126px; height: 32px; }
.toolbar .input.search {
  min-width: 220px;
  padding-left: 31px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%236b7480' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m16.5 16.5 4 4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
}
.quick-actions { gap: 8px; }
.quick-actions .btn { font-weight: 500; }

/* ============================ 表格 ============================ */

.table-wrap { width: 100%; overflow-x: auto; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
table.data th {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: left;
  white-space: nowrap;
}
table.data td {
  padding: 9px 12px;
  border-bottom: 1px solid #eef1f4;
  color: var(--text-soft);
  white-space: nowrap;
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}
table.data tbody tr { transition: background 0.12s; }
table.data tbody tr:hover { background: var(--surface-soft); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tr.voided td { color: #98a1ac; text-decoration: line-through; }
table.data tr.voided td .badge { text-decoration: none; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .empty { padding: 36px 0; color: var(--muted); text-align: center; }
table.data tfoot td { border-top: 1px solid var(--border); background: var(--surface-soft); font-weight: 600; }
table.data.clickable tbody tr { cursor: pointer; }
table.data.clickable tbody tr:focus-visible { outline: 2px solid var(--primary-line); outline-offset: -2px; }
.table-actions { display: flex; gap: 2px; }
/* 操作列用文字链而不是三个描边按钮，降低每行的视觉噪音 */
.table-actions .btn {
  height: 24px;
  padding: 0 7px;
  border-color: transparent;
  background: transparent;
  color: var(--primary);
  font-size: 12px;
}
.table-actions .btn:hover { border-color: transparent; background: var(--primary-soft); color: var(--primary-hover); }
.table-actions .btn-danger { color: var(--danger); background: transparent; }
.table-actions .btn-danger:hover { border-color: transparent; background: var(--danger-soft); color: var(--danger); }
.table-foot { padding: 7px 14px 10px; color: var(--muted); font-size: 11px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  background: #f1f3f6;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.7;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.badge-green { border-color: #c9e6d7; background: var(--success-soft); color: var(--success); }
.badge-red { border-color: #f3d2ce; background: var(--danger-soft); color: var(--danger); }
.badge-warn { border-color: #f2ddbe; background: var(--warn-soft); color: var(--warn); }
.badge-blue { border-color: var(--primary-line); background: var(--primary-soft); color: var(--primary); }
.badge-green::before, .badge-red::before, .badge-warn::before, .badge-blue::before {
  content: "";
  width: 4px;
  height: 4px;
  flex: none;
  border-radius: 50%;
  background: currentColor;
}
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 9px 14px; border-top: 1px solid var(--border); }
.pager .info { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.pager .btns { display: flex; align-items: center; gap: 6px; }

/* ============================ 指标卡 / 图表 ============================ */

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat {
  position: relative;
  padding: 14px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.15s;
}
.stat::after { display: none; }
.stat:hover { border-color: var(--border-strong); }
.stat .label { color: var(--muted); font-size: 12px; font-weight: 500; letter-spacing: 0; }
.stat .value {
  margin: 7px 0 3px;
  color: var(--text);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.stat .sub { color: var(--muted); font-size: 11.5px; line-height: 1.5; font-variant-numeric: tabular-nums; }
.stat-icon {
  position: absolute;
  top: 13px;
  right: 13px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-xs);
  background: var(--stat-soft, var(--primary-soft));
  color: var(--stat-color, var(--primary));
}
.stat-icon svg { width: 15px; height: 15px; }
.stat.primary { --stat-color: #1b4b7d; --stat-soft: #eaf1f8; }
.stat.success { --stat-color: #0f7b4f; --stat-soft: #e9f5ef; }
.stat.warn { --stat-color: #b25e09; --stat-soft: #fdf3e4; }
.stat.danger { --stat-color: #b42318; --stat-soft: #fdecea; }
.stat .hint { position: absolute; right: 14px; top: 12px; font-size: 20px; opacity: 0.14; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 14px; }
.grid-2 > *, .grid-3 > * { min-width: 0; }
.mt16 { margin-top: 14px; }
.mb16 { margin-bottom: 14px; }

.chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 210px;
  padding: 12px 4px 0;
  background-image: repeating-linear-gradient(
    to top,
    transparent 0,
    transparent calc(25% - 1px),
    rgba(16, 24, 40, 0.06) calc(25% - 1px),
    rgba(16, 24, 40, 0.06) 25%
  );
}
.chart .col { flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; }
.chart .bars { width: 100%; height: calc(100% - 22px); display: flex; align-items: flex-end; justify-content: center; gap: 4px; }
.chart .bar {
  width: 14px;
  max-width: 34px;
  min-height: 2px;
  border-radius: 2px 2px 0 0;
  transform-origin: bottom;
  animation: barGrow 0.4s ease both;
  animation-delay: calc(var(--i, 0) * 22ms);
  transition: filter 0.15s;
}
.chart .bar:hover { filter: brightness(0.94); }
.chart .bar.sale { background: #2f6fa8; }
.chart .bar.purchase { background: #c19a5b; }
.chart .bar.zero { background: #e4e8ec; }
.chart .x { color: var(--muted); font-size: 10.5px; font-weight: 500; font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 12px; color: var(--muted); font-size: 11.5px; }
.legend i { width: 7px; height: 7px; display: inline-block; margin-right: 5px; border-radius: 1px; }

/* 走势区间切换 + 浮层 */
.head-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.seg-ctl { display: inline-flex; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius-xs); background: var(--surface-soft); }
.seg-ctl button {
  padding: 3px 9px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  transition: background 0.14s, color 0.14s;
}
.seg-ctl button:hover { color: var(--text); }
.seg-ctl button.on { background: var(--surface); color: var(--primary); font-weight: 600; box-shadow: var(--shadow-sm); }
.chart-box { min-height: 210px; }
.chart-wrap { position: relative; }
.chart .col { cursor: pointer; border-radius: 3px; transition: background 0.14s; }
.chart .col:hover { background: rgba(27, 75, 125, 0.045); }
.chart .col:focus-visible { background: rgba(27, 75, 125, 0.06); outline: 2px solid var(--primary-line); outline-offset: -2px; }
.chart.dense { gap: 3px; }
.chart.dense .bars { gap: 2px; }
.chart.dense .bar { width: 100%; max-width: 9px; border-radius: 1px 1px 0 0; }
.chart.dense .x { font-size: 9px; }
.chart.dense .bar.zero { background: #e4e8ec; }

.chart-tip {
  position: absolute;
  z-index: 6;
  min-width: 148px;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  font-size: 11.5px;
  pointer-events: none;
}
.chart-tip[hidden] { display: none; }
.tip-date { margin-bottom: 6px; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.tip-row { display: flex; align-items: center; gap: 6px; margin-top: 2px; color: var(--muted); }
.tip-row i { flex: none; width: 6px; height: 6px; border-radius: 1px; }
.tip-row span { flex: 1; }
.tip-row b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.tip-row.net { margin-top: 5px; padding-top: 5px; border-top: 1px solid var(--border); }
.tip-row.net.up b { color: var(--primary); }
.tip-row.net.down b { color: var(--success); }
.tip-hint { margin-top: 5px; color: var(--muted); font-size: 10.5px; }

/* 指标卡可点穿 */
a.stat { display: block; color: inherit; text-decoration: none; }
a.stat:focus-visible { outline: 2px solid var(--primary-line); outline-offset: 1px; }
a.stat .sub { transition: opacity 0.15s; }
a.stat:hover .sub { opacity: 0; }
.stat-go {
  position: absolute;
  right: 14px;
  bottom: 13px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--stat-color, var(--primary));
  font-size: 11.5px;
  font-weight: 500;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.16s, transform 0.16s;
}
.stat-go svg { width: 12px; height: 12px; }
a.stat:hover .stat-go, a.stat:focus-visible .stat-go { opacity: 1; transform: none; }

/* 分类占比环形图 */
.donut { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut-wrap { position: relative; width: 132px; height: 132px; flex: none; }
.donut-svg { display: block; width: 100%; height: 100%; }
.donut-svg .seg { stroke-width: 4.6; cursor: pointer; transition: opacity 0.15s, stroke-width 0.15s; }
.donut.has-hover .seg { opacity: 0.28; }
.donut.has-hover .seg.is-active { opacity: 1; stroke-width: 5.8; }
.donut-svg .seg:focus-visible, .donut-svg .seg:focus { outline: none; stroke-width: 5.8; }
.ring-center { position: absolute; inset: 0; z-index: 1; display: grid; place-content: center; text-align: center; pointer-events: none; }
.ring-center b { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.ring-center small { display: block; max-width: 96px; margin-top: 2px; color: var(--muted); font-size: 10px; line-height: 1.3; }
.share-list { flex: 1; min-width: 168px; display: grid; gap: 1px; font-size: 12px; }
.share-list .row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 7px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background 0.14s, opacity 0.14s;
}
.share-list .row:hover, .share-list .row.is-active { background: var(--surface-soft); }
.share-list .row:focus-visible { outline: 2px solid var(--primary-line); outline-offset: -2px; }
.share-list .row.off { opacity: 0.5; }
.share-list .row.off .name { text-decoration: line-through; }
.share-list i { width: 8px; height: 8px; border-radius: 1px; flex: none; cursor: pointer; transition: transform 0.14s; }
.share-list i:hover { transform: scale(1.3); }
.share-list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-soft); }
.share-list .val { color: var(--muted); font-variant-numeric: tabular-nums; }
.share-list .go { flex: none; width: 13px; height: 13px; color: #b6bfc9; opacity: 0; transition: opacity 0.14s, transform 0.14s; }
.share-list .go svg { width: 13px; height: 13px; }
.share-list .row:hover .go { opacity: 1; transform: translateX(1px); }
.share-hint { margin-top: 10px; color: var(--muted); font-size: 11px; }

/* 服务状态条 */
.sys-status {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.sys-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--warn); flex: none; }
.sys-dot.ok { background: var(--success); }
.sys-dot.bad { background: var(--danger); }
button.sys-status {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--border);
  background: transparent;
  font: inherit;
  font-size: 11.5px;
  text-align: left;
  cursor: pointer;
}
button.sys-status:hover { color: var(--text-soft); }
button.sys-status:focus-visible { outline: 2px solid var(--primary-line); outline-offset: 2px; }

/* 明细弹窗内的小结构 */
.day-sum { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 10px; margin-bottom: 14px; }
.day-sum > div { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-soft); }
.day-sum span { display: block; color: var(--muted); font-size: 11px; }
.day-sum b { display: block; margin: 3px 0 2px; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.day-sum small { color: var(--muted); font-size: 10.5px; }
.sec-title { display: flex; align-items: center; gap: 8px; margin: 14px 0 7px; font-size: 12.5px; font-weight: 600; }
.order-remark { margin-bottom: 12px; color: var(--muted); font-size: 12px; }

/* ============================ 表单与单据 ============================ */

.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-4 { grid-column: span 4; }
.form-grid label { display: block; margin-bottom: 5px; color: var(--text-soft); font-size: 12px; font-weight: 500; }
.form-grid input, .form-grid select, .form-grid textarea {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--surface);
  font-size: 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-grid textarea { height: auto; padding: 7px 10px; line-height: 1.55; resize: vertical; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border); background: var(--surface-soft); }
.form-section { padding: 0 0 16px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.form-section:last-of-type { padding-bottom: 0; margin-bottom: 0; border-bottom: 0; }
.form-section-title {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 12px;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0;
}
.form-section-title::before { content: ""; width: 2px; height: 11px; border-radius: 1px; background: var(--primary); }
.form-note {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.6;
}

.scan-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}
.scan-bar input { flex: 1 1 210px; min-width: 0; height: 30px; padding: 0 9px; border: 1px solid var(--border-strong); border-radius: var(--radius-xs); outline: none; background: var(--surface); }
.scan-bar input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(27, 75, 125, 0.1); }
.scan-bar .hint { color: var(--muted); font-size: 11.5px; }
.scan-bar .btn svg { width: 14px; height: 14px; }

.items-table input, .items-table select {
  width: 100%;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  outline: none;
  background: var(--surface);
  font-size: 12.5px;
}
.items-table input:focus, .items-table select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(27, 75, 125, 0.1); }
.items-table td { vertical-align: middle; }
.items-table .col-book { min-width: 260px; }
.items-table .col-qty { width: 110px; }
.items-table .col-price { width: 120px; }
.items-table .col-amount { width: 120px; text-align: right; font-variant-numeric: tabular-nums; }
.items-table .col-op { width: 70px; text-align: center; }
.stock-hint { margin-top: 2px; color: var(--muted); font-size: 10.5px; }
.total-bar { display: flex; align-items: baseline; justify-content: flex-end; gap: 10px; padding: 12px 14px; color: var(--muted); font-size: 12.5px; }
.total-bar strong { color: var(--text); font-size: 22px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.input-group { display: flex; align-items: center; gap: 6px; }
.input-group input { flex: 1 1 auto; min-width: 0; width: auto; }
.btn-icon { flex: 0 0 auto; width: 34px; height: 32px; padding: 0; display: grid; place-items: center; }
.btn-icon svg { width: 16px; height: 16px; }
.scan-retry { margin-top: 4px; }
.scan-retry[hidden] { display: none !important; }

/* ============================ 标签页 ============================ */

.tabs { display: flex; gap: 2px; max-width: 100%; margin-bottom: 14px; padding: 0; overflow-x: auto; border-bottom: 1px solid var(--border); background: none; }
.tab {
  padding: 8px 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.14s, border-color 0.14s;
}
.tab:hover { color: var(--text); }
.tab.active { border-bottom-color: var(--primary); color: var(--primary); font-weight: 600; background: none; box-shadow: none; }

/* ============================ 弹窗 / 提示 ============================ */

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px;
  overflow-y: auto;
  background: rgba(16, 24, 40, 0.42);
  animation: fadeIn 0.14s ease both;
}
.modal {
  width: 560px;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.18s ease both;
}
.modal.wide { width: 820px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
.modal-head h3 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: 0; }
.modal-body { padding: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 11px 16px; border-top: 1px solid var(--border); background: var(--surface-soft); }
.modal-close { width: 26px; height: 26px; border-radius: var(--radius-xs); background: transparent; }

.toast-root { position: fixed; top: 16px; left: 50%; z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; transform: translateX(-50%); pointer-events: none; }
.toast {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 210px;
  max-width: 82vw;
  overflow: hidden;
  padding: 9px 13px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  background: #1f2937;
  color: #f3f5f7;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.2s ease both;
}
.toast.success { background: #1f2937; box-shadow: inset 2px 0 0 #2f9e6b; }
.toast.error { background: #1f2937; box-shadow: inset 2px 0 0 #d14638; }
.toast.success .toast-ico { color: #57b98c; }
.toast.error .toast-ico { color: #e4786c; }
.toast-ico { display: grid; place-items: center; opacity: 0.9; }
.toast-ico svg { width: 15px; height: 15px; }
.toast-msg { font-size: 12.5px; font-weight: 500; }
.toast-progress { position: absolute; left: 0; bottom: 0; width: 100%; height: 2px; background: rgba(255, 255, 255, 0.35); transform-origin: left; animation: toastProgress 2.6s linear both; }

/* ============================ 空状态 / 骨架屏 ============================ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 44px 20px;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}
.empty-state .big { display: block; margin-bottom: 2px; font-size: 32px; opacity: 0.4; }
.empty-state .empty-text { max-width: 460px; line-height: 1.7; }
.empty-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 4px; }
.empty-icon { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-soft); color: #8e98a4; }
.empty-icon svg { width: 19px; height: 19px; }
.loading-ring { width: 22px; height: 22px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.7s linear infinite; }

.skeleton { padding: 14px; display: grid; gap: 11px; }
.skel-row { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr) minmax(0, 0.6fr); gap: 14px; align-items: center; }
.skel { display: block; height: 10px; border-radius: 3px; background: linear-gradient(90deg, #eef1f4 25%, #f7f9fa 50%, #eef1f4 75%); background-size: 220% 100%; animation: shimmer 1.2s ease-in-out infinite; }
.skel-w1 { width: 100%; }
.skel-w2 { width: 68%; }
.skel-w3 { width: 42%; }

/* ============================ 通用小件 ============================ */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface-soft);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.muted { color: var(--muted); }
.right { text-align: right; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 2px 2px 0; }
.section-title h3 { margin: 0; color: var(--text); font-size: 13px; font-weight: 600; letter-spacing: 0; }
.section-title span { color: var(--muted); font-size: 11px; }

/* ============================ APP 底部导航 / 更多页 ============================ */

.tabbar { display: none; }
.more-page { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.more-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 1px solid #1d344c;
  border-radius: var(--radius);
  background: #14263a;
  color: #e8eff6;
}
.more-profile .avatar { width: 42px; height: 42px; border-radius: var(--radius-sm); background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.14); font-size: 15px; }
.more-profile-info { min-width: 0; }
.more-profile-info strong { display: block; color: #f1f6fa; font-size: 15px; font-weight: 600; }
.more-profile-info span { display: block; margin-top: 2px; color: #8fa3b8; font-size: 11px; }
.profile-badge { margin-left: auto; padding: 2px 7px; border: 1px solid rgba(255, 255, 255, 0.16); border-radius: var(--radius-xs); color: #c3d3e2; font-size: 10.5px; }
.more-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.more-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  transition: border-color 0.14s, background 0.14s;
}
.more-card:hover { border-color: var(--border-strong); background: var(--surface-soft); }
.more-ico { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: var(--radius-xs); background: var(--primary-soft); color: var(--primary); }
.more-ico svg { width: 17px; height: 17px; }
.more-card-text { min-width: 0; }
.more-card-text strong { display: block; color: var(--text); font-size: 13px; font-weight: 500; }
.more-card-text small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.more-actions { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.more-action { width: 100%; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--border); background: var(--surface); color: var(--text-soft); text-align: left; font-size: 13px; transition: background 0.14s; }
.more-action:last-child { border-bottom: 0; }
.more-action:hover { background: var(--surface-soft); }
.more-action-ico { width: 20px; height: 20px; display: grid; place-items: center; color: var(--primary); }
.more-action-ico svg { width: 16px; height: 16px; }
.more-action .more-arrow { width: 14px; height: 14px; margin-left: auto; color: #b6bfc9; }
.more-action .more-arrow svg { width: 14px; height: 14px; }
.more-action.danger, .more-action.danger .more-action-ico { color: var(--danger); }
.more-tip { margin: 0 0 6px; color: var(--muted); font-size: 11px; text-align: center; }

/* ============================ 库存盘点 ============================ */

.tk-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tk-title h3 { margin: 0; }
.tk-meta { margin-top: 6px; font-size: 12px; line-height: 1.7; }
.tk-summary { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 14px; }
.tk-summary .chip b { font-variant-numeric: tabular-nums; }
.tk-progress { width: 88px; height: 4px; margin-bottom: 5px; border-radius: 2px; background: #eceff3; overflow: hidden; }
.tk-progress > span { display: block; height: 100%; border-radius: 2px; background: var(--primary); }
.tk-stale { font-size: 11px; color: var(--warn); font-weight: 500; }
.tk-filter { border-bottom: 1px solid var(--border); }
.qty-input {
  width: 88px;
  margin-left: auto;
  padding: 4px 7px;
  border-radius: var(--radius-xs);
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
table.data td .qty-input { display: block; }
.diff-up { color: var(--success); font-weight: 600; font-variant-numeric: tabular-nums; }
.diff-down { color: var(--danger); font-weight: 600; font-variant-numeric: tabular-nums; }
table.data td [data-diff] { white-space: nowrap; }
.tk-confirm { display: grid; gap: 0; }
.tk-confirm-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.tk-confirm-row:last-child { border-bottom: 0; }
.tk-confirm-row > span { color: var(--muted); }
.tk-confirm-row > b { font-variant-numeric: tabular-nums; }

/* ============================ 经营分析 ============================ */

.rank-list { display: grid; gap: 9px; }
.rank-row { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 12.5px; }
.rank-label { color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-bar { height: 6px; border-radius: 2px; background: #eef1f4; overflow: hidden; }
.rank-bar > span { display: block; height: 100%; border-radius: 2px; background: #2f6fa8; }
.rank-bar.alt > span { background: #c19a5b; }
.rank-val { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.rank-val i { display: block; color: var(--muted); font-style: normal; font-size: 11px; font-weight: 400; }
.level-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.level-card { padding: 11px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-soft); }
.level-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.level-head b { font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.level-sub { margin-bottom: 7px; color: var(--muted); font-size: 11.5px; }
.level-track { height: 5px; border-radius: 2px; background: #e7ebef; overflow: hidden; }
.level-track > span { display: block; height: 100%; border-radius: 2px; background: var(--primary); }

/* ============================ 扫码录入 ============================ */

.scan-wrap { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.scan-stage { position: relative; aspect-ratio: 4 / 3; overflow: hidden; border-radius: var(--radius-sm); background: #0f151c; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06); }
.scan-stage video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-guide { position: absolute; inset: 14% 8%; border-radius: var(--radius-xs); pointer-events: none; }
.scan-guide i, .scan-guide b { position: absolute; inset: 0; border-radius: var(--radius-xs); }
.scan-guide i {
  background:
    linear-gradient(#e8eff6, #e8eff6) left top / 20px 2px no-repeat,
    linear-gradient(#e8eff6, #e8eff6) left top / 2px 20px no-repeat,
    linear-gradient(#e8eff6, #e8eff6) right top / 20px 2px no-repeat,
    linear-gradient(#e8eff6, #e8eff6) right top / 2px 20px no-repeat,
    linear-gradient(#e8eff6, #e8eff6) left bottom / 20px 2px no-repeat,
    linear-gradient(#e8eff6, #e8eff6) left bottom / 2px 20px no-repeat,
    linear-gradient(#e8eff6, #e8eff6) right bottom / 20px 2px no-repeat,
    linear-gradient(#e8eff6, #e8eff6) right bottom / 2px 20px no-repeat;
  transition: opacity 0.15s;
}
.scan-guide b { top: 50%; bottom: auto; height: 2px; background: linear-gradient(90deg, transparent, rgba(78, 147, 201, 0.95), transparent); animation: scanline 2.2s ease-in-out infinite; }
.scan-guide.hit i { background-image:
    linear-gradient(#4c9a6a, #4c9a6a), linear-gradient(#4c9a6a, #4c9a6a), linear-gradient(#4c9a6a, #4c9a6a), linear-gradient(#4c9a6a, #4c9a6a),
    linear-gradient(#4c9a6a, #4c9a6a), linear-gradient(#4c9a6a, #4c9a6a), linear-gradient(#4c9a6a, #4c9a6a), linear-gradient(#4c9a6a, #4c9a6a);
  background-position: left top, left top, right top, right top, left bottom, left bottom, right bottom, right bottom;
  background-size: 20px 2px, 2px 20px, 20px 2px, 2px 20px, 20px 2px, 2px 20px, 20px 2px, 2px 20px;
  background-repeat: no-repeat;
}
.scan-guide.hit b { background: #4c9a6a; animation: none; }
.scan-cover {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 7px;
  padding: 20px;
  text-align: center;
  background: #131c26;
  color: #dbe4ee;
}
.scan-cover-ico { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid rgba(255, 255, 255, 0.12); border-radius: var(--radius-sm); background: rgba(255, 255, 255, 0.06); color: #b9c9d9; }
.scan-cover-ico svg { width: 20px; height: 20px; }
.scan-cover strong { font-size: 13px; font-weight: 600; }
.scan-cover small { max-width: 300px; color: #8b9daf; font-size: 11.5px; line-height: 1.6; }
.scan-side { display: grid; gap: 10px; align-content: start; }
.scan-hint { margin: 0; color: var(--text-soft); font-size: 12px; line-height: 1.6; }
.scan-cont { display: flex; align-items: center; gap: 7px; color: var(--text-soft); font-size: 12px; cursor: pointer; }
.scan-cont input { width: 14px; height: 14px; accent-color: var(--primary); }
.scan-side .btn svg { width: 14px; height: 14px; }

/* ========================= 登录页：登录 / 注册切换 ========================= */

.login-tabs {
  display: flex;
  gap: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.login-tab {
  position: relative;
  padding: 0 1px 9px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.14s;
}
.login-tab:hover { color: var(--text); }
.login-tab.active { color: var(--primary); font-weight: 600; }
.login-tab.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--primary);
}
.login-form-box h2 { font-size: 17px; }
.login-form-box .form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.login-form-box .login-tip { margin-top: 12px; }

/* 注册表单比登录高，屏幕矮的时候别被垂直居中裁掉顶部 */
@media (max-height: 760px) {
  .login-wrap { place-items: start center; }
}

/* ========================= 账号与权限 ========================= */

.role-chip {
  padding: 0 5px;
  border: 1px solid var(--primary-line);
  border-radius: var(--radius-xs);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.6;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.dropdown-head {
  display: grid;
  gap: 2px;
  padding: 7px 9px 9px;
  margin-bottom: 2px;
  border-bottom: 1px solid var(--border);
}
.dropdown-head strong { color: var(--text); font-size: 12.5px; font-weight: 600; }
.dropdown-head span { color: var(--muted); font-size: 11px; }

.user-stats { display: flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.user-stat { flex: 1 1 96px; padding: 10px 14px; border-right: 1px solid var(--border); }
.user-stat:last-child { border-right: 0; }
.user-stat span { display: block; color: var(--muted); font-size: 11.5px; }
.user-stat b { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.user-stat.pending b { color: var(--warn); }

.pending-box {
  border: 1px solid #f2ddbe;
  border-radius: var(--radius);
  background: var(--warn-soft);
  padding: 10px 14px;
  margin-bottom: 14px;
}
.pending-box h4 { margin: 0 0 8px; font-size: 12.5px; font-weight: 600; color: var(--warn); }
.pending-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 7px 0;
  border-top: 1px solid rgba(178, 94, 9, 0.16);
  font-size: 12.5px;
}
.pending-row:first-of-type { border-top: 0; }
.pending-row .who { font-weight: 500; color: var(--text); }
.pending-row .meta { color: var(--muted); font-size: 11.5px; }
.pending-row .sp { margin-left: auto; display: flex; gap: 6px; }

.perm-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.perm-table th, .perm-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.perm-table th { color: var(--muted); font-weight: 500; font-size: 11.5px; }
.perm-table td.c, .perm-table th.c { text-align: center; width: 76px; }
.perm-table .yes { color: var(--success); font-weight: 600; }
.perm-table .no { color: #c2c9d2; }

.role-pick { display: grid; gap: 8px; }
.role-pick label {
  display: flex;
  gap: 9px;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.14s, background 0.14s;
}
.role-pick label:hover { border-color: var(--primary-line); background: var(--surface-soft); }
/* 单选框别继承 .form-grid input 的 100% 宽高，否则会被拉成一个大圆圈 */
.role-pick input[type="radio"] {
  width: 14px;
  height: 14px;
  min-width: 14px;
  flex: none;
  margin: 2px 0 0;
  padding: 0;
  accent-color: var(--primary);
  cursor: pointer;
}
.role-pick label > div { flex: 1; min-width: 0; }
.role-pick b { display: block; font-size: 12.5px; font-weight: 600; }
.role-pick small { display: block; margin-top: 2px; color: var(--muted); font-size: 11.5px; line-height: 1.55; }
.role-pick input:checked + div b { color: var(--primary); }

.deny-state {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 56px 20px;
  text-align: center;
}
.deny-state strong { font-size: 14px; font-weight: 600; }
.deny-state p { margin: 0; max-width: 420px; color: var(--muted); font-size: 12.5px; line-height: 1.7; }
.scan-manual { display: flex; gap: 6px; }
.scan-manual input { flex: 1 1 auto; min-width: 0; height: 32px; padding: 0 9px; border: 1px solid var(--border-strong); border-radius: var(--radius-xs); background: var(--surface); outline: none; }
.scan-manual input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(27, 75, 125, 0.1); }
.scan-log { display: grid; gap: 5px; }
.scan-log-row { padding: 6px 9px; border: 1px solid #cfe6da; border-radius: var(--radius-xs); font-size: 11.5px; line-height: 1.5; background: var(--success-soft); color: var(--success); }
.scan-log-row.bad { border-color: #f0cfc9; background: var(--danger-soft); color: var(--danger); }
.scan-note { margin: 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-soft); color: var(--muted); font-size: 11.5px; line-height: 1.6; }

/* ============================ 响应式 ============================ */

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid .span-4 { grid-column: span 2; }
}

@media (max-width: 860px) {
  .sidebar { display: none; }
  .topbar { display: none; }
  .view { padding: 12px 12px calc(80px + env(safe-area-inset-bottom)); }
  .stat-grid { gap: 10px; margin-bottom: 12px; }
  .stat { padding: 12px; }
  .stat .value { font-size: 20px; }
  .stat-icon { top: 11px; right: 11px; width: 26px; height: 26px; }
  .card-head { padding: 10px 12px; }
  .card-body { padding: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2, .form-grid .span-4 { grid-column: span 1; }
  .grid-2, .grid-3 { gap: 12px; }
  .chart { height: 180px; gap: 6px; }
  .login-panel { grid-template-columns: 1fr; min-height: 0; }
  .login-brand { display: none; }
  .login-form-side { padding: 28px 22px; }

  .tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 80;
    display: flex;
    height: calc(58px + env(safe-area-inset-bottom));
    padding: 2px 6px env(safe-area-inset-bottom);
    border-top: 1px solid var(--border);
    background: var(--surface);
  }
  .tab-item {
    position: relative;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 3px 0;
    border: 0;
    background: none;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 500;
    line-height: 1.2;
  }
  .tab-item svg { width: 20px; height: 20px; }
  .tab-item.active { color: var(--primary); font-weight: 600; }
  .tab-item.active::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 50%;
    width: 34px;
    height: 26px;
    border-radius: var(--radius-xs);
    background: var(--primary-soft);
    transform: translateX(-50%);
  }
  .tab-item svg, .tab-item span { position: relative; z-index: 1; }
  .tab-item:active svg { transform: scale(0.92); }
}

@media (max-width: 600px) {
  .topbar-right { gap: 8px; }
  .user-btn { padding: 2px; }
  #user-name, .user-btn .caret { display: none; }
  .view { padding-left: 10px; padding-right: 10px; }
  .chart { height: 168px; }
  .chart .bar { width: 11px; }
  table.data th, table.data td { padding: 8px 9px; }
  /* 操作列文字链在窄屏收一档，给主数据列腾宽度 */
  .table-actions { gap: 0; }
  .table-actions .btn { height: 22px; padding: 0 5px; font-size: 11.5px; }
  .bk-name { max-width: 150px; white-space: normal; }
  /* 图书列表在手机上收起操作列，改为点整行进编辑 */
  .books-table th:last-child, .books-table td:last-child { display: none; }
  .books-table tbody tr { cursor: pointer; }
  .toolbar .input.search { min-width: 100%; }
  .card-head h3 { font-size: 13px; }
  .modal-mask { padding: 3vh 10px; }
  .modal-head { padding: 11px 13px; }
  .modal-body { padding: 13px; }
  .modal-foot { padding: 10px 13px; }
}

@media (max-width: 560px) {
  .donut { gap: 12px; }
  .donut-wrap { width: 116px; height: 116px; }
  .share-list { flex: 1 1 100%; min-width: 0; }
  .share-list .row { padding: 5px 7px; }
  .share-list .go { display: none; }
  .ring-center b { font-size: 13px; }
  .ring-center small { max-width: 82px; font-size: 9.5px; }
  .head-tools { gap: 8px; }
  .seg-ctl button { padding: 3px 8px; font-size: 11px; }
  .chart.dense { gap: 2px; }
  .chart.dense .bar { width: 100%; max-width: 4px; }
}

@media (max-width: 520px) {
  .stat { padding: 11px; }
  .stat .value { font-size: 19px; }
  .stat .sub { font-size: 10.5px; }
  .stat-icon { width: 24px; height: 24px; }
  .stat-icon svg { width: 14px; height: 14px; }
  .col-hide-xs { display: none !important; }
  .more-grid { gap: 8px; }
  .more-card { padding: 11px; }
  .more-ico { width: 30px; height: 30px; }
}

@media (max-width: 360px) {
  .more-grid { grid-template-columns: 1fr; }
  .tab-item { font-size: 10px; }
}

/* 盘点页紧凑表头 */
@media (max-width: 860px) {
  .tk-summary { padding: 0 12px 12px; }
  .tk-progress { width: 66px; }
  .qty-input { width: 72px; }
  .col-hide-sm { display: none !important; }
  .tk-sep { display: none; }
  .tk-filter .toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
  .tk-filter .toolbar .input, .tk-filter .toolbar select { width: 100%; min-width: 0; }
  .tk-filter .toolbar .input.search { grid-column: 1 / -1; min-width: 0; }
  .tk-filter .toolbar .btn, .tk-filter .toolbar .chip { grid-column: span 1; justify-content: center; }
  .tk-head { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; align-items: center; }
  .tk-head .toolbar { display: contents; }
  .tk-head #tk-status, .tk-head #tk-from, .tk-head #tk-to { width: 100%; min-width: 0; font-size: 12px; }
  .tk-head .input.search { grid-column: 1 / -1; width: 100%; min-width: 0; }
  .tk-head .btn { width: 100%; justify-content: center; }
  table.data.tk-table th, table.data.tk-table td { padding: 8px 8px; font-size: 12px; }
  .rank-row { grid-template-columns: 72px minmax(0, 1fr) auto; gap: 8px; font-size: 12px; }
  .level-grid { grid-template-columns: 1fr; }
  .scan-wrap { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .scan-stage { aspect-ratio: 3 / 2; }
  .modal.wide { width: 100%; }
}

@media (max-width: 560px) {
  .login-form-box .form-row-2 { grid-template-columns: 1fr; }
  .login-tabs { gap: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
