/* ==========================================================================
   实验室数据归档与借阅管理系统 · 基础样式
   依赖 tokens.css（先于本文件加载）；本文件禁止硬编码 hex（U-2-1）。
   包含：reset / 排版 / 应用骨架 / 按钮 / 表单 / 徽章 / 卡片 / 表格 /
         Toast / 模态 / 抽屉 / 空态 / 骨架屏 / 分页 / 登录页
   ========================================================================== */

/* ---------- reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

html,
body,
h1,
h2,
h3,
h4,
p,
ul,
ol,
figure {
  margin: 0;
  padding: 0;
}

ul,
ol {
  list-style: none;
}

body {
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-weight: 400;
  color: var(--text-primary);
  background: var(--bg-page);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--primary-600);
  text-decoration: none;
}

a:hover {
  color: var(--primary-500);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

img,
svg {
  display: block;
}

table {
  width: 100%;
  border-collapse: collapse;
}

h1 {
  font-size: var(--fs-h1);
  line-height: var(--lh-h1);
  font-weight: 600;
  color: var(--text-title);
}

h2 {
  font-size: var(--fs-h2);
  line-height: var(--lh-h2);
  font-weight: 600;
  color: var(--text-title);
}

::selection {
  background: var(--primary-100);
}

/* 滚动条（U-9-5 登记值） */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-thumb {
  border-radius: var(--radius-full);
  background: var(--scrollbar-thumb);
}

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

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

/* ---------- 通用工具类 ---------- */
.num {
  font-variant-numeric: tabular-nums;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.nowrap {
  white-space: nowrap;
}

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

.weak {
  color: var(--text-weak);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.cell-ellipsis {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-cell {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.file-cell svg {
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--text-weak);
}

.file-cell__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sha-cell {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  white-space: nowrap;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-weak);
}

.copy-btn svg {
  width: 14px;
  height: 14px;
}

.copy-btn:hover {
  background: var(--primary-50);
  color: var(--primary-600);
}

.copy-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--focus-ring);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  white-space: nowrap;
}

.row-actions .btn--ghost {
  flex: none;
}

.tbl .col-actions .row-actions {
  justify-content: flex-end;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 48px;
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border-default);
}

.toolbar__spacer {
  flex: 1;
}

.toolbar .input {
  width: 220px;
  min-width: 0;
}

.tip {
  display: inline-flex;
}

