.yard-layout-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.yard-layout-toolbar h2 {
  margin: 0;
}

.yard-layout-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.modal-content.yard-layout-modal-content {
  max-width: 560px;
}

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

.yard-layout-settings-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: #e8f4ff;
  font-weight: 900;
}

.yard-layout-settings-grid input[type="number"] {
  width: 100% !important;
  padding: 8px;
  box-sizing: border-box;
  font-size: 1.1rem !important;
  margin: 0;
}

.yard-layout-modal-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.modal-content.yard-detail-modal-content {
  width: 94%;
  max-width: 860px;
  max-height: 88vh;
  overflow: auto;
}

.yard-detail-section {
  margin-bottom: 18px;
}

.yard-detail-title {
  margin: 0 0 10px;
  padding: 9px 10px;
  background: #08782d;
  color: #fff;
  font-size: 1.45rem;
  text-align: left;
  cursor: move;
  user-select: none;
  touch-action: none;
}

.yard-detail-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: #2e2e2e;
  color: #fff;
}

.yard-detail-table th,
.yard-detail-table td {
  border: 1px solid #777;
  padding: 7px 5px;
  text-align: center;
  font-weight: 800;
}

.yard-detail-table th {
  background: #626262;
}

.yard-detail-table tr.has-warning td {
  background: rgba(120, 20, 20, 0.72);
  color: #ffd6d6;
}

.yard-detail-status {
  color: #ffdf6b;
  font-weight: 900;
  white-space: normal;
}

.yard-layout-message {
  min-height: 24px;
  margin-bottom: 8px;
  color: #ffd966;
  font-weight: bold;
  text-align: center;
}

.yard-layout-issue-summary {
  width: min(100%, 1440px);
  margin: 0 auto 8px;
  padding: 8px 10px;
  box-sizing: border-box;
  border: 1px solid rgba(255, 200, 80, 0.55);
  border-radius: 6px;
  background: rgba(50, 35, 20, 0.9);
  color: #fff4cc;
  font-size: 0.88rem;
  line-height: 1.35;
}

.yard-layout-issue-summary:empty {
  display: none;
}

.yard-issue-title {
  margin-bottom: 6px;
  font-weight: 900;
  color: #ffd966;
}

.yard-issue-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.yard-issue-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 5px 7px;
  border: 1px solid rgba(255,255,255,0.24);
  border-radius: 5px;
  background: rgba(0,0,0,0.28);
  color: #fff;
  font-weight: 800;
}

.yard-issue-chip.is-over,
.yard-issue-chip.is-missing {
  border-color: rgba(255, 99, 71, 0.75);
  color: #ffd6d0;
}

.yard-issue-chip.is-short {
  border-color: rgba(255, 217, 102, 0.75);
  color: #fff0b8;
}

.yard-saved-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-bottom: 8px;
}

.yard-saved-groups button {
  padding: 6px 9px;
  font-size: 0.86rem;
  background: #4f6f88;
}

.yard-saved-groups button.yard-group-tool {
  background: #5b5963;
  border: 1px solid rgba(255,255,255,0.22);
}

.yard-saved-groups button.yard-group-cancel {
  background: #9b2f2f;
  font-weight: 900;
}

.yard-saved-groups button.yard-group-align {
  background: #2f7d5a;
  font-weight: 900;
}

.yard-saved-groups button.yard-group-free-transform {
  background: #6d557f;
  font-weight: 900;
}

.yard-saved-groups button.yard-group-free-transform.is-active {
  background: #d28b22;
  box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.35);
}

.yard-saved-groups button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.yard-saved-groups button.is-active {
  background: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.35);
}

