:root {
  color-scheme: light;
  /* 中性色阶（统一冷色调） */
  --bg: #f4f7fa;
  --surface: #ffffff;
  --surface-soft: #eef3f7;
  --surface-hover: #f8fbfd;
  --ink: #17222b;
  --ink-soft: #2b3a46;
  --muted: #5c6b78;
  --faint: #8b98a5;
  --line: #dbe3ea;
  --line-strong: #c3cfd9;
  /* 主色（teal）+ 辅助色 */
  --teal: #0f8b8d;
  --teal-dark: #0a6e72;
  --teal-soft: #e4f4f3;
  --accent-shadow: rgba(15, 139, 141, 0.22);
  /* 语义色 */
  --amber: #c77916;
  --amber-soft: #fff3d8;
  --danger: #b34141;
  --danger-soft: #fdeaea;
  --success: #1a9d5c;
  --success-soft: #e6f7ee;
  /* 圆角体系 */
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  /* 阴影体系 */
  --shadow-rest: 0 2px 8px rgba(23, 34, 43, 0.06);
  --shadow-raised: 0 6px 20px rgba(23, 34, 43, 0.1);
  --shadow: 0 18px 45px rgba(23, 34, 43, 0.1);
  /* 焦点环 */
  --focus-ring: 0 0 0 2px #fff, 0 0 0 4px var(--teal);
  --sidebar-width: 244px;
  font-family: "Microsoft YaHei UI", "PingFang SC", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

/* 全局焦点可见性 */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* 动效降级 */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  /* v4.1.16：禁止移动浏览器文字自动放大（text autosizing），
     否则窄视口下中文内容被放大导致布局超出屏幕宽度 */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

/* ---- 嵌入后台模式（移植新增）----
   从 FastAdmin 菜单进入时带 ?embed=1：后台自己的侧边栏已经在提供导航，
   再显示报价系统自带的侧边栏就是双份导航，故隐藏之，让工作区占满整个标签页。
   视图切换改由后台菜单驱动（菜单项带 ?view=xxx），库存数与「关于」移到顶栏。
   独立整页入口 /addons/quote 不带 embed，保持原样。 */
.app-shell.embed-mode {
  grid-template-columns: minmax(0, 1fr);
}

.app-shell.embed-mode .sidebar {
  display: none;
}

/* 注意特异性：这些元素同时带 .tool-button（单类，且在本文件更靠后定义），
   单写 .embed-only 会被它按顺序压过去，所以隐藏规则要写成 .app-shell .embed-only */
.app-shell .embed-only {
  display: none;
}

.app-shell.embed-mode .embed-only {
  display: inline-flex;
}

/* 嵌入模式下顶栏右侧按钮较多，允许换行，避免窄标签页里被挤出可视区 */
.app-shell.embed-mode .topbar .toolbar {
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* 嵌入模式：状态文案让位给「配件数量 + 关于」，两者合成一行放在标题下方 */
.app-shell.embed-mode #data-source-label {
  display: none;
}

.app-shell.embed-mode .topbar-embed-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-embed-count {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

.topbar-embed-count strong {
  color: var(--teal);
  font-size: 15px;
  font-weight: 700;
}

/* 文字按钮（无边框，仅文字 + 悬停下划线），与顶栏状态文案同一行的「关于」用它 */
.text-button {
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  font-size: 13px;
  color: var(--teal);
  cursor: pointer;
  line-height: inherit;
}

.text-button:hover {
  text-decoration: underline;
}

.text-button:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
  border-radius: 2px;
}

/* 嵌入模式下工作区顶部不再需要自身留白（后台标签页已有边距） */
.app-shell.embed-mode .workspace {
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  background: #fbfcfd;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: #fff;
  padding: 5px;
  box-shadow: 0 10px 22px var(--accent-shadow);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand h1,
.brand p,
.topbar p,
.panel-head h3,
.panel-head p,
.quote-head h3,
.quote-head p,
.empty-state h4,
.empty-state p,
.quote-empty p {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  line-height: 1.1;
  letter-spacing: 0;
}

.brand p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0;
}

.nav-list {
  display: grid;
  gap: 7px;
  margin-bottom: auto;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  padding: 0 11px;
  text-align: left;
  font-size: 14px;
}

.sidebar-nav-item.active {
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-weight: 700;
}

.theme-panel {
  display: grid;
  gap: 12px;
  margin-top: auto;
  margin-bottom: -8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
  box-shadow: 0 8px 22px rgba(23, 34, 43, 0.04);
}

.theme-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.theme-panel-head strong {
  color: var(--ink);
  font-size: 13px;
}

.theme-panel-head span,
.theme-custom span {
  color: var(--muted);
  font-size: 11px;
}

.theme-swatches {
  display: grid;
  /* v4.1.17：minmax(0, 1fr) 防色块撑宽 */
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 7px;
}

.theme-swatch {
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid transparent;
  border-radius: 7px;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.42), 0 5px 12px rgba(23, 34, 43, 0.1);
  padding: 0;
}

.theme-swatch.active {
  border-color: var(--ink);
}

.theme-custom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.theme-custom input {
  width: 42px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 3px;
}

.sidebar-nav-item svg,
.tool-button svg,
.icon-button svg,
.search-box svg,
.empty-state svg,
.quote-empty svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
  box-shadow: 0 8px 22px rgba(23, 34, 43, 0.04);
}

.sidebar-status strong,
.sidebar-status span {
  display: block;
}

.sidebar-status strong {
  font-size: 18px;
}

.sidebar-status span {
  color: var(--muted);
  font-size: 12px;
}

.sidebar-version {
  display: block;
  width: 100%;
  padding: 6px 0;
  margin: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--faint);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
}

.sidebar-version:hover {
  background: var(--surface-soft);
  color: var(--teal);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 99px;
  background: var(--amber);
  box-shadow: 0 0 0 4px var(--amber-soft);
}

.workspace {
  min-width: 0;
  padding: 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

/* v4.6：topbar 报价单标题改为只读文字（内容来自设置 → PDF 文字自定义 → 标题文字） */
.quote-title-text {
  margin: 0;
  width: fit-content;
  max-width: min(460px, 100%);
  color: var(--ink);
  font-size: 24px;
  line-height: 1.25;
  font-weight: 800;
  overflow-wrap: break-word;
}

.topbar p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tool-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 0 13px;
  font-size: 13px;
  font-weight: 700;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.tool-button:hover,
.icon-button:hover {
  border-color: var(--teal);
  background: #f7fbfb;
}

.tool-button:active,
.icon-button:active {
  transform: translateY(1px);
}

.tool-button.primary {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.tool-button.primary:hover {
  background: var(--teal-dark);
}

.tool-button.danger {
  border-color: rgba(220, 38, 38, 0.28);
  color: var(--danger);
}

.tool-button.danger:hover:not(:disabled) {
  border-color: var(--danger);
  background: #fff5f5;
}

.tool-button input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.icon-button {
  width: 36px;
  padding: 0;
}

.app-view[hidden] {
  display: none !important;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 390px);
  gap: 18px;
  align-items: start;
}

.catalog-panel,
.quote-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.catalog-panel {
  min-width: 0;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-head h3,
.quote-head h3 {
  font-size: 17px;
  line-height: 1.25;
}

.panel-head p,
.quote-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(420px, 48%);
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--faint);
  padding: 0 11px;
}

/* 隐藏浏览器原生搜索清除按钮 */
.search-box input[type="search"]::-webkit-search-cancel-button,
.search-box input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.search-box input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--ink);
  font-size: 13px;
  padding-right: 24px;
}

.search-box .search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border: none;
  background: var(--line);
  color: var(--muted);
  border-radius: 50%;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 12px;
  line-height: 1;
  transition: all 0.15s;
  z-index: 1;
}

.search-box .search-clear.visible {
  display: flex;
}

.search-box .search-clear:hover {
  background: var(--muted);
  color: #fff;
}

.catalog-filter-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.catalog-batch-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px;
  border-bottom: 1px solid var(--line);
  background: #f0f7f7;
}

.batch-select-all {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.batch-select-all input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}

.tool-button.small {
  padding: 6px 12px;
  font-size: 12px;
  gap: 6px;
}

.col-check {
  width: 36px;
  text-align: center;
}

.col-check input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--teal);
  cursor: pointer;
}

/* Catalog body custom price display */
.price-custom {
  color: #d97706;
  font-weight: 700;
}

/* Quote list price editing */
.quote-price-edit {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.quote-price-input {
  width: 70px;
  height: 22px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  text-align: right;
  font-size: 12px;
  font-weight: 600;
  padding: 0 4px;
  outline: 0;
  transition: all 0.2s;
}

.quote-price-input:hover,
.quote-price-input:focus {
  border-color: var(--teal);
  background: #fff;
}

.quote-price-edit.custom .quote-price-input {
  color: #d97706;
  font-weight: 700;
  background: #fffbeb;
  border-color: #fbbf24;
}

.catalog-filter-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.catalog-filter-field select {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  outline: 0;
  font-size: 12px;
  font-weight: 700;
}

.catalog-filter-field select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.12);
}

.table-wrap {
  position: relative;
  min-height: 420px;
  overflow: auto;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding: 12px 18px;
  background: #fbfcfd;
  color: var(--muted);
  font-size: 12px;
}

.pagination-bar[hidden] {
  display: none;
}

.pagination-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination-actions button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.pagination-actions button:hover:not(:disabled) {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.pagination-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

/* 翻页按钮图标 - 桌面端隐藏图标显示文字 */
.page-btn .page-btn-icon { display: none; }
.page-btn .page-btn-text { display: inline; }

@media (max-width: 760px) {
  /* 移动端隐藏文字显示图标 */
  .page-btn .page-btn-icon {
    display: inline;
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
  }
  .page-btn .page-btn-text {
    display: none;
  }
  .page-btn {
    min-width: 36px;
    min-height: 36px;
    padding: 0 8px;
  }
  .pagination-actions span {
    font-size: 11px;
  }
}

.pagination-actions span,
.pagination-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  white-space: nowrap;
}

.pagination-info label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pagination-info select {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 0 8px;
  font-size: 12px;
  font-weight: 800;
}

table {
  width: 100%;
  min-width: 840px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f9fbfc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

tbody tr:hover {
  background: #f7fbfb;
}

.category-label {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 6px;
  background: var(--surface-soft);
  color: #41515c;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.item-name {
  display: grid;
  gap: 3px;
}

.item-name strong {
  font-size: 13px;
  line-height: 1.25;
}

.item-name span {
  color: var(--muted);
  font-size: 12px;
}

.money {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stock-low {
  color: var(--amber);
  font-weight: 800;
}

.stock-empty {
  color: var(--danger);
  font-weight: 800;
}

/* Hide stock column when stock display is disabled */
body.hide-stock .col-stock,
body.hide-stock .col-stock-header {
  display: none;
}

.add-button {
  display: inline-grid;
  width: 32px;
  min-height: 32px;
  place-items: center;
  border: 1px solid var(--teal);
  border-radius: 7px;
  background: #fff;
  color: var(--teal-dark);
  padding: 0;
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}

.add-button:hover {
  background: var(--teal-soft);
}

.add-button:disabled {
  border-color: var(--line);
  color: var(--faint);
  cursor: not-allowed;
}

.empty-state {
  position: absolute;
  inset: 86px 18px 18px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: #fbfcfd;
  color: var(--muted);
  text-align: center;
  padding: 28px;
}

.empty-state svg {
  width: 30px;
  height: 30px;
  color: var(--teal);
}

.empty-state h4 {
  color: var(--ink);
  font-size: 16px;
}

.empty-state p {
  max-width: 390px;
  font-size: 13px;
  line-height: 1.6;
}

.quote-panel {
  position: sticky;
  top: 20px;
  overflow: hidden;
}

.quote-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.quote-head-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.customer-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.customer-form label,
.price-controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.customer-form .wide {
  grid-column: 1 / -1;
}

.date-field-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.date-field-row input {
  flex: 1;
  min-width: 0;
}

.icon-button-sm {
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}

.icon-button-sm svg {
  width: 14px;
  height: 14px;
}

.icon-button-sm:hover {
  border-color: var(--teal);
  color: var(--teal-dark);
  background: var(--teal-soft);
}

.icon-button-sm:active {
  transform: scale(0.95);
}

#quote-no-display {
  background: #f5f7f8 !important;
  color: var(--muted) !important;
  cursor: default;
}

.customer-form input,
.customer-form textarea,
.logo-upload-control,
.price-controls input {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  outline: 0;
  font-size: 13px;
  font-family: inherit;
}

.customer-form textarea {
  resize: vertical;
  line-height: 1.5;
}

.logo-upload-control {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  cursor: pointer;
}

.logo-upload-control input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.logo-preview {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  border-radius: 7px;
  background: var(--teal);
  color: #fff;
  font-weight: 900;
}

.logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.logo-upload-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.logo-upload-copy strong {
  color: var(--ink);
  font-size: 13px;
}

.logo-upload-copy small {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logo-remove-button {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  flex: 0 0 auto;
  margin-left: auto;
}

.logo-remove-button:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: #fff5f5;
}

.logo-remove-button[hidden] {
  display: none;
}

.customer-form input:focus,
.logo-upload-control:focus-within,
.price-controls input:focus,
.search-box:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.12);
}

.quote-list {
  display: grid;
  max-height: 340px;
  overflow: auto;
}

.quote-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
}

.quote-row strong {
  display: block;
  font-size: 13px;
  line-height: 1.35;
}

.quote-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.quote-actions {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.quantity-stepper {
  display: flex;
  align-items: center;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.quantity-stepper button {
  width: 28px;
  height: 28px;
  border: 0;
  background: #fff;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
}

.quantity-stepper span {
  display: grid;
  width: 32px;
  height: 28px;
  place-items: center;
  border-inline: 1px solid var(--line);
  font-size: 12px;
  font-weight: 800;
}

.quantity-input {
  width: 48px;
  height: 28px;
  border: none;
  border-inline: 1px solid var(--line);
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
  background: #fff;
  outline: none;
  -moz-appearance: textfield;
}

.quantity-input::-webkit-inner-spin-button,
.quantity-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.remove-row {
  border: 0;
  background: transparent;
  color: var(--danger);
  font-size: 12px;
  font-weight: 800;
  padding: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}
.remove-row:hover {
  background: rgba(220, 38, 38, 0.08);
}
.remove-row svg {
  width: 14px;
  height: 14px;
}

/* 报价单排序按钮（上移/下移，v4.1.14 新增） */
.quote-action-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.move-row {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  width: 26px;
  height: 26px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}
.move-row:hover:not(:disabled) {
  background: var(--surface-soft);
  color: var(--teal);
  border-color: var(--teal);
}
.move-row:disabled {
  opacity: 0.35;
  cursor: default;
}

/* 行级保存按钮（数据编辑器） */
.save-row {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  margin-right: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 6px;
}
.save-row:disabled {
  opacity: 0.6;
  cursor: default;
}
.save-row.active {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal-dark);
}
.save-row:hover:not(:disabled) {
  border-color: var(--teal);
}
.save-row svg {
  width: 13px;
  height: 13px;
}
.data-editor-table td.row-actions {
  white-space: nowrap;
  text-align: right;
}

/* 未保存行高亮 */
.data-editor-table tr.row-dirty td {
  background: rgba(245, 158, 11, 0.08);
}

.quote-empty {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 220px;
  gap: 8px;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.quote-empty svg {
  width: 30px;
  height: 30px;
  color: var(--teal);
}

.quote-empty strong {
  color: var(--ink);
  font-size: 15px;
}

.quote-empty p {
  max-width: 260px;
  font-size: 12px;
  line-height: 1.55;
}

.history-panel {
  border-top: 1px solid var(--line);
  background: #fff;
}

.history-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 10px;
}

.history-head h4 {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.25;
}

.history-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.history-list {
  display: grid;
  max-height: 180px;
  overflow: auto;
  padding: 0 18px 14px;
}

.history-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding: 10px 0;
}

