body {
  margin: 0;
  background: #f5f5f5;
}

.page {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 12px 12px 12px 0;
  /* 좌측은 페이지에 붙임 */
  min-height: calc(100vh - 60px);
}

.panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #e5e7eb;
  gap: 8px;
}

.panel-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: #333;
}

.panel-actions {
  display: flex;
  gap: 8px;
}

.panel-actions button {
  padding: 10px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-weight: 700;
}

.panel-actions button.primary {
  background: #2b2b2b;
  color: #fff;
  border-color: #2b2b2b;
}

.panel-actions button:disabled {
  opacity: .6;
  cursor: not-allowed;
}

.panel-body {
  padding: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid #e5e7eb;
  background: #fafafa;
}

.toolbar input[type="search"] {
  flex: 1;
  min-width: 160px;
  padding: 8px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}

/* 필터 패널 박스 */
.filter-panel {
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 6px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.filter-panel .filter-label {
  font-size: 13px;
  font-weight: 700;
  color: #666;
  white-space: nowrap;
}

.filter-panel .radio-group {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 0;
}

.filter-panel .radio-group label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #333;
  cursor: pointer;
  margin: 0;
}

.filter-panel .radio-group input[type="radio"] {
  margin: 0;
  cursor: pointer;
}

table.asset-table {
  width: 100%;
  border-collapse: collapse;
}

table.asset-table thead th {
  text-align: left;
  font-size: 13px;
  color: #666;
  font-weight: 700;
  border-bottom: 1px solid #e5e7eb;
  padding: 10px 12px;
}

table.asset-table tbody td {
  border-bottom: 1px solid #f0f0f0;
  padding: 10px 12px;
  font-size: 14px;
  color: #333;
}

table.asset-table tbody td.status-cell {
  padding: 4px 8px;
}

table.asset-table tbody td.status-cell .status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

table.asset-table tbody td.status-cell .status-badge.status-normal {
  background: #27811e;
}

table.asset-table tbody td.status-cell .status-badge.status-damage {
  background: #7f1d1d;
}

table.asset-table tbody td.status-cell .status-badge.status-fault {
  background: #dc2626;
}

table.asset-table tbody td.status-cell .status-badge.status-outbound {
  background: #0d6efd;
}

table.asset-table tbody td.status-cell .status-badge.status-sold {
  background: #000000;
}

table.asset-table tbody tr {
  background: #fff;
  cursor: pointer;
}

table.asset-table tbody tr:hover {
  background: #f9fafb;
}

table.asset-table tbody tr.selected {
  background: #fff3e9;
}

td.checkbox-cell,
th.checkbox-cell {
  width: 44px;
}

.empty {
  padding: 40px 20px;
  text-align: center;
  color: #777;
}

#assetNoteInput {
  border: 2px solid #000000;
}


.asset-sort-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: none;
  background: transparent;
  font: inherit;
  color: inherit;
  padding: 0;
  cursor: pointer;
}

.asset-sort-button:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

.asset-sort-button[data-sort-direction="asc"]::after {
  content: "▲";
  font-size: 11px;
  color: var(--accent-blue);
}

.asset-sort-button[data-sort-direction="desc"]::after {
  content: "▼";
  font-size: 11px;
  color: var(--accent-blue);
}

.asset-sort-button[data-sort-direction="none"]::after {
  content: "";
}






.radio-group {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.radio-group label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Generic toggle group (used for asset type and region) */
.toggle-group,
.region-toggle {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  width: 100%;
}

.toggle-group .toggle-btn,
.region-toggle .toggle-btn {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 6px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  transition: all 0.2s ease;
  color: #9ca3af;
  flex: 1 1 0;
}

.toggle-group .toggle-btn:hover,
.region-toggle .toggle-btn:hover {
  border-color: #6b7280;
  color: #6b7280;
}

.toggle-group .toggle-btn.active,
.region-toggle .toggle-btn.active {
  background: #374151;
  color: #fff;
  border-color: #374151;
  box-shadow: 0 4px 8px rgba(55, 65, 81, 0.25);
  font-size: 17px;
}

@media (max-width: 1080px) {

  .toggle-group,
  .region-toggle {
    flex-wrap: wrap;
  }
}

/* Inline panels for type + region */
.inline-panels-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 640px) {
  .inline-panels-row {
    grid-template-columns: 1fr;
  }
}

.inline-panel {
  border: 1px solid #f3f4f6;
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  display: grid;
  gap: 12px;
}

.inline-panel .panel-title {
  font-weight: 800;
  font-size: 14px;
  color: #333;
}

/* Required label style */
.required-label {
  color: #7f1d1d;
  font-weight: 800;
}

.stack-panels {
  display: grid;
  gap: 10px;
  margin-bottom: 8px;
}

