/* ============================================================================
   领用样机管理 · 设计系统（v1.4.0 纯视觉重构）
   零依赖、无构建、无外部字体/图标/CDN。图标一律用 emoji 或内联 SVG。
   结构：① 设计令牌 ② 基础与重置 ③ 布局骨架（顶栏/页面/卡片）
        ④ 排版与文本 ⑤ 按钮与表单 ⑥ 表格与空状态 ⑦ 徽标与指标卡
        ⑧ 流程时间线（7 节点）⑨ 归还明细 ⑩ 弹层/提示/骨架
        ⑪ 登录页 ⑫ 响应式三档（≥1200 / 768—1199 / <768）⑬ 暗色（可选）
   ========================================================================== */

/* ---------------------------------------------------------------------------
   ① 设计令牌
   --------------------------------------------------------------------------- */
:root {
  /* 中性色阶 50—900 */
  --c-50: #f8fafc;
  --c-100: #f1f5f9;
  --c-200: #e6eaf1;
  --c-300: #cbd5e1;
  --c-400: #94a3b8;
  --c-500: #64748b;
  --c-600: #475569;
  --c-700: #334155;
  --c-800: #1e293b;
  --c-900: #0f172a;

  /* 语义色 */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --primary-ring: rgba(37, 99, 235, 0.28);
  --success: #059669;
  --success-soft: #ecfdf5;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-soft: #fef2f2;
  --info: #0891b2;
  --info-soft: #ecfeff;
  --violet-soft: #ede9fe;

  /* 表面 / 分割线 / 文本 */
  --bg: var(--c-50);
  --card: #ffffff;
  --card-soft: #fbfcfe;
  --line: var(--c-200);
  --line-strong: var(--c-300);
  --text: var(--c-900);
  --muted: var(--c-500);
  --faint: var(--c-400);

  /* 间距刻度 */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;

  /* 圆角 */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;
  --radius: var(--radius-md);

  /* 阴影 3 级 */
  --shadow-1: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-2: 0 4px 12px rgba(15, 23, 42, 0.07), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-3: 0 18px 48px rgba(15, 23, 42, 0.18), 0 6px 16px rgba(15, 23, 42, 0.10);

  /* 字体栈：系统无衬线 + 中文回退，不引外部字体 */
  --font-sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "Cascadia Mono", "JetBrains Mono", Consolas, monospace;

  /* 字号阶梯 */
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-lg: 16px;
  --text-xl: 20px;
  --text-2xl: 28px;

  /* 兼容既有变量名（旧引用不失效） */
  --primary-dark: var(--primary-hover);
  --ok: var(--success);

  /* 动效 */
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
  --dur: 160ms;
}

/* ---------------------------------------------------------------------------
   ② 基础与重置
   --------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--primary);
  color: #ffffff;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--c-300);
  border: 2px solid var(--bg);
  border-radius: var(--radius-pill);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--c-400);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--c-300) transparent;
}

a {
  color: var(--primary-hover);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}

a:hover {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  text-decoration: none;
}

img,
svg {
  max-width: 100%;
}

/* ---------------------------------------------------------------------------
   ③ 布局骨架
   --------------------------------------------------------------------------- */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: var(--space-6);
  padding: var(--space-3) var(--space-6);
  background: color-mix(in srgb, var(--card) 88%, transparent);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-1);
  backdrop-filter: saturate(160%) blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text);
  text-decoration: none;
  flex: 0 0 auto;
}

.brand:hover {
  text-decoration: none;
  color: var(--text);
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  font-size: 17px;
  line-height: 1;
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
  box-shadow: var(--shadow-1);
  flex: 0 0 auto;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand-sub {
  font-size: 11px;
  font-weight: 500;
  color: var(--faint);
  letter-spacing: 0.04em;
}

.nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: wrap;
}

.nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--c-600);
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.nav-link:hover {
  background: var(--c-100);
  color: var(--c-900);
  text-decoration: none;
}

.nav-link.active {
  background: var(--primary-soft);
  color: var(--primary-hover);
  font-weight: 600;
}

