html, body {
  margin: 0;
  padding: 0;
  font-family: Arial, sans-serif;
  background: #f5f6f8;
  overflow-x: hidden;
}

* {
  box-sizing: border-box;
}

.page {
  padding: 8px;
}

h1 {
  font-size: 14px;
  margin: 0 0 8px;
}

.toolbar {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

button {
  border: 0;
  background: #1a73e8;
  color: white;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 11px;
}

button:disabled {
  background: #9aa0a6;
  cursor: not-allowed;
}

.status {
  font-size: 11px;
  color: #444;
}

.table-wrap {
  width: 100%;
  max-height: 78vh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: #fff;
  border-radius: 16px;
  padding: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.loading {
  padding: 20px;
  text-align: center;
  color: #666;
  font-size: 11px;
}

table {
  border-collapse: separate;
  border-spacing: 0;
  width: max-content;
  min-width: 100%;
  table-layout: fixed;
  background: #fff;
}

th,
td {
  border: 1px solid #dcdfe3;
  padding: 4px 6px;
  text-align: center;
  background: #fff;
  font-size: 11px;
  height: 42px;
}

/* 헤더 고정 */
thead th {
  position: sticky;
  top: 0;
  z-index: 30;
  background: #eef3fd;
  font-weight: 700;
  white-space: normal;
  word-break: keep-all;
  line-height: 1.15;
  height: auto;
  min-height: 42px;
  padding: 6px 4px;
}

/* 첫 번째 열: 품번 고정, 내용 기준으로 축소 */
.col-code {
  width: 88px;
  min-width: 88px;
  max-width: 88px;
}

thead .col-code {
  position: sticky;
  left: 0;
  z-index: 40;
  background: #eef3fd;
}

tbody .col-code {
  position: sticky;
  left: 0;
  z-index: 20;
  background: #f8f8f8;
}

/* 두 번째 열: 품명 고정, 너무 넓지 않게 */
.col-name {
  width: 135px;
  min-width: 135px;
  max-width: 135px;
  text-align: left;
}

thead .col-name {
  position: sticky;
  left: 88px;
  z-index: 41;
  background: #eef3fd;
}

tbody .col-name {
  position: sticky;
  left: 88px;
  z-index: 21;
  background: #f8f8f8;
  text-align: left;
}

/* 숫자 열: 헤더 줄바꿈 전제로 축소 */
.col-num {
  width: 78px;
  min-width: 78px;
  max-width: 78px;
}

td.readonly {
  background: #f1f3f4;
}

.item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 34px;
  padding: 0 4px;
  border: 1px solid #c7ccd1;
  border-radius: 10px;
  background: #fff;
  font-size: 11px;
}

.error,
select.error {
  outline: 2px solid #d93025;
  background: #fdecea;
}

.col-code,
.col-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 모바일 */
@media (max-width: 768px) {
  .page {
    padding: 6px;
  }

  h1 {
    font-size: 12px;
    margin-bottom: 6px;
  }

  .toolbar {
    gap: 4px;
    margin-bottom: 6px;
  }

  button {
    font-size: 10px;
    padding: 7px 10px;
    border-radius: 8px;
  }

  .status,
  .loading {
    font-size: 10px;
  }

  th,
  td {
    font-size: 9px;
    padding: 2px 3px;
    height: 34px;
  }

  .col-code {
    width: 64px;
    min-width: 64px;
    max-width: 64px;
  }

  .col-name {
    width: 80px;
    min-width: 80px;
    max-width: 80px;
  }

  .col-num {
    width: 48px;
    min-width: 48px;
    max-width: 48px;
  }

  thead .col-name,
  tbody .col-name {
    left: 64px;
  }

  select {
    font-size: 8px;
    height: 24px;
    padding: 0 1px;
    border-radius: 6px;
  }

  .item-name {
    font-size: 9px;
  }
}
