:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-soft: #f7f8fa;
  --line: #d9dfe5;
  --line-strong: #c4ccd4;
  --ink: #1f2933;
  --muted: #6b7785;
  --teal: #0f766e;
  --teal-dark: #0b5f59;
  --blue: #1769aa;
  --amber: #c56a09;
  --amber-soft: #fff4d8;
  --danger: #b42318;
  --success: #137a50;
  --shadow: 0 8px 24px rgba(31, 41, 51, .08);
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  font-size: 14px;
}

body { overflow-x: hidden; }

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, .10), transparent 45%),
    linear-gradient(315deg, rgba(23, 105, 170, .08), transparent 42%),
    var(--bg);
}

.login-panel {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-lockup > div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-lockup h1,
.brand-lockup p {
  margin: 0;
}

.brand-lockup h1 { font-size: 21px; line-height: 1.3; }
.brand-lockup p { color: var(--muted); margin-top: 5px; font-size: 13px; }
.brand-lockup.compact { gap: 10px; }
.brand-lockup.compact > div { min-width: 0; }
.brand-lockup.compact strong { font-size: 15px; }

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-size: 22px;
  font-weight: 800;
}

.login-panel .brand-lockup { margin-bottom: 26px; }

/* 🔧 2026-11-21 FR-270：登录密码显示切换 + 记住用户名密码 */
.password-wrap { position: relative; display: flex; }
.password-wrap input { padding-right: 34px; }
.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  color: #6b7a89;
  padding: 2px;
}
.password-toggle:hover { color: var(--teal); }
.login-remember { margin: -4px 0 14px; }

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 15px;
  color: #384553;
  font-size: 13px;
}

.field input,
.asset-filters input,
.asset-filters select,
.inline-field select,
.form-toolbar input,
.field-control {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  outline: none;
  padding: 9px 10px;
  transition: border-color .15s, box-shadow .15s;
}

.field input:focus,
.asset-filters input:focus,
.asset-filters select:focus,
.inline-field select:focus,
.form-toolbar input:focus,
.field-control:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .12);
}

.button {
  border: 1px solid transparent;
  border-radius: 6px;
  min-height: 36px;
  padding: 7px 14px;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}