.yard-layout-canvas {
  position: relative;
  width: min(100%, 1440px);
  aspect-ratio: 5 / 9;
  min-height: 2350px;
  margin: 0 auto;
  overflow: hidden;
  border: 4px solid #d7d0b8;
  background:
    linear-gradient(90deg, rgba(0,0,0,0.08) 1px, transparent 1px) 0 0 / 16.66% 100%,
    linear-gradient(0deg, rgba(0,0,0,0.08) 1px, transparent 1px) 0 0 / 100% 16.66%,
    linear-gradient(rgba(255,255,255,0.12), rgba(255,255,255,0.12)),
    url("../images/yamabackbord2.png") center / 100% 100% no-repeat,
    radial-gradient(circle at 54% 44%, rgba(95, 95, 95, 0.12) 0 25%, transparent 42%),
    linear-gradient(90deg, #f2f0e8 0 92%, #bfe4ef 92% 100%);
  box-shadow: inset 0 0 80px rgba(20, 20, 20, 0.12), 0 6px 18px rgba(0,0,0,0.35);
  touch-action: none;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

.yard-layout-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #333;
  font-weight: bold;
  font-size: 1.1rem;
}

.yard-box {
  position: absolute;
  width: var(--yard-box-width, 78px);
  height: var(--yard-box-height, 112px);
  border: 0;
  background: url("../images/yamabox.png") center / 100% 100% no-repeat;
  color: #111;
  box-shadow: 0 5px 10px rgba(0,0,0,0.24);
  padding: 24px 9px 13px;
  box-sizing: border-box;
  text-align: center;
  user-select: none;
  touch-action: none;
  z-index: 2;
  overflow: hidden;
  transform-origin: center center;
}

.yard-box.is-warning {
  background:
    linear-gradient(rgba(255, 60, 60, 0.22), rgba(255, 60, 60, 0.22)),
    url("../images/yamabox.png") center / 100% 100% no-repeat;
  filter: saturate(1.25);
  box-shadow: 0 0 0 3px rgba(210, 0, 0, 0.9), 0 6px 12px rgba(0,0,0,0.28);
}

.yard-box.is-dragging {
  opacity: 0.9;
  z-index: 20;
}

.yard-box.is-selected {
  outline: 4px solid rgba(0, 162, 255, 0.42);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.9), 0 0 0 7px rgba(0, 123, 255, 0.55), 0 8px 14px rgba(0,0,0,0.32);
}

.yard-box.is-free-transform {
  overflow: visible;
  z-index: 30;
}

.yard-box.is-selected::after {
  content: "묶음";
  position: absolute;
  right: -6px;
  top: -14px;
  padding: 2px 5px;
  border-radius: 4px;
  background: #007bff;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
}

.yard-transform-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  border: 1px solid #168dff;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.9);
  z-index: 35;
  touch-action: none;
  box-sizing: border-box;
}

.yard-transform-handle[data-dir="n"] {
  top: -7px;
  left: 50%;
  transform: translateX(-50%);
  cursor: ns-resize;
}

.yard-transform-handle[data-dir="s"] {
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  cursor: ns-resize;
}

.yard-transform-handle[data-dir="e"] {
  right: -7px;
  top: 50%;
  transform: translateY(-50%);
  cursor: ew-resize;
}

.yard-transform-handle[data-dir="w"] {
  left: -7px;
  top: 50%;
  transform: translateY(-50%);
  cursor: ew-resize;
}

.yard-transform-handle[data-dir="nw"] {
  left: -7px;
  top: -7px;
  cursor: nwse-resize;
}

.yard-transform-handle[data-dir="ne"] {
  right: -7px;
  top: -7px;
  cursor: nesw-resize;
}

.yard-transform-handle[data-dir="sw"] {
  left: -7px;
  bottom: -7px;
  cursor: nesw-resize;
}

.yard-transform-handle[data-dir="se"] {
  right: -7px;
  bottom: -7px;
  cursor: nwse-resize;
}

.yard-transform-handle[data-dir="rotate"] {
  top: -31px;
  left: 50%;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  transform: translateX(-50%);
  background: #168dff;
  color: #fff;
  cursor: grab;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 900;
}

.yard-transform-handle[data-dir="rotate"]:active {
  cursor: grabbing;
}

.yard-lock {
  position: absolute;
  top: 0px;
  left: 7px;
  width: 20px;
  height: 20px;
  border: 0;
  background: transparent;
  color: #111;
  padding: 0;
  margin: 0;
  font-size: 16px;
  line-height: 24px;
  cursor: grab;
}

.yard-lock:active {
  cursor: grabbing;
}