.history-main {
  min-width: 0;
}

.history-main strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-main p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.history-actions {
  display: flex;
  gap: 6px;
}

.history-actions button {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
}

.history-actions button:hover {
  border-color: var(--teal);
  color: var(--teal-dark);
  background: var(--teal-soft);
}

.history-empty {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 70px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
}

.history-empty svg {
  width: 22px;
  height: 22px;
  color: var(--teal);
}

.history-empty p {
  margin: 0;
  font-size: 12px;
}

.history-workspace {
  display: block;
}

.history-workspace-panel {
  min-height: calc(100vh - 126px);
}

.history-list-large {
  max-height: none;
  padding: 0 18px 18px;
}

.history-list-large .history-row {
  min-height: 72px;
}

.history-list-large .history-main strong {
  font-size: 15px;
}

.history-list-large .history-main p {
  font-size: 13px;
}

.history-list-large .history-actions button {
  min-width: 64px;
}

/* ── History Filters ── */
.history-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  width: min(480px, 50%);
}

.history-filters .search-box {
  width: 100%;
}
.history-date-filter {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  width: 100%;
  justify-content: flex-end;
}
.history-date-filter input[type="date"] {
  height: 38px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--card);
  color: var(--ink);
  font-size: 12px;
  font-family: inherit;
}
.history-date-filter input[type="date"]:focus {
  outline: none;
  border-color: var(--teal);
}

/* ── History Toolbar ── */
.history-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.history-select-all-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}

.history-select-all-label input {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}

.history-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-selected-count {
  font-size: 12px;
  color: var(--teal-dark);
  font-weight: 700;
  white-space: nowrap;
}

/* ── History Card List ── */
.history-card-list {
  display: grid;
  gap: 12px;
  padding: 16px 18px 18px;
}

.history-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.history-card:hover {
  border-color: var(--teal);
  box-shadow: 0 2px 12px rgba(15, 139, 141, 0.08);
}

.history-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fafbfc;
}

.history-card-check {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.history-card-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}

.history-card-title {
  flex: 1;
  min-width: 0;
}

