:root {
  color-scheme: light;
  --canvas: #edf1f3;
  --paper: #ffffff;
  --panel: #f8fafb;
  --panel-strong: #ffffff;
  --ink: #152231;
  --muted: #6d7b89;
  --muted-light: #98a4af;
  --line: #dce3e8;
  --line-strong: #cbd5dc;
  --accent: #087a63;
  --accent-dark: #05644f;
  --accent-soft: #e1f4ef;
  --danger: #c23d45;
  --danger-soft: #fff0f1;
  --shadow-sm: 0 1px 2px rgb(20 35 49 / 5%);
  --shadow-md: 0 12px 30px rgb(20 35 49 / 10%);
  --shadow-stage: 0 24px 60px rgb(36 51 64 / 18%), 0 2px 8px rgb(36 51 64 / 8%);
  --radius-sm: 7px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 1050px;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  color: var(--ink);
  background: var(--canvas);
  font-family:
    "Inter", "SF Pro Text", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei",
    sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

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

button {
  border: 0;
}

button,
select,
input[type="checkbox"],
input[type="range"],
input[type="color"] {
  cursor: pointer;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--paper);
  transition:
    border-color 120ms ease,
    box-shadow 120ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(8 122 99 / 10%);
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.75;
}

#app {
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr);
  width: 100%;
  height: 100%;
}

.topbar {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(260px, 1fr) auto;
  align-items: center;
  min-width: 0;
  padding: 0 14px 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 96%);
  box-shadow: var(--shadow-sm);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  display: grid;
  width: 35px;
  height: 35px;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background:
    radial-gradient(circle at 28% 20%, rgb(255 255 255 / 20%), transparent 38%),
    #112f2b;
  box-shadow: 0 4px 10px rgb(17 47 43 / 18%);
}

.brand-mark svg {
  width: 21px;
  height: 21px;
  fill: currentColor;
  stroke: none;
}

.brand strong {
  display: block;
  font-size: 14px;
  font-weight: 720;
  letter-spacing: 0.02em;
}

.brand span {
  display: block;
  margin-top: 2px;
  color: var(--muted-light);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.document-title {
  display: flex;
  align-items: center;
  justify-self: center;
  min-width: 0;
  max-width: 680px;
  padding: 5px 10px;
  border-radius: 9px;
  transition: background 120ms ease;
}

.document-title:hover {
  background: #f5f8f9;
}

.document-title input {
  width: min(320px, 30vw);
  min-width: 100px;
  height: 28px;
  padding: 0 7px;
  border-color: transparent;
  background: transparent;
  font-size: 13px;
  font-weight: 650;
  text-align: center;
}

.document-title input:focus {
  border-color: var(--line);
  background: #fff;
}

.status-dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-radius: 50%;
  background: #bcc7ce;
}

.status-dot.unsaved {
  background: #e4a323;
  box-shadow: 0 0 0 3px rgb(228 163 35 / 12%);
}

.status-dot.saved {
  background: var(--accent);
}

.document-size {
  flex: 0 0 auto;
  margin-left: 9px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--muted);
  background: #fff;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

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

.action-separator {
  width: 1px;
  height: 22px;
  margin: 0 5px;
  background: var(--line);
}

.button {
  display: inline-flex;
  height: 34px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
  transition:
    background 120ms ease,
    border-color 120ms ease,
    box-shadow 120ms ease,
    transform 100ms ease;
}

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

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

.button-primary {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 4px 10px rgb(8 122 99 / 16%);
}

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

.button-secondary {
  border-color: var(--line);
  color: #354554;
  background: #fff;
}

.button-secondary:hover {
  border-color: var(--line-strong);
  background: #f7f9fa;
}

.icon-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border-radius: 8px;
  color: #526270;
  background: transparent;
  font-size: 18px;
  transition:
    color 120ms ease,
    background 120ms ease;
}

