* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
}

.app-shell {
  display: grid;
  grid-template-rows: var(--toolbar-height) 1fr var(--status-bar-height);
  min-height: 100vh;
}

.app-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 24px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.app-title,
.app-subtitle,
.panel-section h2,
.preview-header h2,
.preview-header p {
  margin: 0;
}

.app-title {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
}

.app-subtitle,
.preview-header p {
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.toolbar-actions,
.import-actions,
.pagination-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, var(--control-panel-width)) 1fr;
  min-height: 0;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  overflow: auto;
  padding: 20px;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
}

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

.panel-section h2,
.preview-header h2 {
  font-size: 1rem;
  font-weight: 700;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--color-surface-muted);
  color: var(--color-text-muted);
  font-size: 0.8125rem;
}

.input-mode-group .btn {
  flex: 1;
}

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

.settings-grid-wide {
  grid-column: 1 / -1;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.empty-feature-note {
  padding: 12px;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-size: 0.875rem;
  line-height: 1.6;
}

.preview-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  min-height: 0;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.preview-stage {
  min-height: 0;
  overflow: auto;
  padding: 28px;
  text-align: center;
}

.a4-page {
  position: relative;
  display: grid;
  width: 210mm;
  height: 297mm;
  margin: 0 auto;
  background: #ffffff;
  box-shadow: var(--shadow-panel);
  transform: scale(var(--preview-scale));
  transform-origin: top center;
}

.label-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  text-align: center;
}

.label-cell-empty {
  color: transparent;
}

.label-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  line-height: 1.25;
}

.label-name {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.label-department {
  display: flex;
  flex-direction: column;
  max-width: 100%;
  color: inherit;
  overflow-wrap: anywhere;
}

.label-asset {
  position: absolute;
  z-index: 2;
  pointer-events: none;
}

.label-qr {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #ffffff;
  color: var(--color-text-muted);
  font-size: 7px;
  line-height: 1;
}

.label-qr img,
.label-qr canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.label-logo {
  display: block;
  object-fit: contain;
}

.asset-top-left {
  top: 4mm;
  left: 4mm;
}

.asset-top-right {
  top: 4mm;
  right: 4mm;
}

.asset-bottom-left {
  bottom: 4mm;
  left: 4mm;
}

.asset-bottom-right {
  right: 4mm;
  bottom: 4mm;
}

.asset-center {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.8125rem;
}

@media (max-width: 1024px) {
  .workspace {
    grid-template-columns: 340px 1fr;
  }

  .preview-stage {
    padding: 20px;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-rows: auto 1fr var(--status-bar-height);
  }

  .app-toolbar,
  .preview-header,
  .status-bar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .control-panel {
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--color-border);
  }

  .a4-page {
    --preview-scale: 0.46;
  }
}