.history-card-title strong {
  display: block;
  font-size: 14px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-card-time {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.history-card-quoteno {
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 11px;
  color: var(--teal-dark);
  background: var(--teal-soft);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.history-card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.history-btn-preview {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.history-btn-preview:hover {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.history-btn-preview svg {
  width: 13px;
  height: 13px;
}

/* v4.6：历史卡片快捷导出 PDF 按钮（含成本/不含成本） */
.history-btn-export {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.history-btn-export:hover {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.history-btn-export:disabled {
  opacity: 0.6;
  cursor: default;
}

.history-btn-export svg {
  width: 13px;
  height: 13px;
}

.history-btn-load {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  border: 1px solid var(--teal);
  border-radius: 7px;
  background: var(--teal);
  color: #fff;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: background 160ms ease;
}

.history-btn-load:hover {
  background: var(--teal-dark);
}

.history-btn-load svg {
  width: 13px;
  height: 13px;
}

.history-btn-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(220, 38, 38, 0.2);
  border-radius: 7px;
  background: #fff;
  color: var(--danger);
  padding: 0;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.history-btn-delete:hover {
  border-color: var(--danger);
  background: #fff5f5;
}

.history-btn-delete svg {
  width: 14px;
  height: 14px;
}

.history-card-body {
  padding: 12px 16px 14px;
  display: grid;
  gap: 8px;
}

.history-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
}

.history-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.history-stat-label {
  color: var(--muted);
  font-weight: 600;
}

.history-stat-value {
  color: var(--ink);
  font-weight: 800;
}

.history-stat-total {
  color: var(--teal-dark);
  font-size: 14px;
}

.history-stat-profit {
  color: #16a34a;
}

.history-card-supplier {
  font-size: 12px;
  color: var(--muted);
}

.history-card-note {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 10px;
  background: #f8f9fa;
  border-radius: 6px;
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-card-items {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.history-item-tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-weight: 700;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-more {
  background: #f0f0f0;
  color: var(--muted);
}

.source-workspace {
  display: block;
}

.source-workspace-panel {
  min-height: calc(100vh - 126px);
}

.source-actions {
  display: grid;
  gap: 12px;
  width: 100%;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.source-button-group {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.source-button-group {
  justify-content: flex-end;
  flex-wrap: nowrap;
  min-width: 0;
  overflow-x: auto;
  padding: 0 18px 12px;
}

.source-button-group .tool-button {
  flex: 0 0 auto;
}

.source-filter-bar {
  border-bottom: 0;
}

.data-editor-wrap {
  overflow: auto;
}

.data-editor-table {
  min-width: 1208px;
}

.data-editor-table th {
  white-space: nowrap;
}

.data-editor-table td {
  padding: 8px;
}

.data-editor-table .select-col {
  width: 42px;
  min-width: 42px;
  text-align: center;
}

.data-editor-table input {
  width: 100%;
  min-width: 92px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 0 9px;
  outline: 0;
  font-size: 12px;
}

.data-editor-table .data-select-checkbox {
  width: 16px;
  min-width: 16px;
  min-height: 16px;
  height: 16px;
  padding: 0;
  border-radius: 4px;
  accent-color: var(--teal);
}

.data-editor-table input[data-source-field="name"],
.data-editor-table input[data-source-field="spec"],
.data-editor-table input[data-source-field="supplier"] {
  min-width: 150px;
}

.data-editor-table input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.12);
}

.data-editor-empty {
  height: 180px;
  color: var(--muted);
  text-align: center;
}

.price-controls {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.number-field {
  display: flex;
  align-items: center;
}

.number-field input {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  text-align: right;
}

.number-field span {
  display: grid;
  min-width: 32px;
  min-height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 7px 7px 0;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.totals {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 16px 18px 18px;
}

.totals div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.totals dt {
  color: var(--muted);
  font-size: 13px;
}

.totals dd {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.grand-total {
  margin-top: 6px;
  border-top: 1px solid var(--line);
  padding-top: 13px;
}

.grand-total dt {
  color: var(--ink);
  font-weight: 800;
}

.grand-total dd {
  color: var(--teal-dark);
  font-size: 26px;
}

.tool-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.export-stage {
  position: fixed;
  left: -10000px;
  top: 0;
  width: 794px;
  background: #fff;
  pointer-events: none;
}

.quote-document {
  width: 794px;
  min-height: 1123px;
  padding: 46px;
  background: #ffffff;
  color: #15222d;
  font-family: "Microsoft YaHei UI", "PingFang SC", "Segoe UI", Arial, sans-serif;
  /* v4.8：字号/行高显式声明（原先继承自 #export-stage 舞台）——
     html2canvas 克隆渲染时继承链不同会导致逐行排版漂移、分页切片切到行中间 */
  font-size: 14px;
  line-height: normal;
}

.pdf-hero {
  display: flex;
  justify-content: space-between;
  gap: 28px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 100%);
  color: #fff;
  padding: 28px 30px;
}

.pdf-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  font-size: 15px;
}

.pdf-brand span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.18);
  font-weight: 900;
}

.pdf-logo-image {
  display: block;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.18);
  object-fit: cover;
}

.pdf-brand div {
  display: grid;
  gap: 3px;
}

.pdf-brand strong {
  color: #fff;
  font-size: 16px;
  line-height: 1.2;
}

.pdf-brand small {
  color: rgba(255, 255, 255, 0.78);
  font-size: 11px;
  line-height: 1.25;
}

.pdf-hero h2,
.pdf-hero p,
.pdf-section-title h3,
.pdf-note h3,
.pdf-note p,
.pdf-note ul {
  margin: 0;
}

.pdf-hero h2 {
  font-size: 34px;
  line-height: 1.15;
  letter-spacing: 0;
}

.pdf-hero p {
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
}

.pdf-meta {
  display: grid;
  align-content: end;
  min-width: 170px;
  gap: 6px;
  text-align: right;
}

.pdf-meta span,
.pdf-info-grid span,
.pdf-section-title span {
  color: #687887;
  font-size: 12px;
}

.pdf-meta span {
  color: rgba(255, 255, 255, 0.7);
}

.pdf-meta strong {
  font-size: 14px;
  font-weight: 800;
}

.pdf-info-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 18px;
}
.pdf-info-grid.info-cols-2 {
  grid-template-columns: repeat(2, 1fr);
}
.pdf-info-grid.info-cols-3 {
  grid-template-columns: repeat(3, 1fr);
}
.pdf-info-grid.info-cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

.pdf-info-grid div {
  display: grid;
  gap: 6px;
  min-height: 62px;
  border: 1px solid #dce4ea;
  border-radius: 8px;
  background: #f8fbfc;
  padding: 11px 12px;
  min-width: 0;
}

.pdf-info-grid strong {
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.3;
}

.pdf-section {
  margin-top: 24px;
}

.pdf-section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.pdf-section-title h3,
.pdf-note h3 {
  color: #15222d;
  font-size: 17px;
}

.pdf-table {
  width: 100%;
  min-width: 0;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border: 1px solid #dce4ea;
  border-radius: 8px;
}

.pdf-table th,
.pdf-table td {
  border-bottom: 1px solid #e4ebf0;
  padding: 11px 10px;
  font-size: 12px;
  line-height: 1.4;
}

.pdf-table th {
  position: static;
  background: #f1f6f7;
  color: #435462;
  font-weight: 900;
  /* v5.3.1：显式左对齐——页面里 th 左对齐依赖 Bootstrap reset（th{text-align:inherit}），
     服务端引擎 HTML 不含 Bootstrap 会落到 UA 默认居中，导致导出表头文字偏移 */
  text-align: left;
}

/* ---- v5.3.2 打印加强（设置开关 pdfPrintEnhance，v5.3.3 颜色自定义）----
   浅灰框线加深（纸质打印更清晰）；主题色系（luxury/wireframe/geometric/panel）线色本就较深，不适用。
   v5.3.3：不再依赖页面 id（预览/舞台/引擎 HTML 均有 .quote-document 与 .pdf-print-strong 类），
   用双份类名把特异性提升至 0-4-0 以上（+4 个 :not()），高于全部样式段(0-3-0)与编辑器生成 CSS(0-2-0)；
   颜色取 --pdf-enhance（用户可自定义，默认 #93a3b5），行线取 --pdf-enhance-line；
   【移植改动】行线原为 color-mix(in srgb, var(--pdf-enhance) 50%, #ffffff)——浏览器渲染没问题，
   但 html2canvas 解析不了 color-mix（报 unsupported color function "color"）。本插件没有服务端
   打印引擎、导出走 html2canvas 截图管线，故改为 JS 预先算好写入 --pdf-enhance-line
   （见 app.js 的 patchEnhanceLineColor），输出颜色与原来一致 */
.quote-document.pdf-print-strong.pdf-print-strong:not(.pdf-style-luxury):not(.pdf-style-wireframe):not(.pdf-style-geometric):not(.pdf-style-panel) .pdf-table,
.quote-document.pdf-print-strong.pdf-print-strong:not(.pdf-style-luxury):not(.pdf-style-wireframe):not(.pdf-style-geometric):not(.pdf-style-panel) .pdf-note,
.quote-document.pdf-print-strong.pdf-print-strong:not(.pdf-style-luxury):not(.pdf-style-wireframe):not(.pdf-style-geometric):not(.pdf-style-panel) .pdf-totals,
.quote-document.pdf-print-strong.pdf-print-strong:not(.pdf-style-luxury):not(.pdf-style-wireframe):not(.pdf-style-geometric):not(.pdf-style-panel) .pdf-info-grid div,
.quote-document.pdf-print-strong.pdf-print-strong:not(.pdf-style-luxury):not(.pdf-style-wireframe):not(.pdf-style-geometric):not(.pdf-style-panel) .pdf-hero,
.quote-document.pdf-print-strong.pdf-print-strong:not(.pdf-style-luxury):not(.pdf-style-wireframe):not(.pdf-style-geometric):not(.pdf-style-panel) .pdf-footer {
  border-color: var(--pdf-enhance, #93a3b5);
}
.quote-document.pdf-print-strong.pdf-print-strong:not(.pdf-style-luxury):not(.pdf-style-wireframe):not(.pdf-style-geometric):not(.pdf-style-panel) .pdf-table th,
.quote-document.pdf-print-strong.pdf-print-strong:not(.pdf-style-luxury):not(.pdf-style-wireframe):not(.pdf-style-geometric):not(.pdf-style-panel) .pdf-table td {
  border-color: var(--pdf-enhance-line, #c9d1da);
}

.pdf-table tr:last-child td {
  border-bottom: 0;
}

.pdf-table th:nth-child(1),
.pdf-table td:nth-child(1) {
  width: auto;
}

.pdf-table th:nth-child(4),
.pdf-table td:nth-child(4) {
  width: auto;
  text-align: center;
}

.pdf-table th:nth-child(5),
.pdf-table th:nth-child(6),
.pdf-table td:nth-child(5),
.pdf-table td:nth-child(6) {
  width: auto;
  text-align: right;
  white-space: nowrap;
}

/* 含成本PDF表格：成本价、单价、金额列样式 */
.pdf-table.has-cost th:nth-child(5),
.pdf-table.has-cost th:nth-child(6),
.pdf-table.has-cost th:nth-child(7),
.pdf-table.has-cost td:nth-child(5),
.pdf-table.has-cost td:nth-child(6),
.pdf-table.has-cost td:nth-child(7) {
  width: auto;
  text-align: right;
  white-space: nowrap;
}

.pdf-table td span {
  display: inline;
  font-size: inherit;
  font-weight: 700;
  color: inherit;
}

.pdf-table td strong,
.pdf-table td small {
  display: block;
}

.pdf-table td small {
  margin-top: 3px;
  color: #687887;
  font-size: 10px;
}

.pdf-bottom-grid {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 18px;
  margin-top: 22px;
}

.pdf-note {
  border: 1px solid #dce4ea;
  border-radius: 8px;
  background: #fbfcfd;
  padding: 16px;
}

.pdf-note p,
.pdf-note li {
  color: #536574;
  font-size: 12px;
  line-height: 1.7;
}

.pdf-note p {
  margin-top: 9px;
}

.pdf-note ul {
  margin-top: 12px;
  padding-left: 18px;
}

.pdf-totals {
  display: grid;
  gap: 9px;
  margin: 0;
  border: 1px solid #dce4ea;
  border-radius: 8px;
  background: #ffffff;
  padding: 16px;
}

.pdf-totals div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.pdf-totals dt {
  color: #687887;
  font-size: 12px;
}

.pdf-totals dd {
  margin: 0;
  font-size: 13px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.pdf-grand {
  margin-top: 7px;
  border-top: 1px solid #dce4ea;
  padding-top: 13px;
}

.pdf-grand dt {
  color: #15222d;
  font-weight: 900;
}

.pdf-grand dd {
  color: #0a6e72;
  font-size: 22px;
}

.pdf-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 26px;
  border-top: 1px solid #dce4ea;
  padding-top: 14px;
  color: #71808d;
  font-size: 11px;
}

.quote-document.pdf-compact {
  padding: 34px 38px;
}

.pdf-compact .pdf-hero {
  padding: 20px 24px;
}

.pdf-compact .pdf-brand {
  margin-bottom: 16px;
}

.pdf-compact .pdf-hero h2 {
  font-size: 29px;
}

.pdf-compact .pdf-info-grid {
  margin-top: 14px;
}

.pdf-compact .pdf-info-grid div {
  min-height: 52px;
  padding: 9px 10px;
}

.pdf-compact .pdf-section {
  margin-top: 18px;
}

.pdf-compact .pdf-table th,
.pdf-compact .pdf-table td {
  padding: 7px 8px;
  font-size: 11px;
  line-height: 1.3;
}

.pdf-compact .pdf-table td span {
  font-size: inherit;
}

.pdf-compact .pdf-bottom-grid {
  gap: 14px;
  margin-top: 16px;
}

.pdf-compact .pdf-note,
.pdf-compact .pdf-totals {
  padding: 12px;
}

.pdf-compact .pdf-note p,
.pdf-compact .pdf-note li {
  font-size: 11px;
  line-height: 1.45;
}

.pdf-compact .pdf-footer {
  margin-top: 18px;
  padding-top: 10px;
}

.quote-document.pdf-ultra-compact {
  padding: 28px 32px;
}

.pdf-ultra-compact .pdf-hero {
  padding: 16px 20px;
}

.pdf-ultra-compact .pdf-brand {
  margin-bottom: 10px;
  font-size: 13px;
}

.pdf-ultra-compact .pdf-brand span {
  width: 28px;
  height: 28px;
}

.pdf-ultra-compact .pdf-logo-image {
  width: 28px;
  height: 28px;
}

.pdf-ultra-compact .pdf-brand strong {
  font-size: 13px;
}

.pdf-ultra-compact .pdf-brand small {
  font-size: 9px;
}

.pdf-ultra-compact .pdf-hero h2 {
  font-size: 25px;
}

.pdf-ultra-compact .pdf-hero p {
  margin-top: 4px;
  font-size: 11px;
}

.pdf-ultra-compact .pdf-meta {
  gap: 3px;
}

.pdf-ultra-compact .pdf-info-grid {
  gap: 6px;
  margin-top: 10px;
}

.pdf-ultra-compact .pdf-info-grid div {
  min-height: 42px;
  padding: 7px 8px;
}

.pdf-ultra-compact .pdf-info-grid span,
.pdf-ultra-compact .pdf-section-title span,
.pdf-ultra-compact .pdf-meta span {
  font-size: 10px;
}

.pdf-ultra-compact .pdf-info-grid strong,
.pdf-ultra-compact .pdf-meta strong {
  font-size: 11px;
}

.pdf-ultra-compact .pdf-section {
  margin-top: 13px;
}

.pdf-ultra-compact .pdf-section-title {
  margin-bottom: 7px;
}

.pdf-ultra-compact .pdf-section-title h3,
.pdf-ultra-compact .pdf-note h3 {
  font-size: 14px;
}

.pdf-ultra-compact .pdf-table th,
.pdf-ultra-compact .pdf-table td {
  padding: 5px 6px;
  font-size: 10px;
  line-height: 1.22;
}

.pdf-ultra-compact .pdf-table td small {
  margin-top: 1px;
  font-size: 9px;
}

.pdf-ultra-compact .pdf-table td span {
  font-size: inherit;
}

.pdf-ultra-compact .pdf-bottom-grid {
  grid-template-columns: 1fr 238px;
  gap: 10px;
  margin-top: 12px;
}

.pdf-ultra-compact .pdf-note,
.pdf-ultra-compact .pdf-totals {
  padding: 10px;
}

.pdf-ultra-compact .pdf-note p,
.pdf-ultra-compact .pdf-note li,
.pdf-ultra-compact .pdf-totals dt {
  font-size: 10px;
  line-height: 1.35;
}

.pdf-ultra-compact .pdf-note ul {
  display: none;
}

.pdf-ultra-compact .pdf-totals {
  gap: 6px;
}

.pdf-ultra-compact .pdf-totals dd {
  font-size: 11px;
}

.pdf-ultra-compact .pdf-grand {
  margin-top: 4px;
  padding-top: 8px;
}

.pdf-ultra-compact .pdf-grand dd {
  font-size: 18px;
}

.pdf-ultra-compact .pdf-footer {
  margin-top: 12px;
  padding-top: 8px;
  font-size: 10px;
}

@media (max-width: 1380px) {
  .app-shell {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  :root {
    --sidebar-width: 76px;
  }

  .brand {
    justify-content: center;
  }

  .brand div:last-child,
  .sidebar-status div {
    display: none;
  }

  .sidebar-nav-item {
    justify-content: center;
    padding: 0;
    font-size: 0;
  }

  .sidebar-nav-item svg {
    display: block;
  }

  .theme-panel {
    gap: 7px;
    padding: 6px;
  }

  .theme-panel-head {
    display: none;
  }

  .theme-custom {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
  }

  .theme-custom span {
    font-size: 12px;
  }

  .theme-custom input {
    width: 48px;
    height: 36px;
  }

  .theme-swatches {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .sidebar-status {
    justify-content: center;
  }

}

@media (max-width: 1180px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  .quote-panel {
    position: static;
  }

  .source-actions {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .source-button-group {
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px;
  }

  .brand div:last-child {
    display: block;
  }

  .theme-panel {
    margin-top: 0;
    margin-bottom: 0;
    flex: 1 1 100%;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "theme-head theme-custom"
      "theme-swatches theme-swatches";
    gap: 8px 10px;
    padding: 10px;
  }

  .theme-panel-head {
    grid-area: theme-head;
    display: flex;
    justify-content: flex-start;
    min-width: 0;
  }

  .theme-custom {
    grid-area: theme-custom;
    display: flex;
    justify-content: flex-end;
  }

  .theme-swatches {
    grid-area: theme-swatches;
    grid-template-columns: repeat(6, minmax(30px, 1fr));
    gap: 6px;
  }

  .theme-swatch {
    min-height: 30px;
  }

  .theme-custom input {
    width: 34px;
    height: 28px;
  }

  .nav-list,
  .sidebar-status {
    display: none;
  }

  .workspace {
    padding: 12px;
  }

  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar {
    justify-content: flex-start;
  }

  .tool-button {
    flex: 1 1 148px;
  }

  .catalog-batch-bar {
    padding: 8px 12px;
    gap: 8px;
  }

  .batch-select-all {
    font-size: 12px;
  }

  .tool-button.small {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .catalog-filter-bar {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 12px 16px;
  }

  .catalog-filter-field select {
    min-height: 40px;
  }

  .source-button-group .tool-button {
    flex: 0 0 auto;
  }

  /* 移动端按钮组横向滑动优化 */
  .source-button-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 12px 16px;
    overflow: visible;
    justify-content: stretch;
  }

  .source-button-group .tool-button {
    flex: 1 1 auto;
    width: 100%;
    min-height: 38px;
    justify-content: center;
  }

  .source-button-group .tool-button.primary {
    grid-column: 1 / -1;
  }

  /* 刷新按钮在移动端占整行（两格），与新增数据按钮一致，避免半格显示 */
  .source-button-group #refresh-source-data {
    grid-column: 1 / -1;
  }

  .search-box {
    width: 100%;
  }

  .customer-form,
  .price-controls {
    grid-template-columns: 1fr;
  }

  .quote-row {
    grid-template-columns: 1fr;
  }

  .history-row {
    grid-template-columns: 1fr;
  }

  .history-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .history-filters {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }
  .history-filters .search-box {
    width: 100%;
  }
  .history-date-filter {
    width: 100%;
  }
  .history-date-filter input[type="date"] {
    flex: 1;
    min-width: 0;
  }

  .history-toolbar-actions {
    flex-wrap: wrap;
  }

  .history-card-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .history-card-title {
    flex: 1 1 calc(100% - 28px);
    order: 1;
  }

  .history-card-check {
    order: 0;
  }

  .history-card-actions {
    order: 2;
    width: 100%;
    justify-content: flex-end;
  }

  .history-card-stats {
    gap: 4px 12px;
  }

  .history-card-note {
    white-space: normal;
  }

  .quote-actions {
    grid-template-columns: auto 1fr;
    justify-items: start;
    align-items: center;
  }
}


/* ---- About Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(23, 34, 43, 0.45);
  backdrop-filter: blur(3px);
}

.modal-card {
  width: min(520px, 94vw);
  max-height: 85vh;
  overflow-y: auto;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 24px 56px rgba(23, 34, 43, 0.22);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  margin: 0;
  font-size: 16px;
  color: var(--ink);
}

.modal-close {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
}

.modal-close:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

.modal-body {
  padding: 18px 22px 22px;
}

.about-intro {
  margin: 0 0 18px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.7;
}

.about-features h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--ink);
}

.about-features ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.about-features li {
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--bg);
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
}

.about-features li strong {
  color: var(--teal);
}

.about-version {
  margin: 18px 0 0;
  color: var(--faint);
  font-size: 12px;
  text-align: right;
}

/* v4.1.33：关于弹窗 HTTPS 信任证书下载区 */
.about-cert-downloads {
  margin: 14px 0 0;
  padding: 10px 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.7;
}
.about-cert-downloads span {
  color: var(--text);
}
.about-cert-downloads a {
  color: var(--teal);
  font-weight: 600;
  margin: 0 10px 0 4px;
  text-decoration: none;
  border-bottom: 1px dashed var(--teal);
}
.about-cert-downloads a:hover {
  opacity: 0.8;
}
.about-cert-downloads .about-cert-tip {
  display: block;
  margin-top: 4px;
  color: var(--faint);
  font-size: 12px;
}

/* Mobile Navigation */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  /* v4.1.16：固定定位宽度必须显式限制，防止跟随含滚动条的 innerWidth 溢出
     （经典滚动条浏览器 innerWidth > 布局视口，left:0+right:0 会把导航栏撑到
      innerWidth 宽度，页面出现横向滑动） */
  width: 100%;
  max-width: 100%;
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 8px 16px;
  z-index: 100;
  justify-content: space-around;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
}

.mobile-nav-item svg {
  width: 20px;
  height: 20px;
}

.mobile-nav-item.active {
  color: var(--teal-dark);
  background: var(--teal-soft);
}

/* Mobile Styles */
@media (max-width: 760px) {
  .mobile-nav {
    display: flex;
  }

  .workspace {
    padding-bottom: 80px;
  }
}

/* ---- Settings Page ---- */
.settings-workspace {
  padding: 20px;
  max-width: 1000px;
}

.settings-header {
  grid-column: 1 / -1;
  margin-bottom: 4px;
  padding: 8px 4px 0;
}

.settings-header .settings-title {
  margin-bottom: 4px;
}

.settings-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.settings-container {
  display: grid;
  /* v4.1.17：minmax(0, 1fr) 允许列收缩——grid 列默认 min-width:auto，
     内部内容 min-content 会把列撑出视口（移动端字体/渲染差异下触发横向溢出） */
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: stretch;
}

.settings-title {
  font-size: 24px;
  color: var(--ink);
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.settings-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-rest);
  transition: box-shadow 0.2s;
  /* v4.1.17：grid 子项允许收缩（防内容 min-content 撑出视口） */
  min-width: 0;
}

.settings-section:hover {
  box-shadow: var(--shadow-raised);
}

.settings-section--half {
  grid-column: span 1;
  display: flex;
  flex-direction: column;
}

.settings-section--half .settings-toggle {
  margin-top: auto;
  padding-top: 12px;
}

.settings-section--full {
  grid-column: 1 / -1;
}

.settings-section-title {
  font-size: 16px;
  color: var(--ink);
  margin: 0 0 4px;
  font-weight: 700;
  /* v4.1.17：长标题换行防溢出 */
  overflow-wrap: break-word;
  word-break: break-word;
}

.settings-section-desc {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 14px 0;
  line-height: 1.5;
  /* v4.1.17：长描述换行防溢出 */
  overflow-wrap: break-word;
  word-break: break-word;
}

.settings-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.settings-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.settings-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.settings-toggle-track {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: #cbd5e1;
  transition: background 200ms ease;
  flex-shrink: 0;
}

.settings-toggle-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform 200ms ease;
}

.settings-toggle input:checked + .settings-toggle-track {
  background: var(--teal);
}

.settings-toggle input:checked + .settings-toggle-track::after {
  transform: translateX(20px);
}

.settings-toggle-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.settings-note-inputs {
  display: grid;
  gap: 12px;
}

.settings-note-inputs label {
  display: grid;
  gap: 4px;
}

.settings-note-inputs label span {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.settings-note-inputs textarea {
  width: 100%;
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  outline: 0;
  transition: border-color 160ms ease;
}

.settings-note-inputs textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.12);
}

.pdf-labels-group {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-hover);
}

.pdf-labels-group:first-of-type {
  margin-top: 0;
}

.pdf-labels-group h4 {
  font-size: 12px;
  font-weight: 700;
  color: var(--teal-dark);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pdf-labels-group h4::before {
  content: "";
  width: 4px;
  height: 14px;
  border-radius: 2px;
  background: var(--teal);
}

.pdf-labels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  /* v4.1.17：grid 子项允许收缩，输入框 max-width 100% 防撑宽 */
  min-width: 0;
}

.pdf-labels-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 12px;
}

.pdf-labels-grid select {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  padding: 6px 9px;
  font-size: 12px;
  font-family: inherit;
  outline: 0;
  cursor: pointer;
  transition: border-color 160ms ease;
}

.pdf-labels-grid select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.1);
}

.pdf-labels-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.pdf-labels-status {
  font-size: 12px;
  font-weight: 700;
  color: #16a34a;
  transition: opacity 300ms ease;
}

.pdf-labels-grid label {
  display: grid;
  gap: 3px;
}

.pdf-labels-grid label span {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.pdf-labels-grid input,
.pdf-labels-grid textarea,
.pdf-labels-grid select {
  width: 100%;
  max-width: 100%;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 6px 9px;
  font-size: 12px;
  font-family: inherit;
  outline: 0;
  box-sizing: border-box;
  transition: border-color 160ms ease;
}

.pdf-labels-grid textarea {
  min-height: 50px;
  resize: vertical;
}

.pdf-labels-grid input:focus,
.pdf-labels-grid textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.1);
}

/* Theme panel in settings */
.settings-section .theme-panel {
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
}

.settings-section .theme-swatches {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.settings-section .theme-swatch {
  width: 42px;
  height: 42px;
  aspect-ratio: auto;
  border-radius: 8px;
  flex-shrink: 0;
}

.settings-section .theme-custom {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--muted);
}

@media (max-width: 760px) {
  .settings-section .theme-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    grid-template-columns: none;
    grid-template-areas: none;
  }
}

