/* ============================================================
   产品测试记录与辅助样品查询 - 样式
   浅色 / 深色主题通过 <html data-theme="dark"> 切换
   ============================================================ */

:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1a2332;
  --muted: #667085;
  --border: #e3e8f0;
  --input-bg: #ffffff;
  --header-bg: rgba(255, 255, 255, 0.88);
  --hover: #f7f9fc;
  --table-head: #f8fafc;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #edf3ff;
  --focus-ring: rgba(37, 99, 235, 0.16);

  --pass: #15803d;
  --pass-bg: #e8f7ee;
  --pass-border: #b3e3c4;
  --fail: #d92d20;
  --fail-bg: #fdecea;
  --fail-border: #f3bfb9;
  --warn: #b45309;
  --warn-bg: #fff5e5;
  --warn-border: #f3d3a1;

  --tag-bg: #f1f4f9;
  --tag-text: #475467;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 10px 28px rgba(16, 24, 40, 0.07);
  --radius: 12px;

  /* 搭配图 */
  --diagram-bg: #fbfcfe;
  --diagram-grid: rgba(37, 99, 235, 0.07);
  --node-thumb-bg: #f4f6fa;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1219;
  --card: #151c25;
  --text: #e6edf6;
  --muted: #93a1b5;
  --border: #263241;
  --input-bg: #0f161f;
  --header-bg: rgba(13, 18, 25, 0.88);
  --hover: #1a2330;
  --table-head: #182130;
  --primary: #4f8cff;
  --primary-hover: #6aa1ff;
  --primary-soft: #16263f;
  --focus-ring: rgba(79, 140, 255, 0.22);

  --pass: #4ade80;
  --pass-bg: rgba(34, 197, 94, 0.13);
  --pass-border: rgba(74, 222, 128, 0.32);
  --fail: #f87171;
  --fail-bg: rgba(239, 68, 68, 0.14);
  --fail-border: rgba(248, 113, 113, 0.32);
  --warn: #fbbf24;
  --warn-bg: rgba(245, 158, 11, 0.14);
  --warn-border: rgba(251, 191, 36, 0.32);

  --tag-bg: #1e2836;
  --tag-text: #aebed2;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.35);

  /* 搭配图 */
  --diagram-bg: #101821;
  --diagram-grid: rgba(79, 140, 255, 0.1);
  --node-thumb-bg: #1a2330;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
    "PingFang SC", "Hiragino Sans GB", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  transition: background-color 0.2s ease, color 0.2s ease;
}

body.modal-open {
  overflow: hidden;
}

h1, h2, h3, h4, p {
  margin: 0;
}

button {
  font: inherit;
}

/* ------------------------- 顶部栏 ------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.5px;
}

.brand-text h1 {
  font-size: 16px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-text .sub {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

/* ------------------------- 通用按钮 ------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease,
    color 0.15s ease, transform 0.05s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background: var(--primary);
  color: #fff;
}

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

.btn.ghost {
  border-color: var(--border);
  background: var(--card);
  color: var(--text);
}

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

.btn.tiny {
  padding: 4px 9px;
  border-color: var(--border);
  background: var(--card);
  font-size: 12px;
  color: var(--muted);
}

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

.btn.tiny.danger:hover {
  border-color: var(--fail);
  color: var(--fail);
  background: var(--fail-bg);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--hover);
  color: var(--text);
}

/* ------------------------- 页面布局 ------------------------- */

main {
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px 24px 64px;
}

.filter-card,
.table-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.filter-card {
  padding: 16px 18px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px 14px;
}

.keyword-field {
  grid-column: span 2;
}

.filter-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field > span,
.field > label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

/* 字段标题行：左边标题，右边「新增 / 勾选填入」等轻量操作 */
.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field-hint {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  opacity: 0.9;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 400;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.check input {
  width: auto;
  margin: 0;
  accent-color: var(--primary);
}

.link-btn {
  padding: 0;
  border: none;
  background: none;
  color: var(--primary);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
}

.link-btn:hover {
  text-decoration: underline;
}

.required {
  color: var(--fail);
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease,
    background-color 0.2s ease;
}

textarea {
  resize: vertical;
  min-height: 64px;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

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

/* ------------------------- 列表信息 ------------------------- */

.list-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 2px 10px;
  color: var(--muted);
  font-size: 13px;
}

.list-meta #resultCount {
  color: var(--text);
  font-weight: 600;
}