.icon-button:hover:not(:disabled) {
  color: var(--ink);
  background: #edf2f4;
}

.icon-button:disabled {
  opacity: 0.32;
  cursor: default;
}

.icon-button.small {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  background: #fff;
}

.danger-hover:hover:not(:disabled) {
  color: var(--danger);
  background: var(--danger-soft);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(520px, 1fr) 390px;
  min-width: 0;
  min-height: 0;
}

.template-sidebar {
  display: none;
  min-height: 0;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.sidebar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 21px 17px 14px;
}

.eyebrow {
  display: block;
  margin-bottom: 4px;
  color: var(--muted-light);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.sidebar-heading h2,
.dialog-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.template-list {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding: 3px 10px 16px;
}

.template-card {
  position: relative;
  display: flex;
  width: 100%;
  align-items: center;
  gap: 11px;
  margin-bottom: 4px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--ink);
  background: transparent;
  text-align: left;
  transition:
    border-color 120ms ease,
    background 120ms ease,
    box-shadow 120ms ease;
}

.template-card-main {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  gap: 11px;
  padding: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.template-card:hover {
  background: #fff;
}

.template-card.active {
  border-color: #d8e7e2;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.template-card.active::before {
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: -10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
  content: "";
}

.template-thumb {
  position: relative;
  display: grid;
  width: 43px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  border: 1px solid #dfe5e8;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 2px 5px rgb(20 35 49 / 5%);
}

.template-thumb::before,
.template-thumb::after {
  position: absolute;
  right: 4px;
  left: 4px;
  height: 2px;
  background: #dce3e7;
  content: "";
}

.template-thumb::before {
  top: 7px;
}

.template-thumb::after {
  bottom: 6px;
  height: 5px;
  background: repeating-linear-gradient(90deg, #8fa0aa 0 1px, transparent 1px 3px);
}

.template-card-copy {
  min-width: 0;
}

.template-card-copy strong {
  display: block;
  overflow: hidden;
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-card-copy span {
  display: block;
  margin-top: 3px;
  color: var(--muted-light);
  font-size: 10px;
}

.template-menu-button {
  display: grid;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  place-items: center;
  margin-left: auto;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
}

.template-menu-button:hover {
  background: #f0f4f5;
}

.sidebar-footer {
  display: grid;
  gap: 3px;
  padding: 10px;
  border-top: 1px solid var(--line);
}

.sidebar-action {
  display: flex;
  height: 33px;
  align-items: center;
  gap: 9px;
  padding: 0 9px;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  font-weight: 550;
  text-align: left;
}

.sidebar-action:hover {
  color: var(--ink);
  background: #edf2f3;
}

.sidebar-action svg {
  width: 15px;
  height: 15px;
}

.designer {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr) 34px;
  background: var(--canvas);
}

.designer-toolbar {
  display: none;
  min-width: 0;
  align-items: center;
  gap: 10px;
  padding: 0 15px;
  border-bottom: 1px solid var(--line);
  background: #f9fbfb;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.tool-group.compact {
  margin-left: auto;
}

.tool-divider {
  width: 1px;
  height: 23px;
  background: var(--line);
}

.tool-button {
  display: inline-flex;
  height: 32px;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  border-radius: 7px;
  color: #526270;
  background: transparent;
  font-size: 11px;
  font-weight: 550;
}

.tool-button:hover {
  color: var(--ink);
  background: #eaf0f2;
}

.tool-button svg {
  width: 16px;
  height: 16px;
}

.tool-icon {
  display: inline-grid;
  width: 18px;
  height: 18px;
  place-items: center;
  font-family: Georgia, serif;
  font-size: 17px;
  font-weight: 700;
}

.barcode-icon {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 1.5px;
  padding: 3px 1px;
}

.barcode-icon i {
  width: 1.4px;
  background: currentColor;
}

.barcode-icon i:nth-child(2),
.barcode-icon i:nth-child(5) {
  width: 2.4px;
}

.canvas-area {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: 34px minmax(0, 1fr);
  overflow: hidden;
}

.canvas-area::before {
  position: absolute;
  inset: 34px 0 0;
  z-index: 0;
  opacity: 0.48;
  background-image: radial-gradient(circle, #bac5cc 0.75px, transparent 0.75px);
  background-position: 0 0;
  background-size: 17px 17px;
  content: "";
  pointer-events: none;
}

.canvas-meta {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  color: var(--muted-light);
  font-size: 10px;
}

.canvas-hint kbd {
  padding: 2px 5px;
  border: 1px solid #d7dfe4;
  border-radius: 4px;
  color: #768491;
  background: rgb(255 255 255 / 65%);
  font-family: inherit;
  font-size: 9px;
}

.stage-scroller {
  position: relative;
  z-index: 1;
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  overflow: auto;
  padding: 34px 58px 50px;
}

.stage-shell {
  position: relative;
  flex: 0 0 auto;
  transition:
    width 160ms ease,
    height 160ms ease;
}

.stage-shell::after {
  position: absolute;
  right: 10px;
  bottom: -25px;
  left: 10px;
  height: 14px;
  border-radius: 50%;
  background: rgb(25 42 54 / 13%);
  filter: blur(9px);
  content: "";
}

.label-stage {
  position: relative;
  overflow: hidden;
  transform-origin: top left;
  background: #fff;
  box-shadow: var(--shadow-stage);
  outline: none;
  user-select: none;
  -webkit-user-select: none;
}

.label-stage.grid::after {
  position: absolute;
  inset: 0;
  z-index: 999;
  opacity: 0.22;
  background-image:
    linear-gradient(to right, #91a3ad 1px, transparent 1px),
    linear-gradient(to bottom, #91a3ad 1px, transparent 1px);
  background-size: 5mm 5mm;
  content: "";
  pointer-events: none;
}

.label-stage.grid::after {
  display: none;
}

.label-element {
  position: absolute;
  z-index: 1;
  display: flex;
  overflow: visible;
  border: 1px solid transparent;
  color: var(--ink);
  transform-origin: center;
  cursor: default;
  pointer-events: none;
  touch-action: none;
}

.label-element:hover {
  border-color: rgb(8 122 99 / 28%);
}

.label-element.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgb(8 122 99 / 12%);
}

.label-element.text-element {
  align-items: center;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
}

.label-element.barcode-element,
.label-element.qrcode-element {
  align-items: center;
  justify-content: center;
}

.label-element canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  pointer-events: none;
}

.label-element.image-element {
  overflow: hidden;
}

.label-element.image-element img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.label-element.line-element {
  align-items: center;
  overflow: visible;
}

.label-element.line-element::before {
  width: 100%;
  height: 0;
  border-top: var(--line-thickness, 0.25mm) solid currentColor;
  content: "";
  pointer-events: none;
}

.label-element.line-element.line-vertical {
  justify-content: center;
}

.label-element.line-element.line-vertical::before {
  width: 0;
  height: 100%;
  border-top: 0;
  border-left: var(--line-thickness, 0.25mm) solid currentColor;
}

.barcode-error {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  border: 1px dashed #d3a5a5;
  color: var(--danger);
  background: #fff5f5;
  font-size: 2mm;
  text-align: center;
}

.resize-handle {
  position: absolute;
  right: -5px;
  bottom: -5px;
  z-index: 1000;
  display: none;
  width: 10px;
  height: 10px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 4px rgb(0 0 0 / 18%);
  cursor: nwse-resize;
  touch-action: none;
}

.label-element.selected .resize-handle,
.print-label .resize-handle {
  display: block;
}

.print-label .resize-handle {
  display: none !important;
}

.empty-canvas {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #98a5ae;
  font-size: 2.8mm;
  text-align: center;
}

.zoom-toolbar {
  position: absolute;
  right: 18px;
  bottom: 15px;
  z-index: 4;
  display: flex;
  height: 31px;
  align-items: center;
  padding: 0 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(255 255 255 / 92%);
  box-shadow: 0 5px 16px rgb(23 38 49 / 10%);
  backdrop-filter: blur(10px);
}

.zoom-toolbar .icon-button {
  width: 27px;
  height: 27px;
  font-size: 16px;
}

.zoom-value {
  min-width: 44px;
  padding: 0 4px;
  color: var(--muted);
  background: transparent;
  font-size: 10px;
  font-weight: 600;
}

.statusbar {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  padding: 0 17px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: #f9fbfb;
  font-size: 10px;
}

.status-copy {
  display: flex;
  align-items: center;
  gap: 7px;
}

.status-copy.subtle {
  color: var(--muted-light);
}

.status-led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.inspector {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: var(--panel-strong);
}

.inspector-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  height: 54px;
  flex: 0 0 auto;
  align-items: end;
  padding: 0 13px;
  border-bottom: 1px solid var(--line);
}

.inspector-tab {
  position: relative;
  height: 41px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  font-weight: 600;
}

.inspector-tab:hover {
  color: var(--ink);
}

.inspector-tab.active {
  border-bottom-color: var(--accent);
  color: var(--accent);
}

[data-inspector-tab="design"],
#design-panel,
#undo-button,
#redo-button,
#save-template-button,
.action-separator {
  display: none !important;
}

.inspector-panel {
  display: none;
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 28px;
}

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

.section-block {
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid #edf1f3;
}

.section-block:last-child {
  border-bottom: 0;
}

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

.section-title strong {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.section-title span {
  color: var(--muted-light);
  font-size: 9px;
}

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

.property-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.property-grid .full {
  grid-column: 1 / -1;
}

.field {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.field > label,
.field > span:first-child {
  color: #687887;
  font-size: 10px;
  font-weight: 550;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  height: 32px;
  padding: 0 9px;
  font-size: 11px;
}

.field textarea {
  height: 70px;
  padding: 8px 9px;
  line-height: 1.5;
  resize: vertical;
}

.field input[type="color"] {
  height: 32px;
  padding: 3px;
}

.field-note {
  margin-top: 6px;
  color: var(--muted-light);
  font-size: 9px;
  line-height: 1.5;
}

.input-with-unit {
  position: relative;
  display: block;
}

.input-with-unit input {
  width: 100%;
  height: 32px;
  padding: 0 31px 0 9px;
}

.input-with-unit em {
  position: absolute;
  top: 50%;
  right: 9px;
  color: var(--muted-light);
  font-size: 9px;
  font-style: normal;
  transform: translateY(-50%);
  pointer-events: none;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f8f9;
}

.segmented button {
  height: 25px;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  font-size: 10px;
}

.segmented button.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 1px 4px rgb(20 35 49 / 9%);
}

.toggle-row {
  display: flex;
  min-height: 31px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #5b6b79;
  font-size: 10px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
  flex: 0 0 auto;
}

.switch input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  background: #ccd6dc;
  transition: background 140ms ease;
}

.switch span::after {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 18%);
  content: "";
  transition: transform 140ms ease;
}

.switch input:checked + span {
  background: var(--accent);
}

.switch input:checked + span::after {
  transform: translateX(14px);
}

.no-selection {
  padding: 8px 1px 20px;
  text-align: center;
}

.no-selection-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  margin: 0 auto 12px;
  border: 1px solid #e0e7eb;
  border-radius: 14px;
  color: #87949e;
  background: #f7f9fa;
}