/* PDF Style Grid */
.pdf-style-grid {
  display: grid;
  /* v4.1.17：minmax(0, 1fr) 防卡片内部内容撑宽列 */
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.pdf-style-card {
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  /* v4.1.17：grid 子项允许收缩 */
  min-width: 0;
}

.pdf-style-card:hover {
  border-color: var(--teal);
}

.pdf-style-card.active {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.pdf-style-card strong {
  display: block;
  font-size: 14px;
  color: var(--ink);
  margin-top: 8px;
  /* v4.1.17：长名称换行防溢出 */
  overflow-wrap: break-word;
  word-break: break-word;
}

.pdf-style-card span {
  font-size: 11px;
  color: var(--muted);
  display: block;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* PDF Style Previews */
.pdf-style-preview {
  height: 80px;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
}

.sp-header {
  height: 20px;
  border-radius: 4px;
  flex-shrink: 0;
}

.sp-row {
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.sp-side {
  position: absolute;
  left: 8px;
  top: 32px;
  bottom: 8px;
  width: 4px;
  border-radius: 2px;
}

/* Classic preview */
.pdf-style-preview-classic {
  background: #f8fbfc;
}
.pdf-style-preview-classic .sp-header {
  background: linear-gradient(135deg, var(--teal), var(--teal-dark));
}
.pdf-style-preview-classic .sp-row {
  background: #e4ebf0;
}

/* Luxury preview */
.pdf-style-preview-luxury {
  background: #f8fafc;
  padding: 0;
}
.pdf-style-preview-luxury .sp-header {
  background: linear-gradient(135deg, var(--teal-dark), var(--teal));
  height: 28px;
  border-radius: 0;
  position: relative;
}
.pdf-style-preview-luxury .sp-header::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--teal), var(--teal-soft), var(--teal));
}
.pdf-style-preview-luxury .sp-side {
  background: var(--teal);
}
.pdf-style-preview-luxury .sp-row {
  background: var(--teal-soft);
  margin-left: 8px;
  margin-right: 8px;
}

/* Minimal Gray preview */
.pdf-style-preview-minimal-gray {
  background: #fff;
  padding: 6px 8px;
}
.pdf-style-preview-minimal-gray .sp-header {
  background: transparent;
  border-bottom: 2px solid #374151;
  height: 12px;
  border-radius: 0;
}
.pdf-style-preview-minimal-gray .sp-row {
  background: transparent;
  border-bottom: 1px solid #e5e7eb;
  height: 8px;
  margin: 0;
}

/* Minimal Blue preview */
.pdf-style-preview-minimal-blue {
  background: #f8fafc;
  padding: 0;
}
.pdf-style-preview-minimal-blue .sp-header {
  background: var(--teal);
  height: 20px;
  border-radius: 0;
}
.pdf-style-preview-minimal-blue .sp-row {
  background: #fff;
  margin: 2px 6px;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Wireframe preview */
.pdf-style-preview-wireframe {
  background: #fff;
  padding: 6px 8px;
}
.pdf-style-preview-wireframe .sp-header {
  background: transparent;
  border: 2px solid var(--teal);
  border-radius: 2px;
  height: 16px;
}
.pdf-style-preview-wireframe .sp-row {
  background: transparent;
  border: 1px solid var(--teal-soft);
  border-radius: 0;
  height: 8px;
  margin: 2px 0;
}

/* Geometric preview */
.pdf-style-preview-geometric {
  background: #fff;
  padding: 6px 8px;
  position: relative;
}
.pdf-style-preview-geometric .sp-header {
  background: transparent;
  height: 18px;
  border-top: 4px solid var(--teal);
  border-radius: 0;
}
.pdf-style-preview-geometric .sp-row {
  background: transparent;
  border-bottom: 1px dotted #d1d5db;
  height: 8px;
  margin: 2px 0;
  border-radius: 0;
}

/* Panel preview */
.pdf-style-preview-panel {
  background: #fff;
  padding: 6px 8px;
}
.pdf-style-preview-panel .sp-header {
  background: transparent;
  border-bottom: 2px solid var(--teal);
  height: 12px;
  border-radius: 0;
}
.pdf-style-preview-panel .sp-side {
  left: auto;
  right: 8px;
  top: 24px;
  width: 26px;
  background: var(--teal-soft);
  opacity: 0.6;
}
.pdf-style-preview-panel .sp-row {
  background: #eef2f4;
  height: 8px;
  margin: 3px 32px 0 0;
  border-radius: 2px;
}

/* Minimal Lines preview */
.pdf-style-preview-minimal-lines {
  background: #fff;
  padding: 6px 8px;
}
.pdf-style-preview-minimal-lines .sp-header {
  background: linear-gradient(90deg, #374151 0%, #374151 58%, transparent 58%);
  height: 13px;
  border-radius: 0;
}
.pdf-style-preview-minimal-lines .sp-row {
  background: transparent;
  border-bottom: 1px solid #e5e7eb;
  height: 8px;
  margin: 0;
  border-radius: 0;
}

/* ---- PDF Style Preview: Custom ---- */
.pdf-style-preview-custom {
  background: #1e1e2e;
  align-items: center;
  justify-content: center;
}
.sp-code-icon {
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 18px;
  font-weight: 700;
  color: #a6e3a1;
  letter-spacing: 1px;
}

/* ---- Custom CSS Editor ---- */
.custom-css-editor {
  margin-top: 12px;
}
.custom-css-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.custom-css-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.custom-css-header-left span {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.custom-css-load-select {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
}
.custom-css-load-select:focus {
  outline: none;
  border-color: var(--teal);
}
/* v5.1：空白行填充——三档选项纵向排列（每行 开关+标签；自定义行数行尾带输入框） */
.fill-mode-rows {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}
/* v5.3：空白行填充设置分组副标题 */
.settings-subtitle {
  margin: 2px 0 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
/* 行数输入框必须覆盖 .settings-toggle input 的原生隐藏规则
   （position/width/height/opacity/pointer-events——否则被 1×1px 透明化不可见），
   选择器需保持 .settings-toggle 前缀以提升优先级 */
.settings-toggle .fill-row-count-input {
  position: static;
  width: 64px;
  height: 30px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
  font-size: 13px;
  opacity: 1;
  pointer-events: auto;
  margin-left: 2px;
}
.settings-toggle .fill-row-count-input:focus {
  outline: none;
  border-color: var(--teal);
}
.settings-toggle .fill-row-count-input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.custom-css-actions {
  display: flex;
  gap: 8px;
}
.custom-css-editor textarea {
  width: 100%;
  min-height: 200px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.5;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  resize: vertical;
  tab-size: 2;
}
.custom-css-editor textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(15, 139, 141, 0.15);
}
.custom-css-editor textarea::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

/* ---- PDF Style: Luxury ---- */
.quote-document.pdf-style-luxury {
  padding: 0;
  background: #f8fafc;
}
.quote-document.pdf-style-luxury .pdf-hero {
  background: linear-gradient(135deg, var(--teal-dark) 0%, var(--teal) 100%);
  border-radius: 0;
  padding: 36px 46px 32px;
  position: relative;
}
.quote-document.pdf-style-luxury .pdf-hero::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--teal), var(--teal-soft), var(--teal));
}
.quote-document.pdf-style-luxury .pdf-brand {
  margin-bottom: 20px;
}
.quote-document.pdf-style-luxury .pdf-brand span {
  background: rgba(255, 255, 255, 0.25);
}
.quote-document.pdf-style-luxury .pdf-meta {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 12px 16px;
}
.quote-document.pdf-style-luxury .pdf-info-grid {
  margin: 20px 46px 0;
}
.quote-document.pdf-style-luxury .pdf-info-grid div {
  border: none;
  background: var(--teal-soft);
  border-left: 3px solid var(--teal);
}
.quote-document.pdf-style-luxury .pdf-section {
  margin: 20px 46px 0;
  border-left: 3px solid var(--teal);
  padding-left: 16px;
}
.quote-document.pdf-style-luxury .pdf-section-title {
  border-bottom: 2px solid var(--teal-soft);
  padding-bottom: 8px;
}
.quote-document.pdf-style-luxury .pdf-table th {
  background: linear-gradient(135deg, var(--teal-dark), var(--teal));
  color: #fff;
}
.quote-document.pdf-style-luxury .pdf-table {
  border-color: var(--teal-soft);
  table-layout: auto;
}
.quote-document.pdf-style-luxury .pdf-table th:nth-child(1),
.quote-document.pdf-style-luxury .pdf-table td:nth-child(1),
.quote-document.pdf-style-luxury .pdf-table th:nth-child(4),
.quote-document.pdf-style-luxury .pdf-table td:nth-child(4),
.quote-document.pdf-style-luxury .pdf-table th:nth-child(5),
.quote-document.pdf-style-luxury .pdf-table td:nth-child(5),
.quote-document.pdf-style-luxury .pdf-table th:nth-child(6),
.quote-document.pdf-style-luxury .pdf-table td:nth-child(6),
.quote-document.pdf-style-luxury .pdf-table th:nth-child(7),
.quote-document.pdf-style-luxury .pdf-table td:nth-child(7) {
  width: auto;
}
.quote-document.pdf-style-luxury .pdf-table td span {
  background: var(--teal-soft);
  color: var(--teal-dark);
}
.quote-document.pdf-style-luxury .pdf-bottom-grid {
  margin: 20px 46px 0;
}
.quote-document.pdf-style-luxury .pdf-note {
  background: var(--teal-soft);
  border: none;
  border-radius: 8px;
  padding: 16px;
}
.quote-document.pdf-style-luxury .pdf-grand dd {
  color: var(--teal-dark);
  font-size: 24px;
}
.quote-document.pdf-style-luxury .pdf-totals {
  border-color: var(--teal-soft);
  background: var(--teal-soft);
}
.quote-document.pdf-style-luxury .pdf-footer {
  margin: 20px 46px 0;
  border-color: var(--teal-soft);
  padding: 16px 0;
}

/* ---- PDF Style: Minimal Gray ---- */
.quote-document.pdf-style-minimal-gray {
  padding: 36px 32px;
}
.quote-document.pdf-style-minimal-gray .pdf-hero {
  background: transparent;
  color: var(--ink);
  border-radius: 0;
  padding: 0;
  border-bottom: 3px double var(--ink);
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 12px 20px;
  padding-bottom: 8px;
}
.quote-document.pdf-style-minimal-gray .pdf-hero > div:first-child {
  grid-column: 1;
  grid-row: 1;
}
.quote-document.pdf-style-minimal-gray .pdf-hero h2 {
  font-size: 24px;
  font-weight: 300;
  letter-spacing: 4px;
  margin: 0 0 4px;
}
.quote-document.pdf-style-minimal-gray .pdf-hero p {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin: 0;
}
.quote-document.pdf-style-minimal-gray .pdf-brand {
  grid-column: 2;
  grid-row: 1;
  color: var(--ink);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 15px;
}
.quote-document.pdf-style-minimal-gray .pdf-brand strong {
  color: var(--ink);
  font-weight: 600;
  font-size: 13px;
}
.quote-document.pdf-style-minimal-gray .pdf-brand small {
  color: var(--muted);
  font-size: 11px;
}
.quote-document.pdf-style-minimal-gray .pdf-brand span {
  background: #f3f4f6;
  color: var(--ink);
}
.quote-document.pdf-style-minimal-gray .pdf-meta {
  grid-column: 1 / -1;
  grid-row: 2;
  display: flex;
  gap: 20px;
  font-size: 10px;
  padding-top: 10px;
  border-top: 1px solid #e5e7eb;
  justify-content: flex-end;
  text-align: right;
}
.quote-document.pdf-style-minimal-gray .pdf-meta span {
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.quote-document.pdf-style-minimal-gray .pdf-meta strong {
  color: var(--ink);
  font-size: 10px;
}
.quote-document.pdf-style-minimal-gray .pdf-info-grid {
  gap: 0;
  margin-top: 20px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  overflow: hidden;
}
.quote-document.pdf-style-minimal-gray .pdf-info-grid div {
  border: none;
  background: transparent;
  border-radius: 0;
  padding: 10px 14px;
  min-height: auto;
}
.quote-document.pdf-style-minimal-gray .pdf-info-grid span {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}
.quote-document.pdf-style-minimal-gray .pdf-info-grid strong {
  font-size: 13px;
  font-weight: 600;
}
.quote-document.pdf-style-minimal-gray .pdf-section-title {
  margin-top: 24px;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
}
.quote-document.pdf-style-minimal-gray .pdf-section-title::before {
  content: "";
  flex: 0 0 4px;
  height: 14px;
  background: var(--ink);
}
.quote-document.pdf-style-minimal-gray .pdf-section-title h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--ink);
  font-weight: 600;
  margin: 0;
}
.quote-document.pdf-style-minimal-gray .pdf-section-title span {
  color: #9ca3af;
  font-size: 11px;
  margin-left: auto;
}
.quote-document.pdf-style-minimal-gray .pdf-table {
  border: 1px solid #d1d5db;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 12px;
  table-layout: auto;
}
.quote-document.pdf-style-minimal-gray .pdf-table th:nth-child(1),
.quote-document.pdf-style-minimal-gray .pdf-table td:nth-child(1),
.quote-document.pdf-style-minimal-gray .pdf-table th:nth-child(4),
.quote-document.pdf-style-minimal-gray .pdf-table td:nth-child(4),
.quote-document.pdf-style-minimal-gray .pdf-table th:nth-child(5),
.quote-document.pdf-style-minimal-gray .pdf-table td:nth-child(5),
.quote-document.pdf-style-minimal-gray .pdf-table th:nth-child(6),
.quote-document.pdf-style-minimal-gray .pdf-table td:nth-child(6),
.quote-document.pdf-style-minimal-gray .pdf-table th:nth-child(7),
.quote-document.pdf-style-minimal-gray .pdf-table td:nth-child(7) {
  width: auto;
}
.quote-document.pdf-style-minimal-gray .pdf-table th {
  background: #f9fafb;
  color: var(--ink);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--ink);
  padding: 10px 12px;
}
.quote-document.pdf-style-minimal-gray .pdf-table td {
  border-bottom-color: #e5e7eb;
  padding: 10px 12px;
}
.quote-document.pdf-style-minimal-gray .pdf-table td span {
  background: transparent;
  color: var(--ink);
  padding: 0;
  font-weight: 500;
}
.quote-document.pdf-style-minimal-gray .pdf-bottom-grid {
  margin-top: 24px;
  gap: 20px;
}
.quote-document.pdf-style-minimal-gray .pdf-note {
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  padding: 14px;
}
.quote-document.pdf-style-minimal-gray .pdf-note h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--ink);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid #e5e7eb;
}
.quote-document.pdf-style-minimal-gray .pdf-grand {
  border-top: 3px double var(--ink);
  padding-top: 12px;
}
.quote-document.pdf-style-minimal-gray .pdf-grand dd {
  color: var(--ink);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: 1px;
}
.quote-document.pdf-style-minimal-gray .pdf-totals {
  border: 1px solid #d1d5db;
  border-radius: 4px;
}
.quote-document.pdf-style-minimal-gray .pdf-totals dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.quote-document.pdf-style-minimal-gray .pdf-footer {
  border: none;
  padding-top: 16px;
  margin-top: 20px;
  border-top: 1px solid #d1d5db;
  font-size: 10px;
  letter-spacing: 0.5px;
}

