:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --line: #e4e8f0;
  --text: #1f2733;
  --muted: #6b7688;
  --brand: #2f5bea;
  --brand-dark: #1f43c0;
  --green: #1a9e5f;
  --green-bg: #e7f6ee;
  --orange: #d97706;
  --orange-bg: #fdf1df;
  --red: #d64545;
  --red-bg: #fdeaea;
  --blue: #2f6fea;
  --blue-bg: #e8f0fe;
  --indigo: #6d4fd8;
  --indigo-bg: #efeafe;
  --gray-bg: #eef1f6;
  --shadow: 0 1px 3px rgba(20, 40, 80, .08), 0 8px 24px rgba(20, 40, 80, .06);
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* ---------- 顶栏 ---------- */
#topbar {
  background: linear-gradient(135deg, #2746c8, #3b62ea);
  color: #fff; box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 1100px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.brand { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.brand-ico { font-size: 20px; }
.role-badge {
  font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px;
  background: rgba(255,255,255,.2); border: 1px solid rgba(255,255,255,.35);
}
.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-chip { font-size: 13px; opacity: .95; margin-right: 4px; }
.btn-ghost { background: transparent; border: 1px solid rgba(255,255,255,.5); color: #fff; }
.btn-ghost:hover { background: rgba(255,255,255,.14); }

/* ---------- 标签栏 ---------- */
#tabbar {
  max-width: 1100px; margin: 0 auto; padding: 0 8px; display: flex; gap: 4px; overflow-x: auto;
}
#tabbar .tab {
  background: none; border: none; color: rgba(255,255,255,.82); font-size: 14.5px;
  padding: 10px 16px 12px; cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap;
}
#tabbar .tab:hover { color: #fff; }
#tabbar .tab.active { color: #fff; border-bottom-color: #fff; font-weight: 600; }
#tabbar .tab .cnt {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 5px; font-size: 11.5px;
  background: rgba(255,255,255,.25); border-radius: 999px; text-align: center; font-weight: 700;
}

/* ---------- 布局 ---------- */
main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; }
#foot { max-width: 1100px; margin: 0 auto; padding: 0 16px 26px; color: var(--muted); font-size: 12.5px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h2 { margin: 0; font-size: 20px; }
.page-head .sub { color: var(--muted); font-size: 13px; }

/* ---------- 通用卡片 ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px;
}
.card + .card { margin-top: 0; }
.grid { display: grid; gap: 12px; }
.grid.cols-4 { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }

.stat-card { display: flex; flex-direction: column; gap: 2px; }
.stat-card .num { font-size: 26px; font-weight: 800; }
.stat-card .lbl { color: var(--muted); font-size: 12.5px; }

/* ---------- 设备卡片 ---------- */
.eq-card { display: flex; flex-direction: column; gap: 8px; }
.eq-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.eq-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; color: var(--muted); }
.eq-name { font-size: 15.5px; font-weight: 700; margin: 0; }
.eq-meta { color: var(--muted); font-size: 12.5px; }
.eq-meta .cat {
  display: inline-block; background: var(--gray-bg); border-radius: 6px; padding: 0 8px; margin-right: 6px;
  font-size: 12px; color: #4a5568;
}
.eq-activity { font-size: 12.5px; background: var(--gray-bg); border-radius: 8px; padding: 6px 10px; color: #4a5568; }
.eq-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 2px; }
.eq-note { font-size: 12px; color: var(--muted); }