/* ---------- 按钮（UI §4.1） ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 36px;
  padding: 0 var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  background: transparent;
  font-size: var(--fs-body);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.btn svg {
  flex: none;
  width: 16px;
  height: 16px;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--focus-ring);
}

.btn--primary {
  background: var(--primary-600);
  border-color: var(--primary-600);
  color: var(--white);
}

.btn--primary:hover {
  background: var(--primary-700);
  border-color: var(--primary-700);
}

.btn--primary:active {
  background: var(--primary-800);
  border-color: var(--primary-800);
}

.btn--secondary {
  background: var(--white);
  border-color: var(--border-default);
  color: var(--text-primary);
}

.btn--secondary:hover {
  background: var(--bg-page);
  border-color: var(--border-strong);
}

.btn--danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--white);
}

.btn--danger:hover {
  background: var(--danger-dark);
  border-color: var(--danger-dark);
}

.btn--success {
  background: var(--success);
  border-color: var(--success);
  color: var(--white);
}

.btn--success:hover {
  background: var(--success-dark);
  border-color: var(--success-dark);
}

.btn--sm {
  height: 30px;
  padding: 0 var(--space-3);
  font-size: var(--fs-small);
}

.btn--ghost {
  height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary-600);
  font-size: var(--fs-small);
  font-weight: 500;
}

.btn--ghost:hover {
  color: var(--primary-500);
  text-decoration: underline;
}

.btn--ghost--danger {
  color: var(--danger);
}

.btn--ghost--danger:hover {
  color: var(--danger-dark);
}

.btn--ghost--success {
  color: var(--success);
}

.btn--ghost--success:hover {
  color: var(--success-dark);
}

.btn--disabled,
.btn:disabled {
  background: var(--bg-subtle);
  border-color: var(--border-default);
  color: var(--text-weak);
  cursor: not-allowed;
}

.btn--ghost:disabled,
.btn--ghost.btn--disabled {
  background: transparent;
  border-color: transparent;
  color: var(--text-weak);
  text-decoration: none;
}

.btn--block {
  width: 100%;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--white);
  color: var(--text-secondary);
}

.icon-btn:hover {
  background: var(--bg-page);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

/* ---------- 表单（UI §4.4） ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.field__label {
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--text-primary);
}

.field__hint {
  font-size: var(--fs-caption);
  line-height: var(--lh-caption);
  color: var(--text-weak);
}

.input,
.select,
.textarea {
  width: 100%;
  height: 36px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--white);
  font-size: var(--fs-body);
  color: var(--text-primary);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.select {
  appearance: none;
  padding-right: var(--space-8);
  background-image: var(--icon-chevron);
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-weak);
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--primary-600);
  box-shadow: 0 0 0 2px var(--focus-ring);
}

.input:disabled,
.select:disabled,
.textarea:disabled {
  background: var(--bg-subtle);
  color: var(--text-weak);
  cursor: not-allowed;
}

.textarea {
  height: auto;
  min-height: 88px;
  padding: var(--space-2) var(--space-3);
  line-height: var(--lh-body);
  resize: vertical;
}

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

.err-text {
  font-size: var(--fs-caption);
  line-height: var(--lh-caption);
  color: var(--danger);
}

.char-count {
  align-self: flex-end;
  font-size: var(--fs-small);
  line-height: var(--lh-small);
  color: var(--text-weak);
}

.char-count--error {
  color: var(--danger);
}

/* ---------- 状态徽章（UI §4.2，文案由模板逐字输出） ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: 22px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--fs-caption);
  line-height: 1;
  font-weight: 500;
  white-space: nowrap;
}

.badge::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: currentColor;
}

.badge--pending-review,
.badge--amber {
  background: var(--badge-amber-bg);
  color: var(--warning);
}

.badge--sealed,
.badge--approved,
.badge--emerald {
  background: var(--badge-emerald-bg);
  color: var(--success);
}

.badge--rejected,
.badge--red {
  background: var(--badge-red-bg);
  color: var(--danger);
}

.badge--waiting,
.badge--sky {
  background: var(--badge-sky-bg);
  color: var(--info);
}

.badge--consumed,
.badge--expired,
.badge--cancelled,
.badge--slate {
  background: var(--badge-slate-bg);
  color: var(--text-secondary);
}

.badge--role {
  height: 20px;
  padding: 0 var(--space-2);
  background: var(--primary-50);
  color: var(--primary-700);
  font-size: var(--fs-caption);
}

.badge--role::before {
  display: none;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--white);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 52px;
  padding: var(--space-4) 20px;
  border-bottom: 1px solid var(--border-default);
}

.card__title {
  font-size: var(--fs-h2);
  line-height: var(--lh-h2);
  font-weight: 600;
  color: var(--text-title);
}

.card__body {
  padding: 20px;
}

.card--flush {
  overflow: hidden;
}

/* ---------- 表格（UI §4.3） ---------- */
.table-wrap {
  width: 100%;
  overflow: auto;
  border-radius: var(--radius-xl);
}

.tbl {
  width: 100%;
  min-width: 100%;
  table-layout: auto;
}

.tbl th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 40px;
  padding: 0 var(--space-3);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-default);
  font-size: var(--fs-caption);
  line-height: var(--lh-caption);
  font-weight: 500;
  color: var(--text-secondary);
  text-align: left;
  white-space: nowrap;
}

.tbl td {
  height: 48px;
  padding: 0 var(--space-3);
  border-bottom: 1px solid var(--border-default);
  font-size: var(--fs-body);
  color: var(--text-primary);
  vertical-align: middle;
}

.tbl tbody tr:last-child td {
  border-bottom: 0;
}

.tbl tbody tr:hover td {
  background: var(--bg-page);
}

.tbl tbody tr.is-selected td {
  background: var(--primary-50);
}