/* ---- PDF Style: Minimal Blue ---- */
.quote-document.pdf-style-minimal-blue {
  padding: 0;
  background: #f8fafc;
}
.quote-document.pdf-style-minimal-blue .pdf-hero {
  background: var(--teal);
  color: #fff;
  border: none;
  border-radius: 0;
  padding: 32px 36px 28px;
}
.quote-document.pdf-style-minimal-blue .pdf-hero h2 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.quote-document.pdf-style-minimal-blue .pdf-hero p {
  color: rgba(255, 255, 255, 0.7);
  font-size: 11px;
}
.quote-document.pdf-style-minimal-blue .pdf-brand {
  margin-bottom: 16px;
}
.quote-document.pdf-style-minimal-blue .pdf-brand span {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}
.quote-document.pdf-style-minimal-blue .pdf-meta {
  color: rgba(255, 255, 255, 0.8);
  font-size: 12px;
}
.quote-document.pdf-style-minimal-blue .pdf-meta strong {
  color: #fff;
}
.quote-document.pdf-style-minimal-blue .pdf-info-grid {
  gap: 10px;
  margin: -20px 36px 0;
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  position: relative;
  z-index: 1;
}
.quote-document.pdf-style-minimal-blue .pdf-info-grid div {
  border: none;
  background: #f8fafc;
  border-radius: 6px;
  padding: 12px;
}
.quote-document.pdf-style-minimal-blue .pdf-info-grid span {
  font-size: 11px;
  color: var(--muted);
}
.quote-document.pdf-style-minimal-blue .pdf-section {
  margin: 20px 36px 0;
}
.quote-document.pdf-style-minimal-blue .pdf-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.quote-document.pdf-style-minimal-blue .pdf-section-title h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.quote-document.pdf-style-minimal-blue .pdf-table {
  border: none;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  table-layout: auto;
}
.quote-document.pdf-style-minimal-blue .pdf-table th:nth-child(1),
.quote-document.pdf-style-minimal-blue .pdf-table td:nth-child(1),
.quote-document.pdf-style-minimal-blue .pdf-table th:nth-child(4),
.quote-document.pdf-style-minimal-blue .pdf-table td:nth-child(4),
.quote-document.pdf-style-minimal-blue .pdf-table th:nth-child(5),
.quote-document.pdf-style-minimal-blue .pdf-table td:nth-child(5),
.quote-document.pdf-style-minimal-blue .pdf-table th:nth-child(6),
.quote-document.pdf-style-minimal-blue .pdf-table td:nth-child(6),
.quote-document.pdf-style-minimal-blue .pdf-table th:nth-child(7),
.quote-document.pdf-style-minimal-blue .pdf-table td:nth-child(7) {
  width: auto;
}
.quote-document.pdf-style-minimal-blue .pdf-table th {
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-weight: 700;
  font-size: 12px;
  border-bottom: none;
  padding: 10px 12px;
}
.quote-document.pdf-style-minimal-blue .pdf-table td {
  background: #fff;
  border-bottom-color: #f1f5f9;
  font-size: 12px;
  padding: 10px 12px;
}
.quote-document.pdf-style-minimal-blue .pdf-table td span {
  background: transparent;
  color: var(--ink);
  border-radius: 0;
  font-size: inherit;
  padding: 0;
}
.quote-document.pdf-style-minimal-blue .pdf-bottom-grid {
  margin: 20px 36px 0;
}
.quote-document.pdf-style-minimal-blue .pdf-note {
  background: #fff;
  border: none;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.quote-document.pdf-style-minimal-blue .pdf-grand dd {
  color: var(--teal-dark);
  font-size: 20px;
}
.quote-document.pdf-style-minimal-blue .pdf-totals {
  border: none;
  background: var(--teal-soft);
  border-radius: 6px;
}
.quote-document.pdf-style-minimal-blue .pdf-footer {
  border-color: #e5e7eb;
  font-size: 10px;
  color: var(--muted);
}

/* ---- PDF Style: Wireframe (线框) ---- */
/* Pure line-based style, no background fills, theme-colored borders */
.quote-document.pdf-style-wireframe {
  background: #fff;
  padding: 40px 36px;
}
.quote-document.pdf-style-wireframe .pdf-brand {
  color: var(--ink);
}
.quote-document.pdf-style-wireframe .pdf-brand span {
  background: transparent;
  border: 2px solid var(--teal);
  color: var(--teal);
}
.quote-document.pdf-style-wireframe .pdf-brand strong {
  color: var(--ink);
}
.quote-document.pdf-style-wireframe .pdf-brand small {
  color: var(--muted);
}
.quote-document.pdf-style-wireframe .pdf-hero {
  background: transparent;
  color: var(--ink);
  border-radius: 0;
  padding: 0 0 16px;
  border-bottom: 2px solid var(--teal);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px 20px;
}
.quote-document.pdf-style-wireframe .pdf-hero h2 {
  font-size: 26px;
  font-weight: 300;
  letter-spacing: 6px;
  color: var(--ink);
}
.quote-document.pdf-style-wireframe .pdf-hero p {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-top: 6px;
}
.quote-document.pdf-style-wireframe .pdf-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}
.quote-document.pdf-style-wireframe .pdf-meta span {
  color: var(--muted);
}
.quote-document.pdf-style-wireframe .pdf-meta strong {
  color: var(--teal);
  font-size: 10px;
}
.quote-document.pdf-style-wireframe .pdf-info-grid {
  gap: 0;
  margin-top: 20px;
  border: 1px solid var(--teal);
  border-radius: 2px;
  overflow: hidden;
}
.quote-document.pdf-style-wireframe .pdf-info-grid div {
  border: none;
  background: transparent;
  border-radius: 0;
  padding: 10px 14px;
}
.quote-document.pdf-style-wireframe .pdf-info-grid dt {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.quote-document.pdf-style-wireframe .pdf-info-grid dd {
  color: var(--ink);
  font-weight: 600;
}
.quote-document.pdf-style-wireframe .pdf-section {
  margin-top: 24px;
}
.quote-document.pdf-style-wireframe .pdf-section-title {
  margin-bottom: 12px;
}
.quote-document.pdf-style-wireframe .pdf-section-title h3 {
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--teal);
  font-weight: 600;
}
.quote-document.pdf-style-wireframe .pdf-section-title span {
  font-size: 10px;
  color: var(--muted);
}
.quote-document.pdf-style-wireframe .pdf-table {
  border: 1px solid var(--teal);
  border-radius: 2px;
  overflow: hidden;
  table-layout: auto;
}
.quote-document.pdf-style-wireframe .pdf-table th {
  background: transparent;
  color: var(--teal);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 2px solid var(--teal);
  padding: 10px 12px;
}
/* 移植改动：本段原用 color-mix(in srgb, var(--teal) N%, ...)，html2canvas 解析不了，
   已改为引用 JS 预计算的 --teal-aNN / --teal-wNN 变量（见 app.js 的 applyThemeColor）。 */
.quote-document.pdf-style-wireframe .pdf-table td {
  border-bottom-color: var(--teal-a20, rgba(15, 139, 141, 0.2));
  padding: 10px 12px;
}
.quote-document.pdf-style-wireframe .pdf-table td span {
  background: transparent;
  color: var(--ink);
  padding: 0;
  font-weight: 500;
}
.quote-document.pdf-style-wireframe .pdf-bottom-grid {
  margin-top: 24px;
  gap: 20px;
}
.quote-document.pdf-style-wireframe .pdf-note {
  border: 1px solid var(--teal-a40, rgba(15, 139, 141, 0.4));
  border-radius: 2px;
  background: transparent;
  padding: 14px;
}
.quote-document.pdf-style-wireframe .pdf-note h3 {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: var(--teal);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--teal-a30, rgba(15, 139, 141, 0.3));
}
.quote-document.pdf-style-wireframe .pdf-totals {
  border: 1px solid var(--teal);
  border-radius: 2px;
  background: transparent;
}
.quote-document.pdf-style-wireframe .pdf-grand {
  border-top: 2px solid var(--teal);
  padding-top: 12px;
}
.quote-document.pdf-style-wireframe .pdf-grand dd {
  color: var(--teal);
  font-size: 22px;
  font-weight: 300;
  letter-spacing: 2px;
}
.quote-document.pdf-style-wireframe .pdf-footer {
  border: none;
  padding-top: 16px;
  margin-top: 20px;
  border-top: 1px solid var(--teal);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 1px;
}

/* ---- PDF Style: Geometric (几何) ---- */
/* Redesigned: centered layout, dotted accents, stacked bottom, dot decorations */
.quote-document.pdf-style-geometric {
  background: #fff;
  padding: 44px 40px;
}
.quote-document.pdf-style-geometric .pdf-brand {
  color: var(--ink);
  justify-content: center;
  text-align: center;
}
.quote-document.pdf-style-geometric .pdf-brand span {
  background: var(--teal);
  color: #fff;
  border-radius: 50%;
}
.quote-document.pdf-style-geometric .pdf-brand strong {
  color: var(--ink);
}
.quote-document.pdf-style-geometric .pdf-brand small {
  color: var(--muted);
}
.quote-document.pdf-style-geometric .pdf-hero {
  background: transparent;
  color: var(--ink);
  border-radius: 0;
  padding: 20px 0 0;
  text-align: center;
  display: block;
  border-top: 6px solid var(--teal);
}
.quote-document.pdf-style-geometric .pdf-hero h2 {
  font-size: 28px;
  font-weight: 200;
  letter-spacing: 8px;
  color: var(--ink);
}
.quote-document.pdf-style-geometric .pdf-hero p {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 4px;
  text-transform: uppercase;
  margin-top: 4px;
}
.quote-document.pdf-style-geometric .pdf-meta {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-top: 14px;
  font-size: 11px;
  color: var(--muted);
}
.quote-document.pdf-style-geometric .pdf-meta span {
  color: var(--muted);
}
.quote-document.pdf-style-geometric .pdf-meta strong {
  color: var(--ink);
  font-size: 11px;
}
.quote-document.pdf-style-geometric .pdf-info-grid {
  gap: 0;
  margin-top: 24px;
  border: 1px dotted #d1d5db;
  border-radius: 0;
  overflow: hidden;
}
.quote-document.pdf-style-geometric .pdf-info-grid.info-cols-2 {
  grid-template-columns: repeat(2, 1fr);
}
.quote-document.pdf-style-geometric .pdf-info-grid.info-cols-3 {
  grid-template-columns: repeat(3, 1fr);
}
.quote-document.pdf-style-geometric .pdf-info-grid.info-cols-4 {
  grid-template-columns: repeat(2, 1fr);
}
.quote-document.pdf-style-geometric .pdf-info-grid div {
  border: none;
  background: transparent;
  border-radius: 0;
  padding: 12px 16px;
  border-right: 1px dotted #d1d5db;
  border-bottom: 1px dotted #d1d5db;
}
.quote-document.pdf-style-geometric .pdf-info-grid.info-cols-2 div:nth-child(2n),
.quote-document.pdf-style-geometric .pdf-info-grid.info-cols-4 div:nth-child(2n) {
  border-right: none;
}
.quote-document.pdf-style-geometric .pdf-info-grid.info-cols-3 div:nth-child(3n) {
  border-right: none;
}
.quote-document.pdf-style-geometric .pdf-info-grid div:last-child {
  border-right: none;
  border-bottom: none;
}
.quote-document.pdf-style-geometric .pdf-info-grid dt {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.quote-document.pdf-style-geometric .pdf-info-grid dd {
  color: var(--ink);
  font-weight: 700;
  margin-top: 4px;
}
.quote-document.pdf-style-geometric .pdf-section {
  margin-top: 28px;
}
.quote-document.pdf-style-geometric .pdf-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.quote-document.pdf-style-geometric .pdf-section-title h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 3px;
  text-transform: uppercase;
}
.quote-document.pdf-style-geometric .pdf-section-title::before {
  content: "";
  flex: 0 0 8px;
  height: 8px;
  background: var(--teal);
  border-radius: 50%;
}
.quote-document.pdf-style-geometric .pdf-section-title span {
  font-size: 10px;
  color: var(--muted);
  margin-left: auto;
}
.quote-document.pdf-style-geometric .pdf-table {
  border: none;
  border-radius: 0;
  overflow: visible;
  border-collapse: collapse;
}
.quote-document.pdf-style-geometric .pdf-table th {
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px dotted var(--teal);
  padding: 10px 12px;
}
.quote-document.pdf-style-geometric .pdf-table td {
  border-bottom: 1px dotted #e5e7eb;
  padding: 10px 12px;
}
.quote-document.pdf-style-geometric .pdf-table td span {
  background: transparent;
  color: var(--ink);
  padding: 0;
  font-weight: 500;
}
.quote-document.pdf-style-geometric .pdf-table tr:last-child td {
  border-bottom: 1px dotted var(--teal);
}
.quote-document.pdf-style-geometric .pdf-bottom-grid {
  grid-template-columns: 1fr;
  margin-top: 28px;
  gap: 20px;
}
.quote-document.pdf-style-geometric .pdf-note {
  border: none;
  border-top: 1px dotted var(--teal);
  border-radius: 0;
  background: transparent;
  padding: 14px 0;
}
.quote-document.pdf-style-geometric .pdf-note h3 {
  font-size: 10px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.quote-document.pdf-style-geometric .pdf-totals {
  border: none;
  border-top: 1px dotted var(--teal);
  border-radius: 0;
  background: transparent;
  padding: 14px 0;
}
.quote-document.pdf-style-geometric .pdf-grand {
  border-top: none;
  padding-top: 12px;
  margin-top: 8px;
}
.quote-document.pdf-style-geometric .pdf-grand dt {
  font-size: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--muted);
}
.quote-document.pdf-style-geometric .pdf-grand dd {
  color: var(--teal);
  font-size: 26px;
  font-weight: 200;
  letter-spacing: 2px;
}
.quote-document.pdf-style-geometric .pdf-footer {
  border: none;
  padding-top: 16px;
  margin-top: 24px;
  border-top: 1px solid var(--teal);
  border-bottom: 1px solid var(--teal);
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  letter-spacing: 2px;
}

/* ---- PDF Style: Panel (分栏面板) ---- */
/* v4.3 布局变体：右侧栏放客户信息+数量税率+汇总，左主栏放表格+报价说明（独占一行） */
.quote-document.pdf-style-panel {
  padding: 36px 34px;
}
.quote-document.pdf-style-panel .pdf-hero {
  background: transparent;
  color: var(--ink);
  border-radius: 0;
  padding: 0 0 12px;
  border-bottom: 2px solid var(--teal);
  align-items: flex-end;
}
.quote-document.pdf-style-panel .pdf-hero h2 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 2px;
}
.quote-document.pdf-style-panel .pdf-hero p {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-top: 6px;
}
.quote-document.pdf-style-panel .pdf-brand {
  margin-bottom: 10px;
}
.quote-document.pdf-style-panel .pdf-brand strong {
  color: var(--ink);
  font-size: 13px;
}
.quote-document.pdf-style-panel .pdf-brand small {
  color: var(--muted);
}
.quote-document.pdf-style-panel .pdf-brand span {
  background: #eef4f4;
  color: var(--ink);
}
.quote-document.pdf-style-panel .pdf-logo-image {
  background: transparent;
}
.quote-document.pdf-style-panel .pdf-meta span {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.quote-document.pdf-style-panel .pdf-meta strong {
  color: var(--ink);
  font-size: 12px;
}
.quote-document.pdf-style-panel .pdf-panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 200px;
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}
.quote-document.pdf-style-panel .pdf-panel-main {
  min-width: 0;
}
/* 移植改动：本段原用 color-mix(in srgb, var(--teal) N%, ...)，html2canvas 解析不了，
   已改为引用 JS 预计算的 --teal-aNN / --teal-wNN 变量（见 app.js 的 applyThemeColor）。 */
