:root {
  color-scheme: light;
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-muted: #f1f5f9;
  --line: #d9dee7;
  --text: #18212f;
  --muted: #657084;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --warning: #b45309;
  --good: #15803d;
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  line-height: 1.45;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  min-height: 36px;
  padding: 0 12px;
}

button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px clamp(16px, 3vw, 36px);
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
  letter-spacing: 0;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.view-tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 8px;
  padding: 10px clamp(12px, 2vw, 24px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.tab-button {
  min-width: 104px;
  font-weight: 800;
}

.tab-button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

main {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 18px clamp(12px, 2vw, 24px) 36px;
}

.summary-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.summary-band div {
  min-width: 0;
  padding: 16px;
  background: var(--surface);
}

.summary-band strong {
  display: block;
  font-size: 28px;
  line-height: 1.1;
}

.summary-band span {
  color: var(--muted);
  font-size: 13px;
}

.controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px 180px 150px;
  gap: 12px;
  margin: 16px 0;
  align-items: end;
}

.controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
}

textarea {
  min-height: 70px;
  resize: vertical;
}

.product-name-input.name-edited,
.flea-price-input.price-edited,
.check-comment-input.comment-edited,
.synced-edited {
  border-color: #eab308;
  background: #fff7bf;
  box-shadow: 0 0 0 2px rgba(234, 179, 8, 0.18);
}

.readonly-value,
.readonly-note {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: #334155;
  padding: 8px 10px;
  overflow-wrap: anywhere;
}

.readonly-value {
  display: flex;
  align-items: center;
}

.readonly-note {
  min-height: 70px;
  color: var(--muted);
  white-space: pre-wrap;
}

.table-shell {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.view-panel[hidden] {
  display: none !important;
}

.table-head,
.item-row {
  display: grid;
  grid-template-columns: 116px minmax(250px, 1.35fr) 150px minmax(145px, 0.8fr) minmax(145px, 0.8fr) minmax(170px, 0.9fr) 142px;
  gap: 12px;
  align-items: start;
}

.table-head {
  position: sticky;
  top: 57px;
  z-index: 1;
  padding: 12px 14px;
  background: #eef2f6;
  border-bottom: 1px solid var(--line);
  color: #425166;
  font-size: 13px;
  font-weight: 800;
}

.item-list {
  min-height: 340px;
}

.item-row {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.item-row:last-child {
  border-bottom: 0;
}

.thumb-button,
.check-thumb-button {
  width: 104px;
  height: 104px;
  padding: 0;
  overflow: hidden;
  background: var(--surface-muted);
}

.thumb-button img,
.check-thumb-button img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.product-stack,
.price-stack,
.status-stack {
  display: grid;
  gap: 8px;
}

.labeled-cell::before {
  display: none;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 8px;
  background: #fff;
}

.badge.review {
  border-color: #fed7aa;
  background: #fff7ed;
  color: var(--warning);
}

.badge.done {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: var(--good);
}

.source-name {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.links a {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--accent-strong);
  padding: 0 8px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
}

.links a:hover {
  background: #ecfdf5;
  border-color: var(--accent);
}

.checklist-shell {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.checklist-head,
.checklist-row {
  display: grid;
  grid-template-columns: 116px minmax(220px, 0.9fr) minmax(260px, 1fr) minmax(260px, 1fr);
  gap: 12px;
  align-items: start;
}

.checklist-head {
  position: sticky;
  top: 57px;
  z-index: 2;
  padding: 12px 14px;
  background: #eef2f6;
  border-bottom: 1px solid var(--line);
  color: #425166;
  font-size: 13px;
  font-weight: 800;
}

.checklist-list {
  min-height: 340px;
}

.checklist-row {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.checklist-row:last-child {
  border-bottom: 0;
}

.check-product-stack,
.check-note-stack,
.check-comment-stack {
  display: grid;
  gap: 8px;
}

.check-price-chip {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  min-height: 28px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: #334155;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
}

.check-comment-input {
  min-height: 92px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 0 0;
}

#pageLabel {
  color: var(--muted);
  min-width: 80px;
  text-align: center;
}

dialog {
  width: min(92vw, 920px);
  border: 0;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.62);
}

.dialog-close {
  float: right;
  margin-bottom: 10px;
}

#dialogImage {
  display: block;
  max-width: 100%;
  max-height: 78vh;
  margin: 0 auto;
  object-fit: contain;
}

#dialogCaption {
  margin: 12px 0 0;
  color: var(--muted);
  text-align: center;
  overflow-wrap: anywhere;
}

@media (max-width: 1100px) {
  .app-header,
  .controls {
    grid-template-columns: 1fr;
  }

  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .table-head {
    display: none;
  }

  .checklist-head {
    display: none;
  }

  .item-row {
    grid-template-columns: 110px minmax(0, 1fr);
  }

  .checklist-row {
    grid-template-columns: 110px minmax(0, 1fr);
  }

  .item-row > :nth-child(n + 3) {
    grid-column: 2;
  }

  .checklist-row > :nth-child(n + 3) {
    grid-column: 2;
  }

  .labeled-cell {
    gap: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
  }

  .labeled-cell::before {
    display: block;
    content: attr(data-label);
    color: #425166;
    font-size: 12px;
    font-weight: 800;
  }

  .check-note-stack,
  .check-comment-stack {
    padding-top: 8px;
    border-top: 1px solid var(--line);
  }

  .check-note-stack::before,
  .check-comment-stack::before {
    display: block;
    color: #425166;
    font-size: 12px;
    font-weight: 800;
  }

  .check-note-stack::before {
    content: "확인사항";
  }

  .check-comment-stack::before {
    content: "코멘트";
  }
}

@media (max-width: 680px) {
  main {
    padding-inline: 10px;
  }

  .summary-band {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .item-row {
    grid-template-columns: 1fr;
  }

  .item-row > * {
    grid-column: auto !important;
  }

  .thumb-button,
  .check-thumb-button {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
  }
}

@media print {
  .app-header,
  .controls,
  .pagination,
  .view-tabs,
  .links,
  .source-name,
  dialog {
    display: none !important;
  }

  body {
    background: white;
  }

  main {
    width: 100%;
    padding: 0;
  }

  .table-shell {
    box-shadow: none;
    border: 0;
  }

  .item-row {
    break-inside: avoid;
  }
}