.button.primary { background: var(--teal); color: #fff; }
.button.primary:hover { background: var(--teal-dark); }
.button.secondary { background: var(--blue); color: #fff; }
.button.secondary:hover { background: #12578f; }
.button.ghost { background: #fff; border-color: var(--line-strong); color: var(--ink); }
.button.ghost:hover { border-color: var(--teal); color: var(--teal); }
.button.small { min-height: 30px; padding: 4px 9px; font-size: 12px; }
.button.wide { width: 100%; }
.button:disabled { opacity: .5; cursor: not-allowed; }

/* 🔧 v6（需求书_网络版 11.2）：顶栏「维护管理」入口（a 元素复用按钮样式，去链接默认样式） */
.admin-nav { display: inline-flex; align-items: center; text-decoration: none; }

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 17px;
  line-height: 1;
}

.icon-button:hover { border-color: var(--teal); color: var(--teal); }

.form-error {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 12px;
}

.app-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 9px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.header-actions,
.editor-actions,
.image-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.inline-field {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.inline-field select { width: 170px; padding: 6px 8px; }

.user-chip {
  min-width: 0;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid #c9ddd9;
  border-radius: 999px;
  background: #eef8f6;
  color: var(--teal-dark);
  padding: 5px 10px;
  font-size: 12px;
}

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, 350px) minmax(0, 1fr);
}

.asset-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.panel-heading {
  min-height: 58px;
  padding: 12px 14px 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-heading h2 {
  margin: 0 0 3px;
  font-size: 16px;
}

.asset-filters {
  display: grid;
  grid-template-columns: 1fr 118px;
  gap: 8px;
  padding: 0 14px 12px;
  border-bottom: 1px solid var(--line);
}

.asset-filters > input { grid-column: 1 / -1; }
.asset-filters select { padding: 7px 8px; }
/* 🔒 L3 包装编号筛选下拉独占一行 */
.asset-filters select#l3Filter { grid-column: 1 / -1; }

/* 🔒 锁操作行：开始著录 / 释放所选 / 提示 */
.lock-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 0;
}

.lock-actions .muted { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 🔒 清单表头（全选本页） */
.asset-list-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  padding: 8px 14px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}

.checkbox-line {
  grid-column: 1 / -1;
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.checkbox-line input { accent-color: var(--teal); }

.asset-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.asset-row {
  width: 100%;
  display: grid;
  grid-template-columns: 26px 54px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: start;
  padding: 11px 14px;
  border: 0;
  border-bottom: 1px solid #edf0f3;
  background: #fff;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.asset-row:hover { background: #f4f9f8; }
.asset-row.active { background: #e9f5f2; box-shadow: inset 3px 0 0 var(--teal); }

/* 🔒 他人锁定：琥珀色浅底提示只读；本人锁定：teal 浅底 */
.asset-row.locked-other { background: #fffaf0; }
.asset-row.locked-other:hover { background: #fdf3e0; }
.asset-row.locked-mine { background: #f2faf8; }
.asset-row.locked-mine.active { background: #e9f5f2; }

.row-check {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
}

.row-check input { accent-color: var(--teal); width: 16px; height: 16px; cursor: pointer; }

.lock-meta { color: var(--amber); font-weight: 600; }
.asset-row.locked-mine .lock-meta { color: var(--teal-dark); }

.asset-row-code {
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--blue);
}

.asset-row-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.asset-row-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.asset-row-meta { color: var(--muted); font-size: 11px; }

.status-tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  white-space: nowrap;
  background: #edf0f3;
  color: #52606d;
}

.status-tag.cataloging { background: #fff0d6; color: #8a5200; }
.status-tag.done { background: #e2f5eb; color: var(--success); }
.status-tag.counted { background: #e8f1ff; color: #185ea5; }

/* 🔒 编辑器锁徽标：unlocked(灰)/mine(teal)/other(琥珀)/none(灰) */
.lock-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  white-space: nowrap;
  background: #edf0f3;
  color: #52606d;
}

.lock-badge.mine { background: #e2f5eb; color: var(--success); font-weight: 600; }
.lock-badge.other { background: #fff0d6; color: #8a5200; font-weight: 600; }
.lock-badge.unlocked { background: #eef1f4; color: var(--muted); }

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}

.editor-panel {
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}

.empty-editor {
  height: 100%;
  display: grid;
  place-content: center;
  gap: 8px;
  text-align: center;
  color: var(--muted);
}

.empty-editor strong { color: var(--ink); font-size: 18px; }

.editor-view {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.editor-toolbar {
  min-height: 62px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.asset-identity {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.asset-code {
  font-family: Consolas, monospace;
  font-size: 12px;
  color: var(--blue);
}

#editorTitle {
  min-width: 0;
  max-width: 380px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
}

.editor-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(420px, 46%) minmax(0, 54%);
}

.image-workbench {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #111820;
}

.image-toolbar {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}

.image-stage {
  position: relative;
  flex: 1;
  min-height: 280px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 50%, #1c2732, #0c1116 70%);
  touch-action: none;
  cursor: grab;
}

.image-stage.dragging { cursor: grabbing; }

.image-stage img {
  position: absolute;
  left: 50%;
  top: 50%;
  display: none;
  max-width: none;
  user-select: none;
  transform-origin: center center;
  will-change: transform;
}

.image-stage img.is-visible { display: block; }

.image-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #9ca7b2;
  font-size: 13px;
  pointer-events: none;
}

.ocr-panel {
  max-height: 32%;
  overflow: auto;
  background: #fff;
  border-top: 1px solid var(--line);
}

.ocr-panel summary {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 40px;
  padding: 5px 10px;
  background: #fff;
  border-bottom: 1px solid #edf0f3;
  cursor: pointer;
  font-weight: 600;
}

.ocr-panel pre {
  margin: 0;
  padding: 10px 12px 14px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #384553;
  font-family: "Microsoft YaHei", sans-serif;
  font-size: 12px;
  line-height: 1.65;
}

.form-workbench {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.form-toolbar {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.form-toolbar input { max-width: 260px; }

.field-groups {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 4px 14px 24px;
}

.field-group {
  padding: 14px 0 8px;
  border-bottom: 1px solid #edf0f3;
}

.field-group:last-child { border-bottom: 0; }

.field-group h3 {
  margin: 0 0 11px;
  color: #344250;
  font-size: 13px;
  letter-spacing: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px 14px;
}

.field-item {
  min-width: 0;
}

.field-item.wide { grid-column: 1 / -1; }

.field-label {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 5px;
  color: #52606d;
  font-size: 12px;
}

.required-star { color: var(--danger); }

.field-control {
  min-height: 36px;
  padding: 7px 9px;
  resize: vertical;
}

textarea.field-control {
  min-height: 74px;
  line-height: 1.55;
}

.ocr-hint {
  margin-top: 5px;
  display: flex;
  align-items: flex-start;
  gap: 7px;
  min-width: 0;
  color: #7d590e;
  font-size: 11px;
  line-height: 1.45;
}

.ocr-hint button {
  flex: 0 0 auto;
  border: 0;
  border-radius: 4px;
  background: var(--amber-soft);
  color: var(--amber);
  padding: 2px 6px;
  font-size: 11px;
}

.ocr-hint span {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* 🔥 v269 2026-11-21 新增：AI 著录字段徽标（淡紫底 + 深紫字，与 CS 端 AI 淡紫色规范一致）——仅追加，不修改既有规则 */
.ai-badge {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 5px;
  border-radius: 3px;
  background: #e6e6fa;
  color: #4b0082;
  font-size: 10px;
  font-weight: 600;
  vertical-align: middle;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  max-width: min(420px, calc(100vw - 36px));
  padding: 10px 14px;
  border-radius: 7px;
  background: #23313d;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity .18s, transform .18s;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #8f2018; }

.loading-row,
.empty-row {
  padding: 24px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 310px minmax(0, 1fr); }
  .editor-grid { grid-template-columns: minmax(360px, 42%) minmax(0, 58%); }
  .field-grid { grid-template-columns: 1fr; }
  .field-item.wide { grid-column: auto; }
  #editorTitle { max-width: 220px; }
  #editorUser { display: none; }
}

@media (max-width: 860px) {
  .app-header { align-items: flex-start; flex-wrap: wrap; padding: 9px 10px; }
  .header-actions { width: 100%; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
  .brand-lockup.compact { max-width: 100%; }
  .workspace { display: flex; flex-direction: column; min-height: auto; }
  .asset-panel { max-height: 40vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .editor-panel { min-height: 70vh; }
  .editor-view { height: auto; }
  .editor-toolbar { align-items: flex-start; flex-direction: column; }
  .editor-actions { width: 100%; flex-wrap: wrap; }
  .asset-identity { flex-wrap: wrap; }
  #editorTitle { max-width: 100%; }
  .editor-grid { display: flex; flex-direction: column; }
  .image-workbench { min-height: 52vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .image-stage { min-height: 360px; }
  .form-workbench { min-height: 60vh; }
  .image-tools { flex-wrap: wrap; }
  .field-grid { grid-template-columns: 1fr; }
  .field-item.wide { grid-column: auto; }
}

@media (max-width: 520px) {
  .login-panel { padding: 22px; }
  .asset-filters { grid-template-columns: 1fr; }
  .asset-filters input,
  .asset-filters select,
  .checkbox-line { grid-column: auto; }
  .asset-row { grid-template-columns: 26px 48px minmax(0, 1fr); }
  .asset-row .status-tag { grid-column: 2; justify-self: start; }
  .form-toolbar { align-items: stretch; flex-direction: column; }
  .form-toolbar input { max-width: none; }
}
