:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --line: #d9dee7;
  --text: #1b1f27;
  --muted: #687386;
  --accent: #16745f;
  --accent-strong: #0f5f4d;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --success: #087443;
  --success-bg: #edfdf4;
  --shadow: 0 18px 60px rgba(15, 23, 42, 0.18);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.page-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.page-header {
  align-items: flex-end;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.title-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  font-weight: 720;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0;
}

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

.button,
.icon-button {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  justify-content: center;
  min-height: 36px;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.button {
  background: var(--surface);
  color: var(--text);
  padding: 0 14px;
}

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

.button.primary:hover {
  background: var(--accent-strong);
}

.button.subtle {
  min-height: 30px;
  padding: 0 10px;
}

.button[aria-current="page"] {
  border-color: var(--accent);
  color: var(--accent);
}

.icon-button {
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  height: 36px;
  line-height: 1;
  padding: 0;
  width: 36px;
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}

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

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

th {
  background: #eef2f6;
  color: #384253;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

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

.address-cell {
  max-width: 360px;
  min-width: 240px;
}

.identifier-cell {
  min-width: 180px;
  overflow-wrap: anywhere;
}

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

.notice {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
}

.notice.error {
  background: var(--danger-bg);
  border-color: #ffc9c4;
  color: var(--danger);
}

.modal,
.image-modal,
.translation-modal {
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0;
}

.modal::backdrop,
.image-modal::backdrop,
.translation-modal::backdrop {
  background: rgba(15, 23, 42, 0.48);
}

.modal-panel,
.translation-modal-panel {
  background: var(--surface);
  display: grid;
  gap: 16px;
  max-height: min(82vh, 860px);
  padding: 18px;
  width: min(1080px, calc(100vw - 36px));
}

.translation-modal-panel {
  width: min(560px, calc(100vw - 36px));
}

.historical-preview-modal-panel {
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  width: min(1320px, calc(100vw - 36px));
}

.historical-preview-search {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.historical-preview-workspace {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(230px, 300px) minmax(0, 1fr);
  min-height: 430px;
  overflow: hidden;
  padding-top: 16px;
}

.historical-preview-results {
  align-content: start;
  display: grid;
  gap: 8px;
  overflow: auto;
  padding-right: 4px;
}

.historical-preview-result {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  display: grid;
  gap: 4px;
  padding: 10px;
  text-align: left;
  width: 100%;
}

.historical-preview-result:hover,
.historical-preview-result.selected {
  border-color: var(--accent);
}

.historical-preview-result.selected {
  background: rgba(22, 116, 95, 0.1);
  box-shadow: inset 0 0 0 1px rgba(22, 116, 95, 0.14);
}

.historical-preview-result strong,
.historical-preview-result span,
.historical-preview-result small {
  overflow-wrap: anywhere;
}

.historical-preview-result span,
.historical-preview-result small {
  color: var(--muted);
}

.historical-preview-template {
  border-left: 1px solid var(--line);
  min-width: 0;
  overflow: auto;
  padding-left: 16px;
}

.historical-preview-template-content {
  min-height: 100%;
}

.historical-preview-paper {
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  color: #000000;
  font-family: "Microsoft YaHei", "微软雅黑", "Arial Unicode MS", Arial, sans-serif;
  margin: 0 auto;
  max-width: 760px;
  padding: 28px 36px;
}

.historical-preview-paper h3 {
  font-size: 18px;
  margin: 0 0 8px;
  text-align: center;
}

.historical-preview-paper p {
  font-size: 13px;
  font-weight: 600;
  margin: 2px 0;
}

.historical-preview-paper table {
  border: 1px solid #000000;
  border-collapse: collapse;
  margin-top: 18px;
  table-layout: fixed;
  width: 100%;
}

.historical-preview-paper td {
  border: 1px solid #000000;
  font-size: 12px;
  padding: 5px 6px;
  vertical-align: top;
  word-break: break-word;
}

.historical-preview-paper td:first-child {
  text-align: right;
  width: 100px;
}

.historical-preview-paper img {
  display: inline-block;
  height: auto;
  margin: 2px 4px 2px 0;
  max-height: 88px;
  max-width: 100%;
  vertical-align: middle;
}

.historical-preview-missing {
  color: var(--danger);
}

.modal-header,
.modal-footer,
.actions {
  align-items: center;
  display: flex;
  gap: 12px;
}

.modal-header,
.modal-footer {
  justify-content: space-between;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: #384253;
  font-weight: 650;
}

textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  min-height: 58vh;
  padding: 12px;
  resize: vertical;
  width: 100%;
}

textarea:focus,
.button:focus-visible,
.icon-button:focus-visible {
  outline: 3px solid rgba(22, 116, 95, 0.24);
  outline-offset: 2px;
}

.status {
  color: var(--muted);
  min-height: 20px;
}

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

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

.tabs {
  align-items: center;
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.tab {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  display: inline-flex;
  min-height: 38px;
  padding: 0 14px;
  text-decoration: none;
}

.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.translation-panel {
  display: none;
}

.translation-panel.active {
  display: block;
}

.translation-table th:nth-child(1),
.translation-table td:nth-child(1) {
  width: 48%;
}

.translation-table th:nth-child(2),
.translation-table td:nth-child(2) {
  width: 34%;
}

.translation-table th:nth-child(3),
.translation-table td:nth-child(3) {
  min-width: 180px;
  width: 18%;
}

.readonly-source {
  color: #243041;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.source-separator {
  color: var(--muted);
  padding: 0 6px;
}

.text-input {
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  min-height: 36px;
  padding: 0 10px;
  width: 100%;
}

.text-input:focus {
  outline: 3px solid rgba(22, 116, 95, 0.24);
  outline-offset: 2px;
}

.row-status {
  display: inline-flex;
  margin-left: 8px;
  min-width: 72px;
}

.original-text,
.translated-text {
  display: block;
  overflow-wrap: anywhere;
}

.translated-text {
  color: var(--accent);
  font-size: 13px;
  margin-top: 3px;
}

.purchase-shell {
  width: min(1480px, calc(100% - 28px));
}

.purchase-preview-shell {
  width: min(1760px, calc(100% - 28px));
}

.purchase-editor-layout {
  align-items: start;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
}

.purchase-preview-layout {
  align-items: start;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(280px, 340px) minmax(360px, 1fr) 406px;
}

.purchase-preview-layout.is-product-gallery-collapsed {
  grid-template-columns: minmax(280px, 340px) minmax(360px, 1fr);
}

.preview-source-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 16px;
  max-height: calc(100vh - 128px);
  overflow: auto;
  padding: 14px;
  position: sticky;
  top: 14px;
}

.product-gallery-panel {
  align-content: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  max-height: calc(100vh - 128px);
  overflow: auto;
  padding: 14px;
  position: sticky;
  top: 14px;
}

.product-gallery-panel-header {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 2px;
  padding-bottom: 10px;
}

.product-gallery-panel-title-row {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.product-gallery-panel-header h2,
.product-gallery-sku {
  font-size: 14px;
  margin: 0;
}

.product-gallery-panel-header .muted {
  font-size: 12px;
  margin: 0;
}

.preview-source-section {
  display: grid;
  gap: 10px;
}

.preview-source-grid,
.preview-option-actions,
.preview-product-primary,
.preview-product-secondary,
.preview-order-summary {
  display: grid;
  gap: 8px;
}

.preview-order-summary {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.preview-product-primary {
  grid-template-columns: minmax(0, 1.4fr) minmax(84px, 96px) minmax(92px, 0.8fr);
}

.preview-product-secondary,
.preview-option-meta {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.preview-option-actions {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(84px, 96px);
}

.preview-source-card,
.preview-option-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 10px;
}

.preview-product-options {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  padding-top: 10px;
}

.preview-product-options h3 {
  font-size: 13px;
  margin: 0;
}

.preview-product-options .muted {
  font-size: 12px;
  margin: 0;
}

.preview-product-option {
  display: grid;
  gap: 8px;
}

.preview-source-button {
  align-items: start;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  display: grid;
  gap: 4px;
  min-height: 42px;
  min-width: 0;
  padding: 8px 10px;
  text-align: left;
  width: 100%;
}

.preview-source-button:hover {
  border-color: var(--accent);
}

.preview-source-button.preview-source-used {
  background: rgba(255, 224, 102, 0.32);
  border-color: rgba(196, 145, 2, 0.62);
  box-shadow: inset 0 0 0 1px rgba(196, 145, 2, 0.18);
}

.preview-source-button.preview-source-used span {
  color: #8a6400;
}

.preview-source-button:disabled {
  cursor: default;
  opacity: 0.58;
}

.preview-source-button span {
  color: var(--muted);
  font-size: 12px;
}

.preview-source-button strong {
  font-weight: 650;
  overflow-wrap: anywhere;
}

.preview-contact-list {
  display: grid;
  gap: 8px;
}

.preview-contact-field {
  align-items: start;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 8px 10px;
}

.preview-contact-field-content {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.preview-contact-field-content span {
  color: var(--muted);
  font-size: 12px;
}

.preview-contact-field-content strong {
  font-weight: 650;
  overflow-wrap: anywhere;
}

.preview-copy-button {
  align-self: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--accent-strong);
  cursor: pointer;
  font-size: 12px;
  padding: 5px 8px;
}

.preview-copy-button:hover {
  border-color: var(--accent);
}

.preview-copy-button:disabled {
  cursor: default;
  opacity: 0.55;
}

.preview-copy-status {
  color: var(--accent-strong);
  font-size: 11px;
  grid-column: 1 / -1;
  min-height: 14px;
}

.preview-source-reference-ids {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 2px;
}

.preview-source-button .preview-source-reference-id {
  background: #1e3a5f;
  color: #ffffff;
  font-size: 9px;
  line-height: 15px;
  margin: 0;
}

.preview-source-button.preview-source-used .preview-source-reference-id {
  color: #ffffff;
}

.preview-product-primary .preview-source-button,
.preview-product-secondary .preview-source-button,
.preview-option-actions .preview-source-button {
  height: 100%;
}

.preview-source-thumb {
  border: 1px solid var(--line);
  border-radius: 6px;
  height: 72px;
  max-width: 100%;
  object-fit: cover;
  width: 72px;
}

.woocommerce-product-images {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  padding-top: 14px;
}

.woocommerce-product-image-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, 120px);
  justify-content: start;
}

.woocommerce-product-image-grid button {
  appearance: none;
  background: #ffffff;
  border: 0;
  border-radius: 6px;
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
  overflow: hidden;
  padding: 0;
  width: 120px;
}

.woocommerce-product-image-grid img {
  display: block;
  height: auto;
  width: 120px;
}

.woocommerce-product-image-grid button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.preview-options-list {
  display: grid;
  gap: 10px;
}

.preview-option-meta {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  gap: 8px;
}

.preview-option-meta span {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-width: 0;
  padding: 7px 10px;
  white-space: nowrap;
}

.function-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  margin-bottom: 0;
  max-height: calc(100vh - 128px);
  padding: 12px;
  position: sticky;
  top: 14px;
}

.function-panel-header {
  align-items: stretch;
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 10px;
}

.function-search {
  max-width: none;
}

.function-search-status {
  min-height: 18px;
}

.function-groups {
  display: grid;
  gap: 12px;
  max-height: none;
  overflow: auto;
  padding-right: 4px;
}

.function-group {
  display: grid;
  gap: 6px;
}

.function-group > strong {
  color: #384253;
}

.function-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.function-chip {
  background: #f7fafc;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  gap: 6px;
  max-width: 100%;
  min-height: 30px;
  padding: 4px 10px;
}

.function-chip span {
  color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
}

.function-chip small {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.purchase-template-wrap {
  overflow: auto;
  padding-bottom: 12px;
}

.purchase-template-gallery-toggle {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
  min-height: 30px;
}

.purchase-template-gallery-toggle[hidden] {
  display: none;
}

.purchase-order-manager {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px;
}

.purchase-order-manager-header {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.purchase-order-manager-header h2 {
  font-size: 14px;
  margin: 0;
}

.purchase-order-manager-header .muted {
  font-size: 12px;
  margin: 3px 0 0;
}

.purchase-order-manager-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.purchase-order-template-selector {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  min-height: 36px;
  padding: 0 28px 0 10px;
}

.purchase-order-template-selector:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.purchase-order-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.purchase-order-switcher-item {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  min-height: 32px;
  padding: 0 12px;
}

.purchase-order-switcher-item:hover,
.purchase-order-switcher-item.active {
  border-color: var(--accent);
  color: var(--accent);
}

.purchase-order-switcher-item.active {
  background: rgba(22, 116, 95, 0.1);
  box-shadow: inset 0 0 0 1px rgba(22, 116, 95, 0.14);
  font-weight: 650;
}

.po-page {
  background: #ffffff;
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.16);
  color: #000000;
  font-family: "Microsoft YaHei", "微软雅黑", "Arial Unicode MS", Arial, sans-serif;
  font-size: 13.5px;
  line-height: 1.25;
  margin: 0 auto;
  min-height: 297mm;
  padding: 25.4mm 31.75mm;
  width: 210mm;
}

.po-title {
  color: #000000;
  font-size: 18.5px;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 4px;
  min-height: 23px;
  text-align: center;
}

.po-meta {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  margin: 0;
}

.po-meta + .po-meta {
  margin-top: 2px;
}

.po-table {
  border: 1px solid #000000;
  border-collapse: collapse;
  margin-top: 24px;
  min-width: 0;
  table-layout: fixed;
  width: 100%;
}

.po-table col:first-child {
  width: 100px;
}

.po-table col:last-child {
  width: auto;
}

.po-table td {
  border: 1px solid #000000;
  color: #000000;
  font-size: 13.5px;
  font-weight: 400;
  line-height: 1.25;
  min-height: 20px;
  padding: 5px 6px;
  vertical-align: middle;
}

.po-table td:first-child {
  text-align: right;
  overflow-wrap: anywhere;
  white-space: normal;
}

.po-table td:last-child {
  cursor: text;
  text-align: left;
  word-break: break-word;
}

.po-table .image-row td {
  height: 87px;
  vertical-align: top;
}

.po-table .tall-row td {
  height: 44px;
  vertical-align: top;
}

.po-table .tall-row td:last-child {
  font-weight: 700;
}

.po-template-select {
  background: #ffffff;
  border: 1px solid #707070;
  color: #000000;
  font: inherit;
  font-weight: 700;
  max-width: 100%;
  min-width: 120px;
  padding: 3px 28px 3px 6px;
}

.po-template-select-field {
  align-items: start;
  display: grid;
  gap: 6px;
  grid-template-columns: minmax(0, 1fr);
}

.po-template-select-editor {
  min-height: 26px;
  outline: none;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  word-break: break-word;
}

.po-table .compact-row td {
  height: 20px;
}

.po-table .text-row td {
  height: 164px;
  vertical-align: top;
}

[data-po-field],
[data-po-row],
[data-preview-field],
[data-preview-row] {
  min-height: 18px;
  outline: none;
}

[data-po-field].editing,
[data-po-row].editing {
  background: rgba(255, 236, 153, 0.35);
  box-shadow: inset 0 0 0 1px rgba(196, 145, 2, 0.35);
}

.missing-token {
  color: var(--danger);
}

.missing-translation {
  color: #9a5b00;
}

.translation-form {
  display: grid;
  gap: 12px;
}

.po-rendered-image {
  display: inline-block;
  height: auto;
  margin: 2px 6px 2px 0;
  max-height: 100px;
  max-width: 100%;
  vertical-align: middle;
}

.preview-token {
  display: inline-block;
  max-width: 100%;
  vertical-align: middle;
  white-space: pre-wrap;
}

.preview-source-token {
  margin: 1px 3px 1px 0;
}

.preview-reference-token {
  align-items: center;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 3px;
}

.preview-reference-editable {
  cursor: text;
}

.preview-reference-value {
  border-bottom: 1px dashed rgba(30, 58, 95, 0.58);
  min-width: 1ch;
  outline: 0;
  padding: 0 1px;
  white-space: pre-wrap;
}

.preview-reference-value:focus {
  background: rgba(219, 234, 254, 0.78);
  border-bottom-color: #1d4ed8;
}

.preview-reference-badge {
  background: #1e3a5f;
  border-radius: 3px;
  color: #ffffff;
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
  line-height: 17px;
  margin: 1px 1px 1px 0;
  max-width: 100%;
  overflow: hidden;
  padding: 0 5px;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}

.historical-preview-reference-badge {
  background: #334155;
  font-size: 9px;
  line-height: 15px;
  margin-right: 3px;
}

.preview-token .po-rendered-image {
  margin: 1px 2px;
}

.preview-manual-image-token {
  line-height: 0;
  position: relative;
}

.preview-manual-image-token .po-rendered-image {
  display: block;
  height: auto;
  max-height: none;
  max-width: none;
  margin: 0;
}

.preview-image-resize-handle {
  background: #1e3a5f;
  border: 2px solid #ffffff;
  border-radius: 3px;
  bottom: -5px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.45);
  cursor: nwse-resize;
  display: block;
  height: 11px;
  position: absolute;
  right: -5px;
  width: 11px;
  z-index: 2;
}

.preview-manual-image-token:hover .preview-image-resize-handle,
.preview-manual-image-token:focus-within .preview-image-resize-handle {
  opacity: 1;
}

.preview-token-missing {
  background: var(--danger-bg);
  border: 1px solid #ffc9c4;
  border-radius: 4px;
  color: var(--danger);
  margin: 1px 3px 1px 0;
  min-height: 18px;
  padding: 1px 4px;
}

.preview-token-needs-translation {
  background: rgba(255, 236, 153, 0.9);
}

.preview-manual-format[data-preview-format~="bold"] {
  font-weight: 700;
}

.preview-manual-format[data-preview-format~="italic"] {
  font-style: italic;
}

.preview-manual-format[data-preview-format~="underline"] {
  text-decoration: underline;
}

.preview-manual-format[data-preview-format~="strikethrough"] {
  text-decoration: line-through;
}

.preview-manual-format[data-preview-format~="text-black"] {
  color: #111827;
}

.preview-manual-format[data-preview-format~="text-blue"] {
  color: #1d4ed8;
}

.preview-manual-format[data-preview-format~="text-red"] {
  color: #b91c1c;
}

.preview-manual-format[data-preview-format~="text-green"] {
  color: #047857;
}

.preview-manual-format[data-preview-format~="text-brown"] {
  color: #92400e;
}

.preview-manual-format[data-preview-format~="background-graphite"] {
  background: #1f2937;
  color: #ffffff;
}

.preview-manual-format[data-preview-format~="background-navy"] {
  background: #1e3a5f;
  color: #ffffff;
}

.preview-manual-format[data-preview-format~="background-wine"] {
  background: #5b2137;
  color: #ffffff;
}

.preview-manual-format[data-preview-format~="background-forest"] {
  background: #14532d;
  color: #ffffff;
}

.preview-manual-format[data-preview-format~="background-ochre"] {
  background: #713f12;
  color: #ffffff;
}

.preview-format-toolbar {
  align-items: center;
  background: #18212f;
  border: 1px solid #334155;
  border-radius: 6px;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.3);
  display: flex;
  gap: 7px;
  padding: 7px;
  position: fixed;
  transform: translateX(-50%);
  z-index: 20;
}