.no-selection-icon svg {
  width: 22px;
  height: 22px;
}

.no-selection strong {
  display: block;
  font-size: 12px;
}

.no-selection p {
  margin: 5px auto 0;
  color: var(--muted-light);
  font-size: 10px;
  line-height: 1.6;
}

.layer-list {
  display: grid;
  gap: 3px;
}

.layer-row {
  display: flex;
  height: 33px;
  align-items: center;
  gap: 8px;
  padding: 0 7px;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  text-align: left;
}

.layer-row:hover {
  background: #f4f7f8;
}

.layer-row.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.layer-type {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 5px;
  color: #74838f;
  background: #eef2f4;
  font-family: Georgia, serif;
  font-size: 10px;
  font-weight: 700;
}

.layer-row.active .layer-type {
  color: var(--accent);
  background: #fff;
}

.layer-name {
  overflow: hidden;
  flex: 1;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-upload {
  display: grid;
  min-height: 108px;
  place-items: center;
  padding: 15px;
  border: 1px dashed #b9c8d0;
  border-radius: 10px;
  color: var(--muted);
  background:
    linear-gradient(135deg, rgb(8 122 99 / 2%), transparent),
    #fbfcfc;
  text-align: center;
  transition:
    border-color 120ms ease,
    background 120ms ease;
}

.quick-spec-block {
  padding-bottom: 16px;
}

.quick-code-card {
  margin-bottom: 11px;
  padding: 9px 10px;
  border: 1px solid #dbe9e5;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgb(23 105 168 / 5%), transparent 70%),
    #f8fbfc;
}

.quick-code-card span {
  display: block;
  margin-bottom: 4px;
  color: #78909f;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.quick-code-card code {
  display: block;
  overflow: hidden;
  color: #185c8f;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-series-field {
  margin-bottom: 11px;
}

.label-series-block {
  margin-bottom: 10px;
}

.label-series-block .section-title {
  margin-bottom: 7px;
}

.label-series-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.label-series-choice {
  display: grid;
  min-height: 48px;
  align-content: center;
  gap: 3px;
  padding: 8px 9px;
  border: 1px solid #dfe7eb;
  border-radius: 8px;
  color: #536775;
  background: #fff;
  text-align: left;
}

.label-series-choice:hover {
  border-color: #9acabb;
}

.label-series-choice.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.label-series-choice strong {
  font-size: 10px;
  font-weight: 750;
}

.label-series-choice span {
  color: #82919c;
  font-size: 8px;
}

.layout-choice-block {
  padding: 9px;
  margin-bottom: 9px;
  border: 1px solid #e2eaee;
  border-radius: 9px;
  background: #fbfcfd;
}

.layout-choice-block .section-title {
  margin-bottom: 8px;
}

.layout-choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.layout-choice {
  display: grid;
  min-width: 0;
  justify-items: center;
  gap: 3px;
  padding: 6px 4px;
  border: 1px solid #dfe7eb;
  border-radius: 7px;
  color: #778792;
  background: #fff;
  font-size: 8px;
}

.layout-choice:hover,
.layout-choice.active {
  border-color: #75b4a4;
  color: var(--accent);
  background: #f4fbf9;
}

.layout-choice strong {
  font-size: 9px;
}

.layout-mini {
  position: relative;
  display: block;
  width: 39px;
  height: 24px;
  overflow: hidden;
  border: 1px solid currentColor;
  border-radius: 2px;
  background: #fff;
  opacity: 0.7;
}

.layout-mini i {
  position: absolute;
  display: block;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}

.layout-mini-1 i:nth-child(1) {
  top: 5px;
  left: 4px;
  width: 23px;
  height: 4px;
}

.layout-mini-1 i:nth-child(2) {
  top: 12px;
  left: 4px;
  width: 20px;
}

.layout-mini-1 i:nth-child(3) {
  right: 4px;
  bottom: 3px;
  left: 4px;
  height: 4px;
}

.layout-mini-2 i:nth-child(1),
.layout-mini-2 i:nth-child(2) {
  top: 6px;
  width: 12px;
  height: 10px;
  background: repeating-linear-gradient(
    to bottom,
    currentColor 0 2px,
    transparent 2px 4px
  );
}

.layout-mini-2 i:nth-child(1) {
  left: 4px;
}

.layout-mini-2 i:nth-child(2) {
  right: 4px;
}

.layout-mini-2 i:nth-child(3) {
  right: 4px;
  bottom: 3px;
  left: 4px;
}

.layout-mini-3 i:nth-child(1) {
  top: 3px;
  right: 3px;
  left: 3px;
  height: 6px;
}

.layout-mini-3 i:nth-child(2) {
  top: 12px;
  left: 4px;
  width: 20px;
}

.layout-mini-3 i:nth-child(3) {
  right: 4px;
  bottom: 3px;
  left: 4px;
  height: 4px;
}

.model-spec-card {
  margin-top: 9px;
  padding: 9px;
  border: 1px solid #e2eaee;
  border-radius: 9px;
  background: #fbfcfd;
}

.model-spec-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.model-spec-header strong {
  color: #185c8f;
  font-size: 10px;
  font-weight: 750;
}

.model-spec-header span {
  color: var(--muted-light);
  font-size: 8px;
}

.model-spec-card .property-grid {
  gap: 8px;
}

.model-spec-card .field {
  gap: 4px;
}

.model-spec-card .field input,
.model-spec-card .field select {
  height: 30px;
  padding: 0 7px;
  font-size: 10px;
}

.quick-quantity-field {
  margin-top: 10px;
}

.internal-info-card {
  margin-top: 11px;
  padding: 10px;
  border: 1px dashed #b8ccd7;
  border-radius: 9px;
  background:
    linear-gradient(135deg, rgb(37 89 127 / 4%), transparent 65%),
    #f8fbfc;
}

.internal-info-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.internal-info-header strong,
.internal-info-header span {
  display: block;
}

.internal-info-header strong {
  color: #29485e;
  font-size: 10px;
}

.internal-info-header div > span {
  margin-top: 2px;
  color: var(--muted-light);
  font-size: 8px;
}

.internal-only-badge {
  display: inline-flex !important;
  height: 20px;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
  border-radius: 20px;
  color: #687b88;
  background: #eaf0f3;
  font-size: 8px !important;
  font-weight: 650;
  white-space: nowrap;
}

.internal-only-badge svg {
  width: 11px;
  height: 11px;
}

.internal-info-grid {
  gap: 8px;
}

.internal-info-grid .field {
  gap: 4px;
}

.internal-info-grid input {
  height: 29px;
  padding: 0 7px;
  font-size: 10px;
}

.internal-info-grid textarea {
  height: 48px;
  padding: 6px 7px;
  font-size: 10px;
}

.internal-info-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  color: #667985;
  font-size: 8px;
  line-height: 1.5;
}