/* ---------- 借用记录 ---------- */
.bk-card { display: flex; flex-direction: column; gap: 6px; }
.bk-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.bk-no { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; }
.bk-purpose { font-weight: 600; }
.bk-items { font-size: 13px; color: #3d4757; }
.bk-time { font-size: 12.5px; color: var(--muted); }
.bk-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.bk-note { font-size: 12.5px; background: var(--orange-bg); color: #8a5a00; border-radius: 8px; padding: 6px 10px; }

/* ---------- 徽章 ---------- */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  white-space: nowrap;
}
.b-available { background: var(--green-bg); color: var(--green); }
.b-reserved  { background: var(--orange-bg); color: var(--orange); }
.b-borrowed  { background: var(--blue-bg); color: var(--blue); }
.b-maintenance { background: var(--gray-bg); color: #7a8699; }
.b-retired   { background: #e7e9ee; color: #8b93a3; }
.b-pending   { background: var(--orange-bg); color: var(--orange); }
.b-approved  { background: var(--indigo-bg); color: var(--indigo); }
.b-checkedOut{ background: var(--blue-bg); color: var(--blue); }
.b-returned  { background: var(--green-bg); color: var(--green); }
.b-rejected  { background: var(--red-bg); color: var(--red); }
.b-cancelled { background: var(--gray-bg); color: #7a8699; }
.b-late      { background: var(--red-bg); color: var(--red); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .55; } }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
.tbl th, .tbl td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl th { color: var(--muted); font-weight: 600; font-size: 12.5px; background: #fafbfd; white-space: nowrap; }
.tbl tr:hover td { background: #f8faff; }
.tbl .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }

/* ---------- 按钮 / 输入 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  border: 1px solid transparent; border-radius: 9px; padding: 7px 14px; cursor: pointer;
  font-size: 13.5px; font-weight: 600; background: var(--brand); color: #fff;
  transition: .15s; text-decoration: none; line-height: 1.4;
}
.btn:hover { background: var(--brand-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-green { background: var(--green); } .btn-green:hover { background: #15854f; }
.btn-red { background: var(--red); } .btn-red:hover { background: #bb3434; }
.btn-orange { background: var(--orange); } .btn-orange:hover { background: #b96306; }
.btn-gray { background: #8a93a3; } .btn-gray:hover { background: #737d8f; }
.btn-outline { background: #fff; color: var(--brand); border-color: #c9d4f5; }
.btn-outline:hover { background: #f0f4ff; color: var(--brand-dark); }

input[type=text], input[type=password], input[type=number], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #ccd4e2; border-radius: 9px; font-size: 14px;
  font-family: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #c7d4fb; border-color: var(--brand); }
textarea { resize: vertical; min-height: 60px; }
label.f { display: block; margin: 10px 0 3px; font-size: 13px; font-weight: 600; color: #3d4757; }
.f-hint { font-size: 12px; color: var(--muted); margin-top: 2px; }
.f-row { display: flex; gap: 10px; flex-wrap: wrap; }
.f-row > div { flex: 1; min-width: 150px; }

/* ---------- 登录 ---------- */
.auth-wrap { min-height: 78vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px 14px; }
.auth-box { width: 100%; max-width: 420px; }
.auth-logo { text-align: center; margin-bottom: 16px; }
.auth-logo .big { font-size: 44px; }
.auth-logo h1 { margin: 6px 0 2px; font-size: 22px; }
.auth-logo p { color: var(--muted); margin: 0; font-size: 13.5px; }
.auth-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 24px; box-shadow: var(--shadow); }
.auth-card h2 { margin: 0 0 4px; font-size: 18px; }
.auth-card .tip { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.auth-switch { text-align: center; margin-top: 14px; font-size: 13.5px; color: var(--muted); }
.auth-switch a { color: var(--brand); cursor: pointer; font-weight: 600; }

.info-box { background: #eef4ff; border: 1px solid #d5e2fb; color: #31518f; border-radius: 12px; padding: 12px 14px; font-size: 13px; margin-top: 14px; }
.info-box b { display: block; margin-bottom: 2px; }

/* ---------- 提示条 ---------- */
.alert { border-radius: 10px; padding: 10px 14px; font-size: 13.5px; margin-bottom: 12px; }
.alert-red { background: var(--red-bg); color: #9c2b2b; border: 1px solid #f5c9c9; }
.alert-orange { background: var(--orange-bg); color: #8a5a00; border: 1px solid #f3ddb2; }
.alert-green { background: var(--green-bg); color: #116a41; border: 1px solid #c2e8d3; }
.alert-blue { background: var(--blue-bg); color: #2454b0; border: 1px solid #c8dafb; }

/* ---------- 空状态 ---------- */
.empty { text-align: center; color: var(--muted); padding: 40px 10px; font-size: 14px; }
.empty .ic { font-size: 34px; display: block; margin-bottom: 8px; }

/* ---------- 弹窗 ---------- */
.modal-root { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-mask { position: absolute; inset: 0; background: rgba(15, 23, 42, .45); }
.modal {
  position: relative; background: #fff; border-radius: 14px; width: 100%; max-width: 560px;
  max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16.5px; }
.modal-x { border: none; background: none; font-size: 16px; color: var(--muted); cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.modal-x:hover { background: var(--gray-bg); }
.modal-body { padding: 14px 18px 18px; overflow-y: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

/* 多选设备 */
.chk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 7px; max-height: 240px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 9px; }
.chk-grid label { display: flex; gap: 6px; align-items: flex-start; font-size: 13px; padding: 5px 6px; border-radius: 7px; cursor: pointer; }
.chk-grid label:hover { background: #f2f6ff; }
.chk-grid label.disabled { opacity: .45; cursor: not-allowed; }
.chk-grid .c-sub { display: block; font-size: 11px; color: var(--muted); }
.chk-grid input { margin-top: 2px; }
.cat-title { font-size: 12px; font-weight: 700; color: var(--muted); margin: 10px 0 2px; grid-column: 1 / -1; }
.radio-line { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; }
.radio-line label { display: inline-flex; gap: 6px; align-items: center; font-size: 13.5px; cursor: pointer; }

/* ---------- Toast ---------- */
#toasts { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(92vw, 480px); }
.toast {
  background: #1f2733; color: #fff; border-radius: 10px; padding: 10px 18px; font-size: 13.5px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); animation: slideIn .2s ease; max-width: 100%;
}
.toast.err { background: #b23a3a; }
.toast.ok { background: #15854f; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

@media (max-width: 600px) {
  body { font-size: 14.5px; }
  .topbar-inner { padding: 10px 12px; }
  main { padding: 14px 12px 30px; }
  .btn { padding: 8px 12px; }
}

/* 运行信息（管理员） */
.run-info { font-family: ui-monospace, Menlo, Consolas, monospace; background: #0f172a; color: #b8f0d0; border-radius: 10px; padding: 12px 14px; font-size: 12.5px; overflow-x: auto; white-space: pre; line-height: 1.7; }

/* ---------- 类别筛选按钮行（设备库 / 设备管理 / 借用弹窗共用） ---------- */
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip-row .btn { white-space: nowrap; }

/* ---------- 悬浮「扫一扫」（登录后所有页面可见） ---------- */
.scan-fab {
  position: fixed; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 90;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 12px 18px; border: none; border-radius: 999px; cursor: pointer;
  background: var(--brand); color: #fff; font-size: 14px; font-weight: 700;
  box-shadow: 0 10px 26px rgba(37, 99, 235, .35);
}
.scan-fab:hover { background: var(--brand-dark); }
.scan-fab:active { transform: scale(.97); }
@media (max-width: 600px) { .scan-fab { right: 12px; padding: 12px 14px; font-size: 13.5px; } }

/* ---------- 登录页「记住我」 ---------- */
.remember-line { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13.5px; color: #3d4757; cursor: pointer; }
.remember-line input { width: auto; margin: 0; }

/* ---------- 本次借用清单（扫码累加） ---------- */
.draft-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; margin-bottom: 10px;
  background: var(--blue-bg); border: 1px solid #c8dafb; border-radius: 10px; }
.draft-title { font-size: 13px; color: #2454b0; }
.draft-chip { display: inline-flex; align-items: center; gap: 4px; background: #fff; border: 1px solid #c8dafb;
  color: #2454b0; border-radius: 999px; padding: 2px 4px 2px 10px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.draft-x { border: none; background: transparent; color: #7a8699; cursor: pointer; font-size: 14px; line-height: 1; padding: 2px 6px; border-radius: 999px; }
.draft-x:hover { background: var(--red-bg); color: var(--red); }
.scan-count { text-align: center; font-size: 13.5px; font-weight: 700; color: var(--brand); margin: 8px 0 2px; }

/* ---------- 扫一扫 ---------- */
.scan-wrap { position: relative; border-radius: 14px; overflow: hidden; background: #0f172a; aspect-ratio: 4 / 3; margin-bottom: 4px; }
.scan-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame {
  position: absolute; left: 50%; top: 50%; width: 62%; aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%); border: 3px solid rgba(255,255,255,.9); border-radius: 12px;
  box-shadow: 0 0 0 100vmax rgba(15,23,42,.35);
}
.scan-frame::after {
  content: ''; position: absolute; left: 0; right: 0; height: 2px; background: #6ee7a8;
  animation: scanline 1.8s ease-in-out infinite;
}
@keyframes scanline { 0% { top: 4%; } 50% { top: 94%; } 100% { top: 4%; } }

/* ---------- 今日待办条（总览） ---------- */
.todo-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.todo-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.todo-chip { display: flex; flex-direction: column; align-items: center; min-width: 104px; padding: 8px 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff; cursor: pointer; transition: .15s; }
.todo-chip b { font-size: 19px; line-height: 1.2; color: var(--brand); }
.todo-chip span { font-size: 12px; color: var(--muted); white-space: nowrap; }
.todo-chip:hover:not(:disabled) { border-color: var(--brand); background: #f6f9ff; }
.todo-chip:disabled { opacity: .5; cursor: not-allowed; }
.todo-chip.danger b { color: var(--red); }
.todo-chip.danger:hover:not(:disabled) { border-color: var(--red); background: var(--red-bg); }

/* ---------- 设备档期条 ---------- */
.day-strip { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 6px; }
.day-cell { flex: 0 0 auto; width: 58px; border-radius: 10px; padding: 6px 4px; text-align: center; border: 1px solid var(--line); }
.day-cell .d { display: block; font-size: 13px; font-weight: 700; }
.day-cell .w { display: block; font-size: 11px; opacity: .75; }
.day-cell .s { display: block; font-size: 11px; margin-top: 3px; }
.day-cell.free { background: var(--green-bg); border-color: #c2e8d3; color: #116a41; }
.day-cell.busy { background: var(--orange-bg); border-color: #f3ddb2; color: #8a5a00; }

/* ---------- 归还验收：逐台判定 ---------- */
.ck-list { display: flex; flex-direction: column; gap: 10px; }
.ck-item { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fcfdff; }
.ck-item-head { margin-bottom: 6px; }
.acc-box { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.acc-item { font-size: 13px; display: inline-flex; align-items: center; gap: 5px; }
.bk-due-soon { color: var(--orange); font-weight: 600; }

/* ---------- 小屏：表格转卡片，方便现场用手机操作 ---------- */
@media (max-width: 720px) {
  .todo-bar { flex-direction: column; align-items: stretch; }
  .todo-chips { display: grid; grid-template-columns: 1fr 1fr; }
  .todo-chip { min-width: 0; }
  table.tbl.responsive { min-width: 0; }
  table.tbl.responsive thead { display: none; }
  table.tbl.responsive tr { display: block; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; padding: 6px 10px; background: #fff; }
  table.tbl.responsive tr:hover td { background: transparent; }
  table.tbl.responsive td { display: flex; justify-content: space-between; align-items: center; gap: 10px; border: none; padding: 6px 0; text-align: right; }
  table.tbl.responsive td::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; font-weight: 600; text-align: left; flex: 0 0 auto; }
  table.tbl.responsive td:not([data-label])::before { content: ''; }
  table.tbl.responsive td[data-label="操作"] { display: block; }
  table.tbl.responsive td[data-label="操作"]::before { display: block; margin-bottom: 4px; }
  .day-cell { width: 54px; }
  .modal { max-height: 92vh; }
}