.quote-document.pdf-style-panel .pdf-panel-side {
  display: grid;
  gap: 12px;
  min-width: 0;
  background: var(--teal-w07, #eef7f7);
  border: 1px solid var(--teal-w18, #d4eaea);
  border-radius: 10px;
  padding: 14px;
}
.quote-document.pdf-style-panel .pdf-side-info {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  margin-top: 0;
}
.quote-document.pdf-style-panel .pdf-side-info div {
  min-height: 0;
  border: none;
  border-bottom: 1px solid var(--teal-w14, #ddefef);
  border-radius: 0;
  background: transparent;
  padding: 9px 2px;
}
.quote-document.pdf-style-panel .pdf-side-info div:last-child {
  border-bottom: none;
}
.quote-document.pdf-style-panel .pdf-side-info span {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 1px;
}
.quote-document.pdf-style-panel .pdf-side-info strong {
  font-size: 13px;
  overflow-wrap: anywhere;
}
.quote-document.pdf-style-panel .pdf-side-stats {
  display: grid;
  gap: 8px;
}
.quote-document.pdf-style-panel .pdf-side-stats div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.quote-document.pdf-style-panel .pdf-side-stats span {
  color: var(--muted);
  font-size: 11px;
}
.quote-document.pdf-style-panel .pdf-side-stats strong {
  font-size: 13px;
  font-weight: 800;
}
.quote-document.pdf-style-panel .pdf-section {
  margin-top: 0;
}
.quote-document.pdf-style-panel .pdf-section-title h3 {
  font-size: 15px;
}
.quote-document.pdf-style-panel .pdf-table th,
.quote-document.pdf-style-panel .pdf-table td {
  padding: 9px 7px;
  font-size: 11px;
}
.quote-document.pdf-style-panel .pdf-table th {
  background: var(--teal-w08, #ecf6f6);
}
.quote-document.pdf-style-panel .pdf-table td small {
  font-size: 9px;
}
.quote-document.pdf-style-panel .pdf-note {
  margin-top: 18px;
  padding: 14px 16px;
}
.quote-document.pdf-style-panel .pdf-note h3 {
  font-size: 14px;
}
.quote-document.pdf-style-panel .pdf-totals {
  border: none;
  border-top: 1px solid var(--teal-w18, #d4eaea);
  border-radius: 0;
  background: transparent;
  padding: 12px 2px 0;
  gap: 7px;
}
.quote-document.pdf-style-panel .pdf-totals dt {
  font-size: 11px;
}
.quote-document.pdf-style-panel .pdf-totals dd {
  font-size: 13px;
}
.quote-document.pdf-style-panel .pdf-grand {
  margin-top: 4px;
  border-top: 1px solid var(--teal);
  padding-top: 10px;
}
.quote-document.pdf-style-panel .pdf-grand dd {
  color: var(--teal);
  font-size: 16px;
}
.quote-document.pdf-style-panel.pdf-compact .pdf-table th,
.quote-document.pdf-style-panel.pdf-compact .pdf-table td {
  padding: 7px 6px;
}
.quote-document.pdf-style-panel.pdf-ultra-compact .pdf-table th,
.quote-document.pdf-style-panel.pdf-ultra-compact .pdf-table td {
  padding: 5px 5px;
  font-size: 10px;
}
.quote-document.pdf-style-panel.pdf-ultra-compact .pdf-note {
  margin-top: 12px;
  padding: 10px 12px;
}

/* ---- PDF Style: Minimal Lines (极简横线) ---- */
/* v4.3 布局变体：全无盒子边框，表格只有极细横线；数量/税率在表格末尾 meta 行；报价说明独占一行，汇总右对齐行式 */
.quote-document.pdf-style-minimal-lines {
  padding: 42px 46px;
}
.quote-document.pdf-style-minimal-lines .pdf-hero {
  background: transparent;
  color: var(--ink);
  border-radius: 0;
  padding: 0 0 14px;
  border-bottom: 1px solid #d1d5db;
  align-items: flex-end;
}
.quote-document.pdf-style-minimal-lines .pdf-hero h2 {
  font-size: 30px;
  font-weight: 200;
  letter-spacing: 8px;
}
.quote-document.pdf-style-minimal-lines .pdf-hero p {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-top: 6px;
}
.quote-document.pdf-style-minimal-lines .pdf-brand {
  margin-bottom: 12px;
}
.quote-document.pdf-style-minimal-lines .pdf-brand strong {
  color: var(--ink);
  font-weight: 600;
  font-size: 13px;
}
.quote-document.pdf-style-minimal-lines .pdf-brand small {
  color: var(--muted);
}
.quote-document.pdf-style-minimal-lines .pdf-brand span {
  background: #f3f4f6;
  color: var(--ink);
}
.quote-document.pdf-style-minimal-lines .pdf-logo-image {
  background: transparent;
}
.quote-document.pdf-style-minimal-lines .pdf-meta span {
  color: var(--muted);
  font-size: 10px;
}
.quote-document.pdf-style-minimal-lines .pdf-meta strong {
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}
.quote-document.pdf-style-minimal-lines .pdf-info-grid {
  display: flex;
  gap: 48px;
  margin-top: 16px;
}
.quote-document.pdf-style-minimal-lines .pdf-info-grid div {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-height: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 0;
}
.quote-document.pdf-style-minimal-lines .pdf-info-grid span {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 1px;
}
.quote-document.pdf-style-minimal-lines .pdf-info-grid strong {
  font-size: 14px;
  font-weight: 600;
}
.quote-document.pdf-style-minimal-lines .pdf-section {
  margin-top: 26px;
}
.quote-document.pdf-style-minimal-lines .pdf-section-title h3 {
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
  font-weight: 600;
}
.quote-document.pdf-style-minimal-lines .pdf-section-title span {
  font-size: 11px;
}
.quote-document.pdf-style-minimal-lines .pdf-table {
  border: none;
  border-radius: 0;
  overflow: visible;
  margin-top: 6px;
}
.quote-document.pdf-style-minimal-lines .pdf-table th {
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid #d1d5db;
}
.quote-document.pdf-style-minimal-lines .pdf-table td {
  border-bottom: 1px solid #eceef0;
}
.quote-document.pdf-style-minimal-lines .pdf-table tr:last-child td {
  border-bottom: 1px solid #d1d5db;
}
.quote-document.pdf-style-minimal-lines .pdf-table-meta {
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  padding-top: 8px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 1px;
}
.quote-document.pdf-style-minimal-lines .pdf-bottom-grid {
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 26px;
}
.quote-document.pdf-style-minimal-lines .pdf-note {
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 0;
}
.quote-document.pdf-style-minimal-lines .pdf-note h3 {
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
  font-weight: 600;
}
.quote-document.pdf-style-minimal-lines .pdf-totals {
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 0;
  gap: 8px;
  max-width: 320px;
  margin-left: auto;
}
.quote-document.pdf-style-minimal-lines .pdf-grand {
  margin-top: 6px;
  border-top: 2px solid var(--ink);
  padding-top: 12px;
}
.quote-document.pdf-style-minimal-lines .pdf-grand dt {
  font-size: 11px;
  letter-spacing: 2px;
}
.quote-document.pdf-style-minimal-lines .pdf-grand dd {
  color: var(--teal);
  font-size: 24px;
  font-weight: 300;
}
.quote-document.pdf-style-minimal-lines .pdf-footer {
  margin-top: 30px;
  border-top: 1px solid #d1d5db;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 1px;
}

/* ---- PDF Style: Sections End ---- */

@media (max-width: 760px) {
  .settings-workspace {
    padding: 12px;
  }
  .pdf-style-grid {
    /* v4.1.17：minmax(0, 1fr) 防卡片内部内容撑宽 */
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ============================================
   Toast 通知系统
   ============================================ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.app-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  max-width: 420px;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  pointer-events: auto;
  transform: translateX(120%);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-left: 4px solid var(--teal);
}

.app-toast.show {
  transform: translateX(0);
  opacity: 1;
}

.app-toast.hide {
  transform: translateX(120%);
  opacity: 0;
}

.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.app-toast.success { border-left-color: #22c55e; }
.app-toast.success .toast-icon { color: #22c55e; }
.app-toast.error { border-left-color: var(--danger); }
.app-toast.error .toast-icon { color: var(--danger); }
.app-toast.warning { border-left-color: var(--amber); }
.app-toast.warning .toast-icon { color: var(--amber); }
.app-toast.info { border-left-color: var(--teal); }
.app-toast.info .toast-icon { color: var(--teal); }

.toast-close {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  margin-left: auto;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.toast-close:hover { opacity: 1; }
.toast-close svg { width: 14px; height: 14px; }

@media (max-width: 760px) {
  .toast-container {
    top: 12px;
    right: 12px;
    left: 12px;
  }
  .app-toast {
    min-width: auto;
    max-width: none;
  }
}

/* ============================================
   搜索框清除按钮 + 高亮
   ============================================ */
.search-box {
  position: relative;
}

.search-box .search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border: none;
  background: var(--surface-soft);
  color: var(--muted);
  border-radius: 50%;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 12px;
  line-height: 1;
  transition: all 0.15s;
}

.search-box .search-clear.visible {
  display: flex;
}

.search-box .search-clear:hover {
  background: var(--line);
  color: var(--ink);
}

.search-box input[type="search"] {
  padding-right: 32px;
}

mark.search-highlight {
  background: var(--amber-soft);
  color: var(--ink);
  padding: 0 2px;
  border-radius: 2px;
}

/* ============================================
   统计面板
   ============================================ */
.stats-panel {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.stat-card {
  background: var(--surface);
  border-radius: 8px;
  padding: 12px;
  border: 1px solid var(--line);
}

.stat-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--ink);
}

.stat-value.profit { color: #22c55e; }
.stat-value.cost { color: var(--amber); }

/* 图表样式 */
.stats-charts {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.chart-container {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
}

.chart-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 12px;
}

/* v4.6：饼图与图例并排布局——图例项多时在自身区域内滚动，
   不再把图表区纵向撑高产生大片空白（旧版图例堆叠在饼图下方） */
.pie-chart {
  display: flex;
  align-items: center;
  gap: 18px;
  width: 100%;
}

.pie-chart canvas {
  width: 150px;
  flex: 0 0 auto;
  height: auto;
}

.pie-chart .pie-empty {
  margin: auto;
  color: var(--muted);
  font-size: 12px;
}

.pie-legend {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 168px;
  overflow-y: auto;
  padding-right: 4px;
  font-size: 11.5px;
}

.pie-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.pie-legend-name {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.pie-legend-count {
  margin-left: auto;
  color: var(--muted);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.pie-legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.bar-chart {
  width: 100%;
  height: 150px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding-top: 10px;
}

.bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.bar-fill {
  width: 100%;
  min-height: 4px;
  background: var(--teal);
  border-radius: 4px 4px 0 0;
  transition: height 0.3s;
}

.bar-label {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}

.bar-value {
  font-size: 10px;
  font-weight: 700;
  color: var(--ink);
}

@media (max-width: 760px) {
  .stats-charts {
    grid-template-columns: 1fr;
  }

  .pie-chart canvas {
    width: 120px;
  }

  .pie-legend {
    max-height: 140px;
  }
}

/* ============================================
   客户/供应商模板
   ============================================ */
.template-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-height: 200px;
  overflow-y: auto;
  display: none;
}

.template-dropdown.show {
  display: block;
}

.template-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid var(--line);
}

.template-item:last-child { border-bottom: none; }
.template-item:hover { background: var(--teal-soft); }

.template-item-logo {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface-soft);
}

.template-item-info {
  flex: 1;
  min-width: 0;
}

.template-item-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.template-item-detail {
  font-size: 11px;
  color: var(--muted);
}

.template-item-delete {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

.template-item:hover .template-item-delete { opacity: 1; }
.template-item-delete:hover { color: var(--danger); }

/* ============================================
   数据源卡片式布局（移动端）
   ============================================ */
@media (max-width: 760px) {
  .data-editor-wrap {
    overflow: visible;
    min-width: 0;
  }
  .data-editor-table,
  .data-editor-table thead,
  .data-editor-table tbody,
  .data-editor-table th,
  .data-editor-table td,
  .data-editor-table tr {
    display: block;
    width: 100%;
    min-width: 0;
  }
  .data-editor-table {
    min-width: 0;
  }
  .data-editor-table thead { display: none; }

  /* 卡片：两列网格布局 */
  .data-editor-table tbody tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-rest);
    transition: box-shadow 0.15s;
  }
  .data-editor-table tbody tr:active {
    box-shadow: var(--shadow-raised);
  }

  /* 字段：label 在上，输入框在下 */
  .data-editor-table td {
    border: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    overflow: visible;
  }
  .data-editor-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--faint);
    font-size: 11px;
    letter-spacing: 0.4px;
    text-align: left;
    flex-shrink: 0;
  }
  .data-editor-table td input {
    width: 100%;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-hover);
    padding: 0 12px;
    font-size: 14px;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  }
  .data-editor-table td input:focus {
    border-color: var(--teal);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.12);
  }

  /* 复选框整行（卡片头部） */
  .data-editor-table td.select-col {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 2px;
  }
  .data-editor-table td.select-col::before {
    content: attr(data-label);
    font-size: 12px;
    font-weight: 700;
    color: var(--ink-soft);
    letter-spacing: 0;
  }
  .data-editor-table td.select-col .data-select-checkbox {
    width: 22px;
    height: 22px;
    min-height: 0;
    accent-color: var(--teal);
    margin: 0;
  }

  /* 名称字段整行突出显示 */
  .data-editor-table td[data-label="名称"] {
    grid-column: 1 / -1;
  }
  .data-editor-table td[data-label="名称"]::before {
    content: attr(data-label);
    font-size: 12px;
    font-weight: 700;
    color: var(--ink-soft);
  }
  .data-editor-table td[data-label="名称"] input {
    font-weight: 700;
    font-size: 15px;
    color: var(--ink);
    border-color: var(--line-strong);
  }

  /* 数字字段右对齐 */
  .data-editor-table td[data-label="库存"] input,
  .data-editor-table td[data-label="成本"] input,
  .data-editor-table td[data-label="售价"] input {
    text-align: right;
    font-variant-numeric: tabular-nums;
  }

  /* 删除/保存按钮整行（卡片底部），保持同一行横向排列 */
  .data-editor-table td:last-child {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
    margin-top: 2px;
  }
  .data-editor-table .remove-row {
    min-width: 42px;
    min-height: 40px;
    padding: 0;
    font-size: 15px;
    background: var(--surface-hover);
    border: 1px solid var(--line);
    border-radius: var(--radius);
  }
  .data-editor-table .remove-row svg {
    width: 18px;
    height: 18px;
  }
  .data-editor-table .save-row {
    min-width: 72px;
    min-height: 40px;
    padding: 0 12px;
    font-size: 13px;
    justify-content: center;
    /* 按钮间距由 row-actions 的 gap 统一控制 */
  }
  .data-editor-table .save-row svg {
    width: 16px;
    height: 16px;
  }

  /* 下拉建议面板适配 */
  .suggest-wrap {
    width: 100%;
  }
  .suggest-toggle {
    right: 8px;
    width: 24px;
    height: 24px;
  }
}

/* ============================================
   批量修改弹窗
   ============================================ */
.batch-edit-modal {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
}

.batch-edit-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 24px;
  width: 90%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.batch-edit-card h3 {
  margin-bottom: 16px;
  font-size: 16px;
}

.batch-edit-field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.batch-edit-field label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.batch-edit-field input,
.batch-edit-field select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  font-size: 13px;
}

.batch-edit-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}
/* ---- Backup Management ---- */
.backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  /* v4.1.17：防按钮行撑宽 */
  min-width: 0;
}