.preview-format-toolbar[hidden] {
  display: none;
}

.preview-format-bold,
.preview-format-swatch {
  border: 1px solid transparent;
  cursor: pointer;
  flex: 0 0 auto;
}

.preview-format-bold {
  background: #f8fafc;
  border-radius: 4px;
  color: #111827;
  font-family: Georgia, serif;
  font-size: 16px;
  font-weight: 700;
  height: 26px;
  line-height: 1;
  width: 30px;
}

.preview-format-size {
  background: #f8fafc;
  border: 1px solid transparent;
  border-radius: 4px;
  color: #111827;
  cursor: pointer;
  flex: 0 0 auto;
  font-size: 12px;
  height: 26px;
  min-width: 58px;
  padding: 0 5px;
}

.preview-format-swatch {
  background: var(--preview-swatch-color);
  border-radius: 50%;
  height: 18px;
  width: 18px;
}

.preview-format-swatch-text {
  box-shadow: inset 0 -3px 0 rgba(255, 255, 255, 0.72);
}

.preview-format-swatch:focus-visible,
.preview-format-bold:focus-visible,
.preview-format-size:focus-visible {
  outline: 2px solid #f8fafc;
  outline-offset: 2px;
}

.preview-format-divider {
  background: #475569;
  height: 20px;
  width: 1px;
}

