/* 공통 스타일 — 상단 바, 그리드, 확대 보기, 관리자 화면 */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, "Malgun Gothic", sans-serif; background: #595959; color: #eee; }

.topbar {
  display: flex; justify-content: flex-end; padding: 8px 12px;
  position: sticky; top: 0; background: #595959; z-index: 30;
}
.col-btns { display: flex; gap: 8px; align-items: center; }
.col-btn {
  width: 34px; height: 34px; border: 1px solid #999; background: #6e6e6e; color: #fff;
  font-size: 15px; cursor: pointer; border-radius: 4px;
}
.col-btn.selected { opacity: 0.35; }
.login-icon { font-size: 22px; text-decoration: none; margin-left: 6px; }

.banner { width: 100%; }
.banner img { width: 100%; display: block; }

.grid { display: grid; gap: 10px; padding: 10px; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-6 { grid-template-columns: repeat(6, 1fr); }
.grid.cols-9 { grid-template-columns: repeat(9, 1fr); }
.grid img {
  width: 100%; aspect-ratio: 3 / 4; object-fit: cover; display: block; cursor: pointer;
  border-radius: 8px; box-shadow: 4px 4px 8px rgba(0,0,0,.45);
}

/* 확대 보기 (라이트박스) — 상단 바(3/6/9)는 그대로 노출 */
#lightbox {
  position: fixed; top: 50px; left: 0; right: 0; bottom: 0;
  background: #111; z-index: 20; display: flex; flex-direction: column;
}
#lightbox[hidden] { display: none; }
body.lb-open { overflow: hidden; }
#lb-stage { flex: 1 1 0; min-height: 0; overflow: auto; display: flex; }
#lb-stage img { display: block; max-width: none; margin: auto; }
#lb-back {
  position: absolute; top: 8px; left: 8px; z-index: 22;
  width: 40px; height: 40px; font-size: 20px; border: none; border-radius: 50%;
  background: rgba(255,255,255,.85); cursor: pointer;
}
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 22;
  width: 44px; height: 64px; font-size: 30px; border: none;
  background: rgba(255,255,255,.5); cursor: pointer;
}
#lb-prev { left: 0; }
#lb-next { right: 0; }
@media (hover: none) { .lb-nav { display: none; } } /* 폰은 스와이프로 이동 */
#lb-bar {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: #222; flex-shrink: 0;
}
#lb-bar button {
  width: 36px; height: 36px; font-size: 18px; border: none; border-radius: 4px;
  background: #eee; cursor: pointer;
}
#lb-slider { flex: 1; }
#lb-download { color: #fff; text-decoration: none; border: 1px solid #888; padding: 6px 12px; border-radius: 4px; }
#lb-bar #lb-share { width: auto; height: auto; color: #fff; background: none; border: 1px solid #888; padding: 6px 12px; border-radius: 4px; font-size: 14px; }
@media (hover: none) { #lb-minus, #lb-plus, #lb-slider { display: none; } } /* 폰은 핀치로 줌 */
@media (hover: none) { #lb-bar { justify-content: flex-end; } }

.login-wrap { max-width: 320px; margin: 80px auto; display: flex; flex-direction: column; gap: 10px; }
.login-wrap input, .login-wrap button { padding: 10px; font-size: 15px; width: 100%; }
.error { color: #c00; }

/* 관리자/결재자 공통 */
.admin-bar { justify-content: space-between; align-items: center; border-bottom: 1px solid #777; }
.tabs { display: flex; gap: 4px; }
.tabs a {
  padding: 8px 14px; text-decoration: none; color: #eee;
  border: 1px solid #888; border-bottom: none; border-radius: 6px 6px 0 0;
}
.tabs a.active { background: #222; color: #fff; }
.tabs-right { display: flex; gap: 12px; align-items: center; }
.tabs-right a { color: #ddd; text-decoration: none; font-size: 14px; }

.admin-main { max-width: 860px; margin: 0 auto; padding: 12px; }
.card { border: 1px solid #777; border-radius: 8px; padding: 14px; margin-bottom: 16px; background: #fff; color: #222; }
.card h2 { font-size: 17px; margin-bottom: 10px; }
.card h3 { font-size: 15px; margin: 10px 0 6px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.hint { color: #ccc; font-size: 13px; margin: 6px 0; }
.card .hint { color: #777; }
button.primary { background: #2563eb; color: #fff; border: none; }
.card button, .order-head button {
  padding: 8px 14px; font-size: 14px; border: 1px solid #bbb; border-radius: 6px;
  background: #f5f5f5; cursor: pointer;
}
.card button.primary { background: #2563eb; color: #fff; border: none; }
button.mini { padding: 2px 8px; font-size: 12px; }
.preview-thumb { width: 180px; aspect-ratio: 3/4; object-fit: cover; display: block; margin: 8px 0; }
.approved-row { display: flex; gap: 10px; align-items: center; padding: 6px 0; }

/* 크롭 모달 */
#crop-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.75); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 10px;
}
#crop-modal[hidden] { display: none; }
.crop-wrap { background: #fff; border-radius: 8px; padding: 12px; max-width: 720px; width: 100%; }
#crop-area { position: relative; touch-action: none; user-select: none; overflow: hidden; }
#crop-area img { width: 100%; max-height: 60vh; object-fit: contain; display: block; pointer-events: none; }
#crop-box {
  position: absolute; border: 2px solid #2563eb; box-shadow: 0 0 0 9999px rgba(0,0,0,.45);
  cursor: move;
}
#crop-size { width: 100%; margin: 10px 0; }

/* 순번 표시(반투명)와 수정본 비교 */
.version { position: relative; }
.version img { width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block; }
.version .num {
  position: absolute; top: 6px; left: 6px; z-index: 2;
  background: rgba(0,0,0,.45); color: #fff; border-radius: 4px;
  padding: 2px 8px; font-size: 15px;
}
.version .rev-label {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  background: rgba(37,99,235,.75); color: #fff; border-radius: 4px;
  padding: 2px 8px; font-size: 12px;
}
.version.selectable { cursor: pointer; }
.version.selectable:hover { outline: 3px solid #2563eb; }

.seq-row { margin: 10px 0; }
.versions { display: flex; gap: 6px; }
.versions.multi { overflow-x: auto; scroll-snap-type: x mandatory; }
.versions.multi .version { flex: 0 0 48%; scroll-snap-align: start; }
.versions.multi .version img { aspect-ratio: auto; object-fit: contain; }
@media (max-width: 700px) {
  .versions.multi .version { flex: 0 0 100%; } /* 폰: 좌우 스와이프로 번갈아 보기 */
}
.versions:not(.multi) .version { max-width: 240px; }

.batch-head .spacer { flex: 1; }
.status { font-size: 13px; padding: 2px 8px; border-radius: 4px; background: #eee; }
.status-pending { background: #fef3c7; }
.status-approved { background: #dcfce7; }
.status-rejected { background: #fee2e2; }

.order-head { justify-content: space-between; }
#order-grid img { cursor: grab; }
.user-table { width: 100%; border-collapse: collapse; }
.user-table th, .user-table td { border-bottom: 1px solid #eee; padding: 8px 6px; text-align: left; font-size: 14px; }

/* 위치 수정 — 이미지 삭제 버튼 */
.order-item { position: relative; }
.order-item .del {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  width: 26px; height: 26px; line-height: 1; font-size: 15px;
  border: none; border-radius: 50%; background: rgba(220,38,38,.85); color: #fff; cursor: pointer;
}