.tbl--compact td {
  height: 40px;
  padding-top: 4px;
  padding-bottom: 4px;
  font-size: var(--fs-small);
}

.tbl--compact th {
  height: 40px;
}

.tbl .col-check {
  width: 44px;
  padding-right: 0;
  text-align: center;
}

.tbl .col-num {
  text-align: right;
}

.tbl .col-actions {
  text-align: right;
}

.tbl .col-first {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--white);
}

.tbl th.col-first {
  z-index: 3;
  background: var(--bg-subtle);
}

.tbl .col-actions {
  position: sticky;
  right: 0;
  z-index: 1;
  background: var(--white);
  box-shadow: -8px 0 12px -12px var(--text-secondary);
}

.tbl th.col-actions {
  z-index: 3;
  background: var(--bg-subtle);
}

.tbl .col-cd {
  position: sticky;
  /* 紧贴右侧冻结的操作列（工单表操作列宽 130px），避免两列之间露出被遮内容 */
  right: 130px;
  z-index: 1;
  background: var(--white);
}

.tbl th.col-cd {
  z-index: 3;
  background: var(--bg-subtle);
}

.tbl tbody tr:hover td.col-first,
.tbl tbody tr:hover td.col-actions,
.tbl tbody tr:hover td.col-cd {
  background: var(--bg-page);
}

.tbl tbody tr.is-selected td.col-first,
.tbl tbody tr.is-selected td.col-actions,
.tbl tbody tr.is-selected td.col-cd {
  background: var(--primary-50);
}

.tbl .cell-wrap {
  white-space: normal;
  line-height: var(--lh-small);
  padding-top: var(--space-2);
  padding-bottom: var(--space-2);
}

.checkbox {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--primary-600);
  cursor: pointer;
}

.checkbox:disabled {
  cursor: not-allowed;
}

.table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 56px;
  padding: var(--space-2) var(--space-4);
  border-top: 1px solid var(--border-default);
  font-size: var(--fs-small);
  color: var(--text-secondary);
}

/* ---------- 提示条 ---------- */
.notice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  font-size: var(--fs-small);
  line-height: var(--lh-small);
}

.notice svg {
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 2px;
}

.notice--info {
  background: var(--badge-sky-bg);
  border-color: var(--notice-info-border);
  color: var(--notice-info-text);
}

.notice--warn {
  background: var(--badge-amber-bg);
  border-color: var(--notice-warn-border);
  color: var(--notice-warn-text);
}

.notice--success {
  background: var(--badge-emerald-bg);
  border-color: var(--notice-success-border);
  color: var(--notice-success-text);
}

.notice--danger {
  background: var(--badge-red-bg);
  border-color: var(--notice-danger-border);
  color: var(--notice-danger-text);
}

.notice__body {
  flex: 1;
  min-width: 0;
}

.notice__title {
  font-weight: 600;
}

/* ---------- 空态 / 骨架屏（UI §4.9） ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-8) var(--space-6);
  text-align: center;
}

.empty-state__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  color: var(--text-weak);
}

.empty-state__icon svg {
  width: 24px;
  height: 24px;
}

.empty-state__title {
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-weight: 600;
  color: var(--text-primary);
}

.empty-state__desc {
  max-width: 420px;
  font-size: var(--fs-small);
  line-height: var(--lh-small);
  color: var(--text-secondary);
}

.empty-state--error .empty-state__icon {
  background: var(--badge-red-bg);
  color: var(--danger);
}

.skel {
  display: block;
  height: 12px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--bg-subtle) 25%, var(--border-default) 37%, var(--bg-subtle) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}

.skel--sm {
  width: 40%;
}

.skel--md {
  width: 65%;
}

.skel-row td {
  height: 48px;
}

.skel-tree {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
}

@keyframes shimmer {
  0% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0 50%;
  }
}

/* ---------- 标签页（UI §4.8） ---------- */
.tabs {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  height: 40px;
  border-bottom: 1px solid var(--border-default);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 40px;
  padding: 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  font-size: var(--fs-body);
  font-weight: 500;
  color: var(--text-secondary);
}