.backup-actions .tool-button {
  min-width: 0;
}

.backup-list {
  font-size: 13px;
  color: var(--muted);
}

.backup-empty {
  padding: 16px 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.backup-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 6px;
  background: var(--faint, #f8fbfb);
  /* v4.1.17：flex 子项允许收缩，防长文件名撑宽 */
  min-width: 0;
}

.backup-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  /* v4.1.17：防长备份文件名（无空格连续字符串）撑宽卡片 */
  min-width: 0;
  flex: 1 1 auto;
}

.backup-info strong {
  font-size: 13px;
  color: var(--ink, #163238);
  font-family: "Segoe UI", monospace;
  /* v4.1.17：文件名强制换行防溢出 */
  overflow-wrap: anywhere;
  word-break: break-all;
}

.backup-size {
  font-size: 12px;
  color: var(--muted);
}

.backup-restore-btn {
  font-size: 12px !important;
  padding: 4px 10px !important;
  /* v4.1.17：不被拉伸、不收缩 */
  flex: 0 0 auto;
  min-width: 0;
}

/* 移植新增：备份文件落盘路径的展示行 */
.backup-path-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.backup-path-line code {
  font-family: "Segoe UI", Consolas, monospace;
  font-size: 12px;
  background: var(--faint, #f2f7f7);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 6px;
  /* 路径里没有空格，必须强制换行，否则窄屏会被撑宽 */
  overflow-wrap: anywhere;
  min-width: 0;
}

.backup-path-copy {
  font-size: 12px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink, #163238);
  cursor: pointer;
  flex: 0 0 auto;
}

.backup-path-copy:hover {
  border-color: var(--teal);
  color: var(--teal);
}

/* 移植新增：备份列表的「恢复 / 删除」按钮组 + 删除按钮
   backup-item 是 flex，按钮组必须 flex:0 0 auto 且允许换行，
   否则窄屏（移动端设置页）会被长文件名挤成一条线 */
.backup-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.backup-delete-btn {
  font-size: 12px !important;
  padding: 4px 10px !important;
  flex: 0 0 auto;
  min-width: 0;
  color: #c0392b;
  border-color: #e6b3ac;
}

.backup-delete-btn:hover {
  background: #fdf2f0;
  border-color: #c0392b;
}

/* ============================================
   UI 美化增强（v3.9 设计系统）
   ============================================ */

/* 卡片统一 */
.catalog-panel {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-rest);
  transition: box-shadow 0.2s;
}

.catalog-panel:hover {
  box-shadow: var(--shadow-raised);
}

/* 按钮体系 */
.tool-button {
  border-radius: var(--radius);
  transition: all 0.15s ease;
  font-weight: 600;
}

.tool-button.primary {
  background: var(--teal);
  border-color: var(--teal);
}

.tool-button.primary:hover:not(:disabled) {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
  box-shadow: 0 2px 8px var(--accent-shadow);
}

.tool-button.small {
  border-radius: var(--radius-sm);
}

.icon-button {
  border-radius: var(--radius);
  transition: all 0.15s ease;
}

.icon-button:hover {
  background: var(--teal-soft);
  color: var(--teal-dark);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px var(--accent-shadow);
}

/* 输入框统一 */
.customer-form input,
.customer-form textarea,
.price-controls input,
.search-box,
.catalog-filter-field select {
  border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.customer-form input:focus,
.customer-form textarea:focus,
.price-controls input:focus,
.catalog-filter-field select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.12);
}

/* 表格 */
th {
  background: #f8fafc;
  letter-spacing: 0.3px;
}

tbody tr {
  transition: background 0.12s;
}

/* 侧边栏 */
.sidebar {
  background: linear-gradient(180deg, #ffffff 0%, #f7fafc 100%);
  box-shadow: 1px 0 0 var(--line);
}

.brand-mark {
  box-shadow: 0 2px 10px var(--accent-shadow);
  transition: transform 0.2s;
}

.brand-mark:hover {
  transform: scale(1.05);
}

.sidebar-nav-item {
  border-radius: var(--radius);
  transition: all 0.15s;
}

.sidebar-nav-item.active {
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-weight: 700;
}

/* 历史卡片 */
.history-card {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-rest);
  transition: box-shadow 0.2s, transform 0.15s;
}

.history-card:hover {
  box-shadow: var(--shadow-raised);
  transform: translateY(-2px);
}

.history-card .history-btn-preview,
.history-card .history-btn-load,
.history-card .history-btn-export {
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

/* 标签 */
.category-label,
.history-item-tag {
  border-radius: var(--radius-sm);
}

/* 报价面板 */
.quote-panel {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-rest);
}

.quote-row {
  border-radius: var(--radius);
  transition: background 0.15s;
}

.quote-row:hover {
  background: var(--surface-hover);
}

/* 数量步进器 */
.quantity-stepper button {
  transition: all 0.15s;
}

.quantity-stepper button:hover:not(:disabled) {
  background: var(--teal-soft);
  color: var(--teal-dark);
}

/* 弹窗 */
.batch-edit-modal .batch-edit-card,
.modal-card {
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  animation: modal-in 0.2s ease-out;
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* 分页按钮 */
.pagination-actions button,
.page-btn {
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.pagination-actions button:hover:not(:disabled),
.page-btn:hover:not(:disabled) {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal-dark);
}

/* 设置页 */
.settings-section {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-rest);
}

.pdf-style-card {
  border-radius: var(--radius-lg);
  transition: all 0.2s;
}

.pdf-style-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-raised);
}

.pdf-style-card.active {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px var(--teal-soft), 0 4px 12px var(--accent-shadow);
}

/* 主题色块 */
.theme-swatch {
  transition: transform 0.15s, box-shadow 0.15s;
}

.theme-swatch:hover {
  transform: scale(1.1);
}

.theme-swatch.active {
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--teal);
}

/* 移动端优化 */
@media (max-width: 760px) {
  .history-card:hover {
    transform: none;
  }
  .tool-button {
    min-height: 36px;
  }
  .history-card-actions button {
    min-height: 32px;
  }
  .settings-section {
    padding: 16px;
  }
}

/* 滚动条美化 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--faint);
}

/* ============================================
   数据源自定义下拉组件
   ============================================ */
.suggest-wrap {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}

.suggest-wrap .suggest-input {
  width: 100%;
  padding-right: 26px;
}

.suggest-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}

.suggest-toggle:hover {
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.suggest-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-raised);
  max-height: 180px;
  overflow-y: auto;
  animation: suggest-in 0.12s ease-out;
}

.suggest-panel[hidden] {
  display: none;
}

@keyframes suggest-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.suggest-option {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.suggest-option:hover {
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.suggest-empty {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--faint);
  text-align: center;
}

/* ============================================
   移动端浮动报价栏
   ============================================ */
.mobile-quote-bar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  z-index: 900;
  display: block;
}

.mobile-quote-bar[hidden] {
  display: none;
}

#mobile-quote-bar-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  border-radius: 14px;
  background: var(--teal);
  color: #fff;
  padding: 12px 16px;
  box-shadow: 0 6px 24px var(--accent-shadow);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  font-family: inherit;
}

#mobile-quote-bar-btn:active {
  transform: scale(0.98);
}

.mqb-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.mqb-icon {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.18);
}

.mqb-icon svg {
  width: 15px;
  height: 15px;
}

.mqb-count {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.mqb-total {
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.mqb-arrow {
  display: grid;
  place-items: center;
  opacity: 0.85;
}

.mqb-arrow svg {
  width: 14px;
  height: 14px;
}

@media (min-width: 761px) {
  .mobile-quote-bar {
    display: none !important;
  }
}

/* ============================================
   全局UI统一优化（v3.9）
   ============================================ */

/* 侧边栏品牌区 */
.brand-mark {
  background: linear-gradient(135deg, var(--teal-soft) 0%, #ffffff 100%);
}

/* 历史卡片操作按钮统一 */
.history-btn-preview,
.history-btn-load,
.history-btn-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 30px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s;
}

.history-btn-preview {
  border: 1px solid var(--teal);
  background: #fff;
  color: var(--teal-dark);
}

.history-btn-preview:hover {
  background: var(--teal-soft);
}

.history-btn-load {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
}

.history-btn-load:hover {
  border-color: var(--teal);
  color: var(--teal-dark);
  background: var(--surface-hover);
}

.history-btn-delete {
  width: 30px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--faint);
}

.history-btn-delete:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* 统计卡片 hover */
.stat-card {
  transition: transform 0.15s, box-shadow 0.15s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-raised);
}

/* 模板管理列表项 hover */
.template-manage-list .template-manage-item {
  transition: background 0.12s;
}

.template-manage-list .template-manage-item:hover {
  background: var(--surface-hover);
}

/* 空状态图标 */
.history-empty svg,
.empty-state svg,
.quote-empty svg {
  color: var(--teal);
  opacity: 0.6;
}

/* 批量修改弹窗输入框 */
.batch-edit-field input:focus,
.batch-edit-field select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.12);
}

/* 回收站列表 hover */
#trash-list > div:hover {
  background: var(--surface-hover);
}

/* 数据源删除按钮 */
.remove-row {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  min-height: 30px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  transition: all 0.15s;
}

.remove-row:hover {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}

/* 桌面端数据源卡片布局微调 */
.template-manage-item .tool-button.small {
  padding: 4px 10px;
  min-height: 28px;
  font-size: 12px;
}

/* ============================================
   移动端报价面板优化
   ============================================ */
@media (max-width: 760px) {
  /* 报价面板更紧凑 */
  .quote-panel {
    border-radius: var(--radius-lg);
    margin-top: 4px;
  }

  .quote-head {
    padding: 14px 16px;
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--surface);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .customer-form {
    padding: 12px 16px;
    gap: 10px;
  }

  .customer-form label {
    font-size: 11px;
  }

  /* 报价行紧凑布局 */
  .quote-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 12px 16px;
  }

  .quote-row > div:first-child {
    min-width: 0;
  }

  .quote-row strong {
    font-size: 13px;
    line-height: 1.35;
    display: block;
    word-break: break-all;
  }

  .quote-row p {
    font-size: 12px;
    margin: 4px 0 0;
    color: var(--muted);
  }

  .quote-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
  }

  .quote-actions .quantity-stepper {
    height: 32px;
  }

  .quote-actions .remove-row {
    min-height: 30px;
    padding: 0 10px;
    font-size: 12px;
  }

  /* 价格输入框紧凑 */
  .quote-price-edit input {
    width: 90px;
    min-height: 30px;
    font-size: 13px;
  }

  /* 价格控制区域 */
  .price-controls {
    padding: 12px 16px;
  }

  .price-controls label {
    font-size: 11px;
  }

  /* 合计区域 */
  .totals {
    padding: 12px 16px;
  }

  .totals div {
    padding: 6px 0;
  }

  .totals .grand-total {
    padding: 10px 0;
  }

  /* 目录表格在移动端显示关键列 */
  table {
    min-width: 640px;
  }

  /* 报价单输入框字号防止iOS缩放 */
  .customer-form input,
  .customer-form textarea,
  .price-controls input,
  .quantity-input {
    font-size: 16px;
  }
}

/* ============================================
   设置页面移动端适配
   ============================================ */
@media (max-width: 760px) {
  .settings-workspace {
    padding: 12px;
  }

  .settings-container {
    /* v4.1.17：minmax(0, 1fr) 防内容撑宽 */
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .settings-section--half,
  .settings-section--full {
    grid-column: 1 / -1;
  }

  .settings-section {
    padding: 16px;
    border-radius: var(--radius);
  }

  .settings-title {
    font-size: 20px;
  }

  .pdf-labels-group {
    padding: 12px;
  }

  .pdf-labels-grid {
    /* v4.1.17：minmax(0, 1fr) 防输入框内容撑宽 */
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .backup-actions {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
  }

  .backup-actions .tool-button {
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
    padding: 0 14px;
  }

  /* PDF导出样式的预览按钮恢复大小 */
  #preview-style-btn {
    flex: 0 0 auto;
    width: auto;
    padding: 8px 16px;
    align-self: flex-start;
  }

  .settings-section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .theme-panel {
    padding: 12px;
  }
}

/* ============================================================
   v4.1.18：应用内报价预览弹窗（PWA standalone 不再 window.open）
   ============================================================ */
#preview-modal .modal-dialog {
  max-width: 860px;
}
#preview-modal .modal-body {
  background: #f0f4f5;
}
#preview-modal .modal-header {
  flex-wrap: wrap;
  gap: 8px;
}
#preview-modal .modal-title {
  font-size: 16px;
}
/* 含成本/不含成本切换标签（原预览窗口样式迁入应用内） */
#preview-modal-tabs {
  display: flex;
  gap: 4px;
  background: var(--teal-soft);
  border-radius: 8px;
  padding: 3px;
}
#preview-modal-tabs .preview-tab {
  padding: 6px 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
#preview-modal-tabs .preview-tab.active {
  background: #fff;
  color: var(--teal-dark);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
#preview-modal-tabs .preview-tab:hover {
  color: var(--ink);
}
#preview-modal .preview-content {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  padding: 32px 40px;
}
#preview-modal .preview-print-btn {
  padding: 6px 16px;
  border: 1px solid var(--teal);
  border-radius: 7px;
  background: var(--teal);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}
#preview-modal .preview-print-btn:hover {
  background: var(--teal-dark);
}
@media (max-width: 768px) {
  #preview-modal .preview-content {
    padding: 16px 12px;
  }
}

/* v4.8：导出遮罩——导出过程中拦截一切点击防中断（toast z-index 10000 在其上方仍可见） */
#export-overlay {
  position: fixed;
  inset: 0;
  z-index: 9990;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: wait;
}
.export-overlay-box {
  background: #ffffff;
  border-radius: 12px;
  padding: 26px 38px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.25);
}
.export-overlay-box p {
  margin: 12px 0 0;
  font-size: 14px;
  color: var(--ink);
  font-weight: 600;
}
.export-spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto;
  border: 4px solid var(--teal-soft);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: export-spin 0.8s linear infinite;
}
@keyframes export-spin {
  to { transform: rotate(360deg); }
}

.preview-page .quote-document {
  width: 794px;
}