.nav-link.active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 1px;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: var(--primary);
  transform: translateX(-50%);
}

.user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 0 0 auto;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--card-soft);
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--primary-hover);
  background: var(--primary-soft);
  border: 1px solid color-mix(in srgb, var(--primary) 18%, transparent);
  flex: 0 0 auto;
}

.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}

.user-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.user-sub {
  font-size: 11px;
  color: var(--faint);
  white-space: nowrap;
}

.role-badge {
  display: inline-block;
  padding: 0 7px;
  font-size: 10px;
  line-height: 17px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--primary-hover);
  background: var(--primary-soft);
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

main {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-6) var(--space-8);
  flex: 1 1 auto;
}

/* 页面标题区：标题 + 副标题 + 主操作 */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-6);
}

.page-head-main {
  min-width: 0;
}

.page-title {
  margin: 0;
  font-size: var(--text-2xl);
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.page-sub {
  margin: var(--space-1) 0 0;
  font-size: var(--text-sm);
  color: var(--muted);
}

.page-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-1);
}

.card-soft {
  background: var(--card-soft);
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

.card-title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 650;
  letter-spacing: -0.01em;
}

.card-sub {
  margin: var(--space-1) 0 0;
  font-size: var(--text-sm);
  color: var(--muted);
}

.section-title {
  margin: var(--space-6) 0 var(--space-3);
  font-size: var(--text-lg);
  font-weight: 650;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.section-title::before {
  content: "";
  width: 3px;
  height: 15px;
  border-radius: 2px;
  background: var(--primary);
  flex: 0 0 auto;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  align-items: start;
}

.grid1 {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

/* ---------------------------------------------------------------------------
   ④ 排版与文本
   --------------------------------------------------------------------------- */
h1,
h2,
h3 {
  color: var(--text);
}

h1 {
  font-size: var(--text-xl);
  margin: 0 0 var(--space-4);
}

h2 {
  font-size: var(--text-lg);
  margin: var(--space-6) 0 var(--space-3);
}

h3 {
  font-size: var(--text-lg);
  margin: 0 0 var(--space-3);
}

p {
  margin: var(--space-2) 0;
}

.muted {
  color: var(--muted);
}

.faint {
  color: var(--faint);
}

.err {
  color: var(--danger);
  font-size: var(--text-sm);
  min-height: 0;
}

.err:not(:empty) {
  margin-top: var(--space-2);
}

.ok {
  color: var(--success);
  font-size: var(--text-sm);
}

.hint {
  color: var(--muted);
  font-size: var(--text-xs);
  margin-top: var(--space-3);
  line-height: 1.8;
}

.num,
.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------------------
   ⑤ 按钮与表单
   --------------------------------------------------------------------------- */
button,
.link-btn {
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 550;
  line-height: 1.4;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--c-700);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
    color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform 80ms var(--ease);
}

button:hover:not(:disabled),
.link-btn:hover {
  border-color: var(--c-400);
  background: var(--card-soft);
  color: var(--c-900);
  text-decoration: none;
}

button:active:not(:disabled),
.link-btn:active {
  transform: translateY(1px);
}

button:focus-visible,
.link-btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

button:disabled,
.link-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

button.primary,
.link-btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

button.primary:hover:not(:disabled),
.link-btn.primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #ffffff;
}

button.danger,
.link-btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

button.danger:hover:not(:disabled),
.link-btn.danger:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
  color: #ffffff;
}

button.ghost,
.link-btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

button.ghost:hover:not(:disabled),
.link-btn.ghost:hover {
  background: var(--c-100);
  border-color: transparent;
  color: var(--c-800);
}

button.link {
  border: none;
  background: none;
  padding: 4px 2px;
  color: var(--muted);
  font-weight: 500;
}

button.link:hover:not(:disabled) {
  color: var(--primary-hover);
  background: none;
  border: none;
}

button.sm,
.link-btn.sm {
  padding: 4px 10px;
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

label.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: var(--text-xs);
  color: var(--muted);
  min-width: 0;
}