.tab:hover {
  color: var(--text-primary);
}

.tab--active {
  color: var(--primary-600);
  border-bottom-color: var(--primary-600);
}

.tab__pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  background: var(--text-weak);
  color: var(--white);
  font-size: var(--fs-overline);
  font-weight: 600;
  line-height: 1;
}

.tab--active .tab__pill {
  background: var(--primary-600);
}

/* ---------- 筛选 chips（UI §6 U-6-7） ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  min-height: 26px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: 26px;
  padding: 0 var(--space-2);
  border: 0;
  border-radius: var(--radius-full);
  background: var(--primary-50);
  color: var(--primary-600);
  font-size: var(--fs-caption);
  line-height: 1;
}

.chip__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary-500);
}

.chip__close svg {
  width: 12px;
  height: 12px;
}

.chip__close:hover {
  color: var(--primary-700);
}

.chip--ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 0;
}

/* ---------- Toast（UI §4.6：top 120px，避开页面操作按钮行） ---------- */
.toast {
  position: fixed;
  /* [U-06] UI 规范 U-4-18 写 120px，但实测 1440×1000 下 .ph-actions 按钮底边为 126px，
     120 会压住按钮 6px。按「必须位于操作按钮行之下」的规范意图改 132px，并登记冲突。 */
  top: 132px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: 360px;
  max-width: calc(100vw - 48px);
  pointer-events: none;
}

.toast__item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: 14px 16px;
  border-left: 3px solid var(--info);
  border-radius: var(--radius-xl);
  background: var(--white);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--text-primary);
  pointer-events: auto;
  animation: toastIn .2s ease;
}

.toast__icon {
  flex: none;
  margin-top: 3px;
  color: var(--info);
}

.toast__icon svg {
  width: 16px;
  height: 16px;
}

.toast__text {
  flex: 1;
  min-width: 0;
}

.toast__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-weak);
}

.toast__close:hover {
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.toast__close svg {
  width: 12px;
  height: 12px;
}

.toast__item--success {
  border-left-color: var(--success);
}

.toast__item--success .toast__icon {
  color: var(--success);
}

.toast__item--warn {
  border-left-color: var(--warning);
}

.toast__item--warn .toast__icon {
  color: var(--warning);
}

.toast__item--error {
  border-left-color: var(--danger);
}

.toast__item--error .toast__icon {
  color: var(--danger);
}

.toast__item--info {
  border-left-color: var(--info);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- 模态 / 抽屉（UI §4.5） ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background: var(--overlay-modal);
  animation: fadeIn .15s ease;
}

.overlay--drawer {
  align-items: stretch;
  justify-content: flex-end;
  padding: 0;
  background: var(--overlay-drawer);
}

.modal {
  width: 480px;
  max-width: 100%;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-2xl);
  background: var(--white);
  box-shadow: var(--shadow-lg);
  animation: popIn .18s ease;
}

.modal--wide {
  width: 640px;
}

.modal__head {
  padding: var(--space-6) var(--space-6) 0;
}

.modal__title {
  font-size: var(--fs-h2);
  line-height: var(--lh-h2);
  font-weight: 600;
  color: var(--text-title);
}

.modal__body {
  padding: var(--space-4) var(--space-6);
  overflow: auto;
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--text-primary);
}

.modal__foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: 0 var(--space-6) var(--space-6);
}

.modal__danger {
  margin-top: var(--space-3);
  color: var(--danger);
  font-weight: 500;
}

.drawer {
  display: flex;
  flex-direction: column;
  width: 480px;
  max-width: 92vw;
  height: 100%;
  background: var(--white);
  box-shadow: var(--shadow-lg);
  animation: slideIn .22s ease;
}

.drawer__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-6) var(--space-6) var(--space-4);
  border-bottom: 1px solid var(--border-default);
}

.drawer__title {
  font-size: var(--fs-h2);
  line-height: var(--lh-h2);
  font-weight: 600;
  color: var(--text-title);
}

.drawer__sub {
  margin-top: var(--space-1);
  font-size: var(--fs-small);
  line-height: var(--lh-small);
  color: var(--text-secondary);
}