.internal-status-dot {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
}

.internal-status-dot.incomplete {
  background: #d79b2a;
}

.internal-clear-button {
  padding: 0;
  margin-top: 7px;
  color: #7a8b96;
  background: transparent;
  font-size: 8px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.internal-archive-card {
  border-color: #d5e3eb;
  background:
    linear-gradient(135deg, rgb(37 89 127 / 5%), transparent 65%),
    #f9fbfc;
}

.quick-add-button {
  width: 100%;
  margin-top: 11px;
}

.data-upload:hover {
  border-color: var(--accent);
  background: #f7fcfa;
}

.data-upload svg {
  width: 24px;
  height: 24px;
  margin-bottom: 7px;
  color: var(--accent);
}

.data-upload strong {
  display: block;
  color: var(--ink);
  font-size: 11px;
}

.data-upload span {
  display: block;
  margin-top: 4px;
  color: var(--muted-light);
  font-size: 9px;
}

.data-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.stat-card {
  padding: 10px;
  border: 1px solid #e7ecef;
  border-radius: 8px;
  background: #fafcfc;
}

.stat-card span {
  display: block;
  color: var(--muted-light);
  font-size: 9px;
}

.stat-card strong {
  display: block;
  margin-top: 4px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.record-preview {
  display: grid;
  gap: 5px;
}

.record-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-height: 39px;
  padding: 6px 7px;
  border: 1px solid #e7ecef;
  border-radius: 8px;
  background: #fff;
}

.record-index {
  display: grid;
  width: 21px;
  height: 21px;
  place-items: center;
  border-radius: 5px;
  color: #7d8a94;
  background: #f0f4f5;
  font-size: 9px;
}

.record-copy {
  min-width: 0;
}

.record-copy strong,
.record-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-copy strong {
  font-size: 10px;
  font-weight: 600;
}

.record-copy span {
  margin-top: 2px;
  color: var(--muted-light);
  font-size: 9px;
}

.record-qty {
  padding: 3px 6px;
  border-radius: 10px;
  color: #5c6b77;
  background: #f1f4f5;
  font-size: 9px;
}

.variable-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.variable-chip {
  padding: 4px 7px;
  border: 1px solid #e1e7ea;
  border-radius: 6px;
  color: #556673;
  background: #fafcfc;
  font-size: 9px;
}

.variable-chip:hover {
  border-color: #bbded5;
  color: var(--accent);
  background: #f4fbf9;
}

.print-setting-card {
  padding: 12px;
  border: 1px solid #e3eaed;
  border-radius: 10px;
  background: #fbfcfc;
}

.print-setting-card + .print-setting-card {
  margin-top: 9px;
}

.print-setting-card strong {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
}

.print-setting-card p {
  margin: 0;
  color: var(--muted-light);
  font-size: 9px;
  line-height: 1.6;
}

.full-width-button {
  display: flex;
  width: 100%;
  height: 38px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font-size: 11px;
  font-weight: 650;
}

.full-width-button:hover {
  border-color: #b8c8d0;
  background: #fafcfc;
}

.full-width-button svg {
  width: 16px;
  height: 16px;
}

.dialog {
  width: min(520px, calc(100vw - 40px));
  padding: 0;
  border: 1px solid #dbe3e7;
  border-radius: var(--radius-lg);
  color: var(--ink);
  background: #fff;
  box-shadow: 0 30px 90px rgb(16 29 39 / 25%);
}

.dialog::backdrop {
  background: rgb(19 31 40 / 45%);
  backdrop-filter: blur(3px);
}

.dialog form {
  padding: 22px;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 22px 15px;
}

.dialog form > .dialog-header {
  padding: 0 0 15px;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.preset-button {
  min-height: 72px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: #fbfcfc;
  font-size: 10px;
  transition:
    border-color 120ms ease,
    background 120ms ease,
    color 120ms ease;
}

.preset-button:hover,
.preset-button.active {
  border-color: var(--accent);
  color: var(--accent);
  background: #f3fbf9;
}

.preset-shape {
  display: block;
  width: var(--preview-width, 40px);
  max-width: 54px;
  height: var(--preview-height, 28px);
  max-height: 34px;
  margin: 0 auto 8px;
  border: 1px solid currentColor;
  border-radius: 2px;
  opacity: 0.55;
}

.custom-size {
  display: grid;
  grid-template-columns: 1fr 22px 1fr;
  align-items: end;
  gap: 8px;
  margin-bottom: 15px;
}

.custom-size label {
  display: grid;
  gap: 6px;
  color: #687887;
  font-size: 10px;
}

.custom-size input {
  width: 100%;
  height: 34px;
  padding: 0 34px 0 9px;
}

.custom-size .input-with-unit {
  position: relative;
}

.multiply {
  display: grid;
  height: 34px;
  place-items: center;
  color: var(--muted-light);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 18px;
}

.preview-dialog {
  width: calc(100vw - 56px);
  max-width: 1200px;
  height: calc(100vh - 56px);
  max-height: 860px;
  overflow: hidden;
}

.preview-header {
  height: 72px;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
}

.preview-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.preview-warning {
  margin-right: 8px;
  color: #a06d13;
  font-size: 9px;
}

.print-preview-body {
  display: grid;
  height: calc(100% - 72px);
  grid-template-columns: 215px minmax(0, 1fr);
}

.print-preview-sidebar {
  padding: 20px 16px;
  border-right: 1px solid var(--line);
  background: #f8fafb;
}

.preview-stat {
  padding: 11px 0;
  border-bottom: 1px solid #e8edef;
}

.preview-stat span {
  display: block;
  color: var(--muted-light);
  font-size: 9px;
}

.preview-stat strong {
  display: block;
  margin-top: 4px;
  font-size: 11px;
}

.preview-note {
  margin-top: 18px;
  padding: 11px;
  border: 1px solid #e4e0cf;
  border-radius: 8px;
  color: #786b49;
  background: #fffaf0;
  font-size: 9px;
  line-height: 1.7;
}

.print-preview-canvas {
  display: flex;
  min-width: 0;
  align-content: flex-start;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 18px;
  overflow: auto;
  padding: 28px;
  background:
    radial-gradient(circle, #bec8ce 0.7px, transparent 0.7px),
    #edf1f3;
  background-size: 17px 17px;
}

.preview-label-shell {
  position: relative;
  flex: 0 0 auto;
  padding: 10px;
  border: 1px solid #d8e0e5;
  border-radius: 7px;
  background: #e7ecef;
  box-shadow: 0 7px 18px rgb(28 43 54 / 10%);
}

.preview-label-shell::after {
  display: block;
  margin-top: 7px;
  color: #8b97a0;
  font-size: 8px;
  text-align: center;
  content: attr(data-index);
}

.preview-label-shell .label-stage {
  box-shadow: 0 2px 5px rgb(20 35 49 / 16%);
}

.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1000;
  display: grid;
  gap: 7px;
  pointer-events: none;
}

.toast {
  min-width: 220px;
  padding: 10px 13px;
  border: 1px solid #dce5e9;
  border-radius: 9px;
  color: #334452;
  background: rgb(255 255 255 / 96%);
  box-shadow: var(--shadow-md);
  font-size: 10px;
  animation: toast-in 160ms ease-out;
}

.toast.error {
  border-color: #f0c8cb;
  color: #9f3038;
  background: #fff7f7;
}

.floating-menu {
  position: fixed;
  z-index: 1200;
  display: grid;
  width: 146px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 14px 35px rgb(20 35 49 / 18%);
}

.floating-menu button {
  height: 31px;
  padding: 0 9px;
  border-radius: 6px;
  color: #4d5d6a;
  background: transparent;
  font-size: 10px;
  text-align: left;
}

.floating-menu button:hover {
  background: #f2f6f7;
}

.floating-menu button.danger {
  color: var(--danger);
}

.floating-menu button.danger:hover {
  background: var(--danger-soft);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#print-root {
  display: none;
}

@media (max-width: 1200px) {
  .app-shell {
    grid-template-columns: minmax(500px, 1fr) 330px;
  }

  .topbar {
    grid-template-columns: auto minmax(220px, 1fr) auto;
  }

  .tool-button {
    width: 33px;
    justify-content: center;
    padding: 0;
    font-size: 0;
  }

  .tool-button svg,
  .tool-button .tool-icon {
    width: 17px;
    height: 17px;
    font-size: 16px;
  }
}

@media print {
  html,
  body {
    width: auto;
    min-width: 0;
    height: auto;
    overflow: visible;
    background: #fff;
  }

  body > *:not(#print-root) {
    display: none !important;
  }

  #print-root {
    display: block !important;
    width: auto;
    height: auto;
  }

  .print-label {
    position: relative;
    display: block;
    overflow: hidden;
    margin: 0;
    padding: 0;
    break-after: page;
    page-break-after: always;
    background: #fff;
  }

  .print-label:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  .print-label .resize-handle {
    display: none !important;
  }
}
