:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --line: #e3e8ee;
  --text: #0f172a;
  --muted: #64748b;
  --brand: #0e7490;
  --brand-dark: #155e75;
  --brand-soft: #ecfeff;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --gray-soft: #f1f5f9;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px -12px rgba(15, 23, 42, .18);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 手机扫码页 ---------- */
.m-wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 0 40px;
  min-height: 100vh;
}

.m-head {
  background: linear-gradient(135deg, #0e7490 0%, #155e75 60%, #1e3a5f 100%);
  color: #fff;
  padding: 22px 20px 26px;
  border-radius: 0 0 22px 22px;
  position: relative;
  overflow: hidden;
}
.m-head::after {
  content: "";
  position: absolute;
  right: -50px; top: -60px;
  width: 190px; height: 190px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .07);
  /* 纯装饰，别挡住右上角「切换账号」的点击 */
  pointer-events: none;
}
.m-head .lab {
  font-size: 12px;
  letter-spacing: .08em;
  opacity: .8;
  text-transform: uppercase;
}
.m-head .code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 27px;
  font-weight: 700;
  letter-spacing: .02em;
  margin: 6px 0 4px;
}

.m-user {
  position: absolute;
  top: 16px; right: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-family: inherit;
  line-height: 1.4;
  color: #fff;
  z-index: 3;
  cursor: pointer;
  /* 用 <button> 而不是 <div>：微信/企业微信里按钮的点击最稳，不会被当成"文字"忽略 */
  -webkit-appearance: none; appearance: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
}
.m-user b { font-weight: 650; }
.m-user:hover { background: rgba(255, 255, 255, .26); }
.m-head .name {
  font-size: 17px;
  font-weight: 500;
  opacity: .95;
  line-height: 1.35;
}
.badges { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; position: relative; z-index: 1; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  backdrop-filter: blur(4px);
}
.badge.in { background: #d1fae5; color: #065f46; }
.badge.out { background: #fef3c7; color: #92400e; }
.badge.used { background: #e2e8f0; color: #334155; }
.badge.void { background: #fee2e2; color: #991b1b; }
.badge.expired { background: #fee2e2; color: #991b1b; }
.badge.warn { background: #ffedd5; color: #9a3412; }

.m-body { padding: 16px 14px 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
}
.card-h {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .04em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fbfcfd;
}
.card-b { padding: 14px 16px; }

/* 归还检查：正常 / 有异常 二选一 */
.seg { display: flex; gap: 8px; }
.seg-btn {
  flex: 1; padding: 9px 0; border: 1px solid var(--line); background: #fff;
  border-radius: 9px; font-size: 13.5px; color: #475569; font-family: inherit;
  cursor: pointer; appearance: none; touch-action: manipulation;
}
.seg-btn.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 650; }

/* 维护内容多选 */
.chk-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chk {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; font-size: 13.5px; color: #475569;
  cursor: pointer; user-select: none; touch-action: manipulation;
}
.chk input { margin: 0; accent-color: var(--brand); }
.chk.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 650; }

.hero-cert {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 16px;
  background: linear-gradient(135deg, #ecfeff, #f0f9ff);
  border: 1px solid #cffafe;
  border-radius: var(--radius);
  margin-bottom: 14px;
  text-decoration: none;
  color: inherit;
}
.hero-cert:hover { text-decoration: none; border-color: #67e8f9; }
.hero-cert .ic {
  width: 46px; height: 46px; flex: 0 0 46px;
  border-radius: 12px;
  background: #0e7490;
  color: #fff;
  display: grid; place-items: center;
  font-size: 20px;
  font-weight: 700;
}
.hero-cert .t { font-weight: 700; font-size: 15.5px; }
.hero-cert .s { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.hero-cert .arrow { margin-left: auto; color: var(--brand); font-size: 20px; }

.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.kv .row {
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
  min-width: 0;
}
.kv .row:nth-last-child(-n+2) { border-bottom: none; }
.kv .k { font-size: 11.5px; color: var(--muted); margin-bottom: 1px; }
.kv .v { font-size: 14px; font-weight: 600; word-break: break-all; }
.kv .full { grid-column: 1 / -1; }

.acts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform .06s ease, filter .15s ease;
  text-decoration: none;
}
.btn:active { transform: scale(.985); }
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px -8px rgba(14, 116, 144, .9); }
.btn-out { background: #f59e0b; color: #fff; box-shadow: 0 6px 16px -8px rgba(245, 158, 11, .9); }
.btn-in { background: var(--ok); color: #fff; box-shadow: 0 6px 16px -8px rgba(5, 150, 105, .9); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { background: var(--gray-soft); }
.btn-sm { padding: 8px 13px; font-size: 13.5px; border-radius: 9px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-wide { grid-column: 1 / -1; }

.tl { list-style: none; margin: 0; padding: 0; }
.tl li {
  position: relative;
  padding: 0 0 16px 22px;
  border-left: 2px solid var(--line);
  margin-left: 5px;
}
.tl li:last-child { border-left-color: transparent; padding-bottom: 0; }
.tl li::before {
  content: "";
  position: absolute;
  left: -6px; top: 5px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #94a3b8;
}
.tl li.out::before { border-color: #f59e0b; }
.tl li.in::before { border-color: var(--ok); }
.tl li.used::before, .tl li.void::before { border-color: #94a3b8; }
.tl .t1 { font-weight: 650; font-size: 14px; }
.tl .t2 { font-size: 12.5px; color: var(--muted); }
.tl .t3 { font-size: 12.5px; color: #475569; margin-top: 2px; }

.empty { text-align: center; color: var(--muted); font-size: 13.5px; padding: 22px 10px; }

/* ---------- 操作抽屉 ---------- */
.mask {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .45);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
  z-index: 40;
}
.mask.on { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 8px 18px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(105%);
  transition: transform .24s cubic-bezier(.22, .8, .3, 1);
  z-index: 50;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 -8px 40px rgba(15, 23, 42, .18);
}
.sheet.on { transform: translateY(0); }
.sheet .bar {
  width: 40px; height: 4px;
  background: #cbd5e1;
  border-radius: 99px;
  margin: 6px auto 14px;
}
.sheet h3 { margin: 0 0 4px; font-size: 18px; }
.sheet .sub { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12.5px; font-weight: 650; color: #475569; margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(14, 116, 144, .12);
}
.hint { font-size: 12px; color: var(--muted); margin-top: 5px; }

.toast {
  position: fixed;
  left: 50%; top: 22px;
  transform: translate(-50%, -24px);
  background: #0f172a;
  color: #fff;
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all .22s ease;
  z-index: 90;
  max-width: 86vw;
  text-align: center;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #b91c1c; }

/* ---------- 后台 ---------- */
.adm { display: flex; min-height: 100vh; }
.side {
  width: 208px;
  flex: 0 0 208px;
  background: #0f172a;
  color: #cbd5e1;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.side .brand {
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  padding: 4px 10px 16px;
  letter-spacing: .02em;
}
.side .brand small { display: block; font-weight: 400; color: #64748b; font-size: 11.5px; margin-top: 3px; }
.side .side-cap {
  color: #64748b;
  font-size: 11px;
  letter-spacing: .12em;
  padding: 10px 11px 4px;
  text-transform: uppercase;
}
.side a {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #e2e8f0;
  padding: 9px 11px;
  border-radius: 9px;
  font-size: 13.5px;
  margin-bottom: 2px;
}
.side a:hover { background: #1e293b; text-decoration: none; color: #fff; }

.side a.on { background: #0e7490; color: #fff; font-weight: 650; }
.side .sep { height: 1px; background: #1e293b; margin: 12px 8px; }
.side .side-logout {
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: inherit;
  color: rgba(255, 255, 255, .58);
  background: none;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.side .side-logout:hover { background: #7f1d1d; color: #fff; }

.main { flex: 1; min-width: 0; padding: 24px 26px 60px; }
.page-h { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-h h1 { font-size: 21px; margin: 0; letter-spacing: -.01em; }
.page-h .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }

.todo-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  margin-bottom: 14px;
  border: 1px solid #fcd34d;
  background: #fffbeb;
  border-radius: 12px;
  color: #92400e;
  font-size: 13.5px;
  text-decoration: none;
  transition: background .15s ease;
}
.todo-bar:hover { background: #fef3c7; border-color: #fbbf24; }
.todo-bar .todo-ico { font-size: 17px; line-height: 1; }
.todo-bar b { color: #b45309; font-size: 14.5px; }
.todo-bar .todo-go { margin-left: auto; font-weight: 600; color: #b45309; white-space: nowrap; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 10px; margin-bottom: 18px; }

/* 标签打印分组卡片 */
.group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(255px, 1fr));
  gap: 14px;
  margin-top: 4px;
}
.grp {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 16px 15px;
  background: #fff;
}
.grp.off { opacity: .55; }
.grp .g-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 7px; }
.grp .g-sub { font-size: 12.5px; color: var(--muted); margin-top: 5px; line-height: 1.6; }
.grp .g-num { font-size: 26px; font-weight: 800; margin: 12px 0 3px; letter-spacing: -.01em; }
.grp .g-num span { font-size: 12.5px; font-weight: 400; color: var(--muted); margin-left: 6px; }
.grp .btn { width: 100%; margin-top: 12px; }
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 15px;
}
.stat .n { font-size: 23px; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.stat .l { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.stat.a .n { color: var(--brand); }
.stat.b .n { color: var(--ok); }
.stat.c .n { color: #b45309; }
.stat.d .n { color: var(--danger); }
.stat.e .n { color: #64748b; }

.toolbar {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px 12px 0 0;
  padding: 12px 14px;
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  align-items: center;
  border-bottom: none;
}
.toolbar input[type=search], .toolbar select, .toolbar input[type=date] {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
.toolbar input[type=search] { min-width: 240px; flex: 1; max-width: 380px; }
.toolbar input[type=date] { width: 138px; font-size: 13px; padding: 8px 9px; }
.toolbar .tb-label { font-size: 12.5px; color: var(--muted); margin-left: 2px; }
.toolbar .tb-range {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  flex: 0 0 auto;
}
.toolbar .tb-count { font-size: 13px; color: var(--muted); margin-left: auto; white-space: nowrap; }

.tbl-wrap {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0 0 12px 12px;
  overflow: auto;
}
table.tbl { width: 100%; min-width: 860px; border-collapse: collapse; font-size: 13.5px; }
table.tbl th {
  text-align: left;
  padding: 10px 12px;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 650;
  font-size: 12.5px;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 2;
}
table.tbl td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
table.tbl tr:hover td { background: #fbfdfe; }
table.tbl .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 600; white-space: nowrap; }
table.tbl .nm { min-width: 168px; max-width: 300px; }
table.tbl .vendor {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #475569;
}
.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}
.pill.in { background: var(--ok-soft); color: #065f46; }
.pill.out { background: #fef3c7; color: #92400e; }
.pill.used { background: var(--gray-soft); color: #334155; }
.pill.void { background: var(--danger-soft); color: #991b1b; }
.pill.exp { background: var(--danger-soft); color: #991b1b; }
.pill.warn { background: #ffedd5; color: #9a3412; }
.pill.nocert { background: var(--gray-soft); color: #64748b; }
.pill.ok { background: var(--ok-soft); color: #065f46; }
.pill.muted { background: var(--gray-soft); color: #64748b; }

.pager { display: flex; gap: 7px; align-items: center; padding: 13px 4px; font-size: 13.5px; color: var(--muted); flex-wrap: wrap; }
.pager a, .pager span.cur {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
.pager span.cur { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 700; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 16px;
}
.panel h2 { font-size: 15px; margin: 0 0 4px; }
.panel .desc { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.panel .desc code { background: var(--gray-soft); padding: 1px 6px; border-radius: 5px; font-size: 12.5px; }

.note {
  background: var(--warn-soft);
  border: 1px solid #fde68a;
  color: #78350f;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.6;
}
.note.info { background: var(--brand-soft); border-color: #a5f3fc; color: #155e75; }
.note.bad { background: var(--danger-soft); border-color: #fecaca; color: #7f1d1d; }

.qr-box { display: inline-block; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.qr-box img { display: block; width: 148px; height: 148px; }

.label-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.label-cell {
  width: 132px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 7px 6px 5px;
  text-align: center;
  background: #fff;
}
.label-cell .c { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; font-size: 12.5px; }
.label-cell img { width: 86px; height: 86px; display: block; margin: 3px auto 0; }

@media (max-width: 860px) {
  .adm { flex-direction: column; }
  .side {
    width: 100%; flex: none; height: auto; position: static;
    display: flex; overflow-x: auto; gap: 4px; padding: 10px;
    align-items: center;
  }
  .side .brand { display: none; }
  .side .side-cap { display: none; }
  .side a { margin: 0; white-space: nowrap; padding: 7px 12px; font-size: 13px; }
  .side .sep { display: none; }

  .main { padding: 16px 13px 50px; }
  .toolbar input[type=search] { min-width: 0; }
  .stat .n { font-size: 20px; }
}
@media print {
  .side, .toolbar, .pager, .page-h, .btn { display: none !important; }
  .main { padding: 0; }
  body { background: #fff; }
}