label.field > span {
  font-weight: 600;
  color: var(--c-600);
  letter-spacing: 0.01em;
}

input,
select,
textarea {
  font: inherit;
  font-size: var(--text-sm);
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  min-width: 140px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

input::placeholder,
textarea::placeholder {
  color: var(--faint);
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--c-400);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: var(--c-100);
  color: var(--faint);
  cursor: not-allowed;
}

textarea {
  min-height: 76px;
  width: 100%;
  resize: vertical;
}

input[type="checkbox"] {
  width: 15px;
  height: 15px;
  min-width: 15px;
  margin: 0;
  padding: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

input[type="file"] {
  padding: 6px;
  font-size: var(--text-xs);
  background: var(--card-soft);
  min-width: 0;
}

.field-error,
.has-error input,
.has-error select,
.has-error textarea {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.field-error {
  background: none;
  color: var(--danger);
  font-size: var(--text-xs);
  font-weight: 500;
}

.row {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  align-items: flex-end;
}

.row > * {
  min-width: 0;
}

.filter-bar {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  align-items: flex-end;
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--card-soft);
}

.toolbar {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
}

.tabs {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

.tabs button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

/* ---------------------------------------------------------------------------
   ⑥ 表格与空状态
   --------------------------------------------------------------------------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--card);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.data-table {
  min-width: 100%;
}

th,
td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

thead th {
  position: relative;
  background: var(--c-50);
  color: var(--c-500);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  border-bottom: 1px solid var(--line-strong);
}

thead th::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 1px;
  background: var(--line);
}

tbody tr {
  transition: background var(--dur) var(--ease);
}

tbody tr:hover {
  background: var(--primary-soft);
}

tbody tr:last-child td {
  border-bottom: none;
}

td .badge,
td .muted {
  vertical-align: middle;
}

/* 定义表（键值对）：详情页左栏 */
.kv {
  font-size: var(--text-sm);
}

.kv th {
  width: 34%;
  padding: 8px 12px 8px 0;
  color: var(--muted);
  font-weight: 500;
  font-size: var(--text-sm);
  letter-spacing: 0;
  text-transform: none;
  background: none;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.kv th::after {
  display: none;
}

.kv td {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.kv tr:last-child th,
.kv tr:last-child td {
  border-bottom: none;
}

/* 空状态：图标 + 文案 */
.empty-cell {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  border-bottom: none;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  color: var(--muted);
}

.empty-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 20px;
  line-height: 1;
  background: var(--c-100);
  color: var(--faint);
}

.empty-text {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--muted);
}

.empty-sub {
  font-size: var(--text-xs);
  color: var(--faint);
}

/* 分页 */
.pager {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  justify-content: flex-end;
  padding-top: var(--space-4);
  color: var(--muted);
  font-size: var(--text-sm);
  flex-wrap: wrap;
}

.pager .num {
  color: var(--c-700);
  font-weight: 600;
}

/* ---------------------------------------------------------------------------
   ⑦ 徽标与指标卡
   --------------------------------------------------------------------------- */
.badge {
  display: inline-block;
  padding: 1px 9px;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 18px;
  background: var(--c-100);
  color: var(--c-600);
  border: 1px solid transparent;
  white-space: nowrap;
  vertical-align: middle;
}

.badge.draft {
  background: var(--c-100);
  color: var(--c-600);
}

.badge.pending_dept,
.badge.pending_approve,
.badge.approved_wait_sn,
.badge.pending_issue {
  background: var(--primary-soft);
  color: var(--primary-hover);
}

.badge.borrowed {
  background: #fff7ed;
  color: var(--warn);
}

/* v1.3.0 按台两步归还：待归还确认是「还没还」，用黄色与已归还（绿）区分 */
.badge.pending_return {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge.returned {
  background: var(--success-soft);
  color: var(--success);
}

.badge.rejected,
.badge.cancelled,
.badge.withdrawn {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.overdue {
  background: #fee2e2;
  color: var(--danger-hover);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-3);
}

/* 指标卡：大数字 + 左侧色条 + 说明小字 */
.metric {
  position: relative;
  display: flex;
  gap: var(--space-3);
  align-items: stretch;
  padding: var(--space-4) var(--space-4) var(--space-4) var(--space-3);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.metric:hover {
  box-shadow: var(--shadow-2);
  transform: translateY(-1px);
}

.metric-bar {
  width: 3px;
  border-radius: var(--radius-pill);
  background: var(--c-300);
  flex: 0 0 auto;
}

.metric-body {
  min-width: 0;
}

.metric-num,
.metric .num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 30px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.metric-label,
.metric .label {
  margin-top: 2px;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.metric-sub {
  margin-top: 2px;
  color: var(--faint);
  font-size: 11px;
}

.metric.red .metric-bar {
  background: var(--danger);
}

.metric.red .metric-num,
.metric.red .num {
  color: var(--danger);
}

.metric.blue .metric-bar {
  background: var(--primary);
}

.metric.green .metric-bar {
  background: var(--success);
}

.metric.amber .metric-bar {
  background: var(--warn);
}

.metric.violet .metric-bar {
  background: #7c3aed;
}

/* 看板横向条 */
.bar {
  height: 8px;
  min-width: 60px;
  border-radius: var(--radius-pill);
  background: var(--c-100);
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--primary);
  transition: width 320ms var(--ease);
}

.bar-fill.blue {
  background: var(--primary);
}

.bar-fill.green {
  background: var(--success);
}

.bar-fill.violet {
  background: #8b5cf6;
}

.bar-cell {
  width: 40%;
}

/* ---------------------------------------------------------------------------
   ⑧ 流程时间线（DESIGN B15，v3 共 7 个节点）
   竖向轨道：已完成打勾（实心）、当前脉冲高亮、未到灰色虚线
   --------------------------------------------------------------------------- */
.flow-summary {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-6);
  background: var(--card-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
  color: var(--muted);
}

.flow-summary strong {
  color: var(--text);
  font-weight: 600;
}

.flow-summary-item {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.flow {
  list-style: none;
  padding: 0;
  margin: 0;
}

.flow-node {
  position: relative;
  padding: 2px 0 var(--space-4) 30px;
  margin-left: 8px;
  border-left: 2px dashed var(--line-strong);
  color: var(--text);
}

.flow-node:last-child {
  border-left-color: transparent;
  padding-bottom: 0;
}

.flow-node .dot {
  position: absolute;
  left: -8px;
  top: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  color: #ffffff;
  background: var(--card);
  border: 2px solid var(--line-strong);
}

.flow-node.done {
  border-left: 2px solid var(--success);
}

.flow-node.done .dot {
  background: var(--success);
  border-color: var(--success);
}

.flow-node.done .dot::after {
  content: "✓";
}

.flow-node.current {
  background: var(--primary-soft);
  border-left: 2px solid var(--primary);
  border-radius: var(--radius-md);
  padding-top: var(--space-2);
  padding-bottom: var(--space-3);
  box-shadow: var(--shadow-1);
}

.flow-node.current .dot {
  background: var(--primary);
  border-color: var(--primary);
  animation: flow-pulse 2s var(--ease) infinite;
}

.flow-node.current .dot::after {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #ffffff;
}

.flow-node.pending {
  color: var(--muted);
  border-left-style: dashed;
  border-left-color: var(--line-strong);
}

.flow-node.pending .dot {
  background: var(--card);
  border-color: var(--line-strong);
}

.flow-node-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.flow-node-label {
  font-size: var(--text-sm);
  font-weight: 650;
}

.flow-node.current .flow-node-label {
  color: var(--primary-hover);
}

.flow-node.pending .flow-node-label {
  font-weight: 500;
  color: var(--muted);
}

.flow-node-meta {
  margin-top: 2px;
  font-size: var(--text-xs);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  align-items: baseline;
}

.flow-node-meta .meta-sep {
  color: var(--faint);
}

.flow-node-comment {
  margin-top: 4px;
  font-size: var(--text-xs);
  color: var(--muted);
  background: var(--c-50);
  border-left: 2px solid var(--line-strong);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 4px 8px;
}

.flow-tag {
  display: inline-block;
  padding: 0 7px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 600;
  line-height: 17px;
  background: var(--c-100);
  color: var(--c-600);
  white-space: nowrap;
}

.flow-tag.done {
  background: var(--success-soft);
  color: var(--success);
}

.flow-tag.current {
  background: var(--primary);
  color: #ffffff;
}

.flow-tag.pending {
  background: var(--c-100);
  color: var(--faint);
}

@keyframes flow-pulse {
  0% {
    box-shadow: 0 0 0 0 var(--primary-ring);
  }
  70% {
    box-shadow: 0 0 0 7px rgba(37, 99, 235, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .flow-node.current .dot {
    animation: none;
  }
  .bar-fill,
  .metric {
    transition: none;
  }
}

/* 流程日志（时间线样式） */
.timeline {
  list-style: none;
  padding: 0;
  margin: 0;
}

.timeline li {
  position: relative;
  border-left: 2px solid var(--line);
  padding: 2px 0 var(--space-3) var(--space-4);
  margin-left: 6px;
}

.timeline li:last-child {
  border-left-color: transparent;
  padding-bottom: 0;
}

.timeline li::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--card);
  border: 2px solid var(--line-strong);
}

.timeline .time {
  color: var(--faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------------------
   ⑨ 归还明细（v1.2.0 部分归还 / v1.3.0 按台两步）
   --------------------------------------------------------------------------- */
.return-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: var(--space-3) 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  background: var(--card);
}

.return-list .return-line {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text);
  margin: 0;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--dur) var(--ease);
}

.return-list .return-line:hover {
  background: var(--c-50);
}

.return-list .return-line input[type="checkbox"] {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

/* 操作面板（详情页动作区） */
.action-panel {
  background: var(--primary-soft);
  border: 1px solid color-mix(in srgb, var(--primary) 16%, transparent);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-6);
  margin-bottom: var(--space-4);
  box-shadow: none;
}

.action-panel h2,
.action-panel .card-title {
  margin-top: 0;
  font-size: var(--text-lg);
}

.action-panel p {
  font-size: var(--text-sm);
  color: var(--c-600);
}

.action-panel .row {
  margin-top: var(--space-3);
}

/* ---------------------------------------------------------------------------
   ⑩ 弹层 / 提示 / 骨架
   --------------------------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: var(--space-4);
  backdrop-filter: blur(2px);
}

.modal[hidden] {
  display: none;
}

.modal-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  width: min(640px, 100%);
  max-height: 85vh;
  overflow: auto;
  box-shadow: var(--shadow-3);
  animation: modal-in 160ms var(--ease);
}

.modal-card h3 {
  margin-top: 0;
  font-size: var(--text-lg);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-6);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.toast {
  position: fixed;
  right: var(--space-6);
  bottom: var(--space-6);
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  max-width: 460px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background: var(--c-900);
  color: #ffffff;
  font-size: var(--text-sm);
  line-height: 1.55;
  z-index: 50;
  box-shadow: var(--shadow-3);
  animation: toast-in 180ms var(--ease);
}

.toast[hidden] {
  display: none;
}

.toast.error {
  background: var(--danger-hover);
}

.toast-icon {
  font-size: var(--text-sm);
  line-height: 1.55;
  flex: 0 0 auto;
}

.toast-msg {
  min-width: 0;
  overflow-wrap: anywhere;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* 骨架加载（首屏，index.html 内联） */
.loading {
  padding: var(--space-8);
  text-align: center;
  color: var(--muted);
}

.boot {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.boot-main {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--c-100);
  border-radius: var(--radius-md);
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.72), transparent);
  animation: skeleton-sweep 1.4s infinite;
}

.skeleton-topbar {
  height: 58px;
  border-radius: 0;
  border-bottom: 1px solid var(--line);
}

.skeleton-title {
  height: 30px;
  width: min(320px, 60%);
  border-radius: var(--radius-sm);
}

.skeleton-card {
  height: 132px;
}

@keyframes skeleton-sweep {
  100% {
    transform: translateX(100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton::after {
    animation: none;
  }
}

/* 树 / 行内小组件 */
.tree {
  list-style: none;
  padding-left: var(--space-4);
  margin: 0;
  border-left: 1px dashed var(--line-strong);
}

.tree > li {
  padding: 2px 0;
}

.tree > li > ul {
  list-style: none;
  padding-left: var(--space-4);
  margin: 0;
  border-left: 1px dashed var(--line-strong);
}

.item-line {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--card-soft);
}

.item-line input[name="model"] {
  flex: 1 1 200px;
  min-width: 120px;
}

.item-line input[name="qty"] {
  width: 90px;
  min-width: 70px;
}

/* ---------------------------------------------------------------------------
   ⑪ 登录页：左品牌区（渐变 + 简介）+ 右表单
   --------------------------------------------------------------------------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0;
  background: var(--bg);
}

.login-shell {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  width: 100%;
  min-height: 100vh;
  background: var(--card);
}

.login-brand {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-8);
  color: #ffffff;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 48%, #4f46e5 100%);
  overflow: hidden;
}

.login-brand::after {
  content: "";
  position: absolute;
  right: -120px;
  bottom: -140px;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.22), transparent 62%);
  pointer-events: none;
}

.login-brand-mark {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-lg);
  font-weight: 700;
}

.login-brand-mark .brand-mark {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: none;
}

.login-brand-title {
  margin: 0;
  font-size: 30px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #ffffff;
}

.login-brand-desc {
  margin: 0;
  max-width: 34ch;
  font-size: var(--text-base);
  line-height: 1.8;
  color: rgba(255, 255, 255, 0.86);
}

.login-brand-list {
  list-style: none;
  padding: 0;
  margin: var(--space-2) 0 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: rgba(255, 255, 255, 0.9);
}

.login-brand-list li {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.login-brand-list .tick {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 10px;
  background: rgba(255, 255, 255, 0.2);
  flex: 0 0 auto;
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-6);
  background: var(--card);
}

.login-card {
  width: min(380px, 100%);
}

.login-card h1 {
  text-align: left;
  font-size: var(--text-xl);
  margin-bottom: var(--space-1);
}

.login-panel-head {
  margin-bottom: var(--space-6);
}

.login-panel-sub {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--muted);
}

.login-card .field {
  margin-bottom: var(--space-3);
}

.login-card input {
  width: 100%;
}

.login-card button[type="submit"] {
  width: 100%;
  margin-top: var(--space-2);
  padding: 9px 16px;
}

.login-divider {
  height: 1px;
  background: var(--line);
  margin: var(--space-6) 0 var(--space-4);
  border: 0;
}

/* ---------------------------------------------------------------------------
   ⑫ 响应式三档：≥1200 / 768—1199 / <768
   --------------------------------------------------------------------------- */

/* 中档（平板 / 窄桌面）：收紧间距与字号 */
@media (min-width: 768px) and (max-width: 1199px) {
  main {
    padding: var(--space-4);
    max-width: 100%;
  }

  .topbar {
    gap: var(--space-4);
    padding: var(--space-3) var(--space-4);
  }

  .grid2 {
    grid-template-columns: 1fr;
  }

  .cards {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  .page-title {
    font-size: var(--text-xl);
  }

  .metric-num {
    font-size: 26px;
  }

  .login-shell {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .login-brand {
    padding: var(--space-8) var(--space-6);
  }

  .login-brand-title {
    font-size: 24px;
  }
}

/* 窄屏（手机）：单列、表格横向滚动 + 首列吸附 */
@media (max-width: 767px) {
  main {
    padding: var(--space-3);
  }

  .topbar {
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
  }

  .brand-sub {
    display: none;
  }

  .nav {
    order: 3;
    flex: 1 0 100%;
    gap: 2px;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }

  .nav-link {
    padding: 6px 11px;
    font-size: var(--text-xs);
  }

  .user {
    margin-left: auto;
  }

  .user-chip {
    padding: 2px;
    border: none;
    background: none;
  }

  .user-meta {
    display: none;
  }

  .brand-title {
    font-size: var(--text-sm);
  }

  .page-head {
    align-items: flex-start;
    margin-bottom: var(--space-4);
  }

  .page-title {
    font-size: var(--text-xl);
  }

  .page-actions {
    width: 100%;
  }

  .card {
    padding: var(--space-4);
    border-radius: var(--radius-md);
  }

  .grid2,
  .grid1 {
    grid-template-columns: 1fr;
  }

  .row,
  .filter-bar {
    gap: var(--space-2);
  }

  .filter-bar {
    padding: var(--space-3);
  }

  label.field,
  input,
  select,
  textarea {
    min-width: 0;
    width: 100%;
  }

  .filter-bar .field {
    flex: 1 1 100%;
  }

  .item-line {
    flex-wrap: wrap;
  }

  .cards {
    grid-template-columns: 1fr 1fr;
  }

  .metric {
    padding: var(--space-3);
  }

  .metric-num {
    font-size: 24px;
  }

  /* 表格横向滚动 + 首列吸附 */
  .table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-sm);
  }

  .table-wrap .data-table {
    min-width: 720px;
  }

  .table-wrap th:first-child,
  .table-wrap td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--card);
    box-shadow: 1px 0 0 var(--line);
  }

  .table-wrap thead th:first-child {
    background: var(--c-50);
    z-index: 3;
  }

  tbody tr:hover td:first-child {
    background: var(--primary-soft);
  }

  .login-wrap {
    padding: 0;
  }

  .login-shell {
    grid-template-columns: 1fr;
    min-height: 100vh;
  }

  .login-brand {
    padding: var(--space-6) var(--space-4);
    gap: var(--space-2);
  }

  .login-brand-title {
    font-size: var(--text-xl);
  }

  .login-brand-desc,
  .login-brand-list {
    display: none;
  }

  .login-panel {
    padding: var(--space-6) var(--space-4) var(--space-8);
  }

  .toast {
    left: var(--space-3);
    right: var(--space-3);
    bottom: var(--space-3);
    max-width: none;
  }

  .pager {
    justify-content: space-between;
  }

  .flow-node {
    padding-left: 26px;
  }
}

/* 大屏（≥1200）：更舒展的留白 */
@media (min-width: 1200px) {
  main {
    max-width: 1280px;
    padding: var(--space-8) var(--space-6) var(--space-8);
  }

  .cards {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  }
}

/* ---------------------------------------------------------------------------
   ⑬ 暗色（可选，跟随系统；不强制）
   --------------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root {
    --c-50: #0f172a;
    --c-100: #162032;
    --c-200: #243044;
    --c-300: #34435c;
    --c-400: #64748b;
    --c-500: #94a3b8;
    --c-600: #cbd5e1;
    --c-700: #e2e8f0;
    --c-800: #f1f5f9;
    --c-900: #f8fafc;
    --bg: #0b1220;
    --card: #111a2b;
    --card-soft: #0e1727;
    --line: #22304a;
    --line-strong: #2f405d;
    --text: #e8eefb;
    --muted: #93a3bd;
    --faint: #6b7d99;
    --primary-soft: #14243f;
    --success-soft: #0d2a22;
    --warn-soft: #2b2113;
    --danger-soft: #2c1618;
    --info-soft: #0d2733;
    --violet-soft: #1e1a33;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 4px 14px rgba(0, 0, 0, 0.45);
    --shadow-3: 0 18px 48px rgba(0, 0, 0, 0.6);
  }

  body {
    background: var(--bg);
  }

  thead th {
    background: #0e1727;
  }

  .badge.borrowed {
    background: #3a2a12;
    color: #fbbf24;
  }

  .badge.overdue {
    background: #3a1719;
    color: #f87171;
  }

  .skeleton::after {
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
  }

  .modal {
    background: rgba(3, 7, 18, 0.66);
  }
}