.purchase-actions {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  margin: 14px auto 0;
  padding: 12px;
  width: min(210mm, 100%);
}

.purchase-actions-leading {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hidden-form {
  display: none;
}

@media print {
  .function-panel,
  .preview-source-panel,
  .product-gallery-panel,
  .purchase-actions,
  .page-header {
    display: none;
  }

  .po-page {
    box-shadow: none;
    margin: 0;
  }

  .po-table,
  .po-table td {
    border-color: transparent;
  }
}

.back-link {
  color: var(--accent);
  display: inline-flex;
  margin-bottom: 6px;
  text-decoration: none;
}

.detail-summary {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 0;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 22px;
}

.detail-summary div {
  border-right: 1px solid var(--line);
  display: grid;
  gap: 4px;
  padding: 14px;
}

.detail-summary div:last-child {
  border-right: 0;
}

.detail-summary span {
  color: var(--muted);
  font-size: 12px;
}

.detail-summary strong {
  font-weight: 650;
  overflow-wrap: anywhere;
}

.section-block {
  margin-top: 22px;
}

.section-heading {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.thumb-image {
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: zoom-in;
  height: 100px;
  max-width: 140px;
  object-fit: cover;
}

.image-modal {
  background: #0b111c;
  max-height: calc(100vh - 32px);
  max-width: min(92vw, 1200px);
  overflow: hidden;
  padding: 52px 16px 16px;
  width: min(92vw, 1200px);
}

.image-viewport {
  align-items: center;
  display: flex;
  justify-content: center;
  max-height: calc(92vh - 68px);
  overflow: auto;
}

.image-viewport.is-image-zoomed {
  align-items: flex-start;
  justify-content: flex-start;
}

.image-navigation {
  align-items: center;
  color: #d7deea;
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-top: 12px;
}

.image-navigation .icon-button {
  background: rgba(255, 255, 255, 0.92);
  min-width: 42px;
}

.image-navigation [data-image-counter] {
  font-size: 13px;
  min-width: 48px;
  text-align: center;
}

.image-modal img {
  cursor: zoom-in;
  display: block;
  max-height: calc(92vh - 68px);
  max-width: 100%;
}

.image-modal img.is-image-zoomed {
  cursor: zoom-out;
}

.image-toolbar {
  display: flex;
  gap: 8px;
  left: 10px;
  position: absolute;
  top: 10px;
}

.image-toolbar .icon-button,
.image-close {
  background: rgba(255, 255, 255, 0.92);
}

.image-toolbar .icon-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.image-close {
  position: absolute;
  right: 10px;
  top: 10px;
}

@media (max-width: 1170px) {
  .purchase-preview-layout {
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  }

  .product-gallery-panel {
    grid-column: 1 / -1;
    max-height: none;
    position: static;
  }
}

@media (max-width: 900px) {
  .page-header {
    align-items: stretch;
    flex-direction: column;
  }

  .historical-preview-search,
  .historical-preview-workspace {
    grid-template-columns: 1fr;
  }

  .historical-preview-workspace {
    min-height: 0;
    overflow: visible;
  }

  .historical-preview-results {
    max-height: 220px;
  }

  .historical-preview-template {
    border-left: 0;
    border-top: 1px solid var(--line);
    max-height: 50vh;
    padding-left: 0;
    padding-top: 16px;
  }

  .purchase-editor-layout {
    grid-template-columns: 1fr;
  }

  .purchase-preview-layout {
    grid-template-columns: 1fr;
  }

  .purchase-order-manager-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .purchase-order-manager-actions {
    width: 100%;
  }

  .purchase-order-template-selector,
  .purchase-order-manager-actions .button {
    flex: 1 1 0;
    min-width: 0;
  }

  .function-panel,
  .preview-source-panel,
  .product-gallery-panel {
    max-height: 45vh;
    position: static;
  }

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

  .detail-summary div {
    border-bottom: 1px solid var(--line);
    border-right: 0;
  }

  .detail-summary div:last-child {
    border-bottom: 0;
  }
}
