﻿/* ========== 基础 ========== */
:root {
  --bg: #f2f5f9;
  --panel: #ffffff;
  --ink: #1c2a3a;
  --ink-2: #44546a;
  --muted: #7a8a9e;
  --line: #e4eaf2;
  --line-2: #eef2f7;
  --brand: #1d6fd6;
  --brand-dark: #1558ad;
  --brand-soft: #e8f1fe;
  --teal: #0e8f83;
  --green: #1c9b5e;
  --green-soft: #e6f6ee;
  --red: #d93a3a;
  --red-soft: #fdecec;
  --amber: #c47c11;
  --amber-soft: #fdf3e2;
  --sidebar: #101d30;
  --sidebar-2: #16253c;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 29, 48, .04), 0 6px 20px rgba(16, 29, 48, .05);
  --shadow-lg: 0 12px 40px rgba(16, 29, 48, .16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cfd8e3; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #b3c0d1; background-clip: content-box; border: 2px solid transparent; }

/* ========== 登录页 ========== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  background: #f4f8fe;
}
.login-shell { width: 100%; max-width: 456px; }
.login-logo { display: flex; align-items: center; justify-content: center; gap: 18px; margin-bottom: 34px; }
.login-logo .word {
  font-size: 44px; font-weight: 800; letter-spacing: 1px; line-height: 1;
  color: #1a6cf0; font-style: italic; font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
}
.login-logo .bar { width: 1px; height: 36px; background: #d5dde9; }
.login-logo .name { font-size: 31px; font-weight: 700; color: #14233c; letter-spacing: 2px; }
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px 44px 32px;
  box-shadow: 0 20px 60px rgba(23, 43, 77, .10), 0 2px 8px rgba(23, 43, 77, .04);
}
.login-card h2 { text-align: center; font-size: 26px; margin: 0 0 8px; color: #16233a; font-weight: 700; }
.login-card .sub { text-align: center; color: #7c8aa0; font-size: 14px; margin-bottom: 28px; }
.lg-field { position: relative; margin-bottom: 16px; }
.lg-field > svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: #93a1b5; pointer-events: none; }
.lg-field input {
  width: 100%; height: 52px; border: 1px solid #e2e8f1; border-radius: 9px;
  padding: 0 46px 0 46px; font-size: 15px; background: #fbfcfe; color: #1c2b45;
  font-family: inherit;
}
.lg-field input::placeholder { color: #a9b4c6; }
.lg-field input:focus { outline: none; border-color: #1a6cf0; background: #fff; box-shadow: 0 0 0 3px rgba(26, 108, 240, .10); }
.lg-eye {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; display: grid; place-items: center;
  border: 0; background: transparent; color: #93a1b5; cursor: pointer; border-radius: 8px;
}
.lg-eye:hover { background: #f0f4fa; color: #5c6b80; }
.lg-remember { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #41506a; margin: 4px 0 20px; user-select: none; cursor: pointer; }
.lg-remember input { width: 16px; height: 16px; accent-color: #1a6cf0; cursor: pointer; }
.login-submit {
  width: 100%; height: 52px; border: 0; border-radius: 9px; background: #1a6cf0;
  color: #fff; font-size: 17px; font-weight: 600; letter-spacing: 6px; cursor: pointer;
  font-family: inherit; transition: background .15s;
}
.login-submit:hover { background: #155fd8; }
.login-submit:disabled { opacity: .7; cursor: default; }
.login-error {
  display: none;
  background: var(--red-soft);
  color: #a32626;
  border: 1px solid #f7c9c9;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}
.login-error.show { display: block; }
.login-foot { text-align: center; margin-top: 22px; color: #9aa8bd; font-size: 12.5px; }
@media (max-width: 560px) {
  .login-page { padding: 32px 16px; align-items: flex-start; }
  .login-logo { margin-bottom: 26px; gap: 12px; }
  .login-logo .word { font-size: 32px; }
  .login-logo .bar { height: 26px; }
  .login-logo .name { font-size: 22px; letter-spacing: 1px; }
  .login-card { padding: 30px 22px 24px; }
}

/* ========== 主框架 ========== */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: #cfdaea;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 18px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.brand .mark {
  width: 36px; height: 36px; border-radius: 10px; flex: 0 0 auto;
  background: linear-gradient(135deg, #2d82ff, #0e8f83);
  display: grid; place-items: center; color: #fff;
}
.brand .mark.jcw { background: linear-gradient(135deg, #2f7bf6, #1a5fd0); font-weight: 800; font-size: 19px; font-style: italic; }
.brand .name { font-size: 15px; font-weight: 600; color: #fff; letter-spacing: .3px; line-height: 1.3; }
.brand .name.jcw-word { font-size: 18px; font-weight: 800; font-style: italic; letter-spacing: 1px; line-height: 1.15; }
.brand .sub { font-size: 11px; color: #7d92ae; letter-spacing: .3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 132px; }

.nav { padding: 14px 10px; flex: 1; overflow-y: auto; }
.nav-label { font-size: 11px; color: #5f7691; letter-spacing: 1px; padding: 12px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; margin-bottom: 2px;
  border-radius: 8px; color: #b9c8db; font-size: 13.5px;
  transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav a.active { background: linear-gradient(90deg, rgba(45, 130, 255, .28), rgba(45, 130, 255, .06)); color: #fff; box-shadow: inset 2px 0 0 #4d9bff; }
.nav a svg { opacity: .85; }
.nav a .dot { margin-left: auto; background: #d93a3a; color: #fff; font-size: 11px; border-radius: 9px; padding: 0 6px; line-height: 17px; }
.nav-cta {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: 6px 12px 12px; padding: 10px 14px; border-radius: 9px;
  background: linear-gradient(135deg, #2d82ff, #1d6fd6);
  color: #fff; font-weight: 600; font-size: 13.5px;
  box-shadow: 0 4px 14px rgba(29, 111, 214, .35);
  transition: filter .15s, box-shadow .15s;
}
.nav-cta:hover { filter: brightness(1.06); box-shadow: 0 6px 18px rgba(29, 111, 214, .45); color: #fff; text-decoration: none; }
.nav-cta.active { box-shadow: 0 4px 14px rgba(29, 111, 214, .45), inset 0 0 0 1px rgba(255, 255, 255, .4); }
.top-new {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 16px; border-radius: 9px; border: 0;
  background: linear-gradient(135deg, #2d82ff, #1d6fd6);
  color: #fff; font-size: 13.5px; font-weight: 600; cursor: pointer;
  box-shadow: 0 3px 12px rgba(29, 111, 214, .3);
}
.top-new:hover { filter: brightness(1.06); }
.sidebar-foot { padding: 14px 18px 18px; border-top: 1px solid rgba(255, 255, 255, .06); font-size: 11px; color: #62778f; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 64px;
  flex: 0 0 64px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .crumbs { font-size: 13px; color: var(--muted); }
.topbar .page-title { font-size: 16px; font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.icon-btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  cursor: pointer;
}
.icon-btn:hover { border-color: #c9d5e4; }
.user-chip { display: flex; align-items: center; gap: 9px; padding-left: 6px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #2d82ff, #0e8f83);
  color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 600;
}
.user-chip .who { line-height: 1.25; }
.user-chip .who b { display: block; font-size: 13px; font-weight: 600; }
.user-chip .who span { font-size: 11px; color: var(--muted); }

.view { padding: 22px 24px 48px; max-width: 1440px; width: 100%; margin: 0 auto; }

/* ========== 通用组件 ========== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 15px;
  border-radius: 8px; border: 1px solid transparent;
  background: var(--brand); color: #fff;
  font-size: 13.5px; font-family: inherit; cursor: pointer;
  transition: background .15s, box-shadow .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { background: var(--brand-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--ink-2); border-color: var(--line); }
.btn.ghost:hover { background: #f7f9fc; border-color: #c9d5e4; }
.btn.danger { background: #fff; color: var(--red); border-color: #f0c4c4; }
.btn.danger:hover { background: #fdf2f2; }
.btn.sm { height: 29px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn.link { background: none; border: none; color: var(--brand); padding: 0 4px; height: auto; }
.btn.link:hover { text-decoration: underline; background: none; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 18px; border-bottom: 1px solid var(--line-2);
}
.card-head h3 { font-size: 14px; }
.card-head .sub { font-size: 12px; color: var(--muted); }
.card-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 16px 18px; }
.card-body.flush { padding: 0; }

.row { display: flex; gap: 14px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-variant-numeric: tabular-nums; font-family: "JetBrains Mono", Consolas, monospace; font-size: 13px; }
.spacer { flex: 1; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; line-height: 1; white-space: nowrap;
  background: #f1f4f9; color: var(--ink-2); border: 1px solid transparent;
}
.badge.red { background: var(--red-soft); color: #b02a2a; }
.badge.green { background: var(--green-soft); color: #14764a; }
.badge.amber { background: var(--amber-soft); color: #97600a; }
.badge.blue { background: var(--brand-soft); color: #1558ad; }
.badge.teal { background: #e4f5f2; color: #0b6f66; }
.badge.gray { background: #f1f4f9; color: #6b7a8c; }
.badge.dot::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.tag { display: inline-block; padding: 1px 7px; border-radius: 6px; background: #f3f6fa; color: var(--ink-2); font-size: 12px; border: 1px solid var(--line-2); }

/* 表单 */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.field > label .req { color: var(--red); margin-left: 2px; }
.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--ink); font-size: 13.5px; font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 74px; padding: 9px 11px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: #9dc2f2; box-shadow: 0 0 0 3px rgba(29, 111, 214, .1);
}
.input::placeholder, .textarea::placeholder { color: #a3b0c2; }
.input.sm, .select.sm { height: 31px; font-size: 12.5px; }
.hint { font-size: 12px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

.search-box { position: relative; }
.search-box svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: #9aa9bb; }
.search-box .input { padding-left: 33px; }

/* 工具栏 */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .search-box { width: 260px; }
.toolbar .spacer { flex: 1; }

.segmented { display: inline-flex; background: #eaeff6; border-radius: 9px; padding: 3px; gap: 2px; }
.segmented button {
  border: none; background: none; font-family: inherit; font-size: 13px; color: var(--ink-2);
  padding: 5px 13px; border-radius: 7px; cursor: pointer; white-space: nowrap;
}
.segmented button.active { background: #fff; color: var(--brand); box-shadow: 0 1px 2px rgba(16, 29, 48, .12); font-weight: 500; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px;
  padding: 11px 14px; background: #f8fafc; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.tbl tbody tr:hover { background: #fafcff; }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl .num { font-variant-numeric: tabular-nums; }
table.tbl .name { font-weight: 500; }
table.tbl .sub { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }
table.tbl td.actions { text-align: right; white-space: nowrap; }
table.tbl td.actions .btn + .btn { margin-left: 6px; }
table.tbl tr.low td { background: #fffafa; }
table.tbl tr.low:hover td { background: #fff5f5; }

.stock-cell { display: flex; align-items: center; gap: 7px; }
.stock-num { font-weight: 600; font-variant-numeric: tabular-nums; }
.stock-num.low { color: var(--red); }
.stock-bar { width: 54px; height: 5px; border-radius: 3px; background: #eef2f7; overflow: hidden; }
.stock-bar i { display: block; height: 100%; background: var(--green); border-radius: 3px; }
.stock-bar i.low { background: var(--red); }
.stock-bar i.warn { background: var(--amber); }

/* 统计卡 */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
  cursor: default;
}
.stat.clickable { cursor: pointer; }
.stat.clickable:hover { border-color: #cfdbea; }
.stat .label { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 28px; font-weight: 600; letter-spacing: .5px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.stat .foot { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat .glyph {
  position: absolute; right: 14px; top: 14px; width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center; background: var(--brand-soft); color: var(--brand);
}
.stat.red .glyph { background: var(--red-soft); color: var(--red); }
.stat.red .value { color: var(--red); }
.stat.green .glyph { background: var(--green-soft); color: var(--green); }
.stat.amber .glyph { background: var(--amber-soft); color: var(--amber); }

.dash-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 16px; }
.dash-grid .span2 { grid-column: 1 / -1; }

.alert-list { display: flex; flex-direction: column; }
.alert-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 18px;
  border-bottom: 1px solid var(--line-2); font-size: 13.5px;
}
.alert-item:last-child { border-bottom: none; }
.alert-item:hover { background: #fafcff; }
.alert-item .nm { flex: 1; min-width: 0; }
.alert-item .nm b { font-weight: 500; }
.alert-item .qty { font-variant-numeric: tabular-nums; color: var(--red); font-weight: 600; }
.empty { padding: 34px 18px; text-align: center; color: var(--muted); font-size: 13px; }
.empty .ico { color: #c3cedb; margin-bottom: 8px; }

.bar-list { display: flex; flex-direction: column; gap: 12px; padding: 4px 2px; }
.bar-row .top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; gap: 10px; }
.bar-row .top .v { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-row .track { height: 7px; border-radius: 4px; background: #f0f4f9; overflow: hidden; }
.bar-row .track i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #2d82ff, #0e8f83); }

/* 借用选择页 */
.borrow-layout { display: grid; grid-template-columns: 1.25fr .95fr; gap: 16px; align-items: start; }
.pick-list { max-height: 560px; overflow-y: auto; }
.pick-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 16px;
  border-bottom: 1px solid var(--line-2); cursor: pointer;
}
.pick-item:hover { background: #f7fbff; }
.pick-item.disabled { opacity: .5; cursor: not-allowed; }
.pick-item .ico {
  width: 34px; height: 34px; border-radius: 9px; background: #eef4fd; color: var(--brand);
  display: grid; place-items: center; flex: 0 0 auto;
}
.pick-item .meta { flex: 1; min-width: 0; }
.pick-item .meta b { font-size: 13.5px; font-weight: 500; display: block; }
.pick-item .meta span { font-size: 12px; color: var(--muted); }
.pick-item .stk { text-align: right; font-size: 12px; color: var(--muted); white-space: nowrap; }
.pick-item .stk b { display: block; font-size: 14px; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.pick-item .stk b.zero { color: var(--red); }

.cart-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.cart-item:last-child { border-bottom: none; }
.cart-item .thumb { width: 40px; height: 40px; border-radius: 9px; }
.cart-item .meta { flex: 1; min-width: 0; }
.cart-item .meta b { font-weight: 500; font-size: 13px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-item .meta span { font-size: 11.5px; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qty-input { width: 56px; height: 32px; text-align: center; padding: 0 4px; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button {
  width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; color: var(--ink-2); font-size: 14px; line-height: 1;
}
.stepper button:hover { background: #f4f7fb; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(13, 24, 41, .45);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  z-index: 100; animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.modal {
  background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; max-height: calc(100vh - 48px);
  display: flex; flex-direction: column; animation: pop .18s ease;
}
.modal.wide { max-width: 760px; }
.modal.xwide { max-width: 940px; }
.modal-head {
  display: flex; align-items: center; gap: 10px; padding: 16px 20px;
  border-bottom: 1px solid var(--line-2);
}
.modal-head h3 { font-size: 15px; }
.modal-head .close {
  margin-left: auto; border: none; background: none; cursor: pointer; color: var(--muted);
  width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center;
}
.modal-head .close:hover { background: #f1f4f9; color: var(--ink); }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--line-2); background: #fbfcfe;
  border-radius: 0 0 14px 14px;
}

/* 借用单详情 */
.detail-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 18px; margin-bottom: 18px; }
.detail-meta .k { font-size: 12px; color: var(--muted); }
.detail-meta .v { font-size: 13.5px; margin-top: 2px; }
.detail-meta .full { grid-column: 1 / -1; }
.section-title { font-size: 13px; font-weight: 600; margin: 20px 0 8px; display: flex; align-items: center; gap: 8px; }
.section-title::before { content: ""; width: 3px; height: 13px; border-radius: 2px; background: var(--brand); }
.record-list { display: flex; flex-direction: column; gap: 8px; }
.record { display: flex; gap: 10px; font-size: 13px; padding: 8px 12px; background: #f8fafc; border-radius: 8px; }
.record .t { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.record.lost { background: #fdf4f4; }

.return-line { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.return-line .head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.return-line .head b { font-size: 13.5px; font-weight: 500; }
.return-line .head .rem { margin-left: auto; font-size: 12.5px; color: var(--muted); }
.return-line .inputs { display: grid; grid-template-columns: 100px 100px 1fr; gap: 10px; align-items: end; }
.return-line .lost-fields { display: grid; grid-template-columns: 1fr 120px 110px; gap: 10px; margin-top: 10px; }
.return-line .lost-fields.hide { display: none; }

/* 分页 */
.pager { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line-2); font-size: 12.5px; color: var(--muted); }
.pager .spacer { flex: 1; }
.pager button {
  height: 30px; min-width: 30px; padding: 0 9px; border-radius: 7px;
  border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 12.5px; color: var(--ink-2);
}
.pager button:hover:not(:disabled) { border-color: #c9d5e4; background: #f7f9fc; }
.pager button:disabled { opacity: .45; cursor: not-allowed; }

/* Toast */
#toast-root { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #16253c; color: #fff; padding: 9px 16px; border-radius: 9px;
  font-size: 13.5px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 8px;
  animation: pop .18s ease;
}
.toast.error { background: #b3261e; }
.toast.success svg { color: #5ee1a4; }

/* 空状态 / 加载 */
.loading { padding: 40px; text-align: center; color: var(--muted); font-size: 13px; }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid #dbe4ef; border-top-color: var(--brand);
  display: inline-block; vertical-align: -3px; margin-right: 8px;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 月度趋势 */
.trend { display: flex; align-items: flex-end; gap: 10px; padding: 6px 2px 0; }
.trend .tcol { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.trend .tv { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.trend .tbar { width: 100%; height: 110px; display: flex; align-items: flex-end; }
.trend .tbar i { display: block; width: 100%; max-width: 44px; margin: 0 auto; border-radius: 5px 5px 2px 2px; background: linear-gradient(180deg, #4d9bff, #0e8f83); }
.trend .tm { font-size: 11.5px; color: var(--muted); white-space: nowrap; }

table.tbl tfoot td { padding: 11px 14px; border-top: 1px solid var(--line); background: #fbfcfe; }

/* 打印 */
@media print {
  .sidebar, .topbar, .toolbar, .pager, .btn { display: none !important; }
  .view { padding: 0; }
  body { background: #fff; }
}

/* 响应式 */
@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  .borrow-layout { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .layout { display: block; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%); transition: transform .2s ease; height: 100%;
  }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .view { padding: 16px 14px 40px; }
  .topbar { padding: 0 14px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .detail-meta { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .return-line .inputs { grid-template-columns: 1fr 1fr; }
  .return-line .lost-fields { grid-template-columns: 1fr 1fr; }
  .toolbar .search-box { width: 100%; }
  .modal-mask { padding: 10px; }
}

/* ===== 物料图片 ===== */
.item-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.item-cell-main { min-width: 0; }
.thumb { display: block; flex: none; border-radius: 10px; object-fit: cover; background: #f3f6fa; border: 1px solid var(--line, #e5eaf1); }
.thumb.ph { display: grid; place-items: center; color: #9aa9bd; background: #f6f8fb; }
.img-edit { display: flex; gap: 16px; align-items: flex-start; }
.img-preview { width: 120px; height: 120px; flex: none; border-radius: 12px; border: 1px dashed #cdd8e6; background: #fafcff; display: grid; place-items: center; overflow: hidden; }
.img-preview img { width: 120px !important; height: 120px !important; }
.img-edit-side { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.img-edit-side .hint { max-width: 420px; }

.tbl td:first-child { max-width: 300px; }
.item-cell-main .name, .item-cell-main .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 210px; display: block; }

.btn.icon-only { padding-left: 10px; padding-right: 10px; }
.toolbar .search-box { min-width: 200px; }

/* ===== 移动端 / 窄屏适配 ===== */
.scrim {
  position: fixed; inset: 0; background: rgba(9, 20, 36, .45);
  opacity: 0; pointer-events: none; transition: opacity .18s ease; z-index: 40;
}
.scrim.show { opacity: 1; pointer-events: auto; }
@media (min-width: 901px) { .scrim { display: none; } }

@media (max-width: 760px) {
  html, body { -webkit-text-size-adjust: 100%; }
  .view { padding: 12px 12px 40px; }
  .topbar { padding: 0 10px; gap: 8px; height: 56px; }
  .topbar .page-title { font-size: 15px; }
  .topbar-right { gap: 8px; }
  .user-chip { padding-left: 0; }
  .user-chip .who { display: none; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
  .stat { padding: 12px 13px; border-radius: 12px; }
  .stat .value { font-size: 22px; }
  .stat .label { font-size: 12px; }
  .card { border-radius: 12px; }
  .card-head { padding: 12px 14px; }
  .card-body { padding: 12px 14px; }
  .toolbar { gap: 8px; margin-bottom: 12px; }
  .toolbar .search-box { width: 100% !important; min-width: 0; order: -1; }
  .toolbar .spacer { display: none; }
  .segmented { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .segmented::-webkit-scrollbar { display: none; }
  .segmented button { white-space: nowrap; flex: 0 0 auto; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  table.tbl { min-width: 660px; }
  table.tbl th, table.tbl td { padding: 9px 10px; }
  table.tbl th { font-size: 12px; }
  table.tbl td:first-child, table.tbl th:first-child {
    position: sticky; left: 0; z-index: 2; background: #fff;
    box-shadow: 1px 0 0 var(--line-2);
  }
  table.tbl th:first-child { background: #f8fafc; }
  table.tbl tr.low td:first-child { background: #fffafa; }
  table.tbl td.actions { white-space: nowrap; }
  .pager { flex-wrap: wrap; gap: 6px; padding: 10px 12px; }
  .pager .spacer { display: none; }
  .modal-mask { padding: 0; align-items: flex-end; }
  .modal {
    width: 100%; max-width: 100%; max-height: 92vh;
    border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(9, 20, 36, .22);
  }
  .modal.wide, .modal.xwide { max-width: 100%; }
  .modal-head { padding: 12px 14px; }
  .modal-body { padding: 14px; }
  .modal-foot { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
  .modal-foot .btn { flex: 1 1 auto; }
  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  .detail-meta { grid-template-columns: 1fr 1fr; }
  .return-line .head { flex-wrap: wrap; gap: 6px; }
  .return-line .inputs { grid-template-columns: 1fr 1fr; }
  .return-line .lost-fields { grid-template-columns: 1fr 1fr; }
  .borrow-layout { grid-template-columns: 1fr; }
  .img-edit { flex-direction: column; }
  .sidebar { width: 84%; max-width: 300px; z-index: 50; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-head .actions { width: 100%; display: flex; gap: 8px; flex-wrap: wrap; }
  .page-head .actions .btn { flex: 1 1 auto; }
  .toast-root, #toast-root { left: 12px; right: 12px; bottom: 16px; }
  .toast { width: 100%; }
  .btn, .icon-btn, .segmented button { min-height: 36px; }
  .input, .select { min-height: 38px; font-size: 15px; }
}

@media (max-width: 420px) {
  .view { padding: 10px 10px 36px; }
  .stat-grid { gap: 8px; }
  .stat .value { font-size: 20px; }
  .detail-meta { grid-template-columns: 1fr; }
  .return-line .inputs, .return-line .lost-fields { grid-template-columns: 1fr; }
  table.tbl { min-width: 600px; }
}

@media (max-width: 760px) {
  table.tbl { min-width: 720px; }
  table.tbl th, table.tbl td { white-space: nowrap; }
  table.tbl td.wrap { white-space: normal; min-width: 150px; max-width: 220px; }
  table.tbl td:first-child { max-width: 220px; }
  .item-cell-main .name, .item-cell-main .sub { max-width: 150px; }
  table.tbl td.actions { position: sticky; right: 0; background: #fff; z-index: 2; box-shadow: -1px 0 0 var(--line-2); }
  table.tbl th:last-child { position: sticky; right: 0; background: #f8fafc; z-index: 2; }
  table.tbl tr.low td.actions { background: #fffafa; }
  table.tbl th:first-child, table.tbl td:first-child { z-index: 3; }
}

@media (max-width: 760px) {
  table.tbl td.actions, table.tbl th:last-child { position: static; box-shadow: none; }
  table.tbl td.actions { background: transparent; }
  table.tbl tr.low td.actions { background: transparent; }
  .tbl-borrows td.actions .btn[data-act="borrow-export"] { display: none; }
  .tbl-borrows td.actions .btn { padding-left: 8px; padding-right: 8px; }
  .tbl-items th:nth-child(2), .tbl-items td:nth-child(2),
  .tbl-items th:nth-child(4), .tbl-items td:nth-child(4),
  .tbl-items th:nth-child(6), .tbl-items td:nth-child(6),
  .tbl-items th:nth-child(7), .tbl-items td:nth-child(7),
  .tbl-items th:nth-child(8), .tbl-items td:nth-child(8) { display: none; }
  .tbl-borrows th:nth-child(3), .tbl-borrows td:nth-child(3),
  .tbl-borrows th:nth-child(4), .tbl-borrows td:nth-child(4),
  .tbl-borrows th:nth-child(5), .tbl-borrows td:nth-child(5),
  .tbl-borrows th:nth-child(6), .tbl-borrows td:nth-child(6) { display: none; }
  .tbl-users th:nth-child(3), .tbl-users td:nth-child(3),
  .tbl-users th:nth-child(4), .tbl-users td:nth-child(4),
  .tbl-users th:nth-child(5), .tbl-users td:nth-child(5) { display: none; }
  .tbl-logs th:nth-child(5), .tbl-logs td:nth-child(5),
  .tbl-logs th:nth-child(6), .tbl-logs td:nth-child(6) { display: none; }
  .tbl-stats th:nth-child(4), .tbl-stats td:nth-child(4),
  .tbl-stats th:nth-child(6), .tbl-stats td:nth-child(6) { display: none; }
  .tbl-items, .tbl-borrows, .tbl-users, .tbl-logs, .tbl-stats { min-width: 0; width: 100%; }
}

@media (max-width: 760px) {
  .tbl-recent th:nth-child(2), .tbl-recent td:nth-child(2),
  .tbl-recent th:nth-child(3), .tbl-recent td:nth-child(3),
  .tbl-recent th:nth-child(4), .tbl-recent td:nth-child(4) { display: none; }
  .tbl-recent { min-width: 0; width: 100%; }
  .tbl-detail { min-width: 560px; }
  .tbl-items td:first-child, .tbl-borrows td:first-child, .tbl-users td:first-child, .tbl-logs td:first-child, .tbl-stats td:first-child { max-width: none; }
  .tbl-items .item-cell-main .name, .tbl-items .item-cell-main .sub { max-width: 160px; }
}

@media (max-width: 760px) {
  table.tbl tr.row-link { cursor: pointer; }
  .tbl-borrows th:last-child, .tbl-borrows td.actions { display: none; }
  .tbl-borrows, .tbl-items, .tbl-users, .tbl-logs, .tbl-stats { min-width: 0; width: 100%; }
  .tbl-items th:nth-child(3), .tbl-items td:nth-child(3) { display: none; }
  .tbl-users td.actions .btn { padding-left: 8px; padding-right: 8px; }
  .tbl-logs td:nth-child(4), .tbl-logs th:nth-child(4) { max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
}

@media (max-width: 760px) {
  table.tbl.tbl-items, table.tbl.tbl-borrows, table.tbl.tbl-users,
  table.tbl.tbl-logs, table.tbl.tbl-stats, table.tbl.tbl-recent { min-width: 0; width: 100%; }
  .tbl-borrows td:first-child { max-width: 150px; }
  .tbl-borrows td:nth-child(2) .name, .tbl-borrows td:nth-child(2) .sub { max-width: 96px; overflow: hidden; text-overflow: ellipsis; }
}

@media (max-width: 760px) {
  .tbl-borrows td:nth-child(8) .badge + .badge { display: none; }
  .tbl-borrows td:nth-child(8) { padding-left: 6px; padding-right: 6px; }
}

@media (max-width: 760px) {
  .detail-meta { grid-template-columns: 1fr 1fr; gap: 10px 12px; }
  .detail-meta .k { font-size: 11.5px; }
  .detail-meta .v { font-size: 13px; }
  .modal-foot .btn { flex: 0 1 auto; padding-left: 12px; padding-right: 12px; font-size: 13px; }
  .modal .detail-table, .tbl-detail { font-size: 13px; }
}
@media (max-width: 360px) {
  .detail-meta { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  table.tbl.tbl-detail { min-width: 0; width: 100%; }
  .tbl-detail th:nth-child(1), .tbl-detail td:nth-child(1) { width: 28px; padding-left: 4px; padding-right: 4px; }
  .tbl-detail th:nth-child(3), .tbl-detail td:nth-child(3),
  .tbl-detail th:nth-child(6), .tbl-detail td:nth-child(6),
  .tbl-detail th:nth-child(7), .tbl-detail td:nth-child(7),
  .tbl-detail th:nth-child(9), .tbl-detail td:nth-child(9) { display: none; }
  .tbl-detail td { padding: 8px 6px; font-size: 12.5px; }
  .tbl-detail th { padding: 8px 6px; }
}

@media (max-width: 760px) {
  .tbl-items td.actions .btn[data-act="item-del"],
  .tbl-items td.actions .btn[data-act="item-on"] { display: none; }
  .tbl-items td.actions .btn, .tbl-users td.actions .btn { padding-left: 8px; padding-right: 8px; font-size: 12.5px; }
  .tbl-items .item-cell-main .name, .tbl-items .item-cell-main .sub { max-width: 120px; }
  .tbl-items .thumb { width: 32px !important; height: 32px !important; }
}

@media (max-width: 760px) {
  .tbl-items .item-cell-main .name, .tbl-items .item-cell-main .sub { max-width: 92px; }
  .tbl-items td { padding-left: 8px; padding-right: 8px; }
  .tbl-items th { padding-left: 8px; padding-right: 8px; }
}

@media (max-width: 760px) {
  .tbl-users th:nth-child(6), .tbl-users td:nth-child(6) { display: none; }
  .tbl-users td.actions .btn[data-act="user-toggle"] { display: none; }
  .tbl-users td.actions .btn { padding: 4px 6px; font-size: 12px; }
  .tbl-users td:first-child { max-width: 120px; }
}

@media (max-width: 760px) {
  .tbl-logs th:nth-child(2), .tbl-logs td:nth-child(2) { display: none; }
  .tbl-logs td { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
  .tbl-logs td:nth-child(1) { max-width: 118px; font-variant-numeric: tabular-nums; }
  .tbl-logs td:nth-child(3) { max-width: 90px; }
}

@media (max-width: 760px) {
  #pick-list { max-height: 44vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .borrow-layout { gap: 12px; }
  .borrow-layout .card + .card { margin-top: 0; }
  .cart-item .thumb { width: 34px !important; height: 34px !important; }
  .cart-item .qty-input { width: 46px; }
}

@media (min-width: 901px) {
  #menu-btn { display: none; }
}

/* ===== PWA：安装引导条 / 独立窗口安全区 ===== */
.install-bar {
  position: fixed; left: 10px; right: 10px;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  z-index: 55; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 12px 14px;
  background: #fff; border: 1px solid #e6eefb; border-radius: 14px;
  box-shadow: 0 10px 30px rgba(15, 35, 70, .18);
}
.install-bar .txt { display: flex; flex-direction: column; gap: 2px; font-size: 13.5px; color: #16233b; }
.install-bar .txt span { font-size: 12px; color: #7c8aa3; }
@media (min-width: 761px) { .install-bar { display: none; } }

@media (display-mode: standalone) {
  .topbar { padding-top: env(safe-area-inset-top, 0px); height: calc(64px + env(safe-area-inset-top, 0px)); }
  .sidebar { padding-top: env(safe-area-inset-top, 0px); }
  .view { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
}

/* 骨架未就绪时不显示空壳 */
.layout[hidden] { display: none !important; }
#boot-loading { background: #f4f8fe; }