.list-meta .hint {
  font-size: 12px;
}

/* ------------------------- 表格 ------------------------- */

.table-card {
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 940px;
  border-collapse: collapse;
}

thead th {
  padding: 11px 14px;
  background: var(--table-head);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

tbody td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

.record-row {
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.record-row:hover {
  background: var(--hover);
}

.record-row.open {
  background: var(--primary-soft);
}

.strong {
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
}

.sub-line {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.col-product {
  min-width: 150px;
}

.col-item {
  min-width: 180px;
}

.col-result {
  width: 108px;
}

.col-aux {
  min-width: 260px;
  max-width: 360px;
}

.col-date {
  width: 112px;
  white-space: nowrap;
}

.col-engineer {
  width: 92px;
  white-space: nowrap;
}

.col-actions {
  width: 176px;
}

.nowrap {
  white-space: nowrap;
}

.row-actions {
  display: flex;
  gap: 6px;
}

/* ------------------------- 结论徽标 / 标签 ------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge.pass {
  color: var(--pass);
  background: var(--pass-bg);
  border-color: var(--pass-border);
}

.badge.fail {
  color: var(--fail);
  background: var(--fail-bg);
  border-color: var(--fail-border);
}

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

.tag {
  display: inline-block;
  max-width: 100%;
  margin: 2px 4px 2px 0;
  padding: 1px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: 12px;
  line-height: 1.7;
  word-break: break-word;
}

.tag.more {
  border-style: dashed;
  cursor: default;
}

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

/* ------------------------- 展开详情 ------------------------- */

.detail-row > td {
  padding: 0;
  background: var(--hover);
  border-bottom: 1px solid var(--border);
}

.detail {
  padding: 18px 20px 20px;
  display: grid;
  gap: 18px;
}

.detail-section h4 {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px 18px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.detail-item.full {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
}

.detail-label {
  color: var(--muted);
  font-size: 11.5px;
}

.detail-value {
  color: var(--text);
  font-size: 13px;
  word-break: break-word;
}

.detail-value a {
  color: var(--primary);
  text-decoration: none;
  word-break: break-all;
}

.detail-value a:hover {
  text-decoration: underline;
}

.detail-item.full .detail-value {
  margin-top: 2px;
}

/* ------------------------- 空状态 ------------------------- */

.empty {
  padding: 56px 20px;
  text-align: center;
  color: var(--muted);
}

.empty p {
  margin-bottom: 4px;
  color: var(--text);
  font-weight: 600;
}

/* ------------------------- 弹窗 ------------------------- */

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 20px;
  background: rgba(8, 12, 20, 0.55);
  backdrop-filter: blur(3px);
  overflow-y: auto;
}

.modal {
  width: 100%;
  max-width: 860px;
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
  animation: modal-in 0.16s ease-out;
}

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

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 {
  font-size: 16px;
  font-weight: 650;
}

.modal-body {
  padding: 18px 20px 6px;
  overflow-y: auto;
}

.form-section + .form-section {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px dashed var(--border);
}

.form-section h3 {
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
}

.section-tip {
  margin-left: 8px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 400;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
}

.span-2 {
  grid-column: span 2;
}

.suggest-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 96px;
  padding: 2px 0;
  overflow-y: auto;
}

.chip {
  padding: 2px 9px;
  border: 1px dashed var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.chip:hover {
  border-color: var(--primary);
  border-style: solid;
  background: var(--primary-soft);
  color: var(--primary);
}

.chip.active {
  border-style: solid;
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

/* ------------------------- 提示 ------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 200;
  transform: translateX(-50%);
  max-width: min(90vw, 480px);
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toast-in 0.18s ease-out;
}

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

.toast.error {
  border-left-color: var(--fail);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* ------------------------- 响应式 ------------------------- */

@media (max-width: 900px) {
  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar {
    flex-wrap: wrap;
    padding: 12px 14px;
  }

  .brand-text .sub {
    display: none;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions .btn {
    flex: 1;
  }

  main {
    padding: 14px 12px 48px;
  }

  .filter-card {
    padding: 14px;
  }

  .keyword-field {
    grid-column: span 1;
  }

  .filter-actions .btn {
    flex: 1;
  }

  .list-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .list-meta .hint {
    display: none;
  }

  .modal-mask {
    padding: 0;
  }

  .modal {
    max-width: none;
    max-height: 100vh;
    min-height: 100vh;
    border: none;
    border-radius: 0;
  }

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

  .span-2 {
    grid-column: span 1;
  }

  .detail {
    padding: 14px;
  }

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

/* ============================================================
   辅助搭配连接图
   ============================================================ */

.diagram-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.diagram-field-head > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.diagram-field-actions {
  display: flex;
  gap: 6px;
}

.diagram-preview {
  min-width: 0;
}

.diagram-scroll {
  overflow-x: auto;
  border-radius: 12px;
}

/* 画布：逻辑尺寸 1000 x 620，节点按百分比定位，窄屏横向滚动 */
.diagram-stage {
  position: relative;
  width: 100%;
  min-width: 680px;
  aspect-ratio: 1000 / 620;
  container-type: inline-size;
  border: 1px solid var(--border);
  border-radius: 12px;
  background-color: var(--diagram-bg);
  background-image: linear-gradient(var(--diagram-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--diagram-grid) 1px, transparent 1px);
  background-size: 30px 30px;
  overflow: hidden;
}

.diagram-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.diagram-svg path {
  fill: none;
  stroke-linecap: round;
}

.diagram-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.diagram-label {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 1px 8px;
  border: 1px solid currentColor;
  border-radius: 999px;
  background: var(--card);
  font-size: clamp(9px, 1.15cqw, 12px);
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
  pointer-events: auto;
}

.diagram-label.editable {
  cursor: pointer;
  font-family: inherit;
}

.diagram-label.editable:hover,
.diagram-label.editable.active {
  box-shadow: 0 0 0 2px var(--focus-ring);
}

.diagram-nodes {
  position: absolute;
  inset: 0;
}

.diagram-node {
  position: absolute;
  width: 15%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 5px 6px 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  box-shadow: 0 2px 10px rgba(16, 24, 40, 0.08);
  text-align: center;
  user-select: none;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

/* 编辑器中可拖拽 */
.editor-stage .diagram-node {
  cursor: grab;
}

.diagram-node.main {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft),
    0 8px 20px rgba(37, 99, 235, 0.16);
}

.diagram-node.linking {
  border-color: var(--warn);
  border-style: dashed;
  box-shadow: 0 0 0 3px var(--warn-bg);
}

.diagram-node.dragging {
  z-index: 5;
  cursor: grabbing;
  box-shadow: 0 10px 26px rgba(16, 24, 40, 0.22);
}

.node-thumb {
  width: 100%;
  height: 7cqw;
  min-height: 40px;
  max-height: 82px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 7px;
  background: var(--node-thumb-bg);
  color: var(--muted);
  font-size: clamp(9px, 1.1cqw, 11.5px);
}

.node-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.node-name {
  font-size: clamp(10px, 1.3cqw, 13.5px);
  font-weight: 600;
  line-height: 1.25;
  word-break: break-word;
}

.node-model {
  min-height: 1em;
  color: var(--muted);
  font-size: clamp(9px, 1.1cqw, 12px);
  line-height: 1.25;
  word-break: break-word;
}

.node-role {
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font-size: clamp(8px, 1cqw, 10.5px);
  line-height: 1.6;
  white-space: nowrap;
}

.diagram-node.main .node-role {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.node-tools {
  position: absolute;
  top: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 3px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.diagram-node:hover .node-tools,
.diagram-node.linking .node-tools {
  opacity: 1;
  pointer-events: auto;
}

.node-tool {
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
  white-space: nowrap;
  cursor: pointer;
}

.node-tool:hover,
.node-tool.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.node-tool.danger:hover {
  border-color: var(--fail);
  background: var(--fail-bg);
  color: var(--fail);
}

.diagram-empty {
  padding: 18px 16px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--hover);
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}

.diagram-flag {
  display: inline-flex;
  align-items: center;
  margin: 2px 0 2px 2px;
  padding: 0 6px;
  border: 1px dashed var(--primary);
  border-radius: 6px;
  color: var(--primary);
  font-size: 11px;
  line-height: 1.7;
  white-space: nowrap;
}

.detail-diagram .diagram-stage {
  min-width: 620px;
}

/* 详情里的接口连接清单：接口名 -> 产品/配件 */
.interface-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 10px;
}

.interface-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  font-size: 12px;
}

.interface-port {
  padding: 0 6px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}

.interface-target {
  color: var(--text);
  word-break: break-word;
}

.detail-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 22px 20px;
  color: var(--muted);
  font-size: 13px;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.small {
  font-size: 12px;
}

/* ------------------------- 搭配图编辑器 ------------------------- */

.diagram-editor {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.de-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.de-head h2 {
  font-size: 16px;
  font-weight: 650;
}

.de-hint {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.de-actions {
  display: flex;
  gap: 8px;
  flex: none;
}

.de-body {
  flex: 1;
  min-height: 0;
  display: flex;
}

.de-sidebar {
  width: 320px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 16px;
  overflow-y: auto;
  background: var(--card);
  border-right: 1px solid var(--border);
}

.de-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.de-section h3 {
  font-size: 13px;
  font-weight: 650;
}

.de-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.de-row input {
  flex: 1 1 130px;
  min-width: 0;
}

.de-image-preview {
  width: 100%;
  height: 96px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--node-thumb-bg);
}

.de-image-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.de-library-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
}

.device-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.device-item:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.device-thumb {
  width: 36px;
  height: 36px;
  flex: none;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 6px;
  background: var(--tag-bg);
  color: var(--muted);
  font-size: 10px;
}

.device-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

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

.device-name {
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.device-sub {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.de-canvas-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  overflow: auto;
}

.de-canvas-wrap .diagram-stage {
  min-width: 820px;
  flex: none;
}

.edge-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.edge-toolbar-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.edge-toolbar input {
  flex: 1 1 180px;
  min-width: 120px;
}

.swatches {
  display: flex;
  gap: 6px;
}

.swatch {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  cursor: pointer;
}

.swatch.active {
  border-color: var(--text);
  box-shadow: inset 0 0 0 2px var(--card);
}

@media (max-width: 900px) {
  .de-body {
    flex-direction: column;
  }

  .de-sidebar {
    width: 100%;
    max-height: 46vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .de-canvas-wrap {
    padding: 14px;
  }

  .de-canvas-wrap .diagram-stage {
    min-width: 720px;
  }
}

/* ------------------------- 登录页 ------------------------- */

.login-page {
  min-height: 100vh;
}

.login-wrap {
  min-height: 100vh;
  max-width: none;
  margin: 0;
  padding: 24px;
  display: grid;
  place-items: center;
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 28px 26px 22px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.login-brand .logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  font-size: 15px;
}

.login-brand-text h1 {
  font-size: 18px;
  font-weight: 650;
}

.login-brand-text p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-submit {
  width: 100%;
  margin-top: 2px;
  padding: 10px 14px;
}

.login-error {
  padding: 8px 10px;
  border: 1px solid var(--fail-border);
  border-radius: 8px;
  background: var(--fail-bg);
  color: var(--fail);
  font-size: 12.5px;
}

.login-foot {
  margin-top: 18px;
  color: var(--muted);
  font-size: 11.5px;
  text-align: center;
}

/* ------------------------- 当前用户 / 导出弹窗 ------------------------- */

.user-chip {
  max-width: 160px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.small-modal {
  max-width: 520px;
}

.foot-spacer {
  flex: 1;
}

.quick-ranges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.export-hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

@media (max-width: 720px) {
  .top-actions {
    flex-wrap: wrap;
  }

  .user-chip {
    width: 100%;
    max-width: none;
    text-align: center;
  }

  .diagram-field-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .diagram-stage {
    min-width: 560px;
  }

  .de-head {
    padding: 10px 14px;
  }

  .de-actions {
    width: 100%;
  }

  .de-actions .btn {
    flex: 1;
  }

  .de-canvas-wrap .diagram-stage {
    min-width: 640px;
  }
}