.drawer__body {
  flex: 1;
  overflow: auto;
  padding: 20px var(--space-6);
}

.drawer__foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-default);
}

.modal__close,
.drawer__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-weak);
}

.modal__close:hover,
.drawer__close:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.modal__close svg,
.drawer__close svg {
  width: 16px;
  height: 16px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(.97);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideIn {
  from {
    transform: translateX(24px);
    opacity: .6;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ---------- 详情键值对 ---------- */
.dl {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: var(--space-3) var(--space-4);
  margin: 0;
  font-size: var(--fs-small);
  line-height: var(--lh-small);
}

.dl dt {
  color: var(--text-secondary);
}

.dl dd {
  margin: 0;
  min-width: 0;
  color: var(--text-primary);
  word-break: break-word;
}

.dl--body {
  font-size: var(--fs-body);
  line-height: var(--lh-body);
}

.dl__block {
  grid-column: 1 / -1;
}

.section-title {
  margin: var(--space-6) 0 var(--space-3);
  font-size: var(--fs-h2);
  line-height: var(--lh-h2);
  font-weight: 600;
  color: var(--text-title);
}

.section-title:first-child {
  margin-top: 0;
}

/* ---------- 底部浮出条 ---------- */
.footer-bar {
  position: fixed;
  bottom: var(--space-6);
  left: calc(50% + var(--sidebar-w) / 2);
  z-index: 150;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-width: 420px;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-2xl);
  background: var(--white);
  box-shadow: var(--shadow-lg);
  transform: translateX(-50%);
  animation: popIn .18s ease;
}

.footer-bar__count {
  font-size: var(--fs-small);
  color: var(--text-secondary);
  white-space: nowrap;
}

.footer-bar__spacer {
  flex: 1;
}

/* ---------- 分页 ---------- */
.pager {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-small);
  color: var(--text-secondary);
}

.pager__size {
  width: 88px;
  height: 30px;
  padding: 0 var(--space-2);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--white);
  font-size: var(--fs-small);
}

.pager__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 var(--space-2);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--white);
  color: var(--text-primary);
  font-size: var(--fs-small);
}

.pager__btn:hover:not(:disabled) {
  background: var(--bg-page);
  border-color: var(--border-strong);
}

.pager__btn:disabled {
  color: var(--text-weak);
  cursor: not-allowed;
}

.pager__btn--active {
  background: var(--primary-600);
  border-color: var(--primary-600);
  color: var(--white);
}

/* ---------- 应用骨架（UI §5） ---------- */
.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  flex: none;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-w);
  height: 100vh;
  overflow-y: auto;
  background: var(--nav-dark);
}

.sidebar__logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: none;
  height: var(--topbar-h);
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--nav-border);
  color: var(--white);
}

.sidebar__logo svg {
  flex: none;
  width: 20px;
  height: 20px;
  color: var(--primary-500);
}

.sidebar__brand {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar__brand strong {
  font-size: var(--fs-body);
  line-height: var(--lh-small);
  font-weight: 600;
  white-space: nowrap;
}

.sidebar__brand span {
  font-size: var(--fs-overline);
  line-height: var(--lh-overline);
  letter-spacing: .08em;
  color: var(--text-weak);
  white-space: nowrap;
}

.sidebar__nav {
  padding: var(--space-2) var(--space-3) var(--space-4);
}

.sidebar__group {
  margin-top: var(--space-2);
}

.sidebar__group-title {
  padding: var(--space-2) var(--space-3);
  font-size: var(--fs-overline);
  line-height: var(--lh-overline);
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--text-weak);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: 40px;
  margin-bottom: var(--space-1);
  padding: 0 var(--space-3);
  border-radius: var(--radius-lg);
  color: var(--text-weak);
  font-size: var(--fs-body);
}

.nav-item svg {
  flex: none;
  width: 20px;
  height: 20px;
}

.nav-item:hover {
  background: var(--nav-hover);
  color: var(--white);
}

.nav-item--active,
.nav-item--active:hover {
  background: var(--primary-600);
  color: var(--white);
}