.yard-warning-mark {
  position: absolute;
  top: 8px;
  right: 7px;
  font-size: 17px;
  filter: drop-shadow(0 1px 1px #fff);
}

.yard-status-badge {
  position: absolute;
  left: 50%;
  bottom: 5px;
  transform: translateX(-50%);
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(255, 217, 102, 0.94);
  color: #3a2600;
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
}

.yard-line {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 33px;
  border-top: 1px solid rgba(0,0,0,0.12);
  text-shadow: 0 1px 0 rgba(255,255,255,0.55);
}

.yard-line:first-of-type {
  border-top: 0;
}

.yard-name {
  font-size: var(--yard-name-font, 18px);
  font-weight: 900;
  line-height: 1.1;
  white-space: nowrap;
}

.yard-qty {
  margin-top: 4px;
  font-size: var(--yard-qty-font, 17px);
  font-weight: 900;
  line-height: 1;
}

.yard-box.is-compact {
  padding-top: 23px;
  padding-left: 7px;
  padding-right: 8px;
}

.yard-box.is-compact .yard-line {
  height: 34px;
}

.yard-box.is-compact .yard-name {
  font-size: var(--yard-compact-name-font, 13px);
  line-height: 1;
}

.yard-box.is-compact .yard-qty {
  margin-top: 3px;
  font-size: var(--yard-compact-qty-font, 14px);
}

@media (max-width: 720px) {
  .yard-layout-canvas {
    min-height: 2200px;
  }

  .yard-transform-handle {
    width: 16px;
    height: 16px;
  }

  .yard-transform-handle[data-dir="n"],
  .yard-transform-handle[data-dir="nw"],
  .yard-transform-handle[data-dir="ne"] {
    top: -11px;
  }

  .yard-transform-handle[data-dir="s"],
  .yard-transform-handle[data-dir="sw"],
  .yard-transform-handle[data-dir="se"] {
    bottom: -11px;
  }

  .yard-transform-handle[data-dir="e"],
  .yard-transform-handle[data-dir="ne"],
  .yard-transform-handle[data-dir="se"] {
    right: -11px;
  }

  .yard-transform-handle[data-dir="w"],
  .yard-transform-handle[data-dir="nw"],
  .yard-transform-handle[data-dir="sw"] {
    left: -11px;
  }

  .yard-transform-handle[data-dir="rotate"] {
    top: -40px;
    width: 30px;
    height: 30px;
    font-size: 18px;
  }

  .yard-box {
    width: var(--yard-box-width, 78px);
    height: var(--yard-box-height, 112px);
    padding: 22px 8px 11px;
  }

  .yard-name,
  .yard-qty {
    font-size: var(--yard-name-font, 18px);
  }

  .yard-qty {
    font-size: var(--yard-qty-font, 17px);
  }

  .yard-box.is-compact .yard-name {
    font-size: var(--yard-compact-name-font, 13px);
  }

  .yard-box.is-compact .yard-qty {
    font-size: var(--yard-compact-qty-font, 14px);
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 6mm;
  }

  html,
  body {
    width: 210mm;
    height: 297mm;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  body * {
    visibility: hidden !important;
  }

  #yardLayoutPage,
  #yardLayoutPage * {
    visibility: visible !important;
  }

  #yardLayoutPage {
    position: absolute;
    left: 0;
    top: 0;
    width: 198mm;
    height: 285mm;
    padding: 0 !important;
    margin: 0 !important;
    background: #fff !important;
    box-shadow: none !important;
  }

  .yard-layout-toolbar,
  .yard-layout-issue-summary,
  .yard-layout-message,
  nav,
  .no-print {
    display: none !important;
  }

  .yard-layout-canvas {
    width: 198mm;
    height: 285mm;
    min-height: 0;
    aspect-ratio: auto;
    border-color: #999;
    box-shadow: none;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .yard-box {
    width: calc(var(--yard-box-width, 78px) * 0.44);
    height: calc(var(--yard-box-height, 112px) * 0.45);
    padding: 11px 3px 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.25);
  }

  .yard-box.is-warning {
    box-shadow: 0 0 0 1px rgba(210, 0, 0, 0.9), 0 2px 4px rgba(0,0,0,0.25);
  }

  .yard-line {
    height: 17px;
  }

  .yard-name {
    font-size: calc(var(--yard-name-font, 18px) * 0.45);
    line-height: 1;
  }

  .yard-qty {
    margin-top: 2px;
    font-size: calc(var(--yard-qty-font, 17px) * 0.48);
  }

  .yard-box.is-compact {
    padding-top: 10px;
    padding-left: 2px;
    padding-right: 2px;
  }

  .yard-box.is-compact .yard-line {
    height: 18px;
  }

  .yard-box.is-compact .yard-name {
    font-size: calc(var(--yard-compact-name-font, 13px) * 0.5);
  }

  .yard-box.is-compact .yard-qty {
    margin-top: 1px;
    font-size: calc(var(--yard-compact-qty-font, 14px) * 0.52);
  }

  .yard-warning-mark {
    top: 0;
    right: 1px;
    font-size: 9px;
  }
}