/* Ensure clear separation between form and right panel */
.form-col {
  min-width: 0;
  padding-top: 10px;
  padding-right: 10px !important;
  /* Increased to ensure visibility */
}

.photo-col {
  min-width: 0;
  max-width: 100%;
  /* Removed left padding/border since it's now on the left */
}

/* Final row split: 수량/비고 vs 사진등록 */
.two-col-final {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 640px) {
  .two-col-final {
    grid-template-columns: 1fr;
  }
}

.photo-panel {
  border: 1px solid #f3f4f6;
  background: #fff;
  border-radius: 16px;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.photo-header {
  padding: 10px 12px;
  border-bottom: 1px solid #e5e7eb;
  font-weight: 800;
  font-size: 14px;
  color: #333;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.photo-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  min-height: 110px;
}

.photo-body .preview-frame {
  width: 100%;
  height: 100%;
  max-height: 180px;
  border: 1px dashed #e5e7eb;
  border-radius: 10px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #fafafa;
}

.photo-body img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.photo-empty {
  color: #888;
  font-size: 13px;
}

.photo-actions {
  padding: 0;
  border-top: none;
  display: flex;
  gap: 8px;
}

.btn-sm {
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  font-weight: 700;
  cursor: pointer;
  font-size: 13px;
}

.btn-sm.primary {
  background: #2b2b2b;
  color: #fff;
  border-color: #2b2b2b;
}

.btn-sm.gray {
  background: #6b7280;
  color: #fff;
  border-color: #6b7280;
}

#btnLinkEquipment {
  background: #cfe9ff;
  color: #0f3c64;
  border-color: #a7d4ff;
}

#btnLinkEquipment.is-unlink {
  background: #ffd9d9;
  color: #7f1d1d;
  border-color: #f5b5b5;
}

/* Keep photo box fixed size and fill (crop) */
.photo-col {
  display: grid;
  grid-template-rows: auto auto;
}

.photo-col .photos-grid {
  height: auto;
}

.photo-col .photo-box {
  aspect-ratio: 8 / 5.3;
  /* */
  height: auto;
  position: relative;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}

.photo-col .photo-box::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.0 1);
  pointer-events: none;
  z-index: 1;
}

.photo-col .photo-box:hover::after {
  opacity: 0;
}

.photo-col .photo-box img {
  object-fit: cover;
}

.photo-col .photo-box img {
  cursor: zoom-in;
}

/* Photo overlay - 정중앙 겹침 배치 */
.photo-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.7);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  z-index: 10;
}

.photo-box:hover .photo-overlay,
.photo-box.empty .photo-overlay {
  opacity: 1;
}

/* 사진이 없을 때는 배경 투명하게 */
.photo-box.empty .photo-overlay {
  background: transparent;
}

.photo-overlay button,
.photo-overlay input {
  pointer-events: auto;
}

/* Lightbox for photo preview */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 5000;
}

.lightbox.show {
  display: flex;
}

.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}



.radio-group {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.radio-group label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}


/* Mobile Optimizations */
@media (max-width: 768px) {
  .page {
    padding: 0;
    /* Full width on mobile */
  }

  .panel {
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .panel-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .toolbar {
    flex-wrap: wrap;
  }

  .toolbar input[type="search"] {
    width: 100%;
    min-width: 0;
  }

  .filter-panel {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .filter-panel .radio-group {
    flex-wrap: wrap;
  }

  /* Table scrolling */
  .panel-body {
    overflow-x: auto;
  }

  table.asset-table {
    min-width: 600px;
    /* Ensure table doesn't squash too much */
  }

  .photo-col {
    border-left: none;
    padding-left: 0;
    border-top: 1px solid #e5e7eb;
    padding-top: 16px;
  }
}

.btn {
  padding: 10px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  font-weight: 700;
  cursor: pointer;
}

.btn.primary {
  background: #28a745;
  color: #fff;
  border-color: #28a745;
}

.btn.danger {
  background: #b91c1c;
  color: #fff;
  border-color: #b91c1c;
}

.btn.gray {
  background: #6b7280;
  color: #fff;
  border-color: #6b7280;
}

@media (max-width: 720px) {
  .panel-actions {
    flex-wrap: wrap;
  }
}

/* Embed mode: hide page chrome and tighten spacing */
body.embed .topbar {
  display: none;
}

body.embed .page {
  padding: 0;
  min-height: auto;
}

body.embed .panel {
  border: none;
  box-shadow: none;
  border-radius: 0;
}

body.embed .panel-header {
  border-radius: 0;
}

body.embed .panel-body {
  padding: 0;
}

@media (max-width: 640px) {
  .asset-toolbar-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    width: 100%;
  }

  .asset-toolbar-actions button {
    width: 100%;
    justify-content: center;
  }
}