.nav-item--static {
  cursor: default;
  opacity: .55;
}

.nav-item--static:hover {
  background: transparent;
  color: var(--text-weak);
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: var(--topbar-h);
  padding: 0 var(--space-6);
  background: var(--white);
  border-bottom: 1px solid var(--border-default);
}

.topbar__crumbs {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  font-size: var(--fs-body);
  color: var(--text-secondary);
  white-space: nowrap;
}

.topbar__crumbs strong {
  font-weight: 400;
  color: var(--text-primary);
}

.topbar__search {
  width: 300px;
  height: 36px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--bg-page);
  font-size: var(--fs-body);
  color: var(--text-primary);
  outline: none;
}

.topbar__search::placeholder {
  color: var(--text-weak);
}

.topbar__search:focus {
  border-color: var(--primary-600);
  box-shadow: 0 0 0 2px var(--focus-ring);
}

.topbar__spacer {
  flex: 1;
}

.topbar__user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  font-size: var(--fs-small);
  color: var(--text-secondary);
  white-space: nowrap;
}

.topbar__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--primary-50);
  color: var(--primary-700);
  font-size: var(--fs-body);
  font-weight: 600;
}

.topbar__name {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.topbar__logout {
  display: inline-flex;
}

.topbar__logout .btn--ghost {
  font-size: var(--fs-small);
  color: var(--text-secondary);
}

.topbar__logout .btn--ghost:hover {
  color: var(--danger);
}

.content {
  flex: 1;
  min-width: 0;
  padding: var(--space-6);
}

.page {
  max-width: 1440px;
  margin: 0 auto;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 56px;
  margin-bottom: var(--space-4);
}

.page-head__main {
  min-width: 0;
}

.page-head__title {
  font-size: var(--fs-h1);
  line-height: var(--lh-h1);
  font-weight: 600;
  color: var(--text-title);
}

.page-head__desc {
  margin-top: var(--space-1);
  font-size: var(--fs-small);
  line-height: var(--lh-small);
  color: var(--text-secondary);
}

.ph-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: none;
}

/* ---------- 登录页 ---------- */
.login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-6);
  background: var(--bg-page);
}

.login__card {
  width: 100%;
  max-width: 400px;
  padding: var(--space-8);
  background: var(--white);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
}

.login__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--primary-600);
  font-size: var(--fs-small);
  font-weight: 500;
}

.login__brand svg {
  flex: none;
  width: 20px;
  height: 20px;
}

.login__title {
  margin-top: var(--space-6);
  font-size: var(--fs-h1);
  line-height: var(--lh-h1);
  font-weight: 600;
  color: var(--text-title);
}

.login__subtitle {
  margin-top: var(--space-1);
  font-size: var(--fs-small);
  line-height: var(--lh-small);
  color: var(--text-secondary);
}

.login__notice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--notice-danger-border);
  border-radius: var(--radius-lg);
  background: var(--badge-red-bg);
  color: var(--notice-danger-text);
  font-size: var(--fs-small);
  line-height: var(--lh-small);
}

.login__notice svg {
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 2px;
}

.login__notice--success {
  border-color: var(--notice-success-border);
  background: var(--badge-emerald-bg);
  color: var(--notice-success-text);
}

.login__form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-top: var(--space-6);
}

.login__submit {
  width: 100%;
  margin-top: var(--space-2);
}

.login__footer {
  margin-top: var(--space-6);
  font-size: var(--fs-caption);
  line-height: var(--lh-caption);
  color: var(--text-weak);
  text-align: center;
}

/* ---------- 断点（UI §5 U-5-6） ---------- */
@media (max-width: 1280px) {
  :root {
    --sidebar-w: 220px;
  }

  .topbar__search {
    width: 200px;
  }

  /* 1280：上传页工具栏新增「上传文件夹」后，220px 搜索框会把刷新按钮挤出卡片 9px；
     按 ≤1280 搜索框 200px 的既有断点口径同步收窄。 */
  .toolbar .input {
    width: 200px;
  }

  .topbar__name {
    max-width: 110px;
  }

  .content {
    padding: var(--space-4);
  }

}