/* 打印：只输出预览内容（隐藏应用界面与弹窗头尾），一页 A4 完整显示 */
@media print {
  /* v4.1.21：显式 A4 纸型——缺 size 时 Chrome 默认 Letter（612×792pt）比 A4 矮，
     内容高度溢出产生空白第二页。
     v4.1.24：margin 0 收窄左右边距（默认 1cm 边距 + 内容居中留白约 117px/边，
     用户反馈边距过大）——内容 635px（zoom 0.8）在 A4 内居中约 79px/边；
     若打印机不支持零边距会自动施加最小边距，内容仍完整 */
  @page {
    size: A4;
    /* v4.9：四周统一边距——打印始终自然分页（单页/分页设置仅影响 PDF 文件导出），
       每一页（含第 2 页起）上下左右都有边距，内容不贴页顶/页侧 */
    margin: 10mm 12mm;
  }
  /* v4.1.23：body 默认背景 #f4f7fa 淡灰——打印（背景图形开启）时会在内容
     右侧/底部露出灰带，必须强制白色 */
  html,
  body {
    background: #fff !important;
  }
  .app-shell,
  .mobile-nav,
  .mobile-quote-bar,
  .app-toast,
  .modal-backdrop,
  /* v4.9 二次修复：返回顶部按钮为 fixed 固定定位，打印时会在每一页出现，必须隐藏 */
  #back-to-top,
  /* v4.1.21：隐藏 PDF 渲染舞台与未激活视图（否则打印多占一页） */
  #export-stage,
  .app-view:not(.active) {
    display: none !important;
  }
  #preview-modal {
    position: static !important;
    display: block !important;
    opacity: 1 !important;
    /* v4.9 二次修复：清除 Bootstrap .modal 的 overflow-y: auto 滚动裁剪，
       否则打印内容可能被截断显示不完整 */
    overflow: visible !important;
  }
  #preview-modal .modal-dialog {
    max-width: none !important;
    margin: 0 !important;
  }
  #preview-modal .modal-content {
    border: 0 !important;
    box-shadow: none !important;
    /* v4.1.21：清除 Bootstrap modal-dialog-scrollable 的高度限制与滚动裁剪 */
    max-height: none !important;
    overflow: visible !important;
  }
  #preview-modal .modal-header,
  #preview-modal .modal-footer {
    display: none !important;
  }
  #preview-modal .modal-body {
    padding: 0 !important;
    background: #fff !important;
    overflow: visible !important;
  }
  #preview-modal .preview-content {
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    /* v4.1.25：打印比例接近预览窗口（90%），上下恢复页边距（margin 0 后顶部
       紧贴页面边缘，用户反馈），左右居中留白随内容放大自然收窄。
       zoom 0.9 → 内容 715px：A4(margin 0) 内左右留白约 40px，硬件边距
       (3-5mm) 后仍完整（可用 ≈756px > 715px） */
    /* v4.9：zoom 适配 @page 四周边距后的可打印宽度（186mm ≈ 703px）；
       二次修复：0.88 时内容 528.0pt 对可打印区 527.2pt 贴边溢出 0.8pt
       （表格右边框会被切，平台四舍五入差异导致“有时候”截断）——
       0.87 → 内容 ≈518pt，留出约 9pt（≈3.4mm）余量 */
    zoom: 0.87;
    margin: 0 auto;
  }
  .pdf-table tr,
  .pdf-note,
  .pdf-totals,
  .pdf-info-grid > div,
  .pdf-hero,
  .pdf-footer {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  #export-overlay {
    display: none !important;
  }
  body.modal-open {
    overflow: visible !important;
  }
}

/* ============================================================
   v4.1 增强段：Bootstrap 兼容 + PDF 舞台隔离 + 离线横幅
   （Bootstrap reset 会影响 html2canvas 截图的 PDF 排版，
    此处恢复 #export-stage 内部为 content-box 基线）
   ============================================================ */

/* ---- PDF 导出舞台隔离（防止 Bootstrap 全局 reset 改变 PDF 排版） ---- */
#export-stage,
#export-stage *,
#export-stage *::before,
#export-stage *::after {
  box-sizing: content-box;
}
#export-stage {
  font-family: "Microsoft YaHei UI", "PingFang SC", "Segoe UI", sans-serif;
  line-height: normal;
  font-size: 14px;
}

/* ---- 离线模式横幅 ---- */
.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1080;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: linear-gradient(135deg, #b45309, #d97706);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(180, 83, 9, 0.35);
  letter-spacing: 0.2px;
}
.offline-banner svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ---- Bootstrap 弹窗与现有主题融合 ---- */
.modal-content {
  border: none;
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.18);
}
.modal-header {
  border-bottom: 1px solid var(--line);
  padding: 14px 18px;
  background: var(--teal-soft);
  border-radius: 14px 14px 0 0;
}
.modal-title {
  color: var(--teal-dark);
  font-weight: 700;
  font-size: 16px;
}
.modal-body {
  padding: 18px;
  color: var(--ink);
}
.modal-footer {
  border-top: 1px solid var(--line);
  padding: 12px 18px;
  gap: 8px;
}
.btn-close {
  filter: none;
  opacity: 0.6;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.btn-close:hover {
  opacity: 1;
  transform: rotate(90deg);
}

/* ---- 表单控件与现有主题融合 ---- */
.form-control,
.form-select {
  border-color: var(--line);
  border-radius: 8px;
  color: var(--ink);
}
.form-control:focus,
.form-select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 0.2rem var(--accent-shadow);
}

/* ---- 美化微调：阴影、过渡统一 ---- */
.tool-button,
.icon-button,
.icon-button-sm {
  transition: background-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
.tool-button:active,
.icon-button:active,
.icon-button-sm:active {
  transform: scale(0.97);
}
.catalog-panel,
.quote-panel,
.history-workspace,
.source-workspace-panel {
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
}
.history-card {
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.history-card:hover {
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.10);
  transform: translateY(-1px);
}

/* ---- 批量修改弹窗字段（Bootstrap modal 内布局） ---- */
.batch-edit-field {
  display: grid;
  grid-template-columns: 76px 1fr;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.batch-edit-field label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}
.batch-edit-field select,
.batch-edit-field input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
}
.batch-edit-field select:focus,
.batch-edit-field input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 0.2rem var(--accent-shadow);
}

/* ============================================================
   v4.1.1 PDF 自定义样式可视化编辑器
   ============================================================ */

/* ---- 设置页入口 ---- */
.pdf-editor-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, var(--teal-soft), #ffffff);
  border: 1px solid var(--line);
  border-radius: 12px;
  /* v4.1.17：防内容撑宽 */
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}
.pdf-editor-entry-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.pdf-editor-entry-text strong {
  font-size: 14px;
  color: var(--ink);
}
.pdf-editor-entry-text span {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  /* v4.1.17：长描述换行防溢出 */
  overflow-wrap: break-word;
  word-break: break-word;
}

/* 客户/供应商管理：标签页行防撑宽（index.html 内联 flex-wrap） */
.template-tabs {
  min-width: 0;
  max-width: 100%;
}
.template-tabs .tool-button {
  min-width: 0;
  flex: 0 0 auto;
}

/* ---- 编辑器视图整体布局 ---- */
.pdf-editor-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.pdf-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.pdf-editor-head h3 {
  font-size: 16px;
  color: var(--ink);
  margin-bottom: 2px;
}
.pdf-editor-head p {
  font-size: 12px;
  color: var(--muted);
}
.pdf-editor-head-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}
.pdf-editor-body {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 0;
  flex: 1;
  min-height: 0;
}

/* ---- 左栏控件面板 ---- */
.pdf-editor-panel {
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 14px 16px 24px;
}
.pdf-editor-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-hover);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 14px;
}
.pdf-editor-tab {
  flex: 1;
  padding: 7px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.pdf-editor-tab.active {
  background: var(--surface);
  color: var(--teal);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}
.pdf-editor-tabpane {
  display: none;
}
.pdf-editor-tabpane.active {
  display: block;
}
.pdf-editor-group {
  margin-bottom: 18px;
  padding: 12px;
  background: var(--surface-hover);
  border-radius: 10px;
}
.pdf-editor-group-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 10px;
}
.pdf-editor-group-head strong {
  font-size: 13px;
  color: var(--ink);
}
.pdf-editor-group-head span {
  font-size: 11px;
  color: var(--muted);
}
.pdf-editor-group select.custom-css-load-select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  background: var(--surface);
  color: var(--ink);
}

/* ---- 模块拖拽列表 ---- */
.pdf-editor-module-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pdf-editor-module {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: grab;
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.15s;
  user-select: none;
}
.pdf-editor-module:hover {
  border-color: var(--teal);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}
.pdf-editor-module.dragging {
  opacity: 0.55;
  border-style: dashed;
  cursor: grabbing;
}
.pdf-editor-module.drop-before {
  border-top: 2px solid var(--teal);
}
.pdf-editor-module.drop-after {
  border-bottom: 2px solid var(--teal);
}
.pdf-editor-module-drag {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: -1px;
  flex-shrink: 0;
}
.pdf-editor-module-label {
  flex: 1;
  font-size: 13px;
  color: var(--ink);
}

/* ---- 开关 ---- */
.pdf-editor-switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 21px;
  flex-shrink: 0;
  cursor: pointer;
}
.pdf-editor-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.pdf-editor-switch span {
  position: absolute;
  inset: 0;
  background: var(--line);
  border-radius: 21px;
  transition: background 0.2s;
}
.pdf-editor-switch span::before {
  content: "";
  position: absolute;
  width: 15px;
  height: 15px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.pdf-editor-switch input:checked + span {
  background: var(--teal);
}
.pdf-editor-switch input:checked + span::before {
  transform: translateX(17px);
}
.pdf-editor-switch.small {
  width: 34px;
  height: 19px;
}
.pdf-editor-switch.small span::before {
  width: 13px;
  height: 13px;
}
.pdf-editor-switch.small input:checked + span::before {
  transform: translateX(15px);
}
.pdf-editor-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 2px;
  font-size: 13px;
  color: var(--ink);
}

/* ---- 配色 ---- */
.pdf-editor-color-reset {
  margin-bottom: 8px;
}
.pdf-editor-color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 0;
}
.pdf-editor-color-row > span {
  font-size: 13px;
  color: var(--ink);
}
.pdf-editor-color-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pdf-editor-color-inputs input[type="color"] {
  width: 42px;
  height: 28px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}
.pdf-editor-color-inputs input[type="color"].follow-theme {
  opacity: 0.45;
}

/* ---- 滑块 ---- */
.pdf-editor-slider-row {
  padding: 6px 0;
}
.pdf-editor-slider-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--ink);
  margin-bottom: 4px;
}
.pdf-editor-slider-value {
  color: var(--teal);
  font-weight: 700;
  font-size: 12px;
}
.pdf-editor-slider-row input[type="range"] {
  width: 100%;
  accent-color: var(--teal);
  cursor: pointer;
}

/* ---- 头部样式分段选择 ---- */
.pdf-editor-segmented {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border-radius: 8px;
  padding: 3px;
}
.pdf-editor-segmented button {
  flex: 1;
  padding: 6px 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
.pdf-editor-segmented button.active {
  background: var(--teal);
  color: #fff;
}

/* ---- 高级页 CSS 编辑 ---- */
.pdf-editor-css-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.pdf-editor-css-toolbar select {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  background: var(--surface);
  color: var(--ink);
}
.pdf-editor-panel textarea {
  width: 100%;
  min-height: 260px;
  padding: 12px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  resize: vertical;
  tab-size: 2;
}
.pdf-editor-panel textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--accent-shadow);
}

/* ---- 右栏实时预览 ---- */
.pdf-editor-preview-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: #eef2f5;
}
.pdf-editor-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.pdf-editor-preview-hint {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
}
.pdf-editor-preview {
  flex: 1;
  overflow: auto;
  padding: 16px;
  min-height: 0;
}
.pdf-editor-preview .quote-document {
  box-shadow: 0 6px 24px rgba(15, 23, 42, 0.14);
}

/* ---- 移动端：单列布局 ---- */
@media (max-width: 900px) {
  .pdf-editor-body {
    grid-template-columns: 1fr;
  }
  

  .pdf-editor-panel {
    border-right: none;
    border-bottom: 1px solid var(--line);
    max-height: 46vh;
  }
  .pdf-editor-preview-wrap {
    min-height: 55vh;
  }
  .pdf-editor-entry {
    flex-direction: column;
    align-items: stretch;
    text-align: left;
  }
  .pdf-editor-entry .tool-button {
    align-self: flex-start;
    /* v4.1.16：取消 flex-grow/basis——移动端全局 .tool-button flex:1 1 148px 的
       基础尺寸在纵向布局中作用于高度，把"打开编辑器"按钮撑到 148px 高
       （与 #preview-style-btn/.backup-actions 的既有修复同源） */
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
  }
}


/* ---- v4.1.4 模块排版预设卡（样式标签页，UI 重设计） ---- */
.pdf-editor-style-reset-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}
.pdf-editor-preset-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.pdf-editor-preset-head > span {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.pdf-editor-preset-reset {
  font-size: 11px;
  color: var(--teal);
  background: var(--teal-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.pdf-editor-preset-reset:hover {
  background: var(--teal);
  color: #fff;
}
.style-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  gap: 6px;
}
.style-card {
  position: relative;
  padding: 7px 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease, border-color 0.15s, background 0.15s;
}
.style-card:hover {
  transform: translateY(-2px);
  border-color: var(--teal);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.10);
}
.style-card:active {
  transform: scale(0.97);
}
.style-card.active {
  border-color: var(--teal);
  background: var(--teal);
  box-shadow: 0 0 0 2px var(--accent-shadow);
}
.style-card.active .pdf-editor-preset-name {
  color: #fff;
  font-weight: 700;
}
.style-mini {
  width: 100%;
  height: 32px;
  border-radius: 7px;
  border: 1px solid rgba(0, 0, 0, 0.10);
  display: block;
  background-size: cover;
  background-position: center;
  margin-bottom: 5px;
}
.style-card .pdf-editor-preset-name {
  display: block;
  text-align: center;
  font-size: 10.5px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* 预览更新反馈闪烁 */
.pdf-editor-preview-hint {
  transition: color 0.3s;
}
.pdf-editor-preview-hint.flash {
  color: var(--teal);
  font-weight: 700;
}

/* 分组容器基础样式（样式页/配色页共用） */
.pdf-editor-preset-group {
  margin-bottom: 16px;
}

/* ---- v4.1.6 预览模式徽标与刷新按钮 ---- */
.pdf-editor-mode-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  border: 1px solid var(--line);
}
.pdf-editor-mode-badge.css-mode {
  background: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
}
.pdf-editor-refresh-preview {
  font-size: 11px;
  padding: 3px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.pdf-editor-refresh-preview:hover {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}

/* ---- v4.1.7 设置页 CSS 自定义模式编辑区块 ---- */
.custom-css-mode-editor {
  margin-top: 12px;
  padding: 12px;
  background: var(--surface-hover);
  border-radius: 10px;
}
.custom-css-mode-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.custom-css-mode-toolbar select {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  background: var(--surface);
  color: var(--ink);
}
.custom-css-mode-editor textarea {
  width: 100%;
  min-height: 220px;
  padding: 12px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  resize: vertical;
  tab-size: 2;
}
.custom-css-mode-editor textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--accent-shadow);
}

/* v4.1.35：返回顶部按钮（右下角固定，滚动后显示） */
#back-to-top {
  position: fixed;
  right: 24px;
  bottom: 28px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s, visibility 0.25s;
  z-index: 1040;
}
#back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
#back-to-top:hover {
  opacity: 0.88;
}
/* 移动端：避开底部导航栏 */
@media (max-width: 760px) {
  #back-to-top {
    right: 14px;
    bottom: 78px;
    width: 40px;
    height: 40px;
    font-size: 18px;
  }
  /* v4.1.35：浮动报价栏显示时按钮上移（栏占 bottom 64~116px，JS 切换 .lift） */
  #back-to-top.lift {
    bottom: 148px;
  }
}
