* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, sans-serif; font-size: 14px; color: #1a1a1a; background: #f4f4f5; }
.top { background: #fff; border-bottom: 1px solid #ddd; padding: 12px 16px; position: sticky; top: 0; z-index: 10; }
.top h1 { margin: 0 0 4px; font-size: 1.1rem; }
.nav-extra { margin: 0 0 10px; font-size: 12px; color: #64748b; }
.nav-extra a { color: #2563eb; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.toolbar input, .toolbar select { padding: 6px 10px; border: 1px solid #ccc; border-radius: 6px; background: #fff; }
.toolbar input[type="search"] { min-width: 200px; }
.toolbar select { min-width: 100px; }
.count { font-weight: 600; color: #334155; margin-left: auto; }
.danger, .action {
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: #fff;
}
.danger { background: #dc2626; }
.action { background: #2563eb; }
.action:disabled, .danger:disabled { opacity: 0.55; cursor: default; }

.review-layout {
  display: flex;
  align-items: stretch;
  min-height: calc(100vh - 120px);
  padding: 12px 16px 32px;
  gap: 0;
  transition: gap 0.2s ease;
}
.review-layout.preview-open { gap: 12px; }
.list-pane {
  flex: 1;
  min-width: 0;
  transition: flex 0.25s ease;
}
.review-layout.preview-open .preview-pane {
  flex: 0 0 48%;
  max-width: 48%;
}
.review-layout.preview-open .list-pane {
  flex: 1;
  min-width: 0;
}

.bundle-days {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: calc(100vh - 140px);
  overflow: auto;
}
.day-section {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}
/* 접힘·펼침 동일 헤더 위치 (날짜·통계 고정) */
.day-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: none;
  background: #f8fafc;
  cursor: pointer;
  text-align: left;
  font: inherit;
}
.day-header:hover { background: #f1f5f9; }
.day-section.open .day-header {
  border-bottom: 1px solid #e2e8f0;
  background: #fff;
}
.day-date { font-weight: 700; color: #0f172a; min-width: 110px; flex-shrink: 0; }
.day-meta { color: #64748b; font-size: 13px; flex: 1; min-width: 0; }
.day-chevron { color: #94a3b8; margin-left: auto; font-size: 12px; flex-shrink: 0; }
.day-body { padding: 0; }
.day-loading { padding: 12px 14px; color: #64748b; font-size: 13px; }
.day-table-wrap { overflow: auto; max-height: min(70vh, 720px); }
.preview-pane {
  flex: 0 0 0;
  width: 0;
  overflow: hidden;
  opacity: 0;
  transition: flex 0.25s ease, width 0.25s ease, opacity 0.2s ease;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
}
.review-layout.preview-open .preview-pane {
  width: auto;
  opacity: 1;
  min-width: 280px;
}
.preview-frame {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  min-height: 320px;
  background: #0f172a;
}
.preview-nav {
  position: absolute;
  top: 10px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 12px;
  z-index: 3;
  pointer-events: none;
}
.preview-nav .nav-btn, .preview-pos { pointer-events: auto; }
.nav-btn {
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  color: #1e293b;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}
.nav-btn:hover { background: #fff; }
.nav-btn:disabled { opacity: 0.4; cursor: default; }
.preview-pos { color: #e2e8f0; font-size: 13px; font-weight: 500; }
.preview-img {
  max-width: 100%;
  max-height: calc(100vh - 220px);
  object-fit: contain;
  border-radius: 4px;
}
.preview-caption {
  margin: 10px 0 0;
  font-size: 12px;
  color: #cbd5e1;
  text-align: center;
  max-width: 100%;
  word-break: break-all;
}
.preview-close {
  margin: 8px;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #f8fafc;
  cursor: pointer;
}

.review-grid { border-collapse: collapse; width: 100%; }
.review-grid th, .review-grid td { border-bottom: 1px solid #eee; padding: 8px 10px; vertical-align: top; }
.review-grid thead th { position: sticky; top: 0; background: #f8fafc; z-index: 2; font-weight: 600; }
.col-check { width: 36px; text-align: center; }
.col-photo { width: 100px; }
.col-body { min-width: 280px; }
.thumb {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 6px;
  background: #eee;
  display: block;
  cursor: pointer;
}
.thumb:hover { outline: 2px solid #2563eb; }
tr.row-active { background: #eff6ff; }
tr.row-active td { background: #eff6ff; }
.row-lines { display: flex; flex-direction: column; gap: 8px; }
.row-lines input, .row-lines select { padding: 4px 6px; border: 1px solid #ccc; border-radius: 4px; font-size: 13px; }
.line-file {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding-bottom: 4px;
  border-bottom: 1px solid #e2e8f0;
}
.line-file .file-label {
  flex: 1;
  min-width: 160px;
  font-size: 13px;
  color: #334155;
  word-break: break-all;
}
.item-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 8px;
  border-bottom: 1px dashed #e2e8f0;
}
.item-block:last-child { border-bottom: none; padding-bottom: 0; }
.line-meta, .line-price, .line-category { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.line-category input[data-f="카테고리번호"] { min-width: 100px; }
.line-category input[readonly] { background: #f8fafc; color: #475569; }
.line-category input[data-f="카테고리"] { min-width: 140px; flex: 1; }
.line-meta input[readonly] { background: #f1f5f9; color: #334155; }
.line-meta input, .line-price input { min-width: 88px; }
.line-meta input.w-name { min-width: 120px; flex: 1; }
.line-meta select { min-width: 88px; color: #334155; }
.line-meta .type-label { font-size: 13px; color: #475569; min-width: 52px; }
.line-price .in-date { min-width: 130px; color: #334155; }
.line-price .in-date:invalid { color: #94a3b8; }
.line-가격표 .pb-code { min-width: 72px; background: #f8fafc; color: #475569; }
.row-lines input::placeholder { color: #94a3b8; }
.row-lines input:disabled::placeholder { color: #cbd5e1; }
.line-ts { font-size: 12px; color: #64748b; white-space: nowrap; }
.line-file .badge { margin-left: auto; }
.badge { display: inline-block; padding: 2px 6px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.badge-ai { background: #dbeafe; color: #1d4ed8; }
.badge-manual { background: #f3f4f6; color: #6b7280; }
.badge-tick { background: #fef3c7; color: #92400e; }
.thumb-empty {
  width: 88px; height: 88px; border-radius: 6px; background: #f1f5f9;
  display: flex; align-items: center; justify-content: center; color: #94a3b8;
}
.photo-strip {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px;
  min-height: 36px; padding: 6px; border: 1px dashed #e2e8f0; border-radius: 6px;
}
.photo-strip.empty { border-style: solid; background: #fafafa; }
.photo-strip.drop-target { border-color: #2563eb; background: #eff6ff; }
.strip-thumb {
  position: relative; width: 52px; height: 52px; padding: 0; border: 1px solid #ddd;
  border-radius: 4px; overflow: hidden; cursor: grab; background: #eee;
}
.strip-thumb.dragging { opacity: 0.45; }
.strip-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.strip-type {
  position: absolute; left: 0; right: 0; bottom: 0;
  font-size: 9px; line-height: 1.2; text-align: center;
  background: rgba(15, 23, 42, 0.72); color: #fff;
}
.photo-expand {
  margin-top: 8px; padding: 10px; border: 1px solid #cbd5e1; border-radius: 8px; background: #f8fafc;
}
.expand-inner { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.expand-thumb {
  width: 160px; height: 160px; object-fit: cover; border-radius: 6px; cursor: pointer; background: #e2e8f0;
}
.expand-fields { flex: 1; min-width: 220px; }
tr.save-err input, tr.save-err select { border-color: #dc2626; }
.bundle-row.save-err input, .bundle-row.save-err select { border-color: #dc2626; }
.toast { position: fixed; bottom: 16px; right: 16px; background: #1f2937; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 100; }
.toast.err { background: #dc2626; }

@media (max-width: 900px) {
  .review-layout.preview-open { flex-direction: column; }
  .review-layout.preview-open .preview-pane {
    flex: none;
    max-width: none;
    min-height: 50vh;
    order: 1;
  }
  .review-layout.preview-open .list-pane {
    flex: none;
    max-height: 45vh;
    order: 2;
  }
}